From 4248917aab1fa31b1f48538762ade6440763bfd3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 10 Sep 2024 20:46:13 +0300 Subject: [PATCH] fix SurroundMap --- src/world/generator/SurroundMap.cpp | 4 ++-- src/world/generator/SurroundMap.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/world/generator/SurroundMap.cpp b/src/world/generator/SurroundMap.cpp index 8017758f..7fed03f2 100644 --- a/src/world/generator/SurroundMap.cpp +++ b/src/world/generator/SurroundMap.cpp @@ -12,7 +12,7 @@ SurroundMap::SurroundMap(int loadDistance, int8_t maxLevel) {} void SurroundMap::setLevelCallback(int8_t level, LevelCallback callback) { - auto& wrapper = levelCallbacks.at(level); + auto& wrapper = levelCallbacks.at(level - 1); wrapper.callback = callback; wrapper.active = callback != nullptr; } @@ -22,7 +22,7 @@ void SurroundMap::setOutCallback(util::AreaMap2D::OutCallback callback) } void SurroundMap::upgrade(int x, int y, int8_t level) { - auto& callback = levelCallbacks[level]; + auto& callback = levelCallbacks[level - 1]; int size = maxLevel - level + 1; for (int ly = -size+1; ly < size; ly++) { for (int lx = -size+1; lx < size; lx++) { diff --git a/src/world/generator/SurroundMap.hpp b/src/world/generator/SurroundMap.hpp index a7af02dd..31bafc52 100644 --- a/src/world/generator/SurroundMap.hpp +++ b/src/world/generator/SurroundMap.hpp @@ -14,7 +14,7 @@ public: using LevelCallback = std::function; struct LevelCallbackWrapper { LevelCallback callback; - bool active; + bool active = false; }; private: util::AreaMap2D areaMap;