From 902e968fd957a3425792d750df4e617dcc94597c Mon Sep 17 00:00:00 2001 From: Koncord Date: Thu, 17 Nov 2016 13:11:42 +0800 Subject: [PATCH] Use RakNetGUID instead uint64_t in TPlayers --- apps/openmw-mp/Networking.cpp | 4 ++-- apps/openmw-mp/Player.cpp | 28 ++++++++++++++-------------- apps/openmw-mp/Player.hpp | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index af21e942b..467d6351c 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -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 { // 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 - 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 else if (pl->second->getLoadState() == Player::POSTLOADED) diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 2b9c4bfea..eb024dd94 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -13,14 +13,14 @@ void Players::deletePlayer(RakNet::RakNetGUID guid) LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu", guid.g); - if (players[guid.g] != 0) + if (players[guid] != 0) { LOG_APPEND(Log::LOG_INFO, "- Emptying slot %i", - players[guid.g]->getId()); + players[guid]->getId()); - slots[players[guid.g]->getId()] = 0; - delete players[guid.g]; - players.erase(guid.g); + slots[players[guid]->getId()] = 0; + delete players[guid]; + 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", guid.g); - players[guid.g] = new Player(guid); - players[guid.g]->getCell()->blank(); - players[guid.g]->Npc()->blank(); - players[guid.g]->NpcStats()->blank(); - players[guid.g]->CreatureStats()->blank(); - players[guid.g]->charClass.blank(); + players[guid] = new Player(guid); + players[guid]->getCell()->blank(); + players[guid]->Npc()->blank(); + players[guid]->NpcStats()->blank(); + players[guid]->CreatureStats()->blank(); + players[guid]->charClass.blank(); 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", i); - slots[i] = players[guid.g]; + slots[i] = players[guid]; slots[i]->setId(i); break; } @@ -52,10 +52,10 @@ void Players::newPlayer(RakNet::RakNetGUID guid) Player *Players::getPlayer(RakNet::RakNetGUID guid) { - return players[guid.g]; + return players[guid]; } -std::map *Players::getPlayers() +TPlayers *Players::getPlayers() { return &players; } diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index d3db0667b..51b61600e 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -19,7 +19,7 @@ #include struct Player; -typedef std::map TPlayers; +typedef std::map TPlayers; typedef std::map TSlots; class Players