vegapnk / RJW-Genes

Rimworld Biotech Genes related to RJW
MIT License
25 stars 28 forks source link

Issue Pheromones + Babies #25

Closed vegapnk closed 1 year ago

vegapnk commented 1 year ago

Summary: Lots of Errors when a pawn with aphrodisiac gene carries or feeds a baby.

I got a bug-report over discord here: https://gist.github.com/HugsLibRecordKeeper/f28aed8f04d2532824ca47c68e3c5f12

Error starts at L4900 and goes on repeating itself. Copied here:

Soyuz caught this error. Please don't report this to the RocketMan team unless you're certain RocketMan caused this error. with error System.NullReferenceException: Object reference not set to an instance of an object
  at CombatAI.CompCache.GetComp_Fast[T] (Verse.Map map) [0x0002e] in <ce82bcaeae1c45afb79f0e6c0e85c327>:0 
  at CombatAI.Patches.GenSight_Patch+GenSight_LineOfSight1_Patch.Prefix (Verse.IntVec3 start, Verse.IntVec3 end, Verse.Map map, System.Boolean skipFirstCell, System.Func`2[Verse.IntVec3,System.Boolean]& validator, System.Int32 halfXOffset, System.Int32 halfZOffset) [0x0000e] in <ce82bcaeae1c45afb79f0e6c0e85c327>:0 
  at (wrapper dynamic-method) Verse.GenSight.Verse.GenSight.LineOfSight_Patch1(Verse.IntVec3,Verse.IntVec3,Verse.Map,bool,System.Func`2<Verse.IntVec3, bool>,int,int)
  at RJW_Genes.Gene_Aphrodisiac_Pheromones+<AffectedPawns>d__4.MoveNext () [0x00095] in <e62e4e1721524e27adb32ac39d6ceac0>:0 
  at RJW_Genes.Gene_Aphrodisiac_Pheromones.Tick () [0x00075] in <e62e4e1721524e27adb32ac39d6ceac0>:0 
  at RimWorld.Pawn_GeneTracker.GeneTrackerTick () [0x00073] in <38562b1a2ab64eacb931fb5df05ca994>:0 
  at (wrapper dynamic-method) Verse.Pawn.Verse.Pawn.Tick_Patch2(Verse.Pawn) 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

I can repeat this, but I get the following error:

Exception ticking Prince (at (148, 0, 127)): System.NullReferenceException: Object reference not set to an instance of an object
  at Verse.GenGrid.InBounds (Verse.IntVec3 c, Verse.Map map) [0x00000] in <38562b1a2ab64eacb931fb5df05ca994>:0 
  at Verse.GenSight.LineOfSight (Verse.IntVec3 start, Verse.IntVec3 end, Verse.Map map, System.Boolean skipFirstCell, System.Func`2[T,TResult] validator, System.Int32 halfXOffset, System.Int32 halfZOffset) [0x00000] in <38562b1a2ab64eacb931fb5df05ca994>:0 
  at RJW_Genes.Gene_Aphrodisiac_Pheromones+<AffectedPawns>d__4.MoveNext () [0x00095] in <bb68597e35094c54acf619f9b6d5c4c1>:0 
  at RJW_Genes.Gene_Aphrodisiac_Pheromones.Tick () [0x00075] in <bb68597e35094c54acf619f9b6d5c4c1>:0 
  at RimWorld.Pawn_GeneTracker.GeneTrackerTick () [0x00037] in <38562b1a2ab64eacb931fb5df05ca994>:0 
  at Verse.Pawn.Tick () [0x00241] in <38562b1a2ab64eacb931fb5df05ca994>:0 
  at Verse.TickList.Tick () [0x0015c] in <38562b1a2ab64eacb931fb5df05ca994>:0 
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.TickList:Tick ()
(wrapper dynamic-method) Verse.TickManager:Verse.TickManager.DoSingleTick_Patch2 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
Verse.Game:UpdatePlay ()
Verse.Root_Play:Update ()

The throwing line is here: https://github.com/vegapnk/RJW-Genes/blob/90204f913474fe86914a415dd982aeebad02b529/Source/Genes/Special/Gene_Aphrodisiac_Pheromones.cs#L43

My guess: The baby is a pawn, but has no position, but has a map, while being fed.

Potential solution: Check for babies and or being carried. Also maybe check for sex-need that should also rule out babies.