OSDN Git Service

[Refactor] #38836 名称用文字配列のマジックナンバー処理。 / Delete magic number from naming string array.
[hengband/hengband.git] / src / bldg.c
index 1e4b03f..e87ab3a 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "angband.h"
 #include "object-hook.h"
+#include "melee.h"
+
 
 /*!
  * ループ中で / hack as in leave_store in store.c
@@ -302,19 +304,15 @@ static void arena_comm(int cmd)
 
                                p_ptr->monster_race_idx = arena_info[p_ptr->arena_number].r_idx;
                                p_ptr->window |= (PW_MONSTER);
-                               window_stuff();
+                               handle_stuff();
 
                        }
                        break;
                case BACT_ARENA_RULES:
-
-                       /* Save screen */
                        screen_save();
 
                        /* Peruse the arena help file */
                        (void)show_file(TRUE, _("arena_j.txt", "arena.txt"), NULL, 0, 0);
-
-                       /* Load screen */
                        screen_load();
 
                        break;
@@ -979,95 +977,6 @@ static int do_poker(void)
                cards[i] = deck[deck_ptr++];
                kaeruka[i] = 0; /* default:nokosu */
        }
-       
-#if 0
-       /* debug:RF */
-       cards[0] = 12;
-       cards[1] = 0;
-       cards[2] = 9;
-       cards[3] = 11;
-       cards[4] = 10;
-#endif
-#if 0
-       /* debug:SF */
-       cards[0] = 3;
-       cards[1] = 2;
-       cards[2] = 4;
-       cards[3] = 6;
-       cards[4] = 5;
-#endif
-#if 0
-       /* debug:Four Cards */
-       cards[0] = 0;
-       cards[1] = 0 + 13 * 1;
-       cards[2] = 0 + 13 * 2;
-       cards[3] = 0 + 13 * 3;
-       cards[4] = 51;
-#endif
-#if 0
-       /* debug:Straight1 */
-       cards[0] = 1;
-       cards[1] = 0 + 13;
-       cards[2] = 3;
-       cards[3] = 2 + 26;
-       cards[4] = 4;
-#endif
-#if 0
-       /* debug:Straight2 */
-       cards[0] = 12;
-       cards[1] = 0;
-       cards[2] = 9;
-       cards[3] = 11 + 13 * 2;
-       cards[4] = 10;
-#endif
-#if 0
-       /* debug:Straight3 */
-       cards[0] = 52;
-       cards[1] = 0;
-       cards[2] = 9;
-       cards[3] = 11 + 13 * 2;
-       cards[4] = 10;
-#endif
-#if 0
-       /* debug:Straight4 */
-       cards[0] = 12;
-       cards[1] = 52;
-       cards[2] = 9;
-       cards[3] = 11 + 13 * 2;
-       cards[4] = 10;
-#endif
-#if 0
-       /* debug:Straight5 */
-       cards[0] = 4;
-       cards[1] = 5 + 13;
-       cards[2] = 6;
-       cards[3] = 7 + 26;
-       cards[4] = 3;
-#endif
-#if 0
-       /* debug:Five Card1 */
-       cards[0] = 4;
-       cards[1] = 52;
-       cards[2] = 4 + 13;
-       cards[3] = 4 + 26;
-       cards[4] = 4 + 39;
-#endif
-#if 0
-       /* debug:Five Card2 */
-       cards[1] = 52;
-       cards[0] = 4;
-       cards[2] = 4 + 13;
-       cards[3] = 4 + 26;
-       cards[4] = 4 + 39;
-#endif
-#if 0
-       /* debug */
-       cards[0] = 52;
-       cards[1] = 0;
-       cards[2] = 1;
-       cards[3] = 2;
-       cards[4] = 3;
-#endif
 
        /* suteruno wo kimeru */
        prt(_("残すカードを決めて下さい(方向で移動, スペースで選択)。", "Stay witch? "), 0, 0);
@@ -1465,7 +1374,6 @@ static bool vault_aux_battle(MONRACE_IDX r_idx)
        }
        if (!dam && !(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK | RF4_BREATH_MASK)) && !(r_ptr->a_ability_flags1 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_BREATH_MASK)) && !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK | RF6_BREATH_MASK))) return (FALSE);
 
