Simplify passing weapon to do_missile_firing
When the player fires a generic secondary, the choice of proximity bomb versus super-mine is never read. When the player specifically drops a bomb, only that choice needs to be read. Pass the chosen weapon as an argument, and avoid computing the choice on the path where it is never read.
This commit is contained in:
parent
b4fcb9c305
commit
52aa9891b9
|
@ -89,7 +89,7 @@ void Flare_create(vmobjptridx_t obj);
|
||||||
bool laser_are_related(vcobjptridx_t o1, vcobjptridx_t o2);
|
bool laser_are_related(vcobjptridx_t o1, vcobjptridx_t o2);
|
||||||
|
|
||||||
void do_laser_firing_player(object &);
|
void do_laser_firing_player(object &);
|
||||||
void do_missile_firing(int drop_bomb, const secondary_weapon_index_t bomb, const vmobjptridx_t plrobjidx);
|
void do_missile_firing(const secondary_weapon_index_t weapon, const vmobjptridx_t plrobjidx);
|
||||||
|
|
||||||
// Fires a laser-type weapon (a Primary weapon)
|
// Fires a laser-type weapon (a Primary weapon)
|
||||||
// Fires from object objnum, weapon type weapon_id.
|
// Fires from object objnum, weapon type weapon_id.
|
||||||
|
|
|
@ -300,8 +300,7 @@ static void do_weapon_n_item_stuff(object_array &Objects, control_info &Controls
|
||||||
|
|
||||||
if (Global_missile_firing_count) {
|
if (Global_missile_firing_count) {
|
||||||
--Global_missile_firing_count;
|
--Global_missile_firing_count;
|
||||||
const auto bomb = which_bomb(player_info);
|
do_missile_firing(player_info.Secondary_weapon, plrobjidx);
|
||||||
do_missile_firing(0, bomb, plrobjidx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Controls.state.cycle_primary > 0)
|
if (Controls.state.cycle_primary > 0)
|
||||||
|
@ -339,7 +338,7 @@ static void do_weapon_n_item_stuff(object_array &Objects, control_info &Controls
|
||||||
{
|
{
|
||||||
const auto bomb = which_bomb(player_info);
|
const auto bomb = which_bomb(player_info);
|
||||||
for (uint_fast32_t i = std::exchange(Controls.state.drop_bomb, 0); i--;)
|
for (uint_fast32_t i = std::exchange(Controls.state.drop_bomb, 0); i--;)
|
||||||
do_missile_firing(1, bomb, plrobjidx);
|
do_missile_firing(bomb, plrobjidx);
|
||||||
}
|
}
|
||||||
#if defined(DXX_BUILD_DESCENT_II)
|
#if defined(DXX_BUILD_DESCENT_II)
|
||||||
if (Controls.state.toggle_bomb > 0)
|
if (Controls.state.toggle_bomb > 0)
|
||||||
|
|
|
@ -2322,14 +2322,13 @@ void release_remote_guided_missile(d_level_unique_object_state &LevelUniqueObjec
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------
|
||||||
//changed on 31/3/10 by kreatordxx to distinguish between drop bomb and secondary fire
|
//changed on 31/3/10 by kreatordxx to distinguish between drop bomb and secondary fire
|
||||||
void do_missile_firing(int drop_bomb, const secondary_weapon_index_t bomb, const vmobjptridx_t plrobjidx)
|
void do_missile_firing(const secondary_weapon_index_t weapon, const vmobjptridx_t plrobjidx)
|
||||||
{
|
{
|
||||||
int gun_flag=0;
|
int gun_flag=0;
|
||||||
fix fire_frame_overhead = 0;
|
fix fire_frame_overhead = 0;
|
||||||
|
|
||||||
auto &plrobj = *plrobjidx;
|
auto &plrobj = *plrobjidx;
|
||||||
auto &player_info = plrobj.ctype.player_info;
|
auto &player_info = plrobj.ctype.player_info;
|
||||||
const auto weapon = drop_bomb ? bomb : player_info.Secondary_weapon;
|
|
||||||
assert(weapon < MAX_SECONDARY_WEAPONS);
|
assert(weapon < MAX_SECONDARY_WEAPONS);
|
||||||
auto &Next_missile_fire_time = player_info.Next_missile_fire_time;
|
auto &Next_missile_fire_time = player_info.Next_missile_fire_time;
|
||||||
if (GameTime64 - Next_missile_fire_time <= FrameTime) // if firing is prolonged by FrameTime overhead, let's try to fix that.
|
if (GameTime64 - Next_missile_fire_time <= FrameTime) // if firing is prolonged by FrameTime overhead, let's try to fix that.
|
||||||
|
|
Loading…
Reference in a new issue