diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index c340268d0..371f0d726 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -8,36 +8,36 @@ TPlayers Players::players; TSlots Players::slots; -void Players::DeletePlayer(RakNet::RakNetGUID id) +void Players::DeletePlayer(RakNet::RakNetGUID guid) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Deleting player with guid %lu", - id.g); + guid.g); - if (players[id] != 0) + if (players[guid] != 0) { LOG_APPEND(Log::LOG_INFO, "- Emptying slot %i", - players[id]->GetID()); + players[guid]->GetID()); - slots[players[id]->GetID()] = 0; - delete players[id]; - players.erase(id); + slots[players[guid]->GetID()] = 0; + delete players[guid]; + players.erase(guid); } LOG_APPEND(Log::LOG_INFO, "- %i remaining", players.size()); } -void Players::NewPlayer(RakNet::RakNetGUID id) +void Players::NewPlayer(RakNet::RakNetGUID guid) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Creating new player with guid %lu", - id.g); + guid.g); - players[id] = new Player(id); - players[id]->GetCell()->blank(); - players[id]->Npc()->blank(); - players[id]->NpcStats()->blank(); - players[id]->CreatureStats()->blank(); - players[id]->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++) { @@ -46,16 +46,16 @@ void Players::NewPlayer(RakNet::RakNetGUID id) LOG_APPEND(Log::LOG_INFO, "- Storing in slot %i", i); - slots[i] = players[id]; + slots[i] = players[guid]; slots[i]->SetID(i); break; } } } -Player *Players::GetPlayer(RakNet::RakNetGUID id) +Player *Players::GetPlayer(RakNet::RakNetGUID guid) { - return players[id]; + return players[guid]; } std::map *Players::GetPlayers() @@ -63,7 +63,7 @@ std::map *Players::GetPlayers() return &players; } -Player::Player(RakNet::RakNetGUID id) : BasePlayer(id) +Player::Player(RakNet::RakNetGUID guid) : BasePlayer(guid) { handshake = false; loaded = false; diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index 09959c9c5..5dfdf9038 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -24,9 +24,9 @@ typedef std::map TSlots; class Players { public: - static void NewPlayer(RakNet::RakNetGUID id); - static void DeletePlayer(RakNet::RakNetGUID id); - static Player *GetPlayer(RakNet::RakNetGUID id); + static void NewPlayer(RakNet::RakNetGUID guid); + static void DeletePlayer(RakNet::RakNetGUID guid); + static Player *GetPlayer(RakNet::RakNetGUID guid); static Player *GetPlayer(unsigned short id); static TPlayers *GetPlayers(); @@ -46,7 +46,7 @@ public: LOADED, POSTLOADED }; - Player(RakNet::RakNetGUID id); + Player(RakNet::RakNetGUID guid); unsigned short GetID(); void SetID(unsigned short id); diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 693ce0e29..d79977095 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -42,7 +42,7 @@ MWWorld::Ptr DedicatedPlayer::getPtr() return ptr; } -void Players::CreatePlayer(RakNet::RakNetGUID id) +void Players::CreatePlayer(RakNet::RakNetGUID guid) { LOG_APPEND(Log::LOG_INFO, "%s", "- Setting up character info"); @@ -50,7 +50,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id) MWWorld::Ptr player = world->getPlayerPtr(); ESM::NPC npc = *player.get()->mBase; - DedicatedPlayer *dedicPlayer = players[id]; + DedicatedPlayer *dedicPlayer = players[guid]; npc.mRace = dedicPlayer->Npc()->mRace; npc.mHead = dedicPlayer->Npc()->mHead; @@ -94,7 +94,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id) dedicPlayer->ptr.getBase()->canChangeCell = true; dedicPlayer->UpdatePtr(world->moveObject(dedicPlayer->ptr, cellStore, newPos.pos[0], newPos.pos[1], newPos.pos[2])); - npc.mId = players[id]->ptr.get()->mBase->mId; + npc.mId = players[guid]->ptr.get()->mBase->mId; MWWorld::ESMStore *store = const_cast(&world->getStore()); MWWorld::Store *esm_store = const_cast *> (&store->get()); @@ -103,15 +103,15 @@ void Players::CreatePlayer(RakNet::RakNetGUID id) dedicPlayer->updateCell(); - ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(id); + ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(guid); dedicPlayer->marker = mEditingMarker; dedicPlayer->setMarkerState(true); } - dedicPlayer->guid = id; + dedicPlayer->guid = guid; dedicPlayer->state = 2; - world->enable(players[id]->ptr); + world->enable(players[guid]->ptr); } @@ -121,31 +121,31 @@ void Players::CleanUp() delete it->second; } -void Players::DisconnectPlayer(RakNet::RakNetGUID id) +void Players::DisconnectPlayer(RakNet::RakNetGUID guid) { - if (players[id]->state > 1) + if (players[guid]->state > 1) { - players[id]->state = 1; + players[guid]->state = 1; // Remove player's marker - players[id]->setMarkerState(false); + players[guid]->setMarkerState(false); MWBase::World *world = MWBase::Environment::get().getWorld(); - world->disable(players[id]->getPtr()); + world->disable(players[guid]->getPtr()); // Move player to ToddTest ESM::Position newPos; world->findInteriorPosition("ToddTest", newPos); MWWorld::CellStore *store = world->getInterior("ToddTest"); - players[id]->getPtr().getBase()->canChangeCell = true; - world->moveObject(players[id]->getPtr(), store, newPos.pos[0], newPos.pos[1], newPos.pos[2]); + players[guid]->getPtr().getBase()->canChangeCell = true; + world->moveObject(players[guid]->getPtr(), store, newPos.pos[0], newPos.pos[1], newPos.pos[2]); } } -DedicatedPlayer *Players::GetPlayer(RakNet::RakNetGUID id) +DedicatedPlayer *Players::GetPlayer(RakNet::RakNetGUID guid) { - return players[id]; + return players[guid]; } MWWorld::Ptr DedicatedPlayer::getLiveCellPtr() diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index 3c86b0a4e..e3d0505de 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -172,14 +172,14 @@ void Networking::Connect(const std::string &ip, unsigned short port) void Networking::ProcessPlayerPacket(RakNet::Packet *packet) { - RakNet::RakNetGUID id; + RakNet::RakNetGUID guid; RakNet::BitStream bsIn(&packet->data[1], packet->length, false); - bsIn.Read(id); + bsIn.Read(guid); DedicatedPlayer *pl = 0; - static RakNet::RakNetGUID myid = getLocalPlayer()->guid; - if (id != myid) - pl = Players::GetPlayer(id); + static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid; + if (guid != myGuid) + pl = Players::GetPlayer(guid); PlayerPacket *myPacket = playerController.GetPacket(packet->data[0]); @@ -195,7 +195,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Received ID_GAME_BASE_INFO from server"); - if (id == myid) + if (guid == myGuid) { LOG_APPEND(Log::LOG_INFO, "%s", "- Packet was about my id"); @@ -218,17 +218,17 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) if (pl == 0) { LOG_APPEND(Log::LOG_INFO, "%s", "- Exchanging data with new player"); - pl = Players::NewPlayer(id); + pl = Players::NewPlayer(guid); } myPacket->Packet(&bsIn, pl, false); - Players::CreatePlayer(id); + Players::CreatePlayer(guid); } break; } case ID_GAME_POS: { - if (id == myid) + if (guid == myGuid) { if (packet->length != myPacket->headerSize()) { @@ -246,21 +246,21 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) case ID_USER_MYID: { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Received ID_USER_MYID from server"); - myid = id; - getLocalPlayer()->guid = id; + myGuid = guid; + getLocalPlayer()->guid = guid; break; } case ID_USER_DISCONNECTED: { - if (id == myid) + if (guid == myGuid) MWBase::Environment::get().getStateManager()->requestQuit(); else if (pl != 0) - Players::DisconnectPlayer(id); + Players::DisconnectPlayer(guid); } case ID_GAME_EQUIPMENT: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) { @@ -347,7 +347,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_DYNAMICSTATS: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) { @@ -378,7 +378,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) case ID_GAME_DIE: { LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Received ID_GAME_DIE from server"); - if (id == myid) + if (guid == myGuid) { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWMechanics::DynamicStat health = player.getClass().getCreatureStats(player).getHealth(); @@ -400,7 +400,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_RESURRECT: { - if (id == myid) + if (guid == myGuid) { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); player.getClass().getCreatureStats(player).resurrect(); @@ -431,7 +431,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_CELL: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) getLocalPlayer()->updateCell(true); @@ -450,7 +450,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_DRAWSTATE: { - if (id == myid) + if (guid == myGuid) getLocalPlayer()->updateDrawStateAndFlags(true); else if (pl != 0) { @@ -462,7 +462,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) case ID_CHAT_MESSAGE: { std::string message; - if (id == myid) + if (guid == myGuid) { myPacket->Packet(&bsIn, getLocalPlayer(), false); message = *getLocalPlayer()->ChatMessage(); @@ -478,7 +478,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_CHARGEN: { - if (id == myid) + if (guid == myGuid) { myPacket->Packet(&bsIn, getLocalPlayer(), false); } @@ -486,7 +486,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_ATTRIBUTE: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) { @@ -516,7 +516,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_SKILL: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) { @@ -546,7 +546,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_LEVEL: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) { @@ -571,7 +571,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GUI_MESSAGEBOX: { - if (id == myid) + if (guid == myGuid) { myPacket->Packet(&bsIn, getLocalPlayer(), false); @@ -590,7 +590,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_CHARCLASS: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) getLocalPlayer()->sendClass(); @@ -603,7 +603,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_INVENTORY: { - if (id == myid) + if (guid == myGuid) { if (packet->length == myPacket->headerSize()) { @@ -653,7 +653,7 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) } case ID_GAME_TIME: { - if (id == myid) + if (guid == myGuid) { myPacket->Packet(&bsIn, getLocalPlayer(), false); MWBase::World *world = MWBase::Environment::get().getWorld(); @@ -674,17 +674,17 @@ void Networking::ProcessPlayerPacket(RakNet::Packet *packet) void Networking::ProcessWorldPacket(RakNet::Packet *packet) { - RakNet::RakNetGUID id; + RakNet::RakNetGUID guid; RakNet::BitStream bsIn(&packet->data[1], packet->length, false); - bsIn.Read(id); + bsIn.Read(guid); DedicatedPlayer *pl = 0; - static RakNet::RakNetGUID myid = getLocalPlayer()->guid; - if (id != myid) - pl = Players::GetPlayer(id); + static RakNet::RakNetGUID myGuid = getLocalPlayer()->guid; + if (guid != myGuid) + pl = Players::GetPlayer(guid); WorldPacket *myPacket = worldController.GetPacket(packet->data[0]); - WorldEvent *event = new WorldEvent(id); + WorldEvent *event = new WorldEvent(guid); myPacket->Packet(&bsIn, event, false); MWWorld::CellStore *ptrCellStore;