OSDN Git Service

[Refactor] #38997 'while (1)' を 'while (TRUE)' に変更 / Changed 'while (1)' to 'while...
[hengband/hengband.git] / src / files.c
index edfb032..11c9abc 100644 (file)
@@ -3149,7 +3149,7 @@ static void display_flag_aux(TERM_LEN row, TERM_LEN col, concptr header,
  * Special display, part 1
  * @return なし
  */
-static void display_player_flag_info(void)
+static void display_player_flag_info(player_type *creature_ptr)
 {
        TERM_LEN row;
        TERM_LEN col;
@@ -3157,12 +3157,12 @@ static void display_player_flag_info(void)
        all_player_flags f;
 
        /* Extract flags and store */
-       player_flags(p_ptr, f.player_flags);
-       tim_player_flags(p_ptr, f.tim_player_flags);
-       player_immunity(p_ptr, f.player_imm);
-       tim_player_immunity(p_ptr, f.tim_player_imm);
-       known_obj_immunity(p_ptr, f.known_obj_imm);
-       player_vuln_flags(p_ptr, f.player_vuln);
+       player_flags(creature_ptr, f.player_flags);
+       tim_player_flags(creature_ptr, f.tim_player_flags);
+       player_immunity(creature_ptr, f.player_imm);
+       tim_player_immunity(creature_ptr, f.tim_player_imm);
+       known_obj_immunity(creature_ptr, f.known_obj_imm);
+       player_vuln_flags(creature_ptr, f.player_vuln);
 
        /*** Set 1 ***/
 
@@ -3280,7 +3280,7 @@ static void display_player_flag_info(void)
  * Special display, part 2
  * @return なし
  */
-static void display_player_other_flag_info(void)
+static void display_player_other_flag_info(player_type *creature_ptr)
 {
        TERM_LEN row;
        TERM_LEN col;
@@ -3288,12 +3288,12 @@ static void display_player_other_flag_info(void)
        all_player_flags f;
 
        /* Extract flags and store */
-       player_flags(p_ptr, f.player_flags);
-       tim_player_flags(p_ptr, f.tim_player_flags);
-       player_immunity(p_ptr, f.player_imm);
-       tim_player_immunity(p_ptr, f.tim_player_imm);
-       known_obj_immunity(p_ptr, f.known_obj_imm);
-       player_vuln_flags(p_ptr, f.player_vuln);
+       player_flags(creature_ptr, f.player_flags);
+       tim_player_flags(creature_ptr, f.tim_player_flags);
+       player_immunity(creature_ptr, f.player_imm);
+       tim_player_immunity(creature_ptr, f.tim_player_imm);
+       known_obj_immunity(creature_ptr, f.known_obj_imm);
+       player_vuln_flags(creature_ptr, f.player_vuln);
 
        /*** Set 1 ***/
 
@@ -3473,7 +3473,7 @@ static void display_player_other_flag_info(void)
  * Special display, part 2a
  * @return なし
  */
-static void display_player_misc_info(void)
+static void display_player_misc_info(player_type *creature_ptr)
 {
        char    buf[80];
        char    tmp[80];
@@ -3498,11 +3498,11 @@ put_str("職業  :", 5, 1);
 #else
                strcat(tmp," ");
 #endif
-       strcat(tmp,p_ptr->name);
+       strcat(tmp,creature_ptr->name);
 
        c_put_str(TERM_L_BLUE, tmp, 1, 34);
        c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
-       c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
+       c_put_str(TERM_L_BLUE, (creature_ptr->mimic_form ? mimic_info[creature_ptr->mimic_form].title : rp_ptr->title), 4, 9);
        c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
 
        /* Display extras */
@@ -3517,11 +3517,11 @@ put_str("MP  :", 8, 1);
 #endif
 
 
-       (void)sprintf(buf, "%d", (int)p_ptr->lev);
+       (void)sprintf(buf, "%d", (int)creature_ptr->lev);
        c_put_str(TERM_L_BLUE, buf, 6, 9);
-       (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
+       (void)sprintf(buf, "%d/%d", (int)creature_ptr->chp, (int)creature_ptr->mhp);
        c_put_str(TERM_L_BLUE, buf, 7, 9);
-       (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
+       (void)sprintf(buf, "%d/%d", (int)creature_ptr->csp, (int)creature_ptr->msp);
        c_put_str(TERM_L_BLUE, buf, 8, 9);
 }
 
@@ -3974,7 +3974,7 @@ void display_player(player_type *creature_ptr, int mode)
                                        /* Bewere that INIT_ASSIGN resets the cur_num. */
                                        init_flags = INIT_NAME_ONLY;
 
-                                       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
+                                       process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
 
 #ifdef JP
                                        sprintf(statmsg, "…あなたは、クエスト「%s」で%sに殺された。", quest[creature_ptr->current_floor_ptr->inside_quest].name, creature_ptr->died_from);
@@ -4010,7 +4010,7 @@ void display_player(player_type *creature_ptr, int mode)
                                        /* Get the quest text */
                                        init_flags = INIT_NAME_ONLY;
 
-                                       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
+                                       process_dungeon_file(creature_ptr, "q_info.txt", 0, 0, 0, 0);
 
                                        sprintf(statmsg, _("…あなたは現在、 クエスト「%s」を遂行中だ。", "...Now, you are in the quest '%s'."), quest[creature_ptr->current_floor_ptr->inside_quest].name);
                                }
@@ -4057,15 +4057,15 @@ void display_player(player_type *creature_ptr, int mode)
                /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
 
                /* Dump the info */
-               display_player_misc_info();
+               display_player_misc_info(creature_ptr);
                display_player_stat_info(creature_ptr);
-               display_player_flag_info();
+               display_player_flag_info(creature_ptr);
        }
 
        /* Special */
        else if (mode == 3)
        {
-               display_player_other_flag_info();
+               display_player_other_flag_info(creature_ptr);
        }
 
        else if (mode == 4)
@@ -5343,7 +5343,7 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
                msg_format(_("'%s'をオープンできません。", "Cannot open '%s'."), name);
                msg_print(NULL);
 
-               return (TRUE);
+               return TRUE;
        }
 
 
@@ -5418,7 +5418,7 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
                        /* Hack -- Re-Open the file */
                        fff = my_fopen(path, "r");
 
-                       if (!fff) return (FALSE);
+                       if (!fff) return FALSE;
 
                        /* File has been restarted */
                        next = 0;
@@ -5731,10 +5731,10 @@ bool show_file(bool show_version, concptr name, concptr what, int line, BIT_FLAG
        my_fclose(fff);
 
        /* Escape */
-       if (skey == 'q') return (FALSE);
+       if (skey == 'q') return FALSE;
 
        /* Normal return */
-       return (TRUE);
+       return TRUE;
 }
 
 
@@ -5757,13 +5757,14 @@ void do_cmd_help(void)
 /*!
  * @brief プレイヤーの名前をチェックして修正する
  * Process the player name.
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param sf セーブファイル名に合わせた修正を行うならばTRUE
  * @return なし
  * @details
  * Extract a clean "base name".
  * Build the savefile name if needed.
  */
-void process_player_name(bool sf)
+void process_player_name(player_type *creature_ptr, bool sf)
 {
        int i, k = 0;
        char old_player_base[32] = "";
@@ -5871,7 +5872,7 @@ void process_player_name(bool sf)
        {
                concptr s;
                s = savefile;
-               while (1)
+               while (TRUE)
                {
                        concptr t;
                        t = my_strstr(s, PATH_SEP);
@@ -5905,7 +5906,7 @@ void process_player_name(bool sf)
        /* Load an autopick preference file */
        if (current_world_ptr->character_generated)
        {
-               if (!streq(old_player_base, p_ptr->base_name)) autopick_load_pref(FALSE);
+               if (!streq(old_player_base, p_ptr->base_name)) autopick_load_pref(creature_ptr, FALSE);
        }
 }
 
@@ -5964,11 +5965,12 @@ void get_name(player_type *creature_ptr)
 /*!
  * @brief セーブするコマンドのメインルーチン
  * Save the game
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param is_autosave オートセーブ中の処理ならばTRUE
  * @return なし
  * @details
  */
-void do_cmd_save_game(int is_autosave)
+void do_cmd_save_game(player_type *creature_ptr, int is_autosave)
 {
        /* Autosaves do not disturb */
        if (is_autosave)
@@ -5982,7 +5984,7 @@ void do_cmd_save_game(int is_autosave)
 
        /* Clear messages */
        msg_print(NULL);
-       handle_stuff();
+       handle_stuff(creature_ptr);
 
        prt(_("ゲームをセーブしています...", "Saving game..."), 0, 0);
 
@@ -5995,7 +5997,7 @@ void do_cmd_save_game(int is_autosave)
        signals_ignore_tstp();
 
        /* Save the player */
-       if (save_player())
+       if (save_player(creature_ptr))
        {
                prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0);
        }
@@ -6143,7 +6145,7 @@ bool (*tombstone_aux)(void) = NULL;
  * Display a "tomb-stone"
  * @return なし
  */
-void print_tomb(void)
+void print_tomb(player_type *dead_ptr)
 {
        bool done = FALSE;
 
@@ -6190,7 +6192,7 @@ void print_tomb(void)
                }
 
                /* King or Queen */
-               if (current_world_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
+               if (current_world_ptr->total_winner || (dead_ptr->lev > PY_MAX_LEVEL))
                {
 #ifdef JP
                        /* 英日切り替え */
@@ -6203,10 +6205,10 @@ void print_tomb(void)
                /* Normal */
                else
                {
-                       p =  player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
+                       p =  player_title[dead_ptr->pclass][(dead_ptr->lev - 1) / 5];
                }
 
-               center_string(buf, p_ptr->name);
+               center_string(buf, dead_ptr->name);
                put_str(buf, 6, 11);
 
 #ifndef JP
@@ -6220,35 +6222,35 @@ void print_tomb(void)
                center_string(buf, cp_ptr->title);
                put_str(buf, 10, 11);
 
-               (void)sprintf(tmp, _("レベル: %d", "Level: %d"), (int)p_ptr->lev);
+               (void)sprintf(tmp, _("レベル: %d", "Level: %d"), (int)dead_ptr->lev);
                center_string(buf, tmp);
                put_str(buf, 11, 11);
 
-               (void)sprintf(tmp, _("経験値: %ld", "Exp: %ld"), (long)p_ptr->exp);
+               (void)sprintf(tmp, _("経験値: %ld", "Exp: %ld"), (long)dead_ptr->exp);
                center_string(buf, tmp);
                put_str(buf, 12, 11);
 
-               (void)sprintf(tmp, _("所持金: %ld", "AU: %ld"), (long)p_ptr->au);
+               (void)sprintf(tmp, _("所持金: %ld", "AU: %ld"), (long)dead_ptr->au);
                center_string(buf, tmp);
                put_str(buf, 13, 11);
 
 #ifdef JP
                /* 墓に刻む言葉をオリジナルより細かく表示 */
-               if (streq(p_ptr->died_from, "途中終了"))
+               if (streq(dead_ptr->died_from, "途中終了"))
                {
                        strcpy(tmp, "<自殺>");
                }
-               else if (streq(p_ptr->died_from, "ripe"))
+               else if (streq(dead_ptr->died_from, "ripe"))
                {
                        strcpy(tmp, "引退後に天寿を全う");
                }
-               else if (streq(p_ptr->died_from, "Seppuku"))
+               else if (streq(dead_ptr->died_from, "Seppuku"))
                {
                        strcpy(tmp, "勝利の後、切腹");
                }
                else
                {
-                       roff_to_buf(p_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
+                       roff_to_buf(dead_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
                        t = tmp + strlen(tmp) + 1;
                        if (*t)
                        {
@@ -6288,12 +6290,12 @@ void print_tomb(void)
                center_string(buf, tmp);
                put_str(buf, 14, 11);
 
-               if (!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
+               if (!streq(dead_ptr->died_from, "ripe") && !streq(dead_ptr->died_from, "Seppuku"))
                {
-                       if (p_ptr->current_floor_ptr->dun_level == 0)
+                       if (dead_ptr->current_floor_ptr->dun_level == 0)
                        {
-                               concptr field_name = p_ptr->town_num ? "街" : "荒野";
-                               if (streq(p_ptr->died_from, "途中終了"))
+                               concptr field_name = dead_ptr->town_num ? "街" : "荒野";
+                               if (streq(dead_ptr->died_from, "途中終了"))
                                {
                                        sprintf(tmp, "%sで死んだ", field_name);
                                }
@@ -6304,24 +6306,24 @@ void print_tomb(void)
                        }
                        else
                        {
-                               if (streq(p_ptr->died_from, "途中終了"))
+                               if (streq(dead_ptr->died_from, "途中終了"))
                                {
-                                       sprintf(tmp, "地下 %d 階で死んだ", (int)p_ptr->current_floor_ptr->dun_level);
+                                       sprintf(tmp, "地下 %d 階で死んだ", (int)dead_ptr->current_floor_ptr->dun_level);
                                }
                                else
                                {
-                                       sprintf(tmp, "に地下 %d 階で殺された", (int)p_ptr->current_floor_ptr->dun_level);
+                                       sprintf(tmp, "に地下 %d 階で殺された", (int)dead_ptr->current_floor_ptr->dun_level);
                                }
                        }
                        center_string(buf, tmp);
                        put_str(buf, 15 + extra_line, 11);
                }
 #else
-               (void)sprintf(tmp, "Killed on Level %d", p_ptr->current_floor_ptr->dun_level);
+               (void)sprintf(tmp, "Killed on Level %d", dead_ptr->current_floor_ptr->dun_level);
                center_string(buf, tmp);
                put_str(buf, 14, 11);
 
-               roff_to_buf(format("by %s.", p_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
+               roff_to_buf(format("by %s.", dead_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
                center_string(buf, tmp);
                put_str(buf, 15, 11);
                t = tmp + strlen(tmp) + 1;
@@ -6341,7 +6343,7 @@ void print_tomb(void)
                (void)sprintf(tmp, "%-.24s", ctime(&ct));
                center_string(buf, tmp);
                put_str(buf, 17, 11);
-               msg_format(_("さようなら、%s!", "Goodbye, %s!"), p_ptr->name);
+               msg_format(_("さようなら、%s!", "Goodbye, %s!"), dead_ptr->name);
        }
 }
 
@@ -6365,7 +6367,7 @@ void show_info(player_type *creature_ptr)
                if (!o_ptr->k_idx) continue;
 
                /* Aware and Known */
-               object_aware(o_ptr);
+               object_aware(creature_ptr, o_ptr);
                object_known(o_ptr);
        }
 
@@ -6380,14 +6382,14 @@ void show_info(player_type *creature_ptr)
                        if (!o_ptr->k_idx) continue;
 
                        /* Aware and Known */
-                       object_aware(o_ptr);
+                       object_aware(creature_ptr, o_ptr);
                        object_known(o_ptr);
                }
        }
 
        /* Hack -- Recalculate bonuses */
        creature_ptr->update |= (PU_BONUS);
-       handle_stuff();
+       handle_stuff(creature_ptr);
 
        /* Flush all input keys */
        flush();
@@ -6434,7 +6436,7 @@ void show_info(player_type *creature_ptr)
        if (creature_ptr->equip_cnt)
        {
                Term_clear();
-               (void)show_equip(0, USE_FULL, 0);
+               (void)show_equip(creature_ptr, 0, USE_FULL, 0);
                prt(_("装備していたアイテム: -続く-", "You are using: -more-"), 0, 0);
 
                if (inkey() == ESCAPE) return;
@@ -6444,7 +6446,7 @@ void show_info(player_type *creature_ptr)
        if (creature_ptr->inven_cnt)
        {
                Term_clear();
-               (void)show_inven(0, USE_FULL, 0);
+               (void)show_inven(creature_ptr, 0, USE_FULL, 0);
                prt(_("持っていたアイテム: -続く-", "You are carrying: -more-"), 0, 0);
 
                if (inkey() == ESCAPE) return;
@@ -6494,6 +6496,7 @@ void show_info(player_type *creature_ptr)
 /*!
  * @brief 異常発生時のゲーム緊急終了処理 /
  * Handle abrupt death of the visual system
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  * @details
  * <pre>
@@ -6503,7 +6506,7 @@ void show_info(player_type *creature_ptr)
  * save file so that player can see tombstone when restart.
  * </pre>
  */
-void exit_game_panic(void)
+void exit_game_panic(player_type *creature_ptr)
 {
        /* If nothing important has happened, just quit */
        if (!current_world_ptr->character_generated || current_world_ptr->character_saved) quit(_("緊急事態", "panic"));
@@ -6530,7 +6533,7 @@ void exit_game_panic(void)
        (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
 
        /* Panic save, or get worried */
-       if (!save_player()) quit(_("緊急セーブ失敗!", "panic save failed!"));
+       if (!save_player(creature_ptr)) quit(_("緊急セーブ失敗!", "panic save failed!"));
 
        /* Successful panic save */
        quit(_("緊急セーブ成功!", "panic save succeeded!"));
@@ -6735,7 +6738,7 @@ static errr counts_seek(int fd, u32b where, bool flag)
                temp1[i] ^= (i+1) * 63;
 
        seekpoint = 0;
-       while (1)
+       while (TRUE)
        {
                if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
                        return 1;
@@ -7053,7 +7056,7 @@ static void handle_signal_abort(int sig)
        signals_ignore_tstp();
 
        /* Attempt to save */
-       if (save_player())
+       if (save_player(p_ptr))
        {
                Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ成功!", "Panic save succeeded!"));
        }