OSDN Git Service

[Refactor] #38997 Added player_type* argument to sort.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 28 Jun 2020 02:54:52 +0000 (11:54 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 28 Jun 2020 02:54:57 +0000 (11:54 +0900)
15 files changed:
src/cmd-action/cmd-pet.c
src/cmd-io/cmd-lore.c
src/cmd-item/cmd-activate.c
src/io-dump/character-dump.c
src/io/save.c
src/io/targeting.c
src/knowledge/knowledge-items.c
src/knowledge/knowledge-monsters.c
src/knowledge/knowledge-quests.c
src/knowledge/knowledge-uniques.c
src/market/building-monster.c
src/room/rooms-pit-nest.c
src/util/sort.c
src/util/sort.h
src/wizard/wizard-spoiler.c

index 20dba92..785a1ec 100644 (file)
@@ -79,7 +79,7 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
                        who[max_pet++] = pet_ctr;
        }
 
-       ang_sort(who, &dummy_why, max_pet, ang_sort_comp_pet_dismiss, ang_sort_swap_hook);
+       ang_sort(creature_ptr, who, &dummy_why, max_pet, ang_sort_comp_pet_dismiss, ang_sort_swap_hook);
 
        /* Process the monsters (backwards) */
        for (i = 0; i < max_pet; i++)
index 50b2135..c459bd2 100644 (file)
@@ -147,7 +147,7 @@ void do_cmd_query_symbol(player_type *creature_ptr)
     query = inkey();
     prt(buf, 0, 0);
     why = 2;
-    ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+    ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
     if (query == 'k') {
         why = 4;
         query = 'y';
@@ -159,7 +159,7 @@ void do_cmd_query_symbol(player_type *creature_ptr)
     }
 
     if (why == 4) {
-        ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+        ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
     }
 
     i = n - 1;
index 3e7586d..78a67c7 100644 (file)
@@ -208,7 +208,7 @@ void exe_activate(player_type *user_ptr, INVENTORY_IDX item)
                                        who[max_pet++] = pet_ctr;
                        }
 
-                       ang_sort(who, &dummy_why, max_pet, ang_sort_comp_pet, ang_sort_swap_hook);
+                       ang_sort(user_ptr, who, &dummy_why, max_pet, ang_sort_comp_pet, ang_sort_swap_hook);
 
                        /* Process the monsters (backwards) */
                        for (i = 0; i < max_pet; i++)
index a4b95a6..dbbc195 100644 (file)
@@ -104,7 +104,7 @@ static void dump_aux_quest(player_type *creature_ptr, FILE *fff)
        for (QUEST_IDX i = 1; i < max_q_idx; i++)
                quest_num[i] = i;
        int dummy;
