OSDN Git Service

[Refactor] #37353 ang_sort_*() in cmd4.c to sort.c.
[hengband/hengband.git] / src / cmd4.c
index e0f7246..d88ef23 100644 (file)
@@ -50,6 +50,7 @@
 #include "artifact.h"
 #include "avatar.h"
 #include "object-hook.h"
+#include "monster-status.h"
 
 
 /*
@@ -4470,7 +4471,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 */
@@ -5124,90 +5124,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"
  */
@@ -5832,7 +5748,7 @@ static void do_cmd_knowledge_pets(void)
                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))
@@ -7100,13 +7016,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 */
@@ -7954,35 +7865,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
  */