Danimineiro / BundleOfTraits

A Rimworld Mod that adds new traits
https://steamcommunity.com/sharedfiles/filedetails/?id=2600986277
MIT License
0 stars 2 forks source link

[BUG] Repeating errors: System.NullReferenceException: Object reference not set to an instance of an object at More_Traits.BOTTraitsManager+<>c.<RemoveWrongPawnsFromSets>b__32_1 #2

Closed Taranchuk closed 2 years ago

Taranchuk commented 2 years ago

Describe the bug At first I got this error: Something went wrong and went null here: PyroPawns:False EntoPawns: False please report this to the BundleOfTraits steam page if you see this message! Then I started receiving repeating errors like these

System.NullReferenceException: Object reference not set to an instance of an object
  at More_Traits.BOTTraitsManager+<>c.<RemoveWrongPawnsFromSets>b__32_1 (Verse.Pawn p) [0x00000] in <9728081fe80840dc93c294028b7ec1ef>:0 
  at System.Collections.Generic.HashSet`1[T].RemoveWhere (System.Predicate`1[T] match) [0x0003a] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at More_Traits.BOTTraitsManager.RemoveWrongPawnsFromSets (System.Int32 whenTicksDivisibleBy) [0x0006d] in <9728081fe80840dc93c294028b7ec1ef>:0 
  at More_Traits.BOTTraitsManager.GameComponentTick () [0x00101] in <9728081fe80840dc93c294028b7ec1ef>:0 
  at Verse.GameComponentUtility.GameComponentTick () [0x00017] in <34cd8c64c0e04e56a196186f1b4f7089>:0 
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch4 (string)
Verse.GameComponentUtility:GameComponentTick ()
(wrapper dynamic-method) Verse.TickManager:Verse.TickManager.DoSingleTick_Patch5 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
(wrapper dynamic-method) Verse.Game:Verse.Game.UpdatePlay_Patch3 (Verse.Game)
Verse.Root_Play:Update ()

To Reproduce

Expected behavior No errors Logs Please attach the log files of your game here. If you use Hugs Lib you can press CTRL+F12 to copy it otherwise you can find them at C:\Users[yourUsername]\AppData\LocalLow\Ludeon Studios\RimWorld by Ludeon Studios\

Screenshots If applicable, please add screenshots to help explain the bug.

My mod list (append your mod list here)

Danimineiro commented 2 years ago

These are two different things, I fixed/reworked the first thing earlier, just haven't had it uploaded yet about the other - I think I just fixed it, don't have a good way to test this

Can you check if you still receive these errors on the newest version? (Just updated on steam)

Taranchuk commented 2 years ago

I think the latest version fixes this error. But I'm getting another one instead:

Parameter name: key
  at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].ContainsKey (TKey key) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at More_Traits.BOTTraitsManager.ManageFleeing (System.Int32 whenTicksDivisibleBy, System.Collections.Generic.HashSet`1[T] hashSet) [0x0004e] in <13ea9b63aafb43f9b83a2ac6f3eadbc6>:0 
  at More_Traits.BOTTraitsManager.GameComponentTick () [0x00008] in <13ea9b63aafb43f9b83a2ac6f3eadbc6>:0 
  at Verse.GameComponentUtility.GameComponentTick () [0x00017] in <34cd8c64c0e04e56a196186f1b4f7089>:0 
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch4 (string)
Verse.GameComponentUtility:GameComponentTick ()
(wrapper dynamic-method) Verse.TickManager:Verse.TickManager.DoSingleTick_Patch5 (Verse.TickManager)
Verse.TickManager:TickManagerUpdate ()
(wrapper dynamic-method) Verse.Game:Verse.Game.UpdatePlay_Patch3 (Verse.Game)
Verse.Root_Play:Update ()

The error repeats every 1-2 seconds

Danimineiro commented 2 years ago

It just says key and gives a trace? Right now it's 1:44 am here so I can't check it out, but I'll be back if I find anything

Taranchuk commented 2 years ago

Looks like I didn't copy the whole error message, sorry about it. It's an exception of accessing a dictionary by a null value.

System.ArgumentNullException: Value cannot be null.
Parameter name: key
  at System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry (TKey key) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].ContainsKey (TKey key) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at More_Traits.BOTTraitsManager.ManageFleeing (System.Int32 whenTicksDivisibleBy, System.Collections.Generic.HashSet`1[T] hashSet) [0x0004e] in <13ea9b63aafb43f9b83a2ac6f3eadbc6>:0 
  at More_Traits.BOTTraitsManager.GameComponentTick () [0x00008] in <13ea9b63aafb43f9b83a2ac6f3eadbc6>:0 
  at Verse.GameComponentUtility.GameComponentTick () [0x00017] in <34cd8c64c0e04e56a196186f1b4f7089>:0  
Taranchuk commented 2 years ago

Dunno what is a key though. If it's a pawn, it could be destroyed or not saved properly.

Danimineiro commented 2 years ago

stupid me, forgot to check if a pawn has a map before doing MapDic.ContainsKey(pawn.Map) (I'm caching some results so I don't have to recalculate stuff multiple times on a single map)

should be fixed in d0fa995