forked from teamnwah/openmw-tes3coop
Merge with tes3mp-packetexpansion by fixing conflicts
# Conflicts: # apps/openmw-mp/Networking.cpp # apps/openmw/mwmp/Networking.cpp # components/CMakeLists.txt # components/openmw-mp/NetworkMessages.hpp # components/openmw-mp/PacketsController.cppcoverity_scan^2
commit
c639337842
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef OPENMW_WORLDEVENT_HPP
|
||||||
|
#define OPENMW_WORLDEVENT_HPP
|
||||||
|
|
||||||
|
#include <components/esm/loadcell.hpp>
|
||||||
|
#include <components/esm/cellref.hpp>
|
||||||
|
#include <RakNetTypes.h>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class WorldEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
WorldEvent(RakNet::RakNetGUID guid) : guid(guid)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RakNet::RakNetGUID guid;
|
||||||
|
|
||||||
|
ESM::Cell cell;
|
||||||
|
ESM::CellRef cellRef;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_WORLDEVENT_HPP
|
@ -0,0 +1,87 @@
|
|||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
|
#include "../Packets/Player/PacketClass.hpp"
|
||||||
|
#include "../Packets/Player/PacketPosition.hpp"
|
||||||
|
#include "../Packets/Player/PacketBaseInfo.hpp"
|
||||||
|
#include "../Packets/Player/PacketEquipment.hpp"
|
||||||
|
#include "../Packets/Player/PacketAttack.hpp"
|
||||||
|
#include "../Packets/Player/PacketDynamicStats.hpp"
|
||||||
|
#include "../Packets/Player/PacketResurrect.hpp"
|
||||||
|
#include "../Packets/Player/PacketDie.hpp"
|
||||||
|
#include "../Packets/Player/PacketCell.hpp"
|
||||||
|
#include "../Packets/Player/PacketSendMyID.hpp"
|
||||||
|
#include "../Packets/Player/PacketDisconnect.hpp"
|
||||||
|
#include "../Packets/Player/PacketDrawState.hpp"
|
||||||
|
#include "../Packets/Player/PacketChatMessage.hpp"
|
||||||
|
#include "../Packets/Player/PacketCharGen.hpp"
|
||||||
|
#include "../Packets/Player/PacketAttribute.hpp"
|
||||||
|
#include "../Packets/Player/PacketSkill.hpp"
|
||||||
|
#include "../Packets/Player/PacketLevel.hpp"
|
||||||
|
#include "../Packets/Player/PacketHandshake.hpp"
|
||||||
|
#include "../Packets/Player/PacketGUIBoxes.hpp"
|
||||||
|
#include "../Packets/Player/PacketTime.hpp"
|
||||||
|
#include "../Packets/Player/PacketLoaded.hpp"
|
||||||
|
#include "../Packets/Player/PacketInventory.hpp"
|
||||||
|
|
||||||
|
#include "PlayerPacketController.hpp"
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void AddPacket(mwmp::PlayerPacketController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
||||||
|
{
|
||||||
|
T *packet = new T(peer);
|
||||||
|
typedef mwmp::PlayerPacketController::packets_t::value_type value_t;
|
||||||
|
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
||||||
|
}
|
||||||
|
|
||||||
|
mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *peer)
|
||||||
|
{
|
||||||
|
AddPacket<PacketPosition>(&packets, peer);
|
||||||
|
AddPacket<PacketCell>(&packets, peer);
|
||||||
|
AddPacket<PacketBaseInfo>(&packets, peer);
|
||||||
|
AddPacket<PacketEquipment>(&packets, peer);
|
||||||
|
|
||||||
|
AddPacket<PacketAttack>(&packets, peer);
|
||||||
|
AddPacket<PacketDynamicStats>(&packets, peer);
|
||||||
|
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);
|
||||||
|
AddPacket<PacketLevel>(&packets, peer);
|
||||||
|
|
||||||
|
AddPacket<PacketHandshake>(&packets, peer);
|
||||||
|
AddPacket<PacketGUIBoxes>(&packets, peer);
|
||||||
|
AddPacket<PacketClass>(&packets, peer);
|
||||||
|
AddPacket<PacketTime>(&packets, peer);
|
||||||
|
AddPacket<PacketLoaded>(&packets, peer);
|
||||||
|
AddPacket<PacketInventory>(&packets, peer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mwmp::PlayerPacket *mwmp::PlayerPacketController::GetPacket(RakNet::MessageID id)
|
||||||
|
{
|
||||||
|
return packets[(unsigned char)id].get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void mwmp::PlayerPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
||||||
|
packet.second->SetStreams(inStream, outStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mwmp::PlayerPacketController::ContainsPacket(RakNet::MessageID id)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(packets_t::value_type &packet, packets) {
|
||||||
|
if (packet.first == id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
@ -1,29 +1,27 @@
|
|||||||
//
|
#ifndef OPENMW_PLAYERPACKETCONTROLLER_HPP
|
||||||
// Created by koncord on 15.01.16.
|
#define OPENMW_PLAYERPACKETCONTROLLER_HPP
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef OPENMW_PACKETSCONTROLLER_HPP
|
|
||||||
#define OPENMW_PACKETSCONTROLLER_HPP
|
|
||||||
|
|
||||||
|
|
||||||
#include <RakPeerInterface.h>
|
#include <RakPeerInterface.h>
|
||||||
#include "Packets/PlayerPacket.hpp"
|
#include "../Packets/Player/PlayerPacket.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
class PacketsController
|
class PlayerPacketController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PacketsController(RakNet::RakPeerInterface *peer);
|
PlayerPacketController(RakNet::RakPeerInterface *peer);
|
||||||
PlayerPacket *GetPacket(RakNet::MessageID id);
|
PlayerPacket *GetPacket(RakNet::MessageID id);
|
||||||
void SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream);
|
void SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream);
|
||||||
|
|
||||||
|
bool ContainsPacket(RakNet::MessageID id);
|
||||||
|
|
||||||
typedef std::map<unsigned char, boost::shared_ptr<PlayerPacket> > packets_t;
|
typedef std::map<unsigned char, boost::shared_ptr<PlayerPacket> > packets_t;
|
||||||
private:
|
private:
|
||||||
packets_t packets;
|
packets_t packets;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENMW_PACKETSCONTROLLER_HPP
|
#endif //OPENMW_PLAYERPACKETCONTROLLER_HPP
|
@ -0,0 +1,43 @@
|
|||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
|
#include "../Packets/World/PacketObjectPlace.hpp"
|
||||||
|
#include "../Packets/World/PacketObjectDelete.hpp"
|
||||||
|
|
||||||
|
#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)
|
||||||
|
{
|
||||||
|
AddPacket<PacketObjectPlace>(&packets, peer);
|
||||||
|
AddPacket<PacketObjectDelete>(&packets, peer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mwmp::WorldPacketController::ContainsPacket(RakNet::MessageID id)
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(packets_t::value_type &packet, packets) {
|
||||||
|
if (packet.first == id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef OPENMW_WORLDPACKETCONTROLLER_HPP
|
||||||
|
#define OPENMW_WORLDPACKETCONTROLLER_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include <RakPeerInterface.h>
|
||||||
|
#include "../Packets/World/WorldPacket.hpp"
|
||||||
|
#include <map>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class WorldPacketController
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WorldPacketController(RakNet::RakPeerInterface *peer);
|
||||||
|
WorldPacket *GetPacket(RakNet::MessageID id);
|
||||||
|
void SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream);
|
||||||
|
|
||||||
|
bool ContainsPacket(RakNet::MessageID id);
|
||||||
|
|
||||||
|
typedef std::map<unsigned char, boost::shared_ptr<WorldPacket> > packets_t;
|
||||||
|
private:
|
||||||
|
packets_t packets;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_WORLDPACKETCONTROLLER_HPP
|
@ -0,0 +1,37 @@
|
|||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include <PacketPriority.h>
|
||||||
|
#include <RakPeer.h>
|
||||||
|
#include "BasePacket.hpp"
|
||||||
|
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
BasePacket::BasePacket(RakNet::RakPeerInterface *peer)
|
||||||
|
{
|
||||||
|
packetID = 0;
|
||||||
|
priority = HIGH_PRIORITY;
|
||||||
|
reliability = RELIABLE_ORDERED;
|
||||||
|
this->peer = peer;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasePacket::~BasePacket()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasePacket::SetReadStream(RakNet::BitStream *bitStream)
|
||||||
|
{
|
||||||
|
bsRead = bitStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasePacket::SetSendStream(RakNet::BitStream *bitStream)
|
||||||
|
{
|
||||||
|
bsSend = bitStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||||
|
{
|
||||||
|
if (inStream != 0)
|
||||||
|
bsRead = inStream;
|
||||||
|
if (outStream != 0)
|
||||||
|
bsSend = outStream;
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef OPENMW_PLAYERPACKET_HPP
|
||||||
|
#define OPENMW_PLAYERPACKET_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <RakNetTypes.h>
|
||||||
|
#include <BitStream.h>
|
||||||
|
#include <PacketPriority.h>
|
||||||
|
#include <components/openmw-mp/Base/BasePlayer.hpp>
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Packets/BasePacket.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class PlayerPacket : public BasePacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlayerPacket(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
|
~PlayerPacket();
|
||||||
|
|
||||||
|
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
||||||
|
|
||||||
|
virtual void Send(BasePlayer *player, bool toOtherPlayers = true);
|
||||||
|
virtual void Send(BasePlayer *player, RakNet::AddressOrGUID destination);
|
||||||
|
virtual void Read(BasePlayer *player);
|
||||||
|
|
||||||
|
virtual void RequestData(RakNet::RakNetGUID guid);
|
||||||
|
|
||||||
|
static size_t headerSize()
|
||||||
|
{
|
||||||
|
return (size_t)(1 + RakNet::RakNetGUID::size()); // packetID + RakNetGUID (uint64_t)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char GetPacketID()
|
||||||
|
{
|
||||||
|
return packetID;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BasePlayer *player;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_PLAYERPACKET_HPP
|
@ -0,0 +1,22 @@
|
|||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include "PacketObjectDelete.hpp"
|
||||||
|
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
PacketObjectDelete::PacketObjectDelete(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
|
{
|
||||||
|
packetID = ID_WORLD_OBJECT_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PacketObjectDelete::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
|
||||||
|
{
|
||||||
|
WorldPacket::Packet(bs, event, send);
|
||||||
|
|
||||||
|
RW(event->cellRef.mRefID, send);
|
||||||
|
RW(event->cellRef.mRefNum.mIndex, send);
|
||||||
|
|
||||||
|
RW(event->cell.mData.mFlags, send);
|
||||||
|
RW(event->cell.mData.mX, send);
|
||||||
|
RW(event->cell.mData.mY, send);
|
||||||
|
RW(event->cell.mName, send);
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef OPENMW_PACKETOBJECTDELETE_HPP
|
||||||
|
#define OPENMW_PACKETOBJECTDELETE_HPP
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class PacketObjectDelete : public WorldPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PacketObjectDelete(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
|
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_PACKETOBJECTDELETE_HPP
|
@ -0,0 +1,23 @@
|
|||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include "PacketObjectPlace.hpp"
|
||||||
|
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
PacketObjectPlace::PacketObjectPlace(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||||
|
{
|
||||||
|
packetID = ID_WORLD_OBJECT_PLACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PacketObjectPlace::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
|
||||||
|
{
|
||||||
|
WorldPacket::Packet(bs, event, send);
|
||||||
|
|
||||||
|
RW(event->cellRef.mRefID, send);
|
||||||
|
RW(event->cellRef.mRefNum.mIndex, send);
|
||||||
|
RW(event->cellRef.mPos, send);
|
||||||
|
|
||||||
|
RW(event->cell.mData.mFlags, send);
|
||||||
|
RW(event->cell.mData.mX, send);
|
||||||
|
RW(event->cell.mData.mY, send);
|
||||||
|
RW(event->cell.mName, send);
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef OPENMW_PACKETOBJECTPLACE_HPP
|
||||||
|
#define OPENMW_PACKETOBJECTPLACE_HPP
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class PacketObjectPlace : public WorldPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PacketObjectPlace(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
|
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_PACKETOBJECTPLACE_HPP
|
@ -0,0 +1,58 @@
|
|||||||
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
#include <PacketPriority.h>
|
||||||
|
#include <RakPeer.h>
|
||||||
|
#include "WorldPacket.hpp"
|
||||||
|
|
||||||
|
using namespace mwmp;
|
||||||
|
|
||||||
|
void WorldPacket::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
|
||||||
|
{
|
||||||
|
this->event = event;
|
||||||
|
this->bs = bs;
|
||||||
|
|
||||||
|
if (send)
|
||||||
|
{
|
||||||
|
bs->Write(packetID);
|
||||||
|
bs->Write(event->guid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldPacket::WorldPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
||||||
|
{
|
||||||
|
packetID = 0;
|
||||||
|
priority = HIGH_PRIORITY;
|
||||||
|
reliability = RELIABLE_ORDERED;
|
||||||
|
this->peer = peer;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldPacket::~WorldPacket()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldPacket::Send(WorldEvent *event, RakNet::AddressOrGUID destination)
|
||||||
|
{
|
||||||
|
bsSend->ResetWritePointer();
|
||||||
|
Packet(bsSend, event, true);
|
||||||
|
peer->Send(bsSend, priority, reliability, 0, destination, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldPacket::Send(WorldEvent *event, bool toOther)
|
||||||
|
{
|
||||||
|
bsSend->ResetWritePointer();
|
||||||
|
Packet(bsSend, event, true);
|
||||||
|
peer->Send(bsSend, priority, reliability, 0, event->guid, toOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldPacket::Read(WorldEvent *event)
|
||||||
|
{
|
||||||
|
Packet(bsRead, event, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldPacket::RequestData(RakNet::RakNetGUID guid)
|
||||||
|
{
|
||||||
|
bsSend->ResetWritePointer();
|
||||||
|
bsSend->Write(packetID);
|
||||||
|
bsSend->Write(guid);
|
||||||
|
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false);
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef OPENMW_WORLDPACKET_HPP
|
||||||
|
#define OPENMW_WORLDPACKET_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <RakNetTypes.h>
|
||||||
|
#include <BitStream.h>
|
||||||
|
#include <PacketPriority.h>
|
||||||
|
#include <components/openmw-mp/Base/WorldEvent.hpp>
|
||||||
|
|
||||||
|
#include <components/openmw-mp/Packets/BasePacket.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace mwmp
|
||||||
|
{
|
||||||
|
class WorldPacket : public BasePacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WorldPacket(RakNet::RakPeerInterface *peer);
|
||||||
|
|
||||||
|
~WorldPacket();
|
||||||
|
|
||||||
|
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
|
||||||
|
|
||||||
|
virtual void Send(WorldEvent *event, bool toOtherPlayers = true);
|
||||||
|
virtual void Send(WorldEvent *event, RakNet::AddressOrGUID destination);
|
||||||
|
virtual void Read(WorldEvent *event);
|
||||||
|
|
||||||
|
virtual void RequestData(RakNet::RakNetGUID guid);
|
||||||
|
|
||||||
|
static size_t headerSize()
|
||||||
|
{
|
||||||
|
return (size_t)(1 + RakNet::RakNetGUID::size()); // packetID + RakNetGUID (uint64_t)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char GetPacketID()
|
||||||
|
{
|
||||||
|
return packetID;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WorldEvent *event;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENMW_WORLDPACKET_HPP
|
@ -1,82 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by koncord on 15.01.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
|
|
||||||
#include "Packets/PacketClass.hpp"
|
|
||||||
#include "Packets/PacketPosition.hpp"
|
|
||||||
#include "Packets/PacketBaseInfo.hpp"
|
|
||||||
#include "components/openmw-mp/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"
|
|
||||||
#include "Packets/PacketInventory.hpp"
|
|
||||||
|
|
||||||
#include "PacketsController.hpp"
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline void AddPacket(mwmp::PacketsController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
|
||||||
{
|
|
||||||
T *packet = new T(peer);
|
|
||||||
typedef mwmp::PacketsController::packets_t::value_type value_t;
|
|
||||||
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
|
||||||
}
|
|
||||||
|
|
||||||
mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
|
|
||||||
{
|
|
||||||
AddPacket<PacketPosition>(&packets, peer);
|
|
||||||
AddPacket<PacketCell>(&packets, peer);
|
|
||||||
AddPacket<PacketBaseInfo>(&packets, peer);
|
|
||||||
AddPacket<PacketEquipment>(&packets, peer);
|
|
||||||
|
|
||||||
AddPacket<PacketAttack>(&packets, peer);
|
|
||||||
AddPacket<PacketDynamicStats>(&packets, peer);
|
|
||||||
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);
|
|
||||||
AddPacket<PacketLevel>(&packets, peer);
|
|
||||||
|
|
||||||
AddPacket<PacketHandshake>(&packets, peer);
|
|
||||||
AddPacket<PacketGUIBoxes>(&packets, peer);
|
|
||||||
AddPacket<PacketClass>(&packets, peer);
|
|
||||||
AddPacket<PacketTime>(&packets, peer);
|
|
||||||
AddPacket<PacketLoaded>(&packets, peer);
|
|
||||||
AddPacket<PacketInventory>(&packets, peer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mwmp::PlayerPacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
|
|
||||||
{
|
|
||||||
return packets[(unsigned char)id].get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void mwmp::PacketsController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
|
||||||
{
|
|
||||||
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
|
||||||
packet.second->SetStreams(inStream, outStream);
|
|
||||||
}
|
|
Loading…
Reference in New Issue