Skip to content

Commit fb6a789

Browse files
kwolekrkahrl
authored andcommittedSep 26, 2013
Re-fix hud_change stat argument retrieval
Conflicts: src/script/lua_api/l_object.cpp
1 parent 9e6bdc3 commit fb6a789

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed
 

‎src/script/lua_api/l_object.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -877,16 +877,18 @@ int ObjectRef::l_hud_change(lua_State *L)
877877
if (player == NULL)
878878
return 0;
879879

880-
u32 id = -1;
881-
if (!lua_isnil(L, 2))
882-
id = lua_tonumber(L, 2);
883-
884-
HudElementStat stat = (HudElementStat)getenumfield(L, 3, "stat",
885-
es_HudElementStat, HUD_STAT_NUMBER);
886-
880+
u32 id = !lua_isnil(L, 2) ? lua_tonumber(L, 2) : -1;
887881
if (id >= player->hud.size())
888882
return 0;
889883

884+
HudElementStat stat = HUD_STAT_NUMBER;
885+
if (!lua_isnil(L, 3)) {
886+
int statint;
887+
std::string statstr = lua_tostring(L, 3);
888+
stat = string_to_enum(es_HudElementStat, statint, statstr) ?
889+
(HudElementStat)statint : HUD_STAT_NUMBER;
890+
}
891+
890892
void *value = NULL;
891893
HudElement *e = player->hud[id];
892894
if (!e)

0 commit comments

Comments
 (0)