Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sfall CitiesLimitFix to fix Resurrection startup #361

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions src/sfall_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down
1 change: 1 addition & 0 deletions src/sfall_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ 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
Expand Down
20 changes: 15 additions & 5 deletions src/worldmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -838,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) {
Expand Down Expand Up @@ -865,10 +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);

// 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
Expand Down Expand Up @@ -1158,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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the game has more cities than save file. For example, the mod was updated but it just added new cities. Is it possible to change this condition to numCities > wmMaxAreaNum to support this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I removed this part

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen now if numCities > wmMaxAreaNum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested, but I have a gut feeling that it will be fine. SFall have this patch enabled by default and nothing happened.
Let's maybe keep a warning there

}

for (int areaIdx = 0; areaIdx < numCities; areaIdx++) {
CityInfo* city = &(wmAreaInfoList[areaIdx]);

Expand Down Expand Up @@ -2530,7 +2540,7 @@ static int wmAreaInit()

configFree(&cfg);

if (wmMaxAreaNum != CITY_COUNT) {
if (!gCitiesLimitFix && wmMaxAreaNum != CITY_COUNT) {
showMesageBox("\nwmAreaInit::Error loading Cities!");
exit(1);
}
Expand Down