From 86a494288312e1555187081461737c18e8a513bb Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 2 Oct 2016 00:34:45 +0000 Subject: [PATCH] Pass player_info to do_secondary_weapon_select --- common/main/fwd-weapon.h | 2 +- similar/main/gamecntl.cpp | 6 ++---- similar/main/weapon.cpp | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/common/main/fwd-weapon.h b/common/main/fwd-weapon.h index bca498b82..71dae6cf8 100644 --- a/common/main/fwd-weapon.h +++ b/common/main/fwd-weapon.h @@ -163,9 +163,9 @@ public: #ifdef dsx namespace dsx { void do_primary_weapon_select(uint_fast32_t weapon_num); -void do_secondary_weapon_select(uint_fast32_t weapon_num); struct player_info; +void do_secondary_weapon_select(player_info &, uint_fast32_t weapon_num); void auto_select_primary_weapon(player_info &); void auto_select_secondary_weapon(player_info &); void select_primary_weapon(player_info &, const char *weapon_name, uint_fast32_t weapon_num, int wait_for_rearm); diff --git a/similar/main/gamecntl.cpp b/similar/main/gamecntl.cpp index ab47ea542..79d637242 100644 --- a/similar/main/gamecntl.cpp +++ b/similar/main/gamecntl.cpp @@ -234,6 +234,7 @@ int which_bomb() namespace dsx { static void do_weapon_n_item_stuff() { + auto &player_info = get_local_plrobj().ctype.player_info; if (Controls.state.fire_flare > 0) { Controls.state.fire_flare = 0; @@ -243,7 +244,6 @@ static void do_weapon_n_item_stuff() if (allowed_to_fire_missile() && Controls.state.fire_secondary) { - auto &player_info = get_local_plrobj().ctype.player_info; Global_missile_firing_count += Weapon_info[Secondary_weapon_to_weapon_info[player_info.Secondary_weapon]].fire_count; } @@ -267,7 +267,7 @@ static void do_weapon_n_item_stuff() const auto select_weapon = exchange(Controls.state.select_weapon, 0) - 1; const auto weapon_num = select_weapon > 4 ? select_weapon - 5 : select_weapon; if (select_weapon > 4) - do_secondary_weapon_select(weapon_num); + do_secondary_weapon_select(player_info, weapon_num); else do_primary_weapon_select(weapon_num); } @@ -291,7 +291,6 @@ static void do_weapon_n_item_stuff() #if defined(DXX_BUILD_DESCENT_II) if (Controls.state.toggle_bomb > 0) { - auto &player_info = get_local_plrobj().ctype.player_info; auto &Secondary_last_was_super = player_info.Secondary_last_was_super; int bomb = Secondary_last_was_super[PROXIMITY_INDEX]?PROXIMITY_INDEX:SMART_MINE_INDEX; @@ -317,7 +316,6 @@ static void do_weapon_n_item_stuff() Controls.state.toggle_bomb = 0; } - auto &player_info = get_local_plrobj().ctype.player_info; if (Controls.state.energy_to_shield && (player_info.powerup_flags & PLAYER_FLAGS_CONVERTER)) transfer_energy_to_shield(); #endif diff --git a/similar/main/weapon.cpp b/similar/main/weapon.cpp index ee0a43bd8..cb986fa32 100644 --- a/similar/main/weapon.cpp +++ b/similar/main/weapon.cpp @@ -625,9 +625,8 @@ void do_primary_weapon_select(uint_fast32_t weapon_num) select_primary_weapon(player_info, weapon_name, weapon_num, 1); } -void do_secondary_weapon_select(uint_fast32_t weapon_num) +void do_secondary_weapon_select(player_info &player_info, uint_fast32_t weapon_num) { - auto &player_info = get_local_plrobj().ctype.player_info; #if defined(DXX_BUILD_DESCENT_I) //added on 10/9/98 by Victor Rachels to add laser cycle //end this section addition - Victor Rachels