Skip to content

Pilot Injuries reset on Save Load #16

Description

@sqparadox

The pilot.FromPilotDef() call in SimGameState_RehydratePatch is causing injuries to be lost.

The pilotDef does not have injuries set at this point but the pilot does, so the call erases those injuries. I was able to fix the issue with a simple check and Traverse call but I don't know if there is a deeper underlying issue.

Here's the fixed code starting on line 32 of SimeGameState.cs:

    if (Main.settings.enablePilotQuirks)
    {
        foreach (Pilot pilot in __instance.PilotRoster.ToList())
        {
            PilotQuirkManager.Instance.proccessPilot(pilot.pilotDef, true);
            if (pilot.Injuries != pilot.pilotDef.Injuries)
                Traverse.Create(pilot.pilotDef).Property("Injuries").SetValue(pilot.Injuries);
            pilot.FromPilotDef(pilot.pilotDef);
        }
        // the commander is not part of the roster, so need to specifically call it.
        PilotQuirkManager.Instance.proccessPilot(__instance.Commander.pilotDef, true);
        if (__instance.Commander.Injuries != __instance.Commander.pilotDef.Injuries)
            Traverse.Create(__instance.Commander.pilotDef).Property("Injuries").SetValue(__instance.Commander.Injuries);
        __instance.Commander.FromPilotDef(__instance.Commander.pilotDef);
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions