コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CTeamControlPoint::DrawDebugTextOverlays( void ) 
{
	int text_offset = BaseClass::DrawDebugTextOverlays();

	if (m_debugOverlays & OVERLAY_TEXT_BIT) 
	{
		char tempstr[1024];
		Q_snprintf(tempstr, sizeof(tempstr), "INDEX: (%d)", GetPointIndex() );
		EntityText(text_offset,tempstr,0);
		text_offset++;

		Q_snprintf( tempstr, sizeof(tempstr), "Red Previous Points: ");
		for ( int i = 0; i < MAX_PREVIOUS_POINTS; i++ )
		{
			if ( m_TeamData[2].iszPreviousPoint[i] != NULL_STRING )
			{
				Q_strncat( tempstr, STRING(m_TeamData[2].iszPreviousPoint[i]), 1024, COPY_ALL_CHARACTERS );
				Q_strncat( tempstr, ", ", 1024, COPY_ALL_CHARACTERS );
			}
		}
		EntityText(text_offset,tempstr,0);
		text_offset++;

		Q_snprintf( tempstr, sizeof(tempstr), "Blue Previous Points: " );
		for ( int i = 0; i < MAX_PREVIOUS_POINTS; i++ )
		{
			if ( m_TeamData[3].iszPreviousPoint[i] != NULL_STRING )
			{
				Q_strncat( tempstr, STRING(m_TeamData[3].iszPreviousPoint[i]), 1024, COPY_ALL_CHARACTERS );
				Q_strncat( tempstr, ", ", 1024, COPY_ALL_CHARACTERS );
			}
		}
		EntityText(text_offset,tempstr,0);
		text_offset++;

		for ( int i = 0; i < MAX_CONTROL_POINT_TEAMS; i++ )
		{
			if ( ObjectiveResource()->GetBaseControlPointForTeam(i) == GetPointIndex() )
			{
				Q_snprintf(tempstr, sizeof(tempstr), "Base Control Point for Team %d", i );
				EntityText(text_offset,tempstr,0);
				text_offset++;
			}
		}
	}

	return text_offset;
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Purpose: Used by Area caps to set the owner
//-----------------------------------------------------------------------------
void CTeamControlPoint::InputSetOwner( inputdata_t &input )
{
	int iCapTeam = input.value.Int();

	Assert( iCapTeam >= 0 && iCapTeam < GetNumberOfTeams() );

	Assert( input.pCaller );

	if ( GetOwner() == iCapTeam )
		return;

	if ( TeamplayGameRules()->PointsMayBeCaptured() )
	{
		// must be done before setting the owner
		HandleScoring( iCapTeam );

		if ( input.pCaller->IsPlayer() )
		{
			int iCappingPlayer = input.pCaller->entindex();
			InternalSetOwner( iCapTeam, true, 1, &iCappingPlayer );
		}
		else
		{
			InternalSetOwner( iCapTeam, false );
		}

		ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
	}
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: Used by ControlMaster to this point to its default owner
//-----------------------------------------------------------------------------
void CTeamControlPoint::InputReset( inputdata_t &input )
{
	m_flLastContestedAt = -1;
	InternalSetOwner( m_iDefaultOwner, false );
	ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
	TeamplayRoundBasedRules()->RecalculateControlPointState();
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::InternalSetLocked( bool bLocked )
{
	if ( !bLocked && m_bLocked )
	{
		// unlocked this point
		IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_unlocked" );
		if ( event )
		{
			event->SetInt( "cp", m_iPointIndex );
			event->SetString( "cpname", STRING( m_iszPrintName ) );
			event->SetInt( "team", m_iTeam );
			gameeventmanager->FireEvent( event );
		}
	}
	else if ( bLocked && !m_bLocked )
	{
		// locked this point
		IGameEvent *event = gameeventmanager->CreateEvent( "teamplay_point_locked" );
		if ( event )
		{
			event->SetInt( "cp", m_iPointIndex );
			event->SetString( "cpname", STRING( m_iszPrintName ) );
			event->SetInt( "team", m_iTeam );
			gameeventmanager->FireEvent( event );
		}
	}

	m_bLocked = bLocked;

	if ( ObjectiveResource() && GetPointIndex() < ObjectiveResource()->GetNumControlPoints() )
	{
		ObjectiveResource()->SetCPLocked( GetPointIndex(), m_bLocked );
		ObjectiveResource()->SetCPUnlockTime( GetPointIndex(), 0.0f );
	}

	if ( !m_bLocked )
	{
		m_flUnlockTime = -1;
		m_OnUnlocked.FireOutput( this, this );
		SetContextThink( NULL, 0, CONTROL_POINT_UNLOCK_THINK );
	}
}
コード例 #5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
float CTeamControlPoint::GetTeamCapPercentage( int iTeam )
{
	int iCappingTeam = ObjectiveResource()->GetCappingTeam( GetPointIndex() );
	if ( iCappingTeam == TEAM_UNASSIGNED )
	{
		// No-one's capping this point.
		if ( iTeam == m_iTeam )
			return 1.0;

		return 0.0;
	}

	float flCapPerc = ObjectiveResource()->GetCPCapPercentage( GetPointIndex() );
	if ( iTeam == iCappingTeam )
		return (1.0 - flCapPerc);
	if ( iTeam == m_iTeam )
		return flCapPerc;

	return 0.0;
}
コード例 #6
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::SetOwner( int iCapTeam, bool bMakeSound, int iNumCappers, int *pCappingPlayers )
{
	if ( TeamplayGameRules()->PointsMayBeCaptured() )
	{
		// must be done before setting the owner
		HandleScoring( iCapTeam );

		InternalSetOwner( iCapTeam, bMakeSound, iNumCappers, pCappingPlayers );
		ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
	}
}
コード例 #7
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::InputSetUnlockTime( inputdata_t &inputdata )
{
	// never lock/unlock the point if we're in waiting for players
	if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->IsInWaitingForPlayers() )
		return;

	int nTime = inputdata.value.Int();

	if ( nTime <= 0 )
	{
		InternalSetLocked( false );
		return;
	}

	m_flUnlockTime = gpGlobals->curtime + nTime;

	if ( ObjectiveResource() )
	{
		ObjectiveResource()->SetCPUnlockTime( GetPointIndex(), m_flUnlockTime );
	}

	SetContextThink( &CTeamControlPoint::UnlockThink, gpGlobals->curtime + 0.1, CONTROL_POINT_UNLOCK_THINK );
}
コード例 #8
0
ファイル: sugeom.c プロジェクト: JohnWStockwellJr/SeisUnix
int main(int argc, char **argv)
{

   cwp_String prefix=NULL; /* Common prefix to build the SPS filenames. */
   cwp_String Rname=NULL;  /* file name for R file                 */
   int numR=0;             /* number of receiver points            */
   FILE *fpR=NULL;         /* file pointer for R file              */
   cwp_String Sname=NULL;  /* file name for S file                 */
   FILE *fpS=NULL;         /* file pointer for S file              */
   int numS=0;             /* number of source points              */
   cwp_String Xname=NULL;  /* file name for X file                 */
   FILE *fpX=NULL;         /* file pointer for X file              */
   int numX=0;             /* number of relation points entries    */
                           /* WARNING: a record can have more than */
                           /*          one relation entry.  E.g. 3D*/
   int rev;                /* SPS revision to process              */

   int   RC;               /* Return code from functions           */
   int   i;                /* Just the "i".                        */
   float scalco;           /* scale factor                         */
   float scalel;           /* scale factor                         */
   float temp;             /* temporary float value                */

   double Xcdp;            /* CDP X Coordinate                     */
   double Ycdp;            /* CDP Y Coordinate                     */
   float ibin;             /* Inline bin size/cdp interval         */
   //float xbin;             /* Xline bin size/ Not used             */

   float dt;               /* sample spacing - I don't need, just check */
   //int nt;                 /* number of points on input trace      */
   cwp_Bool seismic;       /* is this seismic data?      */

   // File control
   int oldfldr;  //  fldr for last trace processed
   int oldskip;  //  still skipping the same fldr?
   int curx;     //  relation entry control
   int curtrl;   //  keeping track of current trace (in case of skip)

   int idxR;     //  Index of receiver station entry
   int idxS;     //  Index of shot point entry
   float recsta; //  receiver station
   //float srcsta; //  source point station

   int nproct = 0; // number of processed traces
   //int nprocf = 0; // number of processed files
        
   /* Initialize */
   initargs(argc, argv);
   requestdoc(1);

   /* Verbose run? */
   if (!getparint("verbose", &verbose))   verbose=0;

   /* get SPS revision to process */
   if (!getparint("rev", &rev))   rev=2;

   /* get inline bin interval     */
   if (!getparfloat("ibin", &ibin))   ibin=0.;

   /* lets prepare the geometry informations */

   /* ==========================================  */
   /* Lets try to get common prefix. ===========  */
   /* ==========================================  */
   getparstring("prefix", &prefix);
   // if ( prefix == NULL )  Who cares?

   /* ==========================================  */
   /* Receiver points information ==============  */
   /* ==========================================  */
   getparstring("rps", &Rname);
   if ( Rname == NULL ) {
      if ( prefix == NULL )
         err("**** Missing required parameter 'rps=', see self-doc");
      //  I have a prefix and need build this file name.
      Rname = calloc(strlen(prefix)+2,sizeof(cwp_String));
      if ( Rname == NULL )
         err("**** Unable to allocate memory for R-File name.");
      strcpy(Rname,prefix);
      strcat(Rname,".r");
   }
   if (verbose)
      warn("Receiver file: %s",Rname);

   fpR = efopen(Rname, "r");
   if ( fpR == NULL )
         err("**** Error opening the receiver information file");

   numR = countRec(fpR, 'R');
   warn("Found %d receiver points entries.",numR);
   if ( numR == 0 )
      err("**** No receiver point information found!!");

   // Allocate area for the receiver informations
   // calloc zero out memory.
   RecInfo = calloc(numR,sizeof(struct PointInfo));
   if ( RecInfo == NULL ){
      err("**** Unable to allocate memory for Receiver Point Informations!!");
   }

   //  Get all Receiver Points info into memory
   RC = getPoints(fpR, 'R', rev, RecInfo);
   if ( RC != numR) {
      warn("Short read for Receiver Point Informations!");
      warn("Read %d receiver points entries instead of expected%d.",RC,numR);
   }
   if (verbose) {
      warn("Stored: %d Receiver Point Informations.",RC);
      for (i=0; i<RC; i++)
          warn("R %10.2f,%10.2f,%4.1f,%10.2lf,%10.2lf,%5.1f",
          RecInfo[i].Line,
          RecInfo[i].Point,
          RecInfo[i].PDepth,
          RecInfo[i].X,
          RecInfo[i].Y,
          RecInfo[i].Elev);
   }


   /* ==========================================  */
   /* Source points information ================  */
   /* ==========================================  */
   getparstring("sps", &Sname);
   if ( Sname == NULL ) {
      if ( prefix == NULL )
         err("**** Missing required parameter 'sps=', see self-doc");
      //  I have a prefix and need build this file name.
      Sname = calloc(strlen(prefix)+2,sizeof(cwp_String));
      if ( Sname == NULL )
         err("**** Unable to allocate memory for S-File name.");
      strcpy(Sname,prefix);
      strcat(Sname,".s");
   }
   if (verbose)
      warn("Source file: %s",Sname);

   fpS = efopen(Sname, "r");
   if ( fpS == NULL )
      err("**** Error opening the source information file");

   numS = countRec(fpS, 'S');
   warn("Found %d source points entries.",numS);
   if ( numS == 0 )
      err("**** No source point information found!!");

   // Allocate area for the Source informations
   // calloc zero out memory.
   SrcInfo = calloc(numS,sizeof(struct PointInfo));
   if ( SrcInfo == NULL ){
      err("**** Unable to allocate memory for Source Point Informations!!");
   }

   //  Get all Source Point info into memory
   RC = getPoints(fpS, 'S', rev, SrcInfo);
   if ( RC != numS) {
      warn("Short read for Source Point Informations!");
      warn("Read %d source point entries instead of expected%d.",RC,numS);
   }
   if (verbose) {
      warn("Stored: %d Source Point Informations.",RC);
      for (i=0; i<RC; i++)
          warn("S %10.2f,%10.2f,%4.1f,%10.2lf,%10.2lf,%5.1f",
          SrcInfo[i].Line,
          SrcInfo[i].Point,
          SrcInfo[i].PDepth,
          SrcInfo[i].X,
          SrcInfo[i].Y,
          SrcInfo[i].Elev);
   }
   /* ------------------------------------------  */

   /* ==========================================  */
   /* Relation (records) information ===========  */
   /* ==========================================  */
   getparstring("xps", &Xname);
   if ( Xname == NULL ) {
      if ( prefix == NULL )
         err("**** Missing required parameter 'xps=', see self-doc");
      //  I have a prefix and need build this file name.
      Xname = calloc(strlen(prefix)+2,sizeof(cwp_String));
      if ( Xname == NULL )
         err("**** Unable to allocate memory for X-File name.");
      strcpy(Xname,prefix);
      strcat(Xname,".x");
   }
   if (verbose)
      warn("Relation file: %s",Xname);

   fpX = efopen(Xname, "r");
   if ( fpX == NULL )
      err("**** Error opening the relation information file");

   numX = countRec(fpX, 'X');
   warn("Found %d relation information entries.",numX);
   if ( numX == 0 )
      err("**** No relation information found!!");

   // Allocate area for the Register informations
   // calloc zero out memory.
   FileInfo = calloc(numX,sizeof(struct RegInfo));
   if ( FileInfo == NULL ){
      err("**** Unable to allocate memory for Registers Informations!!");
   }

   //  Get all Record info into memory
   RC = getFiles(fpX, rev, FileInfo);
   if ( RC != numX) {
      warn("Short read for File Informations!");
      warn("Read %d file entries instead of expected%d.",RC,numX);
   }
   if (verbose) {
      warn("Stored: %d Register Information entries.",RC);
      for (i=0; i<RC; i++)
          warn("X %4d,%1d,%9.1f,%9.1f,%4d,%4d,%1d,%9.1f,%9.1f,%10.1f,%1d",
          FileInfo[i].Num,
          FileInfo[i].Inc,
          FileInfo[i].SLine,
          FileInfo[i].SPoint,
          FileInfo[i].FChan,
          FileInfo[i].TChan,
          FileInfo[i].IncChan,
          FileInfo[i].RLine,
          FileInfo[i].FRecv,
          FileInfo[i].TRecv,
          FileInfo[i].RInc);
   }
   /* ------------------------------------------  */
   /* ==========================================  */
   /* ==========================================  */
   /* ==========================================  */

   /* Get info from first trace */ 
   if (!gettr(&tr))  err("can't get first trace");
   seismic = ISSEISMIC(tr.trid);
   if (seismic) 
   {
      if (verbose)   warn("input is seismic data, trid=%d",tr.trid);
      // dt = ((double) tr.dt)/1000000.0; // Don't use dt
   }
   else 
   {
      if (verbose) warn("input is not seismic data, trid=%d",tr.trid);
      // dt = tr.d1; // Don't use dt
   }

   /* error trapping so that the user can have a default value of dt */
   if (!(dt || getparfloat("dt", &dt))) {
      // dt = .004;  // Don't use dt
      warn("WARNING:  neither dt nor d1 are set, nor is dt getparred!");
      warn("WARNING:  It is not used, just checked!!");
   }

   //nt = tr.ns;
   oldfldr  = 0;  //  fldr for last trace processed
   oldskip = 0;   //  still skipping the same fldr?
   curx = -1;      //  relation entry control
   curtrl = 0;    //  keeping tracl of current trace (in case of skip)

      
   /* ------------------------------------------  */

   /* ==========================================  */
   /* ======  Main loop over traces  ===========  */
   /* ==========================================  */

   do {

      if (tr.fldr != oldfldr) { //  Ok, we have a new fldr.
         // Advance relation entry?
         if 
            (curx+1 < numX && tr.fldr == FileInfo[curx+1].Num) {
            curx++;
            if ( curx == numX ) break;  //  No more relation available.
            // fprintf(stderr,"==> 1-curx %d\n",curx); // Debug
            // Process this one
            if ( verbose )
               warn("** processing fldr=%d",tr.fldr);
            oldfldr = tr.fldr;
            //fprintf(stderr,"==> New file %d: %d\n",curx,tr.fldr); // Debug
         }
         else {  // skip until the next file is found
            if ( tr.fldr != oldskip ) {  //  Skipping new fldr!
               if ( curx+1 == numX) {
                  curx++;
                  break;  //  No more relation available
               }
               warn("** skipping fldr=%d, looking for %d", 
                     tr.fldr,FileInfo[curx+1].Num);
               oldskip = tr.fldr;
            }
            continue;
         }
      }  // (tr.fldr != oldfldr)

      //  Ok, we are processing current fldr
      //  Is this channel within range?
      if ( tr.tracf < FileInfo[curx].FChan ) { // skip this one
         warn("** skipping fldr=%d, tracf=%d, looking for tracf=%d ",
               tr.fldr,tr.tracf,FileInfo[curx].FChan);
         continue;
      }
      else if ( tr.tracf > FileInfo[curx].TChan ) { // <FIXME> still unsure
              if ( curx+1 == numX) { // Is there any more relation info?
                 curx++; // Signal the end of table
                 break;  // Exit, no more relation available
              }
              if ( tr.fldr == FileInfo[curx+1].Num ) { // Is there more info?
                 do {
                    // Advance the register info
                    curx++;
                    if ( tr.tracf >= FileInfo[curx].FChan &&  // If chan ok,
                          tr.tracf <= FileInfo[curx].TChan) { // exit loop
                       break; // Found it
                    }

                 } while (tr.fldr == FileInfo[curx+1].Num);
                 //  Why did I get here?
                 //  do we have a new fldr?
                 if ( tr.tracf < FileInfo[curx].FChan ||
                      tr.tracf > FileInfo[curx].TChan) { // Ok, we have a new fldr.
                    //  skip this trace, look for a new file
                    continue;
                 }

              }
      }

      //  Ok, seems that we are good to process this one.
      //  Lets update the header
      //  We will keep fldr and trcf untoutched
      //  But will update tracl
      curtrl++;
      tr.tracl = curtrl;


      if ( tr.ep == 0 ) // Only if zeroed out, keep otherwise
         tr.ep = FileInfo[curx].SPoint; // No fractionary sp so far.

      tr.cdp = 0;  // not updating it yet

      //  This computes the receiver station 
      //  <FIXME>  Not sure if this use of IncChan is correct. :(
      //  It should group each IncChan channels in a single station
      //  for multicomponent data.  
      recsta = FileInfo[curx].FRecv + 
               (FileInfo[curx].TRecv-FileInfo[curx].FRecv) * 
               ((tr.tracf-FileInfo[curx].FChan)/FileInfo[curx].IncChan)/
               (FileInfo[curx].TChan-FileInfo[curx].FChan);

      //  Get the index of the point at corresponding point  structure
      idxR = GetPointIndex(RecInfo, numR, recsta,FileInfo[curx].RLine);
      idxS = GetPointIndex(SrcInfo, numS, FileInfo[curx].SPoint,
                           FileInfo[curx].SLine);
      // <FIXME> - Take care for information not available!
      // if ( idx[[R|S] < 0 ) { failed!  Skip trace/file! }

      // Avoid division by zero.
      if ( tr.scalel == 0 ) tr.scalel = 1;
      if ( tr.scalco == 0 ) tr.scalco = 1;
      
      // The scale factor
      scalel = 1./tr.scalel;
      scalco = 1./tr.scalco;
      if ( tr.scalel  < 0 )  scalel = -tr.scalel;
      if ( tr.scalco  < 0 )  scalco = -tr.scalco;

      //  Source coordinates
      tr.sx = SrcInfo[idxS].X * scalco;
      tr.sy = SrcInfo[idxS].Y * scalco;
      //  Receiver coordinates
      tr.gx = RecInfo[idxR].X * scalco;
      tr.gy = RecInfo[idxR].Y * scalco;

      if ( ibin != 0 )  {  // compute CDP number

         //  CDP Position (where to store?)
         Xcdp = (RecInfo[idxR].X+SrcInfo[idxS].X)/2.;
         Ycdp = (RecInfo[idxR].Y+SrcInfo[idxS].Y)/2.;

         //  First try for cdp computation.
         //  (may work for 2D straight lines)
         //
         temp = sqrt(pow(Xcdp-RecInfo[0].X,2) + 
                     pow(Ycdp-RecInfo[0].Y,2));
         tr.cdp = 100.5 + temp / ibin;  // 100 is just arbitrary
                                        // .5  if for rounding :P
         // Debug: print cdp# Xcdp Ycdp
         //fprintf(stderr,"cdp %5d  %10.2f  %10.2f\n",tr.cdp,Xcdp,Ycdp);

      }

      // Elevations
      tr.gelev = RecInfo[idxR].Elev * scalel;
      tr.selev = SrcInfo[idxS].Elev * scalel;
      tr.sdepth = SrcInfo[idxS].PDepth * scalel;

      // Offset - The offset signal is just an educated guess.  :/
      tr.offset = sqrt(pow(SrcInfo[idxS].X-RecInfo[idxR].X,2) + 
                       pow(SrcInfo[idxS].Y-RecInfo[idxR].Y,2));
      if ( SrcInfo[idxS].Point > RecInfo[idxR].Point )
         tr.offset = -tr.offset;

      // Assuming all coordinates in UTM projection
      tr.counit = 1;

      tr.sstat = SrcInfo[idxS].StaCor;
      tr.gstat = RecInfo[idxR].StaCor;

      puttr(&tr);
      nproct++; // count processed traces

   } while (gettr(&tr));

   /* ==========================================  */
   /* =========  End of Main loop ==============  */
   /* ==========================================  */

   /* ------------------------------------------  */

   if ( curx >= numX ) {
      warn("***  Last record processed -> fldr %d  ***",oldfldr);
      warn("***  Records after this were discarded ***");
   }

   warn("***  %d traces processed...",nproct);

   return(CWP_Exit());
}
コード例 #9
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::ForceOwner( int iTeam )
{
	InternalSetOwner( iTeam, false, 0, 0 );
	ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
}
コード例 #10
0
//-----------------------------------------------------------------------------
// Purpose: Used by ControlMaster to this point to its default owner
//-----------------------------------------------------------------------------
void CTeamControlPoint::InputReset( inputdata_t &input )
{
	m_flLastContestedAt = -1;
	InternalSetOwner( m_iDefaultOwner, false );
	ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
}
コード例 #11
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::Precache( void )
{
	for ( int i = 0; i < m_TeamData.Count(); i++ )
	{
		// Skip over spectator
		if ( i == TEAM_SPECTATOR )
			continue;

		if ( m_TeamData[i].iszCapSound != NULL_STRING )
		{
			PrecacheScriptSound( STRING(m_TeamData[i].iszCapSound) );
		}

		if ( m_TeamData[i].iszModel != NULL_STRING )
		{
			PrecacheModel( STRING(m_TeamData[i].iszModel) );
		}

		if ( m_TeamData[i].iszIcon != NULL_STRING )
		{
			PrecacheMaterial( STRING( m_TeamData[i].iszIcon ) );
			m_TeamData[i].iIcon = GetMaterialIndex( STRING( m_TeamData[i].iszIcon ) );
			Assert( m_TeamData[i].iIcon != 0 );
		}

		if ( !m_TeamData[i].iIcon )
		{
			Warning( "Invalid hud icon material for team %d in control point '%s' ( point index %d )\n", i, GetDebugName(), GetPointIndex() );
		}

		if ( m_TeamData[i].iszOverlay != NULL_STRING )
		{
			PrecacheMaterial( STRING( m_TeamData[i].iszOverlay ) );
			m_TeamData[i].iOverlay = GetMaterialIndex( STRING( m_TeamData[i].iszOverlay ) );
			Assert( m_TeamData[i].iOverlay != 0 );

			if ( !m_TeamData[i].iOverlay )
			{
				Warning( "Invalid hud overlay material for team %d in control point '%s' ( point index %d )\n", i, GetDebugName(), GetPointIndex() );
			}
		}
	}

	PrecacheScriptSound( STRING( m_iszCaptureStartSound ) );
	PrecacheScriptSound( STRING( m_iszCaptureEndSound ) );
	PrecacheScriptSound( STRING( m_iszCaptureInProgress ) );
	PrecacheScriptSound( STRING( m_iszCaptureInterrupted ) );

	if ( m_iszWarnSound != NULL_STRING )
	{
		PrecacheScriptSound( STRING( m_iszWarnSound ) );
	}

#ifdef TF_DLL
	PrecacheScriptSound( "Announcer.ControlPointContested" );
#endif
}
コード例 #12
0
ファイル: rr_meshpsgap.cpp プロジェクト: dwickeroth/covise
// meshes the ps-part between shroud and tip. will start with three nodes
// across the blade and refine it to FINE (ODD), starting at the blade
// curve para. PARA_FINE_LE up to PARA_FINE_TE, then we'll reduce the number
// of nodes to the number of nodes on the te-line
int MeshRR_PSGapRegion(struct Nodelist *n, struct curve *ml,
struct Ilist *pste, struct Ilist *psnod,
struct region *reg, struct region *reg3,
struct region *reg6, int itip)
{
   int i, j;
   int offset, newnodes;
   int first, last, fine_num, coarse_num = 3;
   int steps4reduc, steps4refin;
   static int ifine[4];

   float u1[3], u2[3];
   float p1[3], p2[3], p[3];
   float alpha, beta, scale, shift, ratio;

   struct Ilist *regnodes;

   int OddExamine(int n);
   int RefineChord(struct Flist *arc1, struct Flist *arc2,
      struct Point *line1, struct Point *line2,
      struct Nodelist *n, struct Ilist *regnodes,
      struct Ilist *nodes0, struct Ilist *nodes1,
      struct Ilist *nodes2, float *p, int istart,
      int iend, int fine, int flag
   #ifdef DEBUG_SSGAP
      , FILE *fp
   #endif
      );

#ifdef DEBUG_SSGAP
   char fn[111];
   FILE *fp;
   static int count = 0;

   sprintf(fn,"rr_debugpsgap_%02d.txt", count++);
   if( (fp = fopen(fn,"w+")) == NULL)
   {
      fprintf(stderr,"Shit happened opening file '%s'!\n",fn);
      exit(-1);
   }
   fprintf(fp,"# MeshRR_PSGapRegion %d\n",count);
   fprintf(stderr," MeshRR_PSGapRegion %d\n",count);
#endif

   // mem. check
   for(i = 1; i < reg->numl; i++)
   {
      if(reg->nodes[i])
      {
         FreeIlistStruct(reg->nodes[i]);
         reg->nodes[i] = NULL;
      }
      reg->nodes[i] = AllocIlistStruct(reg->line[i]->nump+1);
   }
   // nodes[0] will be used to store discretization ratios!
   if(reg->nodes[0])
   {
      FreeIlistStruct(reg->nodes[0]);
      reg->nodes[0] = NULL;
   }
   reg->nodes[0] = AllocIlistStruct(reg->line[1]->nump);
   // domain nodes, all of them.
   if(reg->nodes[reg->numl])
   {
      FreeIlistStruct(reg->nodes[reg->numl]);
      reg->nodes[reg->numl+1] = NULL;
   }
   reg->nodes[reg->numl] = AllocIlistStruct(reg->line[3]->nump * reg->line[1]->nump);
   regnodes = reg->nodes[reg->numl];

   offset = n->num;

#ifdef DEBUG_SSGAP
   fprintf(fp,"# offset = %d\n", offset);
#endif

   // **************************************************
   reg->nodes[1] = CopyIlistStruct(reg3->nodes[2]);
   first = reg6->nodes[0]->num - reg->line[3]->nump;
   for(i = reg6->nodes[0]->num-1; i >= first; i--)
   {
      Add2Ilist(reg->nodes[3], reg6->nodes[0]->list[i]);
   }
#ifdef DEBUG_SSGAP
   fprintf(fp,"# reg->line[3]->nump = %d\n",reg->line[3]->nump);
#endif

   Add2Ilist(reg->nodes[2], reg->nodes[1]->list[0]);
   Add2Ilist(regnodes, reg->nodes[1]->list[0]);
   Add2Ilist(reg->nodes[0], 1);

   // get node index for refining domain (more nodes on chord)
   if(itip == 0)
   {
      if( (ifine[0] = GetPointIndex(reg->para[2]->num, reg->para[2]->list, PARA_FINE_LE, 0))
         < coarse_num)
      {
         ifine[0] = coarse_num;
      }
      // get node index for reducing number of nodes per chord
      ifine[2] = GetPointIndex(reg->para[2]->num, reg->para[2]->list, PARA_FINE_TE, ifine[0]);
      ifine[3] = ifine[2];

      // middle value
      ifine[1] = (ifine[2] + ifine[0])/2;
   }                                              // end itip == 0
   // get and check parameters for mesh refinement
   fine_num = FINE;
   if(fine_num < reg->line[3]->nump) fine_num = reg->line[3]->nump;
   if(OddExamine(fine_num) == EVEN) fine_num++;
   steps4refin = (fine_num - coarse_num)/2;       // reduce by 2 nodes per step
   if((steps4reduc = (fine_num - reg->line[3]->nump)/2)
      > reg->line[1]->nump - ifine[2] - 2)
   {
      fatal("not enough nodes alongside blade surface!");
      exit(-1);
   }

#ifdef DEBUG_SSGAP
   fprintf(fp,"# ifine[0], ifine[1], ifine[2]: %d, %d, %d\n",
      ifine[0], ifine[1], ifine[2]);
#endif
   u1[2] = u2[2] = 0.0;
   p1[2] = p2[2] = p[2] = 0.0;
   // **************************************************
   // create nodes on line between cl and blade surface
   // coarse region (3 nodes p. chord), next to leading edge
   u1[0] = reg->arc[1]->list[1] - reg->arc[2]->list[1];
   u1[1] = reg->line[1]->y[1]   - reg->line[2]->y[1];
   p2[0] = reg->arc[2]->list[1] + 0.5 * u1[0];
   p2[1] = reg->line[2]->y[1]   + 0.5 * u1[1];
#ifdef DEBUG_SSGAP
   fprintf(fp," %f   %f\n", reg->arc[2]->list[0], reg->line[2]->y[0]);
   fprintf(fp," %f   %f\n\n", reg->arc[2]->list[1], reg->line[2]->y[1]);
   fprintf(fp," %f   %f\n", reg->arc[1]->list[0], reg->line[1]->y[0]);
   fprintf(fp," %f   %f\n", reg->arc[1]->list[1], reg->line[1]->y[1]);
#endif
   for(i = 2; i <= ifine[0]; i++)
   {
      scale = (float)(i-2)/(float)(ifine[0]-2);
      shift = (1.0 - scale) * SHIFT;
      u1[0] = reg->arc[1]->list[i] - reg->arc[2]->list[i];
      u1[1] = reg->line[1]->y[i]   - reg->line[2]->y[i];
      p1[0] = reg->arc[2]->list[i] + 0.5 * u1[0];
      p1[1] = reg->line[2]->y[i]   + 0.5 * u1[1];
      p[0]  = p2[0] + shift * (p1[0] - p2[0]);
      p[1]  = p2[1] + shift * (p1[1] - p2[1]);
      p2[0] = p1[0];
      p2[1] = p1[1];
      Add2Ilist(reg->nodes[0], 3);
      // node on cl
      Add2Ilist(regnodes, n->num);
      Add2Ilist(reg->nodes[2], n->num);
      AddNode(n, reg->arc[2]->list[i-1], reg->line[2]->y[i-1], 0.0, ARC);
      // new node
      Add2Ilist(regnodes, n->num);
      AddVNode(n, p, ARC);
      // node on blade surface
      Add2Ilist(regnodes, reg->nodes[1]->list[i-1]);

#ifdef DEBUG_SSGAP
      fprintf(fp,"# scale, shift: %f, %f\n", scale, shift);
      fprintf(fp," %f   %f\n", p[0], p[1]);
      fprintf(fp," %f   %f\n", reg->arc[2]->list[i-1], reg->line[2]->y[i-1]);
      fprintf(fp," %f   %f\n\n", reg->arc[2]->list[i], reg->line[2]->y[i]);
      fprintf(fp," %f   %f\n", reg->arc[1]->list[i], reg->line[1]->y[i]);
      fprintf(fp," %f   %f\n", reg->arc[1]->list[i-1], reg->line[1]->y[i-1]);
      fprintf(fp," %f   %f\n", p[0], p[1]);
#endif
   }                                              // i < ifine[0]

   // **************************************************
   // refine
   steps4refin += ifine[0];
   RefineChord(reg->arc[2], reg->arc[1], reg->line[2], reg->line[1],
      n, regnodes, reg->nodes[0], reg->nodes[2], reg->nodes[1],
      p, ifine[0], steps4refin, coarse_num, REFINE
   #ifdef DEBUG_SSGAP
      , fp
   #endif
      );

   // mesh refined region
   first = 1;
   last  = fine_num - 1;
   alpha = M_PI / (float)(last);
   beta  = M_PI / (float)(ifine[2]-steps4refin-1);
   for(i = steps4refin; i < ifine[2]; i++)
   {
      u1[0] = reg->arc[1]->list[i] - reg->arc[2]->list[i];
      u1[1] = reg->line[1]->y[i]   - reg->line[2]->y[i];
      p1[0] = reg->arc[2]->list[i];
      p1[1] = reg->line[2]->y[i];
      Add2Ilist(reg->nodes[0], fine_num);
      Add2Ilist(regnodes, n->num);
      Add2Ilist(reg->nodes[2], n->num);
      AddVNode(n, p1, ARC);
      ratio = sin(beta*(float)(i-steps4refin));
#ifdef DEBUG_SSGAP
      fprintf(fp,"\n# i: %d, ratio = %f\n",i, ratio);
      fprintf(fp," %f   %f\n", p1[0], p1[1]);
#endif
      for(j = first; j < last; j++)
      {
         scale = (1.0 - ratio) * (0.5 * (1.0- cos(alpha*j))) +
            ratio * (float)(j)/(float)(last);
         p[0]  = p1[0] + u1[0] * scale;
         p[1]  = p1[1] + u1[1] * scale;
         Add2Ilist(regnodes, n->num);
         AddVNode(n, p, ARC);
#ifdef DEBUG_SSGAP
         fprintf(fp," %f   %f\n", p[0], p[1]);
#endif
      }
      Add2Ilist(regnodes, reg->nodes[1]->list[i]);
#ifdef DEBUG_SSGAP
      fprintf(fp," %f   %f\n",
         reg->arc[1]->list[i], reg->line[1]->y[i]);
#endif
   }
   // chord center point
   p[0]  = p1[0] + u1[0] * 0.5;
   p[1]  = p1[1] + u1[1] * 0.5;

   // **************************************************
   // coarsening mesh to number of nodes on te.
   // make number of nodes even, if necessary
   if(OddExamine(fine_num - reg->line[3]->nump) == ODD)
   {
#ifdef DEBUG_SSGAP
      fprintf(fp,"\n# fine_num - reg->line[3]->nump = %d\n",
         fine_num - reg->line[3]->nump);
      fprintf(fp,"# --> make number EVEN!\n");
#endif
      // make number of nodes on chord EVEN
      fine_num--;                                 // make fine_num EVEN

      // interface layer
      i = ifine[2]-1;
      shift = 1.0 - INTERFACE_SHIFT;
      fprintf(fp,"# interface nodes\n");
      p1[0] = reg->arc[2]->list[i]
         + shift * (reg->arc[2]->list[ifine[2]]
         - reg->arc[2]->list[i]);
      p1[1] = reg->line[2]->y[i]
         + shift * (reg->line[2]->y[ifine[2]]
         - reg->line[2]->y[i]);
      u1[0] = DELTA*(reg->arc[1]->list[ifine[2]]
         - reg->arc[2]->list[ifine[2]]);
      u1[1] = DELTA*(reg->line[1]->y[ifine[2]]
         - reg->line[2]->y[ifine[2]]);

      Add2Ilist(reg->nodes[0], fine_num);
      Add2Ilist(regnodes, n->num);
      Add2Ilist(reg->nodes[2], n->num);           // extra node on cl!
      AddVNode(n, p1, ARC);
      last = fine_num-1;
#ifdef DEBUG_SSGAP
      fprintf(fp,"# fine_num = %d\n",fine_num);
      fprintf(fp," %f   %f\n", p1[0], p1[1]);
#endif
      for(i = 1; i < fine_num; i++)
      {
         scale = (float)(i)/(float)(last);
         p[0] = p1[0] + scale*u1[0];
         p[1] = p1[1] + scale*u1[1];
         Add2Ilist(regnodes, n->num);
         AddVNode(n, p, ARC);
#ifdef DEBUG_SSGAP
         fprintf(fp," %f   %f\n", p[0], p[1]);
#endif
      }

      // next chord (EVEN number of nodes)
      fprintf(fp,"\n# new chord (no. %d = ifine[2])\n",ifine[2]);
      p1[0] = reg->arc[2]->list[ifine[2]];
      p1[1] = reg->line[2]->y[ifine[2]];
      u1[0] = reg->arc[1]->list[ifine[2]]
         - reg->arc[2]->list[ifine[2]];
      u1[1] = reg->line[1]->y[ifine[2]]
         - reg->line[2]->y[ifine[2]];
      Add2Ilist(reg->nodes[0], fine_num);
      Add2Ilist(regnodes, n->num);
      Add2Ilist(reg->nodes[2], n->num);
      AddVNode(n, p1, ARC);
      alpha = M_PI / (float)(last);
#ifdef DEBUG_SSGAP
      fprintf(fp," %f   %f\n", p1[0], p1[1]);
#endif
      for(i = 1; i < last; i++)
      {
         scale = 0.5 * (1.0 - cos(alpha*i));
         p[0]  = p1[0] + u1[0] * scale;
         p[1]  = p1[1] + u1[1] * scale;
         Add2Ilist(regnodes, n->num);
         AddVNode(n, p, ARC);
#ifdef DEBUG_SSGAP
         fprintf(fp," %f   %f\n", p[0], p[1]);
#endif
      }
      Add2Ilist(regnodes, reg->nodes[1]->list[ifine[2]]);
#ifdef DEBUG_SSGAP
      fprintf(fp," %f   %f\n",
         reg->arc[1]->list[ifine[2]], reg->line[1]->y[ifine[2]]);
#endif

      ifine[2]++;
      p[0] = p1[0] + u1[0] * 0.5;                 // chord center
      p[1] = p1[1] + u1[1] * 0.5;
   }

   // **************************************************
   // reduce number of nodes on chord to line[3]->nump
   steps4reduc += ifine[2];
#ifdef DEBUG_SSGAP
   fprintf(fp,"\n# steps4reduc = %d\n",steps4reduc);
#endif
   RefineChord(reg->arc[2], reg->arc[1], reg->line[2], reg->line[1],
      n, regnodes, reg->nodes[0], reg->nodes[2], reg->nodes[1],
      p, ifine[2], steps4reduc, fine_num, COARSEN
   #ifdef DEBUG_SSGAP
      , fp
   #endif
      );

   // **************************************************
   // mesh rest of blade to trailing edge
   fine_num = reg->line[3]->nump;
   first = 1;
   last  = fine_num - 1;
   for(i = steps4reduc; i < reg->line[2]->nump-1; i++)
   {
      u1[0] = reg->arc[1]->list[i] - reg->arc[2]->list[i];
      u1[1] = reg->line[1]->y[i]   - reg->line[2]->y[i];
      p1[0] = reg->arc[2]->list[i];
      p1[1] = reg->line[2]->y[i];
      Add2Ilist(reg->nodes[0], fine_num);
      Add2Ilist(regnodes, n->num);
      Add2Ilist(reg->nodes[2], n->num);
      AddVNode(n, p1, ARC);
#ifdef DEBUG_SSGAP
      fprintf(fp,"\n# i: %d\n",i);
      fprintf(fp," %f   %f\n", p1[0], p1[1]);
#endif
      for(j = first; j < last; j++)
      {
         scale = (float)(j)/(float)(last);
         p[0]  = p1[0] + u1[0] * scale;
         p[1]  = p1[1] + u1[1] * scale;
         Add2Ilist(regnodes, n->num);
         AddVNode(n, p, ARC);
#ifdef DEBUG_SSGAP
         fprintf(fp," %f   %f   %f\n", p[0], p[1], scale);
#endif
      }
      Add2Ilist(regnodes, reg->nodes[1]->list[i]);
#ifdef DEBUG_SSGAP
      fprintf(fp," %f   %f\n",
         reg->arc[1]->list[i], reg->line[1]->y[i]);
#endif
   }                                              // end i

   // trailing edge nodes
   Add2Ilist(reg->nodes[0], reg->nodes[3]->num);
   Add2Ilist(reg->nodes[2], reg->nodes[3]->list[0]);
   for(i = 0; i < reg->nodes[3]->num; i++)
   {
      Add2Ilist(regnodes, reg->nodes[3]->list[i]);
   }
   Add2Ilist(reg->nodes[1], reg->nodes[3]->list[reg->nodes[3]->num-1]);
   // **************************************************
   // nodes for boundary conditions
   // periodic boundary (ps)
   for(i = 0; i < reg->nodes[2]->num; i++)
   {
      Add2Ilist(pste, reg->nodes[2]->list[i]);
   }
   // solid blade surface
   if(itip == 0)
   {
      for(i = 0; i < regnodes->num; i++)
      {
         Add2Ilist(psnod, regnodes->list[i]);
      }
   }
   // **************************************************
   // final works
   ifine[2] = ifine[3];                           // reset val.
   newnodes = n->num - offset;
   CalcNodeRadius(&n->n[n->num-newnodes], ml, newnodes);
   CalcNodeAngle(&n->n[n->num-newnodes], ml, newnodes);
   // **************************************************

#ifdef DEBUG_SSGAP
   fprintf(fp,"newnodes = %d\n",newnodes);
   fprintf(fp,"pste\n");
   DumpIlist2File(pste, fp);
   fprintf(fp,"psnod\n");
   DumpIlist2File(psnod, fp);

   for(i = 0; i < reg->numl+1; i++)
   {
      fprintf(fp," ** reg->nodes[%d] **\n", i);
      DumpIlist2File(reg->nodes[i], fp);
   }

   fclose(fp);
#endif
   return(0);
}
コード例 #13
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamControlPoint::ForceOwner( int iTeam )
{
	InternalSetOwner( iTeam, false, 0, 0 );
	ObjectiveResource()->SetOwningTeam( GetPointIndex(), m_iTeam );
	TeamplayRoundBasedRules()->RecalculateControlPointState();
}