From acd041362608090fce28e2a5df647ff55e03177a Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 18 Apr 2024 23:02:22 +0300 Subject: [PATCH] Check that save file have the same amount of cities --- src/worldmap.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/worldmap.cc b/src/worldmap.cc index a913665..a840354 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -1158,6 +1158,15 @@ int wmWorldMap_load(File* stream) int numCities; if (fileReadInt32(stream, &numCities) == -1) return -1; + bool isCitiesLimitFixEnabled = true; + configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, &isCitiesLimitFixEnabled); + if (isCitiesLimitFixEnabled && numCities != wmMaxAreaNum) { + debugPrint("WorldMap Error: Cities limit fix is enabled, " + "but the number of cities in the save file is different from " + "the number of cities in the worldmap.txt file."); + return -1; + } + for (int areaIdx = 0; areaIdx < numCities; areaIdx++) { CityInfo* city = &(wmAreaInfoList[areaIdx]);