forked from teamnwah/openmw-tes3coop
Rename PacketsController into PlayerPacketController
This commit is contained in:
parent
5e0c0dd5f1
commit
d2212ef80b
6 changed files with 41 additions and 49 deletions
|
@ -26,7 +26,7 @@ Networking::Networking(RakNet::RakPeerInterface *peer)
|
||||||
this->peer = peer;
|
this->peer = peer;
|
||||||
players = Players::GetPlayers();
|
players = Players::GetPlayers();
|
||||||
|
|
||||||
controller = new PacketsController(peer);
|
controller = new PlayerPacketController(peer);
|
||||||
|
|
||||||
controller->SetStream(0, &bsOut); // set send stream
|
controller->SetStream(0, &bsOut); // set send stream
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ void Networking::DisconnectPlayer(RakNet::RakNetGUID guid)
|
||||||
Players::DeletePlayer(guid);
|
Players::DeletePlayer(guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketsController *Networking::GetController() const
|
PlayerPacketController *Networking::GetController() const
|
||||||
{
|
{
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef OPENMW_NETWORKING_HPP
|
#ifndef OPENMW_NETWORKING_HPP
|
||||||
#define OPENMW_NETWORKING_HPP
|
#define OPENMW_NETWORKING_HPP
|
||||||
|
|
||||||
#include <components/openmw-mp/PacketsController.hpp>
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
||||||
#include "Player.hpp"
|
#include "Player.hpp"
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
|
@ -27,7 +27,7 @@ namespace mwmp
|
||||||
|
|
||||||
void StopServer(int code);
|
void StopServer(int code);
|
||||||
|
|
||||||
PacketsController *GetController() const;
|
PlayerPacketController *GetController() const;
|
||||||
static const Networking &Get();
|
static const Networking &Get();
|
||||||
static Networking *GetPtr();
|
static Networking *GetPtr();
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace mwmp
|
||||||
RakNet::BitStream bsOut;
|
RakNet::BitStream bsOut;
|
||||||
TPlayers *players;
|
TPlayers *players;
|
||||||
|
|
||||||
PacketsController *controller;
|
PlayerPacketController *controller;
|
||||||
|
|
||||||
bool running;
|
bool running;
|
||||||
int exitCode;
|
int exitCode;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <components/openmw-mp/Packets/PacketDie.hpp>
|
#include <components/openmw-mp/Packets/PacketDie.hpp>
|
||||||
#include <components/openmw-mp/Packets/PacketCell.hpp>
|
#include <components/openmw-mp/Packets/PacketCell.hpp>
|
||||||
#include <components/openmw-mp/Packets/PacketDrawState.hpp>
|
#include <components/openmw-mp/Packets/PacketDrawState.hpp>
|
||||||
#include <components/openmw-mp/PacketsController.hpp>
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
||||||
|
|
||||||
namespace mwmp
|
namespace mwmp
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ namespace mwmp
|
||||||
RakNet::SystemAddress serverAddr;
|
RakNet::SystemAddress serverAddr;
|
||||||
RakNet::BitStream bsOut;
|
RakNet::BitStream bsOut;
|
||||||
|
|
||||||
PacketsController controller;
|
PlayerPacketController controller;
|
||||||
|
|
||||||
void ReceiveMessage(RakNet::Packet *packet);
|
void ReceiveMessage(RakNet::Packet *packet);
|
||||||
LocalPlayer *getLocalPlayer();
|
LocalPlayer *getLocalPlayer();
|
||||||
|
|
|
@ -147,7 +147,7 @@ add_component_dir (version
|
||||||
|
|
||||||
add_component_dir (openmw-mp
|
add_component_dir (openmw-mp
|
||||||
Log
|
Log
|
||||||
PacketsController
|
Controllers/PlayerPacketController
|
||||||
Packets/BasePacket Packets/PlayerPacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquipment
|
Packets/BasePacket Packets/PlayerPacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquipment
|
||||||
Packets/PacketAttack Packets/PacketDynamicStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage
|
Packets/PacketAttack Packets/PacketDynamicStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage
|
||||||
Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketLevel Packets/PacketHandshake
|
Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketLevel Packets/PacketHandshake
|
||||||
|
|
|
@ -1,44 +1,40 @@
|
||||||
//
|
|
||||||
// Created by koncord on 15.01.16.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
#include "Packets/PacketClass.hpp"
|
#include "../Packets/PacketClass.hpp"
|
||||||
#include "Packets/PacketPosition.hpp"
|
#include "../Packets/PacketPosition.hpp"
|
||||||
#include "Packets/PacketBaseInfo.hpp"
|
#include "../Packets/PacketBaseInfo.hpp"
|
||||||
#include "Packets/PacketEquipment.hpp"
|
#include "../Packets/PacketEquipment.hpp"
|
||||||
#include "Packets/PacketAttack.hpp"
|
#include "../Packets/PacketAttack.hpp"
|
||||||
#include "Packets/PacketDynamicStats.hpp"
|
#include "../Packets/PacketDynamicStats.hpp"
|
||||||
#include "Packets/PacketResurrect.hpp"
|
#include "../Packets/PacketResurrect.hpp"
|
||||||
#include "Packets/PacketDie.hpp"
|
#include "../Packets/PacketDie.hpp"
|
||||||
#include "Packets/PacketCell.hpp"
|
#include "../Packets/PacketCell.hpp"
|
||||||
#include "Packets/PacketSendMyID.hpp"
|
#include "../Packets/PacketSendMyID.hpp"
|
||||||
#include "Packets/PacketDisconnect.hpp"
|
#include "../Packets/PacketDisconnect.hpp"
|
||||||
#include "Packets/PacketDrawState.hpp"
|
#include "../Packets/PacketDrawState.hpp"
|
||||||
#include "Packets/PacketChatMessage.hpp"
|
#include "../Packets/PacketChatMessage.hpp"
|
||||||
#include "Packets/PacketCharGen.hpp"
|
#include "../Packets/PacketCharGen.hpp"
|
||||||
#include "Packets/PacketAttribute.hpp"
|
#include "../Packets/PacketAttribute.hpp"
|
||||||
#include "Packets/PacketSkill.hpp"
|
#include "../Packets/PacketSkill.hpp"
|
||||||
#include "Packets/PacketLevel.hpp"
|
#include "../Packets/PacketLevel.hpp"
|
||||||
#include "Packets/PacketHandshake.hpp"
|
#include "../Packets/PacketHandshake.hpp"
|
||||||
#include "Packets/PacketGUIBoxes.hpp"
|
#include "../Packets/PacketGUIBoxes.hpp"
|
||||||
#include "Packets/PacketTime.hpp"
|
#include "../Packets/PacketTime.hpp"
|
||||||
#include "Packets/PacketLoaded.hpp"
|
#include "../Packets/PacketLoaded.hpp"
|
||||||
|
|
||||||
#include "PacketsController.hpp"
|
#include "PlayerPacketController.hpp"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void AddPacket(mwmp::PacketsController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
inline void AddPacket(mwmp::PlayerPacketController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
||||||
{
|
{
|
||||||
T *packet = new T(peer);
|
T *packet = new T(peer);
|
||||||
typedef mwmp::PacketsController::packets_t::value_type value_t;
|
typedef mwmp::PlayerPacketController::packets_t::value_type value_t;
|
||||||
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
||||||
}
|
}
|
||||||
|
|
||||||
mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
|
mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *peer)
|
||||||
{
|
{
|
||||||
AddPacket<PacketPosition>(&packets, peer);
|
AddPacket<PacketPosition>(&packets, peer);
|
||||||
AddPacket<PacketCell>(&packets, peer);
|
AddPacket<PacketCell>(&packets, peer);
|
||||||
|
@ -68,12 +64,12 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mwmp::PlayerPacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
|
mwmp::PlayerPacket *mwmp::PlayerPacketController::GetPacket(RakNet::MessageID id)
|
||||||
{
|
{
|
||||||
return packets[(unsigned char)id].get();
|
return packets[(unsigned char)id].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mwmp::PacketsController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
void mwmp::PlayerPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
||||||
packet.second->SetStreams(inStream, outStream);
|
packet.second->SetStreams(inStream, outStream);
|
|
@ -1,22 +1,18 @@
|
||||||
//
|
#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/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);
|
||||||
|
|
||||||
|
@ -26,4 +22,4 @@ namespace mwmp
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENMW_PACKETSCONTROLLER_HPP
|
#endif //OPENMW_PLAYERPACKETCONTROLLER_HPP
|
Loading…
Reference in a new issue