Пример #1
0
/*
========================
AssertFailed
========================
*/
bool AssertFailed( const char* file, int line, const char* expression )
{
	// Set this to true to skip ALL assertions, including ones YOU CAUSE!
	static volatile bool skipAllAssertions = false;
	if( skipAllAssertions )
	{
		return false;
	}
	
	// Set this to true to skip ONLY this assertion
	static volatile bool skipThisAssertion = false;
	skipThisAssertion = false;
	
	for( int i = 0; i < skippedAssertions.Num(); i++ )
	{
		if( skippedAssertions[i].file == file && skippedAssertions[i].line == line )
		{
			skipThisAssertion = true;
			// Set breakpoint here to re-enable
			if( !skipThisAssertion )
			{
				skippedAssertions.RemoveIndexFast( i );
			}
			return false;
		}
	}
	
	idLib::Warning( "ASSERTION FAILED! %s(%d): '%s'", file, line, expression );
	
// RB begin
#ifdef _WIN32
	if( IsDebuggerPresent() || com_assertOutOfDebugger.GetBool() )
#else
	//if( com_assertOutOfDebugger.GetBool() )
#endif
// RB end
	{
#ifdef _WIN32
#ifdef _MSC_VER
		__debugbreak();
#else
		// DG: mingw support
		DebugBreak();
#endif
#else // not _WIN32
		// DG: POSIX support
		raise( SIGTRAP );
		// DG: end
#endif // _WIN32
	}
	
	if( skipThisAssertion )
	{
		skippedAssertion_t* skipped = skippedAssertions.Alloc();
		skipped->file = file;
		skipped->line = line;
	}
	
	return true;
}
Пример #2
0
/*
================================================
idVoiceChatMgr::GetActiveLocalTalkers
================================================
*/
void idVoiceChatMgr::GetActiveLocalTalkers( idStaticList< int, MAX_PLAYERS >& localTalkers )
{

	localTalkers.Clear();
	
	for( int i = 0; i < talkers.Num(); i++ )
	{
	
		if( !talkers[i].IsLocal() )
		{
			continue;
		}
		
		if( !talkers[i].registeredSuccess )
		{
			continue;
		}
		
		if( !TalkerHasData( i ) )
		{
			continue;
		}
		
		localTalkers.Append( i );
	}
}
Пример #3
0
/*
================================================
idVoiceChatMgr::GetRecipientsForTalker
================================================
*/
void idVoiceChatMgr::GetRecipientsForTalker( int talkerIndex, idStaticList< const lobbyAddress_t*, MAX_PLAYERS >& recipients )
{

	recipients.Clear();
	
	talker_t& talker = talkers[talkerIndex];
	
	if( !talker.IsLocal() )
	{
		return;
	}
	
	sendFrame++;
	
	for( int i = 0; i < talkers.Num(); i++ )
	{
		if( !talkers[i].registeredSuccess )
		{
			continue;
		}
		
		if( talkers[i].IsLocal() )
		{
			continue;		// Only want to send to remote talkers
		}
		
		if( !CanSendVoiceTo( talkerIndex, i ) )
		{
			continue;
		}
		
		if( !sendGlobal && talkers[i].groupIndex != activeGroupIndex )
		{
			continue;
		}
		
		assert( talkers[i].machineIndex >= 0 );
		
		remoteMachine_t& remoteMachine = remoteMachines[ talkers[i].machineIndex ];
		
		assert( remoteMachine.refCount > 0 );
		assert( remoteMachine.lobbyType == activeLobbyType );
		
		if( remoteMachine.sendFrame == sendFrame )
		{
			continue;		// Already on the recipient list
		}
		
		remoteMachine.sendFrame = sendFrame;
		
		recipients.Append( &remoteMachine.address );
	}
}
Пример #4
0
/*
========================
AdjustForCushionChannels

In the very common case of having more sounds that would contribute to the
mix than there are available hardware voices, it can be an audible discontinuity
when a channel initially gets a voice or loses a voice.
To avoid this, make sure that the last few hardware voices are mixed with a volume
of zero, so they won't make a difference as they come and go.
It isn't obvious what the exact best volume ramping method should be, just that
it smoothly change frame to frame.
========================
*/
static float AdjustForCushionChannels( const idStaticList< idActiveChannel, MAX_HARDWARE_VOICES >& activeEmitterChannels,
									   const int uncushionedChannels, const float currentCushionDB, const float driftRate )
{

	float	targetCushionDB;
	if( activeEmitterChannels.Num() <= uncushionedChannels )
	{
		// we should be able to hear all of them
		targetCushionDB = DB_SILENCE;
	}
	else
	{
		// we should be able to hear all of them
		targetCushionDB = activeEmitterChannels[uncushionedChannels].channel->volumeDB;
		if( targetCushionDB < DB_SILENCE )
		{
			targetCushionDB = DB_SILENCE;
		}
		else if( targetCushionDB > s_cushionFadeLimit.GetFloat() )
		{
			targetCushionDB = s_cushionFadeLimit.GetFloat();
		}
	}
	
	// linearly drift the currentTargetCushionDB towards targetCushionDB
	float	driftedDB = currentCushionDB;
	if( driftedDB < targetCushionDB )
	{
		driftedDB += driftRate;
		if( driftedDB > targetCushionDB )
		{
			driftedDB = targetCushionDB;
		}
	}
	else
	{
		driftedDB -= driftRate;
		if( driftedDB < targetCushionDB )
		{
			driftedDB = targetCushionDB;
		}
	}
	
	// ramp the lower sound volumes down
	for( int i = 0; i < activeEmitterChannels.Num(); i++ )
	{
		idSoundChannel* chan = activeEmitterChannels[i].channel;
		chan->volumeDB = MapVolumeFromFadeDB( chan->volumeDB, driftedDB );
	}
	
	return driftedDB;
}
/*
========================
idParallelJobManagerLocal::AllocJobList
========================
*/
idParallelJobList* idParallelJobManagerLocal::AllocJobList( jobListId_t id, jobListPriority_t priority, unsigned int maxJobs, unsigned int maxSyncs, const idColor* color )
{
	for( int i = 0; i < jobLists.Num(); i++ )
	{
		if( jobLists[i]->GetId() == id )
		{
			// idStudio may cause job lists to be allocated multiple times
		}
	}
	idParallelJobList* jobList = new( TAG_JOBLIST ) idParallelJobList( id, priority, maxJobs, maxSyncs, color );
	jobLists.Append( jobList );
	return jobList;
}
/*
========================
idParallelJobManagerLocal::WaitForAllJobLists
========================
*/
void idParallelJobManagerLocal::WaitForAllJobLists()
{
	// wait for all job lists to complete
	for( int i = 0; i < jobLists.Num(); i++ )
	{
		jobLists[i]->Wait();
	}
}
/*
========================
idParallelJobManagerLocal::FreeJobList
========================
*/
void idParallelJobManagerLocal::FreeJobList( idParallelJobList* jobList )
{
	if( jobList == NULL )
	{
		return;
	}
	// wait for all job threads to finish because job list deletion is not thread safe
	for( unsigned int i = 0; i < maxThreads; i++ )
	{
		threads[i].WaitForThread();
	}
	int index = jobLists.FindIndex( jobList );
	assert( index >= 0 && jobLists[index] == jobList );
	jobLists[index]->Wait();
	delete jobLists[index];
	jobLists.RemoveIndexFast( index );
}
Пример #8
0
/*
========================
AssertFailed
========================
*/
bool AssertFailed( const char * file, int line, const char * expression ) {
	// Set this to true to skip ALL assertions, including ones YOU CAUSE!
	static volatile bool skipAllAssertions = false;
	if ( skipAllAssertions ) {
		return false;
	}

	// Set this to true to skip ONLY this assertion
	static volatile bool skipThisAssertion = false;
	skipThisAssertion = false;

	for ( int i = 0; i < skippedAssertions.Num(); i++ ) {
		if ( skippedAssertions[i].file == file && skippedAssertions[i].line == line ) {
			skipThisAssertion = true;
			// Set breakpoint here to re-enable
			if ( !skipThisAssertion ) {
				skippedAssertions.RemoveIndexFast( i );
			}
			return false;
		}
	}

	idLib::Warning( "ASSERTION FAILED! %s(%d): '%s'", file, line, expression );

	if ( IsDebuggerPresent() && com_assertOutOfDebugger.GetBool() ) {
			__debugbreak();
	}

	if ( skipThisAssertion ) {
		skippedAssertion_t * skipped = skippedAssertions.Alloc();
		skipped->file = file;
		skipped->line = line;
	}

	return true;
}
Пример #9
0
/*
================
sdVehiclePathGrid::SetupPathPoints
================
*/
void sdVehiclePathGrid::SetupPathPoints( const idVec3& position, idStaticList< idVec3, MAX_SCRIPTENTITY_PATHPOINTS >& pathPoints, int seed, float cornerX, float cornerY ) const {
	int x, y;
	int xmin, ymin;
	GetCoordsForPoint( x, y, xmin, ymin, position );

	int nx, ny;
	GetEdgePoint( x, y, nx, ny, seed, cornerX, cornerY );

	idVec3 edgePos;
	GetPointInternal( nx, ny, edgePos );

	AdjustTargetForStart( edgePos, position, x, y, xmin, ymin );

	bool ymainaxis = abs( ny - y ) > abs( nx - x );

	int loopPos;
	int loopDir;
	int loopStart;
	int loopEnd;
	float loopLen;
	
	if ( ymainaxis ) {
		loopPos		= ny;
		loopStart	= ny;
		loopDir		= ny > y ? -1 : 1;
		loopLen		= ny - y;
		loopEnd		= y;
	} else {
		loopPos		= nx;
		loopStart	= nx;
		loopDir		= nx > x ? -1 : 1;
		loopLen		= nx - x;
		loopEnd		= x;
	}

	idVec3 endPoint;
	GetPoint( x, y, endPoint );

	idVec3 lastPos;
	GetPoint( nx, ny, lastPos );

	idVec3 inVector = ( endPoint - lastPos );
	inVector[ 2 ] = 0.f;
	inVector.Normalize();
	float scale = 64.f; // inVector.Normalize();

	pathPoints.Clear();

	while ( loopPos != loopEnd ) {
		int currentPos[ 2 ];

		loopPos += loopDir;
		float frac = ( loopPos - loopStart ) / loopLen;

		if ( ymainaxis ) {
			currentPos[ 0 ] = nx + ( ( nx - x ) * frac );
			currentPos[ 1 ] = loopPos;
		} else {
			currentPos[ 0 ] = loopPos;
			currentPos[ 1 ] = ny + ( ( ny - y ) * frac );
		}

		idVec3 newPos;
		GetPointInternal( currentPos[ 0 ], currentPos[ 1 ], newPos );

		//AddSection( lastPos, inVector, newPos, endPoint, loopPos != loopEnd, inSpline );
		pathPoints.Append( newPos );
		lastPos = newPos;
	}

	// add the final point
	idVec3 hoverPos = position;
	hoverPos[ 2 ] = lastPos[ 2 ];
	pathPoints.Append( hoverPos );
}
/*
========================
idParallelJobManagerLocal::GetNumFreeJobLists
========================
*/
int idParallelJobManagerLocal::GetNumFreeJobLists() const
{
	return MAX_JOBLISTS - jobLists.Num();
}
/*
========================
idParallelJobManagerLocal::GetNumJobLists
========================
*/
int idParallelJobManagerLocal::GetNumJobLists() const
{
	return jobLists.Num();
}