2016-10-19 17:36:11 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
#include <boost/make_shared.hpp>
|
|
|
|
|
2016-10-22 15:05:32 +00:00
|
|
|
#include "../Packets/World/PacketObjectDelete.hpp"
|
2016-10-24 08:26:31 +00:00
|
|
|
#include "../Packets/World/PacketObjectPlace.hpp"
|
2017-02-04 11:14:37 +00:00
|
|
|
#include "../Packets/World/PacketObjectScale.hpp"
|
2016-10-24 10:20:04 +00:00
|
|
|
#include "../Packets/World/PacketObjectLock.hpp"
|
2016-10-24 08:26:31 +00:00
|
|
|
#include "../Packets/World/PacketObjectUnlock.hpp"
|
2016-10-25 09:53:18 +00:00
|
|
|
#include "../Packets/World/PacketObjectMove.hpp"
|
2016-10-25 11:28:39 +00:00
|
|
|
#include "../Packets/World/PacketObjectRotate.hpp"
|
2016-10-27 13:09:02 +00:00
|
|
|
#include "../Packets/World/PacketObjectAnimPlay.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
|
|
|
|
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;
|
|
|
|
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
|
|
|
}
|
|
|
|
|
|
|
|
mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *peer)
|
|
|
|
{
|
2016-10-22 15:05:32 +00:00
|
|
|
AddPacket<PacketObjectDelete>(&packets, peer);
|
2016-10-24 08:26:31 +00:00
|
|
|
AddPacket<PacketObjectPlace>(&packets, peer);
|
2017-02-04 11:14:37 +00:00
|
|
|
AddPacket<PacketObjectScale>(&packets, peer);
|
2016-10-24 10:20:04 +00:00
|
|
|
AddPacket<PacketObjectLock>(&packets, peer);
|
2016-10-24 08:26:31 +00:00
|
|
|
AddPacket<PacketObjectUnlock>(&packets, peer);
|
2016-10-25 09:53:18 +00:00
|
|
|
AddPacket<PacketObjectMove>(&packets, peer);
|
2016-10-25 11:28:39 +00:00
|
|
|
AddPacket<PacketObjectRotate>(&packets, peer);
|
2016-10-27 13:09:02 +00:00
|
|
|
AddPacket<PacketObjectAnimPlay>(&packets, peer);
|
2016-10-24 21:50:32 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return packets[(unsigned char)id].get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void mwmp::WorldPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
|
|
|
{
|
|
|
|
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
|
|
|
packet.second->SetStreams(inStream, outStream);
|
2016-10-19 18:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool mwmp::WorldPacketController::ContainsPacket(RakNet::MessageID id)
|
|
|
|
{
|
|
|
|
BOOST_FOREACH(packets_t::value_type &packet, packets) {
|
|
|
|
if (packet.first == id)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|