1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-24 18:23:52 +00:00
openmw-tes3mp/apps/openmw/mwmp/processors/player/ProcessorPlayerAlly.hpp
David Cernat 980edac942 [General] Rename PlayerTeam into PlayerAlly
Considering that you can be allies with someone without being allied to their allies, changing the name makes the system more intuitive.
2019-12-05 19:15:11 +02:00

65 lines
2.3 KiB
C++

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