? blah.txt
Index: code/ai/aicode.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/ai/aicode.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- code/ai/aicode.cpp	20 Feb 2006 02:13:07 -0000	1.61
+++ code/ai/aicode.cpp	20 Feb 2006 07:59:26 -0000	1.62
@@ -9,13 +9,17 @@
 
 /*
  * $Logfile: /Freespace2/code/Ship/AiCode.cpp $
- * $Revision: 1.61 $
- * $Date: 2006/02/20 02:13:07 $
+ * $Revision: 1.62 $
+ * $Date: 2006/02/20 07:59:26 $
  * $Author: Goober5000 $
  * 
  * AI code that does interesting stuff
  *
  * $Log: aicode.cpp,v $
+ * Revision 1.62  2006/02/20 07:59:26  Goober5000
+ * fixed several more things in the new ignore code
+ * --Goober5000
+ *
  * Revision 1.61  2006/02/20 02:13:07  Goober5000
  * added ai-ignore-new which hopefully should fix the ignore bug
  * --Goober5000
@@ -2692,14 +2696,14 @@
 
 */
 
+// Goober5000 - fixed up a bit
 //	Determine if object objnum is supposed to be ignored by object with ai_info *aip.
 //	Return:
 //		TRUE	if objnum is aip->ignore_objnum (and signatures match)
 //				or objnum is in ignore wing
 //		FALSE	otherwise
-int is_ignore_object(ai_info *aip, int objnum)
+int is_ignore_object_sub(int *ignore_objnum, int *ignore_signature, int objnum)
 {
-
 /*	// First, scan all objects in global array of objects to be ignored.
 	for (int i=0; i<MAX_IGNORE_OBJECTS; i++)
 		if (Ignore_objects[i].objnum != -1)
@@ -2711,31 +2715,27 @@
 	// Didn't find in global list.  Now check 
 
 	// Not ignoring anything.
-	if (aip->ignore_objnum == UNUSED_OBJNUM)
+	if (*ignore_objnum == UNUSED_OBJNUM)
 	{
 		return 0;									
 	}
 	// This means it's ignoring an object, not a wing.
-	else if (aip->ignore_objnum >= 0)
+	else if (*ignore_objnum >= 0)
 	{
-		if (aip->ignore_objnum == objnum)
+		// see if this object became invalid
+		if (Objects[*ignore_objnum].signature != *ignore_signature)
 		{
-			// numbers and signatures match
-			if (Objects[aip->ignore_objnum].signature == aip->ignore_signature)
-			{
-				return 1;
-			}
-			// object is no longer valid; reset
-			else
-			{
-				aip->ignore_objnum = UNUSED_OBJNUM;
-				return 0;
-			}
+			// reset
+			*ignore_objnum = UNUSED_OBJNUM;
 		}
-		else
+		// objects and signatures match
+		else if (*ignore_objnum == objnum)
 		{
-			return 0;
+			// found it
+			return 1;
 		}
+
+		return 0;
 	}
 	// Ignoring a wing.
 	else
@@ -2744,10 +2744,9 @@
 		return 0;
 
 		/*
-		int	ignore_wingnum = -(aip->ignore_objnum + 1);
+		int	ignore_wingnum = -(*ignore_objnum + 1);
 
 		Assert(ignore_wingnum < MAX_WINGS);
-		Assert(aip->shipnum >= 0);
 		return (Ships[Objects[objnum].instance].wingnum == ignore_wingnum);
 		*/
 	}
@@ -2760,57 +2759,28 @@
 
 	for (i = 0; i < MAX_IGNORE_NEW_OBJECTS; i++)
 	{
-		// Not ignoring anything.
-		if (aip->ignore_new_objnums[i] == UNUSED_OBJNUM)
-		{
-			continue;
-		}
-		// This means it's ignoring an object, not a wing.
-		else if (aip->ignore_new_objnums[i] >= 0)
-		{
-			if (aip->ignore_new_objnums[i] == objnum)
-			{
-				// numbers and signatures match
-				if (Objects[aip->ignore_new_objnums[i]].signature == aip->ignore_new_signatures[i])
-				{
-					return i;
-				}
-				// object is no longer valid; reset
-				else
-				{
-					aip->ignore_new_objnums[i] = UNUSED_OBJNUM;
-					continue;
-				}
-			}
-			else
-			{
-				continue;
-			}
-		}
-		// Ignoring a wing.
-		else
-		{
-			Int3(); // Should never happen.  I thought I removed this behavior! -- MK, 5/17/98
-			continue;
-
-			/*
-			int	ignore_wingnum = -(aip->ignore_objnums[i] + 1);
-	
-			Assert(ignore_wingnum < MAX_WINGS);
-			Assert(aip->shipnum >= 0);
-			return (Ships[Objects[objnum].instance].wingnum == ignore_wingnum);
-			*/
-		}
+		if (is_ignore_object_sub(&aip->ignore_new_objnums[i], &aip->ignore_new_signatures[i], objnum))
+			return i;
 	}
 
 	return -1;
 }
 
 // Goober5000
