mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[General] Move repeated code in Packet() to base class
This commit is contained in:
parent
df051a777a
commit
0d53a6916d
4 changed files with 15 additions and 15 deletions
|
@ -18,6 +18,17 @@ BasePacket::~BasePacket()
|
|||
|
||||
}
|
||||
|
||||
void BasePacket::Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send)
|
||||
{
|
||||
this->bs = bs;
|
||||
|
||||
if (send)
|
||||
{
|
||||
bs->Write(packetID);
|
||||
bs->Write(guid);
|
||||
}
|
||||
}
|
||||
|
||||
void BasePacket::SetReadStream(RakNet::BitStream *bitStream)
|
||||
{
|
||||
bsRead = bitStream;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <RakNetTypes.h>
|
||||
#include <BitStream.h>
|
||||
#include <PacketPriority.h>
|
||||
#include <components/openmw-mp/Base/BasePlayer.hpp>
|
||||
|
||||
|
||||
namespace mwmp
|
||||
|
@ -17,6 +16,8 @@ namespace mwmp
|
|||
|
||||
~BasePacket();
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, RakNet::RakNetGUID &guid, bool send);
|
||||
|
||||
void SetReadStream(RakNet::BitStream *bitStream);
|
||||
void SetSendStream(RakNet::BitStream *bitStream);
|
||||
void SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream);
|
||||
|
|
|
@ -7,14 +7,8 @@ using namespace mwmp;
|
|||
|
||||
void PlayerPacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
||||
{
|
||||
BasePacket::Packet(bs, player->guid, send);
|
||||
this->player = player;
|
||||
this->bs = bs;
|
||||
|
||||
if (send)
|
||||
{
|
||||
bs->Write(packetID);
|
||||
bs->Write(player->guid);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerPacket::PlayerPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
||||
|
|
|
@ -7,14 +7,8 @@ using namespace mwmp;
|
|||
|
||||
void WorldPacket::Packet(RakNet::BitStream *bs, BaseEvent *event, bool send)
|
||||
{
|
||||
BasePacket::Packet(bs, event->guid, send);
|
||||
this->event = event;
|
||||
this->bs = bs;
|
||||
|
||||
if (send)
|
||||
{
|
||||
bs->Write(packetID);
|
||||
bs->Write(event->guid);
|
||||
}
|
||||
}
|
||||
|
||||
WorldPacket::WorldPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
||||
|
|
Loading…
Reference in a new issue