void TryRunTics (void) { int runtics; // Wait for tics to run while (1) { D_BuildNewTiccmds(); runtics = maketic - gametic; if (runtics) break; WasRenderedInTryRunTics = TRUE; if (movement_smooth && gamestate==wipegamestate) { isExtraDDisplay = TRUE; D_Display(); isExtraDDisplay = FALSE; } } if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); I_GetTime_SaveMS(); G_Ticker (); P_Checksum(gametic); gametic++; }
static void RunTic(ticcmd_t *cmds, boolean *ingame) { extern boolean advancedemo; unsigned int i; // Check for player quits. for (i = 0; i < MAXPLAYERS; ++i) { if (!demoplayback && playeringame[i] && !ingame[i]) { PlayerQuitGame(&players[i]); } } netcmds = cmds; // check that there are players in the game. if not, we cannot // run a tic. if (advancedemo) D_DoAdvanceDemo (); G_Ticker (); }
static void D_DoomLoop (void) { basetic = gametic; I_SubmitSound(); while (!doomexit) { // process one or more tics if (singletics) { I_StartTic (); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); gametic++; maketic++; } else TryRunTics (); // will run at least one tic // killough 3/16/98: change consoleplayer to displayplayer if (players[displayplayer].mo) // cph 2002/08/10 S_UpdateSounds(players[displayplayer].mo);// move positional sounds // Update display, next frame, with current state. D_Display(); // Give the system some time rb->yield(); } }
void TryRunTics (void) { int runtics; int entertime = I_GetTime(); // Wait for tics to run while (1) { #ifdef HAVE_NET NetUpdate(); #else D_BuildNewTiccmds(); #endif runtics = (server ? remotetic : maketic) - gametic; if (!runtics) { if (server) I_WaitForPacket(ms_to_next_tick); else I_uSleep(ms_to_next_tick*1000); if (I_GetTime() - entertime > 10) { remotesend--; if (server) { char buf[sizeof(packet_header_t) + 1]; packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic); buf[sizeof(buf) - 1] = consoleplayer; I_SendPacket((packet_header_t *)buf, sizeof buf); } M_Ticker(); return; } } else break; } while (runtics--) { #ifdef HAVE_NET if (server) CheckQueuedPackets(); #endif if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); gametic++; #ifdef HAVE_NET NetUpdate(); // Keep sending our tics to avoid stalling remote nodes #endif } }
void D_DoomLoop (void) { if (demorecording) G_BeginRecording (); if (M_CheckParm ("-debugfile")) { char filename[20]; sprintf (filename,"debug%i.txt",consoleplayer); printf ("debug output to: %s\n",filename); debugfile = fopen (filename,"w"); } I_InitGraphics (); for (;;) { // frame syncronous IO operations I_StartFrame (); // process one or more tics if (singletics) { I_StartTic (); D_ProcessEvents (); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); gametic++; maketic++; } else { TryRunTics (); // will run at least one tic } S_UpdateSounds (players[consoleplayer].mo);// move positional sounds // Update display, next frame, with current state. D_Display (); #ifndef OS2 #ifndef SNDSERV // Sound mixing for the buffer is snychronous. I_UpdateSound(); #endif // Synchronous sound output is explicitly called. #ifndef SNDINTR // Update sound output. I_SubmitSound(); #endif #endif } }
void TryRunTics(void) { while (maketic <= gametic) D_BuildNewTiccmds(); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); P_Checksum(gametic); gametic++; }
void TryRunTics(void) { // get real tics int entertic = I_GetTime(); int counts; // get available tics NetUpdate(); counts = maketic - gametic; if (!counts && !vid_capfps) return; if (counts < 1) counts = 1; // wait for new tics if needed while (maketic < gametic + counts) { NetUpdate(); // Still no tics to run? Sleep until some are available. if (maketic < gametic + counts) { // If we're in a netgame, we might spin forever waiting for // new network data to be received. So don't stay in here // forever - give the menu a chance to work. if (I_GetTime() - entertic >= MAX_NETGAME_STALL_TICS) return; I_Sleep(1); } } // run the count tics while (counts--) { if (advancetitle) D_DoAdvanceTitle(); G_Ticker(); gametic++; gametime++; if (netcmds[0].buttons & BT_SPECIAL) netcmds[0].buttons = 0; NetUpdate(); } }
void D_DoomTicker(int tics, fixed_t frac) { static boolean wipe = false; int i; if (tics > 4) tics = 4; if (!wipe) { D_ProcessEvents(); for (i = 0; i < tics; ++i) { D_DoAdvanceDemo(); M_Ticker(); G_Ticker(); } // move positional sounds S_UpdateSounds(players[consoleplayer].mo); // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize(); oldgamestate = -1; // force background redraw } // save the current screen if about to wipe if (gamestate != wipegamestate) { wipe = true; wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); } D_Display(frac); oldgamestate = wipegamestate = gamestate; if (wipe) { wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); } } if (wipe && tics > 0) { if (wipe_ScreenWipe(wipe_Melt, 0, 0, SCREENWIDTH, SCREENHEIGHT, tics)) { // done wipe = false; } } // menu is drawn even on top of everything M_Drawer(); I_FinishUpdate(tics); framecount++; }
void TryRunTics (void) { int runtics; int entertime = I_GetTime(); // Wait for tics to run while (1) { NetUpdate(); runtics = (server ? remotetic : maketic) - gametic; if (!runtics) { if (!movement_smooth) { if (server) I_WaitForPacket(ms_to_next_tick); else I_uSleep(ms_to_next_tick*1000); } if (I_GetTime() - entertime > 10) { if (server) { char buf[sizeof(packet_header_t)+1]; remotesend--; packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic); buf[sizeof(buf)-1] = consoleplayer; I_SendPacket((packet_header_t *)buf, sizeof buf); } M_Ticker(); return; } { WasRenderedInTryRunTics = TRUE; if (movement_smooth && gamestate==wipegamestate) { isExtraDDisplay = TRUE; D_Display(); isExtraDDisplay = FALSE; } } } else break; } while (runtics--) { if (server) CheckQueuedPackets(); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); I_GetTime_SaveMS(); G_Ticker (); P_Checksum(gametic); gametic++; NetUpdate(); // Keep sending our tics to avoid stalling remote nodes } }
void TryRunTics(void) // Avoid sleeping/timer crap, just run it. (Themaister) { int runtics = maketic - gametic; while (runtics--) { if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); P_Checksum(gametic); gametic++; } }
void D_DoomLoop (void) { if (demorecording) G_BeginRecording (); TryRunTics(); I_InitGraphics (); R_ExecuteSetViewSize(); D_StartGameLoop(); if (testcontrols) { wipegamestate = gamestate; } while (1) { // frame syncronous IO operations I_StartFrame (); // process one or more tics if (singletics) { I_StartTic (); D_ProcessEvents (); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); gametic++; maketic++; } else { TryRunTics (); // will run at least one tic } S_UpdateSounds (players[consoleplayer].mo);// move positional sounds // Update display, next frame, with current state. if (screenvisible) D_Display (); } }
static void D_DoomLoop(void) { for (;;) { WasRenderedInTryRunTics = false; // frame syncronous IO operations I_StartFrame (); if (ffmap == gamemap) ffmap = 0; // process one or more tics if (singletics) { I_StartTic (); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); P_Checksum(gametic); gametic++; maketic++; } else TryRunTics (); // will run at least one tic // killough 3/16/98: change consoleplayer to displayplayer if (players[displayplayer].mo) // cph 2002/08/10 S_UpdateSounds(players[displayplayer].mo);// move positional sounds if (V_GetMode() == VID_MODEGL ? !movement_smooth || !WasRenderedInTryRunTics : !movement_smooth || !WasRenderedInTryRunTics || gamestate != wipegamestate ) { // Update display, next frame, with current state. D_Display(); } // CPhipps - auto screenshot if (auto_shot_fname && !--auto_shot_count) { auto_shot_count = auto_shot_time; M_DoScreenShot(auto_shot_fname); } } }
// MIKE 11/08 main game loop, called every frame by Flash void D_DoomLoop (void) { // frame syncronous IO operations I_StartFrame (); if(!wipe) { // process one or more tics if (singletics) { I_StartTic (); D_ProcessEvents (); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); gametic++; maketic++; } else { TryRunTics (); // will run at least one tic } S_UpdateSounds (players[consoleplayer].mo);// move positional sounds // Update display, next frame, with current state. //D_Display (); } // MIKE #ifndef SNDSERV // Sound mixing for the buffer is snychronous. I_UpdateSound(); #endif // Synchronous sound output is explicitly called. #ifndef SNDINTR // Update sound output. // I_SubmitSound(); #endif gameTime++; return AS3_Null(); }
void D_DoomLoop (void) { if (demorecording) G_BeginRecording (); if (M_CheckParm ("-debugfile")) { char filename[20]; sprintf (filename,"debug%i.txt",consoleplayer); printf ("debug output to: %s\n",filename); debugfile = fopen (filename,"w"); } I_InitGraphics (); while (1) { // frame syncronous IO operations I_StartFrame (); // process one or more tics if (singletics) { I_StartTic (); D_ProcessEvents (); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); G_Ticker (); gametic++; maketic++; } else { TryRunTics (); // will run at least one tic } S_UpdateSounds (players[consoleplayer].mo);// move positional sounds // Update display, next frame, with current state. D_Display (); } }
static void tryruntics(void) { int runtics; int entertime = I_GetTime(); while (1) { D_BuildNewTiccmds(); runtics = maketic - gametic; if (runtics) break; I_uSleep(ms_to_next_tick * 1000); if (I_GetTime() - entertime > 10) { M_Ticker(); return; } } while (runtics--) { M_Ticker(); G_Ticker(); gametic++; } }
void TryRunTics(void) { static int lastmadetic; int newtics = I_GetTime() - lastmadetic; int runtics; lastmadetic += newtics; while (newtics--) { I_StartTic(); if (maketic - gametime > BACKUPTICS / 2) break; G_BuildTiccmd(&localcmds[maketic++ % BACKUPTICS]); } if (!(runtics = maketic - gametime) && vid_capfps != TICRATE) return; while (runtics--) { if (advancetitle) D_DoAdvanceTitle(); if (menuactive) M_Ticker(); G_Ticker(); gametime++; if (localcmds[0].buttons & BT_SPECIAL) localcmds[0].buttons = 0; } }
void TryStepTics(QWORD tics) { DObject::BeginFrame (); // run the realtics tics while (tics--) { if(canceltics && canceltics--) continue; NetUpdate (); if (advancedemo) D_DoAdvanceDemo (); C_Ticker (); M_Ticker (); G_Ticker (); gametic++; } DObject::EndFrame (); }
int D_MiniLoop(void(*start)(void), void(*stop)(void), void (*draw)(void), dboolean(*tick)(void)) { int action = gameaction = ga_nothing; if(start) start(); while(!action) { int i = 0; int lowtic = 0; int entertic = 0; int availabletics = 0; int counts = 0; // process one or more tics // get real tics entertic = I_GetTime() / ticdup; // get available ticks D_UpdateTiccmd(); lowtic = D_GetLowTic(); availabletics = lowtic - gametic/ticdup; // decide how many tics to run counts = availabletics; if(counts < 1) counts = 1; // wait for new tics if needed while(!D_PlayersInGame() || lowtic < gametic/ticdup + counts) { D_UpdateTiccmd(); lowtic = D_GetLowTic(); if(lowtic < gametic/ticdup) I_Error("D_MiniLoop: lowtic < gametic"); // Don't stay in this loop forever. The menu is still running, // so return to update the screen if(I_GetTime() / ticdup - entertic > 0) goto drawframe; I_Sleep(1); } // run the count * ticdup dics while(counts--) { for(i = 0; i < ticdup; i++) { // check that there are players in the game. if not, we cannot // run a tic. if(!D_PlayersInGame()) break; if(gametic / ticdup > lowtic) I_Error("gametic>lowtic"); G_Ticker(); if(tick) action = tick(); if(gameaction != ga_nothing) action = gameaction; gametic++; // modify command for duplicated tics if(i != ticdup-1) { ticcmd_t *cmd; int buf; int j; buf = (gametic / ticdup) % BACKUPTICS; for(j = 0; j < MAXPLAYERS; j++) { cmd = &netcmds[j][buf]; if(cmd->buttons & BT_SPECIAL) cmd->buttons = 0; } } } D_UpdateTiccmd(); // check for new console commands } drawframe: S_UpdateSounds(); // Update display, next frame, with current state. if(draw && !action) { draw(); I_FinishFrame(); } if(menuactive) M_Drawer(); // send out any new accumulation D_UpdateTiccmd(); // force garbage collection Z_FreeAlloca(); if(devparm) D_PrintDevStats(); } if(stop) stop(); return action; }
void TryRunTics(void) { int i; int lowtic; int entertic; static int oldentertics; int realtics; int availabletics; int counts; // get real tics entertic = I_GetTime() / ticdup; realtics = entertic - oldentertics; oldentertics = entertic; lowtic = maketic; availabletics = lowtic - gametic / ticdup; // decide how many tics to run if (realtics < availabletics - 1) counts = realtics + 1; else if (realtics < availabletics) counts = realtics; else counts = availabletics; if (counts < 1) counts = 1; // wait for new tics if needed while (lowtic < gametic / ticdup + counts) { NetUpdate(); lowtic = maketic; // Don't stay in this loop forever. The menu is still running, // so return to update the screen if (I_GetTime() / ticdup - entertic > 0) return; I_Sleep(1); } // run the count * ticdup dics while (counts--) { for (i = 0; i < ticdup; i++) { if (advancetitle) D_DoAdvanceTitle(); G_Ticker(); gametic++; // modify command for duplicated tics if (i != ticdup - 1) { int buf = (gametic / ticdup) % BACKUPTICS; int j; for (j = 0; j < MAXPLAYERS; j++) { ticcmd_t *cmd = &netcmds[j][buf]; if (cmd->buttons & BT_SPECIAL) cmd->buttons = 0; } } } } }
// // D_DoomMain // void D_DoomMain (void) { unsigned p; extern std::string defdemoname; gamestate = GS_STARTUP; M_FindResponseFile(); // [ML] 23/1/07 - Add Response file support back in if (lzo_init () != LZO_E_OK) // [RH] Initialize the minilzo package. I_FatalError ("Could not initialize LZO routines"); C_ExecCmdLineParams (false, true); // [Nes] test for +logfile command Printf (PRINT_HIGH, "Heapsize: %u megabytes\n", got_heapsize); M_LoadDefaults (); // load before initing other systems C_ExecCmdLineParams (true, false); // [RH] do all +set commands on the command line const char* iwad = Args.CheckValue("-iwad"); if (!iwad) iwad = ""; std::vector<std::string> newwadfiles, newpatchfiles; newwadfiles.push_back(iwad); D_AddWadCommandLineFiles(newwadfiles); D_AddDehCommandLineFiles(newpatchfiles); D_LoadResourceFiles(newwadfiles, newpatchfiles); I_Init(); V_Init(); atterm(V_Close); #ifdef _WIN32 const char *sdlv = getenv("SDL_VIDEODRIVER"); Printf (PRINT_HIGH, "Using %s video driver.\n",sdlv); #endif C_InitConsole(screen->width, screen->height, true); atterm(C_ShutdownConsole); // SDL needs video mode set up first before input code can be used I_InitInput(); D_Init(); atterm(D_Shutdown); // Base systems have been inited; enable cvar callbacks cvar_t::EnableCallbacks(); // [RH] User-configurable startup strings. Because BOOM does. if (GStrings(STARTUP1)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP1)); if (GStrings(STARTUP2)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP2)); if (GStrings(STARTUP3)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP3)); if (GStrings(STARTUP4)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP4)); if (GStrings(STARTUP5)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP5)); // Nomonsters sv_nomonsters = Args.CheckParm("-nomonsters"); // Respawn sv_monstersrespawn = Args.CheckParm("-respawn"); // Fast sv_fastmonsters = Args.CheckParm("-fast"); // developer mode devparm = Args.CheckParm ("-devparm"); // Record a vanilla demo p = Args.CheckParm ("-record"); if (p) { autorecord = true; autostart = true; demorecordfile = Args.GetArg (p+1); } // get skill / episode / map from parms strcpy (startmap, (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1"); // Check for -playdemo, play a single demo then quit. p = Args.CheckParm ("-playdemo"); // Hack to check for +playdemo command, since if you just add it normally // it won't run because it's attempting to run a demo and still set up the // first map as normal. if (!p) p = Args.CheckParm ("+playdemo"); if (p && p < Args.NumArgs()-1) { Printf (PRINT_HIGH, "Playdemo parameter found on command line.\n"); singledemo = true; defdemoname = Args.GetArg (p+1); } // [SL] check for -timedemo (was removed at some point) p = Args.CheckParm("-timedemo"); if (p && p < Args.NumArgs() - 1) { singledemo = true; G_TimeDemo(Args.GetArg(p + 1)); } const char *val = Args.CheckValue ("-skill"); if (val) { sv_skill.Set (val[0]-'0'); } p = Args.CheckParm ("-warp"); if (p && p < Args.NumArgs() - (1+(gameinfo.flags & GI_MAPxx ? 0 : 1))) { int ep, map; if (gameinfo.flags & GI_MAPxx) { ep = 1; map = atoi (Args.GetArg(p+1)); } else { ep = Args.GetArg(p+1)[0]-'0'; map = Args.GetArg(p+2)[0]-'0'; } strncpy (startmap, CalcMapName (ep, map), 8); autostart = true; } // [RH] Hack to handle +map p = Args.CheckParm ("+map"); if (p && p < Args.NumArgs()-1) { strncpy (startmap, Args.GetArg (p+1), 8); ((char *)Args.GetArg (p))[0] = '-'; autostart = true; } if (devparm) Printf (PRINT_HIGH, "%s", GStrings(D_DEVSTR)); // D_DEVSTR // [RH] Now that all text strings are set up, // insert them into the level and cluster data. G_SetLevelStrings(); // [RH] Parse through all loaded mapinfo lumps G_ParseMapInfo(); // [ML] Parse musinfo lump G_ParseMusInfo(); // [RH] Parse any SNDINFO lumps S_ParseSndInfo(); // NOTE(jsd): Set up local player color EXTERN_CVAR(cl_color); R_BuildPlayerTranslation (0, V_GetColorFromString (NULL, cl_color.cstring())); I_FinishClockCalibration (); Printf (PRINT_HIGH, "D_CheckNetGame: Checking network game status.\n"); D_CheckNetGame (); // [RH] Initialize items. Still only used for the give command. :-( InitItems (); // [RH] Lock any cvars that should be locked now that we're // about to begin the game. cvar_t::EnableNoSet (); // [RH] Now that all game subsystems have been initialized, // do all commands on the command line other than +set C_ExecCmdLineParams (false, false); Printf_Bold("\n\35\36\36\36\36 Odamex Client Initialized \36\36\36\36\37\n"); if(gamestate != GS_CONNECTING) Printf(PRINT_HIGH, "Type connect <address> or use the Odamex Launcher to connect to a game.\n"); Printf(PRINT_HIGH, "\n"); setmodeneeded = false; // [Fly] we don't need to set a video mode here! //gamestate = GS_FULLCONSOLE; // [SL] allow the user to pass the name of a netdemo as the first argument. // This allows easy launching of netdemos from Windows Explorer or other GUIs. // [Xyltol] if (Args.GetArg(1)) { std::string demoarg = Args.GetArg(1); if (demoarg.find(".odd") != std::string::npos) CL_NetDemoPlay(demoarg); } p = Args.CheckParm("-netplay"); if (p) { if (Args.GetArg(p + 1)) { std::string filename = Args.GetArg(p + 1); CL_NetDemoPlay(filename); } else { Printf(PRINT_HIGH, "No netdemo filename specified.\n"); } } // denis - bring back the demos if ( gameaction != ga_loadgame ) { if (autostart || netgame || singledemo) { if (singledemo) G_DoPlayDemo(); else { if(autostart) { // single player warp (like in g_level) serverside = true; sv_allowexit = "1"; sv_freelook = "1"; sv_allowjump = "1"; sv_allowredscreen = "1"; sv_gametype = GM_COOP; players.clear(); players.push_back(player_t()); players.back().playerstate = PST_REBORN; consoleplayer_id = displayplayer_id = players.back().id = 1; } G_InitNew (startmap); if (autorecord) if (G_RecordDemo(demorecordfile.c_str())) G_BeginRecording(); } } else { if (gamestate != GS_CONNECTING) gamestate = GS_HIDECONSOLE; C_HideConsole(); if (gamemode == commercial_bfg) // DOOM 2 BFG Edtion AddCommandString("menu_main"); D_StartTitle (); // start up intro loop } } // denis - this will run a demo and quit p = Args.CheckParm ("+demotest"); if (p && p < Args.NumArgs()-1) { demotest = 1; defdemoname = Args.GetArg (p+1); G_DoPlayDemo(); while(demoplayback) { DObject::BeginFrame (); G_Ticker(); DObject::EndFrame (); gametic++; } } else { demotest = 0; D_DoomLoop (); // never returns } }
void TryRunTics(void) { int i; int entertic; static int oldentertics; int realtics; int availabletics; int counts; // get real tics entertic = I_GetTime() / ticdup; realtics = entertic - oldentertics; oldentertics = entertic; // get available tics NetUpdate(); availabletics = maketic - gametic / ticdup; // decide how many tics to run if (realtics < availabletics - 1) counts = realtics + 1; else if (realtics < availabletics) counts = realtics; else counts = availabletics; if (!counts && !vid_capfps) return; if (counts < 1) counts = 1; // wait for new tics if needed while (maketic < gametic / ticdup + counts) { NetUpdate(); // Still no tics to run? Sleep until some are available. if (maketic < gametic/ticdup + counts) { // If we're in a netgame, we might spin forever waiting for // new network data to be received. So don't stay in here // forever - give the menu a chance to work. if (I_GetTime() / ticdup - entertic >= MAX_NETGAME_STALL_TICS) return; I_Sleep(1); } } // run the count * ticdup dics while (counts--) { for (i = 0; i < ticdup; i++) { if (advancetitle) D_DoAdvanceTitle(); G_Ticker(); gametic++; gametime++; // modify command for duplicated tics if (i != ticdup - 1) { ticcmd_t *cmd = &netcmds[(gametic / ticdup) % BACKUPTICS]; if (cmd->buttons & BT_SPECIAL) cmd->buttons = 0; } } NetUpdate(); } }
void TryRunTics () { int runtics; int entertime = I_GetTime(); // Wait for tics to run while (1) { #ifdef HAVE_NET NetUpdate(); #else D_BuildNewTiccmds(); #endif runtics = (server ? remotetic : maketic) - gametic; if (!runtics) { if (!movement_smooth) { #ifdef HAVE_NET if (server) I_WaitForPacket(ms_to_next_tick); else #endif I_uSleep(ms_to_next_tick*1000); } if (I_GetTime() - entertime > 10) { #ifdef HAVE_NET if (server) { char buf[sizeof(packet_header_t)+1]; remotesend--; packet_set((packet_header_t *)buf, PKT_RETRANS, remotetic); buf[sizeof(buf)-1] = consoleplayer; I_SendPacket((packet_header_t *)buf, sizeof buf); } #endif M_Ticker(); return; } //if ((displaytime) < (tic_vars.next-SDL_GetTicks())) { WasRenderedInTryRunTics = true; if (V_GetMode() == VID_MODEGL ? movement_smooth : movement_smooth && gamestate==wipegamestate) { isExtraDDisplay = true; D_Display(0); D_Display(1); isExtraDDisplay = false; } } } else break; } while (runtics--) { #ifdef HAVE_NET if (server) CheckQueuedPackets(); #endif if (advancedemo) D_DoAdvanceDemo (); M_Ticker (); I_GetTime_SaveMS(); G_Ticker (); P_Checksum(gametic); gametic++; #ifdef HAVE_NET NetUpdate(); // Keep sending our tics to avoid stalling remote nodes #endif } }
// // D_DoomMain // void D_DoomMain (void) { unsigned p; const char *iwad; extern std::string defdemoname; M_ClearRandom(); gamestate = GS_STARTUP; SetLanguageIDs (); M_FindResponseFile(); // [ML] 23/1/07 - Add Response file support back in if (lzo_init () != LZO_E_OK) // [RH] Initialize the minilzo package. I_FatalError ("Could not initialize LZO routines"); C_ExecCmdLineParams (false, true); // [Nes] test for +logfile command Printf (PRINT_HIGH, "Heapsize: %u megabytes\n", got_heapsize); M_LoadDefaults (); // load before initing other systems C_ExecCmdLineParams (true, false); // [RH] do all +set commands on the command line iwad = Args.CheckValue("-iwad"); if(!iwad) iwad = ""; D_AddDefWads(iwad); D_AddCmdParameterFiles(); wadhashes = W_InitMultipleFiles (wadfiles); // [RH] Initialize localizable strings. GStrings.LoadStrings (W_GetNumForName ("LANGUAGE"), STRING_TABLE_SIZE, false); GStrings.Compact (); // [RH] Initialize configurable strings. //D_InitStrings (); D_DoDefDehackedPatch (); // [RH] Moved these up here so that we can do most of our // startup output in a fullscreen console. HU_Init (); I_Init (); V_Init (); // Base systems have been inited; enable cvar callbacks cvar_t::EnableCallbacks (); // [RH] User-configurable startup strings. Because BOOM does. if (GStrings(STARTUP1)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP1)); if (GStrings(STARTUP2)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP2)); if (GStrings(STARTUP3)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP3)); if (GStrings(STARTUP4)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP4)); if (GStrings(STARTUP5)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP5)); // Nomonsters sv_nomonsters = Args.CheckParm("-nomonsters"); // Respawn sv_monstersrespawn = Args.CheckParm("-respawn"); // Fast sv_fastmonsters = Args.CheckParm("-fast"); // developer mode devparm = Args.CheckParm ("-devparm"); // Record a vanilla demo p = Args.CheckParm ("-record"); if (p) { autorecord = true; autostart = true; demorecordfile = Args.GetArg (p+1); } // get skill / episode / map from parms strcpy (startmap, (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1"); // Check for -playdemo, play a single demo then quit. p = Args.CheckParm ("-playdemo"); // Hack to check for +playdemo command, since if you just add it normally // it won't run because it's attempting to run a demo and still set up the // first map as normal. if (!p) p = Args.CheckParm ("+playdemo"); if (p && p < Args.NumArgs()-1) { Printf (PRINT_HIGH, "Playdemo parameter found on command line.\n"); singledemo = true; defdemoname = Args.GetArg (p+1); } const char *val = Args.CheckValue ("-skill"); if (val) { sv_skill.Set (val[0]-'0'); } p = Args.CheckParm ("-warp"); if (p && p < Args.NumArgs() - (1+(gameinfo.flags & GI_MAPxx ? 0 : 1))) { int ep, map; if (gameinfo.flags & GI_MAPxx) { ep = 1; map = atoi (Args.GetArg(p+1)); } else { ep = Args.GetArg(p+1)[0]-'0'; map = Args.GetArg(p+2)[0]-'0'; } strncpy (startmap, CalcMapName (ep, map), 8); autostart = true; } // [RH] Hack to handle +map p = Args.CheckParm ("+map"); if (p && p < Args.NumArgs()-1) { strncpy (startmap, Args.GetArg (p+1), 8); ((char *)Args.GetArg (p))[0] = '-'; autostart = true; } if (devparm) Printf (PRINT_HIGH, "%s", GStrings(D_DEVSTR)); // D_DEVSTR // [RH] Now that all text strings are set up, // insert them into the level and cluster data. G_SetLevelStrings (); // [RH] Parse through all loaded mapinfo lumps G_ParseMapInfo (); // [ML] Parse musinfo lump G_ParseMusInfo (); // [RH] Parse any SNDINFO lumps S_ParseSndInfo(); // Check for -file in shareware if (modifiedgame && (gameinfo.flags & GI_SHAREWARE)) I_Error ("You cannot -file with the shareware version. Register!"); #ifdef WIN32 const char *sdlv = getenv("SDL_VIDEODRIVER"); Printf (PRINT_HIGH, "Using %s video driver.\n",sdlv); #endif Printf (PRINT_HIGH, "M_Init: Init miscellaneous info.\n"); M_Init (); Printf (PRINT_HIGH, "R_Init: Init DOOM refresh daemon.\n"); R_Init (); Printf (PRINT_HIGH, "P_Init: Init Playloop state.\n"); P_InitEffects(); // [ML] Do this here so we don't have to put particle crap in server P_Init (); Printf (PRINT_HIGH, "S_Init: Setting up sound.\n"); Printf (PRINT_HIGH, "S_Init: default sfx volume is %g\n", (float)snd_sfxvolume); Printf (PRINT_HIGH, "S_Init: default music volume is %g\n", (float)snd_musicvolume); S_Init (snd_sfxvolume, snd_musicvolume); I_FinishClockCalibration (); Printf (PRINT_HIGH, "D_CheckNetGame: Checking network game status.\n"); D_CheckNetGame (); Printf (PRINT_HIGH, "ST_Init: Init status bar.\n"); ST_Init (); // [RH] Initialize items. Still only used for the give command. :-( InitItems (); // [RH] Lock any cvars that should be locked now that we're // about to begin the game. cvar_t::EnableNoSet (); // [RH] Now that all game subsystems have been initialized, // do all commands on the command line other than +set C_ExecCmdLineParams (false, false); Printf_Bold("\n\35\36\36\36\36 Odamex Client Initialized \36\36\36\36\37\n"); if(gamestate != GS_CONNECTING) Printf(PRINT_HIGH, "Type connect <address> or use the Odamex Launcher to connect to a game.\n"); Printf(PRINT_HIGH, "\n"); setmodeneeded = false; // [Fly] we don't need to set a video mode here! //gamestate = GS_FULLCONSOLE; // [SL] allow the user to pass the name of a netdemo as the first argument. // This allows easy launching of netdemos from Windows Explorer or other GUIs. // [Xyltol] if (Args.GetArg(1)) { std::string demoarg = Args.GetArg(1); if (demoarg.find(".odd") != std::string::npos) CL_NetDemoPlay(demoarg); } p = Args.CheckParm("-netplay"); if (p) { if (Args.GetArg(p + 1)) { std::string filename = Args.GetArg(p + 1); CL_NetDemoPlay(filename); } else { Printf(PRINT_HIGH, "No netdemo filename specified.\n"); } } // denis - bring back the demos if ( gameaction != ga_loadgame ) { if (autostart || netgame || singledemo) { if (singledemo) G_DoPlayDemo(); else { if(autostart) { // single player warp (like in g_level) serverside = true; sv_allowexit = "1"; sv_freelook = "1"; sv_allowjump = "1"; sv_allowredscreen = "1"; sv_gametype = GM_COOP; players.clear(); players.push_back(player_t()); players.back().playerstate = PST_REBORN; consoleplayer_id = displayplayer_id = players.back().id = 1; } G_InitNew (startmap); if (autorecord) if (G_RecordDemo(demorecordfile.c_str())) G_BeginRecording(); } } else { if (gamestate != GS_CONNECTING) gamestate = GS_HIDECONSOLE; C_ToggleConsole(); D_StartTitle (); // start up intro loop } } // denis - this will run a demo and quit p = Args.CheckParm ("+demotest"); if (p && p < Args.NumArgs()-1) { demotest = 1; defdemoname = Args.GetArg (p+1); G_DoPlayDemo(); while(demoplayback) { DObject::BeginFrame (); G_Ticker(); DObject::EndFrame (); gametic++; } } else { demotest = 0; D_DoomLoop (); // never returns } }
void TryRunTics(void) { int i; int lowtic; int entertic; static int oldentertics; int realtics; int availabletics; int counts; // get real tics entertic = I_GetTime() / ticdup; realtics = entertic - oldentertics; oldentertics = entertic; // get available tics NetUpdate(); lowtic = GetLowTic(); availabletics = lowtic - gametic / ticdup; // decide how many tics to run if (net_cl_new_sync) { counts = availabletics; } else { // decide how many tics to run if (realtics < availabletics - 1) counts = realtics + 1; else if (realtics < availabletics) counts = realtics; else counts = availabletics; if (counts < 1) counts = 1; frameon++; if (!demoplayback) { int keyplayer = -1; // ideally maketic should be 1 - 3 tics above lowtic // if we are consistantly slower, speed up time for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) { keyplayer = i; break; } } if (keyplayer < 0) { // If there are no players, we can never advance anyway return; } if (consoleplayer == keyplayer) { // the key player does not adapt } else { if (maketic <= nettics[keyplayer]) { lasttime--; } frameskip[frameon & 3] = (oldnettics > nettics[keyplayer]); oldnettics = maketic; if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) { skiptics = 1; } } } } if (counts < 1) counts = 1; // wait for new tics if needed while (!PlayersInGame() || lowtic < gametic / ticdup + counts) { NetUpdate(); lowtic = GetLowTic(); // Don't stay in this loop forever. The menu is still running, // so return to update the screen if (I_GetTime() / ticdup - entertic > 0) { return; } I_Sleep(1); } // run the count * ticdup dics while (counts--) { for (i = 0; i < ticdup; i++) { // check that there are players in the game. if not, we cannot // run a tic. if (!PlayersInGame()) { return; } if (advancedemo) D_DoAdvanceDemo(); G_Ticker(); gametic++; // modify command for duplicated tics if (i != ticdup - 1) { ticcmd_t *cmd; int buf; int j; buf = (gametic / ticdup) % BACKUPTICS; for (j = 0; j < MAXPLAYERS; j++) { cmd = &netcmds[j][buf]; if (cmd->buttons & BT_SPECIAL) cmd->buttons = 0; } } } NetUpdate(); // check for new console commands } }