예제 #1
0
bool
Assignment::IsControled(void)
{

for(vector<Condition*>::iterator it=GetDomain( )->begin(); it != GetDomain( )->end(); ++it)
   if(!(*it)->IsValue(true))
      return false;
return true;
}
예제 #2
0
파일: check.cpp 프로젝트: casseveritt/sx
static Expr *CheckForGlobalUniformReferences( CgContext *cg, Expr *fExpr, void *arg1, int arg2)
{
  int category, domain, qualifiers;
  Symbol *lSymb;
  Type *lType;
  int gname;
  
  switch (fExpr->kind) {
    case SYMB_N:
      if (static_cast< Symb * >( fExpr )->op == VARIABLE_OP) {
        lSymb = static_cast< Symb * >( fExpr )->symbol;
        lType = static_cast< Symb * >( fExpr )->type;
        category = GetCategory(lType);
        domain = GetDomain(lSymb->type);
        qualifiers = GetQualifiers(lSymb->type);
        if (lSymb->properties & SYMB_NEEDS_BINDING) {
          // This is a non-static global and has not yet been bound
          gname = 0;
          BindDefaultSemantic( cg, lSymb, category, gname);
        }
      }
      break;
    default:
      break;
  }
  return fExpr;
} // CheckForGlobalUniformReferences
예제 #3
0
bool ON_ArcCurve::Extend(
  const ON_Interval& domain
  )

{
  if (IsClosed()) return false;

  double s0, s1;
  bool changed = false;
  GetDomain(&s0, &s1);
  if (domain[0] < s0){
    s0 = domain[0];
    changed = true;
  }
  if (domain[1] > s1){
    s1 = domain[1];
    changed = true;
  }
  if (!changed) return false;

  double a0 = m_arc.Domain().ParameterAt(Domain().NormalizedParameterAt(s0));
  double a1 = m_arc.Domain().ParameterAt(Domain().NormalizedParameterAt(s1));
  if (a1 > a0+2.0*ON_PI) {
    a1 = a0+2.0*ON_PI;
    s1 = Domain().ParameterAt(m_arc.Domain().NormalizedParameterAt(a1));
  }
  m_arc.Trim(ON_Interval(a0, a1));
  SetDomain(s0, s1);
  return true;
}
예제 #4
0
mfxTraceU32 MFXTraceITT_BeginTask(mfxTraceStaticHandle *static_handle
                                ,const char * //file_name
                                ,mfxTraceU32 //line_num
                                ,const char * //function_name
                                ,mfxTraceChar* //category
                                ,mfxTraceLevel level
                                ,const char * task_name
                                ,mfxTraceTaskHandle *handle
                                ,const void * /*task_params*/)
{
    if (!static_handle || !handle) return 1;

    if (MFX_TRACE_LEVEL_API == level ||
        MFX_TRACE_LEVEL_INTERNAL_VTUNE == level)
    {
        // cache string handle across task instances
        if (NULL == static_handle->itt1.ptr)
        {
            static_handle->itt1.ptr = __itt_string_handle_create(task_name);
        }

        // task is traced
        handle->itt1.uint32 = 1;

        __itt_task_begin(GetDomain(), __itt_null, __itt_null,
            (__itt_string_handle*)static_handle->itt1.ptr);
    }

    return 0;
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char * *aEmailAddress)
{
    // use username + "@" + domain for the email address

    nsresult rv;

    nsCAutoString emailAddress;
    nsXPIDLCString username;
    nsXPIDLCString domain;

    rv = GetUsername(getter_Copies(username));
    if (NS_FAILED(rv)) return rv;

    rv = GetDomain(getter_Copies(domain));
    if (NS_FAILED(rv)) return rv;

    if (!username.IsEmpty() && !domain.IsEmpty()) {
        emailAddress = (const char *)username;
        emailAddress += "@";
        emailAddress += (const char *)domain;
    }
    else {
        return NS_ERROR_FAILURE;
    }

    *aEmailAddress = ToNewCString(emailAddress);

    return NS_OK;
}
예제 #6
0
void CFactor::GetDomain( intVector* domain ) const
{
    int domSize;
    const int* dom;
    GetDomain( &domSize, &dom );
    domain->assign( dom, dom + domSize  );
}
예제 #7
0
int BrigadeClass::CheckTactic (int tid)
	{
	Objective	o;

	if (tid < 1)
		return 0;
	if (haveWeaps < 0)
		{
		FalconEntity	*e;
		GridIndex		x,y,dx,dy;

		e = GetTarget();
		if (Engaged() && !e)
			SetEngaged(0);
		if (GetUnitSupply() > 20)
			haveWeaps = 1;
		else
			haveWeaps = 0;
		GetLocation(&x,&y);
		o = GetUnitObjective();
		ourObjOwner = 0;
		if (o && o->GetTeam() == GetTeam())
			ourObjOwner = 1;
		if (o)
			o->GetLocation(&dx,&dy);
		else
			GetUnitDestination(&dx,&dy);
		ourObjDist = FloatToInt32(Distance(x,y,dx,dy));
		}
	if (!CheckUnitType(tid, GetDomain(), GetType()))
		return 0;
	if (!CheckTeam(tid,GetTeam()))
		return 0;
	if (!CheckEngaged(tid,Engaged()))
		return 0;
	if (!CheckCombat(tid,Combat()))
		return 0;
	if (!CheckLosses(tid,Losses()))
		return 0;
	if (!CheckRetreating(tid,Retreating()))
		return 0;
	if (!CheckAction(tid,GetUnitOrders()))
		return 0;
	if (!CheckOwned(tid,ourObjOwner))
		return 0;
	if (TeamInfo[GetTeam()]->GetGroundAction()->actionType != GACTION_OFFENSIVE && !CheckRole(tid,0))
		return 0;
	if (!CheckRange(tid,ourObjDist))
		return 0;
//	if (!CheckDistToFront(tid,ourFrontDist))
//		return 0;
	if (!CheckStatus(tid,Broken()))
		return 0;
//	if (!CheckOdds(tid,odds))
//		return 0;
	return GetTacticPriority(tid);
	}
