Пример #1
0
static void do_signalled(void) {
  sigprocmask(SIG_SETMASK, &ssblock, NULL);
  if (signalled & SIGNALLED_TERM) {
    if (fork_on_reload < 0) { /* this is a temp child; dump stats and exit */
      ipc_write_stats(1);
      if (flog && !flushlog)
        fflush(flog);
      _exit(0);
    }
    dslog(LOG_INFO, 0, "terminating");
#ifndef NO_STATS
    if (statsfile)
      dumpstats();
    logstats(0);
    if (statsfile)
      dumpstats_z();
#endif
    exit(0);
  }
#ifndef NO_STATS
  if (signalled & SIGNALLED_SSTATS && statsfile)
    dumpstats();
  if (signalled & SIGNALLED_LSTATS) {
    logstats(signalled & SIGNALLED_ZSTATS);
    if (signalled & SIGNALLED_ZSTATS && statsfile)
      dumpstats_z();
  }
#endif
  if (signalled & SIGNALLED_RELOG)
    reopenlog();
  if (signalled & SIGNALLED_RELOAD)
    do_reload(fork_on_reload);
  signalled = 0;
  sigprocmask(SIG_SETMASK, &ssempty, NULL);
}
Пример #2
0
/** Play the mission. */
void Game::play()
{
    VQAMovie *mov;
    // Start the music
    SDL_LockAudio();
    pc::sfxeng->playSong(p::ccmap->getMissionData().theme);
    SDL_UnlockAudio();
    pc::gfxeng->setupCurrentGame();
    // Jump to start location
    // @TODO: Jump to correct start location in multiplayer games.
    p::ccmap->restoreLocation(0);
    /* main gameloop */
    while (!pc::input->shouldQuit()) {
        // Draw the scene
        pc::gfxeng->renderScene();
        // Run scheduled events
        p::aequeue->runEvents();
        // Handle the input
        pc::input->handle();
        // Run the AI scripts
        p::ppool->runAIs();
        if (gamemode == 2) {
            // Synchronise events with server
        }
    }
    // Stop the music
    pc::sfxeng->stopSong();

    if (gamemode == 0) {
        if (p::ppool->hasWon() ) {
            try {
                mov = new VQAMovie(p::ccmap->getMissionData().winmov);
                mov->play();
                delete mov;
            } catch (VQAError&) {
            }
        } else if (p::ppool->hasLost() ) {
            try {
                mov = new VQAMovie(p::ccmap->getMissionData().losemov);
                mov->play();
                delete mov;
            } catch (VQAError&) {
            }
        }
    }
    dumpstats();
}