From 20f8deb62a00a6f5b3d768e423b282515d2af26c Mon Sep 17 00:00:00 2001 From: Kp Date: Wed, 31 Jul 2013 02:12:18 +0000 Subject: [PATCH] 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. --- main/ai2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/ai2.c b/main/ai2.c index b08befb04..d11fd4aa6 100644 --- a/main/ai2.c +++ b/main/ai2.c @@ -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; }