summaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2019-08-25 10:55:27 +0200
committerSmallJoker <mk939@ymail.com>2019-09-09 19:19:54 +0200
commitfae6242d4ef6ca34d131054484acf5efc2fcba70 (patch)
tree46d865c5f8af0bb7e67e0c105db85be210891fe1 /src/server.cpp
parenta57f951e021efb11fb7d5779d63aa36ede7a41b4 (diff)
downloadminetest-fae6242d4ef6ca34d131054484acf5efc2fcba70.tar.gz
minetest-fae6242d4ef6ca34d131054484acf5efc2fcba70.tar.bz2
minetest-fae6242d4ef6ca34d131054484acf5efc2fcba70.zip
Send cumulated inventory changes only each step (#8856)
Applies to player and detached inventories
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp23
1 files changed, 10 insertions, 13 deletions
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);
}
}