Make markers get removed when their players quit, rename marker methods

pull/112/merge
David Cernat 8 years ago
parent aed884949c
commit 04eb051df6

@ -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();

@ -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();

@ -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();
}

@ -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;
};

Loading…
Cancel
Save