1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-12 16:58:39 +00:00

Send Position packet on event, don't check it at each AsyncRunStep.

* This permit to cleanup the player checking loop
This commit is contained in:
Loic Blot 2015-03-04 12:19:26 +01:00
parent 7f8f9785d7
commit 40bf1d7b5f
5 changed files with 10 additions and 45 deletions

View file

@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "tool.h" // For ToolCapabilities
#include "gamedef.h"
#include "player.h"
#include "server.h"
#include "scripting_game.h"
#include "genericobject.h"
#include "log.h"
@ -716,7 +717,6 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
m_attachment_parent_id(0),
m_attachment_sent(false),
// public
m_moved(false),
m_physics_override_speed(1),
m_physics_override_jump(1),
m_physics_override_gravity(1),
@ -867,7 +867,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
m_attachment_position = v3f(0,0,0);
m_attachment_rotation = v3f(0,0,0);
m_player->setPosition(m_last_good_position);
m_moved = true;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
//dstream<<"PlayerSAO::step: dtime: "<<dtime<<std::endl;
@ -982,8 +982,7 @@ void PlayerSAO::setPos(v3f pos)
m_player->setPosition(pos);
// Movement caused by this command is always valid
m_last_good_position = pos;
// Force position change on client
m_moved = true;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
void PlayerSAO::moveTo(v3f pos, bool continuous)
@ -993,22 +992,19 @@ void PlayerSAO::moveTo(v3f pos, bool continuous)
m_player->setPosition(pos);
// Movement caused by this command is always valid
m_last_good_position = pos;
// Force position change on client
m_moved = true;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
void PlayerSAO::setYaw(float yaw)
{
m_player->setYaw(yaw);
// Force change on client
m_moved = true;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
void PlayerSAO::setPitch(float pitch)
{
m_player->setPitch(pitch);
// Force change on client
m_moved = true;
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
int PlayerSAO::punch(v3f dir,
@ -1241,7 +1237,6 @@ bool PlayerSAO::checkMovementCheat()
<<" moved too fast; resetting position"
<<std::endl;
m_player->setPosition(m_last_good_position);
m_moved = true;
cheated = true;
}
}