#include "tool.h" // For ToolCapabilities
#include "gamedef.h"
#include "player.h"
+#include "server.h"
#include "scripting_game.h"
#include "genericobject.h"
#include "log.h"
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),
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;
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)
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,
<<" moved too fast; resetting position"
<<std::endl;
m_player->setPosition(m_last_good_position);
- m_moved = true;
cheated = true;
}
}
Do background stuff
*/
- /*
- Handle players
- */
- {
- JMutexAutoLock lock(m_env_mutex);
-
- std::list<u16> clientids = m_clients.getClientIDs();
-
- ScopeProfiler sp(g_profiler, "Server: handle players");
-
- for(std::list<u16>::iterator
- i = clientids.begin();
- i != clientids.end(); ++i)
- {
- PlayerSAO *playersao = getPlayerSAO(*i);
- if(playersao == NULL)
- continue;
-
-
- if(playersao->m_moved) {
- SendMovePlayer(*i);
- playersao->m_moved = false;
- }
- }
- }
-
/* Transform liquids */
m_liquid_transform_timer += dtime;
if(m_liquid_transform_timer >= m_liquid_transform_every)
bool repositioned = m_script->on_respawnplayer(playersao);
if(!repositioned){
v3f pos = findSpawnPos(m_env->getServerMap());
+ // setPos will send the new position to client
playersao->setPos(pos);
}
}
void SendPlayerHPOrDie(u16 peer_id, bool die) { die ? DiePlayer(peer_id) : SendPlayerHP(peer_id); }
void SendPlayerBreath(u16 peer_id);
-
- // Envlock and conlock should be locked when calling these
void SendInventory(u16 peer_id);
+ void SendMovePlayer(u16 peer_id);
// Bind address
Address m_bind_addr;
void SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed);
void SendPlayerHP(u16 peer_id);
- void SendMovePlayer(u16 peer_id);
void SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed);
void SendEyeOffset(u16 peer_id, v3f first, v3f third);
void SendPlayerPrivileges(u16 peer_id);