From 809b4d78baa01f48fd53c4945fb50ff7213d24ab Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 30 Apr 2017 14:57:43 +0300 Subject: [PATCH] [Client] Split off DedicatedPlayer and PlayerList into different files --- apps/openmw/CMakeLists.txt | 4 +- apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwmechanics/actors.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 2 +- apps/openmw/mwmechanics/combat.cpp | 2 +- .../mwmechanics/mechanicsmanagerimp.cpp | 2 +- apps/openmw/mwmechanics/spellcasting.cpp | 2 +- apps/openmw/mwmp/DedicatedPlayer.cpp | 196 ---------------- apps/openmw/mwmp/DedicatedPlayer.hpp | 22 -- apps/openmw/mwmp/GUIController.cpp | 1 + apps/openmw/mwmp/Main.cpp | 1 + apps/openmw/mwmp/MechanicsHelper.cpp | 1 + apps/openmw/mwmp/PlayerList.cpp | 217 ++++++++++++++++++ apps/openmw/mwmp/PlayerList.hpp | 47 ++++ apps/openmw/mwmp/PlayerProcessor.cpp | 2 - apps/openmw/mwmp/PlayerProcessor.hpp | 1 + apps/openmw/mwworld/inventorystore.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 1 + 19 files changed, 279 insertions(+), 230 deletions(-) create mode 100644 apps/openmw/mwmp/PlayerList.cpp create mode 100644 apps/openmw/mwmp/PlayerList.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 4f4b5197f..d0179478c 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -96,8 +96,8 @@ add_openmw_dir (mwbase inputmanager windowmanager statemanager ) -add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer LocalActor DedicatedActor ActorList WorldEvent Cell - CellController MechanicsHelper GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList +add_openmw_dir (mwmp Main Networking LocalPlayer DedicatedPlayer PlayerList LocalActor DedicatedActor ActorList WorldEvent + Cell CellController MechanicsHelper GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList BaseClientPacketProcessor PlayerProcessor WorldProcessor ActorProcessor ProcessorInitializer) add_openmw_dir (mwmp\\processors\\actor ProcessorActorAnimFlags ProcessorActorAnimPlay ProcessorActorAttack diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 41e14cf2d..fb6b02e29 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -13,7 +13,7 @@ #include #include "../mwmp/Main.hpp" #include "../mwmp/LocalPlayer.hpp" -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/CellController.hpp" #include "../mwmp/MechanicsHelper.hpp" /* diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 52a470d24..6e6da347c 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -16,7 +16,7 @@ #include #include "../mwmp/Main.hpp" #include "../mwmp/LocalPlayer.hpp" -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/CellController.hpp" #include "../mwmp/MechanicsHelper.hpp" /* diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index e092dc8fc..36d2a8360 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -19,7 +19,7 @@ #include #include "../mwmp/Main.hpp" #include "../mwmp/LocalPlayer.hpp" -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/CellController.hpp" #include "../mwmp/MechanicsHelper.hpp" /* diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index c18003b44..f27f8bcb1 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -36,7 +36,7 @@ #include "../mwmp/Main.hpp" #include "../mwmp/LocalPlayer.hpp" #include "../mwmp/LocalActor.hpp" -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/CellController.hpp" #include "../mwmp/MechanicsHelper.hpp" /* diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index dc0e41102..ca57c1620 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -12,7 +12,7 @@ #include #include "../mwmp/Main.hpp" #include "../mwmp/LocalPlayer.hpp" -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/CellController.hpp" #include "../mwmp/MechanicsHelper.hpp" /* diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index cfa1186c4..b060ace3e 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -15,7 +15,7 @@ Include additional headers for multiplayer purposes */ #include "../mwmp/Main.hpp" -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/CellController.hpp" /* End of tes3mp addition diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index f20ca14d3..e2d8dea55 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -15,7 +15,7 @@ */ #include #include "../mwmp/Main.hpp" -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/LocalPlayer.hpp" #include "../mwmp/MechanicsHelper.hpp" /* diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 9f06b8280..cc4604f58 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -39,8 +39,6 @@ using namespace mwmp; using namespace std; -std::map PlayerList::players; - DedicatedPlayer::DedicatedPlayer(RakNet::RakNetGUID guid) : BasePlayer(guid) { attack.pressed = 0; @@ -52,200 +50,6 @@ DedicatedPlayer::~DedicatedPlayer() } -void PlayerList::update(float dt) -{ - for (std::map ::iterator it = players.begin(); it != players.end(); it++) - { - DedicatedPlayer *player = it->second; - if (player == 0) continue; - - player->update(dt); - } -} - -void PlayerList::createPlayer(RakNet::RakNetGUID guid) -{ - LOG_APPEND(Log::LOG_INFO, "- Setting up character info"); - - MWBase::World *world = MWBase::Environment::get().getWorld(); - - DedicatedPlayer *dedicPlayer = players[guid]; - - ESM::Creature creature; - ESM::NPC npc; - if (!dedicPlayer->creatureModel.empty()) - { - const ESM::Creature *tmpCreature = world->getStore().get().search(dedicPlayer->creatureModel); - if(tmpCreature == 0) - { - dedicPlayer->creatureModel = ""; - createPlayer(guid); - return; - } - creature = *tmpCreature; - creature.mScript = ""; - if(!dedicPlayer->useCreatureName) - creature.mName = dedicPlayer->npc.mName; - } - else - { - MWWorld::Ptr player = world->getPlayerPtr(); - - npc = *player.get()->mBase; - - // To avoid freezes caused by invalid races, only set race if we find it - // on our client - if (world->getStore().get().search(dedicPlayer->npc.mRace) != 0) - npc.mRace = dedicPlayer->npc.mRace; - - npc.mHead = dedicPlayer->npc.mHead; - npc.mHair = dedicPlayer->npc.mHair; - npc.mClass = dedicPlayer->npc.mClass; - npc.mName = dedicPlayer->npc.mName; - npc.mFlags = dedicPlayer->npc.mFlags; - } - - if (dedicPlayer->state == 0) - { - string recid; - if (dedicPlayer->creatureModel.empty()) - { - npc.mId = "Dedicated Player"; - recid = world->createRecord(npc)->mId; - } - else - { - creature.mId = "Dedicated Player"; - recid = world->createRecord(creature)->mId; - } - - dedicPlayer->reference = new MWWorld::ManualRef(world->getStore(), recid, 1); - } - - // Temporarily spawn or move player to the center of exterior 0,0 whenever setting base info - ESM::Position spawnPos; - spawnPos.pos[0] = spawnPos.pos[1] = Main::get().getCellController()->getCellSize() / 2; - spawnPos.pos[2] = 0; - MWWorld::CellStore *cellStore = world->getExterior(0, 0); - - if (dedicPlayer->state == 0) - { - LOG_APPEND(Log::LOG_INFO, "- Creating new reference pointer for %s", dedicPlayer->npc.mName.c_str()); - - MWWorld::Ptr tmp = world->placeObject(dedicPlayer->reference->getPtr(), cellStore, spawnPos); - - dedicPlayer->ptr.mCell = tmp.mCell; - dedicPlayer->ptr.mRef = tmp.mRef; - - dedicPlayer->cell = *dedicPlayer->ptr.getCell()->getCell(); - dedicPlayer->position = dedicPlayer->ptr.getRefData().getPosition(); - } - else - { - LOG_APPEND(Log::LOG_INFO, "- Updating reference pointer for %s", dedicPlayer->npc.mName.c_str()); - - MWWorld::ESMStore *store = const_cast(&world->getStore()); - - if (!dedicPlayer->creatureModel.empty()) - { - creature.mId = players[guid]->ptr.get()->mBase->mId; - MWWorld::Store *esm_store = const_cast *> (&store->get()); - esm_store->insert(creature); - - } - else - { - npc.mId = players[guid]->ptr.get()->mBase->mId; - MWWorld::Store *esm_store = const_cast *> (&store->get()); - esm_store->insert(npc); - } - - // Disable Ptr to avoid graphical glitches caused by race changes - world->disable(players[guid]->ptr); - - dedicPlayer->setPtr(world->moveObject(dedicPlayer->ptr, cellStore, spawnPos.pos[0], spawnPos.pos[1], spawnPos.pos[2])); - dedicPlayer->updateCell(); - - ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(guid); - dedicPlayer->marker = mEditingMarker; - dedicPlayer->setMarkerState(true); - } - - dedicPlayer->guid = guid; - dedicPlayer->state = 2; - - // Give this new character a fatigue of at least 1 so it doesn't spawn - // on the ground - dedicPlayer->creatureStats.mDynamic[2].mBase = 1; - - world->enable(players[guid]->ptr); -} - -DedicatedPlayer *PlayerList::newPlayer(RakNet::RakNetGUID guid) -{ - LOG_APPEND(Log::LOG_INFO, "- Creating new DedicatedPlayer with guid %lu", guid.g); - - players[guid] = new DedicatedPlayer(guid); - players[guid]->state = 0; - return players[guid]; -} - -void PlayerList::disconnectPlayer(RakNet::RakNetGUID guid) -{ - if (players[guid]->state > 1) - { - players[guid]->state = 1; - - // Remove player's marker - players[guid]->setMarkerState(false); - - MWBase::World *world = MWBase::Environment::get().getWorld(); - world->disable(players[guid]->getPtr()); - - // Move player to exterior 0,0 - ESM::Position newPos; - newPos.pos[0] = newPos.pos[1] = Main::get().getCellController()->getCellSize() / 2; - newPos.pos[2] = 0; - MWWorld::CellStore *cellStore = world->getExterior(0, 0); - - world->moveObject(players[guid]->getPtr(), cellStore, newPos.pos[0], newPos.pos[1], newPos.pos[2]); - } -} - -void PlayerList::cleanUp() -{ - for (std::map ::iterator it = players.begin(); it != players.end(); it++) - delete it->second; -} - -DedicatedPlayer *PlayerList::getPlayer(RakNet::RakNetGUID guid) -{ - return players[guid]; -} - -DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr) -{ - std::map ::iterator it = players.begin(); - - for (; it != players.end(); it++) - { - if (it->second == 0 || it->second->getPtr().mRef == 0) - continue; - string refid = ptr.getCellRef().getRefId(); - if (it->second->getPtr().getCellRef().getRefId() == refid) - return it->second; - } - return 0; -} - -bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr) -{ - if (ptr.mRef == NULL) - return false; - - return (getPlayer(ptr) != 0); -} - void DedicatedPlayer::update(float dt) { MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr); diff --git a/apps/openmw/mwmp/DedicatedPlayer.hpp b/apps/openmw/mwmp/DedicatedPlayer.hpp index e1e2215ed..3307d7045 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.hpp +++ b/apps/openmw/mwmp/DedicatedPlayer.hpp @@ -25,28 +25,6 @@ namespace mwmp { struct DedicatedPlayer; - class PlayerList - { - public: - - static void update(float dt); - - static void createPlayer(RakNet::RakNetGUID guid); - static DedicatedPlayer *newPlayer(RakNet::RakNetGUID guid); - - static void disconnectPlayer(RakNet::RakNetGUID guid); - static void cleanUp(); - - static DedicatedPlayer *getPlayer(RakNet::RakNetGUID guid); - static DedicatedPlayer *getPlayer(const MWWorld::Ptr &ptr); - - static bool isDedicatedPlayer(const MWWorld::Ptr &ptr); - - private: - - static std::map players; - }; - class DedicatedPlayer : public BasePlayer { friend class PlayerList; diff --git a/apps/openmw/mwmp/GUIController.cpp b/apps/openmw/mwmp/GUIController.cpp index 4f74ad7bd..d253b7d7d 100644 --- a/apps/openmw/mwmp/GUIController.cpp +++ b/apps/openmw/mwmp/GUIController.cpp @@ -35,6 +35,7 @@ #include "GUIChat.hpp" #include "LocalPlayer.hpp" #include "DedicatedPlayer.hpp" +#include "PlayerList.hpp" mwmp::GUIController::GUIController(): mInputBox(0), mListBox(0) diff --git a/apps/openmw/mwmp/Main.cpp b/apps/openmw/mwmp/Main.cpp index c5a3da206..6babd07a8 100644 --- a/apps/openmw/mwmp/Main.cpp +++ b/apps/openmw/mwmp/Main.cpp @@ -41,6 +41,7 @@ #include "Networking.hpp" #include "LocalPlayer.hpp" #include "DedicatedPlayer.hpp" +#include "PlayerList.hpp" #include "GUIController.hpp" #include "CellController.hpp" #include "MechanicsHelper.hpp" diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index b4477c791..b436fae75 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -16,6 +16,7 @@ #include "Main.hpp" #include "LocalPlayer.hpp" #include "DedicatedPlayer.hpp" +#include "PlayerList.hpp" #include "CellController.hpp" using namespace mwmp; diff --git a/apps/openmw/mwmp/PlayerList.cpp b/apps/openmw/mwmp/PlayerList.cpp new file mode 100644 index 000000000..c89bdf2b3 --- /dev/null +++ b/apps/openmw/mwmp/PlayerList.cpp @@ -0,0 +1,217 @@ +#include + +#include "../mwbase/environment.hpp" + +#include "../mwclass/npc.hpp" + +#include "../mwmechanics/creaturestats.hpp" + +#include "../mwworld/cellstore.hpp" +#include "../mwworld/player.hpp" +#include "../mwworld/worldimp.hpp" + +#include "PlayerList.hpp" +#include "Main.hpp" +#include "DedicatedPlayer.hpp" +#include "CellController.hpp" +#include "GUIController.hpp" + + +using namespace mwmp; +using namespace std; + +std::map PlayerList::players; + +void PlayerList::update(float dt) +{ + for (std::map ::iterator it = players.begin(); it != players.end(); it++) + { + DedicatedPlayer *player = it->second; + if (player == 0) continue; + + player->update(dt); + } +} + +void PlayerList::createPlayer(RakNet::RakNetGUID guid) +{ + LOG_APPEND(Log::LOG_INFO, "- Setting up character info"); + + MWBase::World *world = MWBase::Environment::get().getWorld(); + + DedicatedPlayer *dedicPlayer = players[guid]; + + ESM::Creature creature; + ESM::NPC npc; + if (!dedicPlayer->creatureModel.empty()) + { + const ESM::Creature *tmpCreature = world->getStore().get().search(dedicPlayer->creatureModel); + if(tmpCreature == 0) + { + dedicPlayer->creatureModel = ""; + createPlayer(guid); + return; + } + creature = *tmpCreature; + creature.mScript = ""; + if(!dedicPlayer->useCreatureName) + creature.mName = dedicPlayer->npc.mName; + } + else + { + MWWorld::Ptr player = world->getPlayerPtr(); + + npc = *player.get()->mBase; + + // To avoid freezes caused by invalid races, only set race if we find it + // on our client + if (world->getStore().get().search(dedicPlayer->npc.mRace) != 0) + npc.mRace = dedicPlayer->npc.mRace; + + npc.mHead = dedicPlayer->npc.mHead; + npc.mHair = dedicPlayer->npc.mHair; + npc.mClass = dedicPlayer->npc.mClass; + npc.mName = dedicPlayer->npc.mName; + npc.mFlags = dedicPlayer->npc.mFlags; + } + + if (dedicPlayer->state == 0) + { + string recid; + if (dedicPlayer->creatureModel.empty()) + { + npc.mId = "Dedicated Player"; + recid = world->createRecord(npc)->mId; + } + else + { + creature.mId = "Dedicated Player"; + recid = world->createRecord(creature)->mId; + } + + dedicPlayer->reference = new MWWorld::ManualRef(world->getStore(), recid, 1); + } + + // Temporarily spawn or move player to the center of exterior 0,0 whenever setting base info + ESM::Position spawnPos; + spawnPos.pos[0] = spawnPos.pos[1] = Main::get().getCellController()->getCellSize() / 2; + spawnPos.pos[2] = 0; + MWWorld::CellStore *cellStore = world->getExterior(0, 0); + + if (dedicPlayer->state == 0) + { + LOG_APPEND(Log::LOG_INFO, "- Creating new reference pointer for %s", dedicPlayer->npc.mName.c_str()); + + MWWorld::Ptr tmp = world->placeObject(dedicPlayer->reference->getPtr(), cellStore, spawnPos); + + dedicPlayer->ptr.mCell = tmp.mCell; + dedicPlayer->ptr.mRef = tmp.mRef; + + dedicPlayer->cell = *dedicPlayer->ptr.getCell()->getCell(); + dedicPlayer->position = dedicPlayer->ptr.getRefData().getPosition(); + } + else + { + LOG_APPEND(Log::LOG_INFO, "- Updating reference pointer for %s", dedicPlayer->npc.mName.c_str()); + + MWWorld::ESMStore *store = const_cast(&world->getStore()); + + if (!dedicPlayer->creatureModel.empty()) + { + creature.mId = players[guid]->ptr.get()->mBase->mId; + MWWorld::Store *esm_store = const_cast *> (&store->get()); + esm_store->insert(creature); + + } + else + { + npc.mId = players[guid]->ptr.get()->mBase->mId; + MWWorld::Store *esm_store = const_cast *> (&store->get()); + esm_store->insert(npc); + } + + // Disable Ptr to avoid graphical glitches caused by race changes + world->disable(players[guid]->ptr); + + dedicPlayer->setPtr(world->moveObject(dedicPlayer->ptr, cellStore, spawnPos.pos[0], spawnPos.pos[1], spawnPos.pos[2])); + dedicPlayer->updateCell(); + + ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(guid); + dedicPlayer->marker = mEditingMarker; + dedicPlayer->setMarkerState(true); + } + + dedicPlayer->guid = guid; + dedicPlayer->state = 2; + + // Give this new character a fatigue of at least 1 so it doesn't spawn + // on the ground + dedicPlayer->creatureStats.mDynamic[2].mBase = 1; + + world->enable(players[guid]->ptr); +} + +DedicatedPlayer *PlayerList::newPlayer(RakNet::RakNetGUID guid) +{ + LOG_APPEND(Log::LOG_INFO, "- Creating new DedicatedPlayer with guid %lu", guid.g); + + players[guid] = new DedicatedPlayer(guid); + players[guid]->state = 0; + return players[guid]; +} + +void PlayerList::disconnectPlayer(RakNet::RakNetGUID guid) +{ + if (players[guid]->state > 1) + { + players[guid]->state = 1; + + // Remove player's marker + players[guid]->setMarkerState(false); + + MWBase::World *world = MWBase::Environment::get().getWorld(); + world->disable(players[guid]->getPtr()); + + // Move player to exterior 0,0 + ESM::Position newPos; + newPos.pos[0] = newPos.pos[1] = Main::get().getCellController()->getCellSize() / 2; + newPos.pos[2] = 0; + MWWorld::CellStore *cellStore = world->getExterior(0, 0); + + world->moveObject(players[guid]->getPtr(), cellStore, newPos.pos[0], newPos.pos[1], newPos.pos[2]); + } +} + +void PlayerList::cleanUp() +{ + for (std::map ::iterator it = players.begin(); it != players.end(); it++) + delete it->second; +} + +DedicatedPlayer *PlayerList::getPlayer(RakNet::RakNetGUID guid) +{ + return players[guid]; +} + +DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr) +{ + std::map ::iterator it = players.begin(); + + for (; it != players.end(); it++) + { + if (it->second == 0 || it->second->getPtr().mRef == 0) + continue; + string refid = ptr.getCellRef().getRefId(); + if (it->second->getPtr().getCellRef().getRefId() == refid) + return it->second; + } + return 0; +} + +bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr) +{ + if (ptr.mRef == NULL) + return false; + + return (getPlayer(ptr) != 0); +} diff --git a/apps/openmw/mwmp/PlayerList.hpp b/apps/openmw/mwmp/PlayerList.hpp new file mode 100644 index 000000000..1f5e4478a --- /dev/null +++ b/apps/openmw/mwmp/PlayerList.hpp @@ -0,0 +1,47 @@ +#ifndef OPENMW_PLAYERLIST_HPP +#define OPENMW_PLAYERLIST_HPP + +#include +#include +#include + +#include "../mwmechanics/aisequence.hpp" + +#include "../mwworld/manualref.hpp" + +#include +#include + +namespace MWMechanics +{ + class Actor; +} + +namespace mwmp +{ + struct DedicatedPlayer; + + class PlayerList + { + public: + + static void update(float dt); + + static void createPlayer(RakNet::RakNetGUID guid); + static DedicatedPlayer *newPlayer(RakNet::RakNetGUID guid); + + static void disconnectPlayer(RakNet::RakNetGUID guid); + static void cleanUp(); + + static DedicatedPlayer *getPlayer(RakNet::RakNetGUID guid); + static DedicatedPlayer *getPlayer(const MWWorld::Ptr &ptr); + + static bool isDedicatedPlayer(const MWWorld::Ptr &ptr); + + private: + + static std::map players; + }; +} + +#endif //OPENMW_PLAYERLIST_HPP diff --git a/apps/openmw/mwmp/PlayerProcessor.cpp b/apps/openmw/mwmp/PlayerProcessor.cpp index f4f5cbab3..cfa56b6b0 100644 --- a/apps/openmw/mwmp/PlayerProcessor.cpp +++ b/apps/openmw/mwmp/PlayerProcessor.cpp @@ -5,8 +5,6 @@ #include #include "Networking.hpp" #include "PlayerProcessor.hpp" -#include "DedicatedPlayer.hpp" -#include "LocalPlayer.hpp" #include "Main.hpp" using namespace mwmp; diff --git a/apps/openmw/mwmp/PlayerProcessor.hpp b/apps/openmw/mwmp/PlayerProcessor.hpp index 22443a800..f3958ec1d 100644 --- a/apps/openmw/mwmp/PlayerProcessor.hpp +++ b/apps/openmw/mwmp/PlayerProcessor.hpp @@ -13,6 +13,7 @@ #include #include "LocalPlayer.hpp" #include "DedicatedPlayer.hpp" +#include "PlayerList.hpp" #include "BaseClientPacketProcessor.hpp" namespace mwmp diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index e1269c501..3f9986b00 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -13,7 +13,7 @@ Include additional headers for multiplayer purposes */ -#include "../mwmp/DedicatedPlayer.hpp" +#include "../mwmp/PlayerList.hpp" /* End of tes3mp addition */ diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 6a03ba3f2..af228da99 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -13,6 +13,7 @@ #include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/PlayerList.hpp" #include "../mwmp/DedicatedPlayer.hpp" #include "../mwmp/LocalActor.hpp" #include "../mwmp/DedicatedActor.hpp"