2017-05-24 16:01:28 +00:00
|
|
|
#include "../Packets/World/PacketObjectAnimPlay.hpp"
|
2016-10-22 15:05:32 +00:00
|
|
|
#include "../Packets/World/PacketObjectDelete.hpp"
|
2016-10-24 10:20:04 +00:00
|
|
|
#include "../Packets/World/PacketObjectLock.hpp"
|
2016-10-25 09:53:18 +00:00
|
|
|
#include "../Packets/World/PacketObjectMove.hpp"
|
2017-05-24 16:01:28 +00:00
|
|
|
#include "../Packets/World/PacketObjectPlace.hpp"
|
2016-10-25 11:28:39 +00:00
|
|
|
#include "../Packets/World/PacketObjectRotate.hpp"
|
2017-05-24 16:01:28 +00:00
|
|
|
#include "../Packets/World/PacketObjectScale.hpp"
|
2017-05-29 01:43:52 +00:00
|
|
|
#include "../Packets/World/PacketObjectSpawn.hpp"
|
2017-07-10 09:33:53 +00:00
|
|
|
#include "../Packets/World/PacketObjectState.hpp"
|
2017-05-24 16:01:28 +00:00
|
|
|
#include "../Packets/World/PacketObjectTrap.hpp"
|
2016-10-24 21:50:32 +00:00
|
|
|
|
2017-02-04 11:14:37 +00:00
|
|
|
#include "../Packets/World/PacketContainer.hpp"
|
2017-02-01 09:54:40 +00:00
|
|
|
#include "../Packets/World/PacketDoorState.hpp"
|
2016-11-20 20:54:49 +00:00
|
|
|
#include "../Packets/World/PacketMusicPlay.hpp"
|
2016-10-24 14:52:19 +00:00
|
|
|
#include "../Packets/World/PacketVideoPlay.hpp"
|
2016-10-19 17:36:11 +00:00
|
|
|
|
2017-07-10 09:33:53 +00:00
|
|
|
#include "../Packets/World/PacketConsoleCommand.hpp"
|
2016-10-26 09:25:50 +00:00
|
|
|
#include "../Packets/World/PacketScriptLocalShort.hpp"
|
|
|
|
#include "../Packets/World/PacketScriptLocalFloat.hpp"
|
2016-10-26 21:41:14 +00:00
|
|
|
#include "../Packets/World/PacketScriptMemberShort.hpp"
|
2016-10-26 09:25:50 +00:00
|
|
|
#include "../Packets/World/PacketScriptGlobalShort.hpp"
|
|
|
|
|
2016-10-19 17:36:11 +00:00
|
|
|
#include "WorldPacketController.hpp"
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
inline void AddPacket(mwmp::WorldPacketController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
|
|
|
{
|
|
|
|
T *packet = new T(peer);
|
|
|
|
typedef mwmp::WorldPacketController::packets_t::value_type value_t;
|
2017-12-09 02:13:14 +00:00
|
|
|
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(std::move(packet))));
|
2016-10-19 17:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *peer)
|
|
|
|
{
|
2017-05-24 16:01:28 +00:00
|
|
|
AddPacket<PacketObjectAnimPlay>(&packets, peer);
|
2016-10-22 15:05:32 +00:00
|
|
|
AddPacket<PacketObjectDelete>(&packets, peer);
|
2016-10-24 10:20:04 +00:00
|
|
|
AddPacket<PacketObjectLock>(&packets, peer);
|
2016-10-25 09:53:18 +00:00
|
|
|
AddPacket<PacketObjectMove>(&packets, peer);
|
2017-05-24 16:01:28 +00:00
|
|
|
AddPacket<PacketObjectPlace>(&packets, peer);
|
2016-10-25 11:28:39 +00:00
|
|
|
AddPacket<PacketObjectRotate>(&packets, peer);
|
2017-05-24 16:01:28 +00:00
|
|
|
AddPacket<PacketObjectScale>(&packets, peer);
|
2017-05-29 01:43:52 +00:00
|
|
|
AddPacket<PacketObjectSpawn>(&packets, peer);
|
2017-07-10 09:33:53 +00:00
|
|
|
AddPacket<PacketObjectState>(&packets, peer);
|
2017-05-24 16:01:28 +00:00
|
|
|
AddPacket<PacketObjectTrap>(&packets, peer);
|
|
|
|
|
2017-02-04 11:14:37 +00:00
|
|
|
AddPacket<PacketContainer>(&packets, peer);
|
2017-02-01 09:54:40 +00:00
|
|
|
AddPacket<PacketDoorState>(&packets, peer);
|
2016-11-20 20:54:49 +00:00
|
|
|
AddPacket<PacketMusicPlay>(&packets, peer);
|
2016-10-24 14:52:19 +00:00
|
|
|
AddPacket<PacketVideoPlay>(&packets, peer);
|
2016-10-26 09:25:50 +00:00
|
|
|
|
2017-07-10 09:33:53 +00:00
|
|
|
AddPacket<PacketConsoleCommand>(&packets, peer);
|
2016-10-26 09:25:50 +00:00
|
|
|
AddPacket<PacketScriptLocalShort>(&packets, peer);
|
|
|
|
AddPacket<PacketScriptLocalFloat>(&packets, peer);
|
2016-10-26 21:41:14 +00:00
|
|
|
AddPacket<PacketScriptMemberShort>(&packets, peer);
|
2016-10-26 09:25:50 +00:00
|
|
|
AddPacket<PacketScriptGlobalShort>(&packets, peer);
|
2016-10-19 17:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mwmp::WorldPacket *mwmp::WorldPacketController::GetPacket(RakNet::MessageID id)
|
|
|
|
{
|
2017-11-28 14:05:10 +00:00
|
|
|
return packets[(RakNet::MessageID)id].get();
|
2016-10-19 17:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mwmp::WorldPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
|
|
|
{
|
2017-11-29 11:00:22 +00:00
|
|
|
for (const auto &packet : packets)
|
2016-10-19 17:36:11 +00:00
|
|
|
packet.second->SetStreams(inStream, outStream);
|
2016-10-19 18:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool mwmp::WorldPacketController::ContainsPacket(RakNet::MessageID id)
|
|
|
|
{
|
2017-11-29 11:00:22 +00:00
|
|
|
for (const auto &packet : packets)
|
2017-06-27 14:41:37 +00:00
|
|
|
{
|
2016-10-19 18:15:59 +00:00
|
|
|
if (packet.first == id)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|