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