#include "angband.h"
#include "cmd-activate.h"
#include "cmd-eat.h"
+#include "cmd-hissatsu.h"
#include "cmd-item.h"
#include "cmd-magiceat.h"
#include "cmd-quaff.h"
#include "realm-hex.h"
#include "object-hook.h"
#include "wild.h"
+#include "monster-status.h"
+#include "floor-save.h"
static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
{
return;
}
-
- /* Paranoia */
if (command_arg < min_level) command_arg = (COMMAND_ARG)min_level;
-
- /* Paranoia */
if (command_arg > max_level) command_arg = (COMMAND_ARG)max_level;
/* Accept request */
* and create a first saved floor
*/
prepare_change_floor_mode(CFM_FIRST_FLOOR);
-
- /* Leaving */
p_ptr->leaving = TRUE;
}
monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Allow regeneration (if needed) */
if (m_ptr->hp < m_ptr->maxhp)
{
monster_type *m_ptr = ¤t_floor_ptr->m_list[monster];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
- /* Paranoia -- Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
if (r_ptr->level >= p_ptr->lev)
{
* and create a first saved floor
*/
prepare_change_floor_mode(CFM_FIRST_FLOOR);
-
- /* Leaving */
p_ptr->leaving = TRUE;
if (p_ptr->dungeon_idx == DUNGEON_ANGBAND)
* and create a first saved floor
*/
prepare_change_floor_mode(CFM_FIRST_FLOOR);
-
- /* Leaving */
p_ptr->leaving = TRUE;
}
else
monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
monster_race *r_ptr;
int delta = 0;
-
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
/* Ignore pet */
if (is_pet(m_ptr)) continue;
/* Stop playing */
p_ptr->playing = FALSE;
-
- /* Leaving */
p_ptr->leaving = TRUE;
}
}
/* Check every feature */
for (i = 1; i < max_f_idx; i++)
{
- /* Access the index */
feature_type *f_ptr = &f_info[i];
/* Skip empty index */
/* Every 15 minutes after 11:00 pm */
if ((hour == 23) && !(min % 15))
{
- /* Disturbing */
disturb(FALSE, TRUE);
switch (min / 15)
{
if (vanilla_town) break;
- if (ambush_flag)
+ if (p_ptr->ambush_flag)
{
msg_print(_("襲撃から逃げるにはマップの端まで移動しなければならない。", "To flee the ambush you have to reach the edge of the map."));
break;
/* Access the slot to be dropped */
o_ptr = &inventory[INVEN_PACK];
- /* Disturbing */
disturb(FALSE, TRUE);
/* Warning */
*/
static void process_player(void)
{
- IDX i;
+ MONSTER_IDX m_idx;
/*** Apply energy ***/
if (p_ptr->inside_battle)
{
- for(i = 1; i < m_max; i++)
+ for(m_idx = 1; m_idx < m_max; m_idx++)
{
- monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
+ monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
- if (!m_ptr->r_idx) continue;
+ if (!monster_is_valid(m_ptr)) continue;
m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
- update_monster(i, FALSE);
+ update_monster(m_idx, FALSE);
}
prt_time();
}
}
}
- /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
handle_stuff();
}
process_command();
}
-
/* Hack -- Pack Overflow */
pack_overflow();
-
/*** Clean up ***/
/* Significant */
shimmer_monsters = FALSE;
/* Shimmer multi-hued monsters */
- for (i = 1; i < m_max; i++)
+ for (m_idx = 1; m_idx < m_max; m_idx++)
{
monster_type *m_ptr;
monster_race *r_ptr;
- /* Access monster */
- m_ptr = ¤t_floor_ptr->m_list[i];
-
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ m_ptr = ¤t_floor_ptr->m_list[m_idx];
+ if (!monster_is_valid(m_ptr)) continue;
/* Skip unseen monsters */
if (!m_ptr->ml) continue;
repair_monsters = FALSE;
/* Rotate detection flags */
- for (i = 1; i < m_max; i++)
+ for (m_idx = 1; m_idx < m_max; m_idx++)
{
monster_type *m_ptr;
-
- /* Access monster */
- m_ptr = ¤t_floor_ptr->m_list[i];
-
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ m_ptr = ¤t_floor_ptr->m_list[m_idx];
+ if (!monster_is_valid(m_ptr)) continue;
/* Nice monsters get mean */
if (m_ptr->mflag & MFLAG_NICE)
/* Assume invisible */
m_ptr->ml = FALSE;
- update_monster(i, FALSE);
+ update_monster(m_idx, FALSE);
- if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
+ if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
+ if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
/* Redraw regardless */
lite_spot(m_ptr->fy, m_ptr->fx);
}
if (p_ptr->pclass == CLASS_IMITATOR)
{
+ int j;
if (p_ptr->mane_num > (p_ptr->lev > 44 ? 3 : p_ptr->lev > 29 ? 2 : 1))
{
p_ptr->mane_num--;
- for (i = 0; i < p_ptr->mane_num; i++)
+ for (j = 0; j < p_ptr->mane_num; j++)
{
- p_ptr->mane_spell[i] = p_ptr->mane_spell[i+1];
- p_ptr->mane_dam[i] = p_ptr->mane_dam[i+1];
+ p_ptr->mane_spell[j] = p_ptr->mane_spell[j + 1];
+ p_ptr->mane_dam[j] = p_ptr->mane_dam[j + 1];
}
}
new_mane = FALSE;
p_ptr->redraw |= (PR_MAP);
p_ptr->update |= (PU_MONSTERS);
-
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
msg_print(_("「時は動きだす…」", "You feel time flowing around you once more."));
p_ptr->timewalk = FALSE;
p_ptr->energy_need = ENERGY_NEED();
- /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
handle_stuff();
}
}
target_who = 0;
pet_t_m_idx = 0;
riding_t_m_idx = 0;
- ambush_flag = FALSE;
+ p_ptr->ambush_flag = FALSE;
/* Cancel the health bar */
health_track(0);
character_xtra = TRUE;
p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
+ p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
+ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH | PU_MONSTERS | PU_DISTANCE | PU_FLOW);
- /* Redraw dungeon */
- p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY);
-
- p_ptr->redraw |= (PR_MAP);
-
- p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-
- /* Update lite/view */
- p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
- p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
-
- /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
handle_stuff();
/* Leave "xtra" mode */
process_player();
process_upkeep_with_speed();
- /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
handle_stuff();
/* Hack -- Hilite the player */
rollback_turns = TURNS_PER_TICK * TOWN_DAWN * rollback_days;
if (current_world_ptr->game_turn > rollback_turns) current_world_ptr->game_turn -= rollback_turns;
- else current_world_ptr->game_turn = 1; /* Paranoia */
+ else current_world_ptr->game_turn = 1;
if (current_floor_ptr->generated_turn > rollback_turns) current_floor_ptr->generated_turn -= rollback_turns;
else current_floor_ptr->generated_turn = 1;
if (old_battle > rollback_turns) old_battle -= rollback_turns;
}
}
}
+
+/*!
+ * @brief ゲーム終了処理 /
+ * Close up the current game (player may or may not be dead)
+ * @return なし
+ * @details
+ * <pre>
+ * This function is called only from "main.c" and "signals.c".
+ * </pre>
+ */
+void close_game(void)
+{
+ char buf[1024];
+ bool do_send = TRUE;
+
+ /* concptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
+ handle_stuff();
+
+ /* Flush the messages */
+ msg_print(NULL);
+
+ /* Flush the input */
+ flush();
+
+
+ /* No suspending now */
+ signals_ignore_tstp();
+
+
+ /* Hack -- Character is now "icky" */
+ character_icky = TRUE;
+
+
+ /* 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)
+ {
+ /* Handle retirement */
+ if (p_ptr->total_winner) kingly();
+
+ /* Save memories */
+ if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
+ {
+ if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
+ }
+ else do_send = FALSE;
+
+ /* You are dead */
+ print_tomb();
+
+ flush();
+
+ /* Show more info */
+ show_info();
+ Term_clear();
+
+ if (check_score())
+ {
+ if ((!send_world_score(do_send)))
+ {
+ if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
+ (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
+ {
+ p_ptr->wait_report_score = TRUE;
+ p_ptr->is_dead = FALSE;
+ if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
+ }
+ }
+ if (!p_ptr->wait_report_score)
+ (void)top_twenty();
+ }
+ else if (highscore_fd >= 0)
+ {
+ display_scores_aux(0, 10, -1, NULL);
+ }
+#if 0
+ /* Dump bones file */
+ make_bones();
+#endif
+ }
+
+ /* Still alive */
+ else
+ {
+ /* Save the game */
+ do_cmd_save_game(FALSE);
+
+ /* Prompt for scores */
+ prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
+ play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
+
+ /* Predict score (or ESCAPE) */
+ if (inkey() != ESCAPE) predict_score();
+ }
+
+
+ /* Shut the high score file */
+ (void)fd_close(highscore_fd);
+
+ /* Forget the high score fd */
+ highscore_fd = -1;
+
+ /* Kill all temporal files */
+ clear_saved_floor_files();
+
+ /* Allow suspending now */
+ signals_handle_tstp();
+}