My Dark Soul MOD crashed after certain turns. Could you guys help me find out the reason?

KCucumber

Chieftain
Joined
Aug 8, 2017
Messages
3
I spend a lot of time create the dark soul mod. but I find that the mod just crashed after certain turns (around 100 turns) every time...and I cannot find the reason...
I have created some other MODs before, but none of them have the same problem. I am pretty sure the codes are correct. And there is no error in logs after the game crashed... so I have no idea how to fix it...
I checked all my codes, artdef setting, pictures, everything should be correct.
I have no idea what can I do now... Could you guys help find out the reason? I think it is a kind of game's bug...

Here is the link to my mod: http://steamcommunity.com/sharedfiles/filedetails/?id=1100902799
and a save data one turn before game crashed is also attached with this question.

please help me have a look... Thanks
 

Attachments

I am also on this project creating the undead unit and equipment, firelink shrine and bonfire models. On selection of unit play custom animation (yep the question I asked in another thread, and I made it!). Pretty fun work with KCucumber. He is very imaginative and the Mod design is crazy. But this crash bug ruins it all.

I tried to turn off all the artdefs /XLPs to see if it's because of arts but no. With all question-mark-icons and Teddy on loading, game still crashed.
We also tried to observe on whose turn it crashed, expecting some specific AI behavior. But out of different rounds of testing, game crashed on entering my turn, one of the AI turn, and even barbarian turn... Game crashed after declared war, units combating, or all at peace, units fortified and doing absolutely nothing. Really random but fixed turn to crash in the same game.

In crash dump I found these lines that might be what was happening but not really sure:
crashDump.png

And all the logs don't have any information about why it crashed. LUA console says couldn't find individual great person icon so used generic instead. I guess that doesn't matter, it's not an exception so it wouldn't crash the game.

@LeeS ,@Gedemon sorry to bother you guys but please help us. Thanks!
 
there is no easy way until we get dll access and VS debugging (and even then, if it's really related to the graphic engine, IMO we won't have access to that)

here's how I debug such crashes ATM...

test one save with a reproductible crash (same turn, same player) only until you found what make it crashes:
- use the tuner to find during which civ's turn it crashes
- reveal the map to see if it's about to capture a city
- register to all event to see what was the las action that doesn't crash
- remove units and city from the map before it's turn
- look at what the the cities are building

etc...
 
there is no easy way until we get dll access and VS debugging (and even then, if it's really related to the graphic engine, IMO we won't have access to that)

here's how I debug such crashes ATM...

test one save with a reproductible crash (same turn, same player) only until you found what make it crashes:
- use the tuner to find during which civ's turn it crashes
- reveal the map to see if it's about to capture a city
- register to all event to see what was the las action that doesn't crash
- remove units and city from the map before it's turn
- look at what the the cities are building

etc...
Thanks very much for you kindly reply
I will try as what you say. Sounds like you also met this kind of crash problem when you making your mod. could you please share some experience about how you fixed them?
 
First was linked to city capture, a patch of the game fixed it (it was reported by ynamp users but was not caused by the mod)

Second was also linked to city capture in one of my mod, but had 2 different causes, see commits of 13 jun. and 20 jun. here: https://github.com/Gedemon/Civ6-GCO/commits/master
 
there is no easy way until we get dll access and VS debugging (and even then, if it's really related to the graphic engine, IMO we won't have access to that)

here's how I debug such crashes ATM...

test one save with a reproductible crash (same turn, same player) only until you found what make it crashes:
- use the tuner to find during which civ's turn it crashes
- reveal the map to see if it's about to capture a city
- register to all event to see what was the las action that doesn't crash
- remove units and city from the map before it's turn
- look at what the the cities are building

etc...
We tried to run some debugging test and thought we found the potential cause but not really...
Wonder how exactly do we "register to all events"?

Thanks.
 
We tried to run some debugging test and thought we found the potential cause but not really...
Wonder how exactly do we "register to all events"?

Thanks.
here's the code I use to get events argument with a new button in FireTuner, it can also be used to check what was the last working event.
Code:
local maxCall = 50
local seen = {}
function dump(t,i)
    seen[t]=true
    local s={}
    local n=0
    for k, v in pairs(t) do
        print(i,k, v)
        if type(v)=="table" and not seen[v] then
            dump(v,i.."\t\t")
        end
    end
end

