|
|
|
@ -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;
|