aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2019-05-21 21:37:47 +0200
committerSmallJoker <mk939@ymail.com>2019-05-21 21:37:47 +0200
commita2848c9cdeba8d077c61ef20108cb208fd073ef8 (patch)
treed7ca76385b710f7eb597717fe067625c1a46d3e6 /src
parent9d09c87f13a197672bd69ede8de987953af945ad (diff)
downloadminetest-a2848c9cdeba8d077c61ef20108cb208fd073ef8.tar.gz
minetest-a2848c9cdeba8d077c61ef20108cb208fd073ef8.tar.bz2
minetest-a2848c9cdeba8d077c61ef20108cb208fd073ef8.zip
Fix forgotten PlayerSAO cast in a90f2ef
Diffstat (limited to 'src')
-rw-r--r--src/script/lua_api/l_object.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index b7924ddb8..7ff1f58bc 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -759,16 +759,17 @@ int ObjectRef::l_set_properties(lua_State *L)
read_object_properties(L, 2, prop, getServer(L)->idef());
+ PlayerSAO *player = getplayersao(ref);
+
if (prop->hp_max < co->getHP()) {
PlayerHPChangeReason reason(PlayerHPChangeReason::SET_HP);
co->setHP(prop->hp_max, reason);
- if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
- getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co, reason);
+ if (player)
+ getServer(L)->SendPlayerHPOrDie(player, reason);
}
- if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER &&
- prop->breath_max < co->getBreath())
- co->setBreath(prop->breath_max);
+ if (player && prop->breath_max < player->getBreath())
+ player->setBreath(prop->breath_max);
co->notifyObjectPropertiesModified();
return 0;