1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

item drop multiplication fix

This commit is contained in:
Perttu Ahola 2011-04-19 17:09:45 +03:00
parent a7d36a50bb
commit 3c61d57f6d
3 changed files with 31 additions and 13 deletions

View file

@ -2470,22 +2470,27 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
dout_server<<"Placed object"<<std::endl;
// If item has count<=1, delete it
if(item->getCount() <= 1)
if(g_settings.getBool("creative_mode") == false)
{
InventoryList *ilist = player->inventory.getList("main");
if(g_settings.getBool("creative_mode") == false && ilist)
// Delete the right amount of items from the slot
u16 dropcount = item->getDropCount();
// Delete item if all gone
if(item->getCount() <= dropcount)
{
// Remove from inventory and send inventory
ilist->deleteItem(item_i);
// Send inventory
SendInventory(peer_id);
if(item->getCount() < dropcount)
dstream<<"WARNING: Server: dropped more items"
<<" than the slot contains"<<std::endl;
InventoryList *ilist = player->inventory.getList("main");
if(ilist)
// Remove from inventory and send inventory
ilist->deleteItem(item_i);
}
}
// Else decrement it
else
{
item->remove(1);
// Else decrement it
else
item->remove(dropcount);
// Send inventory
SendInventory(peer_id);
}