-       ang_sort(quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
+       ang_sort(creature_ptr, quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
 
        fputc('\n', fff);
        do_cmd_knowledge_quests_completed(creature_ptr, fff, quest_num);
@@ -288,7 +288,7 @@ static void dump_aux_arena(player_type *creature_ptr, FILE *fff)
  * @param fff ファイルポインタ
  * @return なし
  */
-static void dump_aux_monsters(FILE *fff)
+static void dump_aux_monsters(player_type *creature_ptr, FILE *fff)
 {
        fprintf(fff, _("\n  [倒したモンスター]\n\n", "\n  [Defeated Monsters]\n\n"));
 
@@ -354,7 +354,7 @@ static void dump_aux_monsters(FILE *fff)
 #endif
 
        /* Sort the array by dungeon depth of monsters */
-       ang_sort(who, &why, uniq_total, ang_sort_comp_hook, ang_sort_swap_hook);
+        ang_sort(creature_ptr, who, &why, uniq_total, ang_sort_comp_hook, ang_sort_swap_hook);
        fprintf(fff, _("\n《上位%ld体のユニーク・モンスター》\n", "\n< Unique monsters top %ld >\n"), MIN(uniq_total, 10));
 
        for (IDX k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
@@ -577,7 +577,7 @@ void make_character_dump(player_type *creature_ptr, FILE *fff, void(*update_play
        dump_aux_recall(fff);
        dump_aux_quest(creature_ptr, fff);
        dump_aux_arena(creature_ptr, fff);
-       dump_aux_monsters(fff);
+       dump_aux_monsters(creature_ptr, fff);
        dump_aux_virtues(creature_ptr, fff);
        dump_aux_race_history(creature_ptr, fff);
        dump_aux_realm_history(creature_ptr, fff);
index e0051c3..61b0101 100644 (file)
@@ -954,7 +954,7 @@ static void wr_saved_floor(player_type *player_ptr, saved_floor_type *sf_ptr)
 
        /* Sort by occurrence */
        int dummy_why;
-       ang_sort(templates, &dummy_why, num_temp, ang_sort_comp_cave_temp, ang_sort_swap_cave_temp);
+       ang_sort(player_ptr, templates, &dummy_why, num_temp, ang_sort_comp_cave_temp, ang_sort_swap_cave_temp);
 
        /*** Dump templates ***/
 
index 82f270c..7ab8483 100644 (file)
@@ -439,11 +439,11 @@ static void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
        /* Set the sort hooks */
        if (mode & (TARGET_KILL))
        {
-               ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
+               ang_sort(creature_ptr, tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
        }
        else
        {
-               ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
+               ang_sort(creature_ptr, tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
        }
 
        if (creature_ptr->riding == 0 || !target_pet || (tmp_pos.n <= 1) || !(mode & (TARGET_KILL)))
@@ -1969,7 +1969,7 @@ static void tgt_pt_prepare(player_type *creature_ptr)
                }
        }
 
-       ang_sort(tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
+       ang_sort(creature_ptr, tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
 }
 
 
index ab00669..1efe11e 100644 (file)
@@ -94,7 +94,7 @@ void do_cmd_knowledge_artifacts(player_type *player_ptr)
        }
 
        u16b why = 3;
-       ang_sort(who, &why, n, ang_sort_art_comp, ang_sort_art_swap);
+       ang_sort(player_ptr, who, &why, n, ang_sort_art_comp, ang_sort_art_swap);
        for (ARTIFACT_IDX k = 0; k < n; k++)
        {
                artifact_type *a_ptr = &a_info[who[k]];
index ff6add5..8a4c6c3 100644 (file)
@@ -100,7 +100,7 @@ static IDX collect_monsters(player_type *creature_ptr, IDX grp_cur, IDX mon_idx[
 
        mon_idx[mon_cnt] = -1;
        int dummy_why;
-       ang_sort(mon_idx, &dummy_why, mon_cnt, ang_sort_comp_monster_level, ang_sort_swap_hook);
+       ang_sort(creature_ptr, mon_idx, &dummy_why, mon_cnt, ang_sort_comp_monster_level, ang_sort_swap_hook);
        return mon_cnt;
 }
 
@@ -205,7 +205,7 @@ void do_cmd_knowledge_kill_count(player_type *creature_ptr)
        }
 
        u16b why = 2;
-       ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+       ang_sort(creature_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
        for (int k = 0; k < n; k++)
        {
                monster_race *r_ptr = &r_info[who[k]];
index 3c2937d..9a48387 100644 (file)
@@ -338,7 +338,7 @@ void do_cmd_knowledge_quests(player_type *creature_ptr)
                quest_num[i] = i;
 
        int dummy;
-       ang_sort(quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
+       ang_sort(creature_ptr, quest_num, &dummy, max_q_idx, ang_sort_comp_quest_num, ang_sort_swap_quest_num);
 
        do_cmd_knowledge_quests_current(creature_ptr, fff);
        fputc('\n', fff);
index 57545e1..0a932f5 100644 (file)
@@ -153,7 +153,7 @@ void do_cmd_knowledge_uniques(player_type *creature_ptr, bool is_alive)
         unique_list_ptr->who[unique_list_ptr->n++] = i;
     }
 
-    ang_sort(unique_list_ptr->who, &unique_list_ptr->why, unique_list_ptr->n, ang_sort_comp_hook, ang_sort_swap_hook);
+    ang_sort(creature_ptr, unique_list_ptr->who, &unique_list_ptr->why, unique_list_ptr->n, ang_sort_comp_hook, ang_sort_swap_hook);
     display_uniques(unique_list_ptr, fff);
     C_KILL(unique_list_ptr->who, max_r_idx, s16b);
     angband_fclose(fff);
index 2216b92..11b419c 100644 (file)
@@ -149,7 +149,7 @@ bool research_mon(player_type *player_ptr)
     char query = 'y';
 
     if (why) {
-        ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+        ang_sort(player_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
     }
 
     if (old_sym == sym && old_i < n)
index 1399f0d..0bb2ec3 100644 (file)
@@ -140,18 +140,19 @@ static concptr pit_subtype_string(int type, bool nest)
 *  @param b 比較対象参照ID2
 *  TODO: to sort.c
 */
-static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
+static bool ang_sort_comp_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
-       nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
+    /* Unused */
+    (void)player_ptr;
+    (void)v;
+
+    nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
        MONSTER_IDX w1 = nest_mon_info[a].r_idx;
        MONSTER_IDX w2 = nest_mon_info[b].r_idx;
        monster_race *r1_ptr = &r_info[w1];
        monster_race *r2_ptr = &r_info[w2];
        int z1, z2;
 
-       /* Unused */
-       (void)v;
-
        /* Extract used info */
        z1 = nest_mon_info[a].used;
        z2 = nest_mon_info[b].used;
@@ -182,13 +183,14 @@ static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
 * @param b スワップ対象参照ID2
 * TODO: to sort.c
 */
-static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
+static void ang_sort_swap_nest_mon_info(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
-       nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
-       nest_mon_info_type holder;
+    /* Unused */
+    (void)player_ptr;
+    (void)v;
 
-       /* Unused */
-       (void)v;
+    nest_mon_info_type *nest_mon_info = (nest_mon_info_type *)u;
+       nest_mon_info_type holder;
 
        /* Swap */
        holder = nest_mon_info[a];
@@ -371,7 +373,7 @@ bool build_type5(player_type *player_ptr)
 
        if (cheat_room)
        {
-               ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
+               ang_sort(player_ptr, nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
 
                /* Dump the entries (prevent multi-printing) */
                for (i = 0; i < NUM_NEST_MON_TYPE; i++)
@@ -382,6 +384,7 @@ bool build_type5(player_type *player_ptr)
                                if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
                                if (!nest_mon_info[i + 1].used) break;
                        }
+
                        msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
                }
        }
index 9c6dfe7..f68d444 100644 (file)
@@ -18,7 +18,8 @@
  * @param ang_sort_swap スワップ用の関数ポインタ
  * @return なし
  */
-static void exe_ang_sort(vptr u, vptr v, int p, int q, bool (*ang_sort_comp)(vptr, vptr, int, int), void (*ang_sort_swap)(vptr, vptr, int, int))
+static void exe_ang_sort(player_type *player_ptr, vptr u, vptr v, int p, int q, bool (*ang_sort_comp)(player_type *, vptr, vptr, int, int),
+    void (*ang_sort_swap)(player_type *, vptr, vptr, int, int))
 {
     if (p >= q)
         return;
@@ -28,26 +29,26 @@ static void exe_ang_sort(vptr u, vptr v, int p, int q, bool (*ang_sort_comp)(vpt
     int b = q;
     while (TRUE) {
         /* Slide i2 */
-        while (!(*ang_sort_comp)(u, v, b, z))
+        while (!(*ang_sort_comp)(player_ptr, u, v, b, z))
             b--;
 
         /* Slide i1 */
-        while (!(*ang_sort_comp)(u, v, z, a))
+        while (!(*ang_sort_comp)(player_ptr, u, v, z, a))
             a++;
 
         if (a >= b)
             break;
 
-        (*ang_sort_swap)(u, v, a, b);
+        (*ang_sort_swap)(player_ptr, u, v, a, b);
 
         a++, b--;
     }
 
     /* Recurse left side */
-    exe_ang_sort(u, v, p, b, ang_sort_comp, ang_sort_swap);
+    exe_ang_sort(player_ptr, u, v, p, b, ang_sort_comp, ang_sort_swap);
 
     /* Recurse right side */
-    exe_ang_sort(u, v, b + 1, q, ang_sort_comp, ang_sort_swap);
+    exe_ang_sort(player_ptr, u, v, b + 1, q, ang_sort_comp, ang_sort_swap);
 }
 
 /*
@@ -60,9 +61,10 @@ static void exe_ang_sort(vptr u, vptr v, int p, int q, bool (*ang_sort_comp)(vpt
  * @param ang_sort_swap スワップ用の関数ポインタ
  * @return なし
  */
-void ang_sort(vptr u, vptr v, int n, bool (*ang_sort_comp)(vptr, vptr, int, int), void (*ang_sort_swap)(vptr, vptr, int, int))
+void ang_sort(player_type *player_ptr, vptr u, vptr v, int n, bool (*ang_sort_comp)(player_type *, vptr, vptr, int, int),
+    void (*ang_sort_swap)(player_type *, vptr, vptr, int, int))
 {
-    exe_ang_sort(u, v, 0, n - 1, ang_sort_comp, ang_sort_swap);
+    exe_ang_sort(player_ptr, u, v, 0, n - 1, ang_sort_comp, ang_sort_swap);
 }
 
 /*
@@ -71,17 +73,17 @@ void ang_sort(vptr u, vptr v, int n, bool (*ang_sort_comp)(vptr, vptr, int, int)
  * We use "u" and "v" to point to arrays of "x" and "y" positions,
  * and sort the arrays by double-distance to the player.
  */
-bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_distance(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     POSITION *x = (POSITION *)(u);
     POSITION *y = (POSITION *)(v);
 
     /* Absolute distance components */
     POSITION kx = x[a];
-    kx -= p_ptr->x;
+    kx -= player_ptr->x;
     kx = ABS(kx);
     POSITION ky = y[a];
-    ky -= p_ptr->y;
+    ky -= player_ptr->y;
     ky = ABS(ky);
 
     /* Approximate Double Distance to the first point */
@@ -89,10 +91,10 @@ bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
 
     /* Absolute distance components */
     kx = x[b];
-    kx -= p_ptr->x;
+    kx -= player_ptr->x;
     kx = ABS(kx);
     ky = y[b];
-    ky -= p_ptr->y;
+    ky -= player_ptr->y;
     ky = ABS(ky);
 
     /* Approximate Double Distance to the first point */
@@ -108,21 +110,21 @@ bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
  * We use "u" and "v" to point to arrays of "x" and "y" positions,
  * and sort the arrays by level of monster
  */
-bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_importance(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     POSITION *x = (POSITION *)(u);
     POSITION *y = (POSITION *)(v);
-    grid_type *ca_ptr = &p_ptr->current_floor_ptr->grid_array[y[a]][x[a]];
-    grid_type *cb_ptr = &p_ptr->current_floor_ptr->grid_array[y[b]][x[b]];
-    monster_type *ma_ptr = &p_ptr->current_floor_ptr->m_list[ca_ptr->m_idx];
-    monster_type *mb_ptr = &p_ptr->current_floor_ptr->m_list[cb_ptr->m_idx];
+    grid_type *ca_ptr = &player_ptr->current_floor_ptr->grid_array[y[a]][x[a]];
+    grid_type *cb_ptr = &player_ptr->current_floor_ptr->grid_array[y[b]][x[b]];
+    monster_type *ma_ptr = &player_ptr->current_floor_ptr->m_list[ca_ptr->m_idx];
+    monster_type *mb_ptr = &player_ptr->current_floor_ptr->m_list[cb_ptr->m_idx];
     monster_race *ap_ra_ptr, *ap_rb_ptr;
 
     /* The player grid */
-    if (y[a] == p_ptr->y && x[a] == p_ptr->x)
+    if (y[a] == player_ptr->y && x[a] == player_ptr->x)
         return TRUE;
 
-    if (y[b] == p_ptr->y && x[b] == p_ptr->x)
+    if (y[b] == player_ptr->y && x[b] == player_ptr->x)
         return FALSE;
 
     /* Extract monster race */
@@ -178,10 +180,10 @@ bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
     }
 
     /* An object get higher priority */
-    if (p_ptr->current_floor_ptr->grid_array[y[a]][x[a]].o_idx && !p_ptr->current_floor_ptr->grid_array[y[b]][x[b]].o_idx)
+    if (player_ptr->current_floor_ptr->grid_array[y[a]][x[a]].o_idx && !player_ptr->current_floor_ptr->grid_array[y[b]][x[b]].o_idx)
         return TRUE;
 
-    if (!p_ptr->current_floor_ptr->grid_array[y[a]][x[a]].o_idx && p_ptr->current_floor_ptr->grid_array[y[b]][x[b]].o_idx)
+    if (!player_ptr->current_floor_ptr->grid_array[y[a]][x[a]].o_idx && player_ptr->current_floor_ptr->grid_array[y[b]][x[b]].o_idx)
         return FALSE;
 
     /* Priority from the terrain */
@@ -192,7 +194,7 @@ bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
         return FALSE;
 
     /* If all conditions are same, compare distance */
-    return ang_sort_comp_distance(u, v, a, b);
+    return ang_sort_comp_distance(player_ptr, u, v, a, b);
 }
 
 /*
@@ -201,8 +203,11 @@ bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
  * We use "u" and "v" to point to arrays of "x" and "y" positions,
  * and sort the arrays by distance to the player.
  */
-void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
+void ang_sort_swap_distance(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
+    /* Unused */
+    (void)player_ptr;
+
     POSITION *x = (POSITION *)(u);
     POSITION *y = (POSITION *)(v);
 
@@ -221,8 +226,11 @@ void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
  * We use "u" to point to array of monster indexes,
  * and "v" to select the type of sorting to perform on "u".
  */
-bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
+bool ang_sort_art_comp(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
+    /* Unused */
+    (void)player_ptr;
+
     u16b *who = (u16b *)(u);
     u16b *why = (u16b *)(v);
 
@@ -283,9 +291,10 @@ bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
  * We use "u" to point to array of monster indexes,
  * and "v" to select the type of sorting to perform.
  */
-void ang_sort_art_swap(vptr u, vptr v, int a, int b)
+void ang_sort_art_swap(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     u16b *who = (u16b *)(u);
@@ -294,9 +303,10 @@ void ang_sort_art_swap(vptr u, vptr v, int a, int b)
     who[b] = holder;
 }
 
-bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_quest_num(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     QUEST_IDX *q_num = (QUEST_IDX *)u;
@@ -305,9 +315,10 @@ bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
     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)
+void ang_sort_swap_quest_num(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     QUEST_IDX *q_num = (QUEST_IDX *)u;
@@ -324,7 +335,7 @@ void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
  * @param b 所持品ID2
  * @return 1の方が大であればTRUE
  */
-bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_pet(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
     (void)v;
@@ -334,8 +345,8 @@ bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
     int w1 = who[a];
     int w2 = who[b];
 
-    monster_type *m_ptr1 = &p_ptr->current_floor_ptr->m_list[w1];
-    monster_type *m_ptr2 = &p_ptr->current_floor_ptr->m_list[w2];
+    monster_type *m_ptr1 = &player_ptr->current_floor_ptr->m_list[w1];
+    monster_type *m_ptr2 = &player_ptr->current_floor_ptr->m_list[w2];
     monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
     monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
 
@@ -377,8 +388,11 @@ bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
  * We use "u" to point to array of monster indexes,
  * and "v" to select the type of sorting to perform on "u".
  */
-bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_hook(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
+    /* Unused */
+    (void)player_ptr;
+
     u16b *who = (u16b *)(u);
     u16b *why = (u16b *)(v);
 
@@ -455,9 +469,10 @@ bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
  * We use "u" to point to array of monster indexes,
  * and "v" to select the type of sorting to perform.
  */
-void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
+void ang_sort_swap_hook(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     u16b *who = (u16b *)(u);
@@ -471,9 +486,10 @@ void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
 /*
  * hook function to sort monsters by level
  */
-bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_monster_level(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     u16b *who = (u16b *)(u);
@@ -507,7 +523,7 @@ bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
  * @param b 比較対象のモンスターID2
  * @return 2番目が大ならばTRUEを返す
  */
-bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_pet_dismiss(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
     (void)v;
@@ -517,15 +533,15 @@ bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
     int w1 = who[a];
     int w2 = who[b];
 
-    monster_type *m_ptr1 = &p_ptr->current_floor_ptr->m_list[w1];
-    monster_type *m_ptr2 = &p_ptr->current_floor_ptr->m_list[w2];
+    monster_type *m_ptr1 = &player_ptr->current_floor_ptr->m_list[w1];
+    monster_type *m_ptr2 = &player_ptr->current_floor_ptr->m_list[w2];
     monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
     monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
 
-    if (w1 == p_ptr->riding)
+    if (w1 == player_ptr->riding)
         return TRUE;
 
-    if (w2 == p_ptr->riding)
+    if (w2 == player_ptr->riding)
         return FALSE;
 
     if (m_ptr1->nickname && !m_ptr2->nickname)
@@ -569,9 +585,10 @@ bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
  * @param b スワップするモンスター種族のID2
  * @return aの方が大きければtrue
  */
-bool ang_sort_comp_cave_temp(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_cave_temp(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     grid_template_type *who = (grid_template_type *)(u);
@@ -590,9 +607,10 @@ bool ang_sort_comp_cave_temp(vptr u, vptr v, int a, int b)
  * @param b スワップするモンスター種族のID2
  * @return なし
  */
-void ang_sort_swap_cave_temp(vptr u, vptr v, int a, int b)
+void ang_sort_swap_cave_temp(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     grid_template_type *who = (grid_template_type *)(u);
@@ -612,9 +630,10 @@ void ang_sort_swap_cave_temp(vptr u, vptr v, int a, int b)
  * @param b 比較したいモンスター種族ID2
  * @return 2が大きければTRUEを返す
  */
-bool ang_sort_comp_evol_tree(vptr u, vptr v, int a, int b)
+bool ang_sort_comp_evol_tree(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     int **evol_tree = (int **)u;
@@ -658,9 +677,10 @@ bool ang_sort_comp_evol_tree(vptr u, vptr v, int a, int b)
  * @param b スワップしたい木構造2
  * @return 2が大きければTRUEを返す
  */
-void ang_sort_swap_evol_tree(vptr u, vptr v, int a, int b)
+void ang_sort_swap_evol_tree(player_type *player_ptr, vptr u, vptr v, int a, int b)
 {
     /* Unused */
+    (void)player_ptr;
     (void)v;
 
     int **evol_tree = (int **)u;
index fb83aa2..2ac21ad 100644 (file)
@@ -2,28 +2,29 @@
 
 #include "system/angband.h"
 
-void ang_sort(vptr u, vptr v, int n, bool(*ang_sort_comp)(vptr, vptr, int, int), void(*ang_sort_swap)(vptr, vptr, int, int));
+void ang_sort(player_type *player_ptr, vptr u, vptr v, int n, bool (*ang_sort_comp)(player_type *, vptr, vptr, int, int),
+    void (*ang_sort_swap)(player_type *, vptr, vptr, int, int));
 
-bool ang_sort_comp_distance(vptr u, vptr v, int a, int b);
-bool ang_sort_comp_importance(vptr u, vptr v, int a, int b);
-void ang_sort_swap_distance(vptr u, vptr v, int a, int b);
+bool ang_sort_comp_distance(player_type *player_ptr, vptr u, vptr v, int a, int b);
+bool ang_sort_comp_importance(player_type *player_ptr, vptr u, vptr v, int a, int b);
+void ang_sort_swap_distance(player_type *player_ptr, vptr u, vptr v, int a, int b);
 
-bool ang_sort_art_comp(vptr u, vptr v, int a, int b);
-void ang_sort_art_swap(vptr u, vptr v, int a, int b);
+bool ang_sort_art_comp(player_type *player_ptr, vptr u, vptr v, int a, int b);
+void ang_sort_art_swap(player_type *player_ptr, vptr u, vptr v, int a, int b);
 
-bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b);
-void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b);
+bool ang_sort_comp_quest_num(player_type *player_ptr, vptr u, vptr v, int a, int b);
+void ang_sort_swap_quest_num(player_type *player_ptr, vptr u, vptr v, int a, int b);
 
-bool ang_sort_comp_pet(vptr u, vptr v, int a, int b);
+bool ang_sort_comp_pet(player_type *player_ptr, vptr u, vptr v, int a, int b);
 
-bool ang_sort_comp_hook(vptr u, vptr v, int a, int b);
-void ang_sort_swap_hook(vptr u, vptr v, int a, int b);
+bool ang_sort_comp_hook(player_type *player_ptr, vptr u, vptr v, int a, int b);
+void ang_sort_swap_hook(player_type *player_ptr, vptr u, vptr v, int a, int b);
 
-bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b);
-bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b);
+bool ang_sort_comp_monster_level(player_type *player_ptr, vptr u, vptr v, int a, int b);
+bool ang_sort_comp_pet_dismiss(player_type *player_ptr, vptr u, vptr v, int a, int b);
 
-bool ang_sort_comp_cave_temp(vptr u, vptr v, int a, int b);
-void ang_sort_swap_cave_temp(vptr u, vptr v, int a, int b);
+bool ang_sort_comp_cave_temp(player_type *player_ptr, vptr u, vptr v, int a, int b);
+void ang_sort_swap_cave_temp(player_type *player_ptr, vptr u, vptr v, int a, int b);
 
-bool ang_sort_comp_evol_tree(vptr u, vptr v, int a, int b);
-void ang_sort_swap_evol_tree(vptr u, vptr v, int a, int b);
+bool ang_sort_comp_evol_tree(player_type *player_ptr, vptr u, vptr v, int a, int b);
+void ang_sort_swap_evol_tree(player_type *player_ptr, vptr u, vptr v, int a, int b);
index 65f4c7c..209bf47 100644 (file)
@@ -828,7 +828,7 @@ static void spoil_artifact(player_type *player_ptr, concptr fname)
  * @param fname 生成ファイル名
  * @return なし
  */
-static void spoil_mon_desc(concptr fname)
+static void spoil_mon_desc(player_type *player_ptr, concptr fname)
 {
     int i, n = 0;
     u16b why = 2;
@@ -859,7 +859,7 @@ static void spoil_mon_desc(concptr fname)
             who[n++] = (s16b)i;
     }
 
-    ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+    ang_sort(player_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
     for (i = 0; i < n; i++) {
         monster_race *r_ptr = &r_info[who[i]];
         concptr name = (r_name + r_ptr->name);
@@ -1103,7 +1103,7 @@ static void spoil_mon_info(player_type *player_ptr, concptr fname)
             who[n++] = (s16b)i;
     }
 
-    ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+    ang_sort(player_ptr, who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
     for (l = 0; l < n; l++) {
         monster_race *r_ptr = &r_info[who[l]];
         flags1 = r_ptr->flags1;
@@ -1211,7 +1211,7 @@ static bool is_partial_tree(int *tree, int *partial_tree)
  * @param fname 出力ファイル名
  * @return なし
  */
-static void spoil_mon_evol(concptr fname)
+static void spoil_mon_evol(player_type *player_ptr, concptr fname)
 {
     char buf[1024];
     monster_race *r_ptr;
@@ -1264,7 +1264,7 @@ static void spoil_mon_evol(concptr fname)
         }
     }
 
-    ang_sort(evol_tree, NULL, max_r_idx, ang_sort_comp_evol_tree, ang_sort_swap_evol_tree);
+    ang_sort(player_ptr, evol_tree, NULL, max_r_idx, ang_sort_comp_evol_tree, ang_sort_swap_evol_tree);
     for (i = 0; i < max_r_idx; i++) {
         r_idx = evol_tree[i][0];
         if (!r_idx)
@@ -1320,13 +1320,13 @@ void do_cmd_spoilers(player_type *player_ptr)
             spoil_artifact(player_ptr, "artifact.txt");
             break;
         case '3':
-            spoil_mon_desc("mon-desc.txt");
+            spoil_mon_desc(player_ptr, "mon-desc.txt");
             break;
         case '4':
             spoil_mon_info(player_ptr, "mon-info.txt");
             break;
         case '5':
-            spoil_mon_evol("mon-evol.txt");
+            spoil_mon_evol(player_ptr, "mon-evol.txt");
             break;
         default:
             bell();