client.cpp: Fix code-style in Client::sendPlayerPos

This commit is contained in:
ANAND 2019-08-21 18:38:41 +05:30 committed by sfan5
parent e2d6445f2a
commit eea082ee3f

@ -1234,42 +1234,41 @@ void Client::sendReady()
void Client::sendPlayerPos() void Client::sendPlayerPos()
{ {
LocalPlayer *myplayer = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
if (!myplayer) if (!player)
return; return;
ClientMap &map = m_env.getClientMap(); ClientMap &map = m_env.getClientMap();
u8 camera_fov = map.getCameraFov();
u8 camera_fov = map.getCameraFov(); u8 wanted_range = map.getControl().wanted_range;
u8 wanted_range = map.getControl().wanted_range;
// Save bandwidth by only updating position when // Save bandwidth by only updating position when
// player is not dead and something changed // player is not dead and something changed
if (m_activeobjects_received && myplayer->isDead()) if (m_activeobjects_received && player->isDead())
return; return;
if ( if (
myplayer->last_position == myplayer->getPosition() && player->last_position == player->getPosition() &&
myplayer->last_speed == myplayer->getSpeed() && player->last_speed == player->getSpeed() &&
myplayer->last_pitch == myplayer->getPitch() && player->last_pitch == player->getPitch() &&
myplayer->last_yaw == myplayer->getYaw() && player->last_yaw == player->getYaw() &&
myplayer->last_keyPressed == myplayer->keyPressed && player->last_keyPressed == player->keyPressed &&
myplayer->last_camera_fov == camera_fov && player->last_camera_fov == camera_fov &&
myplayer->last_wanted_range == wanted_range) player->last_wanted_range == wanted_range)
return; return;
myplayer->last_position = myplayer->getPosition(); player->last_position = player->getPosition();
myplayer->last_speed = myplayer->getSpeed(); player->last_speed = player->getSpeed();
myplayer->last_pitch = myplayer->getPitch(); player->last_pitch = player->getPitch();
myplayer->last_yaw = myplayer->getYaw(); player->last_yaw = player->getYaw();
myplayer->last_keyPressed = myplayer->keyPressed; player->last_keyPressed = player->keyPressed;
myplayer->last_camera_fov = camera_fov; player->last_camera_fov = camera_fov;
myplayer->last_wanted_range = wanted_range; player->last_wanted_range = wanted_range;
NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1); NetworkPacket pkt(TOSERVER_PLAYERPOS, 12 + 12 + 4 + 4 + 4 + 1 + 1);
writePlayerPos(myplayer, &map, &pkt); writePlayerPos(player, &map, &pkt);
Send(&pkt); Send(&pkt);
} }