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 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 NetUpdate(void) { int nowtime; int newtics; int i; int gameticdiv; // check time nowtime = GetTime() / ticdup; newtics = nowtime - lasttime; lasttime = nowtime; if (newtics <= 0) // nothing new to update return; if (skiptics <= newtics) { newtics -= skiptics; skiptics = 0; } else { skiptics -= newtics; newtics = 0; } // build new ticcmds for console player gameticdiv = gametic / ticdup; for (i = 0; i < newtics; i++) { ticcmd_t cmd; I_StartTic(); D_ProcessEvents(); // Always run the menu M_Ticker(); if (maketic - gameticdiv >= 5) break; memset(&cmd, 0, sizeof(ticcmd_t)); G_BuildTiccmd(&cmd); netcmds[consoleplayer][maketic % BACKUPTICS] = cmd; ++maketic; nettics[consoleplayer] = maketic; } }
void D_BuildNewTiccmds(void) { static int lastmadetic; int newtics = I_GetTime() - lastmadetic; lastmadetic += newtics; while (newtics--) { I_StartTic(); if (maketic - gametic > BACKUPTICS/2) break; G_BuildTiccmd(&localcmds[maketic%BACKUPTICS]); maketic++; } }
void D_UpdateTiccmd(void) { int nowtime; int newtics; int i; int gameticdiv; // check time nowtime = D_GetAdjustedTime()/ticdup; newtics = nowtime - gametime; gametime = nowtime; if(skiptics <= newtics) { newtics -= skiptics; skiptics = 0; } else { skiptics -= newtics; newtics = 0; } // build new ticcmds for console player(s) gameticdiv = gametic/ticdup; for(i = 0; i < newtics; i++) { ticcmd_t cmd; I_StartTic(); D_ProcessEvents(); M_Ticker(); // If playing single player, do not allow tics to buffer // up very far if((!netgame || demoplayback) && maketic - gameticdiv > 2) break; // Never go more than ~200ms ahead if(maketic - gameticdiv > 8) break; G_BuildTiccmd(&cmd); netcmds[consoleplayer][maketic % BACKUPTICS] = cmd; ++maketic; } }
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 dboolean BuildNewTic(void) { ticcmd_t cmd; I_StartTic(); D_ProcessEvents(); // Always run the menu M_Ticker(); if (maketic - gametic > 2) return false; G_BuildTiccmd(&cmd); netcmds[maketic % BACKUPTICS] = cmd; ++maketic; return true; }
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 D_BuildNewTiccmds(void) { I_StartTic(); G_BuildTiccmd(&localcmds[maketic % BACKUPTICS]); maketic++; }
void NetUpdate(void) { static int lastmadetic; if (isExtraDDisplay) return; if (server) { // Receive network packets size_t recvlen; packet_header_t *packet = Z_Malloc(10000, PU_STATIC, NULL); while ((recvlen = I_GetPacket(packet, 10000))) { switch(packet->type) { case PKT_TICS: { uint8_t *p = (void*)(packet+1); int tics = *p++; unsigned long ptic = doom_ntohl(packet->tic); if (ptic > (unsigned)remotetic) { // Missed some packet_set(packet, PKT_RETRANS, remotetic); *(uint8_t*)(packet+1) = consoleplayer; I_SendPacket(packet, sizeof(*packet)+1); } else { if (ptic + tics <= (unsigned)remotetic) break; // Will not improve things remotetic = ptic; while (tics--) { int players = *p++; while (players--) { int n = *p++; RawToTic(&netcmds[n][remotetic%BACKUPTICS], p); p += sizeof(ticcmd_t); } remotetic++; } } } break; case PKT_RETRANS: // Resend request remotesend = doom_ntohl(packet->tic); break; case PKT_DOWN: // Server downed { int j; for (j=0; j<MAXPLAYERS; j++) if (j != consoleplayer) playeringame[j] = FALSE; server = FALSE; doom_printf("Server is down\nAll other players are no longer in the game\n"); } break; case PKT_EXTRA: // Misc stuff case PKT_QUIT: // Player quit // Queue packet to be processed when its tic time is reached queuedpacket = Z_Realloc(queuedpacket, ++numqueuedpackets * sizeof *queuedpacket, PU_STATIC, NULL); queuedpacket[numqueuedpackets-1] = Z_Malloc(recvlen, PU_STATIC, NULL); memcpy(queuedpacket[numqueuedpackets-1], packet, recvlen); break; case PKT_BACKOFF: /* cph 2003-09-18 - * The server sends this when we have got ahead of the other clients. We should * stall the input side on this client, to allow other clients to catch up. */ lastmadetic++; break; default: // Other packet, unrecognised or redundant break; } } Z_Free(packet); } { // Build new ticcmds int newtics = I_GetTime() - lastmadetic; newtics = (newtics > 0 ? newtics : 0); lastmadetic += newtics; if (ffmap) newtics++; while (newtics--) { I_StartTic(); if (maketic - gametic > BACKUPTICS/2) break; G_BuildTiccmd(&localcmds[maketic%BACKUPTICS]); maketic++; } if (server && maketic > remotesend) { // Send the tics to the server int sendtics; remotesend -= xtratics; if (remotesend < 0) remotesend = 0; sendtics = maketic - remotesend; { size_t pkt_size = sizeof(packet_header_t) + 2 + sendtics * sizeof(ticcmd_t); packet_header_t *packet = Z_Malloc(pkt_size, PU_STATIC, NULL); packet_set(packet, PKT_TICC, maketic - sendtics); *(uint8_t*)(packet+1) = sendtics; *(((uint8_t*)(packet+1))+1) = consoleplayer; { void *tic = ((uint8_t*)(packet+1)) +2; while (sendtics--) { TicToRaw(tic, &localcmds[remotesend++%BACKUPTICS]); tic = (uint8_t *)tic + sizeof(ticcmd_t); } } I_SendPacket(packet, pkt_size); Z_Free(packet); } } } }
void NetUpdate(void) { int nowtime; int newtics; int i; int gameticdiv; // check time nowtime = GetAdjustedTime() / ticdup; newtics = nowtime - lasttime; lasttime = nowtime; if (skiptics <= newtics) { newtics -= skiptics; skiptics = 0; } else { skiptics -= newtics; newtics = 0; } // build new ticcmds for console player gameticdiv = gametic / ticdup; for (i = 0; i < newtics; i++) { ticcmd_t cmd; I_StartTic(); D_ProcessEvents(); // Always run the menu M_Ticker(); if (net_cl_new_sync) { // If playing single player, do not allow tics to buffer // up very far if ((!netgame || demoplayback) && maketic - gameticdiv > 2) break; // Never go more than ~200ms ahead if (maketic - gameticdiv > 8) break; } else { if (maketic - gameticdiv >= 5) break; } memset(&cmd, 0, sizeof(ticcmd_t)); G_BuildTiccmd(&cmd, maketic); netcmds[consoleplayer][maketic % BACKUPTICS] = cmd; ++maketic; nettics[consoleplayer] = maketic; } }
void NetUpdate (void) { int nowtime; int newtics; int i,j; int realstart; int gameticdiv; // check time nowtime = I_GetTime ()/ticdup; newtics = nowtime - gametime; gametime = nowtime; if (newtics <= 0) // nothing new to update goto listen; if (skiptics <= newtics) { newtics -= skiptics; skiptics = 0; } else { skiptics -= newtics; newtics = 0; } netbuffer->player = consoleplayer; // build new ticcmds for console player gameticdiv = gametic/ticdup; for (i=0 ; i<newtics ; i++) { I_StartTic (); D_ProcessEvents (); if (maketic - gameticdiv >= BACKUPTICS/2-1) break; // can't hold any more //printf ("mk:%i ",maketic); G_BuildTiccmd (&localcmds[maketic%BACKUPTICS]); maketic++; } if (singletics) return; // singletic update is syncronous // send the packet to the other nodes for (i=0 ; i<doomcom->numnodes ; i++) if (nodeingame[i]) { netbuffer->starttic = realstart = resendto[i]; netbuffer->numtics = maketic - realstart; if (netbuffer->numtics > BACKUPTICS) I_Error ("NetUpdate: netbuffer->numtics > BACKUPTICS"); resendto[i] = maketic - doomcom->extratics; for (j=0 ; j< netbuffer->numtics ; j++) netbuffer->cmds[j] = localcmds[(realstart+j)%BACKUPTICS]; if (remoteresend[i]) { netbuffer->retransmitfrom = nettics[i]; HSendPacket (i, NCMD_RETRANSMIT); } else { netbuffer->retransmitfrom = 0; HSendPacket (i, 0); } } // listen for other packets listen: GetPackets (); }
// // NetUpdate // Builds ticcmds for console player, // sends out a packet // void NetUpdate (void) { I_StartTic (); D_ProcessEvents (); G_BuildTiccmd (&consoleplayer().netcmds[gametic%BACKUPTICS]); }