mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00:00
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).
This commit is contained in:
parent
2dd645134e
commit
b8aaef704d
6 changed files with 26 additions and 22 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue