openmw-tes3coop/components/openmw-mp/Packets/Player/PlayerPacket.cpp

51 lines
1.1 KiB
C++
Raw Normal View History

#include <components/openmw-mp/NetworkMessages.hpp>
#include <PacketPriority.h>
#include <RakPeer.h>
2016-10-17 12:54:36 +00:00
#include "PlayerPacket.hpp"
using namespace mwmp;
2016-10-17 12:54:36 +00:00
void PlayerPacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
this->player = player;
this->bs = bs;
2016-08-17 15:20:36 +00:00
if (send)
{
2016-08-05 19:28:01 +00:00
bs->Write(packetID);
bs->Write(player->guid);
}
}
PlayerPacket::PlayerPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
{
packetID = 0;
priority = HIGH_PRIORITY;
reliability = RELIABLE_ORDERED;
this->peer = peer;
}
2016-10-17 12:54:36 +00:00
PlayerPacket::~PlayerPacket()
{
}
2016-10-17 12:54:36 +00:00
void PlayerPacket::Send(BasePlayer *player, RakNet::AddressOrGUID destination)
{
bsSend->ResetWritePointer();
Packet(bsSend, player, true);
peer->Send(bsSend, priority, reliability, 0, destination, false);
}
2016-10-17 12:54:36 +00:00
void PlayerPacket::Send(BasePlayer *player, bool toOther)
{
bsSend->ResetWritePointer();
Packet(bsSend, player, true);
peer->Send(bsSend, priority, reliability, 0, player->guid, toOther);
}
2016-10-17 12:54:36 +00:00
void PlayerPacket::Read(BasePlayer *player)
{
Packet(bsRead, player, false);
}