mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Have the server send the player list to the client (#5924)
* Have the server send the player list to the client Currently the client generates the player list based on the Client active object list, the issue with this is that we can't be sure all player active objects will be sent to the client, so this could result in players showing up when someone run `/status` but auto complete not working with their nick and CSM not being aware of the player
This commit is contained in:
@@ -705,6 +705,19 @@ void Server::handleCommand_ClientReady(NetworkPacket* pkt)
|
||||
peer_id, major_ver, minor_ver, patch_ver,
|
||||
full_ver);
|
||||
|
||||
const std::vector<std::string> &players = m_clients.getPlayerNames();
|
||||
NetworkPacket list_pkt(TOCLIENT_UPDATE_PLAYER_LIST, 0, peer_id);
|
||||
list_pkt << (u8) PLAYER_LIST_INIT << (u16) players.size();
|
||||
for (const std::string &player: players) {
|
||||
list_pkt << player;
|
||||
}
|
||||
m_clients.send(peer_id, 0, &list_pkt, true);
|
||||
|
||||
NetworkPacket notice_pkt(TOCLIENT_UPDATE_PLAYER_LIST, 0, PEER_ID_INEXISTENT);
|
||||
// (u16) 1 + std::string represents a pseudo vector serialization representation
|
||||
notice_pkt << (u8) PLAYER_LIST_ADD << (u16) 1 << std::string(playersao->getPlayer()->getName());
|
||||
m_clients.sendToAll(¬ice_pkt);
|
||||
|
||||
m_clients.event(peer_id, CSE_SetClientReady);
|
||||
m_script->on_joinplayer(playersao);
|
||||
// Send shutdown timer if shutdown has been scheduled
|
||||
|
Reference in New Issue
Block a user