1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-25 00:53:52 +00:00
openmw-tes3mp/apps/openmw/mwmp/processors/player/ProcessorUserDisconnected.hpp
2019-12-02 19:08:03 +02:00

47 lines
1.5 KiB
C++

#ifndef OPENMW_PROCESSORUSERDISCONNECTED_HPP
#define OPENMW_PROCESSORUSERDISCONNECTED_HPP
#include "../PlayerProcessor.hpp"
#include <components/openmw-mp/Utils.hpp>
#include <apps/openmw/mwbase/environment.hpp>
#include "apps/openmw/mwstate/statemanagerimp.hpp"
namespace mwmp
{
class ProcessorUserDisconnected final: public PlayerProcessor
{
public:
ProcessorUserDisconnected()
{
BPP_INIT(ID_USER_DISCONNECTED)
avoidReading = true;
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
MWBase::Environment::get().getStateManager()->requestQuit();
else if (player != 0)
{
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->teamMembers.begin(); iter != localPlayer->teamMembers.end(); )
{
if (*iter == guid)
{
DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(guid);
LOG_APPEND(TimedLog::LOG_INFO, "- Deleting %s from our team members", dedicatedPlayer->npc.mName.c_str());
iter = localPlayer->teamMembers.erase(iter);
}
else
++iter;
}
PlayerList::deletePlayer(guid);
}
}
};
}
#endif //OPENMW_PROCESSORUSERDISCONNECTED_HPP