OSDN Git Service

[Refactor] #38993 o_list と max_o_idx を floor_type に取り込む。 / Move o_list and max_o_idx...
[hengband/hengband.git] / src / cmd4.c
index f567efa..f8b48e5 100644 (file)
 #include "world.h"
 #include "player-status.h"
 #include "sort.h"
+#include "mutation.h"
+#include "quest.h"
+#include "store.h"
+#include "artifact.h"
+#include "avatar.h"
+#include "object-hook.h"
 
 
 /*
@@ -386,7 +392,7 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
            type == NIKKI_RAND_QUEST_F ||
            type == NIKKI_TO_QUEST)
        {
-               IDX old_quest;
+               QUEST_IDX old_quest;
 
                old_quest = p_ptr->inside_quest;
                p_ptr->inside_quest = (quest[num].type == QUEST_TYPE_RANDOM) ? 0 : num;
@@ -420,13 +426,13 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
                return (-1);
        }
 
-       q_idx = quest_number(dun_level);
+       q_idx = quest_number(current_floor_ptr->dun_level);
 
        if (write_level)
        {
                if (p_ptr->inside_arena)
                        note_level = _("アリーナ:", "Arane:");
-               else if (!dun_level)
+               else if (!current_floor_ptr->dun_level)
                        note_level = _("地上:", "Surface:");
                else if (q_idx && (is_fixed_quest_idx(q_idx)
                        && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
@@ -434,9 +440,9 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
                else
                {
 #ifdef JP
-                       sprintf(note_level_buf, "%d階(%s):", (int)dun_level, d_name+d_info[dungeon_type].name);
+                       sprintf(note_level_buf, "%d階(%s):", (int)current_floor_ptr->dun_level, d_name+d_info[p_ptr->dungeon_idx].name);
 #else
-                       sprintf(note_level_buf, "%s L%d:", d_name+d_info[dungeon_type].name, (int)dun_level);
+                       sprintf(note_level_buf, "%s L%d:", d_name+d_info[p_ptr->dungeon_idx].name, (int)current_floor_ptr->dun_level);
 #endif
                        note_level = note_level_buf;
                }
@@ -511,8 +517,8 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
                {
                        fprintf(fff, _(" %2d:%02d %20s %sの最深階%d階に到達した。\n",
                                                   " %2d:%02d %20s reached level %d of %s for the first time.\n"), hour, min, note_level,
-                                                  _(d_name+d_info[dungeon_type].name, num),
-                                                  _(num, d_name+d_info[dungeon_type].name));
+                                                  _(d_name+d_info[p_ptr->dungeon_idx].name, num),
+                                                  _(num, d_name+d_info[p_ptr->dungeon_idx].name));
                        break;
                }
                case NIKKI_TRUMP:
@@ -533,8 +539,8 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
                        }
                        else
                        {
-                               if (!(dun_level+num)) to = _("地上", "the surface");
-                               else to = format(_("%d階", "level %d"), dun_level+num);
+                               if (!(current_floor_ptr->dun_level+num)) to = _("地上", "the surface");
+                               else to = format(_("%d階", "level %d"), current_floor_ptr->dun_level+num);
                        }
                        fprintf(fff, _(" %2d:%02d %20s %sへ%s。\n", " %2d:%02d %20s %s %s.\n"), hour, min, note_level, _(to, note), _(note, to));
                        break;
@@ -543,8 +549,8 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
                {
                        if (!num)
                        fprintf(fff, _(" %2d:%02d %20s 帰還を使って%sの%d階へ下りた。\n", " %2d:%02d %20s recalled to dungeon level %d of %s.\n"), 
-                                               hour, min, note_level, _(d_name+d_info[dungeon_type].name, (int)max_dlv[dungeon_type]), 
-                                                                                          _((int)max_dlv[dungeon_type], d_name+d_info[dungeon_type].name));
+                                               hour, min, note_level, _(d_name+d_info[p_ptr->dungeon_idx].name, (int)max_dlv[p_ptr->dungeon_idx]), 
+                                                                                          _((int)max_dlv[p_ptr->dungeon_idx], d_name+d_info[p_ptr->dungeon_idx].name));
                        else
                                fprintf(fff, _(" %2d:%02d %20s 帰還を使って地上へと戻った。\n", " %2d:%02d %20s recalled from dungeon to surface.\n"), hour, min, note_level);
                        break;
@@ -600,10 +606,10 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
                case NIKKI_WIZ_TELE:
                {
                        concptr to;
-                       if (!dun_level)
+                       if (!current_floor_ptr->dun_level)
                                to = _("地上", "the surface");
                        else
-                               to = format(_("%d階(%s)", "level %d of %s"), dun_level, d_name+d_info[dungeon_type].name);
+                               to = format(_("%d階(%s)", "level %d of %s"), current_floor_ptr->dun_level, d_name+d_info[p_ptr->dungeon_idx].name);
 
                        fprintf(fff, _(" %2d:%02d %20s %sへとウィザード・テレポートで移動した。\n",
                                                   " %2d:%02d %20s wizard-teleport to %s.\n"), hour, min, note_level, to);
@@ -612,10 +618,10 @@ errr do_cmd_write_nikki(int type, int num, concptr note)
                case NIKKI_PAT_TELE:
                {
                        concptr to;
-                       if (!dun_level)
+                       if (!current_floor_ptr->dun_level)
                                to = _("地上", "the surface");
                        else
-                               to = format(_("%d階(%s)", "level %d of %s"), dun_level, d_name+d_info[dungeon_type].name);
+                               to = format(_("%d階(%s)", "level %d of %s"), current_floor_ptr->dun_level, d_name+d_info[p_ptr->dungeon_idx].name);
 
                        fprintf(fff, _(" %2d:%02d %20s %sへとパターンの力で移動した。\n",
                                                   " %2d:%02d %20s used Pattern to teleport to %s.\n"), hour, min, note_level, to);
@@ -3218,7 +3224,7 @@ void do_cmd_visuals(void)
                case '4':
                {
                        static concptr choice_msg = _("モンスターの[色/文字]を変更します", "Change monster attr/chars");
-                       static IDX r = 0;
+                       static MONRACE_IDX r = 0;
 
                        prt(format(_("コマンド: %s", "Command: %s"), choice_msg), 15, 0);
 
@@ -3852,16 +3858,16 @@ void do_cmd_feeling(void)
        if (p_ptr->wild_mode) return;
 
        /* No useful feeling in quests */
