TheSeaMoon4 / Empire-1_4-Continued-

Continued version of Empire
1 stars 7 forks source link

Save file things dictionary bug #3

Open abel1502 opened 6 months ago

abel1502 commented 6 months ago

Ever since I've added Empire to my modlist, I've noticed that after a while of playing, the log tends to get cluttered with more and more messages like these whenever I load the game:

Cannot register VanillaRacesExpandedFungoid.Hediff_GeneInfected (VRE_GeneInfected ticksSinceCreation=16286), (id=Hediff_77751 in loaded object directory. Id already used by VanillaRacesExpandedFungoid.Hediff_GeneInfected (VRE_GeneInfected ticksSinceCreation=0). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_InfectorHands left hand ticksSinceCreation=16286), (id=Hediff_77752 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_InfectorHands left hand ticksSinceCreation=0). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null), (id=Verb_Hediff_77752_0_0_VRE_Infection in loaded object directory. Id already used by RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register MVCF.ManagedVerb MVCF.ManagedVerb, (id=Hediff_77752_0_0_VRE_Infection_Managed in loaded object directory. Id already used by MVCF.ManagedVerb MVCF.ManagedVerb. 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_InfectorHands right hand ticksSinceCreation=16286), (id=Hediff_77753 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_InfectorHands right hand ticksSinceCreation=0). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null), (id=Verb_Hediff_77753_0_0_VRE_Infection in loaded object directory. Id already used by RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register MVCF.ManagedVerb MVCF.ManagedVerb, (id=Hediff_77753_0_0_VRE_Infection_Managed in loaded object directory. Id already used by MVCF.ManagedVerb MVCF.ManagedVerb. 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_InfectorMouth jaw ticksSinceCreation=16286), (id=Hediff_77754 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_InfectorMouth jaw ticksSinceCreation=0). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null), (id=Verb_Hediff_77754_0_0_VRE_Infection_Bite in loaded object directory. Id already used by RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register MVCF.ManagedVerb MVCF.ManagedVerb, (id=Hediff_77754_0_0_VRE_Infection_Bite_Managed in loaded object directory. Id already used by MVCF.ManagedVerb MVCF.ManagedVerb. 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_FungalArmor ticksSinceCreation=16286), (id=Hediff_77783 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_FungalArmor ticksSinceCreation=0). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_FungalRegeneration ticksSinceCreation=16286), (id=Hediff_77789 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_FungalRegeneration ticksSinceCreation=0). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_RotStinkExposure (LungRotExposure ticksSinceCreation=16258), (id=Hediff_78369 in loaded object directory. Id already used by Verse.Hediff_RotStinkExposure (LungRotExposure ticksSinceCreation=16258). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot left tibia ticksSinceCreation=15209), (id=Hediff_78379 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot left tibia ticksSinceCreation=15209). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot left leg ticksSinceCreation=15209), (id=Hediff_78380 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot left leg ticksSinceCreation=15209). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Bruise left leg ticksSinceCreation=15043), (id=Hediff_78382 in loaded object directory. Id already used by Verse.Hediff_Injury (Bruise left leg ticksSinceCreation=15043). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot right hand ticksSinceCreation=14860), (id=Hediff_78383 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot right hand ticksSinceCreation=14860). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot right femur ticksSinceCreation=14769), (id=Hediff_78384 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot right femur ticksSinceCreation=14769). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot right leg ticksSinceCreation=14769), (id=Hediff_78385 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot right leg ticksSinceCreation=14769). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Bite torso ticksSinceCreation=1816), (id=Hediff_74381 in loaded object directory. Id already used by Verse.Hediff_Injury (Bite torso ticksSinceCreation=1816). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register AlteredCarbon.Hediff_CorticalStack (VFEU_CorticalStack neck ticksSinceCreation=1816), (id=Hediff_74382 in loaded object directory. Id already used by AlteredCarbon.Hediff_CorticalStack (VFEU_CorticalStack neck ticksSinceCreation=1816). 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Pawn Avila, (id=Thing_Human36440 in loaded object directory. Id already used by Verse.Pawn Avila. 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

As you can see, these complain about duplicate things in the object dictionary. I've looked into it a bit more than usually, and was able to link this to prisoners being sent to settlements. The things registered twice are all hediffs of a pawn and the pawn themselves. After a quick look at the code, I believe the FCPrisoner class to be the likely culprit. Not only does it create a duplicate instance of the pawn's health tracker, it also exposes it twice from itself -- once via Scribe_Deep.Look(ref prisoner, "prisoner");, then again via Scribe_Deep.Look(ref healthTracker, "healthTracker", new object[] { prisoner });.

I'm now in the process of improvising a fix manually via dnSpy, but if you find a proper solution to this issue, I'll appreciate it.

TheSeaMoon4 commented 6 months ago

Thx for the notice, I don't know when I will have time to fix it since I got some stuff happening in my life, so if you find a fix I will appreciate it and I will give credit to you, I'll try to find some time to look at it myself though

On Tue., Mar. 5, 2024, 11:26 a.m. abel1502 @.***> wrote:

Ever since I've added Empire to my modlist, I've noticed that after a while of playing, the log tends to get cluttered with more and more messages like these whenever I load the game:

Cannot register VanillaRacesExpandedFungoid.Hediff_GeneInfected (VRE_GeneInfected ticksSinceCreation=16286), (id=Hediff_77751 in loaded object directory. Id already used by VanillaRacesExpandedFungoid.Hediff_GeneInfected (VRE_GeneInfected ticksSinceCreation=0). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_InfectorHands left hand ticksSinceCreation=16286), (id=Hediff_77752 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_InfectorHands left hand ticksSinceCreation=0). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null), (id=Verb_Hediff_77752_0_0_VRE_Infection in loaded object directory. Id already used by RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register MVCF.ManagedVerb MVCF.ManagedVerb, (id=Hediff_77752_0_0_VRE_Infection_Managed in loaded object directory. Id already used by MVCF.ManagedVerb MVCF.ManagedVerb. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_InfectorHands right hand ticksSinceCreation=16286), (id=Hediff_77753 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_InfectorHands right hand ticksSinceCreation=0). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null), (id=Verb_Hediff_77753_0_0_VRE_Infection in loaded object directory. Id already used by RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register MVCF.ManagedVerb MVCF.ManagedVerb, (id=Hediff_77753_0_0_VRE_Infection_Managed in loaded object directory. Id already used by MVCF.ManagedVerb MVCF.ManagedVerb. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_InfectorMouth jaw ticksSinceCreation=16286), (id=Hediff_77754 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_InfectorMouth jaw ticksSinceCreation=0). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null), (id=Verb_Hediff_77754_0_0_VRE_Infection_Bite in loaded object directory. Id already used by RimWorld.Verb_MeleeAttackDamage RimWorld.Verb_MeleeAttackDamage(null). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register MVCF.ManagedVerb MVCF.ManagedVerb, (id=Hediff_77754_0_0_VRE_Infection_Bite_Managed in loaded object directory. Id already used by MVCF.ManagedVerb MVCF.ManagedVerb. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_FungalArmor ticksSinceCreation=16286), (id=Hediff_77783 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_FungalArmor ticksSinceCreation=0). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.HediffWithComps (VRE_FungalRegeneration ticksSinceCreation=16286), (id=Hediff_77789 in loaded object directory. Id already used by Verse.HediffWithComps (VRE_FungalRegeneration ticksSinceCreation=0). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_RotStinkExposure (LungRotExposure ticksSinceCreation=16258), (id=Hediff_78369 in loaded object directory. Id already used by Verse.Hediff_RotStinkExposure (LungRotExposure ticksSinceCreation=16258). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot left tibia ticksSinceCreation=15209), (id=Hediff_78379 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot left tibia ticksSinceCreation=15209). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot left leg ticksSinceCreation=15209), (id=Hediff_78380 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot left leg ticksSinceCreation=15209). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Bruise left leg ticksSinceCreation=15043), (id=Hediff_78382 in loaded object directory. Id already used by Verse.Hediff_Injury (Bruise left leg ticksSinceCreation=15043). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot right hand ticksSinceCreation=14860), (id=Hediff_78383 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot right hand ticksSinceCreation=14860). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot right femur ticksSinceCreation=14769), (id=Hediff_78384 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot right femur ticksSinceCreation=14769). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Gunshot right leg ticksSinceCreation=14769), (id=Hediff_78385 in loaded object directory. Id already used by Verse.Hediff_Injury (Gunshot right leg ticksSinceCreation=14769). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Hediff_Injury (Bite torso ticksSinceCreation=1816), (id=Hediff_74381 in loaded object directory. Id already used by Verse.Hediff_Injury (Bite torso ticksSinceCreation=1816). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register AlteredCarbon.Hediff_CorticalStack (VFEU_CorticalStack neck ticksSinceCreation=1816), (id=Hediff_74382 in loaded object directory. Id already used by AlteredCarbon.Hediff_CorticalStack (VFEU_CorticalStack neck ticksSinceCreation=1816). (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Cannot register Verse.Pawn Avila, (id=Thing_Human36440 in loaded object directory. Id already used by Verse.Pawn Avila. (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

As you can see, these complain about duplicate things in the object dictionary. I've looked into it a bit more than usually, and was able to link this to prisoners being sent to settlements. The things registered twice are all hediffs of a pawn and the pawn themselves. After a quick look at the code, I believe the FCPrisoner https://github.com/TheSeaMoon4/Empire-1_4-Continued-/blob/40c3627b52482e9fb2164db339b2cee29be2f2aa/1.4/Source/FactionColonies/settlements/FCPrisoner.cs class to be the likely culprit. Not only does it create a duplicate instance of the pawn's health tracker, it also exposes it twice from itself -- once via Scribe_Deep.Look(ref prisoner, "prisoner");, then again via Scribe_Deep.Look(ref healthTracker, "healthTracker", new object[] { prisoner });.

I'm now in the process of improvising a fix manually via dnSpy, but if you find a proper solution to this issue, I'll appreciate it.

— Reply to this email directly, view it on GitHub https://github.com/TheSeaMoon4/Empire-1_4-Continued-/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB7IWIGVNYZACRFLKCZABIDYWXW2BAVCNFSM6AAAAABEHOUEZ2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGE3DSNRVGE3DIMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

abel1502 commented 6 months ago

Okay, the duplicate pawn actually comes from the cortical stack hediff (which stores a dummy pawn, and so it is duplicated along with the hediff). This means only the hediffs are copied. And yes, judging from the savefile, the issue is indeed that the healthTracker is saved twice. I've cleaned up my savefile and patched the dll, so I'll be able to tell if this worked the next time I send a prisoner to a settlement, I'll be able to tell if it's worked.

As for the fix itself, I'll make a PR shortly. Essentially, I just removed the healthTracker field entirely, as it wasn't used for anything non-redundant, it seems

abel1502 commented 6 months ago

Oh, btw, I haven't looked into the 1.3 files at all, so the same fix may or may not be applicable there.

abel1502 commented 6 months ago

PR #4