-// Like above, but using ignore-new.
-int is_ignore_new_object(ai_info *aip, int objnum)
+int is_ignore_object(ai_info *aip, int objnum, int just_the_original = 0)
 {
-	return (find_ignore_new_object_index(aip, objnum) >= 0);
+	// check original (retail) ignore
+	if (is_ignore_object_sub(&aip->ignore_objnum, &aip->ignore_signature, objnum))
+		return 1;
+
+	// check new ignore
+	if (!just_the_original)
+	{
+		if (find_ignore_new_object_index(aip, objnum) >= 0)
+			return 1;
+	}
+
+	return 0;
 }
 
 // -----------------------------------------------------------------------------
@@ -2874,7 +2844,7 @@
 			if (shipp->flags & SF_DYING)
 				return;
 
-			if (is_ignore_object(aip, ((eno->trial_objp)-Objects)))
+			if (is_ignore_object(aip, OBJ_INDEX(eno->trial_objp)))
 				return;
 
 			if (eno->trial_objp->flags & OF_PROTECTED)
@@ -3231,13 +3201,15 @@
 			aip->ok_to_target_timestamp = timestamp(DELAY_TARGET_TIME);	//	No dynamic targeting for 7 seconds.
 	}
 
-	if (is_ignore_object(aip, aip->target_objnum))
-		aip->ignore_objnum = UNUSED_OBJNUM;
-
 	// Goober5000
 	if ((temp = find_ignore_new_object_index(aip, aip->target_objnum)) >= 0)
+	{
 		aip->ignore_new_objnums[temp] = UNUSED_OBJNUM;
-
+	}
+	else if (is_ignore_object(aip, aip->target_objnum, 1))
+	{
+		aip->ignore_objnum = UNUSED_OBJNUM;
+	}
 
 	aip->mode = AIM_CHASE;
 	aip->submode = SM_ATTACK;				// AL 12-15-97: need to set submode?  I got an assert() where submode was bogus
@@ -8102,7 +8074,13 @@
 
 	// Goober5000
 	if ((temp = find_ignore_new_object_index(aip, aip->target_objnum)) >= 0)
+	{
 		aip->ignore_new_objnums[temp] = UNUSED_OBJNUM;
+	}
+	else if (is_ignore_object(aip, aip->target_objnum, 1))
+	{
+		aip->ignore_objnum = UNUSED_OBJNUM;
+	}
 
 	// -- Done at caller in ai_process_mission_orders -- attacked_objp->flags |= OF_PROTECTED;
 
@@ -10088,7 +10066,7 @@
 
 	if ( hitter_objp->type == OBJ_SHIP ) {
 		//	If the hitter object is the ignore object, don't attack it.
-		if (is_ignore_object(aip, hitter_objp-Objects))
+		if (is_ignore_object(aip, OBJ_INDEX(hitter_objp)))
 			return;
 
 		//	If hitter is on same team as me, don't attack him.
@@ -12663,23 +12641,6 @@
 		aip->target_objnum = -1;
 }
 
