MoveItemSomewhere double bugfix

-> Fix bug where MoveSomewhere from an infinite source would fill the destination inventory with copies of itself.
-> Fix bug where MoveSomewhere would needlessly call callbacks.
-> Remove trailing whitespaces
master
est31 2015-07-19 02:27:12 +02:00
parent 4046f3e302
commit 7bbb9b066a
2 changed files with 47 additions and 33 deletions

View File

@ -380,6 +380,10 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
// If source is infinite, reset it's stack // If source is infinite, reset it's stack
if (src_can_take_count == -1) { if (src_can_take_count == -1) {
// For the caused_by_move_somewhere == true case we didn't force-put the item,
// which guarantees there is no leftover, and code below would duplicate the
// (not replaced) to_stack_was item.
if (!caused_by_move_somewhere) {
// If destination stack is of different type and there are leftover // If destination stack is of different type and there are leftover
// items, attempt to put the leftover items to a different place in the // items, attempt to put the leftover items to a different place in the
// destination inventory. // destination inventory.
@ -392,9 +396,12 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
} }
} }
} }
}
if (move_count > 0) {
list_from->deleteItem(from_i); list_from->deleteItem(from_i);
list_from->addItem(from_i, from_stack_was); list_from->addItem(from_i, from_stack_was);
} }
}
// If destination is infinite, reset it's stack and take count from source // If destination is infinite, reset it's stack and take count from source
if(dst_can_put_count == -1){ if(dst_can_put_count == -1){
list_to->deleteItem(to_i); list_to->deleteItem(to_i);
@ -416,6 +423,13 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
<< " i=" << to_i << " i=" << to_i
<< std::endl; << std::endl;
// If we are inside the move somewhere loop, we don't need to report
// anything if nothing happened (perhaps we don't need to report
// anything for caused_by_move_somewhere == true, but this way its safer)
if (caused_by_move_somewhere && move_count == 0) {
return;
}
/* /*
Record rollback information Record rollback information
*/ */