本文整理汇总了C++中Sys_Milliseconds函数的典型用法代码示例。如果您正苦于以下问题:C++ Sys_Milliseconds函数的具体用法?C++ Sys_Milliseconds怎么用?C++ Sys_Milliseconds使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sys_Milliseconds函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Stop
/*
========================
idSoundVoice_OpenAL::Create
========================
*/
void idSoundVoice_OpenAL::Create( const idSoundSample* leadinSample_, const idSoundSample* loopingSample_ )
{
if( IsPlaying() )
{
// This should never hit
Stop();
return;
}
triggered = true;
leadinSample = ( idSoundSample_OpenAL* )leadinSample_;
loopingSample = ( idSoundSample_OpenAL* )loopingSample_;
if( alIsSource( openalSource ) && CompatibleFormat( leadinSample ) )
{
sampleRate = leadinSample->format.basic.samplesPerSec;
}
else
{
DestroyInternal();
formatTag = leadinSample->format.basic.formatTag;
numChannels = leadinSample->format.basic.numChannels;
sampleRate = leadinSample->format.basic.samplesPerSec;
//soundSystemLocal.hardware.pXAudio2->CreateSourceVoice( &pSourceVoice, ( const WAVEFORMATEX* )&leadinSample->format, XAUDIO2_VOICE_USEFILTER, 4.0f, &streamContext );
CheckALErrors();
alGenSources( 1, &openalSource );
if( CheckALErrors() != AL_NO_ERROR )
//if( pSourceVoice == NULL )
{
// If this hits, then we are most likely passing an invalid sample format, which should have been caught by the loader (and the sample defaulted)
return;
}
alSourcef( openalSource, AL_ROLLOFF_FACTOR, 0.0f );
//if( ( loopingSample == NULL && leadinSample->openalBuffer != 0 ) || ( loopingSample != NULL && soundShader->entries[0]->hardwareBuffer ) )
if( leadinSample->openalBuffer != 0 )
{
alSourcei( openalSource, AL_BUFFER, 0 );
// handle uncompressed (non streaming) single shot and looping sounds
/*
if( triggered )
{
alSourcei( openalSource, AL_BUFFER, looping ? chan->soundShader->entries[0]->openalBuffer : leadinSample->openalBuffer );
}
*/
}
else
{
//if( triggered )
// handle streaming sounds (decode on the fly) both single shot AND looping
alSourcei( openalSource, AL_BUFFER, 0 );
alDeleteBuffers( 3, &lastopenalStreamingBuffer[0] );
lastopenalStreamingBuffer[0] = openalStreamingBuffer[0];
lastopenalStreamingBuffer[1] = openalStreamingBuffer[1];
lastopenalStreamingBuffer[2] = openalStreamingBuffer[2];
alGenBuffers( 3, &openalStreamingBuffer[0] );
/*
if( soundSystemLocal.alEAXSetBufferMode )
{
soundSystemLocal.alEAXSetBufferMode( 3, &chan->openalStreamingBuffer[0], alGetEnumValue( ID_ALCHAR "AL_STORAGE_ACCESSIBLE" ) );
}
*/
openalStreamingBuffer[0];
openalStreamingBuffer[1];
openalStreamingBuffer[2];
}
if( s_debugHardware.GetBool() )
{
if( loopingSample == NULL || loopingSample == leadinSample )
{
idLib::Printf( "%dms: %i created for %s\n", Sys_Milliseconds(), openalSource, leadinSample ? leadinSample->GetName() : "<null>" );
}
else
{
idLib::Printf( "%dms: %i created for %s and %s\n", Sys_Milliseconds(), openalSource, leadinSample ? leadinSample->GetName() : "<null>", loopingSample ? loopingSample->GetName() : "<null>" );
}
}
}
sourceVoiceRate = sampleRate;
//pSourceVoice->SetSourceSampleRate( sampleRate );
//pSourceVoice->SetVolume( 0.0f );
alSourcei( openalSource, AL_SOURCE_RELATIVE, AL_TRUE );
alSource3f( openalSource, AL_POSITION, 0.0f, 0.0f, 0.0f );
//.........这里部分代码省略.........
示例2: Qcommon_Init
//.........这里部分代码省略.........
rcon_password = Cvar_Get("rcon_password", "", CVAR_PRIVATE);
Cmd_AddCommand("z_stats", Z_Stats_f);
//Cmd_AddCommand("setenv", Com_Setenv_f);
Cmd_AddMacro("com_date", Com_Date_m);
Cmd_AddMacro("com_time", Com_Time_m);
Cmd_AddMacro("com_uptime", Com_Uptime_m);
Cmd_AddMacro("com_uptime_long", Com_UptimeLong_m);
Cmd_AddMacro("random", Com_Random_m);
Cmd_AddMacro("com_maplist", Com_MapList_m);
// add any system-wide configuration files
Sys_AddDefaultConfig();
// we need to add the early commands twice, because
// a basedir or cddir needs to be set before execing
// config files, but we want other parms to override
// the settings of the config files
Com_AddEarlyCommands(qfalse);
Sys_Init();
Sys_RunConsole();
FS_Init();
Sys_RunConsole();
// no longer allow CVAR_NOSET modifications
com_initialized = qtrue;
// after FS is initialized, open logfile
logfile_enable->changed = logfile_enable_changed;
logfile_flush->changed = logfile_param_changed;
logfile_name->changed = logfile_param_changed;
logfile_enable_changed(logfile_enable);
// execute configs: default.cfg may come from the packfile, but config.cfg
// and autoexec.cfg must be real files within the game directory
Com_AddConfigFile(COM_DEFAULT_CFG, 0);
Com_AddConfigFile(COM_CONFIG_CFG, FS_TYPE_REAL | FS_PATH_GAME);
Com_AddConfigFile(COM_AUTOEXEC_CFG, FS_TYPE_REAL | FS_PATH_GAME);
Com_AddConfigFile(COM_POSTEXEC_CFG, FS_TYPE_REAL);
Com_AddEarlyCommands(qtrue);
Cmd_AddCommand("lasterror", Com_LastError_f);
Cmd_AddCommand("quit", Com_Quit_f);
#if !USE_CLIENT
Cmd_AddCommand("recycle", Com_Recycle_f);
#endif
srand(Sys_Milliseconds());
Netchan_Init();
NET_Init();
BSP_Init();
CM_Init();
SV_Init();
CL_Init();
TST_Init();
Sys_RunConsole();
// add + commands from command line
if (!Com_AddLateCommands()) {
// if the user didn't give any commands, run default action
char *cmd = COM_DEDICATED ? "dedicated_start" : "client_start";
if ((cmd = Cmd_AliasCommand(cmd)) != NULL) {
Cbuf_AddText(&cmd_buffer, cmd);
Cbuf_Execute(&cmd_buffer);
}
} else {
// the user asked for something explicit
// so drop the loading plaque
SCR_EndLoadingPlaque();
}
// even not given a starting map, dedicated server starts
// listening for rcon commands (create socket after all configs
// are executed to make sure port number is properly set)
if (COM_DEDICATED) {
NET_Config(NET_SERVER);
}
Com_AddConfigFile(COM_POSTINIT_CFG, FS_TYPE_REAL);
Com_Printf("====== " PRODUCT " initialized ======\n\n");
Com_LPrintf(PRINT_NOTICE, APPLICATION " " VERSION ", " __DATE__ "\n");
Com_Printf("http://skuller.net/q2pro/\n\n");
time(&com_startTime);
com_eventTime = Sys_Milliseconds();
}
示例3: Sys_Milliseconds
/*
=================
idSessionLocal::DownloadProgressBox
=================
*/
void idSessionLocal::DownloadProgressBox( backgroundDownload_t *bgl, const char *title, int progress_start, int progress_end ) {
int dlnow = 0, dltotal = 0;
int startTime = Sys_Milliseconds();
int lapsed;
idStr sNow, sTotal, sBW, sETA, sMsg;
if ( !BoxDialogSanityCheck() ) {
return;
}
guiMsg->SetStateString( "visible_msgbox", "1" );
guiMsg->SetStateString( "visible_waitbox", "0" );
guiMsg->SetStateString( "visible_entry", "0" );
guiMsg->SetStateString( "visible_cdkey", "0" );
guiMsg->SetStateString( "mid", "Cancel" );
guiMsg->SetStateString( "visible_mid", "1" );
guiMsg->SetStateString( "visible_left", "0" );
guiMsg->SetStateString( "visible_right", "0" );
guiMsg->SetStateString( "title", title );
guiMsg->SetStateString( "message", "Connecting.." );
guiMsgRestore = guiActive;
guiActive = guiMsg;
msgRunning = true;
while ( 1 ) {
while ( msgRunning ) {
common->GUIFrame( true, false );
if ( bgl->completed ) {
guiActive = guiMsgRestore;
guiMsgRestore = NULL;
return;
} else if ( bgl->url.dltotal != dltotal || bgl->url.dlnow != dlnow ) {
dltotal = bgl->url.dltotal;
dlnow = bgl->url.dlnow;
lapsed = Sys_Milliseconds() - startTime;
sNow.BestUnit( "%.2f", dlnow, MEASURE_SIZE );
if ( lapsed > 2000 ) {
sBW.BestUnit( "%.1f", ( 1000.0f * dlnow ) / lapsed, MEASURE_BANDWIDTH );
} else {
sBW = "-- KB/s";
}
if ( dltotal ) {
sTotal.BestUnit( "%.2f", dltotal, MEASURE_SIZE );
if ( lapsed < 2000 ) {
sprintf( sMsg, "%s / %s", sNow.c_str(), sTotal.c_str() );
} else {
sprintf( sETA, "%.0f sec", ( (float)dltotal / (float)dlnow - 1.0f ) * lapsed / 1000 );
sprintf( sMsg, "%s / %s ( %s - %s )", sNow.c_str(), sTotal.c_str(), sBW.c_str(), sETA.c_str() );
}
} else {
if ( lapsed < 2000 ) {
sMsg = sNow;
} else {
sprintf( sMsg, "%s - %s", sNow.c_str(), sBW.c_str() );
}
}
if ( dltotal ) {
guiMsg->SetStateString( "progress", va( "%d", progress_start + dlnow * ( progress_end - progress_start ) / dltotal ) );
} else {
guiMsg->SetStateString( "progress", "0" );
}
guiMsg->SetStateString( "message", sMsg.c_str() );
}
}
// abort was used - tell the downloader and wait till final stop
bgl->url.status = DL_ABORTING;
guiMsg->SetStateString( "title", "Aborting.." );
guiMsg->SetStateString( "visible_mid", "0" );
// continue looping
guiMsgRestore = guiActive;
guiActive = guiMsg;
msgRunning = true;
}
}
示例4: IN_ProcessEvents
//.........这里部分代码省略.........
else if( ( *c & 0xF0 ) == 0xE0 ) // 1110 xxxx
{
utf32 |= ( *c++ & 0x0F ) << 12;
utf32 |= ( *c++ & 0x3F ) << 6;
utf32 |= ( *c++ & 0x3F );
}
else if( ( *c & 0xF8 ) == 0xF0 ) // 1111 0xxx
{
utf32 |= ( *c++ & 0x07 ) << 18;
utf32 |= ( *c++ & 0x3F ) << 6;
utf32 |= ( *c++ & 0x3F ) << 6;
utf32 |= ( *c++ & 0x3F );
}
else
{
Com_DPrintf( "Unrecognised UTF-8 lead byte: 0x%x\n", (unsigned int)*c );
c++;
}
if( utf32 != 0 )
{
if( IN_IsConsoleKey( A_NULL, utf32 ) )
{
Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qtrue, 0, NULL );
Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qfalse, 0, NULL );
}
else
Sys_QueEvent( 0, SE_CHAR, utf32, 0, 0, NULL );
}
}
}
break;
case SDL_MOUSEMOTION:
if( mouseActive )
Sys_QueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL );
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{
unsigned short b;
switch( e.button.button )
{
case SDL_BUTTON_LEFT: b = A_MOUSE1; break;
case SDL_BUTTON_MIDDLE: b = A_MOUSE3; break;
case SDL_BUTTON_RIGHT: b = A_MOUSE2; break;
case SDL_BUTTON_X1: b = A_MOUSE4; break;
case SDL_BUTTON_X2: b = A_MOUSE5; break;
default: b = A_AUX0 + ( e.button.button - 6 ) % 32; break;
}
Sys_QueEvent( 0, SE_KEY, b,
( e.type == SDL_MOUSEBUTTONDOWN ? qtrue : qfalse ), 0, NULL );
}
break;
case SDL_MOUSEWHEEL:
if( e.wheel.y > 0 )
Sys_QueEvent( 0, SE_KEY, A_MWHEELUP, qtrue, 0, NULL );
else
Sys_QueEvent( 0, SE_KEY, A_MWHEELDOWN, qtrue, 0, NULL );
break;
case SDL_QUIT:
Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n");
break;
case SDL_WINDOWEVENT:
switch( e.window.event )
{
case SDL_WINDOWEVENT_RESIZED:
{
char width[32], height[32];
if (!Cvar_VariableIntegerValue("r_restartOnResize"))
break;
Com_sprintf( width, sizeof( width ), "%d", e.window.data1 );
Com_sprintf( height, sizeof( height ), "%d", e.window.data2 );
Cvar_Set( "r_customwidth", width );
Cvar_Set( "r_customheight", height );
Cvar_Set( "r_mode", "-1" );
// Wait until user stops dragging for 1 second, so
// we aren't constantly recreating the GL context while
// he tries to drag...
vidRestartTime = Sys_Milliseconds( ) + Cvar_VariableIntegerValue("r_resizeDelay");
}
break;
case SDL_WINDOWEVENT_MINIMIZED: Cvar_SetValue( "com_minimized", 1 ); break;
case SDL_WINDOWEVENT_MAXIMIZED: Cvar_SetValue( "com_minimized", 0 ); break;
case SDL_WINDOWEVENT_FOCUS_LOST: Cvar_SetValue( "com_unfocused", 1 ); break;
case SDL_WINDOWEVENT_FOCUS_GAINED: Cvar_SetValue( "com_unfocused", 0 ); break;
}
break;
default:
break;
}
}
}
示例5: CL_UISystemCalls
/*
====================
CL_UISystemCalls
The ui module is making a system call
====================
*/
intptr_t CL_UISystemCalls( intptr_t *args )
{
switch( args[0] )
{
case UI_ERROR:
Com_Error( ERR_DROP, "%s", VMA(1) );
return 0;
case UI_CVAR_REGISTER:
Cvar_Register( (vmCvar_t *)VMA(1),(const char *) VMA(2),(const char *) VMA(3), args[4] );
return 0;
case UI_CVAR_SET:
Cvar_Set( (const char *) VMA(1), (const char *) VMA(2) );
return 0;
case UI_CVAR_SETVALUE:
Cvar_SetValue( (const char *) VMA(1), VMF(2) );
return 0;
case UI_CVAR_UPDATE:
Cvar_Update( (vmCvar_t *) VMA(1) );
return 0;
case UI_R_REGISTERMODEL:
return re.RegisterModel((const char *) VMA(1) );
case UI_R_REGISTERSHADERNOMIP:
return re.RegisterShaderNoMip((const char *) VMA(1) );
case UI_GETGLCONFIG:
CL_GetGlconfig( ( glconfig_t *) VMA(1) );
return 0;
case UI_CMD_EXECUTETEXT:
Cbuf_ExecuteText( args[1], (const char *) VMA(2) );
return 0;
case UI_CVAR_VARIABLEVALUE:
return FloatAsInt( Cvar_VariableValue( (const char *) VMA(1) ) );
case UI_FS_GETFILELIST:
return FS_GetFileList( (const char *) VMA(1), (const char *) VMA(2), (char *) VMA(3), args[4] );
case UI_KEY_SETCATCHER:
Key_SetCatcher( args[1] );
return 0;
case UI_KEY_CLEARSTATES:
Key_ClearStates();
return 0;
case UI_R_SETCOLOR:
re.SetColor( (const float *) VMA(1) );
return 0;
case UI_R_DRAWSTRETCHPIC:
re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] );
return 0;
case UI_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( (const char *) VMA(1), (char *) VMA(2), args[3] );
return 0;
case UI_R_MODELBOUNDS:
re.ModelBounds( args[1], (float *) VMA(2),(float *) VMA(3) );
return 0;
case UI_R_CLEARSCENE:
re.ClearScene();
return 0;
// case UI_KEY_GETOVERSTRIKEMODE:
// return Key_GetOverstrikeMode();
// return 0;
// case UI_PC_READ_TOKEN:
// return PC_ReadTokenHandle( args[1], VMA(2) );
// case UI_PC_SOURCE_FILE_AND_LINE:
// return PC_SourceFileAndLine( args[1], VMA(2), VMA(3) );
case UI_KEY_GETCATCHER:
return Key_GetCatcher();
case UI_MILLISECONDS:
return Sys_Milliseconds();
case UI_S_REGISTERSOUND:
return S_RegisterSound((const char *) VMA(1));
case UI_S_STARTLOCALSOUND:
//.........这里部分代码省略.........
示例6: CL_InitLocal
void
CL_InitLocal(void)
{
cls.state = ca_disconnected;
cls.realtime = Sys_Milliseconds();
CL_InitInput();
adr0 = Cvar_Get("adr0", "", CVAR_ARCHIVE);
adr1 = Cvar_Get("adr1", "", CVAR_ARCHIVE);
adr2 = Cvar_Get("adr2", "", CVAR_ARCHIVE);
adr3 = Cvar_Get("adr3", "", CVAR_ARCHIVE);
adr4 = Cvar_Get("adr4", "", CVAR_ARCHIVE);
adr5 = Cvar_Get("adr5", "", CVAR_ARCHIVE);
adr6 = Cvar_Get("adr6", "", CVAR_ARCHIVE);
adr7 = Cvar_Get("adr7", "", CVAR_ARCHIVE);
adr8 = Cvar_Get("adr8", "", CVAR_ARCHIVE);
cin_force43 = Cvar_Get("cin_force43", "1", 0);
/* register our variables */
cl_add_blend = Cvar_Get("cl_blend", "1", 0);
cl_add_lights = Cvar_Get("cl_lights", "1", 0);
cl_add_particles = Cvar_Get("cl_particles", "1", 0);
cl_add_entities = Cvar_Get("cl_entities", "1", 0);
cl_gun = Cvar_Get("cl_gun", "2", CVAR_ARCHIVE);
cl_footsteps = Cvar_Get("cl_footsteps", "1", 0);
cl_noskins = Cvar_Get("cl_noskins", "0", 0);
cl_autoskins = Cvar_Get("cl_autoskins", "0", 0);
cl_predict = Cvar_Get("cl_predict", "1", 0);
cl_maxfps = Cvar_Get("cl_maxfps", "95", CVAR_ARCHIVE);
cl_drawfps = Cvar_Get("cl_drawfps", "0", CVAR_ARCHIVE);
cl_upspeed = Cvar_Get("cl_upspeed", "200", 0);
cl_forwardspeed = Cvar_Get("cl_forwardspeed", "200", 0);
cl_sidespeed = Cvar_Get("cl_sidespeed", "200", 0);
cl_yawspeed = Cvar_Get("cl_yawspeed", "140", 0);
cl_pitchspeed = Cvar_Get("cl_pitchspeed", "150", 0);
cl_anglespeedkey = Cvar_Get("cl_anglespeedkey", "1.5", 0);
cl_run = Cvar_Get("cl_run", "0", CVAR_ARCHIVE);
freelook = Cvar_Get("freelook", "1", CVAR_ARCHIVE);
lookspring = Cvar_Get("lookspring", "0", CVAR_ARCHIVE);
lookstrafe = Cvar_Get("lookstrafe", "0", CVAR_ARCHIVE);
sensitivity = Cvar_Get("sensitivity", "3", CVAR_ARCHIVE);
m_pitch = Cvar_Get("m_pitch", "0.022", CVAR_ARCHIVE);
m_yaw = Cvar_Get("m_yaw", "0.022", 0);
m_forward = Cvar_Get("m_forward", "1", 0);
m_side = Cvar_Get("m_side", "1", 0);
cl_shownet = Cvar_Get("cl_shownet", "0", 0);
cl_showmiss = Cvar_Get("cl_showmiss", "0", 0);
cl_showclamp = Cvar_Get("showclamp", "0", 0);
cl_timeout = Cvar_Get("cl_timeout", "120", 0);
cl_paused = Cvar_Get("paused", "0", 0);
cl_timedemo = Cvar_Get("timedemo", "0", 0);
cl_stereo = Cvar_Get( "cl_stereo", "0", CVAR_ARCHIVE );
cl_stereo_separation = Cvar_Get( "cl_stereo_separation", "1", CVAR_ARCHIVE );
cl_stereo_convergence = Cvar_Get( "cl_stereo_convergence", "1.4", CVAR_ARCHIVE );
rcon_client_password = Cvar_Get("rcon_password", "", 0);
rcon_address = Cvar_Get("rcon_address", "", 0);
cl_lightlevel = Cvar_Get("gl_lightlevel", "0", 0);
/* userinfo */
info_password = Cvar_Get("password", "", CVAR_USERINFO);
info_spectator = Cvar_Get("spectator", "0", CVAR_USERINFO);
name = Cvar_Get("name", "unnamed", CVAR_USERINFO | CVAR_ARCHIVE);
skin = Cvar_Get("skin", "male/grunt", CVAR_USERINFO | CVAR_ARCHIVE);
rate = Cvar_Get("rate", "8000", CVAR_USERINFO | CVAR_ARCHIVE);
msg = Cvar_Get("msg", "1", CVAR_USERINFO | CVAR_ARCHIVE);
hand = Cvar_Get("hand", "0", CVAR_USERINFO | CVAR_ARCHIVE);
fov = Cvar_Get("fov", "90", CVAR_USERINFO | CVAR_ARCHIVE);
horplus = Cvar_Get("horplus", "1", CVAR_ARCHIVE);
windowed_mouse = Cvar_Get("windowed_mouse", "1", CVAR_USERINFO | CVAR_ARCHIVE);
gender = Cvar_Get("gender", "male", CVAR_USERINFO | CVAR_ARCHIVE);
gender_auto = Cvar_Get("gender_auto", "1", CVAR_ARCHIVE);
gender->modified = false;
cl_vwep = Cvar_Get("cl_vwep", "1", CVAR_ARCHIVE);
/* register our commands */
Cmd_AddCommand("cmd", CL_ForwardToServer_f);
Cmd_AddCommand("pause", CL_Pause_f);
Cmd_AddCommand("pingservers", CL_PingServers_f);
Cmd_AddCommand("skins", CL_Skins_f);
Cmd_AddCommand("userinfo", CL_Userinfo_f);
Cmd_AddCommand("snd_restart", CL_Snd_Restart_f);
Cmd_AddCommand("changing", CL_Changing_f);
Cmd_AddCommand("disconnect", CL_Disconnect_f);
Cmd_AddCommand("record", CL_Record_f);
Cmd_AddCommand("stop", CL_Stop_f);
Cmd_AddCommand("quit", CL_Quit_f);
//.........这里部分代码省略.........
示例7: Sys_Milliseconds
/*
=================
idRenderModelManagerLocal::Preload
=================
*/
void idRenderModelManagerLocal::Preload( const idPreloadManifest& manifest )
{
if( preload_MapModels.GetBool() )
{
// preload this levels images
int start = Sys_Milliseconds();
int numLoaded = 0;
idList< preloadSort_t > preloadSort;
preloadSort.Resize( manifest.NumResources() );
for( int i = 0; i < manifest.NumResources(); i++ )
{
const preloadEntry_s& p = manifest.GetPreloadByIndex( i );
idResourceCacheEntry rc;
idStrStatic< MAX_OSPATH > filename;
if( p.resType == PRELOAD_MODEL )
{
filename = "generated/rendermodels/";
filename += p.resourceName;
idStrStatic< 16 > ext;
filename.ExtractFileExtension( ext );
filename.SetFileExtension( va( "b%s", ext.c_str() ) );
}
if( p.resType == PRELOAD_PARTICLE )
{
filename = "generated/particles/";
filename += p.resourceName;
filename += ".bprt";
}
if( !filename.IsEmpty() )
{
if( fileSystem->GetResourceCacheEntry( filename, rc ) )
{
preloadSort_t ps = {};
ps.idx = i;
ps.ofs = rc.offset;
preloadSort.Append( ps );
}
}
}
preloadSort.SortWithTemplate( idSort_Preload() );
for( int i = 0; i < preloadSort.Num(); i++ )
{
const preloadSort_t& ps = preloadSort[ i ];
const preloadEntry_s& p = manifest.GetPreloadByIndex( ps.idx );
if( p.resType == PRELOAD_MODEL )
{
idRenderModel* model = FindModel( p.resourceName );
if( model != NULL )
{
model->SetLevelLoadReferenced( true );
}
}
else if( p.resType == PRELOAD_PARTICLE )
{
declManager->FindType( DECL_PARTICLE, p.resourceName );
}
numLoaded++;
}
int end = Sys_Milliseconds();
common->Printf( "%05d models preloaded ( or were already loaded ) in %5.1f seconds\n", numLoaded, ( end - start ) * 0.001 );
common->Printf( "----------------------------------------\n" );
}
}
示例8: WinMain
/*
==================
WinMain
==================
*/
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
char cwd[MAX_OSPATH];
// int startTime, endTime;
SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
// _CrtSetBreakAlloc(34804);
// should never get a previous instance in Win32
if ( hPrevInstance ) {
return 0;
}
g_wv.hInstance = hInstance;
Q_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );
// done before Com/Sys_Init since we need this for error output
Sys_CreateConsole();
// no abort/retry/fail errors
SetErrorMode( SEM_FAILCRITICALERRORS );
// get the initial time base
Sys_Milliseconds();
Sys_InitStreamThread();
Com_Init( sys_cmdline );
QuickMemTest();
_getcwd (cwd, sizeof(cwd));
Com_Printf("Working directory: %s\n", cwd);
// hide the early console since we've reached the point where we
// have a working graphics subsystems
if ( !com_viewlog->integer ) {
Sys_ShowConsole( 0, qfalse );
}
// main game loop
while( 1 ) {
// if not running as a game client, sleep a bit
if ( g_wv.isMinimized ) {
Sleep( 5 );
}
#ifdef _DEBUG
if (!g_wv.activeApp)
{
Sleep(50);
}
#endif // _DEBUG
// set low precision every frame, because some system calls
// reset it arbitrarily
// _controlfp( _PC_24, _MCW_PC );
// startTime = Sys_Milliseconds();
// make sure mouse and joystick are only called once a frame
IN_Frame();
// run the game
Com_Frame();
// endTime = Sys_Milliseconds();
// totalMsec += endTime - startTime;
// countMsec++;
}
// never gets here
}
示例9: main
int main (int argc, char **argv)
{
#if WRITE_LOG
FILE *log = NULL;
#endif
u32 ticks_per_s;
int oldtime;
SetupCallbacks();
#if WRITE_LOG
// Wipe log file.
log = fopen("log.txt", "w");
if (log != NULL)
{
fputs("LOG START\n\n", log);
fclose(log);
log = NULL;
}
#endif
// Calculate the clock resolution.
sceRtcGetCurrentTick(&first_ticks);
ticks_per_s = sceRtcGetTickResolution();
ticks_per_ms = ticks_per_s / 1000.0;
// TODO Move elsewhere.
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
// Initialise Quake.
Qcommon_Init (argc, argv);
oldtime = Sys_Milliseconds();
// Run the main loop.
while (go)
{
SceCtrlData pad;
curtime = Sys_Milliseconds();
sys_frame_time = curtime;
if (curtime < oldtime)
{
Sys_Error("curtime (%d) < oldtime (%d)\n", curtime, oldtime);
}
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS)
{
go = false;
}
if (curtime != oldtime)
{
Qcommon_Frame(curtime - oldtime);
oldtime = curtime;
}
}
sceKernelExitGame();
return 0;
}
示例10: CL_CgameSystemCalls
/**
* @brief The cgame module is making a system call
* @param[in] args
* @return
*/
intptr_t CL_CgameSystemCalls(intptr_t *args)
{
switch (args[0])
{
case CG_PRINT:
Com_Printf("%s", (char *)VMA(1));
return 0;
case CG_ERROR:
Com_Error(ERR_DROP, "%s", (char *)VMA(1));
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register(VMA(1), VMA(2), VMA(3), args[4]);
return 0;
case CG_CVAR_UPDATE:
Cvar_Update(VMA(1));
return 0;
case CG_CVAR_SET:
Cvar_SetSafe(VMA(1), VMA(2));
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer(VMA(1), VMA(2), args[3]);
return 0;
case CG_CVAR_LATCHEDVARIABLESTRINGBUFFER:
Cvar_LatchedVariableStringBuffer(VMA(1), VMA(2), args[3]);
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer(args[1], VMA(2), args[3]);
return 0;
case CG_ARGS:
Cmd_ArgsBuffer(VMA(1), args[2]);
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode(VMA(1), VMA(2), args[3]);
case CG_FS_READ:
FS_Read(VMA(1), args[2], args[3]);
return 0;
case CG_FS_WRITE:
return FS_Write(VMA(1), args[2], args[3]);
case CG_FS_FCLOSEFILE:
FS_FCloseFile(args[1]);
return 0;
case CG_FS_GETFILELIST:
return FS_GetFileList(VMA(1), VMA(2), VMA(3), args[4]);
case CG_FS_DELETEFILE:
return FS_Delete(VMA(1));
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText(VMA(1));
return 0;
case CG_ADDCOMMAND:
Cmd_AddCommand(VMA(1));
return 0;
case CG_REMOVECOMMAND:
Cmd_RemoveCommandSafe(VMA(1));
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand(VMA(1));
return 0;
case CG_UPDATESCREEN:
SCR_UpdateScreen();
return 0;
case CG_CM_LOADMAP:
CL_CM_LoadMap(VMA(1));
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
return CM_InlineModel(args[1]);
case CG_CM_TEMPBOXMODEL:
return CM_TempBoxModel(VMA(1), VMA(2), qfalse);
case CG_CM_TEMPCAPSULEMODEL:
return CM_TempBoxModel(VMA(1), VMA(2), qtrue);
case CG_CM_POINTCONTENTS:
return CM_PointContents(VMA(1), args[2]);
case CG_CM_TRANSFORMEDPOINTCONTENTS:
return CM_TransformedPointContents(VMA(1), args[2], VMA(3), VMA(4));
case CG_CM_BOXTRACE:
CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse);
return 0;
case CG_CM_CAPSULETRACE:
CM_BoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue);
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse);
return 0;
case CG_CM_TRANSFORMEDCAPSULETRACE:
CM_TransformedBoxTrace(VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue);
return 0;
case CG_CM_MARKFRAGMENTS:
return re.MarkFragments(args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7));
case CG_R_PROJECTDECAL:
re.ProjectDecal(args[1], args[2], VMA(3), VMA(4), VMA(5), args[6], args[7]);
//.........这里部分代码省略.........
示例11: Sys_SendKeyEvents
void Sys_SendKeyEvents (void)
{
// grab frame time
sys_frame_time = Sys_Milliseconds();
}
示例12: CLT3_InitCGame
void CLT3_InitCGame() {
int t1 = Sys_Milliseconds();
// put away the console
Con_Close();
// find the current mapname
const char* info = GGameType & GAME_WolfSP ? cl.ws_gameState.stringData + cl.ws_gameState.stringOffsets[ Q3CS_SERVERINFO ] :
GGameType & GAME_WolfMP ? cl.wm_gameState.stringData + cl.wm_gameState.stringOffsets[ Q3CS_SERVERINFO ] :
GGameType & GAME_ET ? cl.et_gameState.stringData + cl.et_gameState.stringOffsets[ Q3CS_SERVERINFO ] :
cl.q3_gameState.stringData + cl.q3_gameState.stringOffsets[ Q3CS_SERVERINFO ];
const char* mapname = Info_ValueForKey( info, "mapname" );
String::Sprintf( cl.q3_mapname, sizeof ( cl.q3_mapname ), "maps/%s.bsp", mapname );
if ( GGameType & GAME_Quake3 ) {
// load the dll or bytecode
vmInterpret_t interpret;
if ( cl_connectedToPureServer != 0 ) {
// if sv_pure is set we only allow qvms to be loaded
interpret = VMI_COMPILED;
} else {
interpret = ( vmInterpret_t )( int )Cvar_VariableValue( "vm_cgame" );
}
cgvm = VM_Create( "cgame", CLQ3_CgameSystemCalls, interpret );
} else if ( GGameType & GAME_WolfSP ) {
cgvm = VM_Create( "cgame", CLWS_CgameSystemCalls, VMI_NATIVE );
} else if ( GGameType & GAME_WolfMP ) {
cgvm = VM_Create( "cgame", CLWM_CgameSystemCalls, VMI_NATIVE );
} else {
cgvm = VM_Create( "cgame", CLET_CgameSystemCalls, VMI_NATIVE );
}
if ( !cgvm ) {
common->Error( "VM_Create on cgame failed" );
}
cls.state = CA_LOADING;
// init for this gamestate
// use the lastExecutedServerCommand instead of the serverCommandSequence
// otherwise server commands sent just before a gamestate are dropped
if ( GGameType & GAME_ET ) {
//bani - added clc.demoplaying, since some mods need this at init time, and drawactiveframe is too late for them
VM_Call( cgvm, CG_INIT, clc.q3_serverMessageSequence, clc.q3_lastExecutedServerCommand, clc.q3_clientNum, clc.demoplaying );
} else {
VM_Call( cgvm, CG_INIT, clc.q3_serverMessageSequence, clc.q3_lastExecutedServerCommand, clc.q3_clientNum );
}
// we will send a usercmd this frame, which
// will cause the server to send us the first snapshot
cls.state = CA_PRIMED;
int t2 = Sys_Milliseconds();
common->Printf( "CLT3_InitCGame: %5.2f seconds\n", ( t2 - t1 ) / 1000.0 );
// have the renderer touch all its images, so they are present
// on the card even if the driver does deferred loading
R_EndRegistration();
// clear anything that got printed
Con_ClearNotify();
}
示例13: Menu_Draw
void Menu_Draw( menuframework_s *menu )
{
int i;
menucommon_s *item;
/*
** draw contents
*/
for ( i = 0; i < menu->nitems; i++ )
{
switch ( ( ( menucommon_s * ) menu->items[i] )->type )
{
case MTYPE_FIELD:
Field_Draw( ( menufield_s * ) menu->items[i] );
break;
case MTYPE_SLIDER:
Slider_Draw( ( menuslider_s * ) menu->items[i] );
break;
case MTYPE_LIST:
MenuList_Draw( ( menulist_s * ) menu->items[i] );
break;
case MTYPE_SPINCONTROL:
SpinControl_Draw( ( menulist_s * ) menu->items[i] );
break;
case MTYPE_ACTION:
Action_Draw( ( menuaction_s * ) menu->items[i] );
break;
case MTYPE_SEPARATOR:
Separator_Draw( ( menuseparator_s * ) menu->items[i] );
break;
}
}
item = (menucommon_s *) Menu_ItemAtCursor( menu );
if ( item && item->cursordraw )
{
item->cursordraw( item );
}
else if ( menu->cursordraw )
{
menu->cursordraw( menu );
}
else if ( item && item->type != MTYPE_FIELD )
{
if ( item->flags & QMF_LEFT_JUSTIFY )
{
Draw_Char( menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
}
else
{
Draw_Char( menu->x + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
}
}
if ( item )
{
if ( item->statusbarfunc )
item->statusbarfunc( ( void * ) item );
else if ( item->statusbar )
Menu_DrawStatusBar( item->statusbar );
else
Menu_DrawStatusBar( menu->statusbar );
}
else
{
Menu_DrawStatusBar( menu->statusbar );
}
}
示例14: cl_mm_login_done
/*
* cl_mm_login_done
* callback for login post request
*/
static void cl_mm_login_done( stat_query_t *query, qboolean success, void *customp )
{
int rstatus;
unsigned int uuid;
stat_query_section_t *root;
stat_query_section_t *ratings_section;
if( cl_mm_loginState == LOGIN_STATE_NONE )
{
Com_DPrintf("cl_mm_login_done called when no login in process!\n");
return;
}
cl_mm_enabled = qfalse;
cls.mm_session = 0;
Cvar_ForceSet( cl_mm_session->name, "0" );
if( !success )
{
// TODO: reset login
CL_MM_ErrorMessage( qtrue, "MM Login: StatQuery error" );
cl_mm_loginState = LOGIN_STATE_NONE;
return;
}
Com_DPrintf( "MM Login: %s\n", sq_api->GetRawResponse( query ) );
/*
* ch : new JSON response looks like
* {
* ready: // reflects the 'state of login protocol'
* -1, // for initial login - LOGIN_RESPONSE_HANDLE
* 1, // for login not ready yet - LOGIN_RESPONSE_WAIT
* 2, // ready - LOGIN_RESPONSE_READY
*
* handle: [int], // handle for login-process
* id: [int], // valid when ready=2. 0 on error, > 0 otherwise
* ratings: [
* { gametype: [string], rating: [float], deviation: [float] }
* ..
* ]
* }
*/
root = sq_api->GetRoot( query );
if( root == NULL )
{
CL_MM_ErrorMessage( qtrue, "MM Login: Failed to parse data at step %d", cl_mm_loginState );
// bail out
cl_mm_loginHandle = 0;
cl_mm_loginState = LOGIN_STATE_NONE;
}
else
{
rstatus = (int)sq_api->GetNumber( root, "ready" );
uuid = (unsigned int)sq_api->GetNumber( root, "id" );
Com_DPrintf( "cl_mm_login_done %d %d\n", rstatus, uuid );
// possible responses are ( -1 any ) ( 1 0 ) ( 2 any )
if( rstatus == LOGIN_RESPONSE_NONE )
{
// ERROR
cl_mm_loginState = LOGIN_STATE_NONE;
}
else if( cl_mm_loginState == LOGIN_STATE_WAITING )
{
// here we are expecting a handle to the validation process
if( rstatus == LOGIN_RESPONSE_HANDLE )
{
// we can move to step 2
cl_mm_loginHandle = (unsigned int)sq_api->GetNumber( root, "handle" );;
cl_mm_loginState = LOGIN_STATE_READY;
cl_mm_loginTime = Sys_Milliseconds() /* - MM_LOGIN2_INTERVAL */;
}
else
{
// stop this madness
cl_mm_loginHandle = 0;
cl_mm_loginState = LOGIN_STATE_NONE;
}
}
else if( cl_mm_loginState == LOGIN_STATE_READY && rstatus == LOGIN_RESPONSE_READY )
{
// validation process is done and with got an uuid
cls.mm_session = (unsigned int)sq_api->GetNumber( root, "id" );
cl_mm_loginState = LOGIN_STATE_NONE;
ratings_section = sq_api->GetSection( root, "ratings" );
if( cls.mm_session != 0 && ratings_section != NULL )
{
int idx = 0;
stat_query_section_t *element = sq_api->GetArraySection( ratings_section, idx++ );
while( element )
//.........这里部分代码省略.........
示例15: Accelerometer_HandleEvents
static void Accelerometer_HandleEvents(void)
{
int dx = 0, dy = 0;
int t, tmp;
int x, y, z;
static int jumpTime = 0;
t = Sys_Milliseconds();
if (!accel_angle) {
accel_angle = Cvar_Get("accel_angle", "45", CVAR_ARCHIVE);
}
if (!accel_debug) {
accel_debug = Cvar_Get("accel_debug", "0", CVAR_ARCHIVE);
}
if (!accel_jump) {
accel_jump = Cvar_Get("accel_jump", "-1300", CVAR_ARCHIVE);
}
if (!accel_epsilon_x) {
accel_epsilon_x =
Cvar_Get("accel_epsilon_x", "100", CVAR_ARCHIVE);
}
if (!accel_epsilon_y) {
accel_epsilon_y =
Cvar_Get("accel_epsilon_y", "100", CVAR_ARCHIVE);
}
Accelerometer_ReadCoords(&x, &y, &z);
/* only update sin and cos if the cvar's changed */
tmp = accel_angle->value;
if(tmp != accel_angle_value) {
/* what happened to sincosf()? */
accel_sin = sin(DEG2RAD(tmp));
accel_cos = cos(DEG2RAD(tmp));
accel_angle_value = tmp;
}
tmp = y * accel_cos - z * accel_sin;
z = z * accel_cos + y * accel_sin;
y = tmp;
if (accel_debug->integer) {
Com_DPrintf("Accelerometer_HandleEvents: y = %d\n", y);
}
if (accel_jump->value) {
float mag = sqrtf(y*y+z*z);
// HACK - change the sign of jump to be +ve not -ve
// HACK - z<0 means that lots of jerks will look like jumps
// change it to < -500 or < accel_jump->value/2
int looks_like_a_jump = (mag > -accel_jump->value) && (z < 0);
if (!jumpTime && looks_like_a_jump) {
Com_QueueEvent(t, SE_KEY, K_SPACE, qtrue, 0, NULL);
jumpTime = t;
} else if (jumpTime && !looks_like_a_jump) {
Com_QueueEvent(t, SE_KEY, K_SPACE, qfalse, 0, NULL);
jumpTime = 0;
}
}
if (x > accel_epsilon_x->integer)
dx = -(x - accel_epsilon_x->integer);
else if (x < -accel_epsilon_x->integer)
dx = -(x + accel_epsilon_x->integer);
if (y > accel_epsilon_y->integer)
dy = -(y - accel_epsilon_y->integer);
else if (y < -accel_epsilon_y->integer)
dy = -(y + accel_epsilon_y->integer);
dx *= cl_sensitivity->value;
dy *= cl_sensitivity->value;
Com_QueueEvent(t, SE_ACCEL, dx, dy, 0, NULL);
}