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

39 lines
1.1 KiB
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
{
auto player = Players::getPlayerByGUID(packet.guid);
PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]);
myPacket->setPlayer(player.get());
2017-03-31 18:35:34 +00:00
LOG_MESSAGE_SIMPLE(Log::LOG_TRACE, "Processing %s from %s", processor.second->strPacketID.c_str(),
player->npc.mName.c_str());
2017-04-04 00:05:37 +00:00
if (!processor.second->avoidReading)
{
processor.second->PreReading(*myPacket, player);
2017-04-02 22:13:56 +00:00
myPacket->Read();
}
2017-04-02 22:13:56 +00:00
processor.second->Do(*myPacket, player);
2017-03-31 18:35:34 +00:00
return true;
}
}
return false;
}