From 43863393544654db3845de69fa106cc0bb0b12b7 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 21 Aug 2024 18:19:58 +0000 Subject: [PATCH] Fix crash on rmg generation (regression from previous commit) --- lib/gameState/CGameState.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index 8353be1c7..a99f5fe29 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -312,11 +312,10 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan std::unique_ptr randomMap = mapGenerator.generate(); progressTracking.exclude(mapGenerator); - map = randomMap.release(); // Update starting options - for(int i = 0; i < map->players.size(); ++i) + for(int i = 0; i < randomMap->players.size(); ++i) { - const auto & playerInfo = map->players[i]; + const auto & playerInfo = randomMap->players[i]; if(playerInfo.canAnyonePlay()) { PlayerSettings & playerSettings = scenarioOps->playerInfos[PlayerColor(i)]; @@ -363,6 +362,8 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan } } + map = randomMap.release(); + logGlobal->info("Generated random map in %i ms.", sw.getDiff()); } else