-       /* Okay */
        return (TRUE);
 }
 
@@ -1744,7 +1652,7 @@ static void tsuchinoko(void)
 static void shoukinkubi(void)
 {
        int i;
-       int y = 0;
+       TERM_LEN y = 0;
 
        clear_bldg(4,18);
        prt(_("死体を持ち帰れば報酬を差し上げます。", "Offer a prize when you bring a wanted monster's corpse"),4 ,10);
@@ -1824,7 +1732,7 @@ static bool kankin(void)
        INVENTORY_IDX i;
        int j;
        bool change = FALSE;
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
        object_type *o_ptr;
 
        /* Loop for inventory and right/left arm */
@@ -2000,14 +1908,11 @@ static bool kankin(void)
                                 */
                                item_new = inven_carry(&forge);
 
-                               /* Describe the object */
                                object_desc(o_name, &forge, 0);
                                msg_format(_("%s(%c)を貰った。", "You get %s (%c). "), o_name, index_to_label(item_new));
 
                                /* Auto-inscription */
                                autopick_alter_item(item_new, FALSE);
-
-                               /* Handle stuff */
                                handle_stuff();
 
                                change = TRUE;
@@ -2308,13 +2213,10 @@ static void castle_quest(void)
  */
 static void town_history(void)
 {
-       /* Save screen */
        screen_save();
 
        /* Peruse the building help file */
        (void)show_file(TRUE, _("jbldg.txt", "bldg.txt"), NULL, 0, 0);
-
-       /* Load screen */
        screen_load();
 }
 
@@ -2740,28 +2642,6 @@ static void compare_weapon_aux(object_type *o_ptr, int col, int r)
 }
 
 /*!
- * @brief モンスターへの命中率の計算
- * @param to_h 命中値
- * @param ac 敵AC
- * @return 命中確率
- */
-static PERCENTAGE hit_chance(HIT_PROB to_h, ARMOUR_CLASS ac)
-{
-       PERCENTAGE chance = 0;
-       int meichuu = p_ptr->skill_thn + (p_ptr->to_h[0] + to_h) * BTH_PLUS_ADJ;
-
-       if (meichuu <= 0) return 5;
-
-       chance = 100 - ((ac * 75) / meichuu);
-
-       if (chance > 95) chance = 95;
-       if (chance < 5) chance = 5;
-       if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
-               chance = (chance * 19 + 9) / 20;
-       return chance;
-}
-
-/*!
  * @brief 武器匠における武器一つ毎の完全情報を表示する。
  * @param o_ptr オブジェクトの構造体の参照ポインタ。
  * @param row 表示する列の左端
@@ -2775,12 +2655,12 @@ static PERCENTAGE hit_chance(HIT_PROB to_h, ARMOUR_CLASS ac)
  */
 static void list_weapon(object_type *o_ptr, TERM_LEN row, TERM_LEN col)
 {
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
        char tmp_str[80];
 
-       /* Effective dices */
        DICE_NUMBER eff_dd = o_ptr->dd + p_ptr->to_dd[0];
        DICE_SID eff_ds = o_ptr->ds + p_ptr->to_ds[0];
+       HIT_RELIABILITY reli = p_ptr->skill_thn + (p_ptr->to_h[0] + o_ptr->to_h) * BTH_PLUS_ADJ;
 
        /* Print the weapon name */
        object_desc(o_name, o_ptr, OD_NAME_ONLY);
@@ -2796,8 +2676,11 @@ static void list_weapon(object_type *o_ptr, TERM_LEN row, TERM_LEN col)
 
        /* Print the weapons base damage dice */
        sprintf(tmp_str, "        %2d  %2d  %2d  %2d  %2d (%%)",
-                               hit_chance(o_ptr->to_h, 0), hit_chance(o_ptr->to_h, 50), hit_chance(o_ptr->to_h, 100),
-                               hit_chance(o_ptr->to_h, 150), hit_chance(o_ptr->to_h, 200));
+               hit_chance(reli, 0),
+               hit_chance(reli, 50),
+               hit_chance(reli, 100),
+               hit_chance(reli, 150),
+               hit_chance(reli, 200));
        put_str(tmp_str, row+3, col);
        c_put_str(TERM_YELLOW, _("可能なダメージ:", "Possible Damage:"), row+5, col);
 
