Skip to content

Commit

Permalink
Network proto
Browse files Browse the repository at this point in the history
  • Loading branch information
grorp committed Dec 16, 2024
1 parent 2c13449 commit d6f01e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ void Client::Send(NetworkPacket* pkt)
m_con->Send(PEER_ID_SERVER, scf.channel, pkt, scf.reliable);
}

// Will fill up 12 + 12 + 4 + 4 + 4 + 1 + 1 + 1 + 4 + 4 bytes
// Will fill up 12 + 12 + 4 + 4 + 4 + 1 + 1 + 1 + 4 + 4 + 4 + 4 bytes
void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *pkt, bool camera_inverted)
{
v3f pf = myplayer->getPosition() * 100;
Expand Down Expand Up @@ -1048,6 +1048,8 @@ void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket *
[12+12+4+4+4+1+1] u8 camera_inverted (bool)
[12+12+4+4+4+1+1+1] f32 movement_speed
[12+12+4+4+4+1+1+1+4] f32 movement_direction
[12+12+4+4+4+1+1+1+4+4] f32 point_pitch
[12+12+4+4+4+1+1+1+4+4+4] f32 point_yaw
*/
*pkt << position << speed << pitch << yaw << keyPressed;
*pkt << fov << wanted_range;
Expand Down Expand Up @@ -1418,7 +1420,7 @@ void Client::sendPlayerPos()
player->last_point_pitch = player->point_pitch;
player->last_point_yaw = player->point_yaw;

NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1 + 1 + 4 + 4);
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1 + 1 + 4 + 4 + 4 + 4);

writePlayerPos(player, &map, &pkt, camera_inverted);

Expand Down
2 changes: 2 additions & 0 deletions src/network/networkprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,8 @@ enum ToServerCommand : u16
[2+12+12+4+4+4+1+1] u8 camera_inverted (bool)
[2+12+12+4+4+4+1+1+1] f32 movement_speed
[2+12+12+4+4+4+1+1+1+4] f32 movement_direction
[2+12+12+4+4+4+1+1+1+4+4] f32 point_pitch
[2+12+12+4+4+4+1+1+1+4+4+4] f32 point_yaw
*/

Expand Down

0 comments on commit d6f01e6

Please sign in to comment.