1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 17:49:55 +00:00
openmw-tes3mp/apps/openmw-mp/processors/PlayerProcessor.cpp

27 lines
763 B
C++

#include "PlayerProcessor.hpp"
#include "Networking.hpp"
using namespace mwmp;
template<class T>
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
bool PlayerProcessor::Process(RakNet::Packet &packet) noexcept
{
for (auto &processor : processors)
{
if (processor.first == packet.data[0])
{
Player *player = Players::getPlayer(packet.guid);
PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]);
myPacket->setPlayer(player);
if (!processor.second->avoidReading)
myPacket->Read();
processor.second->Do(*myPacket, *player);
return true;
}
}
return false;
}