Fix overloading problems mentioned by clang

This commit is contained in:
Loic Blot 2016-10-30 16:12:09 +01:00 committed by Ner'zhul
parent 9d25242c5c
commit 595932a860
6 changed files with 40 additions and 35 deletions

@ -507,7 +507,7 @@ void LuaEntitySAO::rightClick(ServerActiveObject *clicker)
m_env->getScriptIface()->luaentity_Rightclick(m_id, clicker); m_env->getScriptIface()->luaentity_Rightclick(m_id, clicker);
} }
void LuaEntitySAO::setPos(v3f pos) void LuaEntitySAO::setPos(const v3f &pos)
{ {
if(isAttached()) if(isAttached())
return; return;
@ -1078,27 +1078,32 @@ void PlayerSAO::moveTo(v3f pos, bool continuous)
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id); ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
} }
void PlayerSAO::setYaw(const float yaw, bool send_data) void PlayerSAO::setYaw(const float yaw)
{ {
if (m_player && yaw != m_yaw) if (m_player && yaw != m_yaw)
m_player->setDirty(true); m_player->setDirty(true);
UnitSAO::setYaw(yaw); UnitSAO::setYaw(yaw);
// Datas should not be sent at player initialization
if (send_data)
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
} }
void PlayerSAO::setPitch(const float pitch, bool send_data) void PlayerSAO::setYawAndSend(const float yaw)
{
setYaw(yaw);
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
}
void PlayerSAO::setPitch(const float pitch)
{ {
if (m_player && pitch != m_pitch) if (m_player && pitch != m_pitch)
m_player->setDirty(true); m_player->setDirty(true);
m_pitch = pitch; m_pitch = pitch;
}
if (send_data) void PlayerSAO::setPitchAndSend(const float pitch)
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id); {
setPitch(pitch);
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
} }
int PlayerSAO::punch(v3f dir, int PlayerSAO::punch(v3f dir,
@ -1173,13 +1178,8 @@ s16 PlayerSAO::readDamage()
return damage; return damage;
} }
void PlayerSAO::setHP(s16 hp, bool direct) void PlayerSAO::setHP(s16 hp)
{ {
if (direct) {
m_hp = hp;
return;
}
s16 oldhp = m_hp; s16 oldhp = m_hp;
s16 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp); s16 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp);

@ -73,7 +73,7 @@ public:
ServerActiveObject *puncher=NULL, ServerActiveObject *puncher=NULL,
float time_from_last_punch=1000000); float time_from_last_punch=1000000);
void rightClick(ServerActiveObject *clicker); void rightClick(ServerActiveObject *clicker);
void setPos(v3f pos); void setPos(const v3f &pos);
void moveTo(v3f pos, bool continuous); void moveTo(v3f pos, bool continuous);
float getMinimumSavedMovement(); float getMinimumSavedMovement();
std::string getDescription(); std::string getDescription();
@ -204,8 +204,12 @@ public:
void setBasePosition(const v3f &position); void setBasePosition(const v3f &position);
void setPos(const v3f &pos); void setPos(const v3f &pos);
void moveTo(v3f pos, bool continuous); void moveTo(v3f pos, bool continuous);
void setYaw(const float yaw, bool send_data = true); void setYaw(const float yaw);
void setPitch(const float pitch, bool send_data = true); // Data should not be sent at player initialization
void setYawAndSend(const float yaw);
void setPitch(const float pitch);
// Data should not be sent at player initialization
void setPitchAndSend(const float pitch);
f32 getPitch() const { return m_pitch; } f32 getPitch() const { return m_pitch; }
f32 getRadPitch() const { return m_pitch * core::DEGTORAD; } f32 getRadPitch() const { return m_pitch * core::DEGTORAD; }
// Deprecated // Deprecated
@ -220,7 +224,8 @@ public:
ServerActiveObject *puncher, ServerActiveObject *puncher,
float time_from_last_punch); float time_from_last_punch);
void rightClick(ServerActiveObject *clicker); void rightClick(ServerActiveObject *clicker);
void setHP(s16 hp, bool direct = false); void setHP(s16 hp);
void setHPRaw(s16 hp) { m_hp = hp; }
s16 readDamage(); s16 readDamage();
u16 getBreath() const { return m_breath; } u16 getBreath() const { return m_breath; }
void setBreath(const u16 breath); void setBreath(const u16 breath);

