Skip to content

Commit f08d82b

Browse files
authored
Merge pull request #6348 from Goober5000/hud_gauge_bugfix
two HUD fixes
2 parents b6879da + dfe34ec commit f08d82b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

code/hud/hud.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3908,7 +3908,9 @@ void hud_page_in()
39083908

39093909
HudGauge* hud_get_custom_gauge(const char* name, bool check_all_gauges)
39103910
{
3911-
auto player_sip = Player_ship->ship_info_index < 0 ? nullptr : &Ship_info[Player_ship->ship_info_index];
3911+
ship_info *player_sip = nullptr;
3912+
if (Player_ship && Player_ship->ship_info_index >= 0)
3913+
player_sip = &Ship_info[Player_ship->ship_info_index];
39123914

39133915
// go through all gauges for all ships and defaults
39143916
if (check_all_gauges) {

code/parse/sexp/LuaSEXP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ luacpp::LuaValue LuaSEXP::sexpToLua(int node, int argnum, int parent_node) const
302302
}
303303
case OPF_ANY_HUD_GAUGE: {
304304
auto name = CTEXT(node);
305-
return LuaValue::createValue(_action.getLuaState(), l_HudGauge.Set(hud_get_gauge(name)));
305+
return LuaValue::createValue(_action.getLuaState(), l_HudGauge.Set(hud_get_gauge(name, true)));
306306
}
307307
case OPF_EVENT_NAME: {
308308
auto name = CTEXT(node);

code/scripting/api/objs/hudgauge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ADE_FUNC(isCustom, l_HudGauge, nullptr, "Custom HUD Gauge status", "boolean", "R
2121
return ade_set_args(L, "b", gauge->isCustom());
2222
}
2323

24-
ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Custom HUD Gauge name, or blank if this is a default gauge, or nil if handle is invalid")
24+
ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Custom HUD Gauge name, or nil if this is a default gauge or the handle is invalid")
2525
{
2626
HudGauge* gauge;
2727

@@ -37,7 +37,7 @@ ADE_VIRTVAR(Name, l_HudGauge, "string", "Custom HUD Gauge name", "string", "Cust
3737
return ade_set_args(L, "s", gauge->getCustomGaugeName());
3838
}
3939

40-
ADE_VIRTVAR(Text, l_HudGauge, "string", "Custom HUD Gauge text", "string", "Custom HUD Gauge text, or blank if this is a default gauge, or nil if handle is invalid")
40+
ADE_VIRTVAR(Text, l_HudGauge, "string", "Custom HUD Gauge text", "string", "Custom HUD Gauge text, or nil if this is a default gauge or the handle is invalid")
4141
{
4242
HudGauge* gauge;
4343
const char* text = nullptr;

0 commit comments

Comments
 (0)