/*! * The mainloop. * Fetches events, executes appropriate code */ void mainLoop(void) { frameUpdate(); // General housekeeping // Screenshot key is now available globally if (keyPressed(KEY_F10)) { kf_ScreenDump(); inputLoseFocus(); // remove it from input stream } if (NetPlay.bComms || focusState == FOCUS_IN || !war_GetPauseOnFocusLoss()) { if (loop_GetVideoStatus()) { videoLoop(); // Display the video if neccessary } else switch (GetGameMode()) { case GS_NORMAL: // Run the gameloop code runGameLoop(); break; case GS_TITLE_SCREEN: // Run the titleloop code runTitleLoop(); break; default: break; } realTimeUpdate(); // Update realTime. } }
/*! * The mainloop. * Fetches events, executes appropriate code */ void mainLoop(void) { frameUpdate(); // General housekeeping // Screenshot key is now available globally if (keyPressed(KEY_F10)) { kf_ScreenDump(); inputLoseFocus(); // remove it from input stream } if (NetPlay.bComms || focusState == FOCUS_IN || !war_GetPauseOnFocusLoss()) { if (loop_GetVideoStatus()) { videoLoop(); // Display the video if neccessary } else switch (GetGameMode()) { case GS_NORMAL: // Run the gameloop code runGameLoop(); break; case GS_TITLE_SCREEN: // Run the titleloop code runTitleLoop(); break; default: break; } realTimeUpdate(); // Update realTime. } // Feed a bit of randomness into libcrypto. unsigned buf[] = {mouseX(), mouseY(), realTime, graphicsTime, gameTime, (unsigned) rand(), 4}; // http://xkcd.com/221/ RAND_add(buf, sizeof(buf), 1); }
/*! * The mainloop. * Fetches events, executes appropriate code */ static void mainLoop(void) { SDL_Event event; while (true) { frameUpdate(); // General housekeeping /* Deal with any windows messages */ while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYUP: case SDL_KEYDOWN: inputHandleKeyEvent(&event.key); break; case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONDOWN: inputHandleMouseButtonEvent(&event.button); break; case SDL_MOUSEMOTION: inputHandleMouseMotionEvent(&event.motion); break; case SDL_ACTIVEEVENT: handleActiveEvent(&event.active); break; case SDL_QUIT: saveConfig(); return; default: break; } } // Screenshot key is now available globally if(keyPressed(KEY_F10)) { kf_ScreenDump(); inputLooseFocus(); // remove it from input stream } // only pause when not in multiplayer, no focus, and we actually want to pause if (NetPlay.bComms || focusState == FOCUS_IN || !war_GetPauseOnFocusLoss()) { if (loop_GetVideoStatus()) { videoLoop(); // Display the video if neccessary } else switch (GetGameMode()) { case GS_NORMAL: // Run the gameloop code runGameLoop(); break; case GS_TITLE_SCREEN: // Run the titleloop code runTitleLoop(); break; default: break; } realTimeUpdate(); // Update realTime. } } }