OSDN Git Service

[Refactor] #37353 ang_sort_*() in cmd4.c to sort.c.
[hengband/hengband.git] / src / cmd4.c
index d6cd31c..d88ef23 100644 (file)
@@ -50,6 +50,7 @@
 #include "artifact.h"
 #include "avatar.h"
 #include "object-hook.h"
+#include "monster-status.h"
 
 
 /*
@@ -845,18 +846,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;
 }
 
 /*!
@@ -874,8 +875,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");
@@ -4181,7 +4180,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;
@@ -4472,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 */
@@ -4629,8 +4627,6 @@ void do_cmd_load_screen(void)
                        Term_draw(x, y, a, c);
                }
        }
-
-       /* Close it */
        my_fclose(fff);
 
        prt(_("ファイルに書き出された画面(記念撮影)をロードしました。", "Screen dump loaded."), 0, 0);
@@ -4812,8 +4808,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);
 }
 
@@ -4956,8 +4950,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) {
@@ -5116,8 +5108,6 @@ void do_cmd_save_screen(void)
 
                /* Skip a line */
                fprintf(fff, "\n");
-
-               /* Close it */
                my_fclose(fff);
 
                msg_print(_("画面(記念撮影)をファイルに書き出しました。", "Screen dump saved."));
@@ -5134,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"
  */
@@ -5283,8 +5189,6 @@ static void do_cmd_knowledge_artifacts(void)
                        {
                                object_type *o_ptr;
                                o_ptr = &current_floor_ptr->o_list[this_o_idx];
-
-                               /* Acquire next object */
                                next_o_idx = o_ptr->next_o_idx;
 
                                /* Ignore non-artifacts */
@@ -5373,8 +5277,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);
 }
 
@@ -5498,8 +5400,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);
 }
 
@@ -5555,8 +5455,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);
 }
 
@@ -5644,8 +5542,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);
 }
 
@@ -5692,8 +5588,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);
 }
 
@@ -5854,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))
@@ -5880,8 +5774,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);
 }
 
@@ -6040,8 +5932,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);
 }
 
@@ -7126,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 */
@@ -7535,9 +7420,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;
                        }
@@ -7552,8 +7437,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);
 }
 
@@ -7582,8 +7465,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);
 }
 
@@ -7626,8 +7507,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);
 }
 
@@ -7673,8 +7552,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);
 }
 
@@ -7988,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
  */
@@ -8061,8 +7909,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 */
@@ -8083,7 +7929,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);
@@ -8143,8 +7989,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);
 }
 
@@ -8212,8 +8056,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);
 }