Rename BasePacket into PlayerPacket

coverity_scan^2
David Cernat 8 years ago
parent 3136a12051
commit b8f4cb94fb

@ -69,7 +69,7 @@ void Networking::Update(RakNet::Packet *packet)
return;
}
BasePacket *myPacket = controller->GetPacket(packet->data[0]);
PlayerPacket *myPacket = controller->GetPacket(packet->data[0]);
if (packet->data[0] == ID_HANDSHAKE)
{

@ -178,7 +178,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
if (id != myid)
pl = Players::GetPlayer(id);
BasePacket *myPacket = controller.GetPacket(packet->data[0]);
PlayerPacket *myPacket = controller.GetPacket(packet->data[0]);
switch (packet->data[0])
{
@ -618,7 +618,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
}
BasePacket *Networking::GetPacket(RakNet::MessageID id)
PlayerPacket *Networking::GetPacket(RakNet::MessageID id)
{
return controller.GetPacket(id);
}

@ -33,7 +33,7 @@ namespace mwmp
void Connect(const std::string& ip, unsigned short port);
void Update();
void SendData(RakNet::BitStream *bitStream);
BasePacket *GetPacket(RakNet::MessageID id);
PlayerPacket *GetPacket(RakNet::MessageID id);
bool isDedicatedPlayer(const MWWorld::Ptr &ptr);
bool Attack(const MWWorld::Ptr &ptr);

@ -148,7 +148,7 @@ add_component_dir (version
add_component_dir (openmw-mp
Log
PacketsController
Packets/BasePacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquipment Packets/PacketAttack
Packets/PlayerPacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquipment Packets/PacketAttack
Packets/PacketDynamicStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage
Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketLevel Packets/PacketHandshake
Packets/PacketGUIBoxes Packets/PacketClass Packets/PacketTime)

@ -7,14 +7,14 @@
using namespace mwmp;
PacketAttack::PacketAttack(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketAttack::PacketAttack(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_ATTACK;
}
void PacketAttack::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->GetAttack()->attacker, send);
RW(player->GetAttack()->target, send);

@ -6,11 +6,11 @@
#define OPENMW_PACKETATTACK_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketAttack : public BasePacket
class PacketAttack : public PlayerPacket
{
public:
PacketAttack(RakNet::RakPeerInterface *peer);

@ -7,14 +7,14 @@
using namespace mwmp;
PacketAttribute::PacketAttribute(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketAttribute::PacketAttribute(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_ATTRIBUTE;
}
void PacketAttribute::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
for (int i = 0; i < AttributeCount; ++i)
RW(player->CreatureStats()->mAttributes[i], send);

@ -5,11 +5,11 @@
#ifndef OPENMW_PACKETATTRIBUTE_HPP
#define OPENMW_PACKETATTRIBUTE_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketAttribute : public BasePacket
class PacketAttribute : public PlayerPacket
{
public:
const static int AttributeCount = 8;

@ -7,14 +7,14 @@
using namespace mwmp;
PacketBaseInfo::PacketBaseInfo(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketBaseInfo::PacketBaseInfo(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_BASE_INFO;
}
void PacketBaseInfo::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->Npc()->mName, send);
RW(player->Npc()->mModel, send);

@ -5,11 +5,11 @@
#ifndef OPENMW_PACKETBASEINFO_HPP
#define OPENMW_PACKETBASEINFO_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketBaseInfo : public BasePacket
class PacketBaseInfo : public PlayerPacket
{
public:
PacketBaseInfo(RakNet::RakPeerInterface *peer);

@ -6,7 +6,7 @@
#include "PacketCell.hpp"
mwmp::PacketCell::PacketCell(RakNet::RakPeerInterface *peer) : BasePacket(peer)
mwmp::PacketCell::PacketCell(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_CELL;
priority = IMMEDIATE_PRIORITY;
@ -15,7 +15,7 @@ mwmp::PacketCell::PacketCell(RakNet::RakPeerInterface *peer) : BasePacket(peer)
void mwmp::PacketCell::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->GetCell()->mData.mFlags, send);

@ -6,11 +6,11 @@
#define OPENMW_PACKETCELL_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketCell : public BasePacket
class PacketCell : public PlayerPacket
{
public:
PacketCell(RakNet::RakPeerInterface *peer);

@ -5,14 +5,14 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketCharGen.hpp"
mwmp::PacketCharGen::PacketCharGen(RakNet::RakPeerInterface *peer) : BasePacket(peer)
mwmp::PacketCharGen::PacketCharGen(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_CHARGEN;
}
void mwmp::PacketCharGen::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(*player->CharGenStage(), send);

@ -6,11 +6,11 @@
#define OPENMW_PACKETCHARGEN_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketCharGen : public BasePacket
class PacketCharGen : public PlayerPacket
{
public:
PacketCharGen(RakNet::RakPeerInterface *peer);

@ -5,14 +5,14 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketChatMessage.hpp"
mwmp::PacketChatMessage::PacketChatMessage(RakNet::RakPeerInterface *peer) : BasePacket(peer)
mwmp::PacketChatMessage::PacketChatMessage(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_CHAT_MESSAGE;
}
void mwmp::PacketChatMessage::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(*player->ChatMessage(), send);
}

@ -5,11 +5,11 @@
#ifndef OPENMW_PACKETCHATMESSAGE_HPP
#define OPENMW_PACKETCHATMESSAGE_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketChatMessage : public BasePacket
class PacketChatMessage : public PlayerPacket
{
public:
PacketChatMessage(RakNet::RakPeerInterface *peer);

@ -5,14 +5,14 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketClass.hpp"
mwmp::PacketClass::PacketClass(RakNet::RakPeerInterface *peer) : BasePacket(peer)
mwmp::PacketClass::PacketClass(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_CHARCLASS;
}
void mwmp::PacketClass::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->charClass.mId, send);
if (player->charClass.mId.empty()) // custom class

@ -6,11 +6,11 @@
#define OPENMW_PACKETCLASS_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketClass : public BasePacket
class PacketClass : public PlayerPacket
{
public:
PacketClass(RakNet::RakPeerInterface *peer);

@ -6,21 +6,21 @@
#define OPENMW_PACKETDIE_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
namespace mwmp
{
class PacketDie: public BasePacket
class PacketDie: public PlayerPacket
{
public:
PacketDie(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketDie(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_DIE;
}
void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->CreatureStats()->mDead, send);
}
};

@ -5,15 +5,15 @@
#ifndef OPENMW_PACKETDISCONNECT_HPP
#define OPENMW_PACKETDISCONNECT_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
namespace mwmp
{
class PacketDisconnect : public BasePacket
class PacketDisconnect : public PlayerPacket
{
public:
PacketDisconnect(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketDisconnect(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_USER_DISCONNECTED;
}

@ -5,14 +5,14 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketDrawState.hpp"
mwmp::PacketDrawState::PacketDrawState(RakNet::RakPeerInterface *peer) : BasePacket(peer)
mwmp::PacketDrawState::PacketDrawState(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_DRAWSTATE;
}
void mwmp::PacketDrawState::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(*player->MovementFlags(), send);

@ -6,11 +6,11 @@
#define OPENMW_PACKETDRAWSTATE_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketDrawState : public BasePacket
class PacketDrawState : public PlayerPacket
{
public:
PacketDrawState(RakNet::RakPeerInterface *peer);

@ -7,14 +7,14 @@
using namespace mwmp;
PacketDynamicStats::PacketDynamicStats(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketDynamicStats::PacketDynamicStats(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_DYNAMICSTATS;
}
void PacketDynamicStats::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->CreatureStats()->mDynamic[0], send); // health
RW(player->CreatureStats()->mDynamic[1], send); // magic
RW(player->CreatureStats()->mDynamic[2], send); // fatigue

@ -6,11 +6,11 @@
#define OPENMW_PACKAGEDYNAMICSTATS_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketDynamicStats : public BasePacket
class PacketDynamicStats : public PlayerPacket
{
public:
PacketDynamicStats(RakNet::RakPeerInterface *peer);

@ -7,14 +7,14 @@
using namespace mwmp;
PacketEquipment::PacketEquipment(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketEquipment::PacketEquipment(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_EQUIPMENT;
}
void PacketEquipment::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
for (int i = 0; i < 19; i++)
{

@ -5,11 +5,11 @@
#ifndef OPENMW_PACKETEQUIPMENT_HPP
#define OPENMW_PACKETEQUIPMENT_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketEquipment : public BasePacket
class PacketEquipment : public PlayerPacket
{
public:
PacketEquipment(RakNet::RakPeerInterface *peer);

@ -7,14 +7,14 @@
using namespace mwmp;
PacketGUIBoxes::PacketGUIBoxes(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketGUIBoxes::PacketGUIBoxes(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GUI_MESSAGEBOX;
}
void PacketGUIBoxes::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->guiMessageBox.id, send);
RW(player->guiMessageBox.type, send);

@ -6,11 +6,11 @@
#define OPENMW_PACKETGUIBOXES_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketGUIBoxes : public BasePacket
class PacketGUIBoxes : public PlayerPacket
{
public:
PacketGUIBoxes(RakNet::RakPeerInterface *peer);

@ -7,14 +7,14 @@
using namespace mwmp;
PacketHandshake::PacketHandshake(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketHandshake::PacketHandshake(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_HANDSHAKE;
}
void PacketHandshake::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->Npc()->mName, send);
RW(*player->GetPassw(), send);
}

@ -5,11 +5,11 @@
#ifndef OPENMW_PACKETHANDSHAKE_HPP
#define OPENMW_PACKETHANDSHAKE_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketHandshake : public BasePacket
class PacketHandshake : public PlayerPacket
{
public:
PacketHandshake(RakNet::RakPeerInterface *peer);

@ -7,14 +7,14 @@
using namespace mwmp;
PacketLevel::PacketLevel(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketLevel::PacketLevel(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_LEVEL;
}
void PacketLevel::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->CreatureStats()->mLevel, send);
}

@ -5,11 +5,11 @@
#ifndef OPENMW_PACKETLEVEL_HPP
#define OPENMW_PACKETLEVEL_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketLevel : public BasePacket
class PacketLevel : public PlayerPacket
{
public:
PacketLevel(RakNet::RakPeerInterface *peer);

@ -5,14 +5,14 @@
#ifndef OPENMW_PACKETLOADED_HPP
#define OPENMW_PACKETLOADED_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketLoaded : public BasePacket
class PacketLoaded : public PlayerPacket
{
public:
PacketLoaded(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketLoaded(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_LOADED;
}

@ -8,7 +8,7 @@
using namespace std;
using namespace mwmp;
PacketPosition::PacketPosition(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketPosition::PacketPosition(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_POS;
priority = MEDIUM_PRIORITY;
@ -17,7 +17,7 @@ PacketPosition::PacketPosition(RakNet::RakPeerInterface *peer) : BasePacket(peer
void PacketPosition::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(*player->Position(), send);
RW(*player->Dir(), send);

@ -5,11 +5,11 @@
#ifndef OPENMW_PACKETPOSITION_HPP
#define OPENMW_PACKETPOSITION_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketPosition : public BasePacket
class PacketPosition : public PlayerPacket
{
public:
PacketPosition(RakNet::RakPeerInterface *peer);

@ -6,21 +6,21 @@
#define OPENMW_PACKETRESURRECT_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
namespace mwmp
{
class PacketResurrect: public BasePacket
class PacketResurrect: public PlayerPacket
{
public:
PacketResurrect(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketResurrect(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_RESURRECT;
}
void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->CreatureStats()->mDead, send);
}
};

@ -5,15 +5,15 @@
#ifndef OPENMW_PACKETSENDMYID_HPP
#define OPENMW_PACKETSENDMYID_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
namespace mwmp
{
class PacketSendMyID : public BasePacket
class PacketSendMyID : public PlayerPacket
{
public:
PacketSendMyID(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketSendMyID(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_USER_MYID;
}

@ -9,14 +9,14 @@
using namespace mwmp;
PacketSkill::PacketSkill(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketSkill::PacketSkill(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_SKILL;
}
void PacketSkill::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
for (int i = 0; i < SkillCount; ++i)
RW(player->NpcStats()->mSkills[i], send);

@ -6,11 +6,11 @@
#define OPENMW_PACKETSKILL_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketSkill : public BasePacket
class PacketSkill : public PlayerPacket
{
public:
const static int SkillCount = 27;

@ -7,14 +7,14 @@
using namespace mwmp;
PacketTime::PacketTime(RakNet::RakPeerInterface *peer) : BasePacket(peer)
PacketTime::PacketTime(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_GAME_TIME;
}
void PacketTime::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
PlayerPacket::Packet(bs, player, send);
RW(player->month, send);
RW(player->day, send);

@ -6,11 +6,11 @@
#define OPENMW_TIMEPACKET_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
namespace mwmp
{
class PacketTime : public BasePacket
class PacketTime : public PlayerPacket
{
public:
PacketTime(RakNet::RakPeerInterface *peer);

@ -1,15 +1,11 @@
//
// Created by koncord on 05.01.16.
//
#include <components/openmw-mp/NetworkMessages.hpp>
#include <PacketPriority.h>
#include <RakPeer.h>
#include "BasePacket.hpp"
#include "PlayerPacket.hpp"
using namespace mwmp;
void BasePacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
void PlayerPacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
this->player = player;
this->bs = bs;
@ -21,7 +17,7 @@ void BasePacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
}
}
BasePacket::BasePacket(RakNet::RakPeerInterface *peer)
PlayerPacket::PlayerPacket(RakNet::RakPeerInterface *peer)
{
packetID = 0;
priority = HIGH_PRIORITY;
@ -29,41 +25,41 @@ BasePacket::BasePacket(RakNet::RakPeerInterface *peer)
this->peer = peer;
}
BasePacket::~BasePacket()
PlayerPacket::~PlayerPacket()
{
}
void BasePacket::Send(BasePlayer *player, RakNet::AddressOrGUID destination)
void PlayerPacket::Send(BasePlayer *player, RakNet::AddressOrGUID destination)
{
bsSend->ResetWritePointer();
Packet(bsSend, player, true);
peer->Send(bsSend, priority, reliability, 0, destination, false);
}
void BasePacket::Send(BasePlayer *player, bool toOther)
void PlayerPacket::Send(BasePlayer *player, bool toOther)
{
bsSend->ResetWritePointer();
Packet(bsSend, player, true);
peer->Send(bsSend, priority, reliability, 0, player->guid, toOther);
}
void BasePacket::Read(BasePlayer *player)
void PlayerPacket::Read(BasePlayer *player)
{
Packet(bsRead, player, false);
}
void BasePacket::SetReadStream(RakNet::BitStream *bitStream)
void PlayerPacket::SetReadStream(RakNet::BitStream *bitStream)
{
bsRead = bitStream;
}
void BasePacket::SetSendStream(RakNet::BitStream *bitStream)
void PlayerPacket::SetSendStream(RakNet::BitStream *bitStream)
{
bsSend = bitStream;
}
void BasePacket::RequestData(RakNet::RakNetGUID player)
void PlayerPacket::RequestData(RakNet::RakNetGUID player)
{
bsSend->ResetWritePointer();
bsSend->Write(packetID);
@ -71,7 +67,7 @@ void BasePacket::RequestData(RakNet::RakNetGUID player)
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, player, false);
}
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
void PlayerPacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
{
if (inStream != 0)
bsRead = inStream;

@ -1,9 +1,5 @@
//
// Created by koncord on 05.01.16.
//
#ifndef OPENMW_BASEPACKET_HPP
#define OPENMW_BASEPACKET_HPP
#ifndef OPENMW_PLAYERPACKET_HPP
#define OPENMW_PLAYERPACKET_HPP
#include <string>
#include <RakNetTypes.h>
@ -14,12 +10,12 @@
namespace mwmp
{
class BasePacket
class PlayerPacket
{
public:
BasePacket(RakNet::RakPeerInterface *peer);
PlayerPacket(RakNet::RakPeerInterface *peer);
~BasePacket();
~PlayerPacket();
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
@ -106,4 +102,4 @@ namespace mwmp
};
}
#endif //OPENMW_BASEPACKET_HPP
#endif //OPENMW_PLAYERPACKET_HPP

@ -68,7 +68,7 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
}
mwmp::BasePacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
mwmp::PlayerPacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
{
return packets[(unsigned char)id].get();
}

@ -7,7 +7,7 @@
#include <RakPeerInterface.h>
#include "Packets/BasePacket.hpp"
#include "Packets/PlayerPacket.hpp"
#include <map>
#include <boost/shared_ptr.hpp>
@ -17,10 +17,10 @@ namespace mwmp
{
public:
PacketsController(RakNet::RakPeerInterface *peer);
BasePacket *GetPacket(RakNet::MessageID id);
PlayerPacket *GetPacket(RakNet::MessageID id);
void SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream);
typedef std::map<unsigned char, boost::shared_ptr<BasePacket> > packets_t;
typedef std::map<unsigned char, boost::shared_ptr<PlayerPacket> > packets_t;
private:
packets_t packets;
};

Loading…
Cancel
Save