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

32 lines
805 B
C++
Raw Normal View History

2017-03-31 18:35:34 +00:00
//
// Created by koncord on 31.03.17.
//
#include "PlayerProcessor.hpp"
#include "Networking.hpp"
using namespace mwmp;
template<class T>
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
2017-03-31 18:35:34 +00:00
bool PlayerProcessor::Process(RakNet::Packet &packet) noexcept
{
2017-04-04 00:05:37 +00:00
for (auto &processor : processors)
2017-03-31 18:35:34 +00:00
{
2017-04-04 00:05:37 +00:00
if (processor.first == packet.data[0])
2017-03-31 18:35:34 +00:00
{
Player *player = Players::getPlayer(packet.guid);
PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]);
myPacket->setPlayer(player);
2017-03-31 18:35:34 +00:00
2017-04-04 00:05:37 +00:00
if (!processor.second->avoidReading)
2017-04-02 22:13:56 +00:00
myPacket->Read();
2017-03-31 18:35:34 +00:00
processor.second->Do(*myPacket, *player);
return true;
}
}
return false;
}