forked from mirror/openmw-tes3mp
[General] Pack player->direction.pos to 1 byte
This commit is contained in:
parent
dded330cc4
commit
7e5e877fda
1 changed files with 7 additions and 7 deletions
|
@ -20,26 +20,26 @@ void PacketPlayerPosition::Packet(RakNet::BitStream *bs, bool send)
|
|||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
float rot[2];
|
||||
unsigned char dir;
|
||||
if(send)
|
||||
{
|
||||
rot[0] = player->position.rot[0] * 0.1f;
|
||||
rot[1] = player->position.rot[2] * 0.1f;
|
||||
|
||||
dir = (player->direction.pos[0] >= 0 ? (unsigned char)(player->direction.pos[0]) : (unsigned char) 0x3) << 2; // pack direction
|
||||
dir += (player->direction.pos[1] >= 0 ? (unsigned char)(player->direction.pos[1]) : (unsigned char) 0x3);
|
||||
}
|
||||
RW(rot[0], send, 1);
|
||||
RW(rot[1], send, 1);
|
||||
|
||||
RW(player->position.pos, send, 1);
|
||||
RW(player->direction.pos[0], send, 1);
|
||||
RW(player->direction.pos[1], send, 1);
|
||||
RW(dir, send);
|
||||
|
||||
if(!send)
|
||||
{
|
||||
player->position.rot[0] = rot[0] / 0.1f;
|
||||
player->position.rot[2] = rot[1] / 0.1f;
|
||||
|
||||
if(abs(player->direction.pos[0]) < 1)
|
||||
player->direction.pos[0] = 0;
|
||||
if(abs(player->direction.pos[1]) < 1)
|
||||
player->direction.pos[1] = 0;
|
||||
player->direction.pos[0] = (dir >> 2) == 0x3 ? -1 : dir >> 2; // unpack direction
|
||||
player->direction.pos[1] = (dir & 0x3) == 0x3 ? -1 : dir & 0x3;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue