RimWorld

RimWorld

Choose Your Medicine
moo 24 Jun @ 8:26pm
1.6 - Possible conflict w/ Priority Treatment
Exception in CheckCurrentToilEndOrFail for pawn Genocidal Maniac driver=JobDriver_TendPatient (toilIndex=3) driver.job=( (Job_-1))
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
[Ref 12C9FE91]
[0x0000c] in <51fded79cd284d4d911c5949aff4cb21>:0
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <51fded79cd284d4d911c5949aff4cb21>:0
at ChooseYourMedicine.Utility_GetList.GetTheCorrectMedicalCareCategory (Verse.Pawn patient, System.Boolean& useDetailed) [0x000a8] in <836b82b53d1f4ae385c9cb31021d1b2e>:0
at ChooseYourMedicine.FindBestMedicine_Prefix.Prefix (Verse.Pawn healer, Verse.Pawn patient, System.Boolean onlyUseInventory, Verse.Thing& __result) [0x00001] in <836b82b53d1f4ae385c9cb31021d1b2e>:0
at RimWorld.HealthAIUtility.FindBestMedicine (Verse.Pawn healer, Verse.Pawn patient, System.Boolean onlyUseInventory) [0x00025] in <78bd3c897ba748f7a6d21cc5498c054e>:0
- PREFIX kopp.rimworld.chooseyourmedicine: Boolean ChooseYourMedicine.FindBestMedicine_Prefix:Prefix(Pawn healer, Pawn patient, Boolean onlyUseInventory, Thing& __result)
at TKS_PriorityTreatment.TKS_PriorityTreatment.MakePriorityTreatmentJob (Verse.Pawn pawn, Verse.Pawn& sickPawn, Verse.AI.Job& queuedJob, System.String callingFunction) [0x003e2] in F:\SteamLibrary\steamapps\common\RimWorld\Mods\PriorityTreatmentRessurected\Source\PriorityTreatmentRessurected.cs:497
at TKS_PriorityTreatment.Pawn_JobTracker_Patches.TryFindAndStartJob_prefix (Verse.AI.Pawn_JobTracker& __instance) [0x0003c] in F:\SteamLibrary\steamapps\common\RimWorld\Mods\PriorityTreatmentRessurected\Source\PriorityTreatmentRessurected.cs:667
at Verse.AI.Pawn_JobTracker.TryFindAndStartJob () [0x00021] in <78bd3c897ba748f7a6d21cc5498c054e>:0
- PREFIX TKS_Ragdoll: Boolean TKS_Ragdoll.Pawn_JobTracker_patches:TryFindAndStartJob_Prefix(Pawn_JobTracker __instance)
- PREFIX TKS_PriorityTreatment: Boolean TKS_PriorityTreatment.Pawn_JobTracker_Patches:TryFindAndStartJob_prefix(Pawn_JobTracker& __instance)
at Verse.AI.Pawn_JobTracker.EndCurrentJob (Verse.AI.JobCondition condition, System.Boolean startNewJob, System.Boolean canReturnToPool) [0x001f7] in <78bd3c897ba748f7a6d21cc5498c054e>:0
at Verse.AI.JobDriver.EndJobWith (Verse.AI.JobCondition condition) [0x00028] in <78bd3c897ba748f7a6d21cc5498c054e>:0
at Verse.AI.JobDriver.CheckCurrentToilEndOrFail () [0x0009a] in <78bd3c897ba748f7a6d21cc5498c054e>:0
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.Log.Error_Patch1 (string)
Verse.AI.JobUtility:TryStartErrorRecoverJob (Verse.Pawn,string,System.Exception,Verse.AI.JobDriver)
Verse.AI.JobDriver:CheckCurrentToilEndOrFail ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.AI.JobDriver.DriverTick_Patch1 (Verse.AI.JobDriver)
Verse.AI.Pawn_JobTracker:JobTrackerTick ()
Verse.Pawn:Tick ()
Verse.Thing:DoTick ()
Verse.TickList:Tick ()
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.DoSingleTick_Patch6 (Verse.TickManager)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition:Verse.TickManager.TickManagerUpdate_Patch0 (Verse.TickManager)
Verse.Game:UpdatePlay ()
Verse.Root_Play:Update ()
< >
Showing 1-7 of 7 comments
Kopp  [developer] 25 Jun @ 1:15am 
@moo
If you give me a way to reproduce the issue, i will have a look.
And without a full log I dont even know which mod or RW version you are using...
moo 25 Jun @ 1:21am 
Unstable 1.6.

