2018-07-14 20:06:09 +00:00
|
|
|
#include "../Packets/Worldstate/PacketCellCreate.hpp"
|
2019-03-22 19:33:34 +00:00
|
|
|
#include "../Packets/Worldstate/PacketCellReset.hpp"
|
2018-05-23 04:48:28 +00:00
|
|
|
#include "../Packets/Worldstate/PacketRecordDynamic.hpp"
|
2018-05-25 04:09:32 +00:00
|
|
|
#include "../Packets/Worldstate/PacketWorldCollisionOverride.hpp"
|
2018-06-07 09:49:12 +00:00
|
|
|
#include "../Packets/Worldstate/PacketWorldMap.hpp"
|
2018-07-17 06:21:13 +00:00
|
|
|
#include "../Packets/Worldstate/PacketWorldRegionAuthority.hpp"
|
2018-05-22 05:53:33 +00:00
|
|
|
#include "../Packets/Worldstate/PacketWorldTime.hpp"
|
2018-07-15 23:20:43 +00:00
|
|
|
#include "../Packets/Worldstate/PacketWorldWeather.hpp"
|
2018-05-21 04:14:08 +00:00
|
|
|
|
2018-05-18 03:40:28 +00:00
|
|
|
#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)
|
|
|
|
{
|
2018-07-14 20:06:09 +00:00
|
|
|
AddPacket<PacketCellCreate>(&packets, peer);
|
2019-03-22 19:33:34 +00:00
|
|
|
AddPacket<PacketCellReset>(&packets, peer);
|
2018-05-23 04:48:28 +00:00
|
|
|
AddPacket<PacketRecordDynamic>(&packets, peer);
|
2018-05-25 04:09:32 +00:00
|
|
|
AddPacket<PacketWorldCollisionOverride>(&packets, peer);
|
2018-06-07 09:49:12 +00:00
|
|
|
AddPacket<PacketWorldMap>(&packets, peer);
|
2018-07-17 06:21:13 +00:00
|
|
|
AddPacket<PacketWorldRegionAuthority>(&packets, peer);
|
2018-05-22 05:53:33 +00:00
|
|
|
AddPacket<PacketWorldTime>(&packets, peer);
|
2018-07-15 23:20:43 +00:00
|
|
|
AddPacket<PacketWorldWeather>(&packets, peer);
|
2018-05-18 03:40:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|