/* ================ Sys_ClearEvents ================ */ void Sys_ClearEvents() { SDL_Event ev; while (SDL_PollEvent(&ev)) ; kbd_polls.SetNum(0, false); mouse_polls.SetNum(0, false); }
/* ================ Sys_ClearEvents ================ */ void Sys_ClearEvents() { SDL_Event ev; while (SDL_PollEvent(&ev)) ; kbd_polls.SetNum(0, false); mouse_polls.SetNum(0, false); joystick_polls.SetNum(0, false); memset( buttonStates, 0, sizeof( buttonStates ) ); memset( joyAxis, 0, sizeof( joyAxis ) ); event_overflow.SetNum(0, false); }
/* ============ sdStatsTracker::GetTopLifeStats ============ */ void sdStatsTracker::GetTopLifeStats( idList< const lifeStatsData_t* >& improved, idList< const lifeStatsData_t* >& unchanged, idList< const lifeStatsData_t* >& worse ) const { improved.SetNum( 0, false ); unchanged.SetNum( 0, false ); worse.SetNum( 0, false ); for( int i = 0; i < lifeStatsData.Num(); i++ ) { const lifeStatsData_t& data = lifeStatsData[ i ]; switch ( data.newValue.GetType() ) { case sdNetStatKeyValue::SVT_FLOAT: case sdNetStatKeyValue::SVT_FLOAT_MAX: if ( data.newValue.GetFloat() > data.oldValue.GetFloat() ) { improved.Append( &data ); } else if( idMath::Fabs( data.newValue.GetFloat() - data.oldValue.GetFloat() ) < STATS_EPSILON ) { unchanged.Append( &data ); } else { worse.Append( &data ); } break; case sdNetStatKeyValue::SVT_INT: case sdNetStatKeyValue::SVT_INT_MAX: if ( data.newValue.GetInt() > data.oldValue.GetInt() ) { improved.Append( &data ); } else if( data.newValue.GetInt() == data.oldValue.GetInt() ) { unchanged.Append( &data ); } else { worse.Append( &data ); } break; default: assert( false ); break; } } sdQuickSort( improved.Begin(), improved.End(), sdSortPercentageImprovement() ); }
/* ======================== idParallelJobList_Threads::Wait ======================== */ void idParallelJobList_Threads::Wait() { if( jobList.Num() > 0 ) { // don't lock up but return if the job list was never properly submitted if( !verify( !done && signalJobCount.Num() > 0 ) ) { return; } bool waited = false; uint64 waitStart = Sys_Microseconds(); while( signalJobCount[signalJobCount.Num() - 1].GetValue() > 0 ) { Sys_Yield(); waited = true; } version.Increment(); while( numThreadsExecuting.GetValue() > 0 ) { Sys_Yield(); waited = true; } jobList.SetNum( 0 ); signalJobCount.SetNum( 0 ); numSyncs = 0; lastSignalJob = 0; uint64 waitEnd = Sys_Microseconds(); deferredThreadStats.waitTime = waited ? ( waitEnd - waitStart ) : 0; } memcpy( & threadStats, & deferredThreadStats, sizeof( threadStats ) ); done = true; }
/* =============== idClipModel::RestoreTraceModels =============== */ void idClipModel::RestoreTraceModels( idRestoreGame *savefile ) { int i, num; ClearTraceModelCache(); savefile->ReadInt( num ); traceModelCache.SetNum( num ); for( i = 0; i < num; i++ ) { trmCache_t *entry = new trmCache_t; savefile->ReadTraceModel( entry->trm ); savefile->ReadFloat( entry->volume ); savefile->ReadVec3( entry->centerOfMass ); savefile->ReadMat3( entry->inertiaTensor ); entry->refCount = 0; traceModelCache[i] = entry; traceModelHash.Add( GetTraceModelHashKey( entry->trm ), i ); } }
/* ================ Sys_EndMouseInputEvents ================ */ void Sys_EndMouseInputEvents() { mouse_polls.SetNum(0, false); }
/* ================ Sys_EndKeyboardInputEvents ================ */ void Sys_EndKeyboardInputEvents() { kbd_polls.SetNum(0, false); }
void Sys_EndJoystickInputEvents() { joystick_polls.SetNum(0, false); }
/* ======================== idConsoleLocal::DrawOverlayText ======================== */ void idConsoleLocal::DrawOverlayText( float& leftY, float& rightY, float& centerY ) { for( int i = 0; i < overlayText.Num(); i++ ) { const idStr& text = overlayText[i].text; int maxWidth = 0; int numLines = 0; for( int j = 0; j < text.Length(); j++ ) { int width = 1; for( ; j < text.Length() && text[j] != '\n'; j++ ) { width++; } numLines++; if( width > maxWidth ) { maxWidth = width; } } idVec4 bgColor( 0.0f, 0.0f, 0.0f, 0.75f ); const float width = maxWidth * SMALLCHAR_WIDTH; const float height = numLines * ( SMALLCHAR_HEIGHT + 4 ); const float bgAdjust = - 0.5f * SMALLCHAR_WIDTH; if( overlayText[i].justify == JUSTIFY_LEFT ) { renderSystem->DrawFilled( bgColor, LOCALSAFE_LEFT + bgAdjust, leftY, width, height ); } else if( overlayText[i].justify == JUSTIFY_RIGHT ) { renderSystem->DrawFilled( bgColor, LOCALSAFE_RIGHT - width + bgAdjust, rightY, width, height ); } else if( overlayText[i].justify == JUSTIFY_CENTER_LEFT || overlayText[i].justify == JUSTIFY_CENTER_RIGHT ) { renderSystem->DrawFilled( bgColor, LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH - width + bgAdjust ) * 0.5f, centerY, width, height ); } else { assert( false ); } idStr singleLine; for( int j = 0; j < text.Length(); j += singleLine.Length() + 1 ) { singleLine = ""; for( int k = j; k < text.Length() && text[k] != '\n'; k++ ) { singleLine.Append( text[k] ); } if( overlayText[i].justify == JUSTIFY_LEFT ) { DrawTextLeftAlign( LOCALSAFE_LEFT, leftY, "%s", singleLine.c_str() ); } else if( overlayText[i].justify == JUSTIFY_RIGHT ) { DrawTextRightAlign( LOCALSAFE_RIGHT, rightY, "%s", singleLine.c_str() ); } else if( overlayText[i].justify == JUSTIFY_CENTER_LEFT ) { DrawTextLeftAlign( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH - width ) * 0.5f, centerY, "%s", singleLine.c_str() ); } else if( overlayText[i].justify == JUSTIFY_CENTER_RIGHT ) { DrawTextRightAlign( LOCALSAFE_LEFT + ( LOCALSAFE_WIDTH + width ) * 0.5f, centerY, "%s", singleLine.c_str() ); } else { assert( false ); } } } overlayText.SetNum( 0 ); }