diff --git a/rts/Game/Game.cpp b/rts/Game/Game.cpp index 07dfe07f80..1ca90d6fa0 100644 --- a/rts/Game/Game.cpp +++ b/rts/Game/Game.cpp @@ -440,6 +440,7 @@ void CGame::Load(const std::string& mapFileName) ENTER_SYNCED_CODE(); eventHandler.GamePreload(); eventHandler.CollectGarbage(true); + readMap->UpdateHeightBounds(); //needed in case pre-game terraform changed the map LEAVE_SYNCED_CODE(); } diff --git a/rts/Map/ReadMap.cpp b/rts/Map/ReadMap.cpp index 114ec1e2f0..60d9d84edb 100644 --- a/rts/Map/ReadMap.cpp +++ b/rts/Map/ReadMap.cpp @@ -746,6 +746,22 @@ void CReadMap::UpdateHeightBounds(int syncFrame) #endif } +void CReadMap::UpdateHeightBounds() +{ + const float* heightmap = GetCornerHeightMapSynced(); + + tempHeightBounds.x = std::numeric_limits::max(); + tempHeightBounds.y = std::numeric_limits::lowest(); + + for (int i = 0; i < (mapDims.mapxp1 * mapDims.mapyp1); ++i) { + tempHeightBounds.x = std::min(tempHeightBounds.x, heightmap[i]); + tempHeightBounds.y = std::max(tempHeightBounds.y, heightmap[i]); + } + + currHeightBounds.x = tempHeightBounds.x; + currHeightBounds.y = tempHeightBounds.y; +} + void CReadMap::UpdateCenterHeightmap(const SRectangle& rect, bool initialize) { const float* heightmapSynced = GetCornerHeightMapSynced(); diff --git a/rts/Map/ReadMap.h b/rts/Map/ReadMap.h index 5017843fbd..af944ad02f 100644 --- a/rts/Map/ReadMap.h +++ b/rts/Map/ReadMap.h @@ -208,6 +208,7 @@ class CReadMap unsigned int CalcHeightmapChecksum(); unsigned int CalcTypemapChecksum(); + void UpdateHeightBounds(); private: void InitHeightBounds(); void UpdateHeightBounds(int syncFrame);