OSDN Git Service

[Refactor] #38997 set_blind() に player_type * 引数を追加. hit_trap_set_abnormal_status_p...
[hengband/hengband.git] / src / wizard1.c
index a720b38..bd582b5 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+#include "term.h"
+
+#include "core.h"
+#include "artifact.h"
 #include "sort.h"
 #include "store.h"
+#include "monster.h"
+#include "object-flavor.h"
+#include "object-hook.h"
+#include "object-ego.h"
+#include "objectkind.h"
+#include "floor-town.h"
+#include "files.h"
 
 
 #ifdef ALLOW_SPOILERS
@@ -209,7 +221,6 @@ static void kind_info(char *buf, char *dam, char *wgt, char *chance, DEPTH *lev,
        (*lev) = k_info[q_ptr->k_idx].level;
        (*val) = object_value(q_ptr);
 
-       /* Hack */
        if (!buf || !dam || !chance || !wgt) return;
 
        /* Description (too brief) */
@@ -299,8 +310,6 @@ static void spoil_obj_desc(concptr fname)
        char chance[80];
        char dam[80];
 
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
@@ -1559,7 +1568,6 @@ static bool make_fake_artifact(object_type *o_ptr, IDX name1)
 
        if (!i) return (FALSE);
 
-       /* Create the artifact */
        object_prep(o_ptr, i);
 
        /* Save the name */
@@ -1595,8 +1603,6 @@ static void spoil_artifact(concptr fname)
        object_type *q_ptr;
        obj_desc_list artifact;
        char buf[1024];
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
@@ -1679,8 +1685,6 @@ static void spoil_mon_desc(concptr fname)
        char ac[80];
        char hp[80];
        char exp[80];
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
@@ -1719,12 +1723,8 @@ static void spoil_mon_desc(concptr fname)
                if (r_ptr->name) who[n++] = (s16b)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 again */
        for (i = 0; i < n; i++)
@@ -1750,14 +1750,12 @@ static void spoil_mon_desc(concptr fname)
                        sprintf(nam, _("    %s", "The %s"), name);
                }
 
-
                /* Level */
                sprintf(lev, "%d", (int)r_ptr->level);
 
                /* Rarity */
                sprintf(rar, "%d", (int)r_ptr->rarity);
 
-               /* Speed */
                if (r_ptr->speed >= 110)
                {
                        sprintf(spd, "+%d", (r_ptr->speed - 110));
@@ -2019,8 +2017,6 @@ static void spoil_mon_info(concptr fname)
 
        u16b why = 2;
        MONRACE_IDX *who;
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
@@ -2055,13 +2051,7 @@ static void spoil_mon_info(concptr fname)
                if (r_ptr->name) who[n++] = (s16b)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);
 
        /*
         * List all monsters in order
@@ -2119,7 +2109,6 @@ static void spoil_mon_info(concptr fname)
                sprintf(buf, "Rar:%d  ", r_ptr->rarity);
                spoil_out(buf);
 
-               /* Speed */
                if (r_ptr->speed >= 110)
                {
                        sprintf(buf, "Spd:+%d  ", (r_ptr->speed - 110));
@@ -2222,67 +2211,6 @@ static bool is_partial_tree(int *tree, int *partial_tree)
        return FALSE;
 }
 
-
-/*!
- * @brief 進化ツリーをソートするためモンスター種族の判定関数 / 
- * Sorting hook -- Comp function
- * @param u 進化木構造データ
- * @param v 未使用
- * @param a 比較したいモンスター種族ID1
- * @param b 比較したいモンスター種族ID2
- * @return 2が大きければTRUEを返す
- */
-static bool ang_sort_comp_evol_tree(vptr u, vptr v, int a, int b)
-{
-       int **evol_tree = (int **)u;
-
-       int w1 = evol_tree[a][0];
-       int w2 = evol_tree[b][0];
-       monster_race *r1_ptr = &r_info[w1];
-       monster_race *r2_ptr = &r_info[w2];
-
-       /* Unused */
-       (void)v;
-
-       /* Used tree first */
-       if (w1 && !w2) return TRUE;
-       if (!w1 && w2) return FALSE;
-
-       /* Sort by monster level */
-       if (r1_ptr->level < r2_ptr->level) return TRUE;
-       if (r1_ptr->level > r2_ptr->level) return FALSE;
-
-       /* Sort by monster experience */
-       if (r1_ptr->mexp < r2_ptr->mexp) return TRUE;
-       if (r1_ptr->mexp > r2_ptr->mexp) return FALSE;
-
-       /* Compare indexes */
-       return w1 <= w2;
-}
-
-/*!
- * @brief 進化ツリーをソートするため木構造のスワップ関数 / 
- * Sorting hook -- Swap function
- * @param u 進化木構造データ
- * @param v 未使用
- * @param a スワップしたい木構造1
- * @param b スワップしたい木構造2
- * @return 2が大きければTRUEを返す
- */
-static void ang_sort_swap_evol_tree(vptr u, vptr v, int a, int b)
-{
-       int **evol_tree = (int **)u;
-       int *holder;
-
-       /* Unused */
-       (void)v;
-
-       /* Swap */
-       holder = evol_tree[a];
-       evol_tree[a] = evol_tree[b];
-       evol_tree[b] = holder;
-}
-
 /*!
  * @brief 進化ツリーをスポイラー出力するメインルーチン / 
  * Print monsters' evolution information to file
@@ -2295,8 +2223,6 @@ static void spoil_mon_evol(concptr fname)
        monster_race *r_ptr;
        int **evol_tree, i, j, n, r_idx;
        int *evol_tree_zero; /* For C_KILL() */
-
-       /* Build the filename */
        path_build(buf, sizeof buf, ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
@@ -2368,13 +2294,7 @@ static void spoil_mon_evol(concptr fname)
        }
 
        /* Step 3: Sort the evolution trees */
-
-       /* Select the sort method */
-       ang_sort_comp = ang_sort_comp_evol_tree;
-       ang_sort_swap = ang_sort_swap_evol_tree;
-
-       /* Sort the array */
-       ang_sort(evol_tree, NULL, max_r_idx);
+       ang_sort(evol_tree, NULL, max_r_idx, ang_sort_comp_evol_tree, ang_sort_swap_evol_tree);
 
        /* Step 4: Print the evolution trees */
        for (i = 0; i < max_r_idx; i++)
@@ -2417,12 +2337,6 @@ static void spoil_mon_evol(concptr fname)
 }
 
 
-
-/*
- * Forward declare
- */
-extern void do_cmd_spoilers(void);
-
 /*!
  * @brief スポイラー出力を行うコマンドのメインルーチン / 
  * Create Spoiler files -BEN-
@@ -2605,8 +2519,6 @@ void spoil_random_artifact(concptr fname)
        object_type *q_ptr;
 
        char buf[1024];
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
@@ -2631,14 +2543,14 @@ void spoil_random_artifact(concptr fname)
                /* random artifacts wielding */
                for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
                {
-                       q_ptr = &inventory[i];
+                       q_ptr = &p_ptr->inventory_list[i];
                        spoil_random_artifact_aux(q_ptr, j);
                }
 
-               /* random artifacts in inventory */
+               /* random artifacts in p_ptr->inventory_list */
                for (i = 0; i < INVEN_PACK; i++)
                {
-                       q_ptr = &inventory[i];
+                       q_ptr = &p_ptr->inventory_list[i];
                        spoil_random_artifact_aux(q_ptr, j);
                }