Use RakNetGUID instead uint64_t in TPlayers

coverity_scan^2
Koncord 8 years ago
parent e2359b01ea
commit 902e968fd9

@ -712,10 +712,10 @@ void Networking::newPlayer(RakNet::RakNetGUID guid)
for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++) //sending other players to new player for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++) //sending other players to new player
{ {
// If we are iterating over the new player, don't send the packets below // If we are iterating over the new player, don't send the packets below
if (pl->first == guid.g) continue; if (pl->first == guid) continue;
// If an invalid key makes it into the Players map, ignore it // If an invalid key makes it into the Players map, ignore it
else if (pl->first == RakNet::UNASSIGNED_RAKNET_GUID.g) continue; else if (pl->first == RakNet::UNASSIGNED_RAKNET_GUID) continue;
// If we are iterating over a player who has inputted their name, proceed // If we are iterating over a player who has inputted their name, proceed
else if (pl->second->getLoadState() == Player::POSTLOADED) else if (pl->second->getLoadState() == Player::POSTLOADED)

@ -13,14 +13,14 @@ void Players::deletePlayer(RakNet::RakNetGUID guid)
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu", LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu",
guid.g); guid.g);
if (players[guid.g] != 0) if (players[guid] != 0)
{ {
LOG_APPEND(Log::LOG_INFO, "- Emptying slot %i", LOG_APPEND(Log::LOG_INFO, "- Emptying slot %i",
players[guid.g]->getId()); players[guid]->getId());
slots[players[guid.g]->getId()] = 0; slots[players[guid]->getId()] = 0;
delete players[guid.g]; delete players[guid];
players.erase(guid.g); players.erase(guid);
} }
} }
@ -29,12 +29,12 @@ void Players::newPlayer(RakNet::RakNetGUID guid)
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Creating new player with guid %lu", LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Creating new player with guid %lu",
guid.g); guid.g);
players[guid.g] = new Player(guid); players[guid] = new Player(guid);
players[guid.g]->getCell()->blank(); players[guid]->getCell()->blank();
players[guid.g]->Npc()->blank(); players[guid]->Npc()->blank();
players[guid.g]->NpcStats()->blank(); players[guid]->NpcStats()->blank();
players[guid.g]->CreatureStats()->blank(); players[guid]->CreatureStats()->blank();
players[guid.g]->charClass.blank(); players[guid]->charClass.blank();
for (int i = 0; i < mwmp::Networking::get().maxConnections(); i++) for (int i = 0; i < mwmp::Networking::get().maxConnections(); i++)
{ {
@ -43,7 +43,7 @@ void Players::newPlayer(RakNet::RakNetGUID guid)
LOG_APPEND(Log::LOG_INFO, "- Storing in slot %i", LOG_APPEND(Log::LOG_INFO, "- Storing in slot %i",
i); i);
slots[i] = players[guid.g]; slots[i] = players[guid];
slots[i]->setId(i); slots[i]->setId(i);
break; break;
} }
@ -52,10 +52,10 @@ void Players::newPlayer(RakNet::RakNetGUID guid)
Player *Players::getPlayer(RakNet::RakNetGUID guid) Player *Players::getPlayer(RakNet::RakNetGUID guid)
{ {
return players[guid.g]; return players[guid];
} }
std::map<uint64_t, Player*> *Players::getPlayers() TPlayers *Players::getPlayers()
{ {
return &players; return &players;
} }

@ -19,7 +19,7 @@
#include <components/openmw-mp/Base/BasePlayer.hpp> #include <components/openmw-mp/Base/BasePlayer.hpp>
struct Player; struct Player;
typedef std::map<uint64_t, Player*> TPlayers; typedef std::map<RakNet::RakNetGUID, Player*> TPlayers;
typedef std::map<unsigned short, Player*> TSlots; typedef std::map<unsigned short, Player*> TSlots;
class Players class Players

Loading…
Cancel
Save