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/server.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index 59bc12581..f6bf491be 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1234,7 +1234,7 @@ Inventory* Server::getInventory(const InventoryLocation &loc) return NULL; } -void Server::setInventoryModified(const InventoryLocation &loc, bool playerSend) +void Server::setInventoryModified(const InventoryLocation &loc) { switch(loc.type){ case InventoryLocation::UNDEFINED: @@ -1248,15 +1248,7 @@ void Server::setInventoryModified(const InventoryLocation &loc, bool playerSend) return; player->setModified(true); - - if (!playerSend) - return; - - PlayerSAO *playersao = player->getPlayerSAO(); - if(!playersao) - return; - - SendInventory(playersao, true); + // Updates are sent in ServerEnvironment::step() } break; case InventoryLocation::NODEMETA: @@ -1269,7 +1261,7 @@ void Server::setInventoryModified(const InventoryLocation &loc, bool playerSend) break; case InventoryLocation::DETACHED: { - sendDetachedInventory(loc.name,PEER_ID_INEXISTENT); + // Updates are sent in ServerEnvironment::step() } break; default: @@ -2617,11 +2609,16 @@ void Server::sendDetachedInventory(const std::string &name, session_t peer_id) Send(&pkt); } -void Server::sendDetachedInventories(session_t peer_id) +void Server::sendDetachedInventories(session_t peer_id, bool incremental) { for (const auto &detached_inventory : m_detached_inventories) { const std::string &name = detached_inventory.first; - //Inventory *inv = i->second; + if (incremental) { + Inventory *inv = detached_inventory.second; + if (!inv || !inv->checkModified()) + continue; + } + sendDetachedInventory(name, peer_id); } } -- cgit v1.2.3