2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
#include <PacketPriority.h>
|
|
|
|
#include <RakPeer.h>
|
2016-10-17 12:54:36 +00:00
|
|
|
#include "PlayerPacket.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2016-10-17 12:54:36 +00:00
|
|
|
void PlayerPacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-03-05 08:01:42 +00:00
|
|
|
BasePacket::Packet(bs, player->guid, send);
|
2016-01-12 03:41:44 +00:00
|
|
|
this->player = player;
|
|
|
|
}
|
|
|
|
|
2016-10-17 15:47:16 +00:00
|
|
|
PlayerPacket::PlayerPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
packetID = 0;
|
|
|
|
priority = HIGH_PRIORITY;
|
|
|
|
reliability = RELIABLE_ORDERED;
|
|
|
|
this->peer = peer;
|
|
|
|
}
|
|
|
|
|
2016-10-17 12:54:36 +00:00
|
|
|
PlayerPacket::~PlayerPacket()
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-17 12:54:36 +00:00
|
|
|
void PlayerPacket::Send(BasePlayer *player, RakNet::AddressOrGUID destination)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
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)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
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)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Packet(bsRead, player, false);
|
|
|
|
}
|