Browse Source

fix some bugs

Kolja Strohm 3 years ago
parent
commit
19fbcdb083

+ 1 - 0
FactoryCraft/AddEntityUpdate.cpp

@@ -22,6 +22,7 @@ void AddEntityUpdate::onUpdate( Dimension* zDimension )
 
 void AddEntityUpdate::write( Framework::StreamWriter* zWriter )
 {
+    WorldUpdate::write( zWriter );
     int id = entity->zType()->getId();
     zWriter->schreibe( (char*)&id, 4 );
     StaticRegistry<EntityType>::INSTANCE.zElement( id )->saveEntity( entity, zWriter );

+ 2 - 2
FactoryCraft/BlockType.cpp

@@ -62,7 +62,7 @@ void BlockType::createSuperBlock( Block* zBlock, Item* zItem ) const
     zBlock->maxHP = item->maxHP;
     zBlock->hardness = item->hardness;
     zBlock->speedModifier = item->speedModifier;
-    zBlock->zTool = StaticRegistry<ItemType>::INSTANCE.zElement( item->toolId );
+    zBlock->zTool = item->toolId >= 0 ? StaticRegistry<ItemType>::INSTANCE.zElement( item->toolId ) : 0;
 }
 
 void BlockType::createSuperItem( Block* zBlock, Item* zItem ) const
@@ -78,7 +78,7 @@ void BlockType::createSuperItem( Block* zBlock, Item* zItem ) const
     item->maxHP = zBlock->maxHP;
     item->hardness = zBlock->hardness;
     item->speedModifier = zBlock->speedModifier;
-    item->toolId = zBlock->zTool->getId();
+    item->toolId = zBlock->zTool ? zBlock->zTool->getId() : -1;
 }
 
 Block* BlockType::loadBlock( Framework::Vec3<int> position, Framework::StreamReader* zReader ) const

+ 1 - 1
FactoryCraft/Inventory.cpp

@@ -270,7 +270,7 @@ void Inventory::addSlot( ItemSlot* slot )
             break;
         index++;
     }
-    pullSlotsOrder->add( slot, index );
+    pushSlotsOrder->add( slot, index );
     updateCache( slot, -1 );
     cs.unlock();
 }

+ 1 - 1
FactoryCraft/ItemSlot.cpp

@@ -48,7 +48,7 @@ void ItemSlot::addItems( ItemStack* zStack, Direction dir )
             }
             else
             {
-                items = zStack->split( MIN( maxSize, items->zItem()->getMaxStackSize() ) );
+                items = zStack->split( MIN( maxSize, zStack->zItem()->getMaxStackSize() ) );
                 items->setMaxSize( MIN( maxSize, items->zItem()->getMaxStackSize() ) );
             }
         }