-       if (p_ptr->inside_quest && !random_quest_number(dun_level))
+       if (p_ptr->inside_quest && !random_quest_number(current_floor_ptr->dun_level))
        {
                msg_print(_("典型的なクエストのダンジョンのようだ。", "Looks like a typical quest level."));
                return;
        }
 
        /* No useful feeling in town */
-       else if (p_ptr->town_num && !dun_level)
+       else if (p_ptr->town_num && !current_floor_ptr->dun_level)
        {
-               if (!strcmp(town[p_ptr->town_num].name, _("荒野", "wilderness")))
+               if (!strcmp(town_info[p_ptr->town_num].name, _("荒野", "wilderness")))
                {
                        msg_print(_("何かありそうな荒野のようだ。", "Looks like a strange wilderness."));
                        return;
@@ -3874,7 +3880,7 @@ void do_cmd_feeling(void)
        }
 
        /* No useful feeling in the wilderness */
-       else if (!dun_level)
+       else if (!current_floor_ptr->dun_level)
        {
                msg_print(_("典型的な荒野のようだ。", "Looks like a typical wilderness."));
                return;
@@ -4795,7 +4801,7 @@ static void do_cmd_knowledge_inven(void)
                        do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
                }
 
-               st_ptr = &town[1].store[STORE_HOME];
+               st_ptr = &town_info[1].store[STORE_HOME];
                strcpy(where, _("家", "H "));
                for (i = 0; i < st_ptr->stock_num; i++)
                {
@@ -5264,19 +5270,19 @@ static void do_cmd_knowledge_artifacts(void)
        }
 
        /* Check the dungeon */
-       for (y = 0; y < cur_hgt; y++)
+       for (y = 0; y < current_floor_ptr->height; y++)
        {
-               for (x = 0; x < cur_wid; x++)
+               for (x = 0; x < current_floor_ptr->width; x++)
                {
-                       cave_type *c_ptr = &cave[y][x];
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
                        /* Scan all objects in the grid */
-                       for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+                       for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                        {
                                object_type *o_ptr;
-                               o_ptr = &o_list[this_o_idx];
+                               o_ptr = &current_floor_ptr->o_list[this_o_idx];
 
                                /* Acquire next object */
                                next_o_idx = o_ptr->next_o_idx;
@@ -6162,7 +6168,7 @@ static void browser_cursor(char ch, int *column, IDX *grp_cur, int grp_cnt,
                int old_grp = grp;
 
                /* Move up or down */
-               grp += ddy[d];
+               grp += (IDX)ddy[d];
 
                /* Verify */
                if (grp >= grp_cnt)     grp = grp_cnt - 1;
@@ -6174,7 +6180,7 @@ static void browser_cursor(char ch, int *column, IDX *grp_cur, int grp_cnt,
        else
        {
                /* Move up or down */
-               list += ddy[d];
+               list += (IDX)ddy[d];
 
                /* Verify */
                if (list >= list_cnt) list = list_cnt - 1;
@@ -6208,11 +6214,10 @@ static void display_visual_list(int col, int row, int height, int width, TERM_CO
                /* Display columns until done */
                for (j = 0; j < width; j++)
                {
-                       byte a;
-                       char c;
+                       TERM_COLOR a, ia;
+                       SYMBOL_CODE c, ic;
                        TERM_LEN x = col + j;
                        TERM_LEN y = row + i;
-                       int ia, ic;
 
                        /* Bigtile mode uses double width */
                        if (use_bigtile) x += j;
@@ -6225,8 +6230,8 @@ static void display_visual_list(int col, int row, int height, int width, TERM_CO
                            (!use_graphics && ic > 0x7f))
                                continue;
 
-                       a = (byte)ia;
-                       c = (char)ic;
+                       a = ia;
+                       c = ic;
 
                        /* Force correct code for both ASCII character and tile */
                        if (c & 0x80) a |= 0x80;
@@ -6375,8 +6380,8 @@ static bool visual_mode_command(char ch, bool *visual_list_ptr,
                        if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
                        if ((c == 0xff) && (ddx[d] > 0)) d = 0;
 
-                       a += ddy[d];
-                       c += ddx[d];
+                       a += (TERM_COLOR)ddy[d];
+                       c += (SYMBOL_CODE)ddx[d];
 
                        /* Force correct code for both ASCII character and tile */
                        if (c & 0x80) a |= 0x80;
@@ -7583,9 +7588,8 @@ static void do_cmd_knowledge_virtues(void)
 }
 
 /*
-* Dungeon
-*
-*/
+ * Dungeon
+ */
 static void do_cmd_knowledge_dungeon(void)
 {
        FILE *fff;
@@ -7684,7 +7688,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
        char rand_tmp_str[120] = "\0";
        GAME_TEXT name[MAX_NLEN];
        monster_race *r_ptr;
-       IDX i;
+       QUEST_IDX i;
        int rand_level = 100;
        int total = 0;
 
@@ -7697,7 +7701,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
                        (quest[i].status == QUEST_STATUS_COMPLETED))
                {
                        /* Set the quest number temporary */
-                       IDX old_quest = p_ptr->inside_quest;
+                       QUEST_IDX old_quest = p_ptr->inside_quest;
                        int j;
 
                        /* Clear the text */
@@ -8062,7 +8066,7 @@ static void do_cmd_knowledge_quests(void)
        fd_kill(file_name);
 
        /* Free Memory */
-       C_KILL(quest_num, max_q_idx, IDX);
+       C_KILL(quest_num, max_q_idx, QUEST_IDX);
 }
 
 
@@ -8092,7 +8096,7 @@ static void do_cmd_knowledge_home(void)
        if (fff)
        {
                /* Print all homes in the different towns */
-               st_ptr = &town[1].store[STORE_HOME];
+               st_ptr = &town_info[1].store[STORE_HOME];
 
                /* Home -- if anything there */
                if (st_ptr->stock_num)