OSDN Git Service

[Refactor] #37353 ペット処理を cmd4.c から cmd-pet.c/h へ分離。
[hengband/hengband.git] / src / cmd4.c
index 671af46..5c6fc97 100644 (file)
@@ -40,7 +40,7 @@
  */
 
 #include "angband.h"
-
+#include "cmd-pet.h"
 
 
 /*
@@ -2593,7 +2593,7 @@ static errr keymap_dump(cptr fname)
        char key[1024];
        char buf[1024];
 
-       int mode;
+       BIT_FLAGS mode;
 
        /* Roguelike */
        if (rogue_like_commands)
@@ -2671,7 +2671,7 @@ void do_cmd_macros(void)
 
        char buf[1024];
 
-       int mode;
+       BIT_FLAGS mode;
 
 
        /* Roguelike */
@@ -3151,7 +3151,7 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d
  */
 void do_cmd_visuals(void)
 {
-       char i;
+       int i;
        char tmp[160];
        char buf[1024];
        bool need_redraw = FALSE;
@@ -3392,7 +3392,7 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                monster_race *r_ptr = &r_info[r];
-                               char c;
+                               int c;
                                IDX t;
 
                                byte da = r_ptr->d_attr;
@@ -3484,7 +3484,7 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                object_kind *k_ptr = &k_info[k];
-                               char c;
+                               int c;
                                IDX t;
 
                                SYMBOL_COLOR da = k_ptr->d_attr;
@@ -3578,7 +3578,7 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                feature_type *f_ptr = &f_info[f];
-                               char c;
+                               int c;
                                IDX t;
 
                                byte da = f_ptr->d_attr[lighting_level];
@@ -5747,7 +5747,8 @@ static void do_cmd_knowledge_uniques(void)
  */
 static void do_cmd_knowledge_weapon_exp(void)
 {
-       int i, j, num, weapon_exp;
+       int i, num, weapon_exp;
+       KIND_OBJECT_IDX j;
 
        FILE *fff;
 
@@ -5806,7 +5807,8 @@ static void do_cmd_knowledge_weapon_exp(void)
  */
 static void do_cmd_knowledge_spell_exp(void)
 {
-       int i = 0, spell_exp, exp_level;
+       SPELL_IDX i = 0;
+       int spell_exp, exp_level;
 
        FILE *fff;
        const magic_type *s_ptr;
@@ -6177,7 +6179,7 @@ static void do_cmd_knowledge_kill_count(void)
                        }
                        else
                        {
-                               s16b This = r_ptr->r_pkills;
+                               MONSTER_NUMBER This = r_ptr->r_pkills;
 
                                if (This > 0)
                                {
@@ -6233,16 +6235,16 @@ static void do_cmd_knowledge_kill_count(void)
                }
                else
                {
-                       s16b This = r_ptr->r_pkills;
+                       MONSTER_NUMBER This = r_ptr->r_pkills;
 
                        if (This > 0)
                        {
 #ifdef JP
                                /* p,tは人と数える by ita */
                                if (my_strchr("pt", r_ptr->d_char))
-                                       fprintf(fff, "     %3d 人の %s\n", This, r_name + r_ptr->name);
+                                       fprintf(fff, "     %3d 人の %s\n", (int)This, r_name + r_ptr->name);
                                else
-                                       fprintf(fff, "     %3d 体の %s\n", This, r_name + r_ptr->name);
+                                       fprintf(fff, "     %3d 体の %s\n", (int)This, r_name + r_ptr->name);
 #else
                                if (This < 2)
                                {
@@ -6669,7 +6671,7 @@ static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
                byte attr;
 
                /* Get the race index */
-               IDX r_idx = mon_idx[mon_top + i] ;
+               MONRACE_IDX r_idx = mon_idx[mon_top + i] ;
 
                /* Access the race */
                monster_race *r_ptr = &r_info[r_idx];
@@ -6992,7 +6994,7 @@ static void display_object_list(int col, int row, int per_page, IDX object_idx[]
                object_kind *flavor_k_ptr;
 
                /* Get the object index */
-               int k_idx = object_idx[object_top + i];
+               KIND_OBJECT_IDX k_idx = object_idx[object_top + i];
 
                /* Access the object */
                object_kind *k_ptr = &k_info[k_idx];
@@ -7386,8 +7388,8 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX di
 /*
  * Display the features in a group.
  */
-static void display_feature_list(int col, int row, int per_page, IDX *feat_idx,
-       IDX feat_cur, IDX feat_top, bool visual_only, int lighting_level)
+static void display_feature_list(int col, int row, int per_page, FEAT_IDX *feat_idx,
+       FEAT_IDX feat_cur, FEAT_IDX feat_top, bool visual_only, int lighting_level)
 {
        int lit_col[F_LIT_MAX], i, j;
        int f_idx_col = use_bigtile ? 62 : 64;
@@ -7403,7 +7405,7 @@ static void display_feature_list(int col, int row, int per_page, IDX *feat_idx,
                byte attr;
 
                /* Get the index */
-               int f_idx = feat_idx[feat_top + i];
+               FEAT_IDX f_idx = feat_idx[feat_top + i];
 
                /* Access the index */
                feature_type *f_ptr = &f_info[f_idx];
@@ -8012,7 +8014,7 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
 
        fprintf(fff, _("《遂行中のクエスト》\n", "< Current Quest >\n"));
 
-       for (i = 1; i < max_quests; i++)
+       for (i = 1; i < max_q_idx; i++)
        {
                if ((quest[i].status == QUEST_STATUS_TAKEN) ||
                        ((quest[i].status == QUEST_STATUS_STAGE_COMPLETED) && (quest[i].type == QUEST_TYPE_TOWER)) ||
@@ -8057,11 +8059,11 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
                                                {
 #ifdef JP
                                                        sprintf(note," - %d 体の%sを倒す。(あと %d 体)",
-                                                               quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
+                                                               (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
 #else
                                                        plural_aux(name);
                                                        sprintf(note," - kill %d %s, have killed %d.",
-                                                               quest[i].max_num, name, quest[i].cur_num);
+                                                               (int)quest[i].max_num, name, (int)quest[i].cur_num);
 #endif
                                                }
                                                else
@@ -8089,10 +8091,10 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
                                        case QUEST_TYPE_KILL_NUMBER:
 #ifdef JP
                                                sprintf(note," - %d 体のモンスターを倒す。(あと %d 体)",
-                                                       quest[i].max_num, quest[i].max_num - quest[i].cur_num);
+                                                       (int)quest[i].max_num, (int)(quest[i].max_num - quest[i].cur_num));
 #else
                                                sprintf(note," - Kill %d monsters, have killed %d.",
-                                                       quest[i].max_num, quest[i].cur_num);
+                                                       (int)quest[i].max_num, (int)quest[i].cur_num);
 #endif
                                                break;
 
@@ -8141,13 +8143,13 @@ static void do_cmd_knowledge_quests_current(FILE *fff)
 #ifdef JP
                                                sprintf(rand_tmp_str,"  %s (%d 階) - %d 体の%sを倒す。(あと %d 体)\n",
                                                        quest[i].name, (int)quest[i].level,
-                                                       quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
+                                                       (int)quest[i].max_num, name, (int)(quest[i].max_num - quest[i].cur_num));
 #else
                                                plural_aux(name);
 
                                                sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
-                                                       quest[i].name, (idx)quest[i].level,
-                                                       quest[i].max_num, name, quest[i].cur_num);
+                                                       quest[i].name, (int)quest[i].level,
+                                                       (int)quest[i].max_num, name, (int)quest[i].cur_num);
 #endif
                                        }
                                        else
@@ -8240,7 +8242,7 @@ void do_cmd_knowledge_quests_completed(FILE *fff, IDX quest_num[])
        int total = 0;
 
        fprintf(fff, _("《達成したクエスト》\n", "< Completed Quest >\n"));
-       for (i = 1; i < max_quests; i++)
+       for (i = 1; i < max_q_idx; i++)
        {
                IDX q_idx = quest_num[i];
                quest_type* const q_ptr = &quest[q_idx];
@@ -8264,7 +8266,7 @@ void do_cmd_knowledge_quests_failed(FILE *fff, IDX quest_num[])
        int total = 0;
 
        fprintf(fff, _("《失敗したクエスト》\n", "< Failed Quest >\n"));
-       for (i = 1; i < max_quests; i++)
+       for (i = 1; i < max_q_idx; i++)
        {
                IDX q_idx = quest_num[i];
                quest_type* const q_ptr = &quest[q_idx];
@@ -8289,7 +8291,7 @@ static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
        int total = 0;
 
        fprintf(fff, _("《残りのランダムクエスト》\n", "< Remaining Random Quest >\n"));
-       for (i = 1; i < max_quests; i++)
+       for (i = 1; i < max_q_idx; i++)
        {
                /* No info from "silent" quests */
                if (quest[i].flags & QUEST_FLAG_SILENT) continue;
@@ -8310,20 +8312,22 @@ static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
 
 bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
 {
-       int *q_num = (int *)u;
+       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);
+       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)
 {
-       int *q_num = (int *)u;
-       int tmp;
+       QUEST_IDX *q_num = (QUEST_IDX *)u;
+       QUEST_IDX tmp;
 
        /* Unused */
        (void)v;
@@ -8355,13 +8359,13 @@ static void do_cmd_knowledge_quests(void)
        }
 
        /* Allocate Memory */
-       C_MAKE(quest_num, max_quests, IDX);
+       C_MAKE(quest_num, max_q_idx, IDX);
 
        /* Sort by compete level */
-       for (i = 1; i < max_quests; i++) quest_num[i] = i;
+       for (i = 1; i < max_q_idx; i++) quest_num[i] = i;
        ang_sort_comp = ang_sort_comp_quest_num;
        ang_sort_swap = ang_sort_swap_quest_num;
-       ang_sort(quest_num, &dummy, max_quests);
+       ang_sort(quest_num, &dummy, max_q_idx);
 
        /* Dump Quest Information */
        do_cmd_knowledge_quests_current(fff);
@@ -8385,7 +8389,7 @@ static void do_cmd_knowledge_quests(void)
        fd_kill(file_name);
 
        /* Free Memory */
-       C_KILL(quest_num, max_quests, IDX);
+       C_KILL(quest_num, max_q_idx, IDX);
 }