Need More Info Incorrect datastore behavior leading to possible crashes

Users who are viewing this thread

When making a mod (or even with vanilla modules) you are required to implement the class `SaveableCampaignBehaviorTypeDefiner` for complex datasaving before using the SyncData method. I'll explain how it could go wrong.
I think this error is responsible for a LOT of the loading issues from old saves.

So in my example i'll define 2 objects to be saved using the dedicated methods.
Code:
protected override void DefineContainerDefinitions()
{
                base.ConstructContainerDefinition(typeof(Dictionary<Hero, (Hero, SkillEffect.PerkRole)>));
}

protected override void DefineGenericStructDefinitions()
{
                base.ConstructGenericStructDefinition(typeof(ValueTuple<Hero, SkillEffect.PerkRole>));
}

And in my main behavior
Code:
public Dictionary<Hero, (Hero, SkillEffect.PerkRole)> AI_Companions_Roles = new Dictionary<Hero, (Hero, SkillEffect.PerkRole)>();
public override void SyncData(IDataStore dataStore)
{
            dataStore.SyncData<Dictionary<Hero, (Hero, SkillEffect.PerkRole)>>("AI_Companions_Roles" , ref this.AI_Companions_Roles);
}

So this is to give a concrete example, now let's talk about the issue.

If i use a new save or a save that never had this mod installed with, all works fine, AI_Companions_Roles is set to an empty dic and everything is fine.
If i save and reload the game with the mod installed, once again everything works fine, SyncData get back the values from my save and all is perfect.
Now if i remove the mod from the load order and load a save with the data contained inside, once again it works fine, the game seem to not have issues with it.

The last part is where i have issues.

If after removing the mod i save, then reactivate the mod and load this last save, it crashes.
AI_Companions_Roles will be set to null cause Syncdata will overwrite the original definition. It seem it have still some traces of my data inside the save game but it set them to null and this makes a lot of issues. I guess it's because when removing the mod, the definitions of how is stored my values is removed too, so it can't read or store them correctly in the next save, but then, as it's not able to understand it, why store something wrong and possibly game breaking? The game should simply discard the data and all would be fine, preventing crashes.
 
Last edited:
Hello, sorry for the late reply. We have fixed a considerable amount of the problems we have encountered so far and improved the game performance with the multiple patches we have released. Please make sure that your game, your drivers, and OS are up to date and the game has necessary permissions over your security software. Please let us know if the problem persists after completing these steps and verifying the integrity of the game files through Steam.
 
Back
Top Bottom