1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 06:49:55 +00:00
openmw-tes3mp/apps/openmw/mwmp/processors/ActorProcessor.cpp

49 lines
1.3 KiB
C++
Raw Normal View History

2017-04-18 05:53:02 +00:00
//
// Created by koncord on 18.04.17.
//
#include "ActorProcessor.hpp"
2017-06-06 16:06:10 +00:00
#include "../Networking.hpp"
#include "../Main.hpp"
2017-04-18 05:53:02 +00:00
using namespace mwmp;
template<class T>
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
2017-04-18 05:53:02 +00:00
bool ActorProcessor::Process(RakNet::Packet &packet, ActorList &actorList)
{
RakNet::BitStream bsIn(&packet.data[1], packet.length, false);
bsIn.Read(guid);
actorList.guid = guid;
2017-04-18 05:53:02 +00:00
ActorPacket *myPacket = Main::get().getNetworking()->getActorPacket(packet.data[0]);
myPacket->setActorList(&actorList);
myPacket->SetReadStream(&bsIn);
for (auto &processor : processors)
{
if (processor.first == packet.data[0])
{
myGuid = Main::get().getLocalPlayer()->guid;
request = packet.length == myPacket->headerSize();
actorList.isValid = true;
if (!request && !processor.second->avoidReading)
{
myPacket->Read();
}
if (actorList.isValid)
processor.second->Do(*myPacket, actorList);
else
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str());
return true;
}
}
2017-04-18 05:53:02 +00:00
return false;
}