2017-06-06 16:06:10 +00:00
|
|
|
#include "../Main.hpp"
|
|
|
|
#include "../Networking.hpp"
|
2017-04-16 06:58:40 +00:00
|
|
|
|
2018-05-21 04:14:08 +00:00
|
|
|
#include "ObjectProcessor.hpp"
|
|
|
|
|
2017-04-16 06:58:40 +00:00
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-06-30 12:09:05 +00:00
|
|
|
template<class T>
|
|
|
|
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
|
2017-04-16 06:58:40 +00:00
|
|
|
|
2019-10-26 13:43:08 +00:00
|
|
|
ObjectProcessor::~ObjectProcessor()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-05-15 19:56:47 +00:00
|
|
|
bool ObjectProcessor::Process(RakNet::Packet &packet, ObjectList &objectList)
|
2017-04-16 06:58:40 +00:00
|
|
|
{
|
|
|
|
RakNet::BitStream bsIn(&packet.data[1], packet.length, false);
|
|
|
|
bsIn.Read(guid);
|
2018-05-12 21:42:24 +00:00
|
|
|
objectList.guid = guid;
|
2017-04-16 06:58:40 +00:00
|
|
|
|
2018-05-12 16:40:00 +00:00
|
|
|
ObjectPacket *myPacket = Main::get().getNetworking()->getObjectPacket(packet.data[0]);
|
2017-04-16 06:58:40 +00:00
|
|
|
|
2018-05-12 21:42:24 +00:00
|
|
|
myPacket->setObjectList(&objectList);
|
2017-04-16 06:58:40 +00:00
|
|
|
myPacket->SetReadStream(&bsIn);
|
|
|
|
|
2017-06-27 14:27:02 +00:00
|
|
|
for (auto &processor: processors)
|
2017-04-16 06:58:40 +00:00
|
|
|
{
|
2017-05-02 19:47:58 +00:00
|
|
|
if (processor.first == packet.data[0])
|
2017-04-16 06:58:40 +00:00
|
|
|
{
|
2017-04-18 07:05:32 +00:00
|
|
|
myGuid = Main::get().getLocalPlayer()->guid;
|
2017-04-16 06:58:40 +00:00
|
|
|
request = packet.length == myPacket->headerSize();
|
|
|
|
|
2018-05-12 21:42:24 +00:00
|
|
|
objectList.isValid = true;
|
2017-05-14 17:24:06 +00:00
|
|
|
|
2017-05-02 19:47:58 +00:00
|
|
|
if (!request && !processor.second->avoidReading)
|
2017-04-16 06:58:40 +00:00
|
|
|
myPacket->Read();
|
|
|
|
|
2018-05-12 21:42:24 +00:00
|
|
|
if (objectList.isValid)
|
|
|
|
processor.second->Do(*myPacket, objectList);
|
2017-05-14 17:24:06 +00:00
|
|
|
else
|
2019-08-19 18:39:33 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(TimedLog::LOG_ERROR, "Received %s that failed integrity check and was ignored!", processor.second->strPacketID.c_str());
|
2017-04-16 06:58:40 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|