dwarfcorp icon indicating copy to clipboard operation
dwarfcorp copied to clipboard

Null reference while building voxel geometry.

Open mklingen opened this issue 6 years ago • 2 comments

https://sentry.io/organizations/cfg/issues/916167930/?project=192119&referrer=github_plugin

NullReferenceException: Object reference not set to an instance of an object.
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\Voxels\VoxelListPrimitive.cs", line 278, in BuildVoxelGeometry
    Void BuildVoxelGeometry(DwarfCorp.RawPrimitive, Int32, Int32, Int32, DwarfCorp.VoxelChunk, DwarfCorp.BoxPrimitive, Cache, DwarfCorp.DesignationSet, DwarfCorp.DesignationDrawer, DwarfCorp.WorldManager)
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\Voxels\VoxelListPrimitive.cs", line 232, in BuildSliceGeometry
    Void BuildSliceGeometry(DwarfCorp.VoxelChunk, DwarfCorp.BoxPrimitive, Cache, Int32, DwarfCorp.RawPrimitive, DwarfCorp.DesignationSet, DwarfCorp.DesignationDrawer, DwarfCorp.WorldManager)
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\Voxels\VoxelListPrimitive.cs", line 202, in InitializeFromChunk
    Void InitializeFromChunk(DwarfCorp.VoxelChunk, DwarfCorp.DesignationSet, DwarfCorp.DesignationDrawer, DwarfCorp.WorldManager)
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\Voxels\VoxelChunk.cs", line 164, in Rebuild
    Void Rebuild(Microsoft.Xna.Framework.Graphics.GraphicsDevice)
  File "C:\Users\matth\Desktop\dwarfcorp\DwarfCorp\DwarfCorpXNA\Voxels\ChunkManager.cs", line 311, in GenerateAllGeometry
    Void GenerateAllGeometry()
...
(1 additional frame(s) were not displayed)

Object reference not set to an instance of an object.

mklingen avatar Mar 04 '19 18:03 mklingen

Looking at this, somehow this is getting called with a null chunk. I broke up this function a bit to localize things, and I also added an exception early on to tell us if geometry is trying to get generated for a null chunk.

mklingen avatar Mar 04 '19 19:03 mklingen

the chunk simply can't be null here, it must be the slice geometry. Adding a bunch of asserts to slice building to get to the root of this.

mklingen avatar Mar 04 '19 19:03 mklingen