mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
realtime map resizing
This commit is contained in:
parent
3cb8091b11
commit
f67cb9ce78
4 changed files with 23 additions and 7 deletions
|
|
@ -40,7 +40,7 @@ class DynamicLight
|
|||
def update
|
||||
# dont render light if its disabled or not awaked
|
||||
@light_sprite.visible = Settings[:light] && $light.awaked
|
||||
if (!Settings[:light] && $light.awaked)
|
||||
if !Settings[:light] || !$light.awaked
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ class Game_Map
|
|||
tile_id = data[x, y, i]
|
||||
if tile_id == nil
|
||||
next #return 0
|
||||
elsif @terrain_tags[tile_id] > 0
|
||||
elsif @terrain_tags[tile_id] && @terrain_tags[tile_id] > 0
|
||||
return @terrain_tags[tile_id]
|
||||
end
|
||||
end
|
||||
|
|
@ -549,4 +549,9 @@ class Game_Map
|
|||
end
|
||||
@map.data[x, y, z]
|
||||
end
|
||||
def resize(x, y, z)
|
||||
@map.data.resize(x, y, z)
|
||||
@map.width = x
|
||||
@map.height = y
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ void Table::resize(int x, int y, int z){
|
|||
|
||||
std::vector<int16_t> newData(x*y*z);
|
||||
|
||||
for (int k = 0; k < std::min(z, zs); ++k)
|
||||
for (int j = 0; j < std::min(y, ys); ++j)
|
||||
for (int i = 0; i < std::min(x, xs); ++i)
|
||||
for (int k = 0; k < z; ++k)
|
||||
for (int j = 0; j < y; ++j)
|
||||
for (int i = 0; i < x; ++i)
|
||||
newData[x*y*k + x*j + i] = at(i, j, k);
|
||||
|
||||
data.swap(newData);
|
||||
|
|
|
|||
15
src/table.h
15
src/table.h
|
|
@ -52,11 +52,22 @@ public:
|
|||
|
||||
/* <internal */
|
||||
inline int16_t &at(int x, int y = 0, int z = 0){
|
||||
return data[xs*ys*z + xs*y + x];
|
||||
int pos = xs*ys*z + xs*y + x;
|
||||
if (pos >= 0 && pos < data.size()) {
|
||||
return data[pos];
|
||||
}
|
||||
static int16_t dummy = 0;
|
||||
dummy = 0;
|
||||
return dummy;
|
||||
}
|
||||
|
||||
inline const int16_t &at(int x, int y = 0, int z = 0) const{
|
||||
return data[xs*ys*z + xs*y + x];
|
||||
int pos = xs*ys*z + xs*y + x;
|
||||
if (pos >= 0 && pos < data.size()) {
|
||||
return data[pos];
|
||||
}
|
||||
static const int16_t fallback = 0;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
sigc::signal<void> modified;
|
||||
|
|
|
|||
Loading…
Reference in a new issue