From f67cb9ce7802c390578beb0b0fdd07a127b6ebfc Mon Sep 17 00:00:00 2001 From: Issac332 <119879937+Issac8658@users.noreply.github.com> Date: Sat, 11 Jul 2026 23:16:34 +0300 Subject: [PATCH] realtime map resizing --- scripts/DynamicLight.rb | 2 +- scripts/Game_Map.rb | 7 ++++++- src/table.cpp | 6 +++--- src/table.h | 15 +++++++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/scripts/DynamicLight.rb b/scripts/DynamicLight.rb index c71a130..6de65ff 100644 --- a/scripts/DynamicLight.rb +++ b/scripts/DynamicLight.rb @@ -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 diff --git a/scripts/Game_Map.rb b/scripts/Game_Map.rb index 9e373c9..6e38592 100644 --- a/scripts/Game_Map.rb +++ b/scripts/Game_Map.rb @@ -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 diff --git a/src/table.cpp b/src/table.cpp index 57c610c..5d1d9c0 100644 --- a/src/table.cpp +++ b/src/table.cpp @@ -62,9 +62,9 @@ void Table::resize(int x, int y, int z){ std::vector 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); diff --git a/src/table.h b/src/table.h index a866aa6..c222b3a 100644 --- a/src/table.h +++ b/src/table.h @@ -52,11 +52,22 @@ public: /* = 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 modified;