@@ -13836,7 +13836,7 @@ extern void ai_maybe_announce_shockwave_weapon(object *firing_objp, int weapon_i
1383613836// need to avoid firing when normally called
1383713837int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1383813838{
13839- int n, weapon_idx, j, bank, bank_adjusted, starting_bank_count = -1, num_fired;
13839+ int n, weapon_idx, j, bank, bank_adjusted, num_fired;
1384013840 ushort starting_sig = 0;
1384113841 ship *shipp;
1384213842 ship_weapon *swp;
@@ -13846,6 +13846,7 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1384613846 polymodel *pm;
1384713847 vec3d missile_point, pnt, firing_pos;
1384813848 bool has_fired = false; // Used to determine whether to fire the scripting hook
13849+ tracking_info tinfo;
1384913850
1385013851 Assert( obj != NULL );
1385113852
@@ -13932,14 +13933,13 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1393213933
1393313934 if ( MULTIPLAYER_MASTER ) {
1393413935 starting_sig = multi_get_next_network_signature( MULTI_SIG_NON_PERMANENT );
13935- starting_bank_count = swp->secondary_bank_ammo[bank];
1393613936 }
1393713937
1393813938 if (ship_fire_secondary_detonate(obj, swp)) {
1393913939 // in multiplayer, master sends a secondary fired packet with starting signature of -1 -- indicates
1394013940 // to client code to set the detonate timer to 0.
1394113941 if ( MULTIPLAYER_MASTER ) {
13942- send_secondary_fired_packet( shipp, 0, starting_bank_count , 1, allow_swarm );
13942+ send_secondary_fired_packet( shipp, 0, tinfo , 1, allow_swarm );
1394313943 }
1394413944
1394513945 // For all banks, if ok to fire a weapon, make it wait a bit.
@@ -14112,10 +14112,6 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1411214112 return 0; // we can make a quick out here!!!
1411314113 }
1411414114
14115- int target_objnum;
14116- ship_subsys *target_subsys;
14117- int locked;
14118-
1411914115 if ( obj == Player_obj || ( MULTIPLAYER_MASTER && obj->flags[Object::Object_Flags::Player_ship] ) ) {
1412014116 // use missile lock slots
1412114117 if ( !shipp->missile_locks_firing.empty() ) {
@@ -14132,39 +14128,35 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1413214128 }
1413314129
1413414130 if (lock_data.obj != nullptr) {
14135- target_objnum = OBJ_INDEX(lock_data.obj);
14136- target_subsys = lock_data.subsys;
14137- locked = 1 ;
14131+ tinfo.objnum = OBJ_INDEX(lock_data.obj);
14132+ tinfo.subsys = lock_data.subsys;
14133+ tinfo. locked = true ;
1413814134 } else {
14139- target_objnum = -1;
14140- target_subsys = nullptr;
14141- locked = 0 ;
14135+ tinfo.objnum = -1;
14136+ tinfo.subsys = nullptr;
14137+ tinfo. locked = false ;
1414214138 }
14143- } else if (wip->wi_flags[Weapon::Info_Flags::Homing_heat]) {
14144- target_objnum = aip->target_objnum;
14145- target_subsys = aip->targeted_subsys;
14146- locked = aip->current_target_is_locked;
1414714139 } else {
14148- target_objnum = -1 ;
14149- target_subsys = nullptr ;
14150- locked = 0 ;
14140+ tinfo.objnum = aip->target_objnum ;
14141+ tinfo.subsys = aip->targeted_subsys ;
14142+ tinfo. locked = aip->current_target_is_locked == 1 ;
1415114143 }
1415214144 } else if (wip->multi_lock && !aip->ai_missile_locks_firing.empty()) {
14153- target_objnum = aip->ai_missile_locks_firing.back().first;
14154- target_subsys = aip->ai_missile_locks_firing.back().second;
14155- locked = 1 ;
14145+ tinfo.objnum = aip->ai_missile_locks_firing.back().first;
14146+ tinfo.subsys = aip->ai_missile_locks_firing.back().second;
14147+ tinfo. locked = true ;
1415614148 aip->ai_missile_locks_firing.pop_back();
1415714149 } else {
14158- target_objnum = aip->target_objnum;
14159- target_subsys = aip->targeted_subsys;
14160- locked = aip->current_target_is_locked;
14150+ tinfo.objnum = aip->target_objnum;
14151+ tinfo.subsys = aip->targeted_subsys;
14152+ tinfo. locked = aip->current_target_is_locked == 1 ;
1416114153 }
1416214154
1416314155 num_slots = pm->missile_banks[bank].num_slots;
1416414156 float target_radius = 0.f;
1416514157
14166- if (target_objnum >= 0) {
14167- target_radius = Objects[target_objnum ].radius;
14158+ if (tinfo.objnum >= 0) {
14159+ target_radius = Objects[tinfo.objnum ].radius;
1416814160 }
1416914161
1417014162 auto launch_curve_data = WeaponLaunchCurveData {
@@ -14286,7 +14278,7 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1428614278
1428714279 // create the weapon -- for multiplayer, the net_signature is assigned inside
1428814280 // of weapon_create
14289- weapon_num = weapon_create( &firing_pos, &firing_orient, weapon_idx, OBJ_INDEX(obj), -1, locked, false, 0.f, nullptr, launch_curve_data);
14281+ weapon_num = weapon_create( &firing_pos, &firing_orient, weapon_idx, OBJ_INDEX(obj), -1, tinfo. locked, false, 0.f, nullptr, launch_curve_data);
1429014282
1429114283 if (weapon_num == -1) {
1429214284 // Weapon most likely failed to fire
@@ -14298,7 +14290,7 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1429814290
1429914291 if (weapon_num >= 0) {
1430014292 weapon_idx = Weapons[Objects[weapon_num].instance].weapon_info_index;
14301- weapon_set_tracking_info(weapon_num, OBJ_INDEX(obj), target_objnum, locked, target_subsys );
14293+ weapon_set_tracking_info(weapon_num, OBJ_INDEX(obj), tinfo );
1430214294 has_fired = true;
1430314295
1430414296 // create the muzzle flash effect
@@ -14362,7 +14354,7 @@ int ship_fire_secondary( object *obj, int allow_swarm, bool rollback_shot )
1436214354 // Cyborg17 - If this is a rollback shot, the server will let the player know within the packet.
1436314355 if ( MULTIPLAYER_MASTER ) {
1436414356 Assert(starting_sig != 0);
14365- send_secondary_fired_packet( shipp, starting_sig, starting_bank_count , num_fired, allow_swarm );
14357+ send_secondary_fired_packet( shipp, starting_sig, tinfo , num_fired, allow_swarm );
1436614358 }
1436714359
1436814360 // Handle Player only stuff, including stats and client secondary packets
0 commit comments