diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-09-18 18:47:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-18 18:47:09 +0200 |
commit | 94a5df795c6d591042d8c29dc4548afdd1074190 (patch) | |
tree | d175b948298a948995ad6ceee8ca4144f9bdd2aa /src/inventorymanager.cpp | |
parent | 05a7da627959afef2198f2036f4144e3d8abfbda (diff) | |
download | minetest-94a5df795c6d591042d8c29dc4548afdd1074190.tar.gz minetest-94a5df795c6d591042d8c29dc4548afdd1074190.tar.bz2 minetest-94a5df795c6d591042d8c29dc4548afdd1074190.zip |
Inventory: Properly revert client predictions (#8945)
Caused by incremental inventory sending
Previously everything was overwritten by serializing the entire inventory
Diffstat (limited to 'src/inventorymanager.cpp')
-rw-r--r-- | src/inventorymanager.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index fccfdea16..57b561477 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -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; } |