OSDN Git Service

[Refactor] #37353 technic_info を spells.h 系列に移動。
[hengband/hengband.git] / src / cmd4.c
index 511c264..a3f05cd 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+
+#include "birth.h"
 #include "cmd-pet.h"
+#include "cmd-spell.h"
+#include "dungeon.h"
 #include "world.h"
+#include "player-effects.h"
 #include "player-status.h"
+#include "player-skill.h"
 #include "sort.h"
 #include "mutation.h"
 #include "quest.h"
 #include "store.h"
 #include "artifact.h"
 #include "avatar.h"
-
+#include "object-flavor.h"
+#include "object-hook.h"
+#include "monster.h"
+#include "monster-status.h"
+#include "floor.h"
+#include "view-mainwindow.h"
+#include "dungeon-file.h"
+#include "files.h"
+#include "player-class.h"
+#include "player-move.h"
+#include "spells.h"
 
 /*
  */
@@ -425,13 +442,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))))
@@ -439,9 +456,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[p_ptr->dungeon_idx].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[p_ptr->dungeon_idx].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;
                }
@@ -538,8 +555,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;
@@ -605,10 +622,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[p_ptr->dungeon_idx].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);
@@ -617,10 +634,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[p_ptr->dungeon_idx].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);
@@ -844,18 +861,18 @@ static void do_cmd_bunshou(void)
 static void do_cmd_last_get(void)
 {
        char buf[256];
-       s32b turn_tmp;
+       GAME_TURN turn_tmp;
 
        if (record_o_name[0] == '\0') return;
 
        sprintf(buf,_("%sの入手を記録します。", "Do you really want to record getting %s? "),record_o_name);
        if (!get_check(buf)) return;
 
-       turn_tmp = turn;
-       turn = record_turn;
+       turn_tmp = current_world_ptr->game_turn;
+       current_world_ptr->game_turn = record_turn;
        sprintf(buf,_("%sを手に入れた。", "descover %s."), record_o_name);
        do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
-       turn = turn_tmp;
+       current_world_ptr->game_turn = turn_tmp;
 }
 
 /*!
@@ -873,8 +890,6 @@ static void do_cmd_erase_nikki(void)
 
        /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
-
-       /* Remove the file */
        fd_kill(buf);
 
        fff = my_fopen(buf, "w");
@@ -3857,16 +3872,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;
@@ -3879,7 +3894,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;
@@ -3889,7 +3904,7 @@ void do_cmd_feeling(void)
        if (p_ptr->muta3 & MUT3_GOOD_LUCK)
                msg_print(do_cmd_feeling_text_lucky[p_ptr->feeling]);
        else if (p_ptr->pseikaku == SEIKAKU_COMBAT ||
-                inventory[INVEN_BOW].name1 == ART_CRIMSON)
+                p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)
                msg_print(do_cmd_feeling_text_combat[p_ptr->feeling]);
        else
                msg_print(do_cmd_feeling_text[p_ptr->feeling]);
@@ -4100,30 +4115,6 @@ static concptr monster_group_char[] =
 
 
 /*
- * hook function to sort monsters by level
- */
-static bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
-{
-       u16b *who = (u16b*)(u);
-
-       int w1 = who[a];
-       int w2 = who[b];
-
-       monster_race *r_ptr1 = &r_info[w1];
-       monster_race *r_ptr2 = &r_info[w2];
-
-       /* Unused */
-       (void)v;
-
-       if (r_ptr2->level > r_ptr1->level) return TRUE;
-       if (r_ptr1->level > r_ptr2->level) return FALSE;
-
-       if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return TRUE;
-       if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return FALSE;
-       return w1 <= w2;
-}
-
-/*
  * Build a list of monster indexes in the given group. Return the number
  * of monsters in the group.
  *
@@ -4180,7 +4171,7 @@ static IDX collect_monsters(IDX grp_cur, IDX mon_idx[], BIT_FLAGS8 mode)
                        int j;
                        for (j = 0; j < MAX_KUBI; j++)
                        {
-                               if (kubi_r_idx[j] == i || kubi_r_idx[j] - 10000 == i ||
+                               if (current_world_ptr->bounty_r_idx[j] == i || current_world_ptr->bounty_r_idx[j] - 10000 == i ||
                                        (p_ptr->today_mon && p_ptr->today_mon == i))
                                {
                                        wanted = TRUE;
@@ -4211,12 +4202,7 @@ static IDX collect_monsters(IDX grp_cur, IDX mon_idx[], BIT_FLAGS8 mode)
        /* Terminate the list */
        mon_idx[mon_cnt] = -1;
 
