diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-09-02 22:51:38 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-09-02 22:51:38 +0300 |
commit | e1a495ee306290b3bec2de9aa298aac1528e9243 (patch) | |
tree | 352db0aedb58fa4a26790227c388d0773f05279f /src/inventorymanager.cpp | |
parent | 6495007924d8907ddfff14be09d38a4b1745b95a (diff) | |
download | minetest-e1a495ee306290b3bec2de9aa298aac1528e9243.tar.gz minetest-e1a495ee306290b3bec2de9aa298aac1528e9243.tar.bz2 minetest-e1a495ee306290b3bec2de9aa298aac1528e9243.zip |
Make inventory GUI do sane things when server-side inventory acts unusually
Diffstat (limited to 'src/inventorymanager.cpp')
-rw-r--r-- | src/inventorymanager.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index e2e537838..1a7f56f31 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -332,6 +332,18 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame // If source is infinite, reset it's stack if(src_can_take_count == -1){ + // If destination stack is of different type and there are leftover + // items, attempt to put the leftover items to a different place in the + // destination inventory. + // The client-side GUI will try to guess if this happens. + if(from_stack_was.name != to_stack_was.name){ + for(u32 i=0; i<list_to->getSize(); i++){ + if(list_to->getItem(i).empty()){ + list_to->changeItem(i, to_stack_was); + break; + } + } + } list_from->deleteItem(from_i); list_from->addItem(from_i, from_stack_was); } |