예제 #8
0
mfxTraceU32 MFXTraceITT_EndTask(mfxTraceStaticHandle * //static_handle
                                ,mfxTraceTaskHandle *handle
                                )
{
    if (!handle) return 1;

    if (1 == handle->itt1.uint32) __itt_task_end(GetDomain());

    return 0;
}
예제 #9
0
BOOL CStation::GetDLGUID(LPCTSTR pszVersionDomain,CString & strGUID)
{
    CDomRS rsTemp;

    strGUID.Empty();
    if(!GetDomain(pszVersionDomain, rsTemp)) {
        return FALSE;
    }

    strGUID = rsTemp.m_VersionId;
    return TRUE;
}
예제 #10
0
파일: gpparam.cpp 프로젝트: Mileslee/wxgis
void wxGISGPParameter::SetSelDomainValue(int nNewSelection)
{
    m_bHasBeenValidated = false;
	m_nSelection = nNewSelection;
	if(m_pDomain)
	{
		switch(m_DataType)
		{
		case enumGISGPParamDTBool:
		case enumGISGPParamDTInteger:
		case enumGISGPParamDTDouble:
		case enumGISGPParamDTText:
		case enumGISGPParamDTSpatRef:
		case enumGISGPParamDTQuery:
        case enumGISGPParamDTFieldAnyChoice:
        case enumGISGPParamDTFieldStringChoice:
        case enumGISGPParamDTFieldIntegerChoice:
        case enumGISGPParamDTFieldRealChoice:
        case enumGISGPParamDTFieldDateChoice:
        case enumGISGPParamDTFieldTimeChoice:
        case enumGISGPParamDTFieldDateTimeChoice:
        case enumGISGPParamDTFieldBinaryChoice:
            SetValue(m_pDomain->GetValue(nNewSelection));
			break;
		case enumGISGPParamDTStringList:
		case enumGISGPParamDTPathArray:
		case enumGISGPParamDTPath:
            {
                //change m_Value ext to filters
                wxString sData = GetValue();
                wxGISGPGxObjectDomain* poDomain = wxDynamicCast(GetDomain(), wxGISGPGxObjectDomain);
                if(poDomain)
                {
                    wxFileName oName(sData);
                    if(oName.IsOk())
                    {
                        if(!oName.HasExt()) //set sel domain
                        {
                            wxGxObjectFilter* poFilter = poDomain->GetFilter(GetSelDomainValue());
                            oName.SetExt(poFilter->GetExt());
                            SetValue(wxVariant(oName.GetFullPath(), wxT("path")));
                        }
                    }
                }
            }
			break;        
		case enumGISGPParamDTUnknown:
		default:
			break;        
		}
	}
}
예제 #11
0
string
Assignment::Print_str()
{
ostringstream   s;
s<<GetRank();
string result=s.str()+" -> "+GetLHSArray()+"["+GetLHSIndex()->Print_str()+"] = "+GetRHSExpression()->Print_str()+";";

string controls;

for(vector<Control*>::iterator it=GetSurroundingControls()->begin(); it != GetSurroundingControls()->end(); ++it)
   controls+="\n\t"+(*it)->Print_str();

string __domain;
for(vector<Condition*>::iterator it=GetDomain()->begin(); it != GetDomain()->end(); ++it)
   __domain+="\n\t"+(*it)->Print_str();

string __counters="\t";
for(vector<string>::iterator it=GetLoopCounters()->begin(); it != GetLoopCounters()->end(); ++it)
   __counters+="\t"+(*it);

result+="\n\n''controls"+controls+"\n\n''domain"+__domain+"\n\n''counters"+__counters;
return result;
}
예제 #12
0
// Divide this curve into two curves at u
bool MH_CrvBezier::Divide(float u, MH_CrvBezier& bezier1, MH_CrvBezier& bezier2) const
{
	size_t nCV = m_vCV.size();
	if(nCV < 2)
		return false;

	float fU[2];
	GetDomain(fU[0], fU[1]);
	if(fU[0] >= u || fU[1] <= u)
		return false;

	MH_CVVect vCV1;
	MH_CVVect vCV2;
	size_t n = nCV-1;
	bool bOK = false;
	MH_CV* pPt3 = new MH_CV[nCV];
	if(!pPt3)
		goto wrapup;

	for(size_t i=0; i<nCV; i++)
		pPt3[i] = m_vCV[i];

	vCV1.push_back(m_vCV.front());
	vCV2.insert(vCV2.begin(), m_vCV.back());

	for(size_t i=1; i<=n; i++)
	{
		for(size_t j=0; j<=n-i; j++)
		{
			pPt3[j] = pPt3[j]*((1-(u-fU[0])/(fU[1]-fU[0]))) + pPt3[j+1]*((u-fU[0])/(fU[1]-fU[0]));
			if(j == 0)
				vCV1.push_back(pPt3[j]);
			if(j == (n-i))
				vCV2.insert(vCV2.begin(), pPt3[j]);
		}
	}

	bezier1.SetCVs(vCV1);
	bezier1.SetDomain(fU[0], u);
    bezier2.SetCVs(vCV2);
	bezier1.SetDomain(u, fU[1]);
	bOK = true;
wrapup:
	if(pPt3)
		delete [] pPt3;
	return bOK;
}
예제 #13
0
int avtGraviTFilter::LoadDomain(int domainId, double ** ppoints, int & numPoints, int ** pedges, int & numEdges)
{
    vtkDataSet * ds2 = GetDomain(domainId , 0);

    vtkCellData * cellData = ds2->GetCellData();
    vtkPolyData * contourPD = (vtkPolyData *) ds2;
    numPoints = contourPD->GetNumberOfPoints();
    vtkCellArray * allFaces = contourPD->GetPolys();

    int contourSize = contourPD->GetNumberOfPoints();
    *ppoints = new double[contourSize * 3];

    double * points = *ppoints;

    for (vtkIdType i = 0; i < contourSize; i++)
    {
        double vtkPts[3] = {0.0, 0.0, 0.0};
        contourPD->GetPoints()->GetPoint(i, vtkPts);

        points[i * 3] = vtkPts[0];
        points[i * 3 + 1] = vtkPts[1];
        points[i * 3 + 2] = vtkPts[2];
    }

    // link the edge

    vtkSmartPointer<vtkIdList> idList = vtkSmartPointer<vtkIdList>::New();
    allFaces->InitTraversal();

    int totalEdges = allFaces->GetNumberOfCells();
    numEdges = totalEdges;
    *pedges = new int[totalEdges * 3];
    int * edges = *pedges;

    for (int i = 0; i < totalEdges; i++)
    {
        allFaces->GetNextCell(idList);
        int v1 = idList->GetId(0) + 1;
        int v2 = idList->GetId(1) + 1;
        int v3 = idList->GetId(2) + 1;

        edges[i * 3] = v1;
        edges[i * 3 + 1] = v2;
        edges[i * 3 + 2] = v3;
    }
    return 0;
}
예제 #14
0
bool INICOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
  {
  if (!(To_Val = value)) {
    sprintf(g->Message, MSG(VALUE_ERROR), Name);
    return true;
  } else if (Buf_Type == value->GetType()) {
    // Values are of the (good) column type
    if (Buf_Type == TYPE_DATE) {
      // If any of the date values is formatted
      // output format must be set for the receiving table
      if (GetDomain() || ((DTVAL *)value)->IsFormatted())
        goto newval;          // This will make a new value;

    } else if (Buf_Type == TYPE_DOUBLE || Buf_Type == TYPE_DECIM)
      // Float values must be written with the correct (column) precision
      // Note: maybe this should be forced by ShowValue instead of this ?
      value->SetPrec(GetScale());

    Value = value;            // Directly access the external value
  } else {
    // Values are not of the (good) column type
    if (check) {
      sprintf(g->Message, MSG(TYPE_VALUE_ERR), Name,
              GetTypeName(Buf_Type), GetTypeName(value->GetType()));
      return true;
      } // endif check

 newval:
    if (InitValue(g))         // Allocate the matching value block
      return true;

  } // endif's Value, Buf_Type

  // Allocate the internal value buffer
  AllocBuf(g);

  // Because Colblk's have been made from a copy of the original TDB in
  // case of Update, we must reset them to point to the original one.
  if (To_Tdb->GetOrig())
    To_Tdb = (PTDB)To_Tdb->GetOrig();

  // Set the Column
  Status = (ok) ? BUF_EMPTY : BUF_NO;
  return false;
  } // end of SetBuffer
예제 #15
0
BOOL NetworkPrefs2Gadgets
(
    struct NetPEditor_DATA *data
)
{
    NNSET(data->netped_deviceString, MUIA_String_Contents, (IPTR)GetDevice());
    NNSET(data->netped_IPString, MUIA_String_Contents, (IPTR)GetIP());
    NNSET(data->netped_maskString, MUIA_String_Contents, (IPTR)GetMask());
    NNSET(data->netped_gateString, MUIA_String_Contents, (IPTR)GetGate());
    NNSET(data->netped_DNSString[0], MUIA_String_Contents, (IPTR)GetDNS(0));
    NNSET(data->netped_DNSString[1], MUIA_String_Contents, (IPTR)GetDNS(1));
    NNSET(data->netped_hostString, MUIA_String_Contents, (IPTR)GetHost());
    NNSET(data->netped_domainString, MUIA_String_Contents, (IPTR)GetDomain());
    NNSET(data->netped_DHCPState, MUIA_Cycle_Active, (IPTR)GetDHCP());
    NNSET(data->netped_Autostart, MUIA_Selected, (IPTR)GetAutostart());

    return TRUE;
}
   bool
   PreSaveLimitationsCheck::CheckLimitations(boost::shared_ptr<DistributionList> list, String &resultDescription)
   {
      boost::shared_ptr<Domain> domain = GetDomain(list->GetDomainID());

      if (GetDuplicateExist(domain, TypeList,list->GetID(), list->GetAddress()))      
         return DuplicateError(resultDescription);

      if (list->GetID() == 0)
      {
         if (domain->GetMaxNoOfDistributionLists()  && 
            domain->GetDistributionLists()->GetCount() >= domain->GetMaxNoOfDistributionLists())
         {
            resultDescription = "The maximum number of distribution lists have been created.";
            return false;
         }
      }

      return true;
   }
   bool
   PreSaveLimitationsCheck::CheckLimitations(boost::shared_ptr<Alias> alias, String &resultDescription)
   {
      boost::shared_ptr<Domain> domain = GetDomain(alias->GetDomainID());

      if (GetDuplicateExist(domain, TypeAlias, alias->GetID(), alias->GetName()))      
         return DuplicateError(resultDescription);

      if (alias->GetID() == 0)
      {
         if (domain->GetMaxNoOfAliasesEnabled() && 
             domain->GetAliases()->GetCount() >= domain->GetMaxNoOfAliases())
         {
            resultDescription = "The maximum number of aliases have been created.";
            return false;
         }
      }


      return true;
   }
