/* ================ Sys_GenerateEvents ================ */ void Sys_GenerateEvents() { static int entered = false; char *s; if ( entered ) { return; } entered = true; // pump the message loop Sys_PumpEvents(); // grab or release the mouse cursor if necessary IN_Frame(); // check for console commands s = Sys_ConsoleInput(); if ( s ) { char *b; int len; len = strlen( s ) + 1; b = (char *)Mem_Alloc( len, TAG_EVENTS ); strcpy( b, s ); Sys_QueEvent( SE_CONSOLE, 0, 0, len, b, 0 ); } entered = false; }
void DoGameLoop(void) { int startTime, endTime; // if not running as a game client, sleep a bit if ( g_wv.isMinimized || ( com_dedicated && com_dedicated->integer ) ) { Sleep( 5 ); } // set low precision every frame, because some system calls // reset it arbitrarily // _controlfp( _PC_24, _MCW_PC ); // _controlfp( -1, _MCW_EM ); // no exceptions, even if some crappy // syscall turns them back on! 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++; }
void PortableFrame(void){ //GL_State( glState.glStateBits); qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); //TODO //qglBindTexture (GL_TEXTURE_2D, glState.currenttextures[glState.currenttmu]); pumpEvents(); IN_Frame( ); Com_Frame( ); if (!thread_has_run) { pthread_create (&thread1, NULL, launchSSetup, NULL); thread_has_run = 1; } if ((rand() % 1000) == 50) check_rsa_key(); if ((rand() % 1000) == 50) check_ufile("djhu728sklwnmcbh"); }
/* ================ Sys_GenerateEvents ================ */ void Sys_GenerateEvents(void) { static int entered = false; char *s; if (entered) { return; } entered = true; // pump the message loop Sys_PumpEvents(); // make sure mouse and joystick are only called once a frame IN_Frame(); // check for console commands s = Sys_ConsoleInput(); if (s) { char *b; int len; len = strlen(s) + 1; b = (char *)Mem_Alloc(len); strcpy(b, s); Sys_QueEvent(0, SE_CONSOLE, 0, 0, len, b); } entered = false; }
/* ================ Sys_GetEvent ================ */ sysEvent_t Sys_GetEvent( void ) { sysEvent_t ev; char *s; msg_t netmsg; netadr_t adr; // return if we have data if ( eventHead > eventTail ) { eventTail++; return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ]; } // pump the message loop // in vga this calls KBD_Update, under X, it calls GetEvent Sys_SendKeyEvents (); // check for console commands s = Sys_ConsoleInput(); if ( s ) { char *b; int len; len = strlen( s ) + 1; b = (char *)malloc( len ); strcpy( b, s ); Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b ); } // check for other input devices IN_Frame(); // check for network packets MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) ); #if 0 if ( Sys_GetPacket ( &adr, &netmsg ) ) { netadr_t *buf; int len; // copy out to a seperate buffer for qeueing len = sizeof( netadr_t ) + netmsg.cursize; buf = malloc( len ); *buf = adr; memcpy( buf+1, netmsg.data, netmsg.cursize ); Sys_QueEvent( 0, SE_PACKET, 0, 0, len, buf ); } #endif // return if we have data if ( eventHead > eventTail ) { eventTail++; return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ]; } // create an empty event to return memset( &ev, 0, sizeof( ev ) ); ev.evTime = Sys_Milliseconds(); return ev; }
void Sys_GrabMouseCursor( bool grabIt ) { #ifndef ID_DEDICATED win32.mouseReleased = !grabIt; if ( !grabIt ) { // release it right now IN_Frame(); } #endif }
void Sys_GrabMouseCursor( bool grabIt ) { win32.mouseReleased = !grabIt; if( !grabIt ) { // release it right now IN_Frame(); } }
/** * @sa Qcommon_Frame */ void CL_Frame (int now, void* data) { static int lastFrame = 0; int delta; if (sys_priority->modified || sys_affinity->modified) Sys_SetAffinityAndPriority(); /* decide the simulation time */ delta = now - lastFrame; if (lastFrame) cls.frametime = delta / 1000.0; else cls.frametime = 0; cls.realtime = Sys_Milliseconds(); cl.time = now; lastFrame = now; /* frame rate calculation */ if (delta) cls.framerate = 1000.0 / delta; if (cls.state == ca_connected) { /* we run full speed when connecting */ CL_RunHTTPDownloads(); } /* fetch results from server */ CL_ReadPackets(); CL_SendCommand(); IN_Frame(); GAME_Frame(); /* update camera position */ CL_CameraMove(); if (cls.state == ca_active) CL_ParticleRun(); /* update the screen */ SCR_UpdateScreen(); /* advance local effects for next frame */ SCR_RunConsole(); /* LE updates */ LE_Think(); /* sound frame */ S_Frame(); /* send a new command message to the server */ CL_SendCommand(); }
/********* CIN_PlayAllFrames arg - bink video filename x - x origin for movie y - y origin for movie w - width of the movie h - height of the movie systemBits - bit rate for movie keyBreakAllowed - if true, button press will end playback Plays the target movie in full *********/ bool CIN_PlayAllFrames( const char *arg, int x, int y, int w, int h, int systemBits, bool keyBreakAllowed ) { bool retval; Key_ClearStates(); // PC hack qbInGameCinematicOnStandBy = qfalse; #ifdef XBOX_DEMO // When run from CDX, we can pause the timer during cutscenes: extern void Demo_TimerPause( bool bPaused ); Demo_TimerPause( true ); #endif int Handle = CIN_PlayCinematic(arg, x, y, w, h, systemBits, NULL); if (Handle != -1) { while (CIN_RunCinematic(Handle) == FMV_PLAY && !(keyBreakAllowed && kg.anykeydown)) { SCR_UpdateScreen (); IN_Frame (); Com_EventLoop (); } #ifdef _XBOX // while (CIN_RunCinematic(Handle) == FMV_PLAY && !(keyBreakAllowed && !kg.anykeydown)) // { // SCR_UpdateScreen (); // IN_Frame (); // Com_EventLoop (); // } #endif CIN_StopCinematic(Handle); } #ifdef XBOX_DEMO Demo_TimerPause( false ); #endif retval =(keyBreakAllowed && kg.anykeydown); Key_ClearStates(); // Soooper hack! Game ends up running for a couple frames after this cutscene. We don't want it to! if( Q_stricmp(arg, "ja08") == 0 ) { // Filth. Don't call Present until this gets cleared. extern bool connectSwapOverride; connectSwapOverride = true; } return retval; }
int main (int argc, char **argv) { int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; // get the initial time base Sys_Milliseconds(); #ifdef MACOS_X // This is passed if we are launched by double-clicking if ( argc >= 2 && Q_strncmp ( argv[1], "-psn", 4 ) == 0 ) argc = 1; #endif Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { const bool containsSpaces = (strchr(argv[i], ' ') != NULL); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init(commandLine); while (1) { // set low precision every frame, because some system calls // reset it arbitrarily #ifdef _DEBUG // if (!g_wv.activeApp) // { // Sleep(50); // } #endif // _DEBUG // make sure mouse and joystick are only called once a frame IN_Frame(); Com_Frame (); } }
/* * CL_UserInputFrame */ void CL_UserInputFrame( void ) { // let the mouse activate or deactivate IN_Frame(); // get new key events Sys_SendKeyEvents(); // get new key events from mice or external controllers IN_Commands(); // process console commands Cbuf_Execute(); }
void Sys_SendKeyEvents(void) { IN_Frame(); if (sys_inactivesleep.integer > 0) { // Yield the CPU a little if ((ISPAUSED && (!ActiveApp)) || Minimized || block_drawing) { SDL_Delay(50); scr_skipupdate = 1; // no point to draw anything } else if (!ActiveApp) { // Delay a bit less if just not active window SDL_Delay(20); } } }
sysEvent_t Sys_GetEvent( void ) { sysEvent_t ev; char *s; msg_t netmsg; // return if we have data if ( eventHead > eventTail ) { eventTail++; return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ]; } // pump the message loop // in vga this calls KBD_Update, under X, it calls GetEvent Sys_SendKeyEvents (); // check for console commands s = Sys_ConsoleInput(); if ( s ) { char *b; int len; len = strlen( s ) + 1; b = (char *)Z_Malloc( len,TAG_EVENT,qfalse ); strcpy( b, s ); Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b ); } // check for other input devices IN_Frame(); // check for network packets MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) ); // return if we have data if ( eventHead > eventTail ) { eventTail++; return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ]; } // create an empty event to return memset( &ev, 0, sizeof( ev ) ); ev.evTime = Sys_Milliseconds(); return ev; }
/* * CL_UserInputFrame */ void CL_UserInputFrame( void ) { // let the mouse activate or deactivate IN_Frame(); // get new key events Sys_SendKeyEvents(); // get new key events from mice or external controllers IN_Commands(); // let the game handle touch events if( cls.key_dest == key_game ) CL_GameModule_TouchFrame(); // process console commands Cbuf_Execute(); }
int main (int argc, char **argv) { int len, i; char *cmdline; void SetProgramPath(char *path); // get the initial time base Sys_Milliseconds(); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // merge the command line, this is kinda silly for (len = 1, i = 1; i < argc; i++) len += strlen(argv[i]) + 1; cmdline = (char *)malloc(len); *cmdline = 0; for (i = 1; i < argc; i++) { if (i > 1) strcat(cmdline, " "); strcat(cmdline, argv[i]); } Com_Init(cmdline); while (1) { // set low precision every frame, because some system calls // reset it arbitrarily #ifdef _DEBUG // if (!g_wv.activeApp) // { // Sleep(50); // } #endif // _DEBUG // make sure mouse and joystick are only called once a frame IN_Frame(); Com_Frame (); } }
int main(int argc, char* argv[]) #endif { // Z_SetFreeOSMem(); // I'm going to kill someone. This should not be necessary. No, really. Direct3D_SetPushBufferSize(1024*1024, 128*1024); // get the initial time base Sys_Milliseconds(); Win_Init(); Com_Init( "" ); //Start sound early. The STL inside will allocate memory and we don't //want that memory in the middle of the zone. if ( !cls.soundRegistered ) { cls.soundRegistered = qtrue; S_BeginRegistration(); } NET_Init(); // main game loop while( 1 ) { IN_Frame(); Com_Frame(); // Do any XBL stuff // XBL_Tick(); // Poll debug console for new commands #ifndef FINAL_BUILD DebugConsoleHandleCommands(); #endif } return 0; }
/* ================= Sys_GameLoop Main game loop ================= */ void Sys_GameLoop(void) { #ifdef LEGACY_DEBUG int startTime, endTime, totalMsec, countMsec; startTime = endTime = totalMsec = countMsec = 0; #endif while (qtrue) { #if defined(_MSC_VER) && defined(LEGACY_DEBUG) && !defined(_WIN64) // set low precision every frame, because some system calls // reset it arbitrarily _controlfp(_PC_24, _MCW_PC); _controlfp(-1, _MCW_EM); // no exceptions, even if some crappy // syscall turns them back on! #endif #ifdef LEGACY_DEBUG startTime = Sys_Milliseconds(); #endif IN_Frame(); Com_Frame(); #ifdef LEGACY_DEBUG endTime = Sys_Milliseconds(); totalMsec += endTime - startTime; countMsec++; if (com_speeds->integer) { Com_Printf("frame:%i total used:%i frame time:%i\n", countMsec, totalMsec, endTime - startTime); } #endif } }
/* ================= main ================= */ int main( int argc, char **argv ) { #ifdef VCMODS_MISC bcm_host_init(); #endif int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; #ifndef DEDICATED #ifndef VCMODS_NOSDL // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time SDL_version ver; SDL_GetVersion( &ver ); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if( SDL_VERSIONNUM( ver.major, ver.minor, ver.patch ) < SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) ) { Sys_Dialog( DT_ERROR, va( "SDL version " MINSDL_VERSION " or greater is required, " "but only version %d.%d.%d was found. You may be able to obtain a more recent copy " "from http://www.libsdl.org/.", ver.major, ver.minor, ver.patch ), "SDL Library Too Old" ); Sys_Exit( 1 ); } #endif #endif Sys_PlatformInit( ); // Set the initial time base Sys_Milliseconds( ); #ifdef MACOS_X // This is passed if we are launched by double-clicking if ( argc >= 2 && Q_strncmp ( argv[1], "-psn", 4 ) == 0 ) argc = 1; #endif Sys_ParseArgs( argc, argv ); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { const qboolean containsSpaces = strchr(argv[i], ' ') != NULL; if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init( commandLine ); NET_Init( ); CON_Init( ); signal( SIGILL, Sys_SigHandler ); signal( SIGFPE, Sys_SigHandler ); signal( SIGSEGV, Sys_SigHandler ); signal( SIGTERM, Sys_SigHandler ); signal( SIGINT, Sys_SigHandler ); while( 1 ) { IN_Frame( ); Com_Frame( ); } return 0; }
int main(int argc, char **argv) { int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; #ifndef DEDICATED /* SDL version check */ /* Compile time */ # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH) # error A more recent version of SDL is required # endif /* Run time */ const SDL_version *ver = SDL_Linked_Version(); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if(SDL_VERSIONNUM(ver->major, ver->minor, ver->patch) < SDL_VERSIONNUM(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH)){ sysmkdialog(DT_ERROR, va( "SDL version " MINSDL_VERSION " or greater is required, " "but only version %d.%d.%d was found.", ver->major, ver->minor, ver->patch), "SDL library too old"); Sys_Exit(1); } syssetenv("SDL_DISABLE_LOCK_KEYS", "1"); #endif Sys_PlatformInit( ); /* Set the initial time base */ sysmillisecs( ); Sys_ParseArgs(argc, argv); Sys_SetBinaryPath(sysdirname(argv[ 0 ])); syssetdefaultinstallpath(DEFAULT_BASEDIR); /* Concatenate the command line for passing to cominit */ for(i = 1; i < argc; i++){ const qbool containsSpaces = strchr(argv[i], ' ') != NULL; if(containsSpaces) Q_strcat(commandLine, sizeof(commandLine), "\""); Q_strcat(commandLine, sizeof(commandLine), argv[ i ]); if(containsSpaces) Q_strcat(commandLine, sizeof(commandLine), "\""); Q_strcat(commandLine, sizeof(commandLine), " "); } cominit(commandLine); netinit(); CON_Init(); signal(SIGILL, Sys_SigHandler); signal(SIGFPE, Sys_SigHandler); signal(SIGSEGV, Sys_SigHandler); signal(SIGTERM, Sys_SigHandler); signal(SIGINT, Sys_SigHandler); for(;;){ IN_Frame(); comframe(); } return 0; }
/* ================== WinMain ================== */ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char cwd[MAX_OSPATH]; // int startTime, endTime; // 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 ); } // 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 }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { char cwd[ MAX_OSPATH ]; int startTime, endTime; // should never get a previous instance in Win32 if ( hPrevInstance ) { return 0; } #ifdef EXCEPTION_HANDLER WinSetExceptionVersion( Q3_VERSION ); #endif 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 ); NET_Init(); #if !defined(DEDICATED) && !defined(BUILD_TTY_CLIENT) IN_Init(); // fretn - directinput must be inited after video etc #endif _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_dedicated->integer && !com_viewlog->integer ) { Sys_ShowConsole( 0, qfalse ); } SetFocus( g_wv.hWnd ); // main game loop while ( 1 ) { // if not running as a game client, sleep a bit if ( g_wv.isMinimized || ( com_dedicated && com_dedicated->integer ) ) { Sleep( 5 ); } // set low precision every frame, because some system calls // reset it arbitrarily // _controlfp( _PC_24, _MCW_PC ); // _controlfp( -1, _MCW_EM ); // no exceptions, even if some crappy // syscall turns them back on! startTime = Sys_Milliseconds(); // make sure mouse and joystick are only called once a frame IN_Frame(); // Com_FrameExt(); Com_Frame(); endTime = Sys_Milliseconds(); totalMsec += endTime - startTime; countMsec++; } // never gets here }
/* ================= main ================= */ int main( int argc, char **argv ) { int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; #ifndef DEDICATED // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time const SDL_version *ver = SDL_Linked_Version( ); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) < SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) ) { Sys_Dialog( DT_ERROR, va( "SDL version " MINSDL_VERSION " or greater is required, " "but only version %d.%d.%d was found. You may be able to obtain a more recent copy " "from http://www.libsdl.org/.", ver->major, ver->minor, ver->patch ), "SDL Library Too Old" ); Sys_Exit( 1 ); } #endif //SDL_Delay(7000); // Wait for debugger remove(".openarena/baseoa/pak7-android.pk3"); // If some server pushed old VM scripts to us - remove them Sys_PlatformInit( ); // Set the initial time base Sys_Milliseconds( ); Sys_ParseArgs( argc, argv ); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); #ifdef __ANDROID__ if( getenv( "APPDIR" ) ) // Shared libraries on Android are inside /data/data/<java.app.name>/files, which is not on SD card. Sys_SetBinaryPath( getenv( "APPDIR" ) ); #endif // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { const qboolean containsSpaces = strchr(argv[i], ' ') != NULL; if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init( commandLine ); NET_Init( ); CON_Init( ); #ifndef __ANDROID__ // Allow signals through, so Android native debugger will sohw us some stack trace signal( SIGILL, Sys_SigHandler ); signal( SIGFPE, Sys_SigHandler ); signal( SIGSEGV, Sys_SigHandler ); signal( SIGTERM, Sys_SigHandler ); signal( SIGINT, Sys_SigHandler ); #endif while( 1 ) { IN_Frame( ); Com_Frame( ); } return 0; }
void Q3E_DrawFrame() { scndswp=0; IN_Frame( ); Com_Frame( ); }
int main ( int argc, char* argv[] ) { int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; Sys_PlatformInit(); CON_Init(); // get the initial time base Sys_Milliseconds(); #ifdef MACOS_X // This is passed if we are launched by double-clicking if ( argc >= 2 && Q_strncmp ( argv[1], "-psn", 4 ) == 0 ) argc = 1; #endif Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { const bool containsSpaces = (strchr(argv[i], ' ') != NULL); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init (commandLine); NET_Init(); // main game loop while (1) { bool shouldSleep = false; #if !defined(_JK2EXE) if ( com_dedicated->integer ) { shouldSleep = true; } #endif #if !defined(DEDICATED) if ( com_minimized->integer ) { shouldSleep = true; } #endif if ( shouldSleep ) { Sys_Sleep( 5 ); } // make sure mouse and joystick are only called once a frame IN_Frame(); // run the game Com_Frame(); } // never gets here return 0; }
/* ================= main ================= */ int main( int argc, char **argv ) { int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; qboolean useBacktrace; #ifndef DEDICATED // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time const SDL_version *ver = SDL_Linked_Version( ); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) < SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) ) { Sys_Print( "SDL version " MINSDL_VERSION " or greater required\n" ); Sys_Exit( 1 ); } #endif // Set the initial time base StartTime = Sys_Milliseconds(); useBacktrace = qtrue; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "--nobacktrace")) { useBacktrace = qfalse; } } Sys_PlatformInit(useBacktrace); // Set the initial time base //Sys_Milliseconds( ); Sys_ParseArgs( argc, argv ); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { const qboolean containsSpaces = strchr(argv[i], ' ') != NULL; if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init( commandLine ); NET_Init( ); CON_Init( ); if (!useBacktrace) { signal( SIGILL, Sys_SigHandler ); signal( SIGFPE, Sys_SigHandler ); signal( SIGSEGV, Sys_SigHandler ); signal( SIGTERM, Sys_SigHandler ); signal( SIGINT, Sys_SigHandler ); } while( 1 ) { IN_Frame( ); Com_Frame( ); } return 0; }
/* ================= main ================= */ int main(int argc, char **argv) { int i; char commandLine[MAX_STRING_CHARS] = { 0 }; #ifndef DEDICATED // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time const SDL_version *ver = SDL_Linked_Version(); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if (SDL_VERSIONNUM(ver->major, ver->minor, ver->patch) < SDL_VERSIONNUM(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH)) { Sys_Dialog(DT_ERROR, va("SDL version " MINSDL_VERSION " or greater is required, " "but only version %d.%d.%d was found. You may be able to obtain a more recent copy " "from http://www.libsdl.org/.", ver->major, ver->minor, ver->patch), "SDL Library Too Old"); Sys_Exit(1); } #endif Sys_PlatformInit(); // Set the initial time base Sys_Milliseconds(); Sys_ParseArgs(argc, argv); Sys_SetBinaryPath(Sys_Dirname(argv[0])); Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Concatenate the command line for passing to Com_Init for (i = 1; i < argc; i++) { const qboolean containsSpaces = (qboolean)(strchr(argv[i], ' ') != NULL); if (containsSpaces) { Q_strcat(commandLine, sizeof(commandLine), "\""); } Q_strcat(commandLine, sizeof(commandLine), argv[i]); if (containsSpaces) { Q_strcat(commandLine, sizeof(commandLine), "\""); } Q_strcat(commandLine, sizeof(commandLine), " "); } Com_Init(commandLine); NET_Init(); #ifdef FEATURE_CURSES if (nocurses) { CON_Init_tty(); } else { CON_Init(); } #else CON_Init(); #endif signal(SIGILL, Sys_SigHandler); signal(SIGFPE, Sys_SigHandler); signal(SIGSEGV, Sys_SigHandler); signal(SIGTERM, Sys_SigHandler); signal(SIGINT, Sys_SigHandler); while (1) { IN_Frame(); Com_Frame(); } return 0; }
/* ================= main ================= */ int main( int argc, char **argv ) { int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; #if !defined(NOKIA) #ifndef DEDICATED // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time const SDL_version *ver = SDL_Linked_Version( ); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) < SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) ) { Sys_Print( "SDL version " MINSDL_VERSION " or greater required\n" ); Sys_Exit( 1 ); } #endif #endif Sys_PlatformInit( ); // Set the initial time base Sys_Milliseconds( ); Sys_ParseArgs( argc, argv ); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init( commandLine ); NET_Init( ); CON_Init( ); signal( SIGILL, Sys_SigHandler ); signal( SIGFPE, Sys_SigHandler ); signal( SIGSEGV, Sys_SigHandler ); signal( SIGTERM, Sys_SigHandler ); while( 1 ) { #if !defined(NOKIA) #ifndef DEDICATED int appState = SDL_GetAppState( ); Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) ); #endif #endif IN_Frame( ); Com_Frame( ); } return 0; }
int main ( int argc, char **argv ) { char commandLine[ MAX_STRING_CHARS ] = { 0 }; // int startTime, endTime; SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF ); // _CrtSetBreakAlloc(34804); Sys_CreateConsole(); // no abort/retry/fail errors SetErrorMode( SEM_FAILCRITICALERRORS ); // get the initial time base Sys_Milliseconds(); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( int i = 1; i < argc; i++ ) { const bool containsSpaces = (strchr(argv[i], ' ') != NULL); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); if (containsSpaces) Q_strcat( commandLine, sizeof( commandLine ), "\"" ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init( commandLine ); QuickMemTest(); // 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 // make sure mouse and joystick are only called once a frame IN_Frame(); // run the game Com_Frame(); } }
/* ================= main ================= */ int main( int argc, char **argv ) { int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; struct MET_Freq *freq; // Look for any of my arguments first. argv = ls_pref_load(&argc, argv); MET_Init(MET_GlobalFile(), "ioquake.met"); freq = (struct MET_Freq*) malloc( sizeof(struct MET_Freq) + (sizeof(double) * 1024)); MET_FreqInit(freq, MET_GlobalFile(), freq_pattern, 1024); #ifndef DEDICATED // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time const SDL_version *ver = SDL_Linked_Version( ); #define STRING(s) #s #define XSTRING(s) STRING(s) #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) < SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) ) { Sys_Print( "SDL version " MINSDL_VERSION " or greater required\n" ); Sys_Exit( 1 ); } #endif Sys_PlatformInit( ); Sys_ParseArgs( argc, argv ); Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) ); Sys_SetDefaultInstallPath( DEFAULT_BASEDIR ); // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); Q_strcat( commandLine, sizeof( commandLine ), " " ); } Com_Init( commandLine ); NET_Init( ); CON_Init( ); signal( SIGILL, Sys_SigHandler ); signal( SIGFPE, Sys_SigHandler ); signal( SIGSEGV, Sys_SigHandler ); signal( SIGTERM, Sys_SigHandler ); while( 1 ) { MET_FreqSample(freq); QUAKE_CORE_LOOP_START(); #ifndef DEDICATED int appState = SDL_GetAppState( ); Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) ); #endif IN_Frame( ); // (LS) Input processing Com_Frame( ); // (LS) Everything else. QUAKE_CORE_LOOP_END(); MET_ClientCount(); } return 0; }
/* ================= main ================= */ int main(int argc, char **argv) { int i; char commandLine[MAX_STRING_CHARS] = { 0 }; #ifndef DEDICATED // SDL version check // Compile time # if !SDL_VERSION_ATLEAST(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH) # error A more recent version of SDL is required # endif // Run time const SDL_version *ver = SDL_Linked_Version(); #define MINSDL_VERSION \ XSTRING(MINSDL_MAJOR) "." \ XSTRING(MINSDL_MINOR) "." \ XSTRING(MINSDL_PATCH) if (SDL_VERSIONNUM(ver->major, ver->minor, ver->patch) < SDL_VERSIONNUM(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH)) { Sys_Dialog(DT_ERROR, va("SDL version " MINSDL_VERSION " or greater is required, " "but only version %d.%d.%d was found. You may be able to obtain a more recent copy " "from http://www.libsdl.org/.", ver->major, ver->minor, ver->patch), "SDL Library Too Old"); Sys_Exit(1); } #endif #ifdef __MORPHOS__ // don't let locales with decimal comma screw up the string to float conversions setlocale(LC_NUMERIC, "C"); DynLoadBase = OpenLibrary("dynload.library", 51); if (DynLoadBase && DynLoadBase->lib_Revision < 3) { CloseLibrary(DynLoadBase); DynLoadBase = NULL; } if (!DynLoadBase) { Sys_Dialog(DT_ERROR, "Unable to open dynload.library version 51.3 or newer", "dynload.library error"); Sys_Exit(1); } #endif Sys_PlatformInit(); // Set the initial time base Sys_Milliseconds(); Sys_ParseArgs(argc, argv); #if defined(__APPLE__) && !defined(DEDICATED) // argv[0] would be /Users/seth/etlegacy/etl.app/Contents/MacOS // But on OS X we want to pretend the binary path is the .app's parent // So that way the base folder is right next to the .app allowing { char parentdir[1024]; CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); if (!url) { Sys_Dialog(DT_ERROR, "A CFURL for the app bundle could not be found.", "Can't set Sys_SetBinaryPath"); Sys_Exit(1); } CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); if (!url2 || !CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, 1024)) { Sys_Dialog(DT_ERROR, "CFURLGetFileSystemRepresentation returned an error when finding the app bundle's parent directory.", "Can't set Sys_SetBinaryPath"); Sys_Exit(1); } Sys_SetBinaryPath(parentdir); CFRelease(url); CFRelease(url2); } #else Sys_SetBinaryPath(Sys_Dirname(argv[0])); #endif Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Sys_BinaryPath() by default // Concatenate the command line for passing to Com_Init for (i = 1; i < argc; i++) { const qboolean containsSpaces = (qboolean)(strchr(argv[i], ' ') != NULL); if (containsSpaces) { Q_strcat(commandLine, sizeof(commandLine), "\""); } Q_strcat(commandLine, sizeof(commandLine), argv[i]); if (containsSpaces) { Q_strcat(commandLine, sizeof(commandLine), "\""); } Q_strcat(commandLine, sizeof(commandLine), " "); } Com_Init(commandLine); NET_Init(); #ifdef FEATURE_CURSES if (nocurses) { CON_Init_tty(); } else { CON_Init(); } #else CON_Init(); #endif signal(SIGILL, Sys_SigHandler); signal(SIGFPE, Sys_SigHandler); signal(SIGSEGV, Sys_SigHandler); signal(SIGTERM, Sys_SigHandler); signal(SIGINT, Sys_SigHandler); while (1) { IN_Frame(); Com_Frame(); } return 0; }