MSeal / RimworldTerrainMovementKit

A mod for other mods to add terrain specific movement options and restrictions
MIT License
1 stars 3 forks source link

Issues during road generation #4

Closed AnnanFay closed 2 years ago

AnnanFay commented 3 years ago

I have been having issues during map generation. Originally I thought it was a mod I was writing, then tracked it back to Biomes! Islands, which uses RTMK dll. It's a null reference exception in the TerrainAware_CheckCellBasedReachability delegate when pathing to build roads.

I can reproduce the issue while loading only Harmony, Core, Royalty, Ideology and RimworldTerrainMovementKit. RimWorld 1.3.3102 rev827

Initializing new game with mods:
  - brrainz.harmony
  - Ludeon.RimWorld
  - Ludeon.RimWorld.Royalty
  - Ludeon.RimWorld.Ideology
  - pyrce.terrain.movement.modkit
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Message (string)
Verse.Game:InitNewGame ()
Verse.Root_Play/<>c:<Start>b__1_2 ()
Verse.LongEventHandler:RunEventFromAnotherThread (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 ()

Error in GenStep: System.NullReferenceException: Object reference not set to an instance of an object
  at TerrainMovement.TerrainAware_CheckCellBasedReachability+<>c__DisplayClass1_0.<Prefix>b__0 (Verse.IntVec3 c) [0x000cb] in <c3fc2801130c42d7a76e3cfd013609fb>:0 
  at Verse.FloodFiller.FloodFill (Verse.IntVec3 root, System.Predicate`1[T] passCheck, System.Func`3[T1,T2,TResult] processor, System.Int32 maxCellsToProcess, System.Boolean rememberParents, System.Collections.Generic.IEnumerable`1[T] extraRoots) [0x00049] in <d243303f714d4dc48680ccaecd2f594e>:0 
  at Verse.FloodFiller.FloodFill (Verse.IntVec3 root, System.Predicate`1[T] passCheck, System.Func`2[T,TResult] processor, System.Int32 maxCellsToProcess, System.Boolean rememberParents, System.Collections.Generic.IEnumerable`1[T] extraRoots) [0x0000d] in <d243303f714d4dc48680ccaecd2f594e>:0 
  at TerrainMovement.TerrainAware_CheckCellBasedReachability.Prefix (System.Boolean& __result, Verse.Map ___map, Verse.RegionGrid ___regionGrid, System.Collections.Generic.List`1[T] ___startingRegions, System.Collections.Generic.List`1[T] ___destRegions, Verse.ReachabilityCache ___cache, Verse.Reachability __instance, Verse.IntVec3 start, Verse.LocalTargetInfo dest, Verse.AI.PathEndMode peMode, Verse.TraverseParms traverseParams) [0x000a9] in <c3fc2801130c42d7a76e3cfd013609fb>:0 
  at (wrapper dynamic-method) Verse.Reachability.Verse.Reachability.CheckCellBasedReachability_Patch1(Verse.Reachability,Verse.IntVec3,Verse.LocalTargetInfo,Verse.AI.PathEndMode,Verse.TraverseParms)
  at (wrapper dynamic-method) Verse.Reachability.Verse.Reachability.CanReach_Patch1(Verse.Reachability,Verse.IntVec3,Verse.LocalTargetInfo,Verse.AI.PathEndMode,Verse.TraverseParms)
  at TerrainMovement.TerrainAwarePathFinder.FindPath (Verse.IntVec3 start, Verse.LocalTargetInfo dest, Verse.TraverseParms traverseParms, Verse.AI.PathEndMode peMode, Verse.AI.PathFinderCostTuning tuning) [0x00170] in <c3fc2801130c42d7a76e3cfd013609fb>:0 
  at TerrainMovement.TerrainPathPatch.Prefix (Verse.AI.PawnPath& __result, Verse.Map ___map, Verse.IntVec3 start, Verse.LocalTargetInfo dest, Verse.TraverseParms traverseParms, Verse.AI.PathEndMode peMode, Verse.AI.PathFinderCostTuning tuning) [0x00007] in <c3fc2801130c42d7a76e3cfd013609fb>:0 
  at (wrapper dynamic-method) Verse.AI.PathFinder.Verse.AI.PathFinder.FindPath_Patch1(Verse.AI.PathFinder,Verse.IntVec3,Verse.LocalTargetInfo,Verse.TraverseParms,Verse.AI.PathEndMode,Verse.AI.PathFinderCostTuning)
  at RimWorld.GenStep_Roads.PrepDrawRoad (Verse.Map map, Verse.TerrainDef rockDef, Verse.IntVec3 start, Verse.IntVec3 end, RimWorld.RoadDef roadDef, RimWorld.RoadPathingDef pathingDef, Verse.IntVec3& centerpoint) [0x00054] in <d243303f714d4dc48680ccaecd2f594e>:0 
  at RimWorld.GenStep_Roads.Generate (Verse.Map map, Verse.GenStepParams parms) [0x00173] in <d243303f714d4dc48680ccaecd2f594e>:0 
  at Verse.MapGenerator.GenerateContentsIntoMap (System.Collections.Generic.IEnumerable`1[T] genStepDefs, Verse.Map map, System.Int32 seed) [0x000d2] in <d243303f714d4dc48680ccaecd2f594e>:0 
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.MapGenerator:GenerateContentsIntoMap (System.Collections.Generic.IEnumerable`1<Verse.GenStepWithParams>,Verse.Map,int)
Verse.MapGenerator:GenerateMap (Verse.IntVec3,RimWorld.Planet.MapParent,Verse.MapGeneratorDef,System.Collections.Generic.IEnumerable`1<Verse.GenStepWithParams>,System.Action`1<Verse.Map>)
Verse.Game:InitNewGame ()
Verse.Root_Play/<>c:<Start>b__1_2 ()
Verse.LongEventHandler:RunEventFromAnotherThread (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 ()

Nested FloodFill calls are not allowed. This will cause bugs.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.FloodFiller:FloodFill (Verse.IntVec3,System.Predicate`1<Verse.IntVec3>,System.Func`3<Verse.IntVec3, int, bool>,int,bool,System.Collections.Generic.IEnumerable`1<Verse.IntVec3>)
Verse.FloodFiller:FloodFill (Verse.IntVec3,System.Predicate`1<Verse.IntVec3>,System.Action`1<Verse.IntVec3>,int,bool,System.Collections.Generic.IEnumerable`1<Verse.IntVec3>)
Verse.RegionMaker:FloodFillAndAddCells (Verse.IntVec3)
Verse.RegionMaker:TryGenerateRegionFrom (Verse.IntVec3)
Verse.RegionAndRoomUpdater:RegenerateNewRegionsFromDirtyCells ()
Verse.RegionAndRoomUpdater:TryRebuildDirtyRegionsAndRooms ()
Verse.RegionGrid:GetValidRegionAt (Verse.IntVec3)
Verse.RegionAndRoomQuery:RegionAt (Verse.IntVec3,Verse.Map,Verse.RegionType)
Verse.RegionAndRoomQuery:DistrictAt (Verse.IntVec3,Verse.Map,Verse.RegionType)
Verse.RegionAndRoomQuery:RoomAt (Verse.IntVec3,Verse.Map,Verse.RegionType)
Verse.GridsUtility:GetRoom (Verse.IntVec3,Verse.Map)
Verse.GenPlace:PlaceSpotQualityAt (Verse.IntVec3,Verse.Rot4,Verse.Map,Verse.Thing,Verse.IntVec3,bool,System.Predicate`1<Verse.IntVec3>)
Verse.GenPlace:TryFindPlaceSpotNear (Verse.IntVec3,Verse.Rot4,Verse.Map,Verse.Thing,bool,Verse.IntVec3&,System.Predicate`1<Verse.IntVec3>)
Verse.GenPlace:TryPlaceThing (Verse.Thing,Verse.IntVec3,Verse.Map,Verse.ThingPlaceMode,Verse.Thing&,System.Action`2<Verse.Thing, int>,System.Predicate`1<Verse.IntVec3>,Verse.Rot4)
Verse.GenPlace:TryPlaceThing (Verse.Thing,Verse.IntVec3,Verse.Map,Verse.ThingPlaceMode,System.Action`2<Verse.Thing, int>,System.Predicate`1<Verse.IntVec3>,Verse.Rot4)
Verse.GenSpawn:CheckMoveItemsAside (Verse.IntVec3,Verse.Rot4,Verse.ThingDef,Verse.Map)
Verse.GenSpawn:Spawn (Verse.Thing,Verse.IntVec3,Verse.Map,Verse.Rot4,Verse.WipeMode,bool)
RimWorld.SketchThing:Spawn (Verse.IntVec3,Verse.Map,RimWorld.Faction,RimWorld.Sketch/SpawnMode,bool,System.Collections.Generic.List`1<Verse.Thing>,bool)
RimWorld.Sketch:Spawn (Verse.Map,Verse.IntVec3,RimWorld.Faction,RimWorld.Sketch/SpawnPosType,RimWorld.Sketch/SpawnMode,bool,bool,System.Collections.Generic.List`1<Verse.Thing>,bool,bool,System.Func`3<RimWorld.SketchEntity, Verse.IntVec3, bool>,System.Action`2<Verse.IntVec3, RimWorld.SketchEntity>)
RimWorld.GenStep_ScatterRuinsSimple:ScatterAt (Verse.IntVec3,Verse.Map,Verse.GenStepParams,int)
Verse.GenStep_Scatterer:Generate (Verse.Map,Verse.GenStepParams)
Verse.MapGenerator:GenerateContentsIntoMap (System.Collections.Generic.IEnumerable`1<Verse.GenStepWithParams>,Verse.Map,int)
Verse.MapGenerator:GenerateMap (Verse.IntVec3,RimWorld.Planet.MapParent,Verse.MapGeneratorDef,System.Collections.Generic.IEnumerable`1<Verse.GenStepWithParams>,System.Action`1<Verse.Map>)
Verse.Game:InitNewGame ()
Verse.Root_Play/<>c:<Start>b__1_2 ()
Verse.LongEventHandler:RunEventFromAnotherThread (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 ()
MSeal commented 2 years ago

FYI this should be fixed now -- I reported in discord and steam but forgot to close this thread! Thank you for reporting