summaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-04 15:27:53 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-04 15:28:33 +0100
commit7e088fdfe3c77083606bce955624aef1da59bb32 (patch)
tree00d427e45bbcac528b4aa86b3060c09454cb08cc /src/server.cpp
parentbbed01ab62bf2433e103dd18c6c07ff3f503bc57 (diff)
downloadminetest-7e088fdfe3c77083606bce955624aef1da59bb32.tar.gz
minetest-7e088fdfe3c77083606bce955624aef1da59bb32.tar.bz2
minetest-7e088fdfe3c77083606bce955624aef1da59bb32.zip
We always know playerSAO when calling SendInventory. Using it instead of searching it via peer_id
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 625ab2231..51b90ce45 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1125,7 +1125,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
SendPlayerInventoryFormspec(peer_id);
// Send inventory
- SendInventory(peer_id);
+ SendInventory(playersao);
// Send HP
if(g_settings->getBool("enable_damage"))
@@ -1329,6 +1329,7 @@ Inventory* Server::getInventory(const InventoryLocation &loc)
break;
default:
assert(0);
+ break;
}
return NULL;
}
@@ -1346,7 +1347,7 @@ void Server::setInventoryModified(const InventoryLocation &loc)
if(!playersao)
return;
- SendInventory(playersao->getPeerID());
+ SendInventory(playersao);
}
break;
case InventoryLocation::NODEMETA:
@@ -1367,6 +1368,7 @@ void Server::setInventoryModified(const InventoryLocation &loc)
break;
default:
assert(0);
+ break;
}
}
@@ -1604,23 +1606,21 @@ void Server::SendNodeDef(u16 peer_id,
Non-static send methods
*/
-void Server::SendInventory(u16 peer_id)
+void Server::SendInventory(PlayerSAO* playerSAO)
{
DSTACK(__FUNCTION_NAME);
- PlayerSAO *playersao = getPlayerSAO(peer_id);
- assert(playersao);
-
- UpdateCrafting(playersao->getPlayer());
+ UpdateCrafting(playerSAO->getPlayer());
/*
Serialize it
*/
- NetworkPacket* pkt = new NetworkPacket(TOCLIENT_INVENTORY, 0, peer_id);
+ NetworkPacket* pkt = new NetworkPacket(TOCLIENT_INVENTORY, 0,
+ playerSAO->getPeerID());
std::ostringstream os;
- playersao->getInventory()->serialize(os);
+ playerSAO->getInventory()->serialize(os);
std::string s = os.str();