void DThinker::RunThinkers () { DThinker *currentthinker; BEGIN_STAT (ThinkCycles); currentthinker = FirstThinker; while (currentthinker) { if (!IndependentThinker(currentthinker)) currentthinker->RunThink(); currentthinker = currentthinker->m_Next; } END_STAT (ThinkCycles); }
// // D_Display // draw current display, possibly wiping it from the previous // void D_Display (void) { if (nodrawers) return; // for comparative timing / profiling BEGIN_STAT(D_Display); // [RH] change the screen mode if needed if (setmodeneeded) { // Change screen mode. if (!V_SetResolution (NewWidth, NewHeight, NewBits)) I_FatalError ("Could not change screen mode"); // Recalculate various view parameters. setsizeneeded = true; // Trick status bar into rethinking its position st_scale.Callback (); // Refresh the console. C_NewModeAdjust (); } // [AM] Moved to below setmodeneeded so we have accurate screen size info. if (gamestate == GS_LEVEL && viewactive && consoleplayer().camera) { if (consoleplayer().camera->player) R_SetFOV(consoleplayer().camera->player->fov, setmodeneeded || setsizeneeded); else R_SetFOV(90.0f, setmodeneeded || setsizeneeded); } // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize (); setmodeneeded = false; } I_BeginUpdate (); // [RH] Allow temporarily disabling wipes if (NoWipe) { NoWipe--; wipegamestate = gamestate; } else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE) { wipegamestate = gamestate; Wipe_Start(); wiping_screen = true; } switch (gamestate) { case GS_FULLCONSOLE: case GS_DOWNLOAD: case GS_CONNECTING: case GS_CONNECTED: C_DrawConsole (); M_Drawer (); I_FinishUpdate (); return; case GS_LEVEL: if (!gametic) break; V_DoPaletteEffects(); if (viewactive) R_RenderPlayerView(&displayplayer()); if (automapactive) AM_Drawer(); V_RestorePalettes(); R_DrawViewBorder(); C_DrawMid (); C_DrawGMid(); CTF_DrawHud (); ST_Drawer (); HU_Drawer (); break; case GS_INTERMISSION: if (viewactive) R_RenderPlayerView(&displayplayer()); C_DrawMid (); CTF_DrawHud (); WI_Drawer (); HU_Drawer (); break; case GS_FINALE: F_Drawer (); break; case GS_DEMOSCREEN: D_PageDrawer (); break; default: break; } // draw pause pic if (paused && !menuactive) { const Texture* texture = R_LoadTexture("M_PAUSE"); int x = (screen->width - texture->getWidth() * CleanXfac) / 2; int y = (automapactive && !viewactive) ? 4 : viewwindowy + 4; screen->DrawTextureCleanNoMove(texture, x, y); } // [RH] Draw icon, if any if (D_DrawIcon) { texhandle_t texhandle = texturemanager.getHandle(D_DrawIcon, Texture::TEX_PATCH); const Texture* texture = texturemanager.getTexture(texhandle); D_DrawIcon = NULL; int x = 160 - texture->getWidth() / 2; int y = 100 - texture->getHeight() / 2; screen->DrawTextureIndirect(texture, x, y); NoWipe = 10; } if (wiping_screen) Wipe_Drawer(); C_DrawConsole(); // draw console M_Drawer(); // menu is drawn even on top of everything I_FinishUpdate(); // page flip or blit buffer END_STAT(D_Display); }
BOOL KGameServer::Loop() { if (!m_bRunning) { QLogPrintf(LOG_INFO, "Shutting down..."); return FALSE; } //PCSTR pszConsoleInput = NULL; ScriptSafe cSafeScript = g_cScriptManager.GetSafeScript(); // 自动处理栈泄露 BEGIN_STAT("KGameServer.Loop.Begin()"); //pszConsoleInput = m_cConsoleReader.ReadInput(); //if (pszConsoleInput) // DoCommand(pszConsoleInput); END_STAT(); BEGIN_STAT("KGameServer.Loop.g_UnifyLoop()"); g_UnifyLoop(); END_STAT(); BEGIN_STAT("KGameServer.Loop.ProcessPackage()"); g_RelayClient.ProcessPackage(); END_STAT(); BEGIN_STAT("KGameServer.Loop.MessageLoop()"); g_piSocketServer->MessageLoop(); END_STAT(); static INT nIdleFrame = 0; static UINT uTickStart = KSysService::GetTickCount(); UINT uTickNow = KSysService::GetTickCount(); DWORD dwFrames = (DWORD)((ULONGLONG)(uTickNow - uTickStart) * GAME_FPS / 1000); DWORD dwFramesDiff = dwFrames - g_cOrpgWorld.m_dwLogicFrames; if (dwFramesDiff) { if (dwFramesDiff > GAME_FPS / 4) Q_Printl("Warning: MilliSecond Between Two Frames: " << dwFramesDiff * 1000 / GAME_FPS); BEGIN_STAT("KGameServer.Loop.g_RelayClient.Activate()"); g_RelayClient.Activate(); END_STAT(); BEGIN_STAT("KGameServer.Loop.g_cGameserverEyes.Active()"); g_cGameserverEyes.Active(); END_STAT(); g_cOrpgWorld.m_nIdleFrame = nIdleFrame; nIdleFrame = 0; } else { nIdleFrame++; BEGIN_STAT("KGameServer.Loop.QThread_Sleep()"); QThread_Sleep(1); //QThread_Sleep(10); END_STAT(); } /*这里会导致堵死消息*/ while (dwFrames > g_cOrpgWorld.m_dwLogicFrames) { BEGIN_STAT("KGameServer.Loop.g_cOrpgWorld.Activate()"); g_cOrpgWorld.Activate(); END_STAT(); BEGIN_STAT("KGameServer.Loop.g_cModuleManager.Breath()"); g_cModuleManager.Breath(); END_STAT(); } INT nTopIndexDiff = cSafeScript->GetTopIndex() - cSafeScript.GetBeginTopIndex(); BEGIN_STAT("KGameServer.Loop.End()"); if (nTopIndexDiff > 0) { QLogPrintf(LOG_ERR, "Detected Lua Stack Leak! %d - %d", cSafeScript.GetBeginTopIndex(), cSafeScript->GetTopIndex()); } END_STAT(); return TRUE; }
// // D_Display // draw current display, possibly wiping it from the previous // void D_Display (void) { BOOL wipe; if (nodrawers) return; // for comparative timing / profiling BEGIN_STAT(D_Display); if (gamestate == GS_LEVEL && viewactive && consoleplayer().camera) R_SetFOV (consoleplayer().camera->player ? consoleplayer().camera->player->fov : 90.0f); // [RH] change the screen mode if needed if (setmodeneeded) { int oldwidth = screen->width; int oldheight = screen->height; int oldbits = DisplayBits; // Change screen mode. if (!V_SetResolution (NewWidth, NewHeight, NewBits)) if (!V_SetResolution (oldwidth, oldheight, oldbits)) I_FatalError ("Could not change screen mode"); // Recalculate various view parameters. setsizeneeded = true; // Trick status bar into rethinking its position st_scale.Callback (); // Refresh the console. C_NewModeAdjust (); } // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize (); setmodeneeded = false; } I_BeginUpdate (); // [RH] Allow temporarily disabling wipes if (NoWipe) { NoWipe--; wipe = false; wipegamestate = gamestate; } else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE) { // save the current screen if about to wipe wipe = true; wipe_StartScreen (); wipegamestate = gamestate; } else { wipe = false; } switch (gamestate) { case GS_FULLCONSOLE: case GS_DOWNLOAD: case GS_CONNECTING: C_DrawConsole (); M_Drawer (); I_FinishUpdate (); return; case GS_LEVEL: if (!gametic) break; // denis - freshen the borders (ffs..) R_DrawViewBorder (); // erase old menu stuff if (viewactive) R_RenderPlayerView (&displayplayer()); if (automapactive) AM_Drawer (); C_DrawMid (); CTF_DrawHud (); ST_Drawer (); HU_Drawer (); break; case GS_INTERMISSION: if (viewactive) R_RenderPlayerView (&displayplayer()); C_DrawMid (); CTF_DrawHud (); WI_Drawer (); HU_Drawer (); break; case GS_FINALE: F_Drawer (); break; case GS_DEMOSCREEN: D_PageDrawer (); break; default: break; } // draw pause pic if (paused && !menuactive) { patch_t *pause = W_CachePatch ("M_PAUSE"); int y; y = (automapactive && !viewactive) ? 4 : viewwindowy + 4; screen->DrawPatchCleanNoMove (pause, (screen->width-(pause->width())*CleanXfac)/2, y); } // [RH] Draw icon, if any if (D_DrawIcon) { int lump = W_CheckNumForName (D_DrawIcon); D_DrawIcon = NULL; if (lump >= 0) { patch_t *p = W_CachePatch (lump); screen->DrawPatchIndirect (p, 160-p->width()/2, 100-p->height()/2); } NoWipe = 10; } static bool live_wiping = false; if (!wipe) { if(live_wiping) { // wipe update online (multiple calls, not just looping here) C_DrawConsole (); wipe_EndScreen(); live_wiping = !wipe_ScreenWipe (1); M_Drawer (); // menu is drawn even on top of wipes I_FinishUpdate (); // page flip or blit buffer } else { // normal update C_DrawConsole (); // draw console M_Drawer (); // menu is drawn even on top of everything I_FinishUpdate (); // page flip or blit buffer } } else { if(!connected) { // wipe update offline int wipestart, wipecont, nowtime, tics; BOOL done; C_DrawConsole (); wipe_EndScreen (); I_FinishUpdateNoBlit (); extern int canceltics; wipestart = I_GetTime (); wipecont = wipestart - 1; do { do { nowtime = I_GetTime (); tics = nowtime - wipecont; } while (!tics); wipecont = nowtime; I_BeginUpdate (); done = wipe_ScreenWipe (tics); M_Drawer (); // menu is drawn even on top of wipes I_FinishUpdate (); // page flip or blit buffer } while (!done); if(!connected) canceltics += I_GetTime () - wipestart; } else { // wipe update online live_wiping = true; // wipe update online (multiple calls, not just looping here) C_DrawConsole (); wipe_EndScreen(); live_wiping = !wipe_ScreenWipe (1); M_Drawer (); // menu is drawn even on top of wipes I_FinishUpdate (); // page flip or blit buffer } } END_STAT(D_Display); }
// // D_Display // draw current display, possibly wiping it from the previous // void D_Display (void) { if (nodrawers) return; // for comparative timing / profiling BEGIN_STAT(D_Display); // [RH] change the screen mode if needed if (setmodeneeded) { // Change screen mode. if (!V_SetResolution (NewWidth, NewHeight, NewBits)) I_FatalError ("Could not change screen mode"); // Recalculate various view parameters. setsizeneeded = true; // Trick status bar into rethinking its position st_scale.Callback (); // Refresh the console. C_NewModeAdjust (); } // [AM] Moved to below setmodeneeded so we have accurate screen size info. if (gamestate == GS_LEVEL && viewactive && consoleplayer().camera) { if (consoleplayer().camera->player) R_SetFOV(consoleplayer().camera->player->fov, setmodeneeded || setsizeneeded); else R_SetFOV(90.0f, setmodeneeded || setsizeneeded); } // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize (); setmodeneeded = false; } I_BeginUpdate (); // [RH] Allow temporarily disabling wipes if (NoWipe) { NoWipe--; wipegamestate = gamestate; } else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE) { wipegamestate = gamestate; Wipe_Start(); wiping_screen = true; } switch (gamestate) { case GS_FULLCONSOLE: case GS_DOWNLOAD: case GS_CONNECTING: case GS_CONNECTED: C_DrawConsole (); M_Drawer (); I_FinishUpdate (); return; case GS_LEVEL: if (!gametic) break; // denis - freshen the borders (ffs..) R_DrawViewBorder (); // erase old menu stuff if (viewactive) R_RenderPlayerView (&displayplayer()); if (automapactive) AM_Drawer (); C_DrawMid (); C_DrawGMid(); CTF_DrawHud (); ST_Drawer (); HU_Drawer (); break; case GS_INTERMISSION: if (viewactive) R_RenderPlayerView (&displayplayer()); C_DrawMid (); CTF_DrawHud (); WI_Drawer (); HU_Drawer (); break; case GS_FINALE: F_Drawer (); break; case GS_DEMOSCREEN: D_PageDrawer (); break; default: break; } // draw pause pic if (paused && !menuactive) { patch_t *pause = W_CachePatch ("M_PAUSE"); int y; y = (automapactive && !viewactive) ? 4 : viewwindowy + 4; screen->DrawPatchCleanNoMove (pause, (screen->width-(pause->width())*CleanXfac)/2, y); } // [RH] Draw icon, if any if (D_DrawIcon) { int lump = W_CheckNumForName (D_DrawIcon); D_DrawIcon = NULL; if (lump >= 0) { patch_t *p = W_CachePatch (lump); screen->DrawPatchIndirect (p, 160-p->width()/2, 100-p->height()/2); } NoWipe = 10; } if (wiping_screen) Wipe_Drawer(); C_DrawConsole(); // draw console M_Drawer(); // menu is drawn even on top of everything I_FinishUpdate(); // page flip or blit buffer END_STAT(D_Display); }