2016-01-12 03:41:44 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 05.01.16.
|
|
|
|
//
|
|
|
|
|
2017-02-05 07:01:33 +00:00
|
|
|
#include "PacketPlayerPosition.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2017-02-05 07:01:33 +00:00
|
|
|
PacketPlayerPosition::PacketPlayerPosition(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-04-25 19:11:33 +00:00
|
|
|
packetID = ID_PLAYER_POSITION;
|
2016-01-12 03:41:44 +00:00
|
|
|
priority = MEDIUM_PRIORITY;
|
|
|
|
//reliability = UNRELIABLE_SEQUENCED;
|
|
|
|
}
|
|
|
|
|
2017-03-06 09:44:08 +00:00
|
|
|
void PacketPlayerPosition::Packet(RakNet::BitStream *bs, bool send)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-03-06 09:44:08 +00:00
|
|
|
PlayerPacket::Packet(bs, send);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-06-02 09:20:34 +00:00
|
|
|
float rot[2];
|
|
|
|
if(send)
|
|
|
|
{
|
|
|
|
rot[0] = player->position.rot[0] * 0.1f;
|
|
|
|
rot[1] = player->position.rot[2] * 0.1f;
|
|
|
|
}
|
|
|
|
RW(rot[0], send, 1);
|
|
|
|
RW(rot[1], send, 1);
|
|
|
|
if(!send)
|
|
|
|
{
|
|
|
|
player->position.rot[0] = rot[0] / 0.1f;
|
|
|
|
player->position.rot[2] = rot[1] / 0.1f;
|
|
|
|
}
|
|
|
|
|
|
|
|
RW(player->position.pos, send, 1);
|
2017-06-02 07:44:51 +00:00
|
|
|
RW(player->direction.pos, send, 1);
|
2017-01-26 04:17:29 +00:00
|
|
|
}
|