mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user