Skip to content

Commit 98de732

Browse files
committed
fix crash in hud_get_custom_gauge()
The `Player_ship` variable can sometimes be NULL, especially in FRED, so revise the conditional to check for this.
1 parent 45d9926 commit 98de732

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
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) {

0 commit comments

Comments
 (0)