From b8aaef704d3e29c43edc3312a3c5e25516d9c864 Mon Sep 17 00:00:00 2001 From: Beha Date: Tue, 30 Jul 2019 11:29:45 -0400 Subject: Move the clamping of hp/breath when their maximums change to read_object_properties(). (#8689) This prevents set_properties() calls that have nothing to do with hp_max or breath_max overriding the saved hp before another mod has the chance to set a player's intended hp_max (such as in on_joinplayer). --- src/script/lua_api/l_object.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 7ff1f58bc..ad8554834 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -757,20 +757,7 @@ int ObjectRef::l_set_properties(lua_State *L) if (!prop) return 0; - 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 (player) - getServer(L)->SendPlayerHPOrDie(player, reason); - } - - if (player && prop->breath_max < player->getBreath()) - player->setBreath(prop->breath_max); - + read_object_properties(L, 2, co, prop, getServer(L)->idef()); co->notifyObjectPropertiesModified(); return 0; } -- cgit v1.2.3