diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-04 11:29:34 +0100 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-03-04 11:29:39 +0100 |
commit | 1b2f64473ed4f222d3b7f02df853730d4382105e (patch) | |
tree | 820e24b348438ce79dc5e183774e4bd091d2d3a9 /src/server.cpp | |
parent | 038d3a31dfa6c382a5a5a57f2ce367d1cd67fb9f (diff) | |
download | minetest-1b2f64473ed4f222d3b7f02df853730d4382105e.tar.gz minetest-1b2f64473ed4f222d3b7f02df853730d4382105e.tar.bz2 minetest-1b2f64473ed4f222d3b7f02df853730d4382105e.zip |
Send Inventory packet on event, don't check it at each AsyncRunStep.
* Call UpdateCrafting into SendInventory because this functions is only called before SendInventory
* Use Player* instead of peer_id for UpdateCrafting because SendInventory already has the Player* pointer, then don't loop for searching Player* per peer_id
* m_env_mutex don't need to be used with this modification because it's already locked before the calls
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/server.cpp b/src/server.cpp index cafeb951d..0bb91d758 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -609,14 +609,6 @@ void Server::AsyncRunStep(bool initial_step) SendMovePlayer(*i); playersao->m_moved = false; } - - /* - Send player inventories if necessary - */ - if(playersao->m_inventory_not_sent) { - UpdateCrafting(*i); - SendInventory(*i); - } } } @@ -1164,7 +1156,6 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id) SendPlayerInventoryFormspec(peer_id); // Send inventory - UpdateCrafting(peer_id); SendInventory(peer_id); // Send HP @@ -1385,7 +1376,8 @@ void Server::setInventoryModified(const InventoryLocation &loc) PlayerSAO *playersao = player->getPlayerSAO(); if(!playersao) return; - playersao->m_inventory_not_sent = true; + + SendInventory(playersao->getPeerID()); } break; case InventoryLocation::NODEMETA: @@ -1650,7 +1642,7 @@ void Server::SendInventory(u16 peer_id) PlayerSAO *playersao = getPlayerSAO(peer_id); assert(playersao); - playersao->m_inventory_not_sent = false; + UpdateCrafting(playersao->getPlayer()); /* Serialize it @@ -2701,13 +2693,10 @@ void Server::DeleteClient(u16 peer_id, ClientDeletionReason reason) SendChatMessage(PEER_ID_INEXISTENT,message); } -void Server::UpdateCrafting(u16 peer_id) +void Server::UpdateCrafting(Player* player) { DSTACK(__FUNCTION_NAME); - Player* player = m_env->getPlayer(peer_id); - assert(player); - // Get a preview for crafting ItemStack preview; InventoryLocation loc; |