mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
Allowing `hb.change_bar' called with hudbar uninitialized
Calling `hb.change_bar' with hunger bar on damage disabled server will crash the server. To not overload other functions to check `enable_damage' over and over, simply make `hb.change_bar' able to be called with uninitialized identifiers. #4586
This commit is contained in:
parent
293eb6d021
commit
77bcf6cff3
1 changed files with 7 additions and 0 deletions
|
@ -330,9 +330,16 @@ function hb.change_hudbar(player, identifier, new_value, new_max_value, new_icon
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local hudtable = hb.get_hudtable(identifier)
|
local hudtable = hb.get_hudtable(identifier)
|
||||||
|
|
||||||
|
-- hb.change_hudbar may be called with a non-existing hudbar like hunger.
|
||||||
|
if hudtable == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if not hudtable.hudstate[name] then
|
if not hudtable.hudstate[name] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local value_changed, max_changed = false, false
|
local value_changed, max_changed = false, false
|
||||||
|
|
||||||
if new_value then
|
if new_value then
|
||||||
|
|
Loading…
Reference in a new issue