From 04eb051df66cf9e183988e5801e57baf7aa2d971 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 24 Oct 2016 15:10:32 +0300 Subject: [PATCH] Make markers get removed when their players quit, rename marker methods --- apps/openmw/mwmp/DedicatedPlayer.cpp | 12 ++++++++---- apps/openmw/mwmp/DedicatedPlayer.hpp | 2 +- apps/openmw/mwmp/PlayerMarkerCollection.cpp | 2 +- apps/openmw/mwmp/PlayerMarkerCollection.hpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 949ea88b2..20599eee0 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -111,7 +111,7 @@ void Players::CreatePlayer(RakNet::RakNetGUID id) ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(id); dedicPlayer->marker = mEditingMarker; - dedicPlayer->markerEnabled = true; + dedicPlayer->setMarkerState(true); } @@ -126,6 +126,10 @@ void Players::DisconnectPlayer(RakNet::RakNetGUID id) if (players[id]->state > 1) { players[id]->state = 1; + + // Remove player's marker + players[id]->setMarkerState(false); + MWBase::World *world = MWBase::Environment::get().getWorld(); world->disable(players[id]->getPtr()); @@ -469,7 +473,7 @@ void DedicatedPlayer::updateMarker() if (!markerEnabled) return; GUIController *gui = Main::get().getGUIController(); - if (gui->mPlayerMarkers.isExists(marker)) + if (gui->mPlayerMarkers.isExistent(marker)) { gui->mPlayerMarkers.deleteMarker(marker); marker = gui->CreateMarker(guid); @@ -487,9 +491,9 @@ void DedicatedPlayer::removeMarker() Main::get().getGUIController()->mPlayerMarkers.deleteMarker(marker); } -void DedicatedPlayer::enableMarker(bool enable) +void DedicatedPlayer::setMarkerState(bool state) { - if (enable) + if (state) updateMarker(); else removeMarker(); diff --git a/apps/openmw/mwmp/DedicatedPlayer.hpp b/apps/openmw/mwmp/DedicatedPlayer.hpp index dfcbb5f97..e42b27322 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.hpp +++ b/apps/openmw/mwmp/DedicatedPlayer.hpp @@ -49,7 +49,7 @@ namespace mwmp void updateMarker(); void removeMarker(); - void enableMarker(bool enable); + void setMarkerState(bool state); private: DedicatedPlayer(RakNet::RakNetGUID guid); virtual ~DedicatedPlayer(); diff --git a/apps/openmw/mwmp/PlayerMarkerCollection.cpp b/apps/openmw/mwmp/PlayerMarkerCollection.cpp index d6c670d9e..815dd4c65 100644 --- a/apps/openmw/mwmp/PlayerMarkerCollection.cpp +++ b/apps/openmw/mwmp/PlayerMarkerCollection.cpp @@ -73,7 +73,7 @@ size_t PlayerMarkerCollection::size() const return mMarkers.size(); } -bool PlayerMarkerCollection::isExists(const ESM::CustomMarker &marker) +bool PlayerMarkerCollection::isExistent(const ESM::CustomMarker &marker) { return mMarkers.find(marker.mCell) != mMarkers.end(); } diff --git a/apps/openmw/mwmp/PlayerMarkerCollection.hpp b/apps/openmw/mwmp/PlayerMarkerCollection.hpp index add80cbb9..bba976975 100644 --- a/apps/openmw/mwmp/PlayerMarkerCollection.hpp +++ b/apps/openmw/mwmp/PlayerMarkerCollection.hpp @@ -39,7 +39,7 @@ namespace mwmp typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; EventHandle_Void eventMarkersChanged; - bool isExists(const ESM::CustomMarker &marker); + bool isExistent(const ESM::CustomMarker &marker); private: ContainerType mMarkers; };