mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +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
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue