ItemStack item = read_item(L, 2, getServer(L));
bool success = co->setWieldedItem(item);
if (success && co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
- getServer(L)->SendInventory(((PlayerSAO*)co)->getPeerID());
+ getServer(L)->SendInventory(((PlayerSAO*)co));
}
lua_pushboolean(L, success);
return 1;
SendPlayerInventoryFormspec(peer_id);
// Send inventory
- SendInventory(peer_id);
+ SendInventory(playersao);
// Send HP
if(g_settings->getBool("enable_damage"))
break;
default:
assert(0);
+ break;
}
return NULL;
}
if(!playersao)
return;
- SendInventory(playersao->getPeerID());
+ SendInventory(playersao);
}
break;
case InventoryLocation::NODEMETA:
break;
default:
assert(0);
+ break;
}
}
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();
void SendPlayerHPOrDie(u16 peer_id, bool die) { die ? DiePlayer(peer_id) : SendPlayerHP(peer_id); }
void SendPlayerBreath(u16 peer_id);
- void SendInventory(u16 peer_id);
+ void SendInventory(PlayerSAO* playerSAO);
void SendMovePlayer(u16 peer_id);
// Bind address