forked from Mirrorlandia_minetest/minetest
We always know playerSAO when calling SendInventory. Using it instead of searching it via peer_id
This commit is contained in:
parent
bbed01ab62
commit
7e088fdfe3
@ -1391,7 +1391,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
|
|||||||
|
|
||||||
// Apply returned ItemStack
|
// Apply returned ItemStack
|
||||||
if (playersao->setWieldedItem(item)) {
|
if (playersao->setWieldedItem(item)) {
|
||||||
SendInventory(pkt->getPeerId());
|
SendInventory(playersao);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ int ObjectRef::l_set_wielded_item(lua_State *L)
|
|||||||
ItemStack item = read_item(L, 2, getServer(L));
|
ItemStack item = read_item(L, 2, getServer(L));
|
||||||
bool success = co->setWieldedItem(item);
|
bool success = co->setWieldedItem(item);
|
||||||
if (success && co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
|
if (success && co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
|
||||||
getServer(L)->SendInventory(((PlayerSAO*)co)->getPeerID());
|
getServer(L)->SendInventory(((PlayerSAO*)co));
|
||||||
}
|
}
|
||||||
lua_pushboolean(L, success);
|
lua_pushboolean(L, success);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1125,7 +1125,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
|
|||||||
SendPlayerInventoryFormspec(peer_id);
|
SendPlayerInventoryFormspec(peer_id);
|
||||||
|
|
||||||
// Send inventory
|
// Send inventory
|
||||||
SendInventory(peer_id);
|
SendInventory(playersao);
|
||||||
|
|
||||||
// Send HP
|
// Send HP
|
||||||
if(g_settings->getBool("enable_damage"))
|
if(g_settings->getBool("enable_damage"))
|
||||||
@ -1329,6 +1329,7 @@ Inventory* Server::getInventory(const InventoryLocation &loc)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1346,7 +1347,7 @@ void Server::setInventoryModified(const InventoryLocation &loc)
|
|||||||
if(!playersao)
|
if(!playersao)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SendInventory(playersao->getPeerID());
|
SendInventory(playersao);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InventoryLocation::NODEMETA:
|
case InventoryLocation::NODEMETA:
|
||||||
@ -1367,6 +1368,7 @@ void Server::setInventoryModified(const InventoryLocation &loc)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1604,23 +1606,21 @@ void Server::SendNodeDef(u16 peer_id,
|
|||||||
Non-static send methods
|
Non-static send methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Server::SendInventory(u16 peer_id)
|
void Server::SendInventory(PlayerSAO* playerSAO)
|
||||||
{
|
{
|
||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
|
|
||||||
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
UpdateCrafting(playerSAO->getPlayer());
|
||||||
assert(playersao);
|
|
||||||
|
|
||||||
UpdateCrafting(playersao->getPlayer());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Serialize it
|
Serialize it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NetworkPacket* pkt = new NetworkPacket(TOCLIENT_INVENTORY, 0, peer_id);
|
NetworkPacket* pkt = new NetworkPacket(TOCLIENT_INVENTORY, 0,
|
||||||
|
playerSAO->getPeerID());
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
playersao->getInventory()->serialize(os);
|
playerSAO->getInventory()->serialize(os);
|
||||||
|
|
||||||
std::string s = os.str();
|
std::string s = os.str();
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ public:
|
|||||||
|
|
||||||
void SendPlayerHPOrDie(u16 peer_id, bool die) { die ? DiePlayer(peer_id) : SendPlayerHP(peer_id); }
|
void SendPlayerHPOrDie(u16 peer_id, bool die) { die ? DiePlayer(peer_id) : SendPlayerHP(peer_id); }
|
||||||
void SendPlayerBreath(u16 peer_id);
|
void SendPlayerBreath(u16 peer_id);
|
||||||
void SendInventory(u16 peer_id);
|
void SendInventory(PlayerSAO* playerSAO);
|
||||||
void SendMovePlayer(u16 peer_id);
|
void SendMovePlayer(u16 peer_id);
|
||||||
|
|
||||||
// Bind address
|
// Bind address
|
||||||
|
Loading…
Reference in New Issue
Block a user