[1.0] Trap rearm state isn't kept through save/load cycles

Started by Lockdown, May 12, 2019, 06:29:14 PM

Previous topic - Next topic

Lockdown

1. Build a trap, and disable auto-rearm.
2. Save game, quit to main menu, then reload game.
3. Trap has auto-rearm enabled again.

Canute

Is the trap inside the home area ?
Then it is a "feature" of the home area.


Lockdown

For clarity, this bug occurs even when the "Toggle automatic rebuild of destroyed structures in the home area" is disabled. And even traps outside the home area get their rearm state overriden on game load, they just override to false instead of true.

As far as I understand, the bug happens because of these two methods in Building_Trap:

public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look<bool>(ref this.autoRearm, "autoRearm", false, false);
Scribe_Collections.Look<Pawn>(ref this.touchingPawns, "testees", LookMode.Reference, new object[0]);
}

public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
base.SpawnSetup(map, respawningAfterLoad);
this.autoRearm = (this.CanSetAutoRearm && map.areaManager.Home[base.Position]);
}


On game load, ExposeData is called first, setting the autoRearm state based on whatever the player had set them to, but then SpawnSetup overrides autoRearm to true if inside home area, false otherwise. The solution is to have SpawnSetup only initialize autoRearm if respawningAfterLoad == false, not every single time. That way, rearm states should be perserved through save/load cycles.

Canute

I think the devs like it when the people deliver the solution for the bug within the report !! :-)
And i think you use the latest version 2231, just to be sure and it isn't fixed at these version allready.