X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Finventorymanager.cpp;h=d4e8d2f25cf43e4e3097dea225acb3eb626fabe7;hb=d4938554818aa71aceb0d360f33c6cfd42f67008;hp=bf5a7dd9d3fde94d12c5dccda203d03bd834e09e;hpb=7bbb9b066a8cc079512ddd3e6b32475309f49fca;p=minetest.git diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index bf5a7dd9d..d4e8d2f25 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -375,8 +375,9 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame If something is wrong (source item is empty, destination is the same as source), nothing happens */ + bool did_swap = false; move_count = list_from->moveItem(from_i, - list_to, to_i, count, !caused_by_move_somewhere); + list_to, to_i, count, !caused_by_move_somewhere, &did_swap); // If source is infinite, reset it's stack if (src_can_take_count == -1) { @@ -397,7 +398,7 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame } } } - if (move_count > 0) { + if (move_count > 0 || did_swap) { list_from->deleteItem(from_i); list_from->addItem(from_i, from_stack_was); } @@ -817,9 +818,9 @@ void ICraftAction::apply(InventoryManager *mgr, // Add the new replacements to the list IItemDefManager *itemdef = gamedef->getItemDefManager(); for (std::vector::iterator it = temp.begin(); - it != temp.end(); it++) { + it != temp.end(); ++it) { for (std::vector::iterator jt = output_replacements.begin(); - jt != output_replacements.end(); jt++) { + jt != output_replacements.end(); ++jt) { if (it->name == jt->name) { *it = jt->addItem(*it, itemdef); if (it->empty()) @@ -849,7 +850,7 @@ void ICraftAction::apply(InventoryManager *mgr, // Put the replacements in the inventory or drop them on the floor, if // the invenotry is full for (std::vector::iterator it = output_replacements.begin(); - it != output_replacements.end(); it++) { + it != output_replacements.end(); ++it) { if (list_main) *it = list_main->addItem(*it); if (it->empty())