Skip to content

Commit 595932a

Browse files
committedOct 30, 2016
Fix overloading problems mentioned by clang
1 parent 9d25242 commit 595932a

File tree

6 files changed

+39
-34
lines changed

6 files changed

+39
-34
lines changed
 

‎src/content_sao.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ void LuaEntitySAO::rightClick(ServerActiveObject *clicker)
507507
m_env->getScriptIface()->luaentity_Rightclick(m_id, clicker);
508508
}
509509

510-
void LuaEntitySAO::setPos(v3f pos)
510+
void LuaEntitySAO::setPos(const v3f &pos)
511511
{
512512
if(isAttached())
513513
return;
@@ -1078,27 +1078,32 @@ void PlayerSAO::moveTo(v3f pos, bool continuous)
10781078
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
10791079
}
10801080

1081-
void PlayerSAO::setYaw(const float yaw, bool send_data)
1081+
void PlayerSAO::setYaw(const float yaw)
10821082
{
10831083
if (m_player && yaw != m_yaw)
10841084
m_player->setDirty(true);
10851085

10861086
UnitSAO::setYaw(yaw);
1087+
}
10871088

1088-
// Datas should not be sent at player initialization
1089-
if (send_data)
1090-
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
1089+
void PlayerSAO::setYawAndSend(const float yaw)
1090+
{
1091+
setYaw(yaw);
1092+
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
10911093
}
10921094

1093-
void PlayerSAO::setPitch(const float pitch, bool send_data)
1095+
void PlayerSAO::setPitch(const float pitch)
10941096
{
10951097
if (m_player && pitch != m_pitch)
10961098
m_player->setDirty(true);
10971099

10981100
m_pitch = pitch;
1101+
}
10991102

1100-
if (send_data)
1101-
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
1103+
void PlayerSAO::setPitchAndSend(const float pitch)
1104+
{
1105+
setPitch(pitch);
1106+
((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
11021107
}
11031108

11041109
int PlayerSAO::punch(v3f dir,
@@ -1173,13 +1178,8 @@ s16 PlayerSAO::readDamage()
11731178
return damage;
11741179
}
11751180

1176-
void PlayerSAO::setHP(s16 hp, bool direct)
1181+
void PlayerSAO::setHP(s16 hp)
11771182
{
1178-
if (direct) {
1179-
m_hp = hp;
1180-
return;
1181-
}
1182-
11831183
s16 oldhp = m_hp;
11841184

11851185
s16 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp);

‎src/content_sao.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class LuaEntitySAO : public UnitSAO
7373
ServerActiveObject *puncher=NULL,
7474
float time_from_last_punch=1000000);
7575
void rightClick(ServerActiveObject *clicker);
76-
void setPos(v3f pos);
76+
void setPos(const v3f &pos);
7777
void moveTo(v3f pos, bool continuous);
7878
float getMinimumSavedMovement();
7979
std::string getDescription();
@@ -204,8 +204,12 @@ class PlayerSAO : public UnitSAO
204204
void setBasePosition(const v3f &position);
205205
void setPos(const v3f &pos);
206206
void moveTo(v3f pos, bool continuous);
207-
void setYaw(const float yaw, bool send_data = true);
208-
void setPitch(const float pitch, bool send_data = true);
207+
void setYaw(const float yaw);
208+
// Data should not be sent at player initialization
209+
void setYawAndSend(const float yaw);
210+
void setPitch(const float pitch);
211+
// Data should not be sent at player initialization
212+
void setPitchAndSend(const float pitch);
209213
f32 getPitch() const { return m_pitch; }
210214
f32 getRadPitch() const { return m_pitch * core::DEGTORAD; }
211215
// Deprecated
@@ -220,7 +224,8 @@ class PlayerSAO : public UnitSAO
220224
ServerActiveObject *puncher,
221225
float time_from_last_punch);
222226
void rightClick(ServerActiveObject *clicker);
223-
void setHP(s16 hp, bool direct = false);
227+
void setHP(s16 hp);
228+
void setHPRaw(s16 hp) { m_hp = hp; }
224229
s16 readDamage();
225230
u16 getBreath() const { return m_breath; }
226231
void setBreath(const u16 breath);

‎src/network/serverpackethandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,8 @@ void Server::handleCommand_PlayerPos(NetworkPacket* pkt)
827827