예제 #18
0
bool COLBLK::InitValue(PGLOBAL g)
  {
  if (Value)
    return false;                       // Already done

  // Unsigned can be set only for valid value types
  int prec = (Unsigned) ? 1 : GetPrecision();

  // Allocate a Value object
  if (!(Value = AllocateValue(g, Buf_Type, Format.Length,
                                 prec, GetDomain())))
    return true;

  AddStatus(BUF_READY);
  Value->SetNullable(Nullable);

#ifdef DEBTRACE
 htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
  this, Buf_Type, Value, ColUse, Status);
#endif

  return false;
  } // end of InitValue
예제 #19
0
void
UpdateUserModes(struct Luser *user, char *modes)

{
	int PLUS = 1;
	int umode;
	unsigned int ii;

	if (!modes || !user)
		return;

	for (ii = 0; ii < strlen(modes); ii++)
	{
		if (modes[ii] == '+')
		{
			PLUS = 1;
			continue;
		}
		if (modes[ii] == '-')
		{
			PLUS = 0;
			continue;
		}
		umode = 0;
		if (modes[ii] == 'i')
			umode = UMODE_I;
		if (modes[ii] == 's')
			umode = UMODE_S;
		if (modes[ii] == 'w')
			umode = UMODE_W;
		if (modes[ii] == 'o')
			umode = UMODE_O;
#ifdef DANCER

		if (modes[ii] == 'e')
			if (PLUS)
			{
				struct NickInfo* realptr = FindNick(user->nick);
				if (realptr)
				{
					realptr->flags |= NS_IDENTIFIED;
					RecordCommand("User %s has +e umode, marking as identified",user->nick);
					umode = UMODE_E;
				}
				else
				{
					/* Blech, who is screwing with us? */
					toserv(":%s MODE %s -e\r\n", Me.name, user->nick);
					RecordCommand("User %s has +e umode but is not known to me, setting -e",
					              user->nick);
					umode = 0;
				}
			}
#endif /* DANCER */

		if (!umode)
			continue;

		if (PLUS)
		{
			if ((umode == UMODE_O) && (!IsOperator(user)))
			{
#ifdef STATSERVICES
				char *hostname, *domain;
				struct HostHash *hosth, *domainh;
				time_t currtime = current_ts;
#endif

#ifdef NICKSERVICES

				CheckOper(user);
#endif

				Network->TotalOperators++;

				if (SafeConnect)
					SendUmode(OPERUMODE_O,
					          "*** New Operator: %s (%s@%s) [%s]",
					          user->nick,
					          user->username,
					          user->hostname,
					          user->server ? user->server->name : "*unknown*");

#ifdef STATSERVICES

				if (Network->TotalOperators > Network->MaxOperators)
				{
					Network->MaxOperators = Network->TotalOperators;
					Network->MaxOperators_ts = current_ts;

					if ((Network->MaxOperators % 5) == 0)
					{
						/* inform +y people of new max oper count */
						SendUmode(OPERUMODE_Y,
						          "*** New Max Operator Count: %ld",
						          Network->MaxOperators);
						putlog(LOG2, "New Max Operator Count: %ld",
								Network->MaxOperators);
					}
				}
				if (Network->TotalOperators > Network->MaxOperatorsT)
				{
					Network->MaxOperatorsT = Network->TotalOperators;
					Network->MaxOperatorsT_ts = current_ts;
				}
#endif

				if (user->server)
				{
					user->server->numopers++;

#ifdef STATSERVICES

					if (user->server->numopers > user->server->maxopers)
					{
						user->server->maxopers = user->server->numopers;
						user->server->maxopers_ts = current_ts;
					}
#endif

				}

#ifdef STATSERVICES
				hostname = user->hostname;

				if ((hosth = FindHost(hostname)))
				{
					hosth->curropers++;
					if (hosth->curropers > hosth->maxopers)
					{
						hosth->maxopers = hosth->curropers;
						hosth->maxopers_ts = currtime;
					}
				}

				if ((domain = GetDomain(hostname)))
				{
					if ((domainh = FindDomain(domain)))
					{
						domainh->curropers++;
						if (domainh->curropers > domainh->maxopers)
						{
							domainh->maxopers = domainh->curropers;
							domainh->maxopers_ts = currtime;
						}
					}
				}
#endif /* STATSERVICES */

			}
			user->umodes |= umode;
		}
		else
		{
			if ((umode == UMODE_O) && (IsOperator(user)))
			{
#ifdef STATSERVICES
				char *hostname, *domain;
				struct HostHash *hosth, *domainh;
#endif

				Network->TotalOperators--;
				if (user->server)
					user->server->numopers--;

#ifdef STATSERVICES

				hostname = user->hostname;

				if ((hosth = FindHost(hostname)))
					hosth->curropers--;

				if ((domain = GetDomain(hostname)))
					if ((domainh = FindDomain(domain)))
						domainh->curropers--;
#endif

			}
			user->umodes &= ~umode;
		}
	}
} /* UpdateUserModes() */
예제 #20
0
void GroundClass::Init(SimInitDataClass* initData)
{
	SimVehicleClass::Init(initData);

	float nextX, nextY;
	float range, velocity;
	float wp1X, wp1Y, wp1Z;
	float wp2X, wp2Y, wp2Z;
	int i;
	WayPointClass* atWaypoint;
	mlTrig trig;
	VehicleClassDataType* vc;

	vc = GetVehicleClassData(Type() - VU_LAST_ENTITY_TYPE);

    // dustTrail = new DrawableTrail(TRAIL_DUST);
	isFootSquad		= FALSE;
	isEmitter		= FALSE;
	needKeepAlive	= FALSE;

	hasCrew			= (vc->Flags & VEH_HAS_CREW)		? TRUE : FALSE;
	isTowed			= (vc->Flags & VEH_IS_TOWED)		? TRUE : FALSE;
	isShip			= (GetDomain() == DOMAIN_SEA)		? TRUE : FALSE;

	// RV - Biker
	radarDown = false;

	// check for radar emitter
	if ( vc->RadarType != RDR_NO_RADAR ){
		isEmitter = TRUE;
	}

	// 2002-01-20 ADDED BY S.G. At time of creation, 
	// the radar will take the mode of the battalion instead of being 
	// off until it finds a target by itself (and can it find it if its radar is off!).
    // SimVehicleClass::Init created the radar so it's safe to do it here...
	if (isEmitter) {
		if (GetCampaignObject()->GetRadarMode() != FEC_RADAR_OFF) {
			RadarClass *radar = NULL;
			radar = (RadarClass*)FindSensor( this, SensorClass::Radar );
			ShiAssert( radar );
			radar->SetEmitting(TRUE);

			
			// 2002-04-22 MN last fix for FalconSP3 - 
			//this was a good intention to keep a 2D target targetted by a deaggregating unit,
			// however - it doesn't work this way. 
			//The campaign air target derived falconentity does not correlate with the deaggregated aircraft.
			// The SAM's radars would stay stuck at TRACK S1 or 
			//TRACK S3 and won't engage. Symptom was the not changing range to the target (.label 4)
			// Now with this code removed, SAMs should work correctly again. 
			//As we have large SAM bubble sizes - it doesn't really matter if we
			// need to go through all search states in the SIM again - 
			//because SAM's are faster in GUIDE mode than in maximum missile range.
			if (g_bSAM2D3DHandover)
			{
				// 2002-03-21 ADDED BY S.G. In addition, we need to set our radar's target RFN 
				//(right f*cking now) and run a sensor sweep on it so it's valid by the 
				//time TargetProcessing is called.
				FalconEntity	*campTargetEntity = ((UnitClass *)GetCampaignObject())->GetAirTarget();
				if (campTargetEntity)
				{
					SetTarget( new SimObjectType(campTargetEntity) );
					CalcRelAzElRangeAta(this, targetPtr);
					radar->SetDesiredTarget(targetPtr);
					radar->SetFlag(RadarClass::FirstSweep);
					radar->Exec(targetList);
				}				
			}
		}
	}

	SetFlag(ON_GROUND);
	SetPowerOutput(1.0F);	// Assume our motor is running all the time

	SetPosition (initData->x, initData->y, OTWDriver.GetGroundLevel(initData->x, initData->y));
	SetYPR(initData->heading, 0.0F, 0.0F);

	SetupGNDAI (initData);
    
	if (initData->ptIndex){
		// Don't move if we've got an assigned point
		gai->moveState = GNDAI_MOVE_HALTED;
		gai->moveFlags |= GNDAI_MOVE_FIXED_POSITIONS;
	}

	CalcTransformMatrix (this);

	strength        = 100.0F;

	// Check for Campaign mode
	// we don't follow waypoints here
	switch (gai->moveState)
	{
		case GNDAI_MOVE_GENERAL:
		{
			waypoint = curWaypoint = NULL;
			numWaypoints = 0;
			DeleteWPList(initData->waypointList);
			InitFromCampaignUnit();
		}
		break;
		case GNDAI_MOVE_WAYPOINT:
		{
			waypoint        = initData->waypointList;
			numWaypoints    = initData->numWaypoints;
			curWaypoint     = waypoint;
			if (curWaypoint)
			{
				// Corrent initial heading/velocity
				// Find the waypoint to go to.
				atWaypoint = curWaypoint;
				for (i=0; i<initData->currentWaypoint; i++)
				{
					atWaypoint = curWaypoint;
					curWaypoint = curWaypoint->GetNextWP();
				}

				// If current is the on we're at, set for the next one.
				if (curWaypoint == atWaypoint)
					curWaypoint = curWaypoint->GetNextWP();

				atWaypoint->GetLocation (&wp1X, &wp1Y, &wp1Z);

				if (curWaypoint == NULL)
				{
					wp1X = initData->x;
					wp1Y = initData->y;
					curWaypoint = atWaypoint;
					SetDelta (0.0F, 0.0F, 0.0F);
					SetYPRDelta (0.0F, 0.0F, 0.0F);
				}
				else {
					curWaypoint->GetLocation (&wp2X, &wp2Y, &wp2Z);

					SetYPR ((float)atan2 (wp2Y - wp1Y, wp2X - wp1X), 0.0F, 0.0F);

					nextX = wp2X;
					nextY = wp2Y;

					range = (float)sqrt((wp1X - nextX) * (wp1X - nextX) + (wp1Y - nextY) * (wp1Y - nextY));
					velocity = range / ((curWaypoint->GetWPArrivalTime() - SimLibElapsedTime) / SEC_TO_MSEC);

					if ((curWaypoint->GetWPArrivalTime() - SimLibElapsedTime) < 1 * SEC_TO_MSEC)
						velocity = 0.0F;

					// sfr: no need for this anymore
					//SetVt(velocity);
					//SetKias(velocity * FTPSEC_TO_KNOTS);
					mlSinCos (&trig, Yaw());
					SetDelta (velocity * trig.cos, velocity * trig.sin, 0.0F);
					SetYPRDelta (0.0F, 0.0F, 0.0F);
				}
			}
		}
		break;
		default:
		{
			SetDelta (0.0F, 0.0F, 0.0F);
			// sfr: no need for this anymore
			//SetVt(0.0F);
			//SetKias(0.0F);
			SetYPRDelta (0.0F, 0.0F, 0.0F);
			gai->moveState = GNDAI_MOVE_HALTED;
			waypoint = curWaypoint = NULL;
			numWaypoints = 0;
			DeleteWPList(initData->waypointList);
			InitFromCampaignUnit();
		}
		break;
	}

	theInputs   = new PilotInputs;

	// Create our SMS
	Sms = new SMSBaseClass (this, initData->weapon,initData->weapons);

	uchar dam[10] = {100};
	for (i = 0; i < 10; i++){
		dam[i] = 100;
	}
	Sms->SelectBestWeapon (dam, LowAir, -1);
	if (Sms->CurHardpoint() != -1){
		isAirCapable = TRUE;
	}
	else{
		isAirCapable = FALSE;
	}

	Sms->SelectBestWeapon (dam, NoMove, -1);
	if (Sms->CurHardpoint() != -1){
		isGroundCapable = TRUE;
	}
	else {
		isGroundCapable = FALSE;
	}
	Sms->SetCurHardpoint(-1);

	if ((GetType() == TYPE_WHEELED && GetSType() == STYPE_WHEELED_AIR_DEFENSE) ||
		(GetType() == TYPE_WHEELED && GetSType() == STYPE_WHEELED_AAA) ||
		(GetType() == TYPE_TRACKED && GetSType() == STYPE_TRACKED_AIR_DEFENSE) ||
		(GetType() == TYPE_TRACKED && GetSType() == STYPE_TRACKED_AAA) ||
		(GetType() == TYPE_TOWED && GetSType() == STYPE_TOWED_AAA))
	{
		isAirDefense = TRUE;
		// If we're an airdefense thingy, elevate our gun, and point in a random direction
		SetDOF(AIRDEF_ELEV, 60.0f * DTR);
		SetDOF(AIRDEF_ELEV2, 60.0f * DTR);
		SetDOF(AIRDEF_AZIMUTH, 180.0F*DTR - rand()/(float)RAND_MAX * 360.0F*DTR);
	}
	else{
		isAirDefense = FALSE;
	}
}
   bool
   PreSaveLimitationsCheck::CheckLimitations(boost::shared_ptr<Account> account, String &resultDescription)
   {
      if (account->GetVacationMessage().GetLength() > 1000)
      {
         resultDescription = "The auto reply message length exceeds the 1000 character limit.";
         return false;
      }

      if (account->GetAddress().FindOneOf(_T("?*|\\/<>")) >= 0)
      {
         resultDescription = "The characters ?*|\\/<> are not permitted in hMailServer account addresses.";
         return false;
      }


      boost::shared_ptr<Domain> domain = GetDomain(account->GetDomainID());

      if (GetDuplicateExist(domain, TypeAccount, account->GetID(), account->GetAddress()))      
         return DuplicateError(resultDescription);

      if (account->GetID() == 0)
      {
         if (domain->GetMaxNoOfAccountsEnabled() && 
             domain->GetAccounts()->GetCount() >= domain->GetMaxNoOfAccounts())
         {
            resultDescription = "The maximum number of accounts have been created.";
            return false;
         }
      }

      if (domain->GetMaxAccountSize() != 0)
      {
         if (account->GetAccountMaxSize() > domain->GetMaxAccountSize())
         {
            resultDescription = "The account is larger than the maximum account size specified in the domain settings.";
            return false;
         }

         if (account->GetAccountMaxSize() == 0)
         {
            resultDescription = "The domain has a maximum account size set. When this is the case, all accounts in the domains must have an account size set.";
            return false;
         }
      }

      if (domain->GetMaxSizeMB() > 0)
      {

         if (account->GetAccountMaxSize() == 0)
         {
            resultDescription = "The domain has a maximum account size set. When this is the case, all accounts in the domains must have an account size set.";
            return false;
         }

         String sError = "Account could not be saved. The total size of all accounts in the domain would exceed the maximum size for the domain.";
         
         __int64 currentSize = PersistentDomain::GetAllocatedSize(domain);

         if (account->GetID() == 0)
         {
            if (currentSize + account->GetAccountMaxSize() > domain->GetMaxSizeMB())
            {
               resultDescription = sError;
               return false;
            }
         }
         else
         {
            boost::shared_ptr<Account> currentAccountSettings = boost::shared_ptr<Account>(new Account);
            PersistentAccount::ReadObject(currentAccountSettings, account->GetID());

            if (currentSize - currentAccountSettings->GetAccountMaxSize() + account->GetAccountMaxSize() > domain->GetMaxSizeMB())
            {
               resultDescription = sError;
               return false;
            }
         }
      }

      String address = account->GetAddress().ToLower();
      if (address.Find(_T("\\")) >= 0 || address.Find(_T("/")) >= 0)
      {
         resultDescription = "An account name may not contain the characters \\ or /.";
         return false;
      }


      return true;
   }
