Check that object is CT_AI before accessing AI-specific fields

Reactors call player_is_visible_from_object, but do not use the ai_info
field.  Add a check to use ai_info only when the object is actually a
robot.
This commit is contained in:
Kp 2013-07-31 02:12:18 +00:00
parent caeb94faef
commit 20f8deb62a

View file

@ -479,7 +479,8 @@ int player_is_visible_from_object(object *objp, vms_vector *pos, fix field_of_vi
fvi_query fq;
// Assume that robot's gun tip is in same segment as robot's center.
objp->ctype.ai_info.SUB_FLAGS &= ~SUB_FLAGS_GUNSEG;
if (objp->control_type == CT_AI)
objp->ctype.ai_info.SUB_FLAGS &= ~SUB_FLAGS_GUNSEG;
fq.p0 = pos;
if ((pos->x != objp->pos.x) || (pos->y != objp->pos.y) || (pos->z != objp->pos.z)) {
@ -490,7 +491,8 @@ int player_is_visible_from_object(object *objp, vms_vector *pos, fix field_of_vi
move_towards_segment_center(objp);
} else {
if (segnum != objp->segnum) {
objp->ctype.ai_info.SUB_FLAGS |= SUB_FLAGS_GUNSEG;
if (objp->control_type == CT_AI)
objp->ctype.ai_info.SUB_FLAGS |= SUB_FLAGS_GUNSEG;
}
fq.startseg = segnum;
}