From 7e6c9fb1723694c5915363d9d183696b749170a1 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 10 Dec 2016 17:51:10 +0000 Subject: [PATCH] Pass player_info to allowed_to_fire_flare --- common/main/fwd-player.h | 1 + common/main/game.h | 5 ----- similar/main/game.cpp | 7 +++---- similar/main/gamecntl.cpp | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/common/main/fwd-player.h b/common/main/fwd-player.h index ade3819b6..337ceb5db 100644 --- a/common/main/fwd-player.h +++ b/common/main/fwd-player.h @@ -84,6 +84,7 @@ struct player_rw; struct player_info; extern array Players; // Misc player info void player_rw_swap(player_rw *p, int swap); +int allowed_to_fire_flare(player_info &); #if defined(DXX_BUILD_DESCENT_II) extern array Guided_missile; extern array Guided_missile_sig; diff --git a/common/main/game.h b/common/main/game.h index 1c54de678..16b50fc1c 100644 --- a/common/main/game.h +++ b/common/main/game.h @@ -352,11 +352,6 @@ window_event_result ReadControls(const d_event &event); int cheats_enabled(); void game_disable_cheats(); int allowed_to_fire_laser(void); -#ifdef dsx -namespace dsx { -int allowed_to_fire_flare(void); -} -#endif int allowed_to_fire_missile(void); void check_rear_view(void); int create_special_path(void); diff --git a/similar/main/game.cpp b/similar/main/game.cpp index 94fa6f6ea..1054097a5 100644 --- a/similar/main/game.cpp +++ b/similar/main/game.cpp @@ -859,15 +859,14 @@ int allowed_to_fire_laser(void) } namespace dsx { -int allowed_to_fire_flare(void) +int allowed_to_fire_flare(player_info &player_info) { - auto &plrobj = get_local_plrobj(); - auto &Next_flare_fire_time = plrobj.ctype.player_info.Next_flare_fire_time; + auto &Next_flare_fire_time = player_info.Next_flare_fire_time; if (Next_flare_fire_time > GameTime64) return 0; #if defined(DXX_BUILD_DESCENT_II) - if (plrobj.ctype.player_info.energy < Weapon_info[weapon_id_type::FLARE_ID].energy_usage) + if (player_info.energy < Weapon_info[weapon_id_type::FLARE_ID].energy_usage) #define FLARE_BIG_DELAY (F1_0*2) Next_flare_fire_time = GameTime64 + FLARE_BIG_DELAY; else diff --git a/similar/main/gamecntl.cpp b/similar/main/gamecntl.cpp index 1a493eb1d..855af3c2b 100644 --- a/similar/main/gamecntl.cpp +++ b/similar/main/gamecntl.cpp @@ -236,7 +236,7 @@ static void do_weapon_n_item_stuff() if (Controls.state.fire_flare > 0) { Controls.state.fire_flare = 0; - if (allowed_to_fire_flare()) + if (allowed_to_fire_flare(player_info)) Flare_create(vobjptridx(ConsoleObject)); }