Page 1 of 1

1.3.3 Structure_Create bug

Posted: Sun Jun 14, 2020 7:28 pm
by n0b0dy007
After updating, and purchasing/installing the DLC, continued an existing save game. May be an odd corner case.
DebugBreak in Structure.bsf/Structure_Create() with an invalid(0) regionID. GetScriptStack() shows:

Code: Select all

Structure_Create in D:/SteamLibrary/steamapps/common/Field of Glory Empires/Data/Scripts/MAP.BSF
Province_CheckCapitol @ 22915
Region_EndTurnUpdate_All @ 70070
Host_ResolveEndTurn @ 86001
Host_ResolveEndOfImpulse_PostBattle @ 85919
Host_Battle_ProcessRemaining @ 86429
Host_ResolveEndOfImpulse_PreBattle @ 85862
Host_ResolveTurnSingleTick @ 85838
UpdateMap @ 112644
I didn't find the cause (but I didn't look too exhaustively, either :roll: ), so I patched Structure.bsf with a precondition check to log and ignore the error:

Code: Select all

	if ((factionID <= 0) || (regionID <= 0) || (strucTplID <= 0))	// @FIXME
	{
		GetScriptStack(0);
		TraceLog("ERROR in Structure_Create(), Stack:\n%w", 0);
		return
	}
	strucID = CreateStructure(factionID, regionID, strucTplID); // UNIQUE: if searched, only this line must be found in all scripts
trace.log and old/new Structure.bsf included in attached CreateStruct.zip.