Skip to content

Commit 09b35ed

Browse files
More helpful assertions here
1 parent 390ddb3 commit 09b35ed

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

code/ai/aicode.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15549,11 +15549,14 @@ void ai_ship_hit(object *objp_ship, object *hit_objp, vec3d *hit_normal)
1554915549
return;
1555015550

1555115551
hitter_objnum = hit_objp->parent;
15552-
Assert((hitter_objnum >= 0) && (hitter_objnum < MAX_OBJECTS));
15552+
Assertion((hitter_objnum >= 0) && (hitter_objnum < MAX_OBJECTS), "hitter_objnum in this function is an invalid index of %d. This can cause random behavior, and is a coder mistake. Please report!", hitter_objnum);
1555315553
objp_hitter = &Objects[hitter_objnum];
1555415554

15555+
Assertion((objp_hitter->type == OBJ_SHIP) || (objp_hitter->type == OBJ_WEAPON) || (objp_hitter->type == OBJ_ASTEROID) || (objp_hitter->type == OBJ_BEAM) || (objp_hitter->type == OBJ_DEBRIS),
15556+
"The ai code is passing an invalid object type of %d to a function when trying to decide how to respond to something hitting it. This is a bug in the code, please report!", objp_hitter->type);
15557+
1555515558
// lets not check hits by ghosts any further either
15556-
if(objp_hitter->type != OBJ_SHIP && objp_hitter->type != OBJ_WEAPON && objp_hitter->type != OBJ_ASTEROID && objp_hitter->type != OBJ_BEAM)
15559+
if(objp_hitter->type != OBJ_SHIP && objp_hitter->type != OBJ_WEAPON && objp_hitter->type != OBJ_ASTEROID && objp_hitter->type != OBJ_BEAM && objp_hitter->type != OBJ_DEBRIS)
1555715560
return;
1555815561

1555915562
// Hit by a protected ship, don't attack it.

0 commit comments

Comments
 (0)