int main (int c, char **v) { double time, oldtime, newtime; quakeparms_t parms; int j; // static char cwd[1024]; // signal(SIGFPE, floating_point_exception_handler); signal(SIGFPE, SIG_IGN); memset(&parms, 0, sizeof(parms)); COM_InitArgv(c, v); parms.argc = com_argc; parms.argv = com_argv; parms.memsize = 16*1024*1024; j = COM_CheckParm("-mem"); if (j) parms.memsize = (int) (Q_atof(com_argv[j+1]) * 1024 * 1024); parms.membase = malloc (parms.memsize); parms.basedir = basedir; // caching is disabled by default, use -cachedir to enable // parms.cachedir = cachedir; noconinput = COM_CheckParm("-noconinput"); if (!noconinput) fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); if (COM_CheckParm("-nostdout")) nostdout = 1; Sys_Init(); Host_Init(&parms); oldtime = Sys_DoubleTime (); while (1) { // find time spent rendering last frame newtime = Sys_DoubleTime (); time = newtime - oldtime; Host_Frame(time); oldtime = newtime; } }
void retro_run(void) { unsigned char *ilineptr = (unsigned char*)vid.buffer; unsigned short *olineptr = (unsigned short*)finalimage; unsigned y, x; // find time spent rendering last frame newtime = Sys_DoubleTime(); _time = newtime - oldtime; #ifdef NQ_HACK if (cls.state == ca_dedicated) { if (_time < sys_ticrate.value) { Sys_Sleep(); //TODO - do something proper for this instead of just 'returning' //continue; // not time to run a server only tic yet return; } _time = sys_ticrate.value; } if (_time > sys_ticrate.value * 2) oldtime = newtime; else oldtime += _time; #endif #ifdef QW_HACK oldtime = newtime; #endif Host_Frame(_time); for (y = 0; y < BASEHEIGHT; ++y) { for (x = 0; x < BASEWIDTH; ++x) *olineptr++ = palette_data[*ilineptr++]; } video_cb(finalimage, BASEWIDTH, BASEHEIGHT, BASEWIDTH << 1); float samples_per_frame = 2 * SAMPLERATE / framerate.value; unsigned read_end = audio_buffer_ptr + samples_per_frame; if (read_end > AUDIO_BUFFER_SAMPLES) read_end = AUDIO_BUFFER_SAMPLES; unsigned read_first = read_end - audio_buffer_ptr; unsigned read_second = samples_per_frame - read_first; audio_batch_cb(audio_buffer + audio_buffer_ptr, read_first >> 1); audio_buffer_ptr = (audio_buffer_ptr + read_first) & (AUDIO_BUFFER_SAMPLES - 1); audio_batch_cb(audio_buffer + audio_buffer_ptr, read_second >> 1); }
int main (int argc, char **argv) { double time, oldtime, newtime; #ifdef PARANOID signal(SIGFPE, floating_point_exception_handler); #else signal(SIGFPE, SIG_IGN); #endif #ifdef hpux // makes it possible to access unaligned pointers (e.g. inside structures) // must be linked with libhpp.a to work (add -lhppa to LDFLAGS) allow_unaligned_data_access(); #endif // we need to check for -noconinput and -nostdout // before Host_Init is called COM_InitArgv (argc, argv); noconinput = COM_CheckParm("-noconinput"); if (!noconinput) fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NDELAY); if (COM_CheckParm("-nostdout")) nostdout = 1; #if id386 Sys_SetFPCW(); #endif Host_Init (argc, argv, 32*1024*1024); oldtime = Sys_DoubleTime (); while (1) { if (dedicated) NET_Sleep (10); // find time spent rendering last frame newtime = Sys_DoubleTime (); time = newtime - oldtime; Host_Frame(time); oldtime = newtime; } return 0; }
static int main_real() { printf("Mounting drive\n"); { FATFS fso; FIL myfile; int r; memset(&fso, 0, sizeof(fso)); memset(&myfile, 0, sizeof(myfile)); r = f_mount(0, &fso); if (r == 0) printf("Succeeded\n"); else printf("Failed\n"); } { double mytime, oldtime, newtime; char *myargv[] = { "fodquake", 0 }; printf("Calling Host_Init()\n"); #if 0 cl.frames = malloc(sizeof(*cl.frames)*UPDATE_BACKUP); memset(cl.frames, 0, sizeof(*cl.frames)*UPDATE_BACKUP); #endif Host_Init(1, myargv, 10*1024*1024); oldtime = Sys_DoubleTime(); while(1) { newtime = Sys_DoubleTime(); mytime = newtime - oldtime; oldtime = newtime; Host_Frame(mytime); } Sys_Error("End of app"); return 0; } }
/* main */ int SDL_main (int c, char **v) { double time, oldtime, newtime; int j; #ifndef WIN32 signal (SIGFPE, SIG_IGN); #endif memset (&host_parms, 0, sizeof (host_parms)); COM_InitArgv (c, v); host_parms.argc = com_argc; host_parms.argv = com_argv; host_parms.memsize = 16 * 1024 * 1024; // 16MB default heap j = COM_CheckParm ("-mem"); if (j) host_parms.memsize = (int) (atof (com_argv[j + 1]) * 1024 * 1024); host_parms.membase = malloc (host_parms.memsize); if (!host_parms.membase) { printf ("Can't allocate memory for zone.\n"); return 1; } #ifndef WIN32 noconinput = COM_CheckParm ("-noconinput"); if (!noconinput) fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NONBLOCK); #endif Host_Init (); oldtime = Sys_DoubleTime (); while (1) { // find time spent rendering last frame newtime = Sys_DoubleTime (); time = newtime - oldtime; Host_Frame (time); oldtime = newtime; } }
int main (int argc, char **argv) { static quakeparms_t parms; float time, oldtime, newtime; signal(SIGFPE, SIG_IGN); SifInitRpc(0); LoadModules(); /* if(mcInit(MC_TYPE_MC) < 0) { printf("Failed to initialise memcard\n"); SleepThread(); } */ inithandle(); parms.memsize = 24*1024*1024; parms.membase = malloc (parms.memsize); parms.basedir = "."; COM_InitArgv (argc, argv); parms.argc = com_argc; parms.argv = com_argv; printf ("Host_Init\n"); Host_Init (&parms); start_ps2_timer(); oldtime = Sys_FloatTime () - 0.1; while (1) { // find time spent rendering last frame newtime = Sys_FloatTime (); time = newtime - oldtime; oldtime = newtime; Host_Frame (time); } stop_ps2_timer(); return 0; }
int main (int argc, char **argv) { #ifdef hpux // makes it possible to access unaligned pointers (e.g. inside structures) // must be linked with libhpp.a to work (add -lhppa to LDFLAGS) allow_unaligned_data_access(); #endif printf ("Host_Init\n"); Host_Init (argc, argv, 5861376); while (1) { Host_Frame (0.1); } return 0; }
int main (int argc, char **argv) { float time, oldtime; APT_CheckNew3DS(&isN3DS); if(isN3DS) osSetSpeedupEnable(true); gfxInit(GSP_RGB565_OES,GSP_RGB565_OES,false); gfxSetDoubleBuffering(GFX_TOP, false); gfxSetDoubleBuffering(GFX_BOTTOM, false); gfxSet3D(true); consoleInit(GFX_BOTTOM, NULL); #ifdef _3DS_CIA if(chdir("sdmc:/3ds/ctrQuake") != 0) Sys_Error("Could not find folder: sdmc:/3ds/ctrQuake"); #endif static quakeparms_t parms; parms.memsize = 24*1024*1024; parms.membase = malloc (parms.memsize); parms.basedir = "."; COM_InitArgv (argc, argv); parms.argc = com_argc; parms.argv = com_argv; Host_Init (&parms); Sys_Init(); oldtime = Sys_FloatTime() -0.1; while (aptMainLoop()) { time = Sys_FloatTime(); separation_distance = osGet3DSliderState(); Host_Frame (time - oldtime); oldtime = time; } gfxExit(); return 0; }
void main (int argc, char **argv) { static quakeparms_t parms; parms.memsize = 8*1024*1024; parms.membase = malloc (parms.memsize); parms.basedir = "."; COM_InitArgv (argc, argv); parms.argc = com_argc; parms.argv = com_argv; printf ("Host_Init\n"); Host_Init (&parms); while (1) { Host_Frame (0.1); } }
int AndroidStep(int width, int height) { // PMPBEGIN(("AndroidStep")); double time, newtime; if(!gInitialized) AndroidInit2(width, height); scr_width = width; scr_height = height; // find time spent rendering last frame newtime = Sys_FloatTime (); time = newtime - g_oldtime; UpdateFrameTimes(time); Host_Frame(time); g_oldtime = newtime; // PMPEND(("AndroidStep")); return key_dest == key_game; }
int main(int argc, char *argv[]) { SDL_Event event; double time, lasttime; int i, length, x, y; bool done; /* Hethrep: Remove traps for signals if DEBUG env var is set * so print_backtrace doesn't get called anymore, * this allows proper coredumps and backtraces for SIGSEGV. * print_backtrace is mostly useless but cleans up after a crash, * so it is useful for users, but bad for backtracing / debugging. */ #ifndef DEBUG if(NULL == getenv("DEBUG")) { signal(SIGILL, print_backtrace); signal(SIGQUIT, print_backtrace); signal(SIGABRT, print_backtrace); signal(SIGFPE, print_backtrace); signal(SIGSEGV, print_backtrace); signal(SIGBUS, print_backtrace); #ifdef SIGSYS signal(SIGSYS, print_backtrace); #endif printf("traps installed\n"); } else #endif printf("DEBUG enabled\n"); Completion_Init(); System_Init(); //Big: PhysFS init needs the command line PHYSFS_init(argv[0]); PHYSFS_setSaneConfig("savage", "", NULL, 0, 0); length = 1; for (i = 0; i < argc; i++) length += 1 + strlen(argv[i]); sys_cmdline = Tag_Malloc(length, MEM_SYSTEM); strcpy(sys_cmdline, ""); for (i = 0; i < argc; i++) { strcat(sys_cmdline, argv[i]); strcat(sys_cmdline, " "); } signal(SIGCHLD, killchild); /* this eliminates zombies */ Host_Init(); Cmd_Register("launchurl", &LaunchURL_cmd); //hash the file once it's already opened, to make a file switch harder //engine_hashlen = Hash_Filename(argv[0], (unsigned char*)engine_hash); lasttime = System_Milliseconds(); sys_time = 0; SDL_EnableUNICODE(sys_useUnicode.integer); #ifdef linux Clipboard_Init(); #endif while(1) { int elapsed; if (!sys_forcefocus.integer && (dedicated_server.integer || sys_sleep.integer || !sys_focus.integer)) System_Sleep(1); //allow time for other processes //the following loop is necessary because System_GetTime() - lasttime could be dangerously close to 0 do { time = System_Milliseconds(); } while (time-lasttime < 1); elapsed = (time-lasttime); if (gfx.integer) { ResetButtonData(); /* Check if there's a pending event. */ while( SDL_PollEvent( &event ) ) { done = HandleEvent(&event); } SDL_GetMouseState(&x, &y); //if(y != Vid_GetScreenH()>>1 && x != Vid_GetScreenW()>>1) { if (inverty.integer) y = Vid_GetScreenH() - y; Input_UpdateMouse(x, y); //} } if (sys_useUnicode.modified) { SDL_EnableUNICODE(sys_useUnicode.integer); sys_useUnicode.modified = false; } sys_time += elapsed; Host_Frame((float)elapsed); lasttime = time; } return TRUE; //this will never get called }
int main (int c, char **v) { double time, oldtime, newtime; quakeparms_t parms; extern int vcrFile; extern int recording; int j; // static char cwd[1024]; // signal(SIGFPE, floating_point_exception_handler); signal(SIGFPE, SIG_IGN); memset(&parms, 0, sizeof(parms)); COM_InitArgv(c, v); parms.argc = com_argc; parms.argv = com_argv; #ifdef GLQUAKE parms.memsize = 16*1024*1024; #else parms.memsize = 8*1024*1024; #endif j = COM_CheckParm("-mem"); if (j) parms.memsize = (int) (Q_atof(com_argv[j+1]) * 1024 * 1024); parms.membase = malloc (parms.memsize); parms.basedir = basedir; // caching is disabled by default, use -cachedir to enable // parms.cachedir = cachedir; fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); Host_Init(&parms); Sys_Init(); if (COM_CheckParm("-nostdout")) nostdout = 1; else { fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); printf ("Linux Quake -- Version %0.3f\n", LINUX_VERSION); } oldtime = Sys_FloatTime () - 0.1; while (1) { // find time spent rendering last frame newtime = Sys_FloatTime (); time = newtime - oldtime; if (cls.state == ca_dedicated) { // play vcrfiles at max speed if (time < sys_ticrate.value && (vcrFile == -1 || recording) ) { usleep(1); continue; // not time to run a server only tic yet } time = sys_ticrate.value; } if (time > sys_ticrate.value*2) oldtime = newtime; else oldtime += time; Host_Frame (time); // graphic debugging aids if (sys_linerefresh.value) Sys_LineRefresh (); } }
/* ================= Host_Main ================= */ int EXPORT Host_Main( int argc, const char **argv, const char *progname, int bChangeGame, pfnChangeGame func ) { static double oldtime, newtime; #ifdef XASH_SDL SDL_Event event; #endif pChangeGame = func; // may be NULL Host_InitCommon( argc, argv, progname, bChangeGame ); // init commands and vars if( host.developer >= 3 ) { Cmd_AddCommand ( "sys_error", Sys_Error_f, "just throw a fatal error to test shutdown procedures"); Cmd_AddCommand ( "host_error", Host_Error_f, "just throw a host error to test shutdown procedures"); Cmd_AddCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons"); Cmd_AddCommand ( "net_error", Net_Error_f, "send network bad message from random place"); } host_cheats = Cvar_Get( "sv_cheats", "0", CVAR_LATCH, "allow usage of cheat commands and variables" ); host_maxfps = Cvar_Get( "fps_max", "72", CVAR_ARCHIVE, "host fps upper limit" ); host_sleeptime = Cvar_Get( "sleeptime", "1", CVAR_ARCHIVE, "higher value means lower accuracy" ); host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" ); host_serverstate = Cvar_Get( "host_serverstate", "0", CVAR_INIT, "displays current server state" ); host_gameloaded = Cvar_Get( "host_gameloaded", "0", CVAR_INIT, "indicates a loaded game library" ); host_clientloaded = Cvar_Get( "host_clientloaded", "0", CVAR_INIT, "indicates a loaded client library" ); host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" ); con_gamemaps = Cvar_Get( "con_mapfilter", "1", CVAR_ARCHIVE, "when enabled, show only maps in game folder (no maps from base folder when running mod)" ); download_types = Cvar_Get( "download_types", "msec", CVAR_ARCHIVE, "list of types to download: Model, Sounds, Events, Custom" ); build = Cvar_Get( "build", va( "%i", Q_buildnum()), CVAR_INIT, "returns a current build number" ); ver = Cvar_Get( "ver", va( "%i/%s.%i", PROTOCOL_VERSION, XASH_VERSION, Q_buildnum( ) ), CVAR_INIT, "shows an engine version" ); host_mapdesign_fatal = Cvar_Get( "host_mapdesign_fatal", "1", CVAR_ARCHIVE, "make map design errors fatal" ); host_xashds_hacks = Cvar_Get( "xashds_hacks", "0", 0, "hacks for xashds in singleplayer" ); // content control Cvar_Get( "violence_hgibs", "1", CVAR_ARCHIVE, "show human gib entities" ); Cvar_Get( "violence_agibs", "1", CVAR_ARCHIVE, "show alien gib entities" ); Cvar_Get( "violence_hblood", "1", CVAR_ARCHIVE, "draw human blood" ); Cvar_Get( "violence_ablood", "1", CVAR_ARCHIVE, "draw alien blood" ); if( host.type != HOST_DEDICATED ) { // when we're in developer-mode, automatically turn cheats on if( host.developer > 1 ) Cvar_SetFloat( "sv_cheats", 1.0f ); Cbuf_AddText( "exec video.cfg\n" ); } Mod_Init(); NET_Init(); Netchan_Init(); // allow to change game from the console if( pChangeGame != NULL ) { Cmd_AddCommand( "game", Host_ChangeGame_f, "change active game/mod" ); Cvar_Get( "host_allow_changegame", "1", CVAR_READ_ONLY, "whether changing game/mod is allowed" ); } else { Cvar_Get( "host_allow_changegame", "0", CVAR_READ_ONLY, "allows to change games" ); } SV_Init(); CL_Init(); HTTP_Init(); // post initializations switch( host.type ) { case HOST_NORMAL: Con_ShowConsole( false ); // hide console // execute startup config and cmdline Cbuf_AddText( va( "exec %s.rc\n", SI.ModuleName )); // intentional fallthrough case HOST_DEDICATED: // if stuffcmds wasn't run, then init.rc is probably missing, use default if( !host.stuffcmdsrun ) Cbuf_AddText( "stuffcmds\n" ); Cbuf_Execute(); break; case HOST_UNKNOWN: break; } if( host.type == HOST_DEDICATED ) { char *defaultmap; Con_InitConsoleCommands (); Cmd_AddCommand( "quit", Sys_Quit, "quit the game" ); Cmd_AddCommand( "exit", Sys_Quit, "quit the game" ); SV_InitGameProgs(); Cbuf_AddText( "exec config.cfg\n" ); // dedicated servers are using settings from server.cfg file Cbuf_AddText( va( "exec %s\n", Cvar_VariableString( "servercfgfile" ))); Cbuf_Execute(); defaultmap = Cvar_VariableString( "defaultmap" ); if( !defaultmap[0] ) Msg( "Please add \"defaultmap\" cvar with default map name to your server.cfg!\n" ); else Cbuf_AddText( va( "map %s\n", defaultmap )); Cvar_FullSet( "xashds_hacks", "0", CVAR_READ_ONLY ); NET_Config( true ); } else { Cmd_AddCommand( "minimize", Host_Minimize_f, "minimize main window to taskbar" ); Cbuf_AddText( "exec config.cfg\n" ); // listenserver/multiplayer config. // need load it to update menu options. Cbuf_AddText( "exec game.cfg\n" ); } host.errorframe = 0; Cbuf_Execute(); host.change_game = false; // done Cmd_RemoveCommand( "setr" ); // remove potential backdoor for changing renderer settings Cmd_RemoveCommand( "setgl" ); // we need to execute it again here if( host.type != HOST_DEDICATED ) Cmd_ExecuteString( "exec config.cfg\n", src_command ); // exec all files from userconfig.d Host_Userconfigd_f(); oldtime = Sys_DoubleTime(); IN_TouchInitConfig(); SCR_CheckStartupVids(); // must be last #ifdef XASH_SDL SDL_StopTextInput(); // disable text input event. Enable this in chat/console? #endif if( host.state == HOST_INIT ) host.state = HOST_FRAME; // initialization is finished // main window message loop while( !host.crashed && !host.shutdown_issued ) { #ifdef XASH_SDL while( !host.crashed && !host.shutdown_issued && SDL_PollEvent( &event ) ) SDLash_EventFilter( &event ); #endif newtime = Sys_DoubleTime (); Host_Frame( newtime - oldtime ); oldtime = newtime; } // never reached return 0; }
int main(int argc, char *argv[]) { int t; double time, oldtime, newtime; host_parms = &parms; parms.basedir = "."; parms.argc = argc; parms.argv = argv; COM_InitArgv(parms.argc, parms.argv); isDedicated = (COM_CheckParm("-dedicated") != 0); Sys_CheckSDL (); Sys_Init(); // default memory size // TODO: less mem, eg. 16 mb, for dedicated server?? parms.memsize = DEFAULT_MEMORY; if (COM_CheckParm("-heapsize")) { t = COM_CheckParm("-heapsize") + 1; if (t < com_argc) parms.memsize = Q_atoi(com_argv[t]) * 1024; } parms.membase = malloc (parms.memsize); if (!parms.membase) Sys_Error ("Not enough memory free; check disk space\n"); Sys_Printf("Quake %1.2f (c) id Software\n", VERSION); Sys_Printf("GLQuake %1.2f (c) id Software\n", GLQUAKE_VERSION); Sys_Printf("FitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION); Sys_Printf("FitzQuake SDL port (c) SleepwalkR, Baker\n"); Sys_Printf("QuakeSpasm %1.2f.%d (c) Ozkan Sezer, Stevenaaus\n", FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH); Sys_Printf("RiftQuake %1.2f\n", RIFTQUAKE_VERSION); Sys_Printf("Host_Init\n"); Host_Init(); oldtime = Sys_DoubleTime(); if (isDedicated) { while (1) { newtime = Sys_DoubleTime (); time = newtime - oldtime; while (time < sys_ticrate.value ) { SDL_Delay(1); newtime = Sys_DoubleTime (); time = newtime - oldtime; } Host_Frame (time); oldtime = newtime; } } else while (1) { appState = SDL_GetAppState(); /* If we have no input focus at all, sleep a bit */ if ( !(appState & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) || cl.paused) { SDL_Delay(16); } /* If we're minimised, sleep a bit more */ if ( !(appState & SDL_APPACTIVE) ) { scr_skipupdate = 1; SDL_Delay(32); } else { scr_skipupdate = 0; } newtime = Sys_DoubleTime (); time = newtime - oldtime; Host_Frame (time); if (time < sys_throttle.value) SDL_Delay(1); oldtime = newtime; } return 0; }
int main(int argc,char** argv) { // fixme chdir("/Users/josh/Dev/ThunderBeastGames/Mongrel/artifacts"); try { GArgs.Init(argc, argv); if (SDL_Init(SDL_INIT_VIDEO) < 0) { Sys_Error("SDL_InitSubSystem(): %s\n",SDL_GetError()); } // Install signal handlers signal(SIGABRT, signal_handler); signal(SIGFPE, signal_handler); signal(SIGILL, signal_handler); signal(SIGSEGV, signal_handler); signal(SIGTERM, signal_handler); signal(SIGINT, signal_handler); signal(SIGKILL, signal_handler); signal(SIGQUIT, signal_handler); Host_Init(); while (1) { Host_Frame(); // Cmd processing was moved here (and removed from Host_Init/Host_Frame // a side effect of removing it from Host_Init is that it becomes impossible // to set some variables before refresh inits, etc // Though, for instance the +map command tries to load a level before the // refresh/graphics driver is initialized, which causes texture generation for example // to fail (refresh is initialized in first Host_Frame screen update //Process console commands GCmdBuf.Exec(); } } catch (VavoomError &e) { Host_Shutdown(); stack_trace(); printf("\n%s\n", e.message); dprintf("\n\nERROR: %s\n", e.message); SDL_Quit(); exit(1); } catch (...) { Host_Shutdown(); dprintf("\n\nExiting due to external exception\n"); fprintf(stderr, "\nExiting due to external exception\n"); throw; } }
static void* main_thread_function(void*) { u32 level, real_heap_size; // hope the parms are all set by now COM_InitArgv(parms_number, parms_array); _CPU_ISR_Disable(level); heap = (char *)align32(SYS_GetArena2Lo()); real_heap_size = heap_size - ((u32)heap - (u32)SYS_GetArena2Lo()); if ((u32)heap + real_heap_size > (u32)SYS_GetArena2Hi()) { _CPU_ISR_Restore(level); Sys_Error("heap + real_heap_size > (u32)SYS_GetArena2Hi()"); } else { SYS_SetArena2Lo(heap + real_heap_size); _CPU_ISR_Restore(level); } VIDEO_SetBlack(TRUE); // Initialise the Host module. quakeparms_t parms; memset(&parms, 0, sizeof(parms)); parms.argc = com_argc; parms.argv = com_argv; parms.basedir = QUAKE_WII_BASEDIR; parms.memsize = real_heap_size; parms.membase = heap; if (parms.membase == 0) { Sys_Error("Heap allocation failed"); } memset(parms.membase, 0, parms.memsize); Host_Init(&parms); #if TIME_DEMO Cbuf_AddText("map start\n"); Cbuf_AddText("wait\n"); Cbuf_AddText("timedemo demo1\n"); #endif #if TEST_CONNECTION Cbuf_AddText("connect 192.168.0.2"); #endif SYS_SetResetCallback(reset_system); SYS_SetPowerCallback(shutdown_system); VIDEO_SetBlack(FALSE); // Run the main loop. u64 last_time = gettime(); for (;;) { if (want_to_reset) Sys_Reset(); if (want_to_shutdown) Sys_Shutdown(); // Get the frame time in ticks. const u64 current_time = gettime(); const u64 time_delta = current_time - last_time; const double seconds = time_delta * (0.001f / TB_TIMER_CLOCK); last_time = current_time; // Run the frame. Host_Frame(seconds); }; // Quit (this code is never reached). Sys_Quit(); return 0; }
int main(int c, char **v) { double time, oldtime, newtime; quakeparms_t parms; int j; // signal(SIGFPE, floating_point_exception_handler); signal(SIGFPE, SIG_IGN); memset(&parms, 0, sizeof(parms)); COM_InitArgv(c, v); parms.argc = com_argc; parms.argv = com_argv; #ifdef GLQUAKE parms.memsize = 16 * 1024 * 1024; #else parms.memsize = 8 * 1024 * 1024; #endif j = COM_CheckParm("-mem"); if (j) parms.memsize = (int)(Q_atof(com_argv[j + 1]) * 1024 * 1024); parms.membase = malloc(parms.memsize); parms.basedir = stringify(QBASEDIR); // caching is disabled by default, use -cachedir to enable // parms.cachedir = cachedir; fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK); Host_Init(&parms); Sys_Init(); if (COM_CheckParm("-nostdout")) nostdout = true; // Make stdin non-blocking // FIXME - check both return values if (!noconinput) fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK); if (!nostdout) printf("TyrQuake -- Version %s\n", stringify(TYR_VERSION)); oldtime = Sys_DoubleTime() - 0.1; while (1) { // find time spent rendering last frame newtime = Sys_DoubleTime(); time = newtime - oldtime; if (cls.state == ca_dedicated) { if (time < sys_ticrate.value) { usleep(1); continue; // not time to run a server only tic yet } time = sys_ticrate.value; } if (time > sys_ticrate.value * 2) oldtime = newtime; else oldtime += time; Host_Frame(time); // graphic debugging aids if (sys_linerefresh.value) Sys_LineRefresh(); } }
int main (int argc, char **argv) { SDL_Window *window; double newtime, oldtime; int previous_key_dest = 0; if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { printf("SDL_Init error: %s\n", SDL_GetError()); return 1; } window = SDL_CreateWindow("NullQuake", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0); if (window == NULL) { Con_Printf("SDL_CreateWindow error: %s\n", SDL_GetError()); SDL_Quit(); return 1; } windowID = SDL_GetWindowID(window); SDL_DisableScreenSaver(); static quakeparms_t parms; parms.memsize = 8*1024*1024; parms.membase = malloc (parms.memsize); char *base_path = SDL_GetBasePath(); if (base_path) { parms.basedir = SDL_strdup(base_path); SDL_free(base_path); } else { parms.basedir = SDL_strdup("./"); } COM_InitArgv (argc, argv); parms.argc = com_argc; parms.argv = com_argv; printf ("Host_Init\n"); Host_Init (&parms); oldtime = Sys_FloatTime(); while (1) { // release mouse cursor in menus if (previous_key_dest != key_dest) { if (key_dest == key_game) { SDL_SetRelativeMouseMode(SDL_TRUE); } else { SDL_SetRelativeMouseMode(SDL_FALSE); } previous_key_dest = key_dest; } // throttle in background if (!isFocused) { SDL_Delay(32); } newtime = Sys_FloatTime(); Host_Frame(newtime - oldtime); oldtime = newtime; } return 0; }
int main(int c, const char **v) { double time, oldtime, newtime; quakeparms_t parms; int j; signal(SIGFPE, SIG_IGN); memset(&parms, 0, sizeof(parms)); COM_InitArgv(c, v); parms.argc = com_argc; parms.argv = com_argv; parms.memsize = 16 * 1024 * 1024; j = COM_CheckParm("-mem"); if (j) parms.memsize = (int)(Q_atof(com_argv[j + 1]) * 1024 * 1024); parms.membase = malloc(parms.memsize); parms.basedir = stringify(QBASEDIR); if (COM_CheckParm("-noconinput")) noconinput = true; if (COM_CheckParm("-nostdout")) nostdout = true; // Make stdin non-blocking // FIXME - check both return values if (!noconinput) fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK); if (!nostdout) #ifdef NQ_HACK printf("Quake -- TyrQuake Version %s\n", stringify(TYR_VERSION)); #endif #ifdef QW_HACK printf("QuakeWorld -- TyrQuake Version %s\n", stringify(TYR_VERSION)); #endif Sys_Init(); Host_Init(&parms); #ifdef NQ_HACK oldtime = Sys_DoubleTime() - 0.1; #endif #ifdef QW_HACK oldtime = Sys_DoubleTime(); #endif while (1) { // find time spent rendering last frame newtime = Sys_DoubleTime(); time = newtime - oldtime; #ifdef NQ_HACK if (cls.state == ca_dedicated) { if (time < sys_ticrate.value) { usleep(1); continue; // not time to run a server only tic yet } time = sys_ticrate.value; } if (time > sys_ticrate.value * 2) oldtime = newtime; else oldtime += time; #endif #ifdef QW_HACK oldtime = newtime; #endif Host_Frame(time); } return 0; }
int main (int argc, char **argv) { double time, oldtime, newtime; PrintVersion(); // make sure there's an FPU signal(SIGNOFP, Sys_NoFPUExceptionHandler); signal(SIGABRT, Sys_DefaultExceptionHandler); signal(SIGALRM, Sys_DefaultExceptionHandler); signal(SIGKILL, Sys_DefaultExceptionHandler); signal(SIGQUIT, Sys_DefaultExceptionHandler); signal(SIGINT, Sys_DefaultExceptionHandler); if (fptest_temp >= 0.0) fptest_temp += 0.1; dos_error_func = Sys_Error; memset (cwd, 0, sizeof(cwd)); if (Sys_GetBasedir(argv[0], cwd, sizeof(cwd)) != 0) Sys_Error ("Couldn't determine current directory"); /* initialize the host params */ memset (&quakeparms, 0, sizeof(quakeparms)); quakeparms.basedir = cwd; quakeparms.userdir = cwd; quakeparms.argc = argc; quakeparms.argv = argv; host_parms = &quakeparms; LOG_Init (&quakeparms); COM_ValidateByteorder (); Sys_DetectWin95 (); Sys_PageInProgram (); Sys_GetMemory (); atexit (Sys_AtExit); // in case we crash isDedicated = (COM_CheckParm ("-dedicated") != 0); Sys_Init (); if (!isDedicated) dos_registerintr(9, TrapKey); // Sys_InitStackCheck (); Host_Init(); // Sys_StackCheck (); // Con_Printf ("Top of stack: 0x%x\n", &time); oldtime = Sys_DoubleTime (); while (1) { newtime = Sys_DoubleTime (); time = newtime - oldtime; if (isDedicated && (time < sys_ticrate.value)) continue; Host_Frame (time); // Sys_StackCheck (); oldtime = newtime; } }
int main (int argc, char **argv) { int i; double time, oldtime; PrintVersion(); if (argc > 1) { for (i = 1; i < argc; i++) { if ( !(strcmp(argv[i], "-v")) || !(strcmp(argv[i], "-version" )) || !(strcmp(argv[i], "--version")) ) { exit(0); } else if ( !(strcmp(argv[i], "-h")) || !(strcmp(argv[i], "-help" )) || !(strcmp(argv[i], "--help")) || !(strcmp(argv[i], "-?")) ) { PrintHelp(argv[0]); exit (0); } } } memset (cwd, 0, sizeof(cwd)); if (Sys_GetBasedir(argv[0], cwd, sizeof(cwd)) != 0) Sys_Error ("Couldn't determine current directory"); /* initialize the host params */ memset (&parms, 0, sizeof(parms)); parms.basedir = cwd; parms.userdir = cwd; /* no userdir on win32 */ parms.argc = argc; parms.argv = argv; host_parms = &parms; LOG_Init (&parms); Sys_Printf("basedir is: %s\n", parms.basedir); Sys_Printf("userdir is: %s\n", parms.userdir); COM_ValidateByteorder (); parms.memsize = STD_MEM_ALLOC; i = COM_CheckParm ("-heapsize"); if (i && i < com_argc-1) { parms.memsize = atoi (com_argv[i+1]) * 1024; if ((parms.memsize > MAX_MEM_ALLOC) && !(COM_CheckParm ("-forcemem"))) { Sys_Printf ("Requested memory (%d Mb) too large, using the default maximum.\n", parms.memsize/(1024*1024)); Sys_Printf ("If you are sure, use the -forcemem switch.\n"); parms.memsize = MAX_MEM_ALLOC; } else if ((parms.memsize < MIN_MEM_ALLOC) && !(COM_CheckParm ("-forcemem"))) { Sys_Printf ("Requested memory (%d Mb) too little, using the default minimum.\n", parms.memsize/(1024*1024)); Sys_Printf ("If you are sure, use the -forcemem switch.\n"); parms.memsize = MIN_MEM_ALLOC; } } parms.membase = malloc (parms.memsize); if (!parms.membase) Sys_Error ("Insufficient memory.\n"); timeBeginPeriod (1); /* 1 ms timer precision */ starttime = timeGetTime (); Host_Init(); oldtime = Sys_DoubleTime (); /* main window message loop */ while (1) { time = Sys_DoubleTime (); if (time - oldtime < sys_ticrate.value ) { Sleep (1); continue; } Host_Frame (time - oldtime); oldtime = time; } return 0; }
int main (int c, char **v) { double time, oldtime, newtime; extern void (*dos_error_func)(char *, ...); static char cwd[1024]; byte screen[80*25*2]; COM_InitArgv (c, v); inthedos = 1; // leilei - stupid hack to let the engine know we're in dos quakeparms.argc = com_argc; quakeparms.argv = com_argv; // moved parm checking up here to get the bottom working... // title image // char ver[6]; // int i; // loadedfile_t *fileinfo; // host_parms = *parms; // Host_Init(&quakeparms); #ifdef BENCH clrscr(); textattr((BLUE<<4)+YELLOW); clreol(); printf (" Lite Engoo Bencher v%4.2f \n",VERSION); textattr((BLUE<<4)+DARKGRAY); #else clrscr(); SetYourBlues(); // COM_Init (parms->basedir); if (COM_CheckParm ("-hipnotic")) { textattr((BLUE<<4)+YELLOW); clreol(); printf (" Quake Mission Pack 1: Scourge of Armagon v%4.2f \n",VERSION); clreol(); printf (" (C)1996 id software (C) 1997 Ritual Entertainment \n",VERSION); } else if (COM_CheckParm ("-rogue")){ textattr((RED<<4)+WHITE); clreol(); printf (" Quake Mission Pack 2: Dissolution of Eternity v%4.2f \n",VERSION); clreol(); printf (" (C)1996 id software (C) 1997 Rogue Entertainment \n",VERSION); } else if (COM_CheckParm ("qsr")){ SetYourBlues(); textattr((BLUE<<4)+YELLOW); clreol(); printf (" HELLSMASH \n",VERSION); //clreol(); } // The notable commercial Quake TCs get their own startup bar ;) else if (COM_CheckParm ("malice")){ textattr((DARKGRAY<<4)+LIGHTRED); clreol(); printf (" Malice v%4.2f \n",VERSION); textattr((DARKGRAY<<4)+WHITE); clreol(); printf (" Copyright C) 1997 Ratloop, Inc. \n",VERSION); } else if (COM_CheckParm ("shrak")){ textattr((CYAN<<4)+WHITE); clreol(); printf (" Shrak v%4.2f \n",VERSION); clreol(); printf (" Copyright C) 1997 Quantum Axcess \n",VERSION); } else if (COM_CheckParm ("xmen")){ textattr((MAGENTA<<4)+YELLOW); clreol(); printf (" X-MEN: Ravages of Apocalypse v%4.2f \n",VERSION); clreol(); printf (" Copyright C) 1997 Zero Gravity / MARVEL Interactive \n",VERSION); } else if (COM_CheckParm ("laser")){ textattr((MAGENTA<<4)+YELLOW); clreol(); printf (" LASER ARENA \n",VERSION); clreol(); printf (" Copyright (C) 2000 Trainwreck Studios / 2015 Inc. \n",VERSION); } else if (COM_CheckParm ("basetf")){ textattr((RED<<4)+YELLOW); clreol(); printf (" TRANSFUSION RELEASE %4.2f ["__DATE__"] -- \n",VERSION); } else if (COM_CheckParm ("grass")){ textattr((BLACK<<4)+YELLOW); clreol(); printf (" Watching Grass Grow \n",VERSION); } else{ // textattr((1<<4)+2); // was yellow textattr((BLUE<<4)+YELLOW); clreol(); // printf (" Quake v%4.2f \n",VERSION); //clreol(); // printf (" Copyright(C)1996 id software \n",VERSION); printf (" ENGOO %4.2f ["__DATE__"] -- \n",VERSION); } #endif // printf ("Build: __DATE__"\n"); //textattr((BLACK<<4)+WHITE); // clreol(); //printf ("Quake v%4.2f\n", VERSION); /* // ANSI start screen never could work so I left it out. Bummer // byte *d; // 2001-09-12 Returning information about loaded file by Maddes fileinfo = COM_LoadHunkFile ("start.bin"); // fileinfo = COM_LoadHunkFile ("end1.bin"); if (fileinfo) memcpy (screen, fileinfo->data, sizeof(screen)); // write the version number directly to the end screen sprintf (ver, " v%4.2f", VERSION); for (i=0 ; i<6 ; i++) screen[0*80*2 + 72*2 + i*2] = ver[i]; if (fileinfo) { memcpy ((void *)real2ptr(0xb8000), screen,80*25*2); // set text pos regs.x.ax = 0x0200; regs.h.bh = 0; regs.h.dl = 0; regs.h.dh = 22; dos_int86 (0x10); } else { } // printf ("WELCOME TO YOUR DOOM!\n"); */ // Do the GPLv2 notice printf ("================================================================================"); printf ("This engine comes with ABSOLUTELY NO WARRANTY;this is Free Software, and you are"); printf (" welcome to redistribute it under certain conditions; see 'COPYING' for details."); printf ("================================================================================"); // make sure there's an FPU signal(SIGNOFP, Sys_NoFPUExceptionHandler); signal(SIGABRT, Sys_DefaultExceptionHandler); signal(SIGALRM, Sys_DefaultExceptionHandler); signal(SIGKILL, Sys_DefaultExceptionHandler); signal(SIGQUIT, Sys_DefaultExceptionHandler); signal(SIGINT, Sys_DefaultExceptionHandler); if (fptest_temp >= 0.0) fptest_temp += 0.1; dos_error_func = Sys_Error; Sys_DetectWin95 (); Sys_PageInProgram (); Sys_GetMemory (); if (COM_CheckParm ("-nolookups")) printf ("!!!!!Generation of lookup tables will be skipped!!!!!\nStuff will not blend and colored lighting will be disabled.\n"); // Prototype stuff atexit (Sys_AtExit); // in case we crash getwd (cwd); if (cwd[strlen(cwd)-1] == '/') cwd[strlen(cwd)-1] = 0; quakeparms.basedir = cwd; //"f:/quake"; isDedicated = (COM_CheckParm ("-dedicated") != 0); Sys_Init (); if (!isDedicated) dos_registerintr(9, TrapKey); //Sys_InitStackCheck (); Host_Init(&quakeparms); //Sys_StackCheck (); //Con_Printf ("Top of stack: 0x%x\n", &time); oldtime = Sys_FloatTime (); while (1) { newtime = Sys_FloatTime (); time = newtime - oldtime; if (cls.state == ca_dedicated && (time<sys_ticrate->value)) continue; Host_Frame (time); //Sys_StackCheck (); oldtime = newtime; } }
/* ================ main ================ */ int main (int c, char **v) { double time, oldtime, newtime; extern void (*dos_error_func)(char *, ...); static char cwd[1024]; printf ("Quake v%4.2f\n", VERSION); // make sure there's an FPU signal(SIGNOFP, Sys_NoFPUExceptionHandler); signal(SIGABRT, Sys_DefaultExceptionHandler); signal(SIGALRM, Sys_DefaultExceptionHandler); signal(SIGKILL, Sys_DefaultExceptionHandler); signal(SIGQUIT, Sys_DefaultExceptionHandler); signal(SIGINT, Sys_DefaultExceptionHandler); if (fptest_temp >= 0.0) fptest_temp += 0.1; COM_InitArgv (c, v); quakeparms.argc = com_argc; quakeparms.argv = com_argv; dos_error_func = Sys_Error; Sys_DetectWin95 (); Sys_PageInProgram (); Sys_GetMemory (); atexit (Sys_AtExit); // in case we crash getwd (cwd); if (cwd[Q_strlen(cwd)-1] == '/') cwd[Q_strlen(cwd)-1] = 0; quakeparms.basedir = cwd; //"f:/quake"; isDedicated = (COM_CheckParm ("-dedicated") != 0); Sys_Init (); if (!isDedicated) dos_registerintr(9, TrapKey); //Sys_InitStackCheck (); Host_Init(&quakeparms); //Sys_StackCheck (); //Con_Printf ("Top of stack: 0x%x\n", &time); oldtime = Sys_FloatTime (); while (1) { newtime = Sys_FloatTime (); time = newtime - oldtime; if (cls.state == ca_dedicated && (time<sys_ticrate.value)) continue; Host_Frame (time); //Sys_StackCheck (); oldtime = newtime; } }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASS wc = { 0 }; wc.lpfnWndProc = MainWndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszClassName = "Module 2"; if (!RegisterClass(&wc)) { return EXIT_FAILURE; } HWND mainWindow; DWORD windowStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE; int width = 800; int height = 600; RECT rectangle = { 0 }; rectangle.bottom = height; rectangle.right = width; AdjustWindowRect(&rectangle, windowStyle, 0); width = rectangle.right - rectangle.left; height = rectangle.bottom - rectangle.top; mainWindow = CreateWindowEx(0, "Module 2", "Lesson 2.6", windowStyle, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL); HDC deviceContext = GetDC(mainWindow); PatBlt(deviceContext, 0, 0, width, height, BLACKNESS); ReleaseDC(mainWindow, deviceContext); Host_Init(); float oldTime = Sys_InitFloatTime(); float targetTime = 1.0f / 60.0f; float timeAccumulated = 0.0f; MSG message; while (IsRunning) { while (PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&message); DispatchMessage(&message); } float newTime = Sys_FloatTime(); float delta = newTime - oldTime; oldTime = newTime; timeAccumulated += delta; if (timeAccumulated >= targetTime) { Host_Frame(targetTime); timeAccumulated -= targetTime; } Sleep(1); } Host_Shutdown(); return 0; }
/* ================= Host_Main ================= */ int EXPORT Host_Main( const char *progname, int bChangeGame, pfnChangeGame func ) { static double oldtime, newtime; pChangeGame = func; // may be NULL if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS )) { MsgDev(D_ERROR, "SDL_Init: %s", SDL_GetError()); return 0; } #ifndef _WIN32 #ifndef __ANDROID__ // Start of IO functions FILE *fd = fopen("/proc/self/cmdline", "r"); char moduleName[64], cmdLine[512] = "", *arg; size_t size = 0; int i = 0; for(i = 0; getdelim(&arg, &size, 0, fd) != -1; i++) { if(!i) { strcpy(moduleName, strrchr(arg, '/')); //strrchr adds a / at begin of string =( memmove(&moduleName[0], &moduleName[1], sizeof(moduleName) - 1); } else { strcat(cmdLine, arg); strcat(cmdLine, " "); } } free(arg); fclose(fd); #endif #else // TODO #endif #ifndef __ANDROID__ Host_InitCommon( moduleName, cmdLine, progname, bChangeGame ); #else Host_InitCommon( NULL, "-dev 3 -log", progname, bChangeGame ); #endif // init commands and vars if( host.developer >= 3 ) { Cmd_AddCommand ( "sys_error", Sys_Error_f, "just throw a fatal error to test shutdown procedures"); Cmd_AddCommand ( "host_error", Host_Error_f, "just throw a host error to test shutdown procedures"); Cmd_AddCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons"); Cmd_AddCommand ( "net_error", Net_Error_f, "send network bad message from random place"); } host_cheats = Cvar_Get( "sv_cheats", "0", CVAR_LATCH, "allow cheat variables to enable" ); host_maxfps = Cvar_Get( "fps_max", "72", CVAR_ARCHIVE, "host fps upper limit" ); host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" ); host_serverstate = Cvar_Get( "host_serverstate", "0", CVAR_INIT, "displays current server state" ); host_gameloaded = Cvar_Get( "host_gameloaded", "0", CVAR_INIT, "inidcates a loaded game.dll" ); host_clientloaded = Cvar_Get( "host_clientloaded", "0", CVAR_INIT, "inidcates a loaded client.dll" ); host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" ); con_gamemaps = Cvar_Get( "con_mapfilter", "1", CVAR_ARCHIVE, "when true show only maps in game folder" ); build = Cvar_Get( "build", va( "%i", Q_buildnum()), CVAR_INIT, "returns a current build number" ); ver = Cvar_Get( "ver", va( "%i/%g (hw build %i)", PROTOCOL_VERSION, XASH_VERSION, Q_buildnum( )), CVAR_INIT, "shows an engine version" ); // content control Cvar_Get( "violence_hgibs", "1", CVAR_ARCHIVE, "show human gib entities" ); Cvar_Get( "violence_agibs", "1", CVAR_ARCHIVE, "show alien gib entities" ); Cvar_Get( "violence_hblood", "1", CVAR_ARCHIVE, "draw human blood" ); Cvar_Get( "violence_ablood", "1", CVAR_ARCHIVE, "draw alien blood" ); if( host.type != HOST_DEDICATED ) { // when we in developer-mode automatically turn cheats on if( host.developer > 1 ) Cvar_SetFloat( "sv_cheats", 1.0f ); Cbuf_AddText( "exec video.cfg\n" ); } Mod_Init(); NET_Init(); Netchan_Init(); // allow to change game from the console if( pChangeGame != NULL ) { Cmd_AddCommand( "game", Host_ChangeGame_f, "change game" ); Cvar_Get( "host_allow_changegame", "1", CVAR_READ_ONLY, "allows to change games" ); } else { Cvar_Get( "host_allow_changegame", "0", CVAR_READ_ONLY, "allows to change games" ); } SV_Init(); CL_Init(); if( host.type == HOST_DEDICATED ) { Con_InitConsoleCommands (); Cmd_AddCommand( "quit", Sys_Quit, "quit the game" ); Cmd_AddCommand( "exit", Sys_Quit, "quit the game" ); // dedicated servers using settings from server.cfg file Cbuf_AddText( va( "exec %s\n", Cvar_VariableString( "servercfgfile" ))); Cbuf_Execute(); Cbuf_AddText( va( "map %s\n", Cvar_VariableString( "defaultmap" ))); } else { Cmd_AddCommand( "minimize", Host_Minimize_f, "minimize main window to tray" ); Cbuf_AddText( "exec config.cfg\n" ); } host.errorframe = 0; Cbuf_Execute(); // post initializations switch( host.type ) { case HOST_NORMAL: Con_ShowConsole( false ); // hide console // execute startup config and cmdline Cbuf_AddText( va( "exec %s.rc\n", SI.ModuleName )); // intentional fallthrough case HOST_DEDICATED: // if stuffcmds wasn't run, then init.rc is probably missing, use default if( !host.stuffcmdsrun ) Cbuf_AddText( "stuffcmds\n" ); Cbuf_Execute(); break; } host.change_game = false; // done Cmd_RemoveCommand( "setr" ); // remove potentially backdoor for change render settings Cmd_RemoveCommand( "setgl" ); // we need to execute it again here Cmd_ExecuteString( "exec config.cfg\n", src_command ); oldtime = Sys_DoubleTime(); SCR_CheckStartupVids(); // must be last SDL_StopTextInput(); // disable text input event. Enable this in chat/console? SDL_Event event; // main window message loop while( !host.crashed ) { while( SDL_PollEvent( &event ) ) SDLash_EventFilter( &event ); newtime = Sys_DoubleTime (); Host_Frame( newtime - oldtime ); oldtime = newtime; } // never reached return 0; }
int32 WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { COM_ParseCmdLine(lpCmdLine); WNDCLASS wc = { 0 }; wc.lpfnWndProc = MainWndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszClassName = "Module 2"; if (!RegisterClass(&wc)) exit(EXIT_FAILURE); HWND mainwindow; DWORD WindowStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE; RECT r; r.top = r.left = 0; r.right = 800; r.bottom = 600; AdjustWindowRect(&r, WindowStyle, FALSE); mainwindow = CreateWindowEx( 0, "Module 2", "Lesson 2.6", WindowStyle, CW_USEDEFAULT, CW_USEDEFAULT, r.right - r.left, r.bottom - r.top, NULL, NULL, hInstance, 0 ); ShowWindow(mainwindow, SW_SHOWDEFAULT); HDC DeviceContext = GetDC(mainwindow); PatBlt(DeviceContext, 0, 0, 800, 600, BLACKNESS); ReleaseDC(mainwindow, DeviceContext); Host_Init(); float oldtime = Sys_InitFloatTime(); MSG msg; while (IsRunning) { // check os while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } float newtime = Sys_FloatTime(); Host_Frame(newtime - oldtime); oldtime = newtime; } Host_Shutdown(); return 0; }