@ -827,8 +827,8 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
playersao->setBasePosition(position); playersao->setBasePosition(position);
player->setSpeed(speed); player->setSpeed(speed);
playersao->setPitch(pitch, false); playersao->setPitch(pitch);
playersao->setYaw(yaw, false); playersao->setYaw(yaw);
player->keyPressed = keyPressed; player->keyPressed = keyPressed;
player->control.up = (keyPressed & 1); player->control.up = (keyPressed & 1);
player->control.down = (keyPressed & 2); player->control.down = (keyPressed & 2);

@ -131,9 +131,9 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
if (sao) { if (sao) {
try { try {
sao->setHP(args.getS32("hp"), true); sao->setHPRaw(args.getS32("hp"));
} catch(SettingNotFoundException &e) { } catch(SettingNotFoundException &e) {
sao->setHP(PLAYER_MAX_HP, true); sao->setHPRaw(PLAYER_MAX_HP);
} }
try { try {
@ -141,10 +141,10 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
} catch (SettingNotFoundException &e) {} } catch (SettingNotFoundException &e) {}
try { try {
sao->setPitch(args.getFloat("pitch"), false); sao->setPitch(args.getFloat("pitch"));
} catch (SettingNotFoundException &e) {} } catch (SettingNotFoundException &e) {}
try { try {
sao->setYaw(args.getFloat("yaw"), false); sao->setYaw(args.getFloat("yaw"));
} catch (SettingNotFoundException &e) {} } catch (SettingNotFoundException &e) {}
try { try {

@ -1090,7 +1090,7 @@ int ObjectRef::l_set_look_vertical(lua_State *L)
if (co == NULL) return 0; if (co == NULL) return 0;
float pitch = luaL_checknumber(L, 2) * core::RADTODEG; float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it // Do it
co->setPitch(pitch); co->setPitchAndSend(pitch);
return 1; return 1;
} }
@ -1103,7 +1103,7 @@ int ObjectRef::l_set_look_horizontal(lua_State *L)
if (co == NULL) return 0; if (co == NULL) return 0;
float yaw = luaL_checknumber(L, 2) * core::RADTODEG; float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it // Do it
co->setYaw(yaw); co->setYawAndSend(yaw);
return 1; return 1;
} }
@ -1121,7 +1121,7 @@ int ObjectRef::l_set_look_pitch(lua_State *L)
if (co == NULL) return 0; if (co == NULL) return 0;
float pitch = luaL_checknumber(L, 2) * core::RADTODEG; float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it // Do it
co->setPitch(pitch); co->setPitchAndSend(pitch);
return 1; return 1;
} }
@ -1139,7 +1139,7 @@ int ObjectRef::l_set_look_yaw(lua_State *L)
if (co == NULL) return 0; if (co == NULL) return 0;
float yaw = luaL_checknumber(L, 2) * core::RADTODEG; float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
// Do it // Do it
co->setYaw(yaw); co->setYawAndSend(yaw);
return 1; return 1;
} }

@ -50,9 +50,9 @@ void TestPlayer::testSave(IGameDef *gamedef)
sao.initialize(&rplayer, std::set<std::string>()); sao.initialize(&rplayer, std::set<std::string>());
rplayer.setPlayerSAO(&sao); rplayer.setPlayerSAO(&sao);
sao.setBreath(10); sao.setBreath(10);
sao.setHP(8, true); sao.setHPRaw(8);
sao.setYaw(0.1f, false); sao.setYaw(0.1f);
sao.setPitch(0.6f, false); sao.setPitch(0.6f);
sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f)); sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
rplayer.save(".", gamedef); rplayer.save(".", gamedef);
UASSERT(fs::PathExists("testplayer_save")); UASSERT(fs::PathExists("testplayer_save"));
@ -65,9 +65,9 @@ void TestPlayer::testLoad(IGameDef *gamedef)
sao.initialize(&rplayer, std::set<std::string>()); sao.initialize(&rplayer, std::set<std::string>());
rplayer.setPlayerSAO(&sao); rplayer.setPlayerSAO(&sao);
sao.setBreath(10); sao.setBreath(10);
sao.setHP(8, true); sao.setHPRaw(8);
sao.setYaw(0.1f, false); sao.setYaw(0.1f);
sao.setPitch(0.6f, false); sao.setPitch(0.6f);
sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f)); sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
rplayer.save(".", gamedef); rplayer.save(".", gamedef);
UASSERT(fs::PathExists("testplayer_load")); UASSERT(fs::PathExists("testplayer_load"));