2017-03-31 18:35:34 +00:00
|
|
|
#include "PlayerProcessor.hpp"
|
|
|
|
#include "Networking.hpp"
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-06-30 12:09:05 +00:00
|
|
|
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);
|
2017-04-09 05:51:28 +00:00
|
|
|
PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]);
|
2017-04-02 22:05:18 +00:00
|
|
|
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;
|
2017-05-16 11:20:40 +00:00
|
|
|
}
|