Fix overloading problems mentioned by clang
authorLoic Blot <loic.blot@unix-experience.fr>
Sun, 30 Oct 2016 15:12:09 +0000 (16:12 +0100)
committerNer'zhul <nerzhul@users.noreply.github.com>
Sun, 30 Oct 2016 15:30:55 +0000 (16:30 +0100)
src/content_sao.cpp
src/content_sao.h
src/network/serverpackethandler.cpp
src/remoteplayer.cpp
src/script/lua_api/l_object.cpp
src/unittest/test_player.cpp

index 23a064085255a008116266979ef9be89a7c7fa51..5fb8f936e58acfe04325db3fb58ba5a5eb69e0db 100644 (file)
@@ -507,7 +507,7 @@ void LuaEntitySAO::rightClick(ServerActiveObject *clicker)
        m_env->getScriptIface()->luaentity_Rightclick(m_id, clicker);
 }
 
-void LuaEntitySAO::setPos(v3f pos)
+void LuaEntitySAO::setPos(const v3f &pos)
 {
        if(isAttached())
                return;
@@ -1078,27 +1078,32 @@ void PlayerSAO::moveTo(v3f pos, bool continuous)
        ((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)
                m_player->setDirty(true);
 
        UnitSAO::setYaw(yaw);
+}
 
-       // Datas should not be sent at player initialization
-       if (send_data)
-               ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
+void PlayerSAO::setYawAndSend(const float yaw)
+{
+       setYaw(yaw);
+       ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
 }
 
-void PlayerSAO::setPitch(const float pitch, bool send_data)
+void PlayerSAO::setPitch(const float pitch)
 {
        if (m_player && pitch != m_pitch)
                m_player->setDirty(true);
 
        m_pitch = pitch;
+}
 
-       if (send_data)
-               ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
+void PlayerSAO::setPitchAndSend(const float pitch)
+{
+       setPitch(pitch);
+       ((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
 }
 
 int PlayerSAO::punch(v3f dir,
@@ -1173,13 +1178,8 @@ s16 PlayerSAO::readDamage()
        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 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp);
index 4ea6277ffd17f60a915950c7ee17c3e0b904b25a..5d837a4663f6b661581d8a2919e98ed79e8b4756 100644 (file)
@@ -73,7 +73,7 @@ public:
                        ServerActiveObject *puncher=NULL,
                        float time_from_last_punch=1000000);
        void rightClick(ServerActiveObject *clicker);
-       void setPos(v3f pos);
+       void setPos(const v3f &pos);
        void moveTo(v3f pos, bool continuous);
        float getMinimumSavedMovement();
        std::string getDescription();
@@ -204,8 +204,12 @@ public:
        void setBasePosition(const v3f &position);
        void setPos(const v3f &pos);
        void moveTo(v3f pos, bool continuous);
-       void setYaw(const float yaw, bool send_data = true);
-       void setPitch(const float pitch, bool send_data = true);
+       void setYaw(const float yaw);
+       // 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 getRadPitch() const { return m_pitch * core::DEGTORAD; }
        // Deprecated
@@ -220,7 +224,8 @@ public:
                ServerActiveObject *puncher,
                float time_from_last_punch);
        void rightClick(ServerActiveObject *clicker);
-       void setHP(s16 hp, bool direct = false);
+       void setHP(s16 hp);
+       void setHPRaw(s16 hp) { m_hp = hp; }
        s16 readDamage();
        u16 getBreath() const { return m_breath; }
        void setBreath(const u16 breath);
index 5e70b4c6c81791a5923192df596d1541b4faba0d..80eec140db94fd04ead4acec60d4ebe1857857c8 100644 (file)
@@ -827,8 +827,8 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
 
        playersao->setBasePosition(position);
        player->setSpeed(speed);
-       playersao->setPitch(pitch, false);
-       playersao->setYaw(yaw, false);
+       playersao->setPitch(pitch);
+       playersao->setYaw(yaw);
        player->keyPressed = keyPressed;
        player->control.up = (keyPressed & 1);
        player->control.down = (keyPressed & 2);
index 60534692802b178ec7cc52c0d9d50a36e0917ea5..f4a79dd081515f136cffe747ddaa892d2ac37235 100644 (file)
@@ -131,9 +131,9 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
 
        if (sao) {
                try {
-                       sao->setHP(args.getS32("hp"), true);
+                       sao->setHPRaw(args.getS32("hp"));
                } catch(SettingNotFoundException &e) {
-                       sao->setHP(PLAYER_MAX_HP, true);
+                       sao->setHPRaw(PLAYER_MAX_HP);
                }
 
                try {
@@ -141,10 +141,10 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
                } catch (SettingNotFoundException &e) {}
 
                try {
-                       sao->setPitch(args.getFloat("pitch"), false);
+                       sao->setPitch(args.getFloat("pitch"));
                } catch (SettingNotFoundException &e) {}
                try {
-                       sao->setYaw(args.getFloat("yaw"), false);
+                       sao->setYaw(args.getFloat("yaw"));
                } catch (SettingNotFoundException &e) {}
 
                try {
index cf124f17cb66de68355fe2377e3d35b830c792ca..42395717f38cfdff3870ba68729e35a84810eec7 100644 (file)
@@ -1090,7 +1090,7 @@ int ObjectRef::l_set_look_vertical(lua_State *L)
        if (co == NULL) return 0;
        float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
        // Do it
-       co->setPitch(pitch);
+       co->setPitchAndSend(pitch);
        return 1;
 }
 
@@ -1103,7 +1103,7 @@ int ObjectRef::l_set_look_horizontal(lua_State *L)
        if (co == NULL) return 0;
        float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
        // Do it
-       co->setYaw(yaw);
+       co->setYawAndSend(yaw);
        return 1;
 }
 
@@ -1121,7 +1121,7 @@ int ObjectRef::l_set_look_pitch(lua_State *L)
        if (co == NULL) return 0;
        float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
        // Do it
-       co->setPitch(pitch);
+       co->setPitchAndSend(pitch);
        return 1;
 }
 
@@ -1139,7 +1139,7 @@ int ObjectRef::l_set_look_yaw(lua_State *L)
        if (co == NULL) return 0;
        float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
        // Do it
-       co->setYaw(yaw);
+       co->setYawAndSend(yaw);
        return 1;
 }
 
index fba4224758021e1ae92c3a97ec16d3d47321f324..85fbc8b2d80f0ab053cc22c03498f21b8626cbfc 100644 (file)
@@ -50,9 +50,9 @@ void TestPlayer::testSave(IGameDef *gamedef)
        sao.initialize(&rplayer, std::set<std::string>());
        rplayer.setPlayerSAO(&sao);
        sao.setBreath(10);
-       sao.setHP(8, true);
-       sao.setYaw(0.1f, false);
-       sao.setPitch(0.6f, false);
+       sao.setHPRaw(8);
+       sao.setYaw(0.1f);
+       sao.setPitch(0.6f);
        sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
        rplayer.save(".", gamedef);
        UASSERT(fs::PathExists("testplayer_save"));
@@ -65,9 +65,9 @@ void TestPlayer::testLoad(IGameDef *gamedef)
        sao.initialize(&rplayer, std::set<std::string>());
        rplayer.setPlayerSAO(&sao);
        sao.setBreath(10);
-       sao.setHP(8, true);
-       sao.setYaw(0.1f, false);
-       sao.setPitch(0.6f, false);
+       sao.setHPRaw(8);
+       sao.setYaw(0.1f);
+       sao.setPitch(0.6f);
        sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
        rplayer.save(".", gamedef);
        UASSERT(fs::PathExists("testplayer_load"));