1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Inventory: Properly revert client predictions (#8945)

Caused by incremental inventory sending
Previously everything was overwritten by serializing the entire inventory
This commit is contained in:
SmallJoker 2019-09-18 18:47:09 +02:00 committed by GitHub
parent 05a7da6279
commit 94a5df795c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View file

@ -348,6 +348,13 @@ void IMoveAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
/* If no items will be moved, don't go further */
if (count == 0) {
// Undo client prediction. See 'clientApply'
if (from_inv.type == InventoryLocation::PLAYER)
list_from->setModified();
if (to_inv.type == InventoryLocation::PLAYER)
list_to->setModified();
infostream<<"IMoveAction::apply(): move was completely disallowed:"
<<" count="<<old_count
<<" from inv=\""<<from_inv.dump()<<"\""
@ -658,8 +665,10 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player, IGame
if (actually_dropped_count == 0) {
infostream<<"Actually dropped no items"<<std::endl;
// Revert client prediction
mgr->setInventoryModified(from_inv);
// Revert client prediction. See 'clientApply'
if (from_inv.type == InventoryLocation::PLAYER)
list_from->setModified();
return;
}