From fae6242d4ef6ca34d131054484acf5efc2fcba70 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sun, 25 Aug 2019 10:55:27 +0200 Subject: Send cumulated inventory changes only each step (#8856) Applies to player and detached inventories --- src/network/serverpackethandler.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/network') diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 1965d87aa..6cb3b3520 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -313,7 +313,7 @@ void Server::handleCommand_Init2(NetworkPacket* pkt) sendMediaAnnouncement(pkt->getPeerId(), lang); // Send detached inventories - sendDetachedInventories(pkt->getPeerId()); + sendDetachedInventories(pkt->getPeerId(), false); // Send time of day u16 time = m_env->getTimeOfDay(); @@ -608,10 +608,9 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt) ma->from_inv.applyCurrentPlayer(player->getName()); ma->to_inv.applyCurrentPlayer(player->getName()); - setInventoryModified(ma->from_inv, false); - if (ma->from_inv != ma->to_inv) { - setInventoryModified(ma->to_inv, false); - } + setInventoryModified(ma->from_inv); + if (ma->from_inv != ma->to_inv) + setInventoryModified(ma->to_inv); bool from_inv_is_current_player = (ma->from_inv.type == InventoryLocation::PLAYER) && @@ -676,7 +675,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt) da->from_inv.applyCurrentPlayer(player->getName()); - setInventoryModified(da->from_inv, false); + setInventoryModified(da->from_inv); /* Disable dropping items out of craftpreview @@ -712,7 +711,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt) ca->craft_inv.applyCurrentPlayer(player->getName()); - setInventoryModified(ca->craft_inv, false); + setInventoryModified(ca->craft_inv); //bool craft_inv_is_current_player = // (ca->craft_inv.type == InventoryLocation::PLAYER) && @@ -731,8 +730,6 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt) a->apply(this, playersao, this); // Eat the action delete a; - - SendInventory(playersao, true); } void Server::handleCommand_ChatMessage(NetworkPacket* pkt) -- cgit v1.2.3