828828
playersao->setBasePosition(position);
829829
player->setSpeed(speed);
830-
playersao->setPitch(pitch, false);
831-
playersao->setYaw(yaw, false);
830+
playersao->setPitch(pitch);
831+
playersao->setYaw(yaw);
832832
player->keyPressed = keyPressed;
833833
player->control.up = (keyPressed & 1);
834834
player->control.down = (keyPressed & 2);

‎src/remoteplayer.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,20 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
131131

132132
if (sao) {
133133
try {
134-
sao->setHP(args.getS32("hp"), true);
134+
sao->setHPRaw(args.getS32("hp"));
135135
} catch(SettingNotFoundException &e) {
136-
sao->setHP(PLAYER_MAX_HP, true);
136+
sao->setHPRaw(PLAYER_MAX_HP);
137137
}
138138

139139
try {
140140
sao->setBasePosition(args.getV3F("position"));
141141
} catch (SettingNotFoundException &e) {}
142142

143143
try {
144-
sao->setPitch(args.getFloat("pitch"), false);
144+
sao->setPitch(args.getFloat("pitch"));
145145
} catch (SettingNotFoundException &e) {}
146146
try {
147-
sao->setYaw(args.getFloat("yaw"), false);
147+
sao->setYaw(args.getFloat("yaw"));
148148
} catch (SettingNotFoundException &e) {}
149149

150150
try {

‎src/script/lua_api/l_object.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ int ObjectRef::l_set_look_vertical(lua_State *L)
10901090
if (co == NULL) return 0;
10911091
float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
10921092
// Do it
1093-
co->setPitch(pitch);
1093+
co->setPitchAndSend(pitch);
10941094
return 1;
10951095
}
10961096

@@ -1103,7 +1103,7 @@ int ObjectRef::l_set_look_horizontal(lua_State *L)
11031103
if (co == NULL) return 0;
11041104
float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
11051105
// Do it
1106-
co->setYaw(yaw);
1106+
co->setYawAndSend(yaw);
11071107
return 1;
11081108
}
11091109

@@ -1121,7 +1121,7 @@ int ObjectRef::l_set_look_pitch(lua_State *L)
11211121
if (co == NULL) return 0;
11221122
float pitch = luaL_checknumber(L, 2) * core::RADTODEG;
11231123
// Do it
1124-
co->setPitch(pitch);
1124+
co->setPitchAndSend(pitch);
11251125
return 1;
11261126
}
11271127

@@ -1139,7 +1139,7 @@ int ObjectRef::l_set_look_yaw(lua_State *L)
11391139
if (co == NULL) return 0;
11401140
float yaw = luaL_checknumber(L, 2) * core::RADTODEG;
11411141
// Do it
1142-
co->setYaw(yaw);
1142+
co->setYawAndSend(yaw);
11431143
return 1;
11441144
}
11451145

‎src/unittest/test_player.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ void TestPlayer::testSave(IGameDef *gamedef)
5050
sao.initialize(&rplayer, std::set<std::string>());
5151
rplayer.setPlayerSAO(&sao);
5252
sao.setBreath(10);
53-
sao.setHP(8, true);
54-
sao.setYaw(0.1f, false);
55-
sao.setPitch(0.6f, false);
53+
sao.setHPRaw(8);
54+
sao.setYaw(0.1f);
55+
sao.setPitch(0.6f);
5656
sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
5757
rplayer.save(".", gamedef);
5858
UASSERT(fs::PathExists("testplayer_save"));
@@ -65,9 +65,9 @@ void TestPlayer::testLoad(IGameDef *gamedef)
6565
sao.initialize(&rplayer, std::set<std::string>());
6666
rplayer.setPlayerSAO(&sao);
6767
sao.setBreath(10);
68-
sao.setHP(8, true);
69-
sao.setYaw(0.1f, false);
70-
sao.setPitch(0.6f, false);
68+
sao.setHPRaw(8);
69+
sao.setYaw(0.1f);
70+
sao.setPitch(0.6f);
7171
sao.setBasePosition(v3f(450.2f, -15.7f, 68.1f));
7272
rplayer.save(".", gamedef);
7373
UASSERT(fs::PathExists("testplayer_load"));

0 commit comments

Comments
 (0)
Please sign in to comment.