Fix forgotten PlayerSAO cast in a90f2ef
authorSmallJoker <mk939@ymail.com>
Tue, 21 May 2019 19:37:47 +0000 (21:37 +0200)
committerSmallJoker <mk939@ymail.com>
Tue, 21 May 2019 19:37:47 +0000 (21:37 +0200)
src/script/lua_api/l_object.cpp

index b7924ddb85db421905b1b51fb3ae20146bdc9dc3..7ff1f58bc21f569fb3ca0051bf57b2e4909e1a06 100644 (file)
@@ -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;