Browse Source

fix bug in place block

Kolja Strohm 3 years ago
parent
commit
ac1988b8ec
2 changed files with 4 additions and 4 deletions
  1. 1 1
      FactoryCraft/Chunk.cpp
  2. 3 3
      FactoryCraft/Dimension.cpp

+ 1 - 1
FactoryCraft/Chunk.cpp

@@ -104,7 +104,7 @@ void Chunk::generateBlock( Framework::Vec3<int> location )
 void Chunk::putBlockAt( Framework::Vec3<int> location, Block* block )
 {
     int index = (location.x * CHUNK_SIZE + location.y) * WORLD_HEIGHT + location.z;
-    assert( index < CHUNK_SIZE* CHUNK_SIZE* WORLD_HEIGHT );
+    assert( index < CHUNK_SIZE* CHUNK_SIZE* WORLD_HEIGHT && index >= 0 );
     Block* old = blocks[ index ];
     if( block )
         blockIds[ index ] = (unsigned short)block->zBlockType()->getId();

+ 3 - 3
FactoryCraft/Dimension.cpp

@@ -108,11 +108,11 @@ void Dimension::placeBlock( Framework::Vec3<int> location, Framework::Either<Blo
         if( y < 0 )
             y += CHUNK_SIZE;
         if( block.isA() )
-            c->putBlockAt( location, block );
+            c->putBlockAt( Vec3<int>( x, y, location.z ), block );
         else
         {
-            c->putBlockAt( location, 0 );
-            c->putBlockTypeAt( location, block );
+            c->putBlockAt( Vec3<int>( x, y, location.z ), 0 );
+            c->putBlockTypeAt( Vec3<int>( x, y, location.z ), block );
         }
     }
     else if( block.isA() )