You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3mp/apps/openmw/mwmp/processors/SystemProcessor.cpp

50 lines
1.2 KiB
C++

#include "../Networking.hpp"
#include "SystemProcessor.hpp"
#include "../Main.hpp"
using namespace mwmp;
template<class T>
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
SystemProcessor::~SystemProcessor()
{
}
bool SystemProcessor::Process(RakNet::Packet &packet)
{
RakNet::BitStream bsIn(&packet.data[1], packet.length, false);
bsIn.Read(guid);
SystemPacket *myPacket = Main::get().getNetworking()->getSystemPacket(packet.data[0]);
myPacket->SetReadStream(&bsIn);
/*if (myPacket == 0)
{
// error: packet not found
}*/
for (auto &processor : processors)
{
if (processor.first == packet.data[0])
{
myGuid = Main::get().getLocalSystem()->guid;
request = packet.length == myPacket->headerSize();
BaseSystem *system = 0;
system = Main::get().getLocalSystem();
if (!request && !processor.second->avoidReading && system != 0)
{
myPacket->setSystem(system);
myPacket->Read();
}
processor.second->Do(*myPacket, system);
return true;
}
}
return false;
}