sumghai / MedPod

Advanced regenerative medical beds for RimWorld
Other
14 stars 15 forks source link

Assigning more than one pawn to rescue downed pawns causes already assigned rescuers to wander #66

Closed SirHumphryApplebee closed 1 year ago

SirHumphryApplebee commented 2 years ago

Describe the bug:
Assigning more than one pawn to rescue causes already assigned rescuers to wander.

Expected behavior:
Able to assign more than one pawn to any rescue efforts

Steps to reproduce:

  1. Load provided save game.

Additional information:

A little more context to the ThinkNodes provided by the HugsLib below. The save game was provided by a third party and doesn't use DLC. There were no errors or alerts in the log when the bug presented itself. By enabling the DLC these ThinkNode errors appeared in the log. Which I have a hunch are related to [MedPod.Patches.JobDriver_WaitDowned_DecorateWaitToil_WakePatientIfKickedOffMedPod.Prefix] but I could be wrong about that.

Could not find think node with key -1299211624 UnityEngine.StackTraceUtility:ExtractStackTrace () Verse.Log:Warning (string) Verse.AI.Job:ExposeData () (wrapper dynamic-method) Verse.PostLoadIniter:Verse.PostLoadIniter.DoAllPostLoadInits_Patch0 (Verse.PostLoadIniter) (wrapper dynamic-method) Verse.ScribeLoader:Verse.ScribeLoader.FinalizeLoading_Patch0 (Verse.ScribeLoader) (wrapper dynamic-method) Verse.Game:Verse.Game.LoadGame_Patch0 (Verse.Game) (wrapper dynamic-method) Verse.SavedGameLoaderNow:Verse.SavedGameLoaderNow.LoadGameFromSaveFileNow_Patch0 (string) Verse.Root_Play/<>c:<Start>b__1_1 () (wrapper dynamic-method) Verse.LongEventHandler:Verse.LongEventHandler.RunEventFromAnotherThread_Patch0 (System.Action) Verse.LongEventHandler/<>c:<UpdateCurrentAsynchronousEvent>b__27_0 () System.Threading.ThreadHelper:ThreadStart_Context (object) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) System.Threading.ThreadHelper:ThreadStart ()

MedPodSave.zip

Video embedded on the Rimworld discord. https://discord.com/channels/214523379766525963/632790371256238120/989354498898133033

HugsLibs log https://gist.github.com/HugsLibRecordKeeper/a4b6037ae7dae7bf04ffe4906f8035af

System and Game Configuration

Operating System: Linux Physical RAM: 16GB RimWorld base game version: 1.3.3389 rev45 RimWorld DLCs loaded: Royalty, Ideology MedPod mod version: 1.4.2 MedPod mod downloaded from: Steam Your mod list: Harmony, Core, Royalty, Ideology, Hugslib, MedPod

Declaration

I hereby verify that:

sumghai commented 2 years ago

@SirHumphryApplebee - I examined the provided save file, and noticed that there were no MedPods on the map, so I tried the following scenarios:

1) Load the save file as-is, try to force two colonists to simultaneously rescue the downed villagers

2) Load the save file, dev-mode build a MedPod with a power source, try to force two colonists to simultaneously rescue the downed villagers

3) Load the save file, dev-mode build a MedPod without a power source, try to force two colonists to simultaneously rescue the downed villagers

4) Load the save file with MedPod disabled, try to force two colonists to simultaneously rescue the downed villagers

So far, I've traced the issue down to the Harmony_FloatMenuMakerMap_OverrideRescueWithMedPodVersion patch method, which looks up a colonist's Float Menu and tries to replace the base game's forced Rescue job with a MedPod-specific version; the latter is designed to first try looking for valid MedPods, then fall back to ordinary medical beds if none are available.

My current theory is that there is something in the MedPod version that causes the fallback portion of the code to be interrupted if another pawn is issued a similar job. I'll need some time to investigate further.


are related to MedPod.Patches.JobDriver_WaitDowned_DecorateWaitToil_WakePatientIfKickedOffMedPod.Prefix but I could be wrong about that.

Nope, not even close.

Those think node warnings only occur if you happen to save a game at the exact moment a pawn is in the middle of executing a job. Saving the game with all pawns idling prevents these messages, even with MedPod and all DLCs installed

sumghai commented 1 year ago

After further consultation with @SirHumphryApplebee on Discord, I've restored the original base game float menu option for rescuing patients to regular medical beds, while adding a separate MedPod-only rescue option. Simultaneous rescues will no longer be interrupted.

As a bonus, this revised approach allows players to actually play triage - consciously deciding which specific pawns should be prioritized to MedPods, and which other pawns should be relegated to regular medical beds.