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.
32 lines
805 B
C++
32 lines
805 B
C++
8 years ago
|
//
|
||
|
// Created by koncord on 31.03.17.
|
||
|
//
|
||
|
|
||
|
#include "PlayerProcessor.hpp"
|
||
|
#include "Networking.hpp"
|
||
|
|
||
|
using namespace mwmp;
|
||
|
|
||
8 years ago
|
template<class T>
|
||
|
typename BasePacketProcessor<T>::processors_t BasePacketProcessor<T>::processors;
|
||
8 years ago
|
|
||
|
bool PlayerProcessor::Process(RakNet::Packet &packet) noexcept
|
||
|
{
|
||
8 years ago
|
for (auto &processor : processors)
|
||
8 years ago
|
{
|
||
8 years ago
|
if (processor.first == packet.data[0])
|
||
8 years ago
|
{
|
||
|
Player *player = Players::getPlayer(packet.guid);
|
||
8 years ago
|
PlayerPacket *myPacket = Networking::get().getPlayerPacketController()->GetPacket(packet.data[0]);
|
||
8 years ago
|
myPacket->setPlayer(player);
|
||
8 years ago
|
|
||
8 years ago
|
if (!processor.second->avoidReading)
|
||
8 years ago
|
myPacket->Read();
|
||
|
|
||
8 years ago
|
processor.second->Do(*myPacket, *player);
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
8 years ago
|
}
|