OSDN Git Service

[Refactor] #37287 #37353 型の置換。 / Type replacement.
[hengband/hengband.git] / src / bldg.c
index 593155a..6d3621f 100644 (file)
@@ -13,7 +13,7 @@
 */
 
 #include "angband.h"
-
+#include "object-hook.h"
 
 /*!
  * ループ中で / hack as in leave_store in store.c
@@ -1438,10 +1438,10 @@ static bool gamble_comm(int cmd)
  * 自爆以外のなんらかのHP攻撃手段を持っていること。
  * @return 参加できるか否か
  */
-static bool vault_aux_battle(int r_idx)
+static bool vault_aux_battle(MONRACE_IDX r_idx)
 {
        int i;
-       int dam = 0;
+       HIT_POINT dam = 0;
 
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1503,7 +1503,7 @@ void battle_monsters(void)
                tekitou = FALSE;
                for(i = 0; i < 4; i++)
                {
-                       IDX r_idx;
+                       MONRACE_IDX r_idx;
                        int j;
                        while (1)
                        {
@@ -2027,7 +2027,7 @@ static bool kankin(void)
  * @param r_idx 判定対象となるモンスターのID
  * @return 悪夢の元凶となり得るか否か。
  */
-bool get_nightmare(int r_idx)
+bool get_nightmare(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -2323,9 +2323,9 @@ static void town_history(void)
  * @return ダメージ期待値
  * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
  */
-s16b calc_crit_ratio_shot(int plus_ammo, int plus_bow)
+HIT_POINT calc_crit_ratio_shot(HIT_POINT plus_ammo, HIT_POINT plus_bow)
 {
-       int i;
+       HIT_POINT i;
        object_type *j_ptr =  &inventory[INVEN_BOW];
        
        /* Extract "shot" power */
@@ -2356,7 +2356,7 @@ s16b calc_crit_ratio_shot(int plus_ammo, int plus_bow)
  * @param dam 基本ダメージ量
  * @return ダメージ期待値
  */
-s16b calc_expect_crit_shot(int weight, int plus_ammo, int plus_bow,  int dam)
+HIT_POINT calc_expect_crit_shot(int weight, int plus_ammo, int plus_bow,  HIT_POINT dam)
 {
        u32b num;
        int i, k, crit;
@@ -2398,7 +2398,7 @@ s16b calc_expect_crit_shot(int weight, int plus_ammo, int plus_bow,  int dam)
  * @param dokubari 毒針処理か否か
  * @return ダメージ期待値
  */
-s16b calc_expect_crit(int weight, int plus, int dam, s16b meichuu, bool dokubari)
+HIT_POINT calc_expect_crit(int weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
 {
        u32b k, num;
        int i;
@@ -2442,7 +2442,7 @@ s16b calc_expect_crit(int weight, int plus, int dam, s16b meichuu, bool dokubari
  * @param force 理力特別計算フラグ
  * @return ダメージ期待値
  */
-static s16b calc_slaydam(int dam, int mult, int div, bool force)
+static HIT_POINT calc_slaydam(HIT_POINT dam, int mult, int div, bool force)
 {
        int tmp;
        if(force)
@@ -2812,53 +2812,6 @@ static void list_weapon(object_type *o_ptr, int row, int col)
        put_str(tmp_str, row+7, col+1);
 }
 
-
-/*!
- * @brief 武器匠の「武器」鑑定対象になるかを判定する。/ Hook to specify "weapon"
- * @param o_ptr オブジェクトの構造体の参照ポインタ。
- * @return 対象になるならTRUEを返す。
- */
-static bool item_tester_hook_melee_weapon(object_type *o_ptr)
-{
-       switch (o_ptr->tval)
-       {
-               case TV_HAFTED:
-               case TV_POLEARM:
-               case TV_DIGGING:
-               {
-                       return (TRUE);
-               }
-               case TV_SWORD:
-               {
-                       if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
-               }
-       }
-
-       return (FALSE);
-}
-
-
-/*!
- * @brief 武器匠の「矢弾」鑑定対象になるかを判定する。/ Hook to specify "weapon"
- * @param o_ptr オブジェクトの構造体の参照ポインタ。
- * @return 対象になるならTRUEを返す。
- */
-static bool item_tester_hook_ammo(object_type *o_ptr)
-{
-       switch (o_ptr->tval)
-       {
-               case TV_SHOT:
-               case TV_ARROW:
-               case TV_BOLT:
-               {
-                       return (TRUE);
-               }
-       }
-
-       return (FALSE);
-}
-
-
 /*!
  * @brief 武器匠鑑定1回分(オブジェクト2種)の処理。/ Compare weapons
  * @details 
@@ -2871,7 +2824,7 @@ static bool item_tester_hook_ammo(object_type *o_ptr)
 static int compare_weapons(int bcost)
 {
        int i, n;
-       int item, item2;
+       OBJECT_IDX item, item2;
        object_type *o_ptr[2];
        object_type orig_weapon;
        object_type *i_ptr;
@@ -2895,7 +2848,7 @@ static int compare_weapons(int bcost)
 
        /* Only compare melee weapons */
        item_tester_no_ryoute = TRUE;
-       item_tester_hook = item_tester_hook_melee_weapon;
+       item_tester_hook = item_tester_hook_orthodox_melee_weapons;
 
        /* Get the first weapon */
        q = _("第一の武器は?", "What is your first weapon? ");
@@ -2919,7 +2872,7 @@ static int compare_weapons(int bcost)
 
                /* Only compare melee weapons */
                item_tester_no_ryoute = TRUE;
-               item_tester_hook = item_tester_hook_melee_weapon;
+               item_tester_hook = item_tester_hook_orthodox_melee_weapons;
 
                /* Hack -- prevent "icky" message */
                character_xtra = TRUE;
@@ -3101,24 +3054,6 @@ static bool eval_ac(int iAC)
 }
 
 
-/*!
- * @brief 修復対象となる壊れた武器かを判定する。 / Hook to specify "broken weapon"
- * @param o_ptr オブジェクトの構造体の参照ポインタ。
- * @return 修復対象になるならTRUEを返す。
- */
-static bool item_tester_hook_broken_weapon(object_type *o_ptr)
-{
-       if (o_ptr->tval != TV_SWORD) return FALSE;
-
-       switch (o_ptr->sval)
-       {
-       case SV_BROKEN_DAGGER:
-       case SV_BROKEN_SWORD:
-               return TRUE;
-       }
-
-       return FALSE;
-}
 
 /*!
  * @brief 修復材料のオブジェクトから修復対象に特性を移植する。
@@ -3184,7 +3119,7 @@ static void give_one_ability_of_object(object_type *to_ptr, object_type *from_pt
 static int repair_broken_weapon_aux(int bcost)
 {
        s32b cost;
-       int item, mater;
+       OBJECT_IDX item, mater;
        object_type *o_ptr, *mo_ptr; /* broken weapon and material weapon */
        object_kind *k_ptr;
        int i, dd_bonus, ds_bonus;
@@ -3235,7 +3170,7 @@ static int repair_broken_weapon_aux(int bcost)
        s = _("材料となる武器がありません。", "You have no material to repair.");
 
        /* Only forge broken weapons */
-       item_tester_hook = item_tester_hook_melee_weapon;
+       item_tester_hook = item_tester_hook_orthodox_melee_weapons;
 
        if (!get_item(&mater, q, s, (USE_INVEN | USE_EQUIP))) return (0);
        if (mater == item)
@@ -3294,7 +3229,7 @@ static int repair_broken_weapon_aux(int bcost)
        else /* TV_BROKEN_SWORD */
        {
                /* Repair to a sword or sometimes material's type weapon */
-               IDX tval = (one_in_(5) ? mo_ptr->tval : TV_SWORD);
+               OBJECT_TYPE_VALUE tval = (one_in_(5) ? mo_ptr->tval : TV_SWORD);
 
                while(1)
                {
@@ -3344,7 +3279,7 @@ static int repair_broken_weapon_aux(int bcost)
        /* Copy base object's ability */
        for (i = 0; i < TR_FLAG_SIZE; i++) o_ptr->art_flags[i] |= k_ptr->flags[i];
        if (k_ptr->pval) o_ptr->pval = MAX(o_ptr->pval, randint1(k_ptr->pval));
-       if (have_flag(k_ptr->flags, TR_ACTIVATE)) o_ptr->xtra2 = k_ptr->act_idx;
+       if (have_flag(k_ptr->flags, TR_ACTIVATE)) o_ptr->xtra2 = (byte_hack)k_ptr->act_idx;
 
        /* Dice up */
        if (dd_bonus > 0)
@@ -3458,7 +3393,8 @@ static int repair_broken_weapon(int bcost)
  */
 static bool enchant_item(int cost, int to_hit, int to_dam, int to_ac)
 {
-       int         i, item;
+       int         i;
+       OBJECT_IDX  item;
        bool        okay = FALSE;
        object_type *o_ptr;
        cptr        q, s;
@@ -3576,7 +3512,8 @@ static bool enchant_item(int cost, int to_hit, int to_dam, int to_ac)
  */
 static void building_recharge(void)
 {
-       int         item, lev;
+       OBJECT_IDX  item;
+       int         lev;
        object_type *o_ptr;
        object_kind *k_ptr;
        cptr        q, s;
@@ -3753,7 +3690,7 @@ if (get_check(format("そのロッドを$%d で再充填しますか?",
                        max_charges = o_ptr->number * k_ptr->pval - o_ptr->pval;
 
                /* Get the quantity for staves and wands */
-               charges = get_quantity(format(_("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold? "), price), 
+               charges = (PARAMETER_VALUE)get_quantity(format(_("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold? "), price), 
                                        MIN(p_ptr->au / price, max_charges));
 
                /* Do nothing */
@@ -4020,8 +3957,9 @@ bool tele_town(void)
  */
 static bool research_mon(void)
 {
-       int i, n;
-       IDX r_idx;
+       IDX i;
+       int n;
+       MONRACE_IDX r_idx;
        char sym, query;
        char buf[128];
 
@@ -4031,7 +3969,7 @@ static bool research_mon(void)
 
        u16b why = 0;
 
-       u16b    *who;
+       IDX *who;
 
        /* XTRA HACK WHATSEARCH */
        bool    all = FALSE;
@@ -4041,7 +3979,7 @@ static bool research_mon(void)
 
        /* XTRA HACK REMEMBER_IDX */
        static int old_sym = '\0';
-       static int old_i = 0;
+       static IDX old_i = 0;
 
 
        /* Save the screen */
@@ -4108,7 +4046,7 @@ static bool research_mon(void)
 
 
        /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, u16b);
+       C_MAKE(who, max_r_idx, IDX);
 
        /* Collect matching monsters */
        for (n = 0, i = 1; i < max_r_idx; i++)
@@ -4140,7 +4078,7 @@ static bool research_mon(void)
                                        continue;
                                }
 #endif
-                               if (isupper(temp[xx])) temp[xx] = tolower(temp[xx]);
+                               if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
                        }
   
 #ifdef JP
@@ -4149,7 +4087,7 @@ static bool research_mon(void)
                        strcpy(temp2, r_name + r_ptr->name);
 #endif
                        for (xx = 0; temp2[xx] && xx < 80; xx++)
-                               if (isupper(temp2[xx])) temp2[xx] = tolower(temp2[xx]);
+                               if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
 
 #ifdef JP
                        if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
@@ -4165,7 +4103,7 @@ static bool research_mon(void)
        if (!n)
        {
                /* Free the "who" array */
-               C_KILL(who, max_r_idx, u16b);
+               C_KILL(who, max_r_idx, IDX);
 
                /* Restore */
                screen_load();
@@ -4273,7 +4211,7 @@ static bool research_mon(void)
        /* prt(buf, 5, 5);*/
 
        /* Free the "who" array */
-       C_KILL(who, max_r_idx, u16b);
+       C_KILL(who, max_r_idx, IDX);
 
        /* Restore */
        screen_load();
@@ -4290,8 +4228,8 @@ static bool research_mon(void)
  */
 static void bldg_process_command(building_type *bldg, int i)
 {
-       int bact = bldg->actions[i];
-       int bcost;
+       BACT_IDX bact = bldg->actions[i];
+       PRICE bcost;
        bool paid = FALSE;
        int amt;
 
@@ -4402,21 +4340,10 @@ static void bldg_process_command(building_type *bldg, int i)
                do_cmd_study();
                break;
        case BACT_HEALING: /* needs work */
-               hp_player(200);
-               set_poisoned(0);
-               set_blind(0);
-               set_confused(0);
-               set_cut(0);
-               set_stun(0);
-               paid = TRUE;
+               paid = cure_critical_wounds(200);
                break;
        case BACT_RESTORE: /* needs work */
-               if (do_res_stat(A_STR)) paid = TRUE;
-               if (do_res_stat(A_INT)) paid = TRUE;
-               if (do_res_stat(A_WIS)) paid = TRUE;
-               if (do_res_stat(A_DEX)) paid = TRUE;
-               if (do_res_stat(A_CON)) paid = TRUE;
-               if (do_res_stat(A_CHR)) paid = TRUE;
+               paid = restore_all_status();
                break;
        case BACT_ENCHANT_ARROWS:
                item_tester_hook = item_tester_hook_ammo;
@@ -4431,8 +4358,8 @@ static void bldg_process_command(building_type *bldg, int i)
                break;
        case BACT_TELEPORT_LEVEL:
        {
-               int select_dungeon;
-               int max_depth;
+               IDX select_dungeon;
+               DEPTH max_depth;
 
                clear_bldg(4, 20);
                select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
@@ -4448,7 +4375,7 @@ static void bldg_process_command(building_type *bldg, int i)
                        else if(quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
                }
                amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "), 
-                                                       d_name + d_info[select_dungeon].name), max_depth);
+                                                       d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
 
                if (amt > 0)
                {
@@ -4811,7 +4738,7 @@ IDX quest_number(DEPTH level)
        if (p_ptr->inside_quest)
                return (p_ptr->inside_quest);
 
-       for (i = 0; i < max_quests; i++)
+       for (i = 0; i < max_q_idx; i++)
        {
                if (quest[i].status != QUEST_STATUS_TAKEN) continue;