/** * Close up the current game (player may or may not be dead) * * Note that the savefile is not saved until the tombstone is * actually displayed and the player has a chance to examine * the inventory and such. This allows cheating if the game * is equipped with a "quit without save" method. XXX XXX XXX */ void close_game(void) { /* Tell the UI we're done with the game state */ event_signal(EVENT_LEAVE_GAME); /* Handle stuff */ handle_stuff(player->upkeep); /* Flush the messages */ event_signal(EVENT_MESSAGE_FLUSH); /* Flush the input */ event_signal(EVENT_INPUT_FLUSH); /* No suspending now */ signals_ignore_tstp(); /* Hack -- Increase "icky" depth */ screen_save_depth++; /* Save monster memory to user directory */ if (!lore_save("lore.txt")) { msg("lore save failed!"); event_signal(EVENT_MESSAGE_FLUSH); } /* Handle death or life */ if (player->is_dead) { death_knowledge(); death_screen(); /* Save dead player */ if (!savefile_save(savefile)) { msg("death save failed!"); event_signal(EVENT_MESSAGE_FLUSH); } } else { /* Save the game */ save_game(); if (Term->mapped_flag) { struct keypress ch; prt("Press Return (or Escape).", 0, 40); ch = inkey(); if (ch.code != ESCAPE) predict_score(); } } /* Hack -- Decrease "icky" depth */ screen_save_depth--; /* Allow suspending now */ signals_handle_tstp(); }
/* * Close up the current game (player may or may not be dead) * * Note that the savefile is not saved until the tombstone is * actually displayed and the player has a chance to examine * the inventory and such. This allows cheating if the game * is equipped with a "quit without save" method. XXX XXX XXX */ void close_game(void) { /* Handle stuff */ handle_stuff(p_ptr); /* Flush the messages */ message_flush(); /* Flush the input */ flush(); /* No suspending now */ signals_ignore_tstp(); /* Hack -- Increase "icky" depth */ character_icky++; /* Handle death */ if (p_ptr->is_dead) { death_screen(); } /* Still alive */ else { /* Save the game */ save_game(); if (Term->mapped_flag) { struct keypress ch; prt("Press Return (or Escape).", 0, 40); ch = inkey(); if (ch.code != ESCAPE) predict_score(); } } /* Hack -- Decrease "icky" depth */ character_icky--; /* Allow suspending now */ signals_handle_tstp(); }
/* * Show scores. */ void show_scores(void) { screen_save(); /* Display the scores */ if (character_generated) { predict_score(); } else { high_score scores[MAX_HISCORES]; highscore_read(scores, N_ELEMENTS(scores)); display_scores_aux(scores, 0, MAX_HISCORES, -1); } screen_load(); /* Hack - Flush it */ Term_fresh(); }
// TODO: Hookify this void close_game(void) { char buf[1024]; /* Handle stuff */ handle_stuff(); /* Flush the messages */ message_flush(); /* Flush the input */ flush(); /* No suspending now */ signals_ignore_tstp(); #ifndef AVT_HOOKIFY_EXIT /* Hack -- Increase "icky" depth */ character_icky++; /* Build the filename */ path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw"); /* Grab permissions */ safe_setuid_grab(); /* Open the high score file, for reading/writing */ highscore_fd = fd_open(buf, O_RDWR); /* Drop permissions */ safe_setuid_drop(); /* Handle death */ if (p_ptr->is_dead) { /* Auxiliary routine */ close_game_aux(); } /* Still alive */ else { /* Save the game */ do_cmd_save_game(); /* Prompt for scores XXX XXX XXX */ prt("Press Return (or Escape).", 0, 40); /* Predict score (or ESCAPE) */ if (inkey() != ESCAPE) predict_score(); } /* Shut the high score file */ fd_close(highscore_fd); /* Forget the high score fd */ highscore_fd = -1; /* Hack -- Decrease "icky" depth */ character_icky--; #endif /* Allow suspending now */ signals_handle_tstp(); }