Ejemplo n.º 1
0
void Win32Video::AddLowResModes()
{
	ModeInfo *mode, *nextmode;

	for (mode = m_Modes; mode != NULL; mode = nextmode)
	{
		nextmode = mode->next;
		if (mode->realheight == mode->height &&
			mode->doubling == 0 &&
			mode->height >= 200*2 &&
			mode->height <= 480*2 &&
			mode->width >= 320*2 &&
			mode->width <= 640*2)
		{
			AddMode (mode->width / 2, mode->height / 2, mode->bits, mode->height / 2, 1);
		}
	}
	for (mode = m_Modes; mode != NULL; mode = nextmode)
	{
		nextmode = mode->next;
		if (mode->realheight == mode->height &&
			mode->doubling == 0 &&
			mode->height >= 200*4 &&
			mode->height <= 480*4 &&
			mode->width >= 320*4 &&
			mode->width <= 640*4)
		{
			AddMode (mode->width / 4, mode->height / 4, mode->bits, mode->height / 4, 2);
		}
	}
}
Ejemplo n.º 2
0
void HeliBrain::FollowWaypoints(void)
{
   // int lastPickle;


   if (self->curWaypoint == NULL)
   {
      AddMode (LoiterMode);
      return;
   }

   GoToCurrentWaypoint();


   /*
   switch (self->curWaypoint->GetWPAction())
   {
      case WP_LAND:
	     if ( onStation == Arrived || onStation == Stabilizing )
		 	LandMe();
		else if ( !(onStation == OnStation) )
         	GoToCurrentWaypoint();
      break;

      default:
         GoToCurrentWaypoint();
      break;
   }
   */
}
Ejemplo n.º 3
0
void HeliBrain::RunDecisionRoutines(void)
{
   /*-----------------------*/
   /* collision avoid check */
   /*-----------------------*/
   CollisionCheck();

   /*-----------*/
   /* Guns Jink */
   /*-----------*/
   GunsJinkCheck();
	// checks for missiles too
   GunsEngageCheck();

   /* Special cases for close in combat logic.                 */
   /* These maneuvers are started from within other maneuvers, */
   /* eg. "rollAndPull" and are self-terminating.            */

   /*------------------*/
   /* default behavior */
   /*------------------*/
   // if (isWing)
   //    AddMode (WingyMode);
   AddMode(WaypointMode);
}
Ejemplo n.º 4
0
// Add 16:9 and 16:10 resolutions you can use in a window or letterboxed
void Win32Video::AddLetterboxModes ()
{
	ModeInfo *mode, *nextmode;

	for (mode = m_Modes; mode != NULL; mode = nextmode)
	{
		nextmode = mode->next;
		if (mode->realheight == mode->height && mode->height * 4/3 == mode->width)
		{
			if (mode->width >= 360)
			{
				AddMode (mode->width, mode->width * 9/16, mode->bits, mode->height, mode->doubling);
			}
			if (mode->width > 640)
			{
				AddMode (mode->width, mode->width * 10/16, mode->bits, mode->height, mode->doubling);
			}
		}
	}
}
Ejemplo n.º 5
0
void Win32Video::AddD3DModes (D3DFORMAT format)
{
	UINT modecount, i;
	D3DDISPLAYMODE mode;

	modecount = D3D->GetAdapterModeCount (D3DADAPTER_DEFAULT, format);
	for (i = 0; i < modecount; ++i)
	{
		if (D3D_OK == D3D->EnumAdapterModes (D3DADAPTER_DEFAULT, format, i, &mode))
		{
			AddMode (mode.Width, mode.Height, 8, mode.Height, 0);
		}
	}
}
Ejemplo n.º 6
0
BOOL LinkOptions::OnInitDialog()
{
    char timeout[6];

    CDialog::OnInitDialog();

    AddMode("Nothing (Disconnect)", LINK_DISCONNECTED);
    AddMode("Cable - Single Computer", LINK_CABLE_IPC);
    AddMode("Cable - Network", LINK_CABLE_SOCKET);
    AddMode("GameCube - Dolphin", LINK_GAMECUBE_DOLPHIN);
    AddMode("Wireless adapter - Single Computer", LINK_RFU_IPC);
    AddMode("Wireless adapter - Network", LINK_RFU_SOCKET);
    AddMode("Game Link (Game Boy) - Single Computer", LINK_GAMEBOY_IPC);
    AddMode("Game Link (Game Boy) - Network", LINK_GAMEBOY_SOCKET);

    sprintf(timeout, "%d", linkTimeout);

    m_timeout.LimitText(5);
    m_timeout.SetWindowText(timeout);

    m_serverip.SetWindowText(theApp.linkHostAddr);

    CheckDlgButton(IDC_AUTOLINK, linkAuto);

    CheckDlgButton(IDC_SSPEED, linkHacks);

    int player_radio = 0;
    switch (linkNumPlayers) {
    case 2:
        player_radio = IDC_LINK2P;
    case 3:
        player_radio = IDC_LINK3P;
    case 4:
        player_radio = IDC_LINK4P;
    default:
        player_radio = IDC_LINK2P;
    }

    CButton* pButton = (CButton*)GetDlgItem(player_radio);
    pButton->SetCheck(true);

    UpdateAvailability();

    UpdateData(FALSE);

    return TRUE;
}
Ejemplo n.º 7
0
BOOL LinkOptions::OnInitDialog(){
	char timeout[6];

	CDialog::OnInitDialog();

	AddMode("Nothing (Disconnect)", LINK_DISCONNECTED);
	AddMode("Cable - Single Computer", LINK_CABLE_IPC);
	AddMode("Cable - Network", LINK_CABLE_SOCKET);
	AddMode("GameCube - Dolphin", LINK_GAMECUBE_DOLPHIN);
	AddMode("Wireless adapter - Single Computer", LINK_RFU_IPC);

	sprintf(timeout, "%d", theApp.linkTimeout);

	m_timeout.LimitText(5);
	m_timeout.SetWindowText(timeout);

	m_serverip.SetWindowText(theApp.linkHost);

	UpdateAvailability();

	UpdateData(FALSE);

	return TRUE;
}
Ejemplo n.º 8
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(
    int argc,
    char *argv[])
{
    GA_devCtx *dc = NULL;

    /* Now handle the query */
    if (argc >= 2 && stricmp(argv[1],"show") == 0) {
        dc = LoadDriver((argc > 2) ? atoi(argv[2]) : 0);
        ShowSettings(dc);
        }
    else if (argc >= 2 && stricmp(argv[1],"showvbe") == 0) {
        dc = LoadDriver((argc > 2) ? atoi(argv[2]) : 0);
        ShowVBESettings(dc);
        }
    else if (argc >= 5 && stricmp(argv[1],"add") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        AddMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 5 && stricmp(argv[1],"addref") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        AddRefresh(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 5 && stricmp(argv[1],"del") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        DelMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 6 && stricmp(argv[1],"set") == 0) {
        dc = LoadDriver((argc > 6) ? atoi(argv[6]) : 0);
        SetMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]),
            (argc > 7) ? atoi(argv[7]) : 0);
        }
    else
        help();
    if (dc)
        GA_unloadDriver(dc);
    return 0;
}
Ejemplo n.º 9
0
Archivo: Chan.cpp Proyecto: jimloco/znc
void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
	CString sModeArg = sModes.Token(0);
	CString sArgs = sModes.Token(1, true);
	bool bAdd = true;

	/* Try to find a CNick* from this channel so that pOpNick->HasPerm()
	 * works as expected. */
	if (pOpNick) {
		CNick* OpNick = FindNick(pOpNick->GetNick());
		/* If nothing was found, use the original pOpNick, else use the
		 * CNick* from FindNick() */
		if (OpNick)
			pOpNick = OpNick;
	}

	if (pOpNick) {
		NETWORKMODULECALL(OnRawMode(*pOpNick, *this, sModeArg, sArgs), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
	}

	for (unsigned int a = 0; a < sModeArg.size(); a++) {
		const unsigned char& uMode = sModeArg[a];

		if (uMode == '+') {
			bAdd = true;
		} else if (uMode == '-') {
			bAdd = false;
		} else if (m_pNetwork->GetIRCSock()->IsPermMode(uMode)) {
			CString sArg = GetModeArg(sArgs);
			CNick* pNick = FindNick(sArg);
			if (pNick) {
				unsigned char uPerm = m_pNetwork->GetIRCSock()->GetPermFromMode(uMode);

				if (uPerm) {
					if (bAdd) {
						pNick->AddPerm(uPerm);

						if (pNick->GetNick().Equals(m_pNetwork->GetCurNick())) {
							AddPerm(uPerm);
						}
					} else {
						pNick->RemPerm(uPerm);

						if (pNick->GetNick().Equals(m_pNetwork->GetCurNick())) {
							RemPerm(uPerm);
						}
					}
					bool bNoChange = (pNick->HasPerm(uPerm) == bAdd);

					if (uMode && pOpNick) {
						NETWORKMODULECALL(OnChanPermission(*pOpNick, *pNick, *this, uMode, bAdd, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);

						if (uMode == CChan::M_Op) {
							if (bAdd) {
								NETWORKMODULECALL(OnOp(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
							} else {
								NETWORKMODULECALL(OnDeop(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
							}
						} else if (uMode == CChan::M_Voice) {
							if (bAdd) {
								NETWORKMODULECALL(OnVoice(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
							} else {
								NETWORKMODULECALL(OnDevoice(*pOpNick, *pNick, *this, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);
							}
						}
					}
				}
			}
		} else {
			bool bList = false;
			CString sArg;

			switch (m_pNetwork->GetIRCSock()->GetModeType(uMode)) {
				case CIRCSock::ListArg:
					bList = true;
					sArg = GetModeArg(sArgs);
					break;
				case CIRCSock::HasArg:
					sArg = GetModeArg(sArgs);
					break;
				case CIRCSock::NoArg:
					break;
				case CIRCSock::ArgWhenSet:
					if (bAdd) {
						sArg = GetModeArg(sArgs);
					}

					break;
			}

			bool bNoChange;
			if (bList) {
				bNoChange = false;
			} else if (bAdd) {
				bNoChange = HasMode(uMode) && GetModeArg(uMode) == sArg;
			} else {
				bNoChange = !HasMode(uMode);
			}
			NETWORKMODULECALL(OnMode(*pOpNick, *this, uMode, sArg, bAdd, bNoChange), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING);

			if (!bList) {
				(bAdd) ? AddMode(uMode, sArg) : RemMode(uMode);
			}
		}
	}
}
Ejemplo n.º 10
0
void Win32Video::InitDDraw ()
{
	DIRECTDRAWCREATEFUNC directdraw_create;
	LPDIRECTDRAW ddraw1;
	STARTLOG;

	HRESULT dderr;

	// Load the DirectDraw library.
	if ((DDraw_dll = LoadLibraryA ("ddraw.dll")) == NULL)
	{
		I_FatalError ("Could not load ddraw.dll");
	}

	// Obtain an IDirectDraw interface.
	if ((directdraw_create = (DIRECTDRAWCREATEFUNC)GetProcAddress (DDraw_dll, "DirectDrawCreate")) == NULL)
	{
		I_FatalError ("The system file ddraw.dll is missing the DirectDrawCreate export");
	}

	dderr = directdraw_create (NULL, &ddraw1, NULL);

	if (FAILED(dderr))
		I_FatalError ("Could not create DirectDraw object: %08lx", dderr);

	dderr = ddraw1->QueryInterface (IID_IDirectDraw2, (LPVOID*)&DDraw);
	if (FAILED(dderr))
	{
		ddraw1->Release ();
		DDraw = NULL;
		I_FatalError ("Could not initialize IDirectDraw2 interface: %08lx", dderr);
	}

	// Okay, we have the IDirectDraw2 interface now, so we can release the
	// really old-fashioned IDirectDraw one.
	ddraw1->Release ();

	DDraw->SetCooperativeLevel (Window, DDSCL_NORMAL);
	FreeModes ();
	dderr = DDraw->EnumDisplayModes (0, NULL, this, EnumDDModesCB);
	if (FAILED(dderr))
	{
		DDraw->Release ();
		DDraw = NULL;
		I_FatalError ("Could not enumerate display modes: %08lx", dderr);
	}
	if (m_Modes == NULL)
	{
		DDraw->Release ();
		DDraw = NULL;
		I_FatalError ("DirectDraw returned no display modes.\n\n"
					"If you started ZDoom from a fullscreen DOS box, run it from "
					"a DOS window instead. If that does not work, you may need to reboot.");
	}
	if (Args->CheckParm ("-2"))
	{ // Force all modes to be pixel-doubled.
		ScaleModes(1);
	}
	else if (Args->CheckParm ("-4"))
	{ // Force all modes to be pixel-quadrupled.
		ScaleModes(2);
	}
	else
	{
		if (OSPlatform == os_Win95)
		{
			// Windows 95 will let us use Mode X. If we didn't find any linear
			// modes in the loop above, add the Mode X modes here.
			AddMode (320, 200, 8, 200, 0);
			AddMode (320, 240, 8, 240, 0);
		}
		AddLowResModes ();
	}
	AddLetterboxModes ();
}
Ejemplo n.º 11
0
void HeliBrain::CheckOrders (void)
{
	if (underOrders) {
		AddMode(FollowOrdersMode);
	}
}
Ejemplo n.º 12
0
Archivo: vidmode.c Proyecto: aosm/X11
/*ARGSUSED*/
static void
AddVesaModeCallback(Widget w, XtPointer call_data, XtPointer client_data)
{
    xf86cfgVesaModeInfo *vesa = (xf86cfgVesaModeInfo*)call_data;
    XF86VidModeModeInfo mode;
    int num_infos = vidtune->num_infos;

    memcpy(&mode, &vesa->info, sizeof(XF86VidModeModeInfo));
    if (XF86VidModeAddModeLine(XtDisplay(toplevel), vidtune->screen,
			       &vesa->info, &mode)) {
	XSync(XtDisplay(toplevel), False);
	GetModes();
    }
    else {
	XBell(XtDisplayOfObject(w), 80);
	return;
    }

    if (vidtune && num_infos == vidtune->num_infos) {
	/* XF86VidModeAddModeLine returned True, but no modeline was added */
	XBell(XtDisplayOfObject(w), 80);
	if (vidtune->monitor && AddMode()) {
	    XF86ConfModeLinePtr mode;
	    char label[256], *ptr, *str;

	    XmuSnprintf(label, sizeof(label), "%s", vesa->ident);

	    /* format mode name to not have spaces */
	    ptr = strchr(label, ')');
	    if (ptr)
		*++ptr = '\0';
	    ptr = str = label;
	    while (*ptr) {
		if (*ptr != ' ')
		    *str++ = *ptr;
		++ptr;
	    }
	    *str = '\0';

	    if (xf86findModeLine(label, vidtune->monitor->mon_modeline_lst)
		!= NULL && !ForceAddMode())
		return;

	    mode = (XF86ConfModeLinePtr)XtCalloc(1, sizeof(XF86ConfModeLineRec));
	    mode->ml_identifier = XtNewString(label);
	    mode->ml_clock = vesa->info.dotclock;
	    mode->ml_hdisplay = vesa->info.hdisplay;
	    mode->ml_hsyncstart = vesa->info.hsyncstart;
	    mode->ml_hsyncend = vesa->info.hsyncend;
	    mode->ml_htotal = vesa->info.htotal;
	    mode->ml_vdisplay = vesa->info.vdisplay;
	    mode->ml_vsyncstart = vesa->info.vsyncstart;
	    mode->ml_vsyncend = vesa->info.vsyncend;
	    mode->ml_vtotal = vesa->info.vtotal;
/*	    mode->ml_vscan = ???;*/
	    mode->ml_flags = vesa->info.flags;
	    mode->ml_hskew = vesa->info.hskew;
	    vidtune->monitor->mon_modeline_lst =
		xf86addModeLine(vidtune->monitor->mon_modeline_lst, mode);
	}
    }
}
Ejemplo n.º 13
0
void HeliBrain::CollisionCheck(void)
{
float relAz, relEl, range, reactTime;
float hRange    = 200.0F; /* range to miss a hostile tgt / fireball */
float hRangeSq = 40000.0F; /* square of hRange */
//float reactFact = 0.75F; /* fudge factor for reaction time */
float timeToImpact,rngSq,dt,pastRngSq;
float ox,oy,oz,tx,ty,tz;
int    collision;
SimObjectType* obj;
Falcon4EntityClassType* classPtr;
SimObjectLocalData* localData;

   /*----------------------------------------------------------*/
   /* Reaction time is a function of gs available and          */
   /* agression level (gs allowed). 2 seconds is the bare      */
   /* minimum for most situations. Modify with reaction factor */
   /*----------------------------------------------------------*/
   // reactTime = ((GS_LIMIT / af->gsAvail)
   //             + (GS_LIMIT / maxGs)) * reactFact;

   // just hard coded in....
   reactTime = 2.0;

   collision = FALSE;

   /*---------------*/
   /* check objects */
   /*---------------*/
   obj = self->targetList;
   while (obj)
   {
      localData = obj->localData;

      /*-----------------------*/
      /* aircraft objects only */
      /*-----------------------*/
	  classPtr = (Falcon4EntityClassType*)obj->BaseData()->EntityType();
      if (classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_AIRPLANE || 
      	  classPtr->vuClassData.classInfo_[VU_TYPE] == TYPE_HELICOPTER  )
      {
         /*----------------*/
         /* time to impact */
         /*----------------*/
         timeToImpact = (localData->range - hRange) / localData->rangedot;

         /*---------------*/
         /* not a problem */
         /*---------------*/
         if (timeToImpact < 0.0 || timeToImpact > reactTime) 
         {
            obj = obj->next;
            continue;
         }

         /*-------------------------------------------------------------*/
         /* check for close approach. Linearly extrapolate out velocity */
         /* vector for react time.                                      */
         /*-------------------------------------------------------------*/
         pastRngSq = 10.0e7F;
         dt = 0.05F;

         while (dt < reactTime)
         {
            ox = self->XPos() + self->XDelta()*dt;
            oy = self->YPos() + self->YDelta()*dt;
            oz = self->ZPos() + self->ZDelta()*dt;

            tx = obj->BaseData()->XPos() + obj->BaseData()->XDelta()*dt;
            ty = obj->BaseData()->YPos() + obj->BaseData()->YDelta()*dt;
            tz = obj->BaseData()->ZPos() + obj->BaseData()->ZDelta()*dt;

            rngSq = (ox-tx)*(ox-tx) + (oy-ty)*(oy-ty) + (oz-tz)*(oz-tz);

            /*------------------------------------------------*/
            /* collision possible if within hRange of target */
            /*------------------------------------------------*/
            if (rngSq <= hRangeSq)
            {
               collision = TRUE;
               break;
            }
            /*----------------------------------------------*/
            /* break out of loop if range begins to diverge */
            /*----------------------------------------------*/
            if (rngSq > pastRngSq) break;   
            pastRngSq = rngSq;

            dt += 0.1F;
         }

         /*------------------------------*/
         /* take action or bite the dust */
         /*------------------------------*/
         if (collision)
         {
            /*------------------------------------*/
            /* Find a point in the maneuver plane */
            /*------------------------------------*/
            // relEl = 45.0F * DTR;
			relEl = 0.0;
            if (localData->droll > 0.0) relAz = -90.0F * DTR;
            else relAz = 90.0F * DTR;

            range  = 4000.0F;

            GetXYZ (self, relAz, relEl, range,
					&trackX, &trackY, &trackZ);

            AddMode(CollisionAvoidMode);

            break;
         }
      }

      obj = obj->next;
   }

   /*---------------------------------------------*/
   /* exit mode when collision no longer probable */
   /*---------------------------------------------*/
   if (curMode == CollisionAvoidMode && !collision) 
   {
   }
}
Ejemplo n.º 14
0
void DigitalBrain::SeparateCheck(void)
{
float turnRadius, rMaxNe, sepRange;
float gs;
WayPointClass* tmpWaypoint = self->waypoint;
short edata[10];
char inTraining = FALSE;
char aaAbort = FALSE;
char agAbort = FALSE;
char campAbort = FALSE;
char damageAbort = FALSE;



//Cobra test we want to stop AI from aborting in fictional dogfight scenario
if (FalconLocalGame->GetGameType() == game_Dogfight)
return;

   // Check for RTB
   if (((SimDriver.RunningTactical() && current_tactical_mission &&
		   current_tactical_mission->get_type() == tt_training)))
   {
      inTraining = TRUE;
   }
// 2001-08-31 BROUGHT BACK TO LIKE IT IS WAS ORIGINALLY (ALSO LIKE IN RP4/5)
   if (missionClass == AAMission && !IsSetATC(AceGunsEngage))
      aaAbort = FALSE;
// 2002-02-12 added by MN - Aircraftclass checks for target being occupied and sets AWACSsaidAbort
// Do an agAbort here if so
   if (self->AWACSsaidAbort)
   {
	   SetGroundTarget(NULL);
	   agAbort = TRUE;
   }
   
// 2001-12-28 MN this prevents FAC aircraft from aborting missions in 3D (they have no weapons..)
  /* if (missionClass == AGMission && !IsSetATC(HasAGWeapon) && missionType != AMIS_FAC)
   {
      if ((missionType != AMIS_BDA && missionType != AMIS_RECON) || !hasCamera)
// 2001-05-12 ADDED BY S.G. ABORT ONLY WHEN THE MISSION IS NOT COMPLETED OR WE ARE AT THE ATTACK WAYPOINT, OTHERWISE FOLLOW WAYPOINTS HOME
// 2001-06-21 MODIFIED BY S.G. BROUGHT BACK TO WHAT IS RELEASED
//		   if (!missionComplete || !self->curWaypoint || self->curWaypoint->GetWPFlags() & WPF_TARGET)
		   if (!missionComplete)
// END OF ADDED SECTION
	         agAbort = TRUE;
   }*/

   if (missionType == AMIS_ABORT)
      campAbort = TRUE;

  

   if (self->pctStrength < 0.50F)
      damageAbort = TRUE;

   if ((aaAbort || agAbort || campAbort || damageAbort) && !inTraining)
   {
      // If pre IP go to landing, else step past target
      if (curMode != RTBMode && curMode != LandingMode && curMode != TakeoffMode)
      {
         // Drop ground target if any
         if (groundTargetPtr)
         {
            SetGroundTarget (NULL);
         }

// 2001-05-13 MODIFIED BY S.G. TO MAKE IT SIMILAR TO THE ABOVE agAbort CODE
// 2001-06-21 RESTATED BY S.G. BROUGHT BACK TO WHAT IS RELEASED
         if (!IsSetATC(ReachedIP))
//	     if (!missionComplete || !self->curWaypoint || self->curWaypoint->GetWPFlags() & WPF_TARGET)
         {
			 // Find the landing waypoint, and make it the current one
			 while (tmpWaypoint)
			 {
				 if (tmpWaypoint->GetWPAction() == WP_LAND)
				 {
					 break;
				 }
				 tmpWaypoint = tmpWaypoint->GetNextWP();
			 }
			 
			 if (tmpWaypoint && !isWing)
			 {
				 self->curWaypoint = tmpWaypoint;
				 SetWaypointSpecificStuff();
			 }
			 
			 if(!IsSetATC(SaidRTB))
			 {
				 SetATCFlag(SaidRTB);
				 // Call going home
				 edata[0] = isWing;
				 AiMakeRadioResponse( self, rcIMADOT, edata );
			 }
         }
         else
         {
					// Find the waypoint after the target, and make it the current one if
					// we haven't gotten there yet
					tmpWaypoint = self->curWaypoint;
					while (tmpWaypoint)
					{
						// 2001-05-13 MODIFIED BY S.G. WPF_TARGET IS A FLAG WITHIN MANY, DON'T TEST FOR EQUALITY!
						//				 if (tmpWaypoint->GetWPFlags() == WPF_TARGET)
						if (tmpWaypoint->GetWPFlags() & WPF_TARGET)
						{
							tmpWaypoint = tmpWaypoint->GetNextWP();
							break;
						}
						tmpWaypoint = tmpWaypoint->GetNextWP();
					}
					 
					if (tmpWaypoint && !isWing)
					{
						self->curWaypoint = tmpWaypoint;
						SetWaypointSpecificStuff();
					}
					 
					if(!IsSetATC(SaidRTB))
					{
						SetATCFlag(SaidRTB);
						// Call going home
						edata[0] = isWing;
						AiMakeRadioResponse( self, rcIMADOT, edata );
					}
         }
      }
	  if (!isWing) {
		  AddMode (RTBMode);
	  }
   }

   if ((!isWing || IsSetATC(SaidBingo) )&& curMode == RTBMode)
      AddMode (RTBMode);

   if (isWing && mpActionFlags[AI_RTB])
      AddMode (RTBMode);

   if (!targetPtr)
      return;

   // If you can't be offensive, and you have a target/threat, run away
/*   if (targetPtr->localData->range < 10.0F * targetData->ataFrom / (180.0F * DTR))
      AddMode (BugoutMode);
*///me123
 
  

   // go no further unless separation is desired
   if (IsSetATC(SaidBingo)  ||
		curMode == WVREngageMode &&(aaAbort || agAbort || campAbort || damageAbort))
   {
      // Entry
      if (curMode != SeparateMode && targetData->range < 2.0f * NM_TO_FT)
      {
         // Find range where tail chase would begin
         sepRange = RangeAtTailChase(self, targetPtr);

         // Find missile Rmax for a tail chase
         // Final flag True = MRM, False = SRM
         // Skip the check if target has no missiles
         if (targetPtr->BaseData()->IsSim() &&
             (((SimBaseClass*)targetPtr->BaseData())->IsSetFlag(HAS_MISSILES) || targetPtr->localData->range > 2.0F * NM_TO_FT))
            rMaxNe = TailChaseRMaxNe (self, targetPtr, FALSE);
         else
            rMaxNe = 6000.0F;

         // Enter if separation range > rne
         if (rMaxNe < sepRange && IsSetATC(SaidJoker))
         {
            // If inside one turn radius threat needs to be ahead of 3/9 line
            // else behind 3/9 line
            gs = af->SustainedGs(TRUE);
            turnRadius = self->GetVt()*self->GetVt() / ((float)sqrt(gs*gs - 1.0F) * GRAVITY);

            if (targetData->range < turnRadius)
            {
               if (targetData->ata < 90.0*DTR) AddMode(SeparateMode);
            }
            else
            {
               if (targetData->ata > 90.0*DTR) AddMode(SeparateMode);
            }
         }
      }
		else if (targetData->range < 6.0f * NM_TO_FT && 
			targetPtr->localData->rangedot > 0.0f || 
			targetData->range > 6000)// last mode was seperate
		{
		  AddMode(SeparateMode);
		}


   }

	//TJL 11/08/03 Bugout code courtesy of Jam/Mike
   // Is the AI deep six? ataFrom is from target nose.
	if (targetData->ataFrom > 135.0F *DTR && FalconLocalGame->GetGameType() != game_Dogfight)
	{
		if(!bugoutTimer)
		{
			//Set 90 second timer
			bugoutTimer = SimLibElapsedTime + 90000;
		}
		//If not 90 seoncds, do nothing
			if (bugoutTimer > SimLibElapsedTime)
			{
				return;
			}
			else
			{
			//If deep six > 90 seconds, disengage.
			AddMode (BugoutMode);
			}
	}
	else
		{
		//reset our timer
			bugoutTimer = 0;
		}

}