Mod pack at https://steamproxy-script.pipiskins.com/sharedfiles/filedetails/stats/3507289931

Note I already dropped Priority Treatment as it's a live mod pack so no more of these errors, so very likely something is up with PT
Last edited by moo; 25 Jun @ 1:22am
seems to be related to your toil removal in JobDriver_TendPatient_Postfix - I'm not sure what it's doing, but i've seen that fire with an index error:

Exception in CheckCurrentToilEndOrFail for pawn Alyona driver=JobDriver_TendPatient (toilIndex=3)
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

if medicine is null from FindBestMedicine(pawn, sickPawn, useOnlyInventory=false) my priority treatment creates a job without the medicine argument.

JobMaker.MakeJob(JobDefOf.TendPatient, sickPawn); //no medicine passed

Perhaps the toil has to do with missing that argument?

Of course, when I run in a simple environment w/ just your and my mods (and a few other cores) I can't reproduce.
Kopp  [developer] 9 Jul @ 12:58pm 
@-=JkJkLoL=- tk421storm
If the first hediff in vanilla gets tended without medicine, all following hediffs tended during the treatment get tended without medicine as well.
So I had to interrupt that. Thats what the postfix is doing.
Eventually there is a better way, but just doing a postfix was easier than doing a transpiler... But I will have another look.
But since it is not reproducible with PT and CYM, the cause is most likely another mod?
interesting, yeah transpilers are rough man, i avoid them like the plague. lemme know if i can help!
Kopp  [developer] 9 Jul @ 3:33pm 
@-=JkJkLoL=- tk421storm
Doesnt the following mean the index was out of range in "ChooseYourMedicine.Utility_GetList.GetTheCorrectMedicalCareCategory" ?

Exception in CheckCurrentToilEndOrFail for pawn Alyona driver=JobDriver_TendPatient (toilIndex=3)
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
[Ref 2427D69C]
at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <eae584ce26bc40229c1b1aa476bfa589>:0
at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0
at ChooseYourMedicine.Utility_GetList.GetTheCorrectMedicalCareCategory (Verse.Pawn patient) [0x000bb] in <968e7ca299844c77acc981c94d990af2>:0 #
...

I have two methods with that name that have different parameters:
One is "GetTheCorrectMedicalCareCategory(Pawn patient, out bool useDetailed)"
the other is "GetTheCorrectMedicalCareCategory(Pawn patient, Hediff firstTendedHediff, out bool useDetailed)"
The method in the stacktrace has only one parameter, so it is the first one that causes the issue? Because the out parameter is somehow ignored?

The method loops through all hediffs and adds the tendable ones to a list, then sorts them by priority, then calls the method with the same name with the parameter listOfTendableHediffs[0].
If there is no tendable hediffs, then the list is empty and we get indexOutOfRange.
I mean... The method should never have been called if there is no tendable hediffs...

I checked the toils postfix again and as long as PriorityTreatment does not add new toils to the job TendPatient, then it should not cause issues.

I will update asap and fix the possible issue mentioned above, but besides that I dont know what may cause the errors.
If it is not fixed, I guess we have to wait for a way to reproduce the issue...
ooo yeah i bet you're right! good catch!
< >
Showing 1-7 of 7 comments
Per page: 1530 50