forked from teamnwah/openmw-tes3coop
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.
76 lines
2.7 KiB
C++
76 lines
2.7 KiB
C++
8 years ago
|
#include <boost/shared_ptr.hpp>
|
||
|
#include <boost/foreach.hpp>
|
||
|
#include <boost/make_shared.hpp>
|
||
|
|
||
8 years ago
|
#include "../Packets/PacketClass.hpp"
|
||
|
#include "../Packets/PacketPosition.hpp"
|
||
|
#include "../Packets/PacketBaseInfo.hpp"
|
||
|
#include "../Packets/PacketEquipment.hpp"
|
||
|
#include "../Packets/PacketAttack.hpp"
|
||
|
#include "../Packets/PacketDynamicStats.hpp"
|
||
|
#include "../Packets/PacketResurrect.hpp"
|
||
|
#include "../Packets/PacketDie.hpp"
|
||
|
#include "../Packets/PacketCell.hpp"
|
||
|
#include "../Packets/PacketSendMyID.hpp"
|
||
|
#include "../Packets/PacketDisconnect.hpp"
|
||
|
#include "../Packets/PacketDrawState.hpp"
|
||
|
#include "../Packets/PacketChatMessage.hpp"
|
||
|
#include "../Packets/PacketCharGen.hpp"
|
||
|
#include "../Packets/PacketAttribute.hpp"
|
||
|
#include "../Packets/PacketSkill.hpp"
|
||
|
#include "../Packets/PacketLevel.hpp"
|
||
|
#include "../Packets/PacketHandshake.hpp"
|
||
|
#include "../Packets/PacketGUIBoxes.hpp"
|
||
|
#include "../Packets/PacketTime.hpp"
|
||
|
#include "../Packets/PacketLoaded.hpp"
|
||
9 years ago
|
|
||
8 years ago
|
#include "PlayerPacketController.hpp"
|
||
9 years ago
|
|
||
8 years ago
|
template <typename T>
|
||
8 years ago
|
inline void AddPacket(mwmp::PlayerPacketController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
||
8 years ago
|
{
|
||
|
T *packet = new T(peer);
|
||
8 years ago
|
typedef mwmp::PlayerPacketController::packets_t::value_type value_t;
|
||
8 years ago
|
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
||
|
}
|
||
9 years ago
|
|
||
8 years ago
|
mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *peer)
|
||
9 years ago
|
{
|
||
8 years ago
|
AddPacket<PacketPosition>(&packets, peer);
|
||
|
AddPacket<PacketCell>(&packets, peer);
|
||
|
AddPacket<PacketBaseInfo>(&packets, peer);
|
||
8 years ago
|
AddPacket<PacketEquipment>(&packets, peer);
|
||
8 years ago
|
|
||
|
AddPacket<PacketAttack>(&packets, peer);
|
||
8 years ago
|
AddPacket<PacketDynamicStats>(&packets, peer);
|
||
8 years ago
|
AddPacket<PacketResurrect>(&packets, peer);
|
||
|
|
||
|
AddPacket<PacketDie>(&packets, peer);
|
||
|
AddPacket<PacketDrawState>(&packets, peer);
|
||
|
AddPacket<PacketSendMyID>(&packets, peer);
|
||
|
AddPacket<PacketDisconnect>(&packets, peer);
|
||
|
|
||
|
AddPacket<PacketChatMessage>(&packets, peer);
|
||
|
AddPacket<PacketCharGen>(&packets, peer);
|
||
|
AddPacket<PacketAttribute>(&packets, peer);
|
||
|
AddPacket<PacketSkill>(&packets, peer);
|
||
8 years ago
|
AddPacket<PacketLevel>(&packets, peer);
|
||
8 years ago
|
|
||
|
AddPacket<PacketHandshake>(&packets, peer);
|
||
|
AddPacket<PacketGUIBoxes>(&packets, peer);
|
||
8 years ago
|
AddPacket<PacketClass>(&packets, peer);
|
||
8 years ago
|
AddPacket<PacketTime>(&packets, peer);
|
||
8 years ago
|
AddPacket<PacketLoaded>(&packets, peer);
|
||
9 years ago
|
}
|
||
|
|
||
|
|
||
8 years ago
|
mwmp::PlayerPacket *mwmp::PlayerPacketController::GetPacket(RakNet::MessageID id)
|
||
9 years ago
|
{
|
||
8 years ago
|
return packets[(unsigned char)id].get();
|
||
9 years ago
|
}
|
||
|
|
||
8 years ago
|
void mwmp::PlayerPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||
9 years ago
|
{
|
||
8 years ago
|
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
||
|
packet.second->SetStreams(inStream, outStream);
|
||
9 years ago
|
}
|