2017-04-16 07:00:25 +00:00
|
|
|
#ifndef OPENMW_PROCESSORUSERDISCONNECTED_HPP
|
|
|
|
#define OPENMW_PROCESSORUSERDISCONNECTED_HPP
|
|
|
|
|
|
|
|
|
2017-06-06 16:06:10 +00:00
|
|
|
#include "../PlayerProcessor.hpp"
|
2019-12-02 17:08:03 +00:00
|
|
|
#include <components/openmw-mp/Utils.hpp>
|
2017-05-29 01:43:52 +00:00
|
|
|
#include <apps/openmw/mwbase/environment.hpp>
|
2017-04-16 07:00:25 +00:00
|
|
|
#include "apps/openmw/mwstate/statemanagerimp.hpp"
|
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
2019-10-24 19:16:17 +00:00
|
|
|
class ProcessorUserDisconnected final: public PlayerProcessor
|
2017-04-16 07:00:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProcessorUserDisconnected()
|
|
|
|
{
|
|
|
|
BPP_INIT(ID_USER_DISCONNECTED)
|
|
|
|
avoidReading = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
|
|
|
{
|
|
|
|
if (isLocal())
|
|
|
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
2017-04-23 22:46:27 +00:00
|
|
|
else if (player != 0)
|
2019-12-02 17:08:03 +00:00
|
|
|
{
|
|
|
|
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
|
|
|
|
|
2019-12-05 17:15:11 +00:00
|
|
|
for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->alliedPlayers.begin(); iter != localPlayer->alliedPlayers.end(); )
|
2019-12-02 17:08:03 +00:00
|
|
|
{
|
|
|
|
if (*iter == guid)
|
|
|
|
{
|
|
|
|
DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(guid);
|
2019-12-05 17:15:11 +00:00
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Deleting %s from our allied players", dedicatedPlayer->npc.mName.c_str());
|
|
|
|
iter = localPlayer->alliedPlayers.erase(iter);
|
2019-12-02 17:08:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
2018-04-08 12:02:43 +00:00
|
|
|
PlayerList::deletePlayer(guid);
|
2019-12-02 17:08:03 +00:00
|
|
|
}
|
2017-04-16 07:00:25 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //OPENMW_PROCESSORUSERDISCONNECTED_HPP
|