diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2021-08-21 20:04:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-21 20:04:04 +0200 |
commit | 0c1e9603db32b4281974fdd8b8e3b505148be47e (patch) | |
tree | 376b6f04d1c27388fbb453694827976a9a6d39a0 /src/script/lua_api | |
parent | a72d13064fcbddaf332c7d53e6f34b74d8781586 (diff) | |
download | minetest-0c1e9603db32b4281974fdd8b8e3b505148be47e.tar.gz minetest-0c1e9603db32b4281974fdd8b8e3b505148be47e.tar.bz2 minetest-0c1e9603db32b4281974fdd8b8e3b505148be47e.zip |
HUD: Reject and warn on invalid stat types (#11548)
This comes into play on older servers which do not know the "stat" type.
Warnings are only logged once to avoid spam within globalstep callbacks
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_localplayer.cpp | 5 | ||||
-rw-r--r-- | src/script/lua_api/l_object.cpp | 8 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/script/lua_api/l_localplayer.cpp b/src/script/lua_api/l_localplayer.cpp index 59d9ea5f8..77a692f08 100644 --- a/src/script/lua_api/l_localplayer.cpp +++ b/src/script/lua_api/l_localplayer.cpp @@ -369,10 +369,11 @@ int LuaLocalPlayer::l_hud_change(lua_State *L) if (!element) return 0; + HudElementStat stat; void *unused; - read_hud_change(L, element, &unused); + bool ok = read_hud_change(L, stat, element, &unused); - lua_pushboolean(L, true); + lua_pushboolean(L, ok); return 1; } diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index c404cb63c..c915fa9e1 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -1555,12 +1555,14 @@ int ObjectRef::l_hud_change(lua_State *L) if (elem == nullptr) return 0; + HudElementStat stat; void *value = nullptr; - HudElementStat stat = read_hud_change(L, elem, &value); + bool ok = read_hud_change(L, stat, elem, &value); - getServer(L)->hudChange(player, id, stat, value); + if (ok) + getServer(L)->hudChange(player, id, stat, value); - lua_pushboolean(L, true); + lua_pushboolean(L, ok); return 1; } |