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/cpp_api/s_entity.cpp | 6 +++--- src/script/cpp_api/s_entity.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/script/cpp_api') diff --git a/src/script/cpp_api/s_entity.cpp b/src/script/cpp_api/s_entity.cpp index 8af9f9bf6..26c7e8cd4 100644 --- a/src/script/cpp_api/s_entity.cpp +++ b/src/script/cpp_api/s_entity.cpp @@ -157,7 +157,7 @@ std::string ScriptApiEntity::luaentity_GetStaticdata(u16 id) } void ScriptApiEntity::luaentity_GetProperties(u16 id, - ObjectProperties *prop) + ServerActiveObject *self, ObjectProperties *prop) { SCRIPTAPI_PRECHECKHEADER @@ -170,11 +170,11 @@ void ScriptApiEntity::luaentity_GetProperties(u16 id, prop->hp_max = 10; // Deprecated: read object properties directly - read_object_properties(L, -1, prop, getServer()->idef()); + read_object_properties(L, -1, self, prop, getServer()->idef()); // Read initial_properties lua_getfield(L, -1, "initial_properties"); - read_object_properties(L, -1, prop, getServer()->idef()); + read_object_properties(L, -1, self, prop, getServer()->idef()); lua_pop(L, 1); } diff --git a/src/script/cpp_api/s_entity.h b/src/script/cpp_api/s_entity.h index 966c2745e..cc08c46e8 100644 --- a/src/script/cpp_api/s_entity.h +++ b/src/script/cpp_api/s_entity.h @@ -35,7 +35,7 @@ public: void luaentity_Remove(u16 id); std::string luaentity_GetStaticdata(u16 id); void luaentity_GetProperties(u16 id, - ObjectProperties *prop); + ServerActiveObject *self, ObjectProperties *prop); void luaentity_Step(u16 id, float dtime); bool luaentity_Punch(u16 id, ServerActiveObject *puncher, float time_from_last_punch, -- cgit v1.2.3