@@ -2838,42 +2721,34 @@ static PRICE compare_weapons(PRICE bcost)
        PRICE total = 0;
        PRICE cost = 0; /* First time no price */
 
-       /* Save the screen */
        screen_save();
-
-       /* Clear the screen */
        clear_bldg(0, 22);
 
        /* Store copy of original wielded weapon */
        i_ptr = &inventory[INVEN_RARM];
        object_copy(&orig_weapon, i_ptr);
 
-       /* Only compare melee weapons */
-       item_tester_no_ryoute = TRUE;
        item_tester_hook = item_tester_hook_orthodox_melee_weapons;
 
        /* Get the first weapon */
        q = _("第一の武器は?", "What is your first weapon? ");
        s = _("比べるものがありません。", "You have nothing to compare.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN)))
+       o_ptr[0] = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr)
        {
                screen_load();
                return (0);
        }
 
-       /* Get the item (in the pack) */
-       o_ptr[0] = &inventory[item];
        n = 1;
        total = bcost;
 
        while (TRUE)
        {
-               /* Clear the screen */
                clear_bldg(0, 22);
 
                /* Only compare melee weapons */
-               item_tester_no_ryoute = TRUE;
                item_tester_hook = item_tester_hook_orthodox_melee_weapons;
 
                /* Hack -- prevent "icky" message */
@@ -2887,8 +2762,8 @@ static PRICE compare_weapons(PRICE bcost)
                        /* Copy i-th weapon into the weapon slot (if it's not already there) */
                        if (o_ptr[i] != i_ptr) object_copy(i_ptr, o_ptr[i]);
 
-                       /* Get the new values */
-                       calc_bonuses();
+                       p_ptr->update |= PU_BONUS;
+                       handle_stuff();
 
                        /* List the new values */
                        list_weapon(o_ptr[i], row, col);
@@ -2899,7 +2774,8 @@ static PRICE compare_weapons(PRICE bcost)
                }
 
                /* Reset the values for the old weapon */
-               calc_bonuses();
+               p_ptr->update |= PU_BONUS;
+               handle_stuff();
 
                character_xtra = old_character_xtra;
 
@@ -2929,13 +2805,11 @@ static PRICE compare_weapons(PRICE bcost)
                        s = _("比べるものがありません。", "You have nothing to compare.");
 
                        /* Get the second weapon */
-                       if (!get_item(&item2, q, s, (USE_EQUIP | USE_INVEN))) continue;
+                       o_ptr[1] = choose_object(&item2, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
+                       if (!o_ptr) continue;
 
                        total += cost;
                        cost = bcost / 2;
-
-                       /* Get the item (in the pack) */
-                       o_ptr[1] = &inventory[item2];
                        n = 2;
                }
                else
@@ -2943,11 +2817,8 @@ static PRICE compare_weapons(PRICE bcost)
                        break;
                }
        }
-
-       /* Restore the screen */
        screen_load();
 
-       /* Done */
        return (total);
 }
 
@@ -3046,7 +2917,6 @@ static bool eval_ac(ARMOUR_CLASS iAC)
        (void)inkey();
        screen_load();
 
-       /* Done */
        return (TRUE);
 }
 
@@ -3122,27 +2992,21 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
        int i, dd_bonus, ds_bonus;
        KIND_OBJECT_IDX k_idx;
        char basenm[MAX_NLEN];
-       cptr q, s; /* For get_item prompt */
+       cptr q, s;
        int row = 7;
-
-       /* Clear screen */
        clear_bldg(0, 22);
 
-       /* Notice */
        prt(_("修復には材料となるもう1つの武器が必要です。", "Hand one material weapon to repair a broken weapon."), row, 2);
        prt(_("材料に使用した武器はなくなります!", "The material weapon will disappear after repairing!!"), row+1, 2);
 
