Skip to content

Commit 1e8ea06

Browse files
authored
Merge pull request scp-fs2open#6711 from Baezon/small-turret-swarm-fix
Small fix for turret swarm stuff
2 parents 49cd8c3 + c085f87 commit 1e8ea06

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

code/weapon/swarm.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ void turret_swarm_delete(int i)
312312
void turret_swarm_set_up_info(int parent_objnum, ship_subsys *turret, const weapon_info *wip, int weapon_num, bool no_tracking_object)
313313
{
314314
turret_swarm_info *tsi;
315-
object *parent_obj, *target_obj;
315+
object *parent_obj;
316316
ship *shipp;
317317
int tsi_index;
318318

@@ -334,10 +334,10 @@ void turret_swarm_set_up_info(int parent_objnum, ship_subsys *turret, const weap
334334
Assert(parent_obj->type == OBJ_SHIP);
335335
shipp = &Ships[parent_obj->instance];
336336
Assert(turret->turret_enemy_objnum < MAX_OBJECTS);
337-
if(!no_tracking_object && ((turret->turret_enemy_objnum < 0) || (turret->turret_enemy_objnum >= MAX_OBJECTS))){
337+
if (turret->turret_enemy_objnum < 0 && !no_tracking_object)
338+
return;
339+
if (turret->turret_enemy_objnum >= MAX_OBJECTS)
338340
return;
339-
}
340-
target_obj = &Objects[turret->turret_enemy_objnum];
341341

342342
// valid swarm weapon
343343
Assert(((wip->wi_flags[Weapon::Info_Flags::Swarm]) && (wip->swarm_count > 0)) || ((wip->wi_flags[Weapon::Info_Flags::Corkscrew]) && (wip->cs_num_fired > 0)));
@@ -399,7 +399,7 @@ void turret_swarm_set_up_info(int parent_objnum, ship_subsys *turret, const weap
399399
tsi->parent_objnum = parent_objnum;
400400
tsi->parent_sig = parent_obj->signature;
401401
tsi->target_objnum = turret->turret_enemy_objnum;
402-
tsi->target_sig = target_obj->signature;
402+
tsi->target_sig = turret->turret_enemy_objnum >= 0 ? Objects[turret->turret_enemy_objnum].signature : 0;
403403
tsi->turret = turret;
404404
tsi->target_subsys = turret->targeted_subsys;
405405
tsi->time_to_fire = 1; // first missile next frame

0 commit comments

Comments
 (0)