diff --git a/common/main/fwd-weapon.h b/common/main/fwd-weapon.h index 458e5ab19..ab63c5a44 100644 --- a/common/main/fwd-weapon.h +++ b/common/main/fwd-weapon.h @@ -169,9 +169,10 @@ void do_secondary_weapon_select(uint_fast32_t weapon_num); #endif void auto_select_primary_weapon(); -void auto_select_secondary_weapon(); #ifdef dsx namespace dsx { +struct player_info; +void auto_select_secondary_weapon(player_info &); void select_primary_weapon(const char *weapon_name, uint_fast32_t weapon_num, int wait_for_rearm); void select_secondary_weapon(const char *weapon_name, uint_fast32_t weapon_num, int wait_for_rearm); diff --git a/d2x-rebirth/main/escort.cpp b/d2x-rebirth/main/escort.cpp index 3ffc7b21a..58b6557a3 100644 --- a/d2x-rebirth/main/escort.cpp +++ b/d2x-rebirth/main/escort.cpp @@ -1411,7 +1411,8 @@ static int maybe_steal_flag_item(const vobjptr_t playerobjp, const PLAYER_FLAG f // ---------------------------------------------------------------------------- static int maybe_steal_secondary_weapon(const vobjptr_t playerobjp, int weapon_num) { - if (auto &secondary_ammo = playerobjp->ctype.player_info.secondary_ammo[weapon_num]) + auto &player_info = playerobjp->ctype.player_info; + if (auto &secondary_ammo = player_info.secondary_ammo[weapon_num]) if (d_rand() < THIEF_PROBABILITY) { if (weapon_index_is_player_bomb(weapon_num)) { @@ -1423,7 +1424,7 @@ static int maybe_steal_secondary_weapon(const vobjptr_t playerobjp, int weapon_n Stolen_items[Stolen_item_index] = Secondary_weapon_to_powerup[weapon_num]; thief_message("%s stolen!", SECONDARY_WEAPON_NAMES(weapon_num)); // Danger! Danger! Use of literal! Danger! if (-- secondary_ammo == 0) - auto_select_secondary_weapon(); + auto_select_secondary_weapon(player_info); // -- compress_stolen_items(); digi_play_sample_once(SOUND_WEAPON_STOLEN, F1_0); diff --git a/similar/main/laser.cpp b/similar/main/laser.cpp index eb40557b3..9c4c2fa29 100644 --- a/similar/main/laser.cpp +++ b/similar/main/laser.cpp @@ -2353,7 +2353,7 @@ void do_missile_firing(int drop_bomb) // don't autoselect if dropping prox and prox not current weapon if (!drop_bomb || player_info.Secondary_weapon == bomb) - auto_select_secondary_weapon(); //select next missile, if this one out of ammo + auto_select_secondary_weapon(player_info); //select next missile, if this one out of ammo } } } diff --git a/similar/main/weapon.cpp b/similar/main/weapon.cpp index 86592aa8d..89244c564 100644 --- a/similar/main/weapon.cpp +++ b/similar/main/weapon.cpp @@ -711,15 +711,14 @@ void auto_select_primary_weapon() auto_select_weapon({}); } -void auto_select_secondary_weapon() +namespace dsx { + +void auto_select_secondary_weapon(player_info &player_info) { - auto &player_info = get_local_plrobj().ctype.player_info; if (!player_has_secondary_weapon(player_info.Secondary_weapon).has_all()) auto_select_weapon({}); } -namespace dsx { - void delayed_autoselect(player_info &player_info) { if (!Controls.state.fire_primary) @@ -1532,7 +1531,7 @@ void DropSecondaryWeapon () if (secondary_ammo == 0) { - auto_select_secondary_weapon(); + auto_select_secondary_weapon(player_info); } }