mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Remove buggy premature sendPlayerPos optimization
This commit is contained in:
parent
88c845166c
commit
26c966048a
2 changed files with 3 additions and 37 deletions
|
@ -1371,49 +1371,21 @@ void Client::sendPlayerPos()
|
||||||
if (!player)
|
if (!player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Save bandwidth by only updating position when
|
// Don't send anything when player is dead:
|
||||||
// player is not dead and something changed
|
// The server would ignore it anyways
|
||||||
|
|
||||||
if (m_activeobjects_received && player->isDead())
|
if (m_activeobjects_received && player->isDead())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ClientMap &map = m_env.getClientMap();
|
|
||||||
u8 camera_fov = std::fmin(255.0f, map.getCameraFov() * 80.0f);
|
|
||||||
u8 wanted_range = std::fmin(255.0f,
|
|
||||||
std::ceil(map.getWantedRange() * (1.0f / MAP_BLOCKSIZE)));
|
|
||||||
|
|
||||||
u32 keyPressed = player->control.getKeysPressed();
|
|
||||||
bool camera_inverted = m_camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT;
|
bool camera_inverted = m_camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT;
|
||||||
f32 movement_speed = player->control.movement_speed;
|
|
||||||
f32 movement_dir = player->control.movement_direction;
|
|
||||||
|
|
||||||
if (
|
|
||||||
player->last_position == player->getPosition() &&
|
|
||||||
player->last_speed == player->getSpeed() &&
|
|
||||||
player->last_pitch == player->getPitch() &&
|
|
||||||
player->last_yaw == player->getYaw() &&
|
|
||||||
player->last_keyPressed == keyPressed &&
|
|
||||||
player->last_camera_fov == camera_fov &&
|
|
||||||
player->last_camera_inverted == camera_inverted &&
|
|
||||||
player->last_wanted_range == wanted_range &&
|
|
||||||
player->last_movement_speed == movement_speed &&
|
|
||||||
player->last_movement_dir == movement_dir)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player->last_position = player->getPosition();
|
player->last_position = player->getPosition();
|
||||||
player->last_speed = player->getSpeed();
|
player->last_speed = player->getSpeed();
|
||||||
player->last_pitch = player->getPitch();
|
player->last_pitch = player->getPitch();
|
||||||
player->last_yaw = player->getYaw();
|
player->last_yaw = player->getYaw();
|
||||||
player->last_keyPressed = keyPressed;
|
|
||||||
player->last_camera_fov = camera_fov;
|
|
||||||
player->last_camera_inverted = camera_inverted;
|
|
||||||
player->last_wanted_range = wanted_range;
|
|
||||||
player->last_movement_speed = movement_speed;
|
|
||||||
player->last_movement_dir = movement_dir;
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
writePlayerPos(player, &map, &pkt, camera_inverted);
|
writePlayerPos(player, &m_env.getClientMap(), &pkt, camera_inverted);
|
||||||
|
|
||||||
Send(&pkt);
|
Send(&pkt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,12 +83,6 @@ public:
|
||||||
v3f last_speed;
|
v3f last_speed;
|
||||||
float last_pitch = 0.0f;
|
float last_pitch = 0.0f;
|
||||||
float last_yaw = 0.0f;
|
float last_yaw = 0.0f;
|
||||||
u32 last_keyPressed = 0;
|
|
||||||
u8 last_camera_fov = 0;
|
|
||||||
u8 last_wanted_range = 0;
|
|
||||||
bool last_camera_inverted = false;
|
|
||||||
f32 last_movement_speed = 0.0f;
|
|
||||||
f32 last_movement_dir = 0.0f;
|
|
||||||
|
|
||||||
float camera_impact = 0.0f;
|
float camera_impact = 0.0f;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue