2019-12-05 17:15:11 +00:00
|
|
|
#ifndef OPENMW_PROCESSORPLAYERALLY_HPP
|
|
|
|
#define OPENMW_PROCESSORPLAYERALLY_HPP
|
2019-12-02 17:08:03 +00:00
|
|
|
|
|
|
|
#include "../PlayerProcessor.hpp"
|
|
|
|
#include "apps/openmw/mwmp/Main.hpp"
|
|
|
|
#include "apps/openmw/mwmp/LocalPlayer.hpp"
|
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
2019-12-05 17:15:11 +00:00
|
|
|
class ProcessorPlayerAlly final: public PlayerProcessor
|
2019-12-02 17:08:03 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-12-05 17:15:11 +00:00
|
|
|
ProcessorPlayerAlly()
|
2019-12-02 17:08:03 +00:00
|
|
|
{
|
2019-12-05 17:15:11 +00:00
|
|
|
BPP_INIT(ID_PLAYER_ALLY)
|
2019-12-02 17:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
|
|
|
{
|
2019-12-03 20:40:02 +00:00
|
|
|
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
|
|
|
|
|
2019-12-02 17:08:03 +00:00
|
|
|
if (isLocal())
|
|
|
|
{
|
2019-12-05 17:15:11 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_ALLY about LocalPlayer %s from server", localPlayer->npc.mName.c_str());
|
2019-12-02 17:08:03 +00:00
|
|
|
|
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
|
|
|
{
|
|
|
|
DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(*iter);
|
|
|
|
|
|
|
|
if (dedicatedPlayer)
|
|
|
|
{
|
2019-12-05 17:15:11 +00:00
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to our allied players", dedicatedPlayer->npc.mName.c_str());
|
2019-12-03 20:40:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (player != 0)
|
|
|
|
{
|
2019-12-05 17:15:11 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_ALLY about DedicatedPlayer %s from server", player->npc.mName.c_str());
|
2019-12-03 20:40:02 +00:00
|
|
|
|
2019-12-05 17:15:11 +00:00
|
|
|
for (std::vector<RakNet::RakNetGUID>::iterator iter = player->alliedPlayers.begin(); iter != player->alliedPlayers.end(); )
|
2019-12-03 20:40:02 +00:00
|
|
|
{
|
|
|
|
if (*iter == localPlayer->guid)
|
|
|
|
{
|
2019-12-05 17:15:11 +00:00
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Adding LocalPlayer %s to their allied players", localPlayer->npc.mName.c_str());
|
2019-12-03 20:40:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DedicatedPlayer *otherDedicatedPlayer = PlayerList::getPlayer(*iter);
|
|
|
|
|
|
|
|
if (otherDedicatedPlayer)
|
|
|
|
{
|
2019-12-05 17:15:11 +00:00
|
|
|
LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to their allied players", otherDedicatedPlayer->npc.mName.c_str());
|
2019-12-03 20:40:02 +00:00
|
|
|
}
|
2019-12-02 17:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-12-05 17:15:11 +00:00
|
|
|
#endif //OPENMW_PROCESSORPLAYERALLY_HPP
|