From 252d7fe83e63084c2492136a7c17fd4f826b9b3c Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 18 Apr 2024 22:51:45 +0300 Subject: [PATCH 01/10] Add CitiesLimitFix into sFall config with default=true --- src/sfall_config.cc | 6 +++++- src/sfall_config.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sfall_config.cc b/src/sfall_config.cc index f3689052..027f2b8a 100644 --- a/src/sfall_config.cc +++ b/src/sfall_config.cc @@ -61,6 +61,7 @@ bool sfallConfigInit(int argc, char** argv) configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_VERSION_STRING, ""); configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONFIG_FILE, ""); configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PATCH_FILE, ""); + configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, true); configSetString(&gSfallConfig, SFALL_CONFIG_SCRIPTS_KEY, SFALL_CONFIG_INI_CONFIG_FOLDER, ""); configSetString(&gSfallConfig, SFALL_CONFIG_SCRIPTS_KEY, SFALL_CONFIG_GLOBAL_SCRIPT_PATHS, ""); @@ -76,7 +77,10 @@ bool sfallConfigInit(int argc, char** argv) strcpy(path, SFALL_CONFIG_FILE_NAME); } - configRead(&gSfallConfig, path, false); + bool isSfallConfigExists = configRead(&gSfallConfig, path, false); + if (!isSfallConfigExists){ + configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, false); + } configParseCommandLineArguments(&gSfallConfig, argc, argv); diff --git a/src/sfall_config.h b/src/sfall_config.h index 7d4b2fb0..4de30ed6 100644 --- a/src/sfall_config.h +++ b/src/sfall_config.h @@ -75,6 +75,8 @@ namespace fallout { #define SFALL_CONFIG_VERSION_STRING "VersionString" #define SFALL_CONFIG_CONFIG_FILE "ConfigFile" #define SFALL_CONFIG_PATCH_FILE "PatchFile" +#define SFALL_CONFIG_CITIES_LIMIT_FIX "CitiesLimitFix" + #define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1 #define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3 From 22a864a0c9fefa56209f7f0e6e62667ba10c7eb7 Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 18 Apr 2024 22:55:17 +0300 Subject: [PATCH 02/10] Ignore cities count if CitiesLimitFix is enabled --- src/worldmap.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/worldmap.cc b/src/worldmap.cc index 4d2495f0..a9136658 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -2530,7 +2530,10 @@ static int wmAreaInit() configFree(&cfg); - if (wmMaxAreaNum != CITY_COUNT) { + bool isCitiesLimitFixEnabled = true; + configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, &isCitiesLimitFixEnabled); + + if (!isCitiesLimitFixEnabled && wmMaxAreaNum != CITY_COUNT) { showMesageBox("\nwmAreaInit::Error loading Cities!"); exit(1); } From 196ad2267feab770da63c276f7498f00cc8cbc66 Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 18 Apr 2024 22:59:24 +0300 Subject: [PATCH 03/10] Fix formatting --- src/sfall_config.cc | 2 +- src/sfall_config.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sfall_config.cc b/src/sfall_config.cc index 027f2b8a..7dffc18b 100644 --- a/src/sfall_config.cc +++ b/src/sfall_config.cc @@ -78,7 +78,7 @@ bool sfallConfigInit(int argc, char** argv) } bool isSfallConfigExists = configRead(&gSfallConfig, path, false); - if (!isSfallConfigExists){ + if (!isSfallConfigExists) { configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, false); } diff --git a/src/sfall_config.h b/src/sfall_config.h index 4de30ed6..ff0ae8ee 100644 --- a/src/sfall_config.h +++ b/src/sfall_config.h @@ -77,7 +77,6 @@ namespace fallout { #define SFALL_CONFIG_PATCH_FILE "PatchFile" #define SFALL_CONFIG_CITIES_LIMIT_FIX "CitiesLimitFix" - #define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1 #define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3 #define SFALL_CONFIG_BURST_MOD_DEFAULT_TARGET_MULTIPLIER 1 From acd041362608090fce28e2a5df647ff55e03177a Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 18 Apr 2024 23:02:22 +0300 Subject: [PATCH 04/10] 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 a9136658..a8403543 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]); From db07e95f5b4d2972f24dfb18ce175d91848d4a4c Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 18 Apr 2024 23:10:56 +0300 Subject: [PATCH 05/10] Use gCitiesLimitFix variable --- src/worldmap.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/worldmap.cc b/src/worldmap.cc index a8403543..f281deaa 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -813,6 +813,7 @@ static int wmMaxEncBaseTypes; static int wmMaxEncounterInfoTables; static bool gTownMapHotkeysFix; +static bool gCitiesLimitFix; static double gGameTimeIncRemainder = 0.0; static FrmImage _backgroundFrmImage; static FrmImage _townFrmImage; @@ -869,6 +870,9 @@ int wmWorldMap_init() gTownMapHotkeysFix = true; configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_TOWN_MAP_HOTKEYS_FIX_KEY, &gTownMapHotkeysFix); + gCitiesLimitFix = true; + configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, &gCitiesLimitFix); + // CE: City size fids should be initialized during startup. They are used // during |wmTeleportToArea| to calculate worldmap position when jumping // from Temple to Arroyo - before giving a chance to |wmInterfaceInit| to @@ -1158,9 +1162,7 @@ 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) { + if (gCitiesLimitFix && 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."); @@ -2539,10 +2541,7 @@ static int wmAreaInit() configFree(&cfg); - bool isCitiesLimitFixEnabled = true; - configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, &isCitiesLimitFixEnabled); - - if (!isCitiesLimitFixEnabled && wmMaxAreaNum != CITY_COUNT) { + if (!gCitiesLimitFix && wmMaxAreaNum != CITY_COUNT) { showMesageBox("\nwmAreaInit::Error loading Cities!"); exit(1); } From ea66287551042fa4b1d461a6384320f4c2d18cba Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 18 Apr 2024 23:23:41 +0300 Subject: [PATCH 06/10] Load gCitiesLimitFix state before it is used --- src/worldmap.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/worldmap.cc b/src/worldmap.cc index f281deaa..a828d6d6 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -839,6 +839,12 @@ static void wmSetFlags(int* flagsPtr, int flag, int value) // 0x4BC89C int wmWorldMap_init() { + // SFALL + gTownMapHotkeysFix = true; + configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_TOWN_MAP_HOTKEYS_FIX_KEY, &gTownMapHotkeysFix); + gCitiesLimitFix = true; + configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, &gCitiesLimitFix); + char path[COMPAT_MAX_PATH]; if (wmGenDataInit() == -1) { @@ -866,13 +872,6 @@ int wmWorldMap_init() wmMarkSubTileRadiusVisited(wmGenData.worldPosX, wmGenData.worldPosY); wmWorldMapSaveTempData(); - // SFALL - gTownMapHotkeysFix = true; - configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_TOWN_MAP_HOTKEYS_FIX_KEY, &gTownMapHotkeysFix); - - gCitiesLimitFix = true; - configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, &gCitiesLimitFix); - // CE: City size fids should be initialized during startup. They are used // during |wmTeleportToArea| to calculate worldmap position when jumping // from Temple to Arroyo - before giving a chance to |wmInterfaceInit| to From e119aa4c4d45adef1808258d4b447f492c7181e5 Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Fri, 19 Apr 2024 12:55:51 +0300 Subject: [PATCH 07/10] Use cities limit patch by default --- src/sfall_config.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/sfall_config.cc b/src/sfall_config.cc index 7dffc18b..12c5db31 100644 --- a/src/sfall_config.cc +++ b/src/sfall_config.cc @@ -77,10 +77,7 @@ bool sfallConfigInit(int argc, char** argv) strcpy(path, SFALL_CONFIG_FILE_NAME); } - bool isSfallConfigExists = configRead(&gSfallConfig, path, false); - if (!isSfallConfigExists) { - configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CITIES_LIMIT_FIX, false); - } + configRead(&gSfallConfig, path, false); configParseCommandLineArguments(&gSfallConfig, argc, argv); From e676089f834a5a6cb880672b286faa6e1bc1ea3e Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Tue, 4 Jun 2024 19:43:37 +0300 Subject: [PATCH 08/10] Remove cities amount check on game load --- src/worldmap.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/worldmap.cc b/src/worldmap.cc index a828d6d6..44aedf76 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -1161,13 +1161,6 @@ int wmWorldMap_load(File* stream) int numCities; if (fileReadInt32(stream, &numCities) == -1) return -1; - if (gCitiesLimitFix && 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]); From 2ca921c5252e9c495d546328db9cdf1186d426db Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Tue, 4 Jun 2024 20:50:03 +0300 Subject: [PATCH 09/10] Revert "Remove cities amount check on game load" This reverts commit e676089f834a5a6cb880672b286faa6e1bc1ea3e. --- src/worldmap.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/worldmap.cc b/src/worldmap.cc index 44aedf76..a828d6d6 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -1161,6 +1161,13 @@ int wmWorldMap_load(File* stream) int numCities; if (fileReadInt32(stream, &numCities) == -1) return -1; + if (gCitiesLimitFix && 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]); From 41a7c97e69602bc4ec870bac5dd2a9afdc4b8618 Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Tue, 4 Jun 2024 20:56:42 +0300 Subject: [PATCH 10/10] Show warning if cities amount differs --- src/worldmap.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/worldmap.cc b/src/worldmap.cc index a828d6d6..4bfb5e93 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -1163,9 +1163,9 @@ int wmWorldMap_load(File* stream) if (gCitiesLimitFix && 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; + "but the number of cities %d in the save file is different from " + "the number of cities %d in the worldmap.txt file.", + numCities, wmMaxAreaNum); } for (int areaIdx = 0; areaIdx < numCities; areaIdx++) {