Skip to content

Commit 1159e66

Browse files
committed
Avoid checking for combat music if the projectile's parent was recycled.
1 parent 37a98b8 commit 1159e66

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

code/ship/shiphit.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ void ship_hit_music(object *ship_objp, object *other_obj)
978978
Assert(other_obj); // Goober5000
979979

980980
ship* ship_p = &Ships[ship_objp->instance];
981+
object *parent;
981982

982983
// Switch to battle track when a ship is hit by fire
983984
//
@@ -991,6 +992,9 @@ void ship_hit_music(object *ship_objp, object *other_obj)
991992

992993
attackee_team = Ships[ship_objp->instance].team;
993994

995+
// avoid uninitialized value by matching them
996+
attacker_team = attackee_team;
997+
994998
switch ( other_obj->type )
995999
{
9961000
case OBJ_SHIP:
@@ -1004,7 +1008,9 @@ void ship_hit_music(object *ship_objp, object *other_obj)
10041008

10051009
case OBJ_WEAPON:
10061010
// parent of weapon is object num of ship that fired it
1007-
attacker_team = Ships[Objects[other_obj->parent].instance].team;
1011+
parent = &Objects[other_obj->parent];
1012+
if (parent->signature == other_obj->parent_sig)
1013+
attacker_team = Ships[parent->instance].team;
10081014
break;
10091015

10101016
default:

0 commit comments

Comments
 (0)