Skip to content

Commit 7b04d40

Browse files
authored
Fix Seg Fault on Standalones with Safer Check for Secondaries (#4446)
Tests with standalone multiplayer builds revealed that the server would seg fault if a player tried to switch secondaries if the ship did not have secondaries. Tests with standalones showed this fixed the bug. Thanks to chief for the bug IDing and the fix code.
1 parent cc2b9fc commit 7b04d40

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

code/io/keycontrol.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,12 +1924,12 @@ int button_function_critical(int n, net_player *p = NULL)
19241924
if(at_self)
19251925
control_used(CYCLE_NUM_MISSLES);
19261926

1927-
if ( objp == Player_obj ) {
1928-
if ( Player_ship->weapons.num_secondary_banks <= 0 ) {
1927+
if ( Ships[objp->instance].weapons.num_secondary_banks <= 0 ) {
1928+
if ( objp == Player_obj ) {
19291929
HUD_sourced_printf(HUD_SOURCE_HIDDEN, "%s", XSTR( "This ship has no secondary weapons", 33));
19301930
gamesnd_play_iface(InterfaceSounds::GENERAL_FAIL);
1931-
break;
19321931
}
1932+
break;
19331933
}
19341934

19351935
polymodel *pm = model_get(Ship_info[Ships[objp->instance].ship_info_index].model_num);

0 commit comments

Comments
 (0)