mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-30 00:17:13 +00:00
fix: player count mismatch (#2051)
tested that showall no longer mis-reports the number of players
This commit is contained in:
@@ -399,13 +399,17 @@ void ChatPacketHandler::HandleShowAll(Packet* packet) {
|
|||||||
|
|
||||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::CLIENT, MessageType::Client::SHOW_ALL_RESPONSE);
|
BitStreamUtils::WriteHeader(bitStream, ServiceType::CLIENT, MessageType::Client::SHOW_ALL_RESPONSE);
|
||||||
bitStream.Write<uint8_t>(!request.displayZoneData && !request.displayIndividualPlayers);
|
bitStream.Write<uint8_t>(!request.displayZoneData && !request.displayIndividualPlayers);
|
||||||
|
// there is no terminator here, the client simply reads this written number of players, if there is a mismatch
|
||||||
|
// then garbage data is printed to the screen
|
||||||
bitStream.Write(Game::playerContainer.GetPlayerCount());
|
bitStream.Write(Game::playerContainer.GetPlayerCount());
|
||||||
bitStream.Write(Game::playerContainer.GetSimCount());
|
bitStream.Write(Game::playerContainer.GetSimCount());
|
||||||
bitStream.Write<uint8_t>(request.displayIndividualPlayers);
|
bitStream.Write<uint8_t>(request.displayIndividualPlayers);
|
||||||
bitStream.Write<uint8_t>(request.displayZoneData);
|
bitStream.Write<uint8_t>(request.displayZoneData);
|
||||||
if (request.displayZoneData || request.displayIndividualPlayers) {
|
if (request.displayZoneData || request.displayIndividualPlayers) {
|
||||||
|
uint32_t writtenEntries = 0;
|
||||||
for (auto& [playerID, playerData] : Game::playerContainer.GetAllPlayers()) {
|
for (auto& [playerID, playerData] : Game::playerContainer.GetAllPlayers()) {
|
||||||
if (!playerData) continue;
|
if (!playerData) continue;
|
||||||
|
writtenEntries++;
|
||||||
bitStream.Write<uint8_t>(0); // structure packing
|
bitStream.Write<uint8_t>(0); // structure packing
|
||||||
if (request.displayIndividualPlayers) bitStream.Write(LUWString(playerData.playerName));
|
if (request.displayIndividualPlayers) bitStream.Write(LUWString(playerData.playerName));
|
||||||
if (request.displayZoneData) {
|
if (request.displayZoneData) {
|
||||||
@@ -414,6 +418,11 @@ void ChatPacketHandler::HandleShowAll(Packet* packet) {
|
|||||||
bitStream.Write(playerData.zoneID.GetCloneID());
|
bitStream.Write(playerData.zoneID.GetCloneID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (writtenEntries != Game::playerContainer.GetPlayerCount()) {
|
||||||
|
LOG("Written players does not match actual players %i != %i", writtenEntries, Game::playerContainer.GetPlayerCount());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
SystemAddress sysAddr = sender.worldServerSysAddr;
|
SystemAddress sysAddr = sender.worldServerSysAddr;
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void PlayerContainer::InsertPlayer(Packet* packet) {
|
|||||||
data.worldServerSysAddr = packet->systemAddress;
|
data.worldServerSysAddr = packet->systemAddress;
|
||||||
|
|
||||||
m_Names[data.playerID] = GeneralUtils::UTF8ToUTF16(data.playerName);
|
m_Names[data.playerID] = GeneralUtils::UTF8ToUTF16(data.playerName);
|
||||||
m_PlayerCount++;
|
if (isLogin) m_PlayerCount++;
|
||||||
|
|
||||||
LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID());
|
LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID());
|
||||||
ChatWeb::SendWSPlayerUpdate(data, isLogin ? eActivityType::PlayerLoggedIn : eActivityType::PlayerChangedZone);
|
ChatWeb::SendWSPlayerUpdate(data, isLogin ? eActivityType::PlayerLoggedIn : eActivityType::PlayerChangedZone);
|
||||||
|
|||||||
Reference in New Issue
Block a user