function getEventArguments(...)
    local args = {...}
    if args then
        print("---------------------------------------------------------------------------------- Start <")
        print("num arguments = " .. #args)
        print(unpack({...}))      
        for i = 1, #args do
            if type(args[i])== "table" then
                print("--------------- "..tostring(args[i]).." ---------------");
                dump(args[i], "");
                print();
            end
        end
        print("------------------------------------------------------------------------------------ End >");
        print();
    else  
        print("---------------------------------------------------------------------------------- Start <")
        print("No arguments...")
        print("------------------------------------------------------------------------------------ End >");
        print();
    end
end

local eventslist = {
    -- GameCoreEvent
    "AnarchyBegins",
    "AnarchyEnds",
    "BeliefAdded",
    "BuildingAddedToMap",
    "BuildingChanged",
    "BuildingRemovedFromMap",
    "CapitalCityChanged",
    "CityAddedToMap",
    "CityCommandStarted",
    "CityDefenseStatusChanged",
    "CityFocusChanged",
    "CityInitialized",
    "CityLiberated",
    "CityMadePurchase",
    "CityPopulationChanged",
    "CityProductionChanged",
    "CityProductionCompleted",
    "CityProductionUpdated",
    "CityProjectCompleted",
    "CityReligionChanged",
    "CityReligionFollowersChanged",
    "CityRemovedFromMap",
    "CitySiegeStatusChanged",
    "CityTileOwnershipChanged",
    "CityUnitsChanged",
    "CityVisibilityChanged",
    "CityWorkerChanged",
    "CivicBoostTriggered",
    "CivicChanged",
    "CivicCompleted",
    "CivicQueueChanged",
    "CivicsUnlocked",
    "Combat",
    "CultureChanged",
    "CultureYieldChanged",
    "DiplomacyDealEnacted",
    "DiplomacyDealExpired",
    "DiplomacyDeclareWar",
    "DiplomacyIncomingDeal",
    "DiplomacyMakePeace",
    "DiplomacyMeet",
    "DiplomacyMeetMajorMinor",
    "DiplomacyMeetMajors",
    "DiplomacyRefusePeace",
    "DiplomacyRelationshipChanged",
    "DiplomacySessionClosed",
    "DiplomacyStatement",
    "DistrictAddedToMap",
    "DistrictBuildProgressChanged",
    "DistrictCombatChanged",
    "DistrictDamageChanged",
    "DistrictPillaged",
    "DistrictRemovedFromMap",
    "DistrictUnitsChanged",
    "DistrictVisibilityChanged",
    "EndTurnBlockingChanged",
    "EndTurnDirty",
    "FaithChanged",
    "FeatureAddedToMap",
    "FeatureChanged",
    "FeatureRemovedFromMap",
    "GoodyHutReward",
    "GovernmentChanged",
    "GovernmentPolicyChanged",
    "GovernmentPolicyObsoleted",
    "GreatPeoplePointsChanged",
    "GreatPeopleTimelineChanged",
    "GreatWorkCreated",
    "GreatWorkMoved",
    "ImprovementActivated",
    "ImprovementAddedToMap",
    "ImprovementChanged",
    "ImprovementOwnershipChanged",
    "ImprovementRemovedFromMap",
    "ImprovementVisibilityChanged",
    "InfluenceChanged",
    "InfluenceGiven",
    "LevyCounterChanged",
    "LocalPlayerChanged",
    "LocalPlayerTurnBegin",
    "LocalPlayerTurnEnd",
    "MapYieldsChanged",
    "NationalParkAdded",
    "NaturalWonderRevealed",
    "NotificationAdded",
    "NotificationDismissed",
    "NotificationRefreshRequested",
    "ObjectPairing",
    "OnAiAdvisorUpdated",
    "PantheonFounded",
    "PhaseBegin",
    "PhaseEnd",
    "PlayerBordersChanged",
    "PlayerDefeat",
    "PlayerDestroyed",
    "PlayerEraChanged",
    "PlayerOperationComplete",
    "PlayerTurnActivated",
    "PlayerTurnDeactivated",
    --"PlayerVictory",
    "PlotMarkerChanged",
    "PlotVisibilityChanged",
    "PlotYieldChanged",
    "QuestChanged",
    "ReligionFounded",
    "RemotePlayerTurnBegin",
    "RemotePlayerTurnEnd",
    "ResearchChanged",
    "ResearchCompleted",
    "ResearchQueueChanged",
    "ResearchYieldChanged",
    "ResourceAddedToMap",
    "ResourceChanged",
    "ResourceRemovedFromMap",
    "ResourceVisibilityChanged",
    "RouteAddedToMap",
    "RouteChanged",
    "RouteRemovedFromMap",
    "SpyAdded",
    "SpyMissionUpdated",
    "SpyRemoved",
    "SpyUpdated",
    "StatusMessage",
    "TeamVictory",
    "TechBoostTriggered",
    "TerrainTypeChanged",
    "TradeRouteActivityChanged",
    "TradeRouteAddedToMap",
    "TradeRouteCapacityChanged",
    "TradeRouteRangeChanged",
    "TradeRouteRemovedFromMap",
    "TreasuryChanged",
    "TurnBegin",
    "TurnEnd",
    "UnitActivityChanged",
    "UnitAddedToMap",
    "UnitAirlifted",
    "UnitArtifactChanged",
    "UnitCaptured",
    "UnitChargesChanged",
    "UnitCommandStarted",
    "UnitDamageChanged",
    "UnitEmbarkedStateChanged",
    "UnitEnterFormation",
    "UnitExitFormation",
    "UnitFormArmy",
    "UnitFormCorps",
    "UnitFortificationChanged",
    "UnitGreatPersonActivated",
    "UnitGreatPersonChanged",
    "UnitGreatPersonCreated",
    "UnitKilledInCombat",
    "UnitMoveComplete",
    "UnitMoved",
    "UnitMovementPointsChanged",
    "UnitMovementPointsCleared",
    "UnitMovementPointsRestored",
    "UnitOperationAdded",
    "UnitOperationDeactivated",
    "UnitOperationSegmentComplete",
    "UnitOperationStarted",
    "UnitOperationsCleared",
    "UnitPromoted",
    "UnitPromotionAvailable",
    "UnitRemovedFromMap",
    "UnitTeleported",
    "UnitUpgraded",
    "UnitVisibilityChanged",
    "WMDCountChanged",
    "WMDDetonated",
    "WMDFalloutChanged",
    "WMDFalloutVisibilityChanged",
    "WonderCompleted",
    "WorldTextMessage",
    -- LocalMachineEvent
    "ARXOrientationChanged",
    "ARXTap",
    "AchievementProgress",
    "AchievementUnlocked",
    "Begin2KLoginProcess",
    "BeginGameView",
    "BeginMy2KLinkAccountProcess",
    "BeginWonderReveal",
    "Camera_Updated",
    "CloudGameInfoUpdated",
    "CloudGameJoinResponse",
    "CloudGameListUpdated",
    "EndGameView",
    "EndWonderReveal",
    "ExitToMainMenu",
    "FiraxisLiveActivate",
    "FrontEndPopup",
    "GameConfigChanged",
    "HideLeaderScreen",
    "InputActionTriggered",
    "InputGestureRecorded",
    "LeaderAnimationChanged",
    "LeaderAnimationComplete",
    "LeaderScreenFinishedLoading",
    "LeaveGameComplete",
    "ModStatusUpdated",
    "MultiplayerChat",
    "MultiplayerGameAbandoned",
    "MultiplayerGameLastPlayer",
    "MultiplayerGameListClear",
    "MultiplayerGameListComplete",
    "MultiplayerGameListUpdated",
    "MultiplayerHostMigrated",
    "MultiplayerJoinGameComplete",
    "MultiplayerJoinRoomAttempt",
    "MultiplayerJoinRoomComplete",
    "MultiplayerJoinRoomFailed",
    "MultiplayerPingTimesChanged",
    "MultiplayerPlayerConnected",
    "MultiplayerPostPlayerDisconnected",
    "MultiplayerPrePlayerDisconnected",
    "MultiplayerSnapshotProcessed",
    "My2KActivate",
    "My2KLinkAccountResult",
    "OptionChangeRequiresAppRestart",
    "OptionChangeRequiresGameRestart",
    "OptionChangeRequiresResolutionAck",
    "OptionChanged",
    "OptionsReset",
    "OptionsReverted",
    "OptionsSaved",
    "PlayerInfoChanged",
    "ShowLeaderScreen",
    "SteamFriendsPresenceUpdated",
    "SteamFriendsStatusUpdated",
    "SteamServersConnected",
    "SteamServersDisconnected",
    "TurnTimerUpdated",
    "UpdateGraphicsOptions",
    "UserAcceptsEULA",
    "UserAcceptsOutdatedDriver",
    "UserAcceptsUnknownDevice",
    "UserConfirmedClose",
    "UserRequestClose",
    "WorldRenderViewChanged",
    -- SequenceEvent
    "AppInitComplete",
    "GameViewStateDone",
    "LoadGameViewStateDone",
    "LoadScreenClose",
    "LoadScreenContentReady",
    "MainMenuStateDone",
    -- SerialEvent
    "AfterGameplayContentChange",
    "AfterGameplayContentConfigure",
    "AllCitiesDeselected",
    "AllDistrictsDeselected",
    "AllUnitsDeselected",
    "AutomationTestComplete",
    "BeforeGameplayContentChange",
    "BeforeGameplayContentConfigure",
    "BeforeMultiplayerInviteProcessing",
    "CitySelectionChanged",
    "CombatVisBegin",
    "CombatVisEnd",
    "CycleUnitSelectionRequest",
    "DemoExit",
    "DemoTurnLimitReached",
    "DistrictSelectionChanged",
    "FinishedGameplayContentChange",
    "FinishedGameplayContentConfigure",
    "GameConfigurationParameterChanged",
    "GameConfigurationRebuilt",
    "GameConfigurationResolved",
    "GameCoreEventPlaybackComplete",
    "GameCoreEventPublishComplete",
    "InterfaceModeChanged",
    "LensFocusHex",
    "LensLayerOff",
    "LensLayerOn",
    "LensUnFocusHex",
    "LoadCanceled",
    "LoadComplete",
    "MapMaxMajorPlayersChanged",
    "MultiplayerGameInvite",
    "MultiplayerGameLaunched",
    "PreTurnBegin",
    "RequestLoad",
    "RequestSave",
    "SaveCanceled",
    "SaveComplete",
    "SubscriptionDownloadStatus",
    "UnitSelectionChanged",
    "UnitSimPositionChanged",
    "UserOptionChanged",
    "VisualStateRestored",
    -- UIEvent
    "DragCamera",
    "SystemUpdateUI",
    -- New
}

local gameEventsList = {
    "CityBuilt",
    "CityConquered",
    "OnCityPopulationChanged",
    "OnFaithEarned",
    "OnGameTurnStarted",
    "OnGreatPersonActivated",
    "OnNewMajorityReligion",
    "OnPillage",
    "OnUnitRetreated",
    "PlayerTurnStartComplete",
    "PlayerTurnStarted",
}

local numCall = {}
local eventsFunctions = {}

for i, eventName in ipairs(eventslist) do  
    print("Adding Listen to Events." .. eventName)
    numCall[eventName] = 0
    eventsFunctions[eventName] = function (...) if numCall[eventName] < maxCall then print("-- Events."..eventName);    getEventArguments(...);    numCall[eventName] = numCall[eventName] + 1; else Events[eventName].Remove( eventsFunctions[eventName] ) end;    end;
    Events[eventName].RemoveAll() -- remove previous listener when running the code again...
    Events[eventName].Add( eventsFunctions[eventName] )
end

for i, eventName in ipairs(gameEventsList) do
    print("Adding Listen to GameEvents." .. eventName)
    numCall[eventName] = 0
    eventsFunctions[eventName] = function (...) if numCall[eventName] < maxCall then print("-- GameEvents."..eventName);    getEventArguments(...);    numCall[eventName] = numCall[eventName] + 1; else GameEvents[eventName].Remove( eventsFunctions[eventName] ) end;    end;
    GameEvents[eventName].RemoveAll()
    GameEvents[eventName].Add( eventsFunctions[eventName] )
end
 
here's the code I use to get events argument with a new button in FireTuner, it can also be used to check what was the last working event.
Code:
local maxCall = 50
local seen = {}
function dump(t,i)
    seen[t]=true
    local s={}
    local n=0
    for k, v in pairs(t) do
        print(i,k, v)
        if type(v)=="table" and not seen[v] then
            dump(v,i.."\t\t")
        end
    end
end

function getEventArguments(...)
    local args = {...}
    if args then
        print("---------------------------------------------------------------------------------- Start <")
        print("num arguments = " .. #args)
        print(unpack({...}))     
        for i = 1, #args do
            if type(args[i])== "table" then
                print("--------------- "..tostring(args[i]).." ---------------");
                dump(args[i], "");
                print();
            end
        end
        print("------------------------------------------------------------------------------------ End >");
        print();
    else 
        print("---------------------------------------------------------------------------------- Start <")
        print("No arguments...")
        print("------------------------------------------------------------------------------------ End >");
        print();
    end
end

local eventslist = {
    -- GameCoreEvent
    "AnarchyBegins",
    "AnarchyEnds",
    "BeliefAdded",
    "BuildingAddedToMap",
    "BuildingChanged",
    "BuildingRemovedFromMap",
    "CapitalCityChanged",
    "CityAddedToMap",
    "CityCommandStarted",
    "CityDefenseStatusChanged",
    "CityFocusChanged",
    "CityInitialized",
    "CityLiberated",
    "CityMadePurchase",
    "CityPopulationChanged",
    "CityProductionChanged",
    "CityProductionCompleted",
    "CityProductionUpdated",
    "CityProjectCompleted",
    "CityReligionChanged",
    "CityReligionFollowersChanged",
    "CityRemovedFromMap",
    "CitySiegeStatusChanged",
    "CityTileOwnershipChanged",
    "CityUnitsChanged",
    "CityVisibilityChanged",
    "CityWorkerChanged",
    "CivicBoostTriggered",
    "CivicChanged",
    "CivicCompleted",
    "CivicQueueChanged",
    "CivicsUnlocked",
    "Combat",
    "CultureChanged",
    "CultureYieldChanged",
    "DiplomacyDealEnacted",
    "DiplomacyDealExpired",
    "DiplomacyDeclareWar",
    "DiplomacyIncomingDeal",
    "DiplomacyMakePeace",
    "DiplomacyMeet",
    "DiplomacyMeetMajorMinor",
    "DiplomacyMeetMajors",
    "DiplomacyRefusePeace",
    "DiplomacyRelationshipChanged",
    "DiplomacySessionClosed",
    "DiplomacyStatement",
    "DistrictAddedToMap",
    "DistrictBuildProgressChanged",
    "DistrictCombatChanged",
    "DistrictDamageChanged",
    "DistrictPillaged",
    "DistrictRemovedFromMap",
    "DistrictUnitsChanged",
    "DistrictVisibilityChanged",
    "EndTurnBlockingChanged",
    "EndTurnDirty",
    "FaithChanged",
    "FeatureAddedToMap",
    "FeatureChanged",
    "FeatureRemovedFromMap",
    "GoodyHutReward",
    "GovernmentChanged",
    "GovernmentPolicyChanged",
    "GovernmentPolicyObsoleted",
    "GreatPeoplePointsChanged",
    "GreatPeopleTimelineChanged",
    "GreatWorkCreated",
    "GreatWorkMoved",
    "ImprovementActivated",
    "ImprovementAddedToMap",
    "ImprovementChanged",
    "ImprovementOwnershipChanged",
    "ImprovementRemovedFromMap",
    "ImprovementVisibilityChanged",
    "InfluenceChanged",
    "InfluenceGiven",
    "LevyCounterChanged",
    "LocalPlayerChanged",
    "LocalPlayerTurnBegin",
    "LocalPlayerTurnEnd",
    "MapYieldsChanged",
    "NationalParkAdded",
    "NaturalWonderRevealed",
    "NotificationAdded",
    "NotificationDismissed",
    "NotificationRefreshRequested",
    "ObjectPairing",
    "OnAiAdvisorUpdated",
    "PantheonFounded",
    "PhaseBegin",
    "PhaseEnd",
    "PlayerBordersChanged",
    "PlayerDefeat",
    "PlayerDestroyed",
    "PlayerEraChanged",
    "PlayerOperationComplete",
    "PlayerTurnActivated",
    "PlayerTurnDeactivated",
    --"PlayerVictory",
    "PlotMarkerChanged",
    "PlotVisibilityChanged",
    "PlotYieldChanged",
    "QuestChanged",
    "ReligionFounded",
    "RemotePlayerTurnBegin",
    "RemotePlayerTurnEnd",
    "ResearchChanged",
    "ResearchCompleted",
    "ResearchQueueChanged",
    "ResearchYieldChanged",
    "ResourceAddedToMap",
    "ResourceChanged",
    "ResourceRemovedFromMap",
    "ResourceVisibilityChanged",
    "RouteAddedToMap",
    "RouteChanged",
    "RouteRemovedFromMap",
    "SpyAdded",
    "SpyMissionUpdated",
    "SpyRemoved",
    "SpyUpdated",
    "StatusMessage",
    "TeamVictory",
    "TechBoostTriggered",
    "TerrainTypeChanged",
    "TradeRouteActivityChanged",
    "TradeRouteAddedToMap",
    "TradeRouteCapacityChanged",
    "TradeRouteRangeChanged",
    "TradeRouteRemovedFromMap",
    "TreasuryChanged",
    "TurnBegin",
    "TurnEnd",
    "UnitActivityChanged",
    "UnitAddedToMap",
    "UnitAirlifted",
    "UnitArtifactChanged",
    "UnitCaptured",
    "UnitChargesChanged",
    "UnitCommandStarted",
    "UnitDamageChanged",
    "UnitEmbarkedStateChanged",
    "UnitEnterFormation",
    "UnitExitFormation",
    "UnitFormArmy",
    "UnitFormCorps",
    "UnitFortificationChanged",
    "UnitGreatPersonActivated",
    "UnitGreatPersonChanged",
    "UnitGreatPersonCreated",
    "UnitKilledInCombat",
    "UnitMoveComplete",
    "UnitMoved",
    "UnitMovementPointsChanged",
    "UnitMovementPointsCleared",
    "UnitMovementPointsRestored",
    "UnitOperationAdded",
    "UnitOperationDeactivated",
    "UnitOperationSegmentComplete",
    "UnitOperationStarted",
    "UnitOperationsCleared",
    "UnitPromoted",
    "UnitPromotionAvailable",
    "UnitRemovedFromMap",
    "UnitTeleported",
    "UnitUpgraded",
    "UnitVisibilityChanged",
    "WMDCountChanged",
    "WMDDetonated",
    "WMDFalloutChanged",
    "WMDFalloutVisibilityChanged",
    "WonderCompleted",
    "WorldTextMessage",
    -- LocalMachineEvent
    "ARXOrientationChanged",
    "ARXTap",
    "AchievementProgress",
    "AchievementUnlocked",
    "Begin2KLoginProcess",
    "BeginGameView",
    "BeginMy2KLinkAccountProcess",
    "BeginWonderReveal",
    "Camera_Updated",
    "CloudGameInfoUpdated",
    "CloudGameJoinResponse",
    "CloudGameListUpdated",
    "EndGameView",
    "EndWonderReveal",
    "ExitToMainMenu",
    "FiraxisLiveActivate",
    "FrontEndPopup",
    "GameConfigChanged",
    "HideLeaderScreen",
    "InputActionTriggered",
    "InputGestureRecorded",
    "LeaderAnimationChanged",
    "LeaderAnimationComplete",
    "LeaderScreenFinishedLoading",
    "LeaveGameComplete",
    "ModStatusUpdated",
    "MultiplayerChat",
    "MultiplayerGameAbandoned",
    "MultiplayerGameLastPlayer",
    "MultiplayerGameListClear",
    "MultiplayerGameListComplete",
    "MultiplayerGameListUpdated",
    "MultiplayerHostMigrated",
    "MultiplayerJoinGameComplete",
    "MultiplayerJoinRoomAttempt",
    "MultiplayerJoinRoomComplete",
    "MultiplayerJoinRoomFailed",
    "MultiplayerPingTimesChanged",
    "MultiplayerPlayerConnected",
    "MultiplayerPostPlayerDisconnected",
    "MultiplayerPrePlayerDisconnected",
    "MultiplayerSnapshotProcessed",
    "My2KActivate",
    "My2KLinkAccountResult",
    "OptionChangeRequiresAppRestart",
    "OptionChangeRequiresGameRestart",
    "OptionChangeRequiresResolutionAck",
    "OptionChanged",
    "OptionsReset",
    "OptionsReverted",
    "OptionsSaved",
    "PlayerInfoChanged",
    "ShowLeaderScreen",
    "SteamFriendsPresenceUpdated",
    "SteamFriendsStatusUpdated",
    "SteamServersConnected",
    "SteamServersDisconnected",
    "TurnTimerUpdated",
    "UpdateGraphicsOptions",
    "UserAcceptsEULA",
    "UserAcceptsOutdatedDriver",
    "UserAcceptsUnknownDevice",
    "UserConfirmedClose",
    "UserRequestClose",
    "WorldRenderViewChanged",
    -- SequenceEvent
    "AppInitComplete",
    "GameViewStateDone",
    "LoadGameViewStateDone",
    "LoadScreenClose",
    "LoadScreenContentReady",
    "MainMenuStateDone",
    -- SerialEvent
    "AfterGameplayContentChange",
    "AfterGameplayContentConfigure",
    "AllCitiesDeselected",
    "AllDistrictsDeselected",
    "AllUnitsDeselected",
    "AutomationTestComplete",
    "BeforeGameplayContentChange",
    "BeforeGameplayContentConfigure",
    "BeforeMultiplayerInviteProcessing",
    "CitySelectionChanged",
    "CombatVisBegin",
    "CombatVisEnd",
    "CycleUnitSelectionRequest",
    "DemoExit",
    "DemoTurnLimitReached",
    "DistrictSelectionChanged",
    "FinishedGameplayContentChange",
    "FinishedGameplayContentConfigure",
    "GameConfigurationParameterChanged",
    "GameConfigurationRebuilt",
    "GameConfigurationResolved",
    "GameCoreEventPlaybackComplete",
    "GameCoreEventPublishComplete",
    "InterfaceModeChanged",
    "LensFocusHex",
    "LensLayerOff",
    "LensLayerOn",
    "LensUnFocusHex",
    "LoadCanceled",
    "LoadComplete",
    "MapMaxMajorPlayersChanged",
    "MultiplayerGameInvite",
    "MultiplayerGameLaunched",
    "PreTurnBegin",
    "RequestLoad",
    "RequestSave",
    "SaveCanceled",
    "SaveComplete",
    "SubscriptionDownloadStatus",
    "UnitSelectionChanged",
    "UnitSimPositionChanged",
    "UserOptionChanged",
    "VisualStateRestored",
    -- UIEvent
    "DragCamera",
    "SystemUpdateUI",
    -- New
}

local gameEventsList = {
    "CityBuilt",
    "CityConquered",
    "OnCityPopulationChanged",
    "OnFaithEarned",
    "OnGameTurnStarted",
    "OnGreatPersonActivated",
    "OnNewMajorityReligion",
    "OnPillage",
    "OnUnitRetreated",
    "PlayerTurnStartComplete",
    "PlayerTurnStarted",
}

local numCall = {}
local eventsFunctions = {}

for i, eventName in ipairs(eventslist) do 
    print("Adding Listen to Events." .. eventName)
    numCall[eventName] = 0
    eventsFunctions[eventName] = function (...) if numCall[eventName] < maxCall then print("-- Events."..eventName);    getEventArguments(...);    numCall[eventName] = numCall[eventName] + 1; else Events[eventName].Remove( eventsFunctions[eventName] ) end;    end;
    Events[eventName].RemoveAll() -- remove previous listener when running the code again...
    Events[eventName].Add( eventsFunctions[eventName] )
end

for i, eventName in ipairs(gameEventsList) do
    print("Adding Listen to GameEvents." .. eventName)
    numCall[eventName] = 0
    eventsFunctions[eventName] = function (...) if numCall[eventName] < maxCall then print("-- GameEvents."..eventName);    getEventArguments(...);    numCall[eventName] = numCall[eventName] + 1; else GameEvents[eventName].Remove( eventsFunctions[eventName] ) end;    end;
    GameEvents[eventName].RemoveAll()
    GameEvents[eventName].Add( eventsFunctions[eventName] )
end
Thank you so much! We will test it out. Hopefully this can help us target the bug.
 
here's the code I use to get events argument with a new button in FireTuner, it can also be used to check what was the last working event.
Code:
local maxCall = 50
local seen = {}
function dump(t,i)
    seen[t]=true
    local s={}
    local n=0
    for k, v in pairs(t) do
        print(i,k, v)
        if type(v)=="table" and not seen[v] then
            dump(v,i.."\t\t")
        end
    end
end

function getEventArguments(...)
    local args = {...}
    if args then
        print("---------------------------------------------------------------------------------- Start <")
        print("num arguments = " .. #args)
        print(unpack({...}))  
        for i = 1, #args do
            if type(args[i])== "table" then
                print("--------------- "..tostring(args[i]).." ---------------");
                dump(args[i], "");
                print();
            end
        end
        print("------------------------------------------------------------------------------------ End >");
        print();
    else
        print("---------------------------------------------------------------------------------- Start <")
        print("No arguments...")
        print("------------------------------------------------------------------------------------ End >");
        print();
    end
end

local eventslist = {
    -- GameCoreEvent
    "AnarchyBegins",
    "AnarchyEnds",
    "BeliefAdded",
    "BuildingAddedToMap",
    "BuildingChanged",
    "BuildingRemovedFromMap",
    "CapitalCityChanged",
    "CityAddedToMap",
    "CityCommandStarted",
    "CityDefenseStatusChanged",
    "CityFocusChanged",
    "CityInitialized",
    "CityLiberated",
    "CityMadePurchase",
    "CityPopulationChanged",
    "CityProductionChanged",
    "CityProductionCompleted",
    "CityProductionUpdated",
    "CityProjectCompleted",
    "CityReligionChanged",
    "CityReligionFollowersChanged",
    "CityRemovedFromMap",
    "CitySiegeStatusChanged",
    "CityTileOwnershipChanged",
    "CityUnitsChanged",
    "CityVisibilityChanged",
    "CityWorkerChanged",
    "CivicBoostTriggered",
    "CivicChanged",
    "CivicCompleted",
    "CivicQueueChanged",
    "CivicsUnlocked",
    "Combat",
    "CultureChanged",
    "CultureYieldChanged",
    "DiplomacyDealEnacted",
    "DiplomacyDealExpired",
    "DiplomacyDeclareWar",
    "DiplomacyIncomingDeal",
    "DiplomacyMakePeace",
    "DiplomacyMeet",
    "DiplomacyMeetMajorMinor",
    "DiplomacyMeetMajors",
    "DiplomacyRefusePeace",
    "DiplomacyRelationshipChanged",
    "DiplomacySessionClosed",
    "DiplomacyStatement",
    "DistrictAddedToMap",
    "DistrictBuildProgressChanged",
    "DistrictCombatChanged",
    "DistrictDamageChanged",
    "DistrictPillaged",
    "DistrictRemovedFromMap",
    "DistrictUnitsChanged",
    "DistrictVisibilityChanged",
    "EndTurnBlockingChanged",
    "EndTurnDirty",
    "FaithChanged",
    "FeatureAddedToMap",
    "FeatureChanged",
    "FeatureRemovedFromMap",
    "GoodyHutReward",
    "GovernmentChanged",
    "GovernmentPolicyChanged",
    "GovernmentPolicyObsoleted",
    "GreatPeoplePointsChanged",
    "GreatPeopleTimelineChanged",
    "GreatWorkCreated",
    "GreatWorkMoved",
    "ImprovementActivated",
    "ImprovementAddedToMap",
    "ImprovementChanged",
    "ImprovementOwnershipChanged",
    "ImprovementRemovedFromMap",
    "ImprovementVisibilityChanged",
    "InfluenceChanged",
    "InfluenceGiven",
    "LevyCounterChanged",
    "LocalPlayerChanged",
    "LocalPlayerTurnBegin",
    "LocalPlayerTurnEnd",
    "MapYieldsChanged",
    "NationalParkAdded",
    "NaturalWonderRevealed",
    "NotificationAdded",
    "NotificationDismissed",
    "NotificationRefreshRequested",
    "ObjectPairing",
    "OnAiAdvisorUpdated",
    "PantheonFounded",
    "PhaseBegin",
    "PhaseEnd",
    "PlayerBordersChanged",
    "PlayerDefeat",
    "PlayerDestroyed",
    "PlayerEraChanged",
    "PlayerOperationComplete",
    "PlayerTurnActivated",
    "PlayerTurnDeactivated",
    --"PlayerVictory",
    "PlotMarkerChanged",
    "PlotVisibilityChanged",
    "PlotYieldChanged",
    "QuestChanged",
    "ReligionFounded",
    "RemotePlayerTurnBegin",
    "RemotePlayerTurnEnd",
    "ResearchChanged",
    "ResearchCompleted",
    "ResearchQueueChanged",
    "ResearchYieldChanged",
    "ResourceAddedToMap",
    "ResourceChanged",
    "ResourceRemovedFromMap",
    "ResourceVisibilityChanged",
    "RouteAddedToMap",
    "RouteChanged",
    "RouteRemovedFromMap",
    "SpyAdded",
    "SpyMissionUpdated",
    "SpyRemoved",
    "SpyUpdated",
    "StatusMessage",
    "TeamVictory",
    "TechBoostTriggered",
    "TerrainTypeChanged",
    "TradeRouteActivityChanged",
    "TradeRouteAddedToMap",
    "TradeRouteCapacityChanged",
    "TradeRouteRangeChanged",
    "TradeRouteRemovedFromMap",
    "TreasuryChanged",
    "TurnBegin",
    "TurnEnd",
    "UnitActivityChanged",
    "UnitAddedToMap",
    "UnitAirlifted",
    "UnitArtifactChanged",
    "UnitCaptured",
    "UnitChargesChanged",
    "UnitCommandStarted",
    "UnitDamageChanged",
    "UnitEmbarkedStateChanged",
    "UnitEnterFormation",
    "UnitExitFormation",
    "UnitFormArmy",
    "UnitFormCorps",
    "UnitFortificationChanged",
    "UnitGreatPersonActivated",
    "UnitGreatPersonChanged",
    "UnitGreatPersonCreated",
    "UnitKilledInCombat",
    "UnitMoveComplete",
    "UnitMoved",
    "UnitMovementPointsChanged",
    "UnitMovementPointsCleared",
    "UnitMovementPointsRestored",
    "UnitOperationAdded",
    "UnitOperationDeactivated",
    "UnitOperationSegmentComplete",
    "UnitOperationStarted",
    "UnitOperationsCleared",
    "UnitPromoted",
    "UnitPromotionAvailable",
    "UnitRemovedFromMap",
    "UnitTeleported",
    "UnitUpgraded",
    "UnitVisibilityChanged",
    "WMDCountChanged",
    "WMDDetonated",
    "WMDFalloutChanged",
    "WMDFalloutVisibilityChanged",
    "WonderCompleted",
    "WorldTextMessage",
    -- LocalMachineEvent
    "ARXOrientationChanged",
    "ARXTap",
    "AchievementProgress",
    "AchievementUnlocked",
    "Begin2KLoginProcess",
    "BeginGameView",
    "BeginMy2KLinkAccountProcess",
    "BeginWonderReveal",
    "Camera_Updated",
    "CloudGameInfoUpdated",
    "CloudGameJoinResponse",
    "CloudGameListUpdated",
    "EndGameView",
    "EndWonderReveal",
    "ExitToMainMenu",
    "FiraxisLiveActivate",
    "FrontEndPopup",
    "GameConfigChanged",
    "HideLeaderScreen",
    "InputActionTriggered",
    "InputGestureRecorded",
    "LeaderAnimationChanged",
    "LeaderAnimationComplete",
    "LeaderScreenFinishedLoading",
    "LeaveGameComplete",
    "ModStatusUpdated",
    "MultiplayerChat",
    "MultiplayerGameAbandoned",
    "MultiplayerGameLastPlayer",
    "MultiplayerGameListClear",
    "MultiplayerGameListComplete",
    "MultiplayerGameListUpdated",
    "MultiplayerHostMigrated",
    "MultiplayerJoinGameComplete",
    "MultiplayerJoinRoomAttempt",
    "MultiplayerJoinRoomComplete",
    "MultiplayerJoinRoomFailed",
    "MultiplayerPingTimesChanged",
    "MultiplayerPlayerConnected",
    "MultiplayerPostPlayerDisconnected",
    "MultiplayerPrePlayerDisconnected",
    "MultiplayerSnapshotProcessed",
    "My2KActivate",
    "My2KLinkAccountResult",
    "OptionChangeRequiresAppRestart",
    "OptionChangeRequiresGameRestart",
    "OptionChangeRequiresResolutionAck",
    "OptionChanged",
    "OptionsReset",
    "OptionsReverted",
    "OptionsSaved",
    "PlayerInfoChanged",
    "ShowLeaderScreen",
    "SteamFriendsPresenceUpdated",
    "SteamFriendsStatusUpdated",
    "SteamServersConnected",
    "SteamServersDisconnected",
    "TurnTimerUpdated",
    "UpdateGraphicsOptions",
    "UserAcceptsEULA",
    "UserAcceptsOutdatedDriver",
    "UserAcceptsUnknownDevice",
    "UserConfirmedClose",
    "UserRequestClose",
    "WorldRenderViewChanged",
    -- SequenceEvent
    "AppInitComplete",
    "GameViewStateDone",
    "LoadGameViewStateDone",
    "LoadScreenClose",
    "LoadScreenContentReady",
    "MainMenuStateDone",
    -- SerialEvent
    "AfterGameplayContentChange",
    "AfterGameplayContentConfigure",
    "AllCitiesDeselected",
    "AllDistrictsDeselected",
    "AllUnitsDeselected",
    "AutomationTestComplete",
    "BeforeGameplayContentChange",
    "BeforeGameplayContentConfigure",
    "BeforeMultiplayerInviteProcessing",
    "CitySelectionChanged",
    "CombatVisBegin",
    "CombatVisEnd",
    "CycleUnitSelectionRequest",
    "DemoExit",
    "DemoTurnLimitReached",
    "DistrictSelectionChanged",
    "FinishedGameplayContentChange",
    "FinishedGameplayContentConfigure",
    "GameConfigurationParameterChanged",
    "GameConfigurationRebuilt",
    "GameConfigurationResolved",
    "GameCoreEventPlaybackComplete",
    "GameCoreEventPublishComplete",
    "InterfaceModeChanged",
    "LensFocusHex",
    "LensLayerOff",
    "LensLayerOn",
    "LensUnFocusHex",
    "LoadCanceled",
    "LoadComplete",
    "MapMaxMajorPlayersChanged",
    "MultiplayerGameInvite",
    "MultiplayerGameLaunched",
    "PreTurnBegin",
    "RequestLoad",
    "RequestSave",
    "SaveCanceled",
    "SaveComplete",
    "SubscriptionDownloadStatus",
    "UnitSelectionChanged",
    "UnitSimPositionChanged",
    "UserOptionChanged",
    "VisualStateRestored",
    -- UIEvent
    "DragCamera",
    "SystemUpdateUI",
    -- New
}

local gameEventsList = {
    "CityBuilt",
    "CityConquered",
    "OnCityPopulationChanged",
    "OnFaithEarned",
    "OnGameTurnStarted",
    "OnGreatPersonActivated",
    "OnNewMajorityReligion",
    "OnPillage",
    "OnUnitRetreated",
    "PlayerTurnStartComplete",
    "PlayerTurnStarted",
}

local numCall = {}
local eventsFunctions = {}

for i, eventName in ipairs(eventslist) do
    print("Adding Listen to Events." .. eventName)
    numCall[eventName] = 0
    eventsFunctions[eventName] = function (...) if numCall[eventName] < maxCall then print("-- Events."..eventName);    getEventArguments(...);    numCall[eventName] = numCall[eventName] + 1; else Events[eventName].Remove( eventsFunctions[eventName] ) end;    end;
    Events[eventName].RemoveAll() -- remove previous listener when running the code again...
    Events[eventName].Add( eventsFunctions[eventName] )
end

for i, eventName in ipairs(gameEventsList) do
    print("Adding Listen to GameEvents." .. eventName)
    numCall[eventName] = 0
    eventsFunctions[eventName] = function (...) if numCall[eventName] < maxCall then print("-- GameEvents."..eventName);    getEventArguments(...);    numCall[eventName] = numCall[eventName] + 1; else GameEvents[eventName].Remove( eventsFunctions[eventName] ) end;    end;
    GameEvents[eventName].RemoveAll()
    GameEvents[eventName].Add( eventsFunctions[eventName] )
end
A follow up. Turned out all the crashes happened on entering player turn, both human player and AI player it doesn't matter. We also observed that the turn was to finish a civic that will make some policies obsolete. Remembering the new UI mess of latest patch (no notification of obsolete policies, new available government, etc), we also discovered a sudden RAM use peak (max out) when the crash happened.
I went to read UI/Governments lua to see if there's anything worth fixing. But the script seemed alright. Though I suspect the Refresh() function that was called in the function triggered by OnGovernmentPolicyObsolete event consumes a huge amount of RAM, which may be a game optimization issue (means we have no idea how to fix until next patch). So we tried deleting all the policy obsolete code lines and our MOD runs OK for now.
We are not sure if it's a temporary solution but thank you very much for your advises. And we are very disappointed/frustrated with 2K/Firaxis for this underdeveloped patch. (Some nice intentions but very poor execution.)
 
Back
Top Bottom