aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-04-19 17:09:45 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-04-19 17:09:45 +0300
commit3c61d57f6d7f627b32b4a8c2f461a8e01e7ac378 (patch)
treef24f8c7f020e9ed628c4b9022d8060b005af8697 /src/server.cpp
parenta7d36a50bb330d4423d3a8dd0177a3da20d5e8f9 (diff)
downloadminetest-3c61d57f6d7f627b32b4a8c2f461a8e01e7ac378.tar.gz
minetest-3c61d57f6d7f627b32b4a8c2f461a8e01e7ac378.tar.bz2
minetest-3c61d57f6d7f627b32b4a8c2f461a8e01e7ac378.zip
item drop multiplication fix
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 6a0c13040..154603a47 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -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);
}