-       /* Get an item */
        q = _("どの折れた武器を修復しますか?", "Repair which broken weapon? ");
        s = _("修復できる折れた武器がありません。", "You have no broken weapon to repair.");
 
        /* Only forge broken weapons */
        item_tester_hook = item_tester_hook_broken_weapon;
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) return (0);
-
-       /* Get the item (in the pack) */
-       o_ptr = &inventory[item];
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP));
+       if (!o_ptr) return (0);
 
        /* It is worthless */
        if (!object_is_ego(o_ptr) && !object_is_artifact(o_ptr))
@@ -3162,23 +3026,20 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
        object_desc(basenm, o_ptr, OD_NAME_ONLY);
        prt(format(_("修復する武器 : %s", "Repairing: %s"), basenm), row+3, 2);
 
-       /* Get an item */
        q = _("材料となる武器は?", "Which weapon for material? ");
        s = _("材料となる武器がありません。", "You have no material to repair.");
 
        /* Only forge broken weapons */
        item_tester_hook = item_tester_hook_orthodox_melee_weapons;
 
-       if (!get_item(&mater, q, s, (USE_INVEN | USE_EQUIP))) return (0);
+       mo_ptr = choose_object(&mater, q, s, (USE_INVEN | USE_EQUIP));
+       if (!mo_ptr) return (0);
        if (mater == item)
        {
                msg_print(_("クラインの壷じゃない!", "This is not a klein bottle!"));
                return (0);
        }
 
-       /* Get the item (in the pack) */
-       mo_ptr = &inventory[mater];
-
        /* Display item name */
        object_desc(basenm, mo_ptr, OD_NAME_ONLY);
        prt(format(_("材料とする武器: %s", "Material : %s"), basenm), row+4, 2);
@@ -3197,9 +3058,11 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
                return (0);
        }
 
+       p_ptr->total_weight -= o_ptr->weight;
+
        if (o_ptr->sval == SV_BROKEN_DAGGER)
        {
-               IDX j;
+               KIND_OBJECT_IDX j;
                int n = 1;
 
                /* Suppress compiler warning */
@@ -3295,7 +3158,6 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
                }
        }
 
