Exemplo n.º 1
0
/*
===============
CG_SpawnNewTrailSystem

Spawns a new trail system
===============
*/
trailSystem_t *CG_SpawnNewTrailSystem( qhandle_t psHandle )
{
	int               i, j;
	trailSystem_t     *ts = nullptr;
	baseTrailSystem_t *bts = &baseTrailSystems[ psHandle - 1 ];

	if ( !bts->registered )
	{
		Log::Warn( "a trail system has not been registered yet" );
		return nullptr;
	}

	for ( i = 0; i < MAX_TRAIL_SYSTEMS; i++ )
	{
		ts = &trailSystems[ i ];

		if ( !ts->valid )
		{
			memset( ts, 0, sizeof( trailSystem_t ) );

			//found a free slot
			ts->class_ = bts;

			ts->valid = true;
			ts->destroyTime = -1;
			ts->birthTime = cg.time;

			for ( j = 0; j < bts->numBeams; j++ )
			{
				CG_SpawnNewTrailBeam( bts->beams[ j ], ts );
			}

			if ( cg_debugTrails.integer >= 1 )
			{
				Log::Debug( "TS %s created", bts->name );
			}

			return ts;
		}
	}

	if ( cg_debugTrails.integer >= 1 )
	{
		Log::Debug( "MAX_TRAIL_SYSTEMS" );
	}

	return nullptr;
}
Exemplo n.º 2
0
/*
===============
CG_SpawnNewTrailSystem

Spawns a new trail system
===============
*/
trailSystem_t *CG_SpawnNewTrailSystem( qhandle_t psHandle )
{
  int               i, j;
  trailSystem_t     *ts = NULL;
  baseTrailSystem_t *bts = &baseTrailSystems[ psHandle - 1 ];

  if( !bts->registered )
  {
    CG_Printf( S_COLOR_RED "ERROR: a trail system has not been registered yet\n" );
    return NULL;
  }

  for( i = 0; i < MAX_TRAIL_SYSTEMS; i++ )
  {
    ts = &trailSystems[ i ];

    if( !ts->valid )
    {
      memset( ts, 0, sizeof( trailSystem_t ) );

      //found a free slot
      ts->_class = bts;

      ts->valid = true;
      ts->destroyTime = -1;

      for( j = 0; j < bts->numBeams; j++ )
        CG_SpawnNewTrailBeam( bts->beams[ j ], ts );

      if( cg_debugTrails.integer >= 1 )
        CG_Printf( "TS %s created\n", bts->name );

      break;
    }
  }

  return ts;
}