cseelhoff / RimThreaded

RimThreaded is a RimWorld mod designed to enable RimWorld to utilize multiple threads.
MIT License
119 stars 21 forks source link

[Misc. Robots] Duplicate robots on first activation / errors #693

Open Niilo007 opened 2 years ago

Niilo007 commented 2 years ago

IMPORTANT:

Please first search existing bugs to ensure you are not creating a duplicate bug report!
Make sure you have the latest version of Rimworld!

Describe the bug

errors when activating misc robots, sometimes activating them for the first time generates duplicate robots. Source code for the mod: https://github.com/HaploX1/RimWorld-Miscellaneous_Source

Steps to reproduce the behavior (VERY IMPORTANT)

  1. Spawn in some hauler and or cleaner base stations (see screenshots)
  2. place and power them
  3. press the button to activate all the robots
  4. See errors
  5. possibly get duplicate robots on generation (doesn't happen all the time, test with 10+ platforms for better chance to duplicate)

Error Logs

Exception ticking AIRobot_RechargeStation_Cleaner145645 (at (196, 0, 253)): System.ArgumentException: An item with the same key has already been added. Key: AIRobot_Cleaner
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000c1] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at TinyTweaks.Patch_ThingDef+AllRecipes_Getter.Postfix (Verse.ThingDef __instance, System.Collections.Generic.List`1[Verse.RecipeDef]& __result) [0x00046] in <1dcc1f55c52947528599a17177735602>:0 
  at (wrapper dynamic-method) Verse.ThingDef.Verse.ThingDef.get_AllRecipes_Patch3(Verse.ThingDef)
  at (wrapper dynamic-method) Verse.ThingListGroupHelper.Verse.ThingListGroupHelper.Includes_Patch1(Verse.ThingRequestGroup,Verse.ThingDef)
  at RimThreaded.ListerThings_Patch.Add (Verse.ListerThings __instance, Verse.Thing t) [0x00088] in <86c14ce4cb7c40ce813d62d5517d4792>:0 
  at (wrapper dynamic-method) Verse.ListerThings.Verse.ListerThings.Add_Patch2(Verse.ListerThings,Verse.Thing)
  at (wrapper dynamic-method) Verse.RegionListersUpdater.Verse.RegionListersUpdater.RegisterInRegions_Patch0(Verse.Thing,Verse.Map)
  at (wrapper dynamic-method) Verse.Thing.Verse.Thing.SpawnSetup_Patch1(Verse.Thing,Verse.Map,bool)
  at Verse.ThingWithComps.SpawnSetup (Verse.Map map, System.Boolean respawningAfterLoad) [0x00000] in <b64badbf3c3d41018b3ca5d3e8c77771>:0 
  at (wrapper dynamic-method) Verse.Pawn.Verse.Pawn.SpawnSetup_Patch4(Verse.Pawn,Verse.Map,bool)
  at AIRobot.X2_AIRobot.SpawnSetup (Verse.Map map, System.Boolean respawningAfterLoad) [0x00001] in <2eaa452ef4364e41ac2c897d46232355>:0 
  at (wrapper dynamic-method) Verse.GenSpawn.Verse.GenSpawn.Spawn_Patch5(Verse.Thing,Verse.IntVec3,Verse.Map,Verse.Rot4,Verse.WipeMode,bool)
  at AIRobot.X2_Building_AIRobotCreator.Spawn (Verse.Thing newThing, Verse.IntVec3 loc, Verse.Map map, Verse.Rot4 rot) [0x00001] in <2eaa452ef4364e41ac2c897d46232355>:0 
  at AIRobot.X2_Building_AIRobotCreator.Spawn (Verse.Thing newThing, Verse.IntVec3 loc, Verse.Map map) [0x00009] in <2eaa452ef4364e41ac2c897d46232355>:0 
  at AIRobot.X2_Building_AIRobotCreator.CreateRobot (System.String pawnDefName, Verse.IntVec3 position, Verse.Map map, RimWorld.Faction faction) [0x000e0] in <2eaa452ef4364e41ac2c897d46232355>:0 
  at AIRobot.X2_Building_AIRobotRechargeStation.Button_SpawnBot () [0x000f7] in <2eaa452ef4364e41ac2c897d46232355>:0 
  at AIRobot.X2_Building_AIRobotRechargeStation.Tick () [0x00045] in <2eaa452ef4364e41ac2c897d46232355>:0 
  at RimThreaded.TickList_Patch.NormalThingTick () [0x00025] in <86c14ce4cb7c40ce813d62d5517d4792>:0 
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch3 (string)
RimThreaded.TickList_Patch:NormalThingTick ()
RimThreaded.RimThreaded:ExecuteTicks ()
RimThreaded.RimThreaded:ProcessTicks (RimThreaded.RimThreaded/ThreadInfo)
RimThreaded.RimThreaded:InitializeThread (object)
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 (object)
Error while generating pawn. Rethrowing. Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Collections.Generic.List`1[T].RemoveAt (System.Int32 index) [0x00009] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at Verse.GenCollection.RemoveLast[T] (System.Collections.Generic.List`1[T] list) [0x00007] in <b64badbf3c3d41018b3ca5d3e8c77771>:0 
  at (wrapper dynamic-method) Verse.PawnGenerator.Verse.PawnGenerator.TryGenerateNewPawnInternal_Patch0(Verse.PawnGenerationRequest&,string&,bool,bool)
  at (wrapper dynamic-method) Verse.PawnGenerator.Verse.PawnGenerator.GenerateNewPawnInternal_Patch1(Verse.PawnGenerationRequest&)
  at Verse.PawnGenerator.GenerateOrRedressPawnInternal (Verse.PawnGenerationRequest request) [0x00183] in <b64badbf3c3d41018b3ca5d3e8c77771>:0 
  at (wrapper dynamic-method) Verse.PawnGenerator.Verse.PawnGenerator.GeneratePawn_Patch3(Verse.PawnGenerationRequest)
UnityEngine.StackTraceUtility:ExtractStackTrace ()
(wrapper dynamic-method) Verse.Log:Verse.Log.Error_Patch3 (string)
(wrapper dynamic-method) Verse.PawnGenerator:Verse.PawnGenerator.GeneratePawn_Patch3 (Verse.PawnGenerationRequest)
AIRobot.X2_Building_AIRobotCreator:CreateRobot (string,Verse.IntVec3,Verse.Map,RimWorld.Faction)
AIRobot.X2_Building_AIRobotRechargeStation:Button_SpawnBot ()
AIRobot.X2_Building_AIRobotRechargeStation:Tick ()
RimThreaded.TickList_Patch:NormalThingTick ()
RimThreaded.RimThreaded:ExecuteTicks ()
RimThreaded.RimThreaded:ProcessTicks (RimThreaded.RimThreaded/ThreadInfo)
RimThreaded.RimThreaded:InitializeThread (object)
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 (object)

Player.log

!!! Link to contents of Player.log or Error.log (MUST BE LINK) !!!

HugsLib log

https://gist.github.com/bb904990ac7e121b861ca86cd5e6c807

Save file

!!! Please add a save file where the issue occurs to speed up testing and fixing of the issue !!!

Screenshots

image image image image image

Mod list (Preferably a RimPy compatible list.)

Niilo007 commented 2 years ago

Here is what it looks like when there are duplicate robots

image

sealvessel commented 2 years ago

I can confirm that this also happens on Misc. Robots++. I had a grid of omnibots that I deactivated+reactivated and somehow I keep getting extra omnibots. There is also a numbering issue when you toggle between omnibots and at some point I reached omnibot number 666.