-       /* */
        if (have_flag(k_ptr->flags, TR_BLOWS))
        {
                int bmax = MIN(3, MAX(1, 40 / (o_ptr->dd * o_ptr->ds)));
@@ -3351,6 +3213,9 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
        /* Add repaired flag */
        o_ptr->discount = 99;
 
+       p_ptr->total_weight += o_ptr->weight;
+       calc_android_exp();
+
        /* Decrease material object */
        inven_item_increase(mater, -1);
        inven_item_optimize(mater);
@@ -3388,33 +3253,23 @@ static int repair_broken_weapon(PRICE bcost)
  */
 static bool enchant_item(PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac)
 {
-       int         i;
-       OBJECT_IDX  item;
-       bool        okay = FALSE;
+       int i;
+       OBJECT_IDX item;
+       bool okay = FALSE;
        object_type *o_ptr;
-       cptr        q, s;
-       int         maxenchant = (p_ptr->lev / 5);
-       char        tmp_str[MAX_NLEN];
+       cptr q, s;
+       int maxenchant = (p_ptr->lev / 5);
+       char tmp_str[MAX_NLEN];
 
        clear_bldg(4, 18);
-#ifdef JP
-       prt(format("現在のあなたの技量だと、+%d まで改良できます。", maxenchant), 5, 0);
-       prt(format(" 改良の料金は一個につき$%d です。", cost), 7, 0);
-#else
-       prt(format("  Based on your skill, we can improve up to +%d.", maxenchant), 5, 0);
-       prt(format("  The price for the service is %d gold per item.", cost), 7, 0);
-#endif
+       prt(format(_("現在のあなたの技量だと、+%d まで改良できます。", "  Based on your skill, we can improve up to +%d."), maxenchant), 5, 0);
+       prt(format(_(" 改良の料金は一個につき$%d です。", "  The price for the service is %d gold per item."), cost), 7, 0);
 
-       item_tester_no_ryoute = TRUE;
-
-       /* Get an item */
        q = _("どのアイテムを改良しますか?", "Improve which item? ");
        s = _("改良できるものがありません。", "You have nothing to improve.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       o_ptr = &inventory[item];
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return (FALSE);
 
        /* Check if the player has enough money */
        if (p_ptr->au < (cost * o_ptr->number))
@@ -3466,12 +3321,8 @@ static bool enchant_item(PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_C
        /* Failure */
        if (!okay)
        {
-               /* Flush */
                if (flush_failure) flush();
-
-               /* Message */
                msg_print(_("改良に失敗した。", "The improvement failed."));
-
                return (FALSE);
        }
        else
@@ -3527,22 +3378,11 @@ static void building_recharge(void)
        /* Only accept legal items */
        item_tester_hook = item_tester_hook_recharge;
 
-       /* Get an item */
        q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
        s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
 
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return;
 
        k_ptr = &k_info[o_ptr->k_idx];
 
@@ -3712,7 +3552,6 @@ if (get_check(format("そのロッドを$%d で再充填しますか?",
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
-       /* Window stuff */
        p_ptr->window |= (PW_INVEN);
 
        /* Pay the price */
@@ -3858,7 +3697,6 @@ static void building_recharge_all(void)
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
 
-       /* Window stuff */
        p_ptr->window |= (PW_INVEN);
 
        /* Pay the price */
@@ -3972,8 +3810,6 @@ static bool research_mon(void)
        static int old_sym = '\0';
        static IDX old_i = 0;
 
-
-       /* Save the screen */
        screen_save();
 
        /* Get a character, or abort */
@@ -4150,8 +3986,6 @@ static bool research_mon(void)
 
                                /* Save this monster ID */
                                monster_race_track(r_idx);
-
-                               /* Hack -- Handle stuff */
                                handle_stuff();
 
                                /* know every thing mode */
@@ -4224,9 +4058,8 @@ static void bldg_process_command(building_type *bldg, int i)
        bool paid = FALSE;
        int amt;
 
-       /* Flush messages XXX XXX XXX */
        msg_flag = FALSE;
-       msg_print(NULL);
+       msg_erase();
 
        if (is_owner(bldg))
                bcost = bldg->member_costs[i];
@@ -4605,21 +4438,15 @@ void do_cmd_bldg(void)
                        }
                }
 
-               if (validcmd)
-                       bldg_process_command(bldg, i);
-
-               /* Notice stuff */
-               notice_stuff();
+               if(validcmd) bldg_process_command(bldg, i);
 
-               /* Handle stuff */
                handle_stuff();
        }
 
        select_floor_music();
 
-       /* Flush messages XXX XXX XXX */
        msg_flag = FALSE;
-       msg_print(NULL);
+       msg_erase();
 
        /* Reinit wilderness to activate quests ... */
        if (reinit_wilderness)
@@ -4630,16 +4457,10 @@ void do_cmd_bldg(void)
        /* Hack -- Decrease "icky" depth */
        character_icky--;
 
-       /* Clear the screen */
        Term_clear();
 
-       /* Update the visuals */
        p_ptr->update |= (PU_VIEW | PU_MONSTERS | PU_BONUS | PU_LITE | PU_MON_LITE);
-
-       /* Redraw entire screen */
        p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
-
-       /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 }
 
@@ -4663,10 +4484,10 @@ static cptr find_quest[] =
  */
 void quest_discovery(QUEST_IDX q_idx)
 {
-       quest_type      *q_ptr = &quest[q_idx];
-       monster_race    *r_ptr = &r_info[q_ptr->r_idx];
-       int             q_num = q_ptr->max_num;
-       char            name[80];
+       quest_type *q_ptr = &quest[q_idx];
+       monster_race *r_ptr = &r_info[q_ptr->r_idx];
+       MONSTER_NUMBER q_num = q_ptr->max_num;
+       GAME_TEXT name[MAX_NLEN];
 
        /* No quest index */
        if (!q_idx) return;
@@ -4759,6 +4580,5 @@ QUEST_IDX random_quest_number(DEPTH level)
                }
        }
 
-       /* Nope */
        return 0;
 }