-       /* Select the sort method */
-       ang_sort_comp = ang_sort_comp_monster_level;
-       ang_sort_swap = ang_sort_swap_hook;
-
-       /* Sort by monster level */
-       ang_sort(mon_idx, &dummy_why, mon_cnt);
+       ang_sort(mon_idx, &dummy_why, mon_cnt, ang_sort_comp_monster_level, ang_sort_swap_hook);
 
        /* Return the number of races */
        return mon_cnt;
@@ -4471,7 +4457,6 @@ static FEAT_IDX collect_features(int grp_cur, FEAT_IDX *feat_idx, BIT_FLAGS8 mod
        /* Check every feature */
        for (i = 0; i < max_f_idx; i++)
        {
-               /* Access the index */
                feature_type *f_ptr = &f_info[i];
 
                /* Skip empty index */
@@ -4628,8 +4613,6 @@ void do_cmd_load_screen(void)
                        Term_draw(x, y, a, c);
                }
        }
-
-       /* Close it */
        my_fclose(fff);
 
        prt(_("ファイルに書き出された画面(記念撮影)をロードしました。", "Screen dump loaded."), 0, 0);
@@ -4792,15 +4775,15 @@ static void do_cmd_knowledge_inven(void)
                strcpy(where, _("装", "E "));
                for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
                {
-                       do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
+                       do_cmd_knowledge_inven_aux(fff, &p_ptr->inventory_list[i], &j, tval, where);
                }
                strcpy(where, _("持", "I "));
                for (i = 0; i < INVEN_PACK; i++)
                {
-                       do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
+                       do_cmd_knowledge_inven_aux(fff, &p_ptr->inventory_list[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++)
                {
@@ -4811,8 +4794,6 @@ static void do_cmd_knowledge_inven(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("*鑑定*済み武器/防具の耐性リスト", "Resistances of *identified* equipment"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -4955,8 +4936,6 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
 
        /* Skip a line */
        fprintf(fff, "\n");
-
-       /* Close it */
        my_fclose(fff);
 
        if (message) {
@@ -5115,8 +5094,6 @@ void do_cmd_save_screen(void)
 
                /* Skip a line */
                fprintf(fff, "\n");
-
-               /* Close it */
                my_fclose(fff);
 
                msg_print(_("画面(記念撮影)をファイルに書き出しました。", "Screen dump saved."));
@@ -5133,90 +5110,6 @@ void do_cmd_save_screen(void)
        }
 }
 
-
-/*
- * Sorting hook -- Comp function -- see below
- *
- * We use "u" to point to array of monster indexes,
- * and "v" to select the type of sorting to perform on "u".
- */
-static bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
-{
-       u16b *who = (u16b*)(u);
-
-       u16b *why = (u16b*)(v);
-
-       int w1 = who[a];
-       int w2 = who[b];
-
-       int z1, z2;
-
-       /* Sort by total kills */
-       if (*why >= 3)
-       {
-               /* Extract total kills */
-               z1 = a_info[w1].tval;
-               z2 = a_info[w2].tval;
-
-               /* Compare total kills */
-               if (z1 < z2) return (TRUE);
-               if (z1 > z2) return (FALSE);
-       }
-
-
-       /* Sort by monster level */
-       if (*why >= 2)
-       {
-               /* Extract levels */
-               z1 = a_info[w1].sval;
-               z2 = a_info[w2].sval;
-
-               /* Compare levels */
-               if (z1 < z2) return (TRUE);
-               if (z1 > z2) return (FALSE);
-       }
-
-
-       /* Sort by monster experience */
-       if (*why >= 1)
-       {
-               /* Extract experience */
-               z1 = a_info[w1].level;
-               z2 = a_info[w2].level;
-
-               /* Compare experience */
-               if (z1 < z2) return (TRUE);
-               if (z1 > z2) return (FALSE);
-       }
-
-
-       /* Compare indexes */
-       return (w1 <= w2);
-}
-
-
-/*
- * Sorting hook -- Swap function -- see below
- *
- * We use "u" to point to array of monster indexes,
- * and "v" to select the type of sorting to perform.
- */
-static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
-{
-       u16b *who = (u16b*)(u);
-
-       u16b holder;
-
-       /* Unused */
-       (void)v;
-
-       /* Swap */
-       holder = who[a];
-       who[a] = who[b];
-       who[b] = holder;
-}
-
-
 /*
  * Check the status of "artifacts"
  */
@@ -5269,21 +5162,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];
-
-                               /* Acquire next object */
+                               o_ptr = &current_floor_ptr->o_list[this_o_idx];
                                next_o_idx = o_ptr->next_o_idx;
 
                                /* Ignore non-artifacts */
@@ -5298,10 +5189,10 @@ static void do_cmd_knowledge_artifacts(void)
                }
        }
 
-       /* Check the inventory and equipment */
+       /* Check the p_ptr->inventory_list and equipment */
        for (i = 0; i < INVEN_TOTAL; i++)
        {
-               object_type *o_ptr = &inventory[i];
+               object_type *o_ptr = &p_ptr->inventory_list[i];
 
                /* Ignore non-objects */
                if (!o_ptr->k_idx) continue;
@@ -5321,19 +5212,12 @@ static void do_cmd_knowledge_artifacts(void)
                if (okay[k]) who[n++] = k;
        }
 
-       /* Select the sort method */
-       ang_sort_comp = ang_sort_art_comp;
-       ang_sort_swap = ang_sort_art_swap;
-
-       /* Sort the array by dungeon depth of monsters */
-       ang_sort(who, &why, n);
+       ang_sort(who, &why, n, ang_sort_art_comp, ang_sort_art_swap);
 
        /* Scan the artifacts */
        for (k = 0; k < n; k++)
        {
                artifact_type *a_ptr = &a_info[who[k]];
-
-               /* Paranoia */
                strcpy(base_name, _("未知の伝説のアイテム", "Unknown Artifact"));
 
                /* Obtain the base object type */
@@ -5372,8 +5256,6 @@ static void do_cmd_knowledge_artifacts(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("既知の伝説のアイテム", "Artifacts Seen"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -5450,12 +5332,8 @@ static void do_cmd_knowledge_uniques(void)
                who[n++] = i;
        }
 
-       /* Select the sort method */
-       ang_sort_comp = ang_sort_comp_hook;
-       ang_sort_swap = ang_sort_swap_hook;
-
        /* Sort the array by dungeon depth of monsters */
-       ang_sort(who, &why, n);
+       ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
 
        if (n_alive_surface)
        {
@@ -5497,8 +5375,6 @@ static void do_cmd_knowledge_uniques(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("まだ生きているユニーク・モンスター", "Alive Uniques"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -5554,8 +5430,6 @@ static void do_cmd_knowledge_weapon_exp(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("武器の経験値", "Weapon Proficiency"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -5643,8 +5517,6 @@ static void do_cmd_knowledge_spell_exp(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("魔法の経験値", "Spell Proficiency"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -5691,8 +5563,6 @@ static void do_cmd_knowledge_skill_exp(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("技能の経験値", "Miscellaneous Proficiency"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -5847,13 +5717,13 @@ static void do_cmd_knowledge_pets(void)
        }
 
        /* Process the monsters (backwards) */
-       for (i = m_max - 1; i >= 1; i--)
+       for (i = current_floor_ptr->m_max - 1; i >= 1; i--)
        {
                /* Access the monster */
-               m_ptr = &m_list[i];
+               m_ptr = &current_floor_ptr->m_list[i];
 
                /* Ignore "dead" monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Calculate "upkeep" for pets */
                if (is_pet(m_ptr))
@@ -5879,8 +5749,6 @@ static void do_cmd_knowledge_pets(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("現在のペット", "Current Pets"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -5964,12 +5832,8 @@ static void do_cmd_knowledge_kill_count(void)
                if (r_ptr->name) who[n++] = i;
        }
 
-       /* Select the sort method */
-       ang_sort_comp = ang_sort_comp_hook;
-       ang_sort_swap = ang_sort_swap_hook;
-
        /* Sort the array by dungeon depth of monsters */
-       ang_sort(who, &why, n);
+       ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
 
        /* Scan the monster races */
        for (k = 0; k < n; k++)
@@ -6039,8 +5903,6 @@ static void do_cmd_knowledge_kill_count(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("倒した敵の数", "Kill Count"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -6167,7 +6029,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;
@@ -6179,7 +6041,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;
@@ -6379,8 +6241,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;
@@ -6795,8 +6657,6 @@ static void desc_obj_fake(KIND_OBJECT_IDX k_idx)
        object_type object_type_body;
        o_ptr = &object_type_body;
        object_wipe(o_ptr);
-
-       /* Create the artifact */
        object_prep(o_ptr, k_idx);
 
        /* It's fully know */
@@ -7125,13 +6985,8 @@ static void display_feature_list(int col, int row, int per_page, FEAT_IDX *feat_
        for (i = 0; i < per_page && (feat_idx[feat_top + i] >= 0); i++)
        {
                TERM_COLOR attr;
-
-               /* Get the index */
                FEAT_IDX f_idx = feat_idx[feat_top + i];
-
-               /* Access the index */
                feature_type *f_ptr = &f_info[f_idx];
-
                int row_i = row + i;
 
                /* Choose a color */
@@ -7534,9 +7389,9 @@ static void do_cmd_knowledge_kubi(void)
 
                for (i = 0; i < MAX_KUBI; i++)
                {
-                       if (kubi_r_idx[i] <= 10000)
+                       if (current_world_ptr->bounty_r_idx[i] <= 10000)
                        {
-                               fprintf(fff,"%s\n", r_name + r_info[kubi_r_idx[i]].name);
+                               fprintf(fff,"%s\n", r_name + r_info[current_world_ptr->bounty_r_idx[i]].name);
 
                                listed = TRUE;
                        }
@@ -7551,8 +7406,6 @@ static void do_cmd_knowledge_kubi(void)
        
        /* Display the file contents */
        show_file(TRUE, file_name, _("賞金首の一覧", "Wanted monsters"), 0, 0);
-       
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -7581,8 +7434,6 @@ static void do_cmd_knowledge_virtues(void)
        
        /* Display the file contents */
        show_file(TRUE, file_name, _("八つの徳", "Virtues"), 0, 0);
-       
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -7625,8 +7476,6 @@ static void do_cmd_knowledge_dungeon(void)
        
        /* Display the file contents */
        show_file(TRUE, file_name, _("今までに入ったダンジョン", "Dungeon"), 0, 0);
-       
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -7672,8 +7521,6 @@ static void do_cmd_knowledge_stat(void)
        
        /* Display the file contents */
        show_file(TRUE, file_name, _("自分に関する情報", "HP-rate & Max stat"), 0, 0);
-       
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -7987,35 +7834,6 @@ static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
        if (!total) fprintf(fff, _("  なし\n", "  Nothing.\n"));
 }
 
-
-bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
-{
-       QUEST_IDX *q_num = (QUEST_IDX *)u;
-       quest_type *qa = &quest[q_num[a]];
-       quest_type *qb = &quest[q_num[b]];
-
-       /* Unused */
-       (void)v;
-
-       return (qa->comptime != qb->comptime) ?
-               (qa->comptime < qb->comptime) :
-               (qa->level <= qb->level);
-}
-
-void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
-{
-       QUEST_IDX *q_num = (QUEST_IDX *)u;
-       QUEST_IDX tmp;
-
-       /* Unused */
-       (void)v;
-
-       tmp = q_num[a];
-       q_num[a] = q_num[b];
-       q_num[b] = tmp;
-}
-
-
 /*
  * Print quest status of all active quests
  */
@@ -8041,9 +7859,7 @@ static void do_cmd_knowledge_quests(void)
 
        /* Sort by compete level */
        for (i = 1; i < max_q_idx; i++) quest_num[i] = i;
-       ang_sort_comp = ang_sort_comp_quest_num;
-       ang_sort_swap = ang_sort_swap_quest_num;
-       ang_sort(quest_num, &dummy, max_q_idx);
+       ang_sort(quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
 
        /* Dump Quest Information */
        do_cmd_knowledge_quests_current(fff);
@@ -8060,8 +7876,6 @@ static void do_cmd_knowledge_quests(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("クエスト達成状況", "Quest status"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 
        /* Free Memory */
@@ -8082,7 +7896,7 @@ static void do_cmd_knowledge_home(void)
        GAME_TEXT o_name[MAX_NLEN];
        concptr         paren = ")";
 
-       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
@@ -8095,7 +7909,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)
@@ -8142,8 +7956,6 @@ static void do_cmd_knowledge_home(void)
 
        /* Display the file contents */
        show_file(TRUE, file_name, _("我が家のアイテム", "Home Inventory"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -8211,8 +8023,6 @@ static void do_cmd_knowledge_autopick(void)
        my_fclose(fff);
        /* Display the file contents */
        show_file(TRUE, file_name, _("自動拾い/破壊 設定リスト", "Auto-picker/Destroyer"), 0, 0);
-
-       /* Remove the file */
        fd_kill(file_name);
 }
 
@@ -8275,7 +8085,7 @@ void do_cmd_knowledge(void)
                        prt("(5) Display kill count", 10, 5);
                        if (!vanilla_town) prt("(6) Display wanted monsters", 11, 5);
                        prt("(7) Display current pets", 12, 5);
-                       prt("(8) Display home inventory", 13, 5);
+                       prt("(8) Display home p_ptr->inventory_list", 13, 5);
                        prt("(9) Display *identified* equip.", 14, 5);
                        prt("(0) Display terrain symbols.", 15, 5);
                }