OSDN Git Service

[Refactor] #37353 ang_sort_*() in cmd4.c to sort.c.
authordeskull <deskull@users.sourceforge.jp>
Tue, 19 Mar 2019 13:51:47 +0000 (22:51 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Tue, 19 Mar 2019 14:28:36 +0000 (23:28 +0900)
src/cmd4.c
src/externs.h
src/sort.c
src/sort.h
src/xtra2.c

index b159da2..d88ef23 100644 (file)
@@ -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"
  */
@@ -7949,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
  */
index 159a1b8..b9230b1 100644 (file)
@@ -539,8 +539,6 @@ extern void do_cmd_save_screen_html_aux(char *filename, int message);
 extern void do_cmd_save_screen(void);
 extern void do_cmd_knowledge_quests_completed(FILE *fff, QUEST_IDX quest_num[]);
 extern void do_cmd_knowledge_quests_failed(FILE *fff, QUEST_IDX quest_num[]);
-extern bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b);
-extern void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b);
 extern void do_cmd_knowledge(void);
 extern void plural_aux(char * Name);
 extern void do_cmd_checkquest(void);
index 3e83920..ac7d304 100644 (file)
@@ -191,3 +191,114 @@ void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
        y[a] = y[b];
        y[b] = temp;
 }
+
+
+
+/*
+ * 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".
+ */
+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.
+ */
+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;
+}
+
+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;
+}
+
index 4834a8c..dbd9bfd 100644 (file)
@@ -4,3 +4,9 @@ extern void ang_sort(vptr u, vptr v, int n);
 extern bool ang_sort_comp_distance(vptr u, vptr v, int a, int b);
 extern bool ang_sort_comp_importance(vptr u, vptr v, int a, int b);
 extern void ang_sort_swap_distance(vptr u, vptr v, int a, int b);
+
+extern bool ang_sort_art_comp(vptr u, vptr v, int a, int b);
+extern void ang_sort_art_swap(vptr u, vptr v, int a, int b);
+
+extern bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b);
+extern void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b);
index bfa1166..637c8c4 100644 (file)
@@ -1937,7 +1937,6 @@ static bool tgt_pt_accept(POSITION y, POSITION x)
 
        if (p_ptr->image) return (FALSE);
 
-       /* Examine the grid */
        g_ptr = &current_floor_ptr->grid_array[y][x];
 
        /* Interesting memorized features */