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.
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
#include "../Packets/Worldstate/PacketCellCreate.hpp"
|
|
#include "../Packets/Worldstate/PacketCellReplace.hpp"
|
|
#include "../Packets/Worldstate/PacketRecordDynamic.hpp"
|
|
#include "../Packets/Worldstate/PacketWorldCollisionOverride.hpp"
|
|
#include "../Packets/Worldstate/PacketWorldMap.hpp"
|
|
#include "../Packets/Worldstate/PacketWorldRegionAuthority.hpp"
|
|
#include "../Packets/Worldstate/PacketWorldTime.hpp"
|
|
#include "../Packets/Worldstate/PacketWorldWeather.hpp"
|
|
|
|
#include "WorldstatePacketController.hpp"
|
|
|
|
template <typename T>
|
|
inline void AddPacket(mwmp::WorldstatePacketController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
|
{
|
|
T *packet = new T(peer);
|
|
typedef mwmp::WorldstatePacketController::packets_t::value_type value_t;
|
|
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
|
}
|
|
|
|
mwmp::WorldstatePacketController::WorldstatePacketController(RakNet::RakPeerInterface *peer)
|
|
{
|
|
AddPacket<PacketCellCreate>(&packets, peer);
|
|
AddPacket<PacketCellReplace>(&packets, peer);
|
|
AddPacket<PacketRecordDynamic>(&packets, peer);
|
|
AddPacket<PacketWorldCollisionOverride>(&packets, peer);
|
|
AddPacket<PacketWorldMap>(&packets, peer);
|
|
AddPacket<PacketWorldRegionAuthority>(&packets, peer);
|
|
AddPacket<PacketWorldTime>(&packets, peer);
|
|
AddPacket<PacketWorldWeather>(&packets, peer);
|
|
}
|
|
|
|
|
|
mwmp::WorldstatePacket *mwmp::WorldstatePacketController::GetPacket(RakNet::MessageID id)
|
|
{
|
|
return packets[(unsigned char)id].get();
|
|
}
|
|
|
|
void mwmp::WorldstatePacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
|
{
|
|
for(const auto &packet : packets)
|
|
packet.second->SetStreams(inStream, outStream);
|
|
}
|
|
|
|
bool mwmp::WorldstatePacketController::ContainsPacket(RakNet::MessageID id)
|
|
{
|
|
for(const auto &packet : packets)
|
|
{
|
|
if (packet.first == id)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|