Skip to content

Commit d716433

Browse files
authored
Merge pull request #3300 from Baezon/fix-flak-substitute-assert
Fix assert with combining flak and non-flak using substitute
2 parents 95235b3 + ce1907c commit d716433

File tree

4 files changed

+6
-33
lines changed

4 files changed

+6
-33
lines changed

code/ai/aiturret.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,9 +2031,7 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
20312031
Script_system.RemHookVars({"Ship", "Weapon", "Beam", "Target"});
20322032

20332033
// if the gun is a flak gun
2034-
if (wip->wi_flags[Weapon::Info_Flags::Flak]) {
2035-
// show a muzzle flash
2036-
flak_muzzle_flash(turret_pos, firing_vec, &Objects[parent_ship->objnum].phys_info, turret_weapon_class);
2034+
if (wip->wi_flags[Weapon::Info_Flags::Flak]) {
20372035

20382036
if(predicted_pos != NULL)
20392037
{
@@ -2048,8 +2046,9 @@ bool turret_fire_weapon(int weapon_num, ship_subsys *turret, int parent_objnum,
20482046
flak_set_range(objp, flak_range_override);
20492047
}
20502048
}
2051-
// otherwise just do mflash if the weapon has it
2052-
else if (wip->muzzle_flash >= 0) {
2049+
2050+
// do mflash if the weapon has it
2051+
if (wip->muzzle_flash >= 0) {
20532052
mflash_create(turret_pos, firing_vec, &Objects[parent_ship->objnum].phys_info, wip->muzzle_flash);
20542053
}
20552054

code/network/multimsgs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "missionui/missiondebrief.h"
5858
#include "network/multi_log.h"
5959
#include "weapon/emp.h"
60+
#include "weapon/muzzleflash.h"
6061
#include "network/multi_kick.h"
6162
#include "cmdline/cmdline.h"
6263
#include "weapon/flak.h"
@@ -8551,7 +8552,7 @@ void process_flak_fired_packet(ubyte *data, header *hinfo)
85518552
}
85528553

85538554
// create a muzzle flash from a flak gun based upon firing position and weapon type
8554-
flak_muzzle_flash(&pos, &dir, &objp->phys_info, wid);
8555+
mflash_create(&pos, &dir, &objp->phys_info, Weapon_info[wid].muzzle_flash);
85558556

85568557
// set its range explicitly - make it long enough so that it's guaranteed to still exist when the server tells us it blew up
85578558
flak_set_range(&Objects[weapon_objnum], (float)flak_range);

code/ship/ship.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11896,11 +11896,6 @@ int ship_fire_primary(object * obj, int stream_weapons, int force, bool rollback
1189611896
{
1189711897
flak_set_range(&Objects[weapon_objnum], flak_range - winfo_p->untargeted_flak_range_penalty);
1189811898
}
11899-
11900-
if ((winfo_p->muzzle_flash>=0) && (((shipp==Player_ship) && (vm_vec_mag(&Player_obj->phys_info.vel)>=45)) || (shipp!=Player_ship)))
11901-
{
11902-
flak_muzzle_flash(&firing_pos,&obj->orient.vec.fvec, &obj->phys_info, swp->primary_bank_weapons[bank_to_fire]);
11903-
}
1190411899
}
1190511900
// create the muzzle flash effect
1190611901
shipfx_flash_create( obj, sip->model_num, &pnt, &obj->orient.vec.fvec, 1, weapon_idx );

code/weapon/flak.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,6 @@ void flak_jitter_aim(vec3d *dir, float dist_to_target, float weapon_subsys_stren
114114
vm_vec_normalize(dir);
115115
}
116116

117-
/**
118-
* Create a muzzle flash from a flak gun based upon firing position and weapon type
119-
*/
120-
void flak_muzzle_flash(vec3d *pos, vec3d *dir, physics_info *pip, int turret_weapon_class)
121-
{
122-
// sanity
123-
Assert((turret_weapon_class >= 0) && (turret_weapon_class < weapon_info_size()));
124-
if((turret_weapon_class < 0) || (turret_weapon_class >= weapon_info_size())){
125-
return;
126-
}
127-
Assert(Weapon_info[turret_weapon_class].wi_flags[Weapon::Info_Flags::Flak]);
128-
if(!(Weapon_info[turret_weapon_class].wi_flags[Weapon::Info_Flags::Flak])){
129-
return;
130-
}
131-
132-
if(Weapon_info[turret_weapon_class].muzzle_flash < 0){
133-
return;
134-
}
135-
136-
mflash_create(pos, dir, pip, Weapon_info[turret_weapon_class].muzzle_flash);
137-
}
138-
139117
/**
140118
* Given a just fired flak shell, pick a detonating distance for it
141119
*/

0 commit comments

Comments
 (0)