예제 #22
0
static void
ss_domain(struct Luser *lptr, int ac, char **av)

{
	struct HostHash *hosth;
	char *domain;
	char str[MAXLINE + 1];

	if (ac < 2)
	{
		notice(n_StatServ, lptr->nick,
		       "Syntax: DOMAIN <domain>");
		notice(n_StatServ, lptr->nick,
		       ERR_MORE_INFO,
		       n_StatServ,
		       "DOMAIN");
		return;
	}

	domain = GetDomain(av[1]);

	RecordCommand("%s: %s!%s@%s DOMAIN [%s]",
	              n_StatServ,
	              lptr->nick,
	              lptr->username,
	              lptr->hostname,
	              domain ? domain : av[1]);

	if (!(hosth = FindDomain(domain)))
	{
		notice(n_StatServ, lptr->nick,
		       "No domains matching [\002%s\002] found",
		       domain ? domain : av[1]);
		return;
	}

	notice(n_StatServ, lptr->nick,
	       "Statistics for domain: \002%s\002",
	       domain);
	notice(n_StatServ, lptr->nick,
	       "Current Clients:  %ld (%ld unique)",
	       hosth->currclients,
	       hosth->currunique);
	notice(n_StatServ, lptr->nick,
	       "Current Opers:    %ld",
	       hosth->curropers);

	strlcpy(str, ctime(&hosth->maxclients_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Clients:      %ld on %s",
	       hosth->maxclients,
	       str);

	strlcpy(str, ctime(&hosth->maxunique_ts), sizeof(str));
	str[strlen(str) - 1] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Unique:       %ld on %s",
	       hosth->maxunique,
	       str);

	if (hosth->maxopers_ts)
	{
		strlcpy(str, "on ", sizeof(str));
		strlcat(str, ctime(&hosth->maxopers_ts), sizeof(str));
		str[strlen(str) - 1] = '\0';
	}
	else
		str[0] = '\0';
	notice(n_StatServ, lptr->nick,
	       "Max Operators:    %ld %s",
	       hosth->maxopers,
	       str);

	notice(n_StatServ, lptr->nick,
	       "Identd Users:     %ld",
	       hosth->curridentd);
	notice(n_StatServ, lptr->nick,
	       "Non-Identd Users: %ld",
	       hosth->currclients - hosth->curridentd);
} /* ss_domain() */
예제 #23
0
/*
** GroundClass Exec() function.
** NOTE: returns TRUE if we've processed this frame.  FALSE if we're to do
** dead reckoning (in VU)
*/
int GroundClass::Exec (void)
{
	//RV - I-Hawk - Added a 0 vector for RV new PS calls
	Tpoint PSvec;
	PSvec.x = 0;
	PSvec.y = 0;
	PSvec.z = 0;

	Tpoint pos;
    Tpoint vec;
	float speedScale;
	float groundZ;
	float	labelLOD;
	float	drawLOD;
	RadarClass *radar = NULL;
	
	SoundPos.UpdatePos((SimBaseClass *)this);

	//Cobra
	pos.x = 0.0f;
	pos.y = 0.0f;
	pos.z = 0.0f;
	
	// MLR 5/23/2004 -
	pos.x = XPos();
	pos.y = YPos();
	pos.z = OTWDriver.GetApproxGroundLevel( pos.x, pos.y );
//	pos.z = -10.0f;//Cobra trying to fix the stupid uninit CTD
	SetPosition(pos.x, pos.y, pos.z);

	// dead? -- we do nothing
	if ( IsDead() ){
		return FALSE;
	}

    // if damaged 
	if ( pctStrength < 0.5f ){
		if (sfxTimer > 1.5f - gai->distLOD * 1.3){
			// reset the timer
			sfxTimer = 0.0f;
			pos.z -= 10.0f;

			// VP_changes this shoud be checked why have GetGroundLevel been subtracted by 10.0F
			// Sometimes the trails seem strange
			vec.x = PRANDFloat() * 20.0f;
			vec.y = PRANDFloat() * 20.0f;
			vec.z = PRANDFloat() * 20.0f;
			
			/*
			OTWDriver.AddSfxRequest(
				new SfxClass(
					SFX_TRAILSMOKE,			// type
					SFX_MOVES | SFX_NO_GROUND_CHECK,						// flags
					&pos,							// world pos
					&vec,							// vector
					3.5f,							// time to live
					4.5f					// scale
				)
			);
					*/
			DrawableParticleSys::PS_AddParticleEx((SFX_TRAILSMOKE + 1),
									&pos,
									&vec);
			
		}
	}
	
	if (IsExploding()){
		// KCK: I've never seen this section of code executed. Maybe it gets hit, but I doubt
		// it.
		if (!IsSetFlag( SHOW_EXPLOSION )){
			// Show the explosion
			Tpoint pos, vec;
			Falcon4EntityClassType *classPtr = (Falcon4EntityClassType *)EntityType();
			//DrawableGroundVehicle *destroyedPtr; // FRB

			//Cobra TJL 11/07/04 CTD point initialize here
			pos.x = 0.0f;
			pos.y = 0.0f;
			pos.z = 0.0f;
			
			// MLR 5/23/2004 - uncommented out the x, y
			pos.x = XPos();
			pos.y = YPos();
			pos.z = OTWDriver.GetApproxGroundLevel( pos.x, pos.y ) - 10.0f;
			
			vec.x = 0.0f;
			vec.y = 0.0f;
			vec.z = 0.0f;
			
			// create a new drawable for destroyed vehicle
			// sometimes.....

           //RV - I-Hawk - Commenting all this if statement... not necessary

			/*
			if ( rand() & 1 ){
				destroyedPtr = new DrawableGroundVehicle(
					classPtr->visType[3],
					&pos,
					Yaw(),
					1.0f 
				);
				
				groundZ = PRANDFloatPos() * 60.0f + 15.0f;
				
				/*
				OTWDriver.AddSfxRequest(
					new SfxClass (
						SFX_BURNING_PART,				// type
						&pos,							// world pos
						&vec,							// 
						(DrawableBSP *)destroyedPtr,
						groundZ,							// time to live
						1.0f 	// scale
					)
				);	
						*/
			/*
				DrawableParticleSys::PS_AddParticleEx((SFX_BURNING_PART + 1),
									&pos,
									&vec);
				
				
				pos.z += 10.0f;
				/*
				OTWDriver.AddSfxRequest(
					new SfxClass(
						SFX_FEATURE_EXPLOSION,				// type
						&pos,							// world pos
						groundZ,							// time to live
						100.0f 		// scale
					) 
				);
						*/
			/*
				DrawableParticleSys::PS_AddParticleEx((SFX_FEATURE_EXPLOSION + 1),
									&pos,
									&PSvec);

			}
			*/
			//RV - I-Hawk - seperating explosion type for ground/sea domains. also
			//adding a check so soldiers will not explode like ground vehicles...

            if (GetDomain() == DOMAIN_LAND && GetType() != TYPE_FOOT)
			{		
				//pos.z -= 20.0f;
				/*
				OTWDriver.AddSfxRequest(
					new SfxClass(
						SFX_VEHICLE_EXPLOSION,				// type
						&pos,							// world pos
						1.5f,							// time to live
						100.0f 		// scale
					)
				);
					*/
				DrawableParticleSys::PS_AddParticleEx((SFX_VEHICLE_EXPLOSION + 1),
										&pos,
										&PSvec);
			}
			else if ( GetDomain() == DOMAIN_SEA )
			{
				DrawableParticleSys::PS_AddParticleEx((SFX_WATER_FIREBALL + 1),
										&pos,
										&PSvec);
			}

			// make sure we don't do it again...
			SetFlag( SHOW_EXPLOSION );
			
			// we can now kill it immediately
			SetDead(TRUE);  
		}
		return FALSE;
	}
	
	// exec any base functionality
	SimVehicleClass::Exec();
	
	// Sept 30, 2002
	// VP_changes: Frequently Z value is not in the correct place. It should follow the terrain.
	if ( drawPointer ){
		drawPointer->GetPosition( &pos );
	}
	else {
		return FALSE;
	}

	//JAM 27Sep03 - Let's try this
	groundZ = pos.z;		// - 0.7f; KCK: WTF is this?

	//VP_changes Sept 25
	groundZ = OTWDriver.GetGroundLevel( pos.x, pos.y );


	// Movement/Targeting for local entities
	if (IsLocal() && SimDriver.MotionOn())
	{
		//I commented this out, because it is done in gai->ProcessTargeting down below DSP 4/30/99
		// Refresh our target pointer (if any)
		//SetTarget( SimCampHandoff( targetPtr, targetList, HANDOFF_RANDOM ) );
		// Look for someone to do radar fire control for us
		FindBattalionFireControl();

		// RV - Biker - Switch on lights for ground/naval vehicles
		int isNight = TimeOfDayGeneral(TheCampaign.CurrentTime) < TOD_DAWNDUSK ? true : false;

		if (drawPointer && ((DrawableBSP *)drawPointer)->GetNumSwitches() >= AIRDEF_LIGHT_SWITCH) 
		{
			if (isShip) 
			{
				isNight = (TimeOfDayGeneral(TheCampaign.CurrentTime) <= TOD_DAWNDUSK || realWeather->weatherCondition == INCLEMENT) ? true : false;

				if (pctStrength > 0.50f) 
				{
					((DrawableBSP *)drawPointer)->SetSwitchMask(0, isNight);
					((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, isNight);
				}
			}
			else if (GetVt() > 1.0f) 
			{
				VuListIterator	vehicleWalker(SimDriver.combinedList);
				FalconEntity* object = (FalconEntity*)vehicleWalker.GetFirst();
				bool hasThreat = false;
				float range = 999.9f * NM_TO_FT;

				// Consider each potential target in our environment
				while (object && !hasThreat) 
				{
					// Skip sleeping sim objects
					if (object->IsSim()) 
					{
						if (!((SimBaseClass*)object)->IsAwake()) 
						{
							object = (FalconEntity*)vehicleWalker.GetNext();
							continue;
						}
					}

					// Fow now we skip missles -- might want to display them eventually...
					if (object->IsMissile() || object->IsBomb()) 
					{
						object = (FalconEntity*)vehicleWalker.GetNext();
						continue;
					}

					if (object->GetTeam() == GetTeam()) 
					{
						object = (FalconEntity*)vehicleWalker.GetNext();
						continue;
					}

					float dx = object->XPos() - XPos();
					float dy = object->YPos() - YPos();
					float dz = object->ZPos() - ZPos();

					range = (float)sqrt(dx*dx + dy*dy + dz*dz);

					if (range < 5.0f * NM_TO_FT)
						hasThreat = true;

					object = (FalconEntity*)vehicleWalker.GetNext();
				}

				// If no enemy nearby and not heavy damaged switch on lights
				if (!hasThreat && pctStrength > 0.75f) {
					((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, isNight);
				}
				else 
				{
					((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0);
				}	
			}
			else 
			{
				((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0);
			}
		}

		// RV - Biker - Do also switch on lights for tractor vehicles
		if (truckDrawable && truckDrawable->GetNumSwitches() >= AIRDEF_LIGHT_SWITCH) 
		{
			if (GetVt() > 1.0f) 
			{
				VuListIterator	vehicleWalker(SimDriver.combinedList);
				FalconEntity* object = (FalconEntity*)vehicleWalker.GetFirst();
				bool hasThreat = false;
				float range = 999.9f * NM_TO_FT;

				// Consider each potential target in our environment
				while (object && !hasThreat) 
				{
					// Skip sleeping sim objects
					if (object->IsSim()) 
					{
						if (!((SimBaseClass*)object)->IsAwake()) 
						{
							object = (FalconEntity*)vehicleWalker.GetNext();
							continue;
						}
					}

					// Fow now we skip missles -- might want to display them eventually...
					if (object->IsMissile() || object->IsBomb()) 
					{
						object = (FalconEntity*)vehicleWalker.GetNext();
						continue;
					}

					if (object->GetTeam() == GetTeam()) 
					{
						object = (FalconEntity*)vehicleWalker.GetNext();
						continue;
					}

					float dx = object->XPos() - XPos();
					float dy = object->YPos() - YPos();
					float dz = object->ZPos() - ZPos();

					range = (float)sqrt(dx*dx + dy*dy + dz*dz);

					if (range < 5.0f * NM_TO_FT)
						hasThreat = true;

					object = (FalconEntity*)vehicleWalker.GetNext();
				}

				// If no enemy nearby and not heavy damaged switch on lights
				if (!hasThreat && pctStrength > 0.75f) {
					truckDrawable->SetSwitchMask(AIRDEF_LIGHT_SWITCH, isNight);
				}
				else 
				{
					truckDrawable->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0);
				}
			}
			else 
			{
				truckDrawable->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0);
			}
		}
		
		// RV - Biker - Shut down ship radar if damaged
		if (isShip && radarDown == false && pctStrength < 0.9f && rand()%50 > (pctStrength - 0.50f)*100) 
		{
			isEmitter = false;
			RadarClass *radar = (RadarClass*)FindSensor(this, SensorClass::Radar);
			if (radar) 
			{
				radarDown = true;
				radar->SetDesiredTarget(NULL);
				radar->SetEmitting(FALSE);
			}

			if (targetPtr) 
			{
				SelectWeapon(true);
			}
		}
		
		// 2001-03-26 ADDED BY S.G. NEED TO KNOW IF THE RADAR CALLED SetSpotted
		// RV - Biker - Rotate radars
		float deltaDOF;
		float curDOF = GetDOFValue(5);
		
		deltaDOF = 180.0f * DTR * SimLibMajorFrameTime;
		curDOF += deltaDOF;
		
		if ( curDOF > 360.0f * DTR )
	  		curDOF -= 360.0f * DTR;

		SetDOF(5, curDOF);
		int spottedSet = FALSE;
		// END OF ADDED SECTION

		// 2002-03-21 ADDED BY S.G. 
		// If localData only has zeros, 
		// there is a good chance they are not valid (should not happen here though)... 
		if (targetPtr) {
			SimObjectLocalData* localData= targetPtr->localData;
			if (
				localData->ataFrom == 0.0f && 
				localData->az == 0.0f  && 
				localData->el == 0.0f && 
				localData->range == 0.0f
			) {
				CalcRelAzElRangeAta(this, targetPtr);
			}
		}
		// END OF ADDED SECTION 2002-03-21

		// check for sending radar emmisions
		// 2002-02-26 MODIFIED BY S.G.
		// Added the nextTargetUpdate check to prevent the radar code to run on every frame!
		if ( isEmitter && nextTargetUpdate < SimLibElapsedTime){
			// 2002-02-26 ADDED BY S.G. Next radar scan is 1 sec for aces, 2 for vets, etc ...
			nextTargetUpdate = SimLibElapsedTime + (5 - gai->skillLevel) * SEC_TO_MSEC; 

			radar = (RadarClass*)FindSensor( this, SensorClass::Radar );
			ShiAssert( radar );
			if (radar){
				radar->Exec( targetList );
			}

			// 2001-03-26 ADDED BY S.G. 
			// IF WE CAN SEE THE RADAR'S TARGET AND WE ARE A AIR DEFENSE THINGY 
			// NOT IN A BKOGEN MORAL STATE, MARK IT AS SPOTTED IF WE'RE BRIGHT ENOUGH
			if (
				radar && 
				radar->CurrentTarget() && 
				gai->skillLevel >= 3 && 
				((UnitClass *)GetCampaignObject())->GetSType() == STYPE_UNIT_AIR_DEFENSE && 
				!((UnitClass *)GetCampaignObject())->Broken()
			){
				CampBaseClass *campBaseObj;
				if (radar->CurrentTarget()->BaseData()->IsSim()){
					campBaseObj = ((SimBaseClass *)radar->CurrentTarget()->BaseData())->GetCampaignObject();
				}
				else{
					campBaseObj = (CampBaseClass *)radar->CurrentTarget()->BaseData();
				}

				// JB 011002 If campBaseObj is NULL the target may be chaff
				if (campBaseObj && !(campBaseObj->GetSpotted(GetTeam())) && campBaseObj->IsFlight()){
					RequestIntercept((FlightClass *)campBaseObj, GetTeam());
				}

				spottedSet = TRUE;
				if (campBaseObj && radar->GetRadarDatFile()){
					campBaseObj->SetSpotted(
						GetTeam(), TheCampaign.CurrentTime, 
						(radar->radarData->flag & RAD_NCTR) != 0 && 
						radar->CurrentTarget()->localData && 
						radar->CurrentTarget()->localData->ataFrom < 45.0f * DTR && 
						radar->CurrentTarget()->localData->range < 
						radar->GetRadarDatFile()->MaxNctrRange / (2.0f * (16.0f - (float)gai->skillLevel) / 16.0f)
					);
				}
				// 2002-03-05 MODIFIED BY S.G. target's aspect and skill used in the equation
			}
		// END OF ADDED SECTION
		}

		// 2001-03-26 ADDED BY S.G. 
		// IF THE BATTALION LEAD HAS LOS 
		// ON IT AND WE ARE A AIR DEFENSE THINGY NOT IN A BKOGEN MORAL STATE, 
		// MARK IT AS SPOTTED IF WE'RE BRIGHT ENOUGH
		// 2002-02-11 MODIFED BY S.G. 
		// Since I only identify visually, need to perform this even if spotted by radar in case I can ID it.
		if (
			/*!spottedSet &&  gai->skillLevel >= 3 && */
			((UnitClass *)GetCampaignObject())->GetSType() == STYPE_UNIT_AIR_DEFENSE && 
			gai == gai->battalionCommand && 
			!((UnitClass *)GetCampaignObject())->Broken() && 
			gai->GetAirTargetPtr() && 
			CheckLOS(gai->GetAirTargetPtr())
		){
			CampBaseClass *campBaseObj;
			if (gai->GetAirTargetPtr()->BaseData()->IsSim())
				campBaseObj = ((SimBaseClass *)gai->GetAirTargetPtr()->BaseData())->GetCampaignObject();
			else
				campBaseObj = (CampBaseClass *)gai->GetAirTargetPtr()->BaseData();

			// JB 011002 If campBaseObj is NULL the target may be chaff

			if (!spottedSet && campBaseObj && !(campBaseObj->GetSpotted(GetTeam())) && campBaseObj->IsFlight())
				RequestIntercept((FlightClass *)campBaseObj, GetTeam());

			if (campBaseObj)
				campBaseObj->SetSpotted(GetTeam(),TheCampaign.CurrentTime, 1);
				// 2002-02-11 MODIFIED BY S.G. Visual detection means identified as well
		}
		// END OF ADDED SECTION

		// KCK: When should we run a target update cycle?
		if (SimLibElapsedTime > lastProcess){
			gai->ProcessTargeting();
			lastProcess = SimLibElapsedTime + processRate;
		}

		// KCK: Check if it's ok to think
		if (SimLibElapsedTime > lastThought ){
			// do movement and (possibly) firing....
			gai->Process ();
			lastThought = SimLibElapsedTime + thoughtRate;
		}

		// RV - Biker - Only allow SAM fire if radar still does work
		SimWeaponClass *theWeapon = Sms->GetCurrentWeapon();

		// FRB - This version seems to give SAMs a little more activity
		if(SimLibElapsedTime > nextSamFireTime  && !allowSamFire){
			allowSamFire = TRUE;
		}

		// Biker's version
		//if(SimLibElapsedTime > nextSamFireTime  && !allowSamFire)
		//{
		//	if (radarDown == false || (theWeapon && theWeapon->IsMissile() && theWeapon->sensorArray[0]->Type() == SensorClass::IRST))
		//		allowSamFire = TRUE;
		//}

		// Move and update delta;
		gai->Move_Towards_Dest();
		
		// edg: always insure that our Z position is valid for the entity.
		// the draw pointer should have this value
		// KCK NOTE: The Z we have is actually LAST FRAME's Z. Probably not a big deal.
		SetPosition(
			XPos() + XDelta() * SimLibMajorFrameTime,
			YPos() + YDelta() * SimLibMajorFrameTime,
			groundZ 
		);
		// do firing
		// this also does weapon keep alive
		if ( Sms ){
			gai->Fire();
		}
	}

	// KCK: I simplified this some. This is now speed squared.
	speedScale = XDelta()*XDelta() + YDelta()*YDelta();
	
	// set our level of detail
	if ( gai == gai->battalionCommand ){
		gai->SetDistLOD();
	}
	else{
		gai->distLOD = gai->battalionCommand->distLOD;
	}
	
	// do some extra LOD stuff: if the unit is not a lead veh amd the
	// distLOD is less than a certain value, remove it from the draw
	// list.
	if (drawPointer && gai->rank != GNDAI_BATTALION_COMMANDER){
		// distLOD cutoff by ranking (KCK: This is explicit for testing, could be a formula/table)
		if (gai->rank & GNDAI_COMPANY_LEADER){
			labelLOD = .5F;
			drawLOD = .25F;
		}
		else if (gai->rank & GNDAI_PLATOON_LEADER){
			labelLOD = .925F;
			drawLOD = .5F;
		}
		else {
			labelLOD = 1.1F;
			drawLOD = .75F;
		}

		// RV - Biker - Why do this maybe helpful knowing which vehicle has problems
		// Determine wether to draw label or not
		if (gai->distLOD < labelLOD){
			if (!IsSetLocalFlag(NOT_LABELED)){
				drawPointer->SetLabel ("", 0xff00ff00);		// Don't label
				SetLocalFlag(NOT_LABELED);
			}
		}
		else if (IsSetLocalFlag(NOT_LABELED)){
			SetLabel(this);
			UnSetLocalFlag(NOT_LABELED);
		}

		//if (IsSetLocalFlag(NOT_LABELED)) {
		//	SetLabel(this);
		//	UnSetLocalFlag(NOT_LABELED);
		//}
	}
	
	if (!targetPtr){
		//rotate turret to be pointing forward again
		float maxAz = TURRET_ROTATE_RATE * SimLibMajorFrameTime;
		float maxEl = TURRET_ELEVATE_RATE * SimLibMajorFrameTime;
		float newEl;
		if (isAirDefense){
			newEl = 60.0F*DTR;
		}
		else {
			newEl = 0.0F;
		}

		float delta = newEl - GetDOFValue(AIRDEF_ELEV);
		if(delta > 180.0F*DTR){
			delta -= 180.0F*DTR;
		}
		else if(delta < -180.0F*DTR){
			delta += 180.0F*DTR;
		}

		// Do elevation adjustments
		if (delta > maxEl){
		    SetDOFInc(AIRDEF_ELEV, maxEl);
		}
		else if (delta < -maxEl){
		    SetDOFInc(AIRDEF_ELEV, -maxEl);
		}
		else {
		    SetDOF(AIRDEF_ELEV, newEl);
		}

		SetDOF(AIRDEF_ELEV, min(85.0F*DTR, max(GetDOFValue(AIRDEF_ELEV), 0.0F)));
		SetDOF(AIRDEF_ELEV2, GetDOFValue(AIRDEF_ELEV));
		
		delta = 0.0F - GetDOFValue(AIRDEF_AZIMUTH);
		
		if(delta > 180.0F*DTR){
		    delta -= 180.0F*DTR;
		}
		else if(delta < -180.0F*DTR){
		    delta += 180.0F*DTR;
		}
		
		// Now do the azmuth adjustments
		if (delta > maxAz){
		    SetDOFInc(AIRDEF_AZIMUTH, maxAz);
		}
		else if (delta < -maxAz){
		    SetDOFInc(AIRDEF_AZIMUTH, -maxAz);
		}
		// RV - Biker - Don't do this
		//else
		//	SetDOF(AIRDEF_AZIMUTH, 0.0F);
	}
	
	// Special shit by ground type
	if ( isFootSquad ){
		if ( speedScale > 0.0f ){
			// Couldn't this be done in the drawable class's update function???
			((DrawableGuys*)drawPointer)->SetSquadMoving( TRUE );
		}
		else {
			// Couldn't this be done in the drawable class's update function???
			((DrawableGuys*)drawPointer)->SetSquadMoving( FALSE );
		}
		
		// If we're less than 80% of the way from "FAR" toward the viewer, just draw one guy
		// otherwise, put 5 guys in a squad.
		if (gai->distLOD < 0.8f) {
			((DrawableGuys*)drawPointer)->SetNumInSquad( 1 );
		} 
		else {
			((DrawableGuys*)drawPointer)->SetNumInSquad( 5 );
		}
	} 
	// We're not a foot squad, so do the vehicle stuff
	else if ( !IsSetLocalFlag( IS_HIDDEN ) && speedScale > 300.0f )
	{
		// speedScale /= ( 900.0f * KPH_TO_FPS * KPH_TO_FPS);		// essentially 1.0F at 30 mph

	    // JPO - for engine noise
	    VehicleClassDataType *vc = GetVehicleClassData(Type() - VU_LAST_ENTITY_TYPE);
	    ShiAssert(FALSE == F4IsBadReadPtr(vc, sizeof *vc));
		// (a) Make sound:
		// everything sounds like a tank right now
		if ( GetCampaignObject()->IsBattalion() ){
		    //if (vc)
			if (vc && vc->EngineSound!=34){ // kludge prevent 34 from playing
				SoundPos.Sfx( vc->EngineSound, 0, 1.0, 0); // MLR 5/16/2004 - 
			}
			else{
				SoundPos.Sfx( SFX_TANK, 0, 1.0, 0); // MLR 5/16/2004 - 
			}
			
			// (b) Make dust
			// dustTimer += SimLibMajorFrameTime;
			// if ( dustTimer > max( 0.2f,  4.5f - speedScale - gai->distLOD * 3.3f ) )
			if ( ((rand() & 7) == 7) &&
				gSfxCount[ SFX_GROUND_DUSTCLOUD ] < gSfxLODCutoff &&
				gTotSfx < gSfxLODTotCutoff 
			){
				// reset the timer
				// dustTimer = 0.0f;
				
				pos.x += PRANDFloat() * 5.0f;
				pos.y += PRANDFloat() * 5.0f;
				pos.z = groundZ;

				// RV - Biker - Move that smoke more behind the vehicle 
				mlTrig		trig;
				mlSinCos (&trig, Yaw());

				pos.x -= 15.0f*trig.cos;
				pos.y -= 15.0f*trig.sin;

				vec.x = PRANDFloat() * 5.0f;
				vec.y = PRANDFloat() * 5.0f;
				vec.z = -20.0f;
				
				//JAM 24Oct03 - No dust trails when it's raining.
				if(realWeather->weatherCondition < INCLEMENT){
					/*
					OTWDriver.AddSfxRequest(
						new SfxClass (SFX_VEHICLE_DUST,				// type //JAM 03Oct03
	//					new SfxClass (SFX_GROUND_DUSTCLOUD,			// type
						SFX_USES_GRAVITY | SFX_NO_DOWN_VECTOR | SFX_MOVES | SFX_NO_GROUND_CHECK,
						&pos,							// world pos
						&vec,
						1.0f,							// time to live
						1.f)); //JAM 03Oct03 8.5f ));		// scale
						*/
					DrawableParticleSys::PS_AddParticleEx((SFX_VEHICLE_DUST + 1),
									&pos,
									&vec);
				}
			}
			
			// (c) Make sure we're using our 'Moving' model (i.e. Trucked artillery, APC, etc)
			if (truckDrawable){
				// Keep truck 20 feet behind us (HACK HACK)
				Tpoint		truckPos;
				mlTrig		trig;
				mlSinCos (&trig, Yaw());
				truckPos.x = XPos()-20.0F*trig.cos;
				truckPos.y = YPos()-20.0F*trig.sin;
				truckPos.z = ZPos();
				truckDrawable->Update(&truckPos, Yaw()+PI);
			}

			if (isTowed || hasCrew){
				SetSwitch(0,0x2);
			}
		}
		else // itsa task force
		{
			if (vc){
				SoundPos.Sfx( vc->EngineSound, 0, 1.0, 0);
			}
			else {
				SoundPos.Sfx( SFX_SHIP, 0, 1.0, 0);
			}
			
			//RV - I-Hawk - Do wakes only at some cases
			if ( (rand() & 7) == 7 )
			{
				//I-Hawk - not using all this anymore
				//
				// reset the timer
				// dustTimer = 0.0f;
				//float ttl;
				//static float trailspd = 5.0f;
				//static float bowfx = 0.92f;
				//static float sternfx = 0.75f;
				//float spdratio = GetVt() / ((UnitClass*)GetCampaignObject())->GetMaxSpeed();

				float radius;
				if ( drawPointer ){
					radius = drawPointer->Radius(); // JPO from 0.15 - now done inline
				}
				else{
					radius = 90.0f;
				}
				
				//I-Hawk - Fixed position for ships wakes, effect "delay" in position is 
				//handled by PS now. No more the "V shape" of water wakes.

				pos.x = XPos() + XDelta() * SimLibMajorFrameTime;
				pos.y = YPos() + YDelta() * SimLibMajorFrameTime;
				pos.z = groundZ;

				//// JPO - think this is sideways on.
				///*
				//vec.x = dmx[1][0] * spdratio * PRANDFloat() * trailspd;
				//vec.y = dmx[1][1] * spdratio * PRANDFloat() * trailspd;
				//vec.z = 0.5f; // from -20 JPO
				//*/

				//I-Hawk - More correct vector for wakes
				vec.x = XDelta();
				vec.y = YDelta();
				vec.z = 0.0f;


				//I-Hawk - Separate wake effect for different ships size
				int theSFX;
			
				if ( radius < 200.0f )
				{
					theSFX = SFX_WATER_WAKE_SMALL;
				}

				else if ( radius >= 200.0f && radius < 400.0f )
				{
					theSFX = SFX_WATER_WAKE_MEDIUM;
				}

				else if ( radius >= 400.0f )
				{
					theSFX = SFX_WATER_WAKE_LARGE;
				}
	
				//I-Hawk - The PS
				DrawableParticleSys::PS_AddParticleEx((theSFX + 1),
									&pos,
									&vec);
			}
		}
	}
	// Otherwise, we're not moving or are hidden. Do some stuff
	else {
		// (b) Make sure we're using our 'Holding' model (i.e. Unlimbered artillery, troops prone, etc)
		if (truckDrawable){
			// Once we stop, our truck doesn't move at all - but sits further away than when moving
			Tpoint truckPos;
			truckPos.x = XPos() + 40.0F;
			truckPos.y = YPos();
			truckPos.z = 0.0F;
			truckDrawable->Update(&truckPos, Yaw());
		}
		if (isTowed || hasCrew){
			SetSwitch(0,0x1);
		}
	}
	
	// ACMI Output
    if (gACMIRec.IsRecording() && (SimLibFrameCount & 0x0f ) == 0){
		ACMIGenPositionRecord genPos;
		genPos.hdr.time = SimLibElapsedTime * MSEC_TO_SEC + OTWDriver.todOffset;
		genPos.data.type = Type();
		genPos.data.uniqueID = ACMIIDTable->Add(Id(),NULL,TeamInfo[GetTeam()]->GetColor());//.num_;
		genPos.data.x = XPos();
		genPos.data.y = YPos();
		genPos.data.z = ZPos();
		genPos.data.roll = Roll();
		genPos.data.pitch = Pitch();
		genPos.data.yaw = Yaw();
		// Remove		genPos.data.teamColor = TeamInfo[GetTeam()]->GetColor();
		gACMIRec.GenPositionRecord( &genPos );
	}

	return IsLocal();
}