-// Goober5000
-void ai_preprocess_ignore_new_objnums(object *objp, ai_info *aip)
-{
-	if (is_ignore_new_object(aip, aip->goal_objnum))
-	{
-		aip->goal_objnum = -1;
-
-		// AL 12-11-97: If in STRAFE mode, we need to ensure that target_objnum is also
-		//              set to -1
-		if (aip->mode == AIM_STRAFE)
-			aip->target_objnum = -1;
-	}
-
-	if (is_ignore_new_object(aip, aip->target_objnum))
-		aip->target_objnum = -1;
-}
-
 /*
 void ai_safety_circle_spot()
 {
Index: code/ai/aigoals.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/ai/aigoals.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- code/ai/aigoals.cpp	20 Feb 2006 02:13:07 -0000	1.20
+++ code/ai/aigoals.cpp	20 Feb 2006 07:59:26 -0000	1.21
@@ -9,13 +9,17 @@
 
 /*
  * $Logfile: /Freespace2/code/Ship/AiGoals.cpp $
- * $Revision: 1.20 $
- * $Date: 2006/02/20 02:13:07 $
+ * $Revision: 1.21 $
+ * $Date: 2006/02/20 07:59:26 $
  * $Author: Goober5000 $
  *
  * File to deal with manipulating AI goals, etc.
  *
  * $Log: aigoals.cpp,v $
+ * Revision 1.21  2006/02/20 07:59:26  Goober5000
+ * fixed several more things in the new ignore code
+ * --Goober5000
+ *
  * Revision 1.20  2006/02/20 02:13:07  Goober5000
  * added ai-ignore-new which hopefully should fix the ignore bug
  * --Goober5000
@@ -676,7 +680,11 @@
 #define PLAYER_PRIORITY_SUPPORT_LOW		10
 
 // define for which goals cause other goals to get purged
-#define PURGE_GOALS		(AI_GOAL_IGNORE | AI_GOAL_IGNORE_NEW | AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)
+// Goober5000 - okay, this seems really stupid.  If any ship in the mission is assigned a goal
+// in PURGE_GOALS_ALL_SHIPS, *every* other ship will have certain goals purged.  So I added
+// PURGE_GOALS_ONE_SHIP for goals which should only purge other goals in the one ship.
+#define PURGE_GOALS_ALL_SHIPS		(AI_GOAL_IGNORE | AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)
+#define PURGE_GOALS_ONE_SHIP		(AI_GOAL_IGNORE_NEW)
 
 // goals given from the player to other ships in the game are also handled in this
 // code
@@ -1095,46 +1103,46 @@
 		} else if ( purge_wing != wingnum )
 			continue;
 
-		switch( mode ) {
-		// ignore goals should get rid of any kind of attack goal
-		case AI_GOAL_IGNORE:
-		case AI_GOAL_IGNORE_NEW:
-			if ( purge_ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DESTROY_SUBSYSTEM) )
-				purge_goal->flags |= AIGF_PURGE;
-			break;
+		switch (mode)
+		{
+			// ignore goals should get rid of any kind of attack goal
+			case AI_GOAL_IGNORE:
+			case AI_GOAL_IGNORE_NEW:
+				if ( purge_ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DESTROY_SUBSYSTEM) )
+					purge_goal->flags |= AIGF_PURGE;
+				break;
 
-		// disarm/disable goals should remove any general attack
-		case AI_GOAL_DISABLE_SHIP:
-		case AI_GOAL_DISARM_SHIP:
-			if ( purge_ai_mode & (AI_GOAL_CHASE | AI_GOAL_CHASE_WING) )
-				purge_goal->flags |= AIGF_PURGE;
-			break;
+			// disarm/disable goals should remove any general attack
+			case AI_GOAL_DISABLE_SHIP:
+			case AI_GOAL_DISARM_SHIP:
+				if ( purge_ai_mode & (AI_GOAL_CHASE | AI_GOAL_CHASE_WING) )
+					purge_goal->flags |= AIGF_PURGE;
+				break;
 		}
 	}
 }
 
-// function to purge the goals of all ships in the game based on the incoming goal structure
-void ai_goal_purge_all_invalid_goals( ai_goal *aigp )
+// function to purge the goals of *all* ships in the game based on the incoming goal structure
+void ai_goal_purge_all_invalid_goals(ai_goal *aigp)
 {
-	int mode, i;
+	int i;
 	ship_obj *sop;
 
-	mode = aigp->ai_mode;
-
 	// only purge goals if a new goal is one of the types in next statement
-	if ( !(mode & PURGE_GOALS) )
+	if (!(aigp->ai_mode & PURGE_GOALS_ALL_SHIPS))
 		return;
 
-	for ( sop = GET_FIRST(&Ship_obj_list); sop != END_OF_LIST(&Ship_obj_list); sop = GET_NEXT(sop) ) {
-		ship *shipp;
-
-		shipp = &Ships[Objects[sop->objnum].instance];
-		ai_goal_purge_invalid_goals( aigp, Ai_info[shipp->ai_index].goals );
+	for (sop = GET_FIRST(&Ship_obj_list); sop != END_OF_LIST(&Ship_obj_list); sop = GET_NEXT(sop))
+	{
+		ship *shipp = &Ships[Objects[sop->objnum].instance];
+		ai_goal_purge_invalid_goals(aigp, Ai_info[shipp->ai_index].goals);
 	}
 
 	// we must do the same for the wing goals
-	for (i = 0; i < Num_wings; i++ )
-		ai_goal_purge_invalid_goals( aigp, Wings[i].ai_goals );
+	for (i = 0; i < Num_wings; i++)
+	{
+		ai_goal_purge_invalid_goals(aigp, Wings[i].ai_goals);
+	}
 }
 
 // Goober5000
@@ -1959,11 +1967,20 @@
 	}
 
 	// if the goal is an ignore/disable/disarm goal, then 
-	if ( (status == SHIP_STATUS_ARRIVED) && (aigp->ai_mode & PURGE_GOALS) && !(aigp->flags & AIGF_GOALS_PURGED) ) {
-		ai_goal_purge_all_invalid_goals( aigp );
-		aigp->flags |= AIGF_GOALS_PURGED;
-	}
-		
+	// Goober5000 - see note at PURGE_GOALS_ALL_SHIPS... this is bizarre
+	if ((status == SHIP_STATUS_ARRIVED) && !(aigp->flags & AIGF_GOALS_PURGED))
+	{
+		if (aigp->ai_mode & PURGE_GOALS_ALL_SHIPS)
+		{
+			ai_goal_purge_all_invalid_goals(aigp);
+			aigp->flags |= AIGF_GOALS_PURGED;
+		}
+		else if (aigp->ai_mode & PURGE_GOALS_ONE_SHIP)
+		{
+			ai_goal_purge_invalid_goals(aigp, aip->goals);
+			aigp->flags |= AIGF_GOALS_PURGED;
+		}
+	}	
 
 	// if we are docking, validate the docking indices on both ships.  We might have to change names to indices.
 	// only enter this calculation if the ship we are docking with has arrived.  If the ship is gone, then
