OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / store.c
index 066d818..c5e93a4 100644 (file)
@@ -11,6 +11,9 @@
  */
 
 #include "angband.h"
+#include "cmd-item.h"
+#include "cmd-zapwand.h"
+#include "cmd-magiceat.h"
 
 #define MIN_STOCK 12
 
@@ -340,7 +343,7 @@ static void say_comment_1(void)
  * @param annoyed 店主のいらつき度
  * @return なし
  */
-static void say_comment_2(s32b value, int annoyed)
+static void say_comment_2(PRICE value, int annoyed)
 {
        char    tmp_val[80];
 
@@ -381,7 +384,7 @@ static void say_comment_2(s32b value, int annoyed)
  * @param annoyed 店主のいらつき度
  * @return なし
  */
-static void say_comment_3(s32b value, int annoyed)
+static void say_comment_3(PRICE value, int annoyed)
 {
        char    tmp_val[80];
 
@@ -556,7 +559,7 @@ static cptr comment_7d[MAX_COMMENT_7D] =
  * @details 
  * We paid "price", it was worth "value", and we thought it was worth "guess"
  */
-static void purchase_analyze(s32b price, s32b value, s32b guess)
+static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
 {
        /* Item was worthless, but we bought it */
        if ((value <= 0) && (price > value))
@@ -567,7 +570,6 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
                chg_virtue(V_HONOUR, -1);
                chg_virtue(V_JUSTICE, -1);
 
-               /* Sound */
                sound(SOUND_STORE1);
        }
 
@@ -581,7 +583,6 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
                if (one_in_(4))
                        chg_virtue(V_HONOUR, -1);
 
-               /* Sound */
                sound(SOUND_STORE2);
        }
 
@@ -596,7 +597,6 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
                else if (one_in_(4))
                        chg_virtue(V_HONOUR, 1);
 
-               /* Sound */
                sound(SOUND_STORE3);
        }
 
@@ -614,7 +614,6 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
                if (10 * price < value)
                        chg_virtue(V_SACRIFICE, 1);
 
-               /* Sound */
                sound(SOUND_STORE4);
        }
 }
@@ -963,7 +962,7 @@ static s32b price_item(object_type *o_ptr, int greed, bool flip)
 static void mass_produce(object_type *o_ptr)
 {
        int size = 1;
-       int discount = 0;
+       DISCOUNT_RATE discount = 0;
 
        s32b cost = object_value(o_ptr);
 
@@ -1099,18 +1098,8 @@ static void mass_produce(object_type *o_ptr)
                discount = 90;
        }
 
-
        if (o_ptr->art_name)
        {
-               if (cheat_peek && discount)
-               {
-#ifdef JP
-msg_print("ランダムアーティファクトは値引きなし。");
-#else
-                       msg_print("No discount on random artifacts.");
-#endif
-
-               }
                discount = 0;
        }
 
@@ -1123,7 +1112,7 @@ msg_print("ランダムアーティファクトは値引きなし。");
        /* Ensure that mass-produced rods and wands get the correct pvals. */
        if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
        {
-               o_ptr->pval *= o_ptr->number;
+               o_ptr->pval *= (PARAMETER_VALUE)o_ptr->number;
        }
 }
 
@@ -1326,7 +1315,7 @@ static int store_check_num(object_type *o_ptr)
  */
 static bool is_blessed(object_type *o_ptr)
 {
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
        object_flags(o_ptr, flgs);
        if (have_flag(flgs, TR_BLESSED)) return (TRUE);
        else return (FALSE);
@@ -1548,7 +1537,7 @@ static bool store_will_buy(object_type *o_ptr)
                }
        }
 
-       /* XXX XXX XXX Ignore "worthless" items */
+       /* Ignore "worthless" items */
        if (object_value(o_ptr) <= 0) return (FALSE);
 
        /* Assume okay */
@@ -1586,7 +1575,6 @@ bool combine_and_reorder_home(int store_num)
                /* Combine the items in the home (backwards) */
                for (i = st_ptr->stock_num - 1; i > 0; i--)
                {
-                       /* Get the item */
                        o_ptr = &st_ptr->stock[i];
 
                        /* Skip empty items */
@@ -1597,7 +1585,6 @@ bool combine_and_reorder_home(int store_num)
                        {
                                int max_num;
 
-                               /* Get the item */
                                j_ptr = &st_ptr->stock[j];
 
                                /* Skip empty items */
@@ -1632,8 +1619,8 @@ bool combine_and_reorder_home(int store_num)
                                        }
                                        else
                                        {
-                                               int old_num = o_ptr->number;
-                                               int remain = j_ptr->number + o_ptr->number - max_num;
+                                               ITEM_NUMBER old_num = o_ptr->number;
+                                               ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
 
                                                /* Add together the item counts */
                                                object_absorb(j_ptr, o_ptr);
@@ -1657,7 +1644,6 @@ bool combine_and_reorder_home(int store_num)
                                        /* Take note */
                                        combined = TRUE;
 
-                                       /* Done */
                                        break;
                                }
                        }
@@ -1670,7 +1656,6 @@ bool combine_and_reorder_home(int store_num)
        /* Re-order the items in the home (forwards) */
        for (i = 0; i < st_ptr->stock_num; i++)
        {
-               /* Get the item */
                o_ptr = &st_ptr->stock[i];
 
                /* Skip empty slots */
@@ -1940,13 +1925,13 @@ static int store_carry(object_type *o_ptr)
  * Increase, by a given amount, the number of a certain item
  * in a certain store. This can result in zero items.
  * </pre>
+ * @todo numは本来ITEM_NUMBER型にしたい。
  */
-static void store_item_increase(int item, int num)
+static void store_item_increase(INVENTORY_IDX item, int num)
 {
        int             cnt;
        object_type *o_ptr;
 
-       /* Get the item */
        o_ptr = &st_ptr->stock[item];
 
        /* Verify the number */
@@ -1956,7 +1941,7 @@ static void store_item_increase(int item, int num)
        num = cnt - o_ptr->number;
 
        /* Save the new number */
-       o_ptr->number += num;
+       o_ptr->number += (ITEM_NUMBER)num;
 }
 
 
@@ -1966,12 +1951,11 @@ static void store_item_increase(int item, int num)
  * @param item 削除したいアイテムのID
  * @return なし
  */
-static void store_item_optimize(int item)
+static void store_item_optimize(INVENTORY_IDX item)
 {
        int             j;
        object_type *o_ptr;
 
-       /* Get the item */
        o_ptr = &st_ptr->stock[item];
 
        /* Must exist */
@@ -2048,10 +2032,11 @@ static bool black_market_crap(object_type *o_ptr)
  */
 static void store_delete(void)
 {
-       int what, num;
+       INVENTORY_IDX what;
+       int num;
 
        /* Pick a random slot */
-       what = randint0(st_ptr->stock_num);
+       what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
 
        /* Determine how many items are here */
        num = st_ptr->stock[what].number;
@@ -2090,7 +2075,9 @@ static void store_delete(void)
  */
 static void store_create(void)
 {
-       int i, tries, level;
+       OBJECT_IDX i;
+       int tries;
+       DEPTH level;
 
        object_type forge;
        object_type *q_ptr;
@@ -2195,7 +2182,7 @@ static void store_create(void)
  * @param minprice アイテムの最低販売価格
  * @return 割引を禁止するならTRUEを返す。
  */
-static bool noneedtobargain(s32b minprice)
+static bool noneedtobargain(PRICE minprice)
 {
        s32b good = st_ptr->good_buy;
        s32b bad = st_ptr->bad_buy;
@@ -2222,7 +2209,7 @@ static bool noneedtobargain(s32b minprice)
  * @param num 売買数 
  * @return なし
  */
-static void updatebargain(s32b price, s32b minprice, int num)
+static void updatebargain(PRICE price, PRICE minprice, int num)
 {
        /* Hack -- auto-haggle */
        if (!manual_haggle) return;
@@ -2267,10 +2254,8 @@ static void display_entry(int pos)
        char            o_name[MAX_NLEN];
        char            out_val[160];
 
-
        int maxwid = 75;
 
-       /* Get the item */
        o_ptr = &st_ptr->stock[pos];
 
        /* Get the "offset" */
@@ -2619,14 +2604,12 @@ static void display_store(void)
  * @param j 選択範囲の最大値
  * @return 実際に選択したらTRUE、キャンセルしたらFALSE
  */
-static int get_stock(int *com_val, cptr pmt, int i, int j)
+static int get_stock(COMMAND_CODE *com_val, cptr pmt, int i, int j)
 {
        char    command;
        char    out_val[160];
        char    lo, hi;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        /* Get the item index */
        if (repeat_pull(com_val))
        {
@@ -2638,9 +2621,7 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
                }
        }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
-       /* Paranoia XXX XXX XXX */
+       /* Paranoia */
        msg_print(NULL);
 
 
@@ -2663,7 +2644,7 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
        /* Ask until done */
        while (TRUE)
        {
-               int k;
+               COMMAND_CODE k;
 
                /* Escape */
                if (!get_com(out_val, &command, FALSE)) break;
@@ -2683,7 +2664,6 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
                        break;
                }
 
-               /* Oops */
                bell();
        }
 
@@ -2693,12 +2673,8 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
        /* Cancel */
        if (command == ESCAPE) return (FALSE);
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        repeat_push(*com_val);
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Success */
        return (TRUE);
 }
@@ -2787,7 +2763,7 @@ static s32b last_inc = 0L;
  * @param final 最終確定価格ならばTRUE
  * @return プレイヤーを締め出す場合TRUEを返す
  */
-static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
+static int get_haggle(cptr pmt, s32b *poffer, PRICE price, int final)
 {
        s32b            i;
 
@@ -2841,7 +2817,7 @@ static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
        }
 
 
-       /* Paranoia XXX XXX XXX */
+       /* Paranoia */
        msg_print(NULL);
 
 
@@ -2948,7 +2924,7 @@ static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
  */
 static bool receive_offer(cptr pmt, s32b *poffer,
                          s32b last_offer, int factor,
-                         s32b price, int final)
+                         PRICE price, int final)
 {
        /* Haggle till done */
        while (TRUE)
@@ -3240,7 +3216,6 @@ static bool sell_haggle(object_type *o_ptr, s32b *price)
                /* No reason to haggle */
                if (final_ask >= purse)
                {
-                       /* Message */
 #ifdef JP
                        msg_print("即座にこの金額にまとまった。");
 #else
@@ -3256,7 +3231,6 @@ static bool sell_haggle(object_type *o_ptr, s32b *price)
                /* No need to haggle */
                else if (noneed)
                {
-                       /* Message */
 #ifdef JP
                        msg_print("結局この金額にまとまった。");
 #else
@@ -3297,7 +3271,7 @@ static bool sell_haggle(object_type *o_ptr, s32b *price)
        final_ask *= o_ptr->number;
 
 
-       /* XXX XXX XXX Display commands */
+       /* Display commands */
 
        /* Haggling parameters */
        min_per = ot_ptr->haggle_per;
@@ -3439,10 +3413,12 @@ static bool sell_haggle(object_type *o_ptr, s32b *price)
  */
 static void store_purchase(void)
 {
-       int i, amt, choice;
-       int item, item_new;
+       int i, choice;
+       COMMAND_CODE item, item_new;
+
+       ITEM_NUMBER amt;
 
-       s32b price, best;
+       PRICE price, best;
 
        object_type forge;
        object_type *j_ptr;
@@ -3626,9 +3602,8 @@ msg_format("一つにつき $%ldです。", (long)(best));
                        /* Describe the object (fully) */
                        object_desc(o_name, j_ptr, 0);
 
-                       /* Message */
 #ifdef JP
-msg_format("%s(%c)を購入する。", o_name, I2A(item));
+                       msg_format("%s(%c)を購入する。", o_name, I2A(item));
 #else
                        msg_format("Buying %s (%c).", o_name, I2A(item));
 #endif
@@ -3680,7 +3655,6 @@ msg_format("%s(%c)を購入する。", o_name, I2A(item));
                                /* Describe the transaction */
                                object_desc(o_name, j_ptr, 0);
 
-                               /* Message */
 #ifdef JP
 msg_format("%sを $%ldで購入しました。", o_name, (long)price);
 #else
@@ -3707,9 +3681,8 @@ msg_format("%sを $%ldで購入しました。", o_name, (long)price);
                                /* Describe the final result */
                                object_desc(o_name, &inventory[item_new], 0);
 
-                               /* Message */
 #ifdef JP
-               msg_format("%s(%c)を手に入れた。", o_name, index_to_label(item_new));
+                               msg_format("%s(%c)を手に入れた。", o_name, index_to_label(item_new));
 #else
                                msg_format("You have %s (%c).",
                                                   o_name, index_to_label(item_new));
@@ -3741,7 +3714,6 @@ msg_format("%sを $%ldで購入しました。", o_name, (long)price);
                                        if (one_in_(STORE_SHUFFLE))
                                        {
                                                char buf[80];
-                                               /* Message */
 #ifdef JP
                                                msg_print("店主は引退した。");
 #else
@@ -3764,7 +3736,6 @@ msg_format("%sを $%ldで購入しました。", o_name, (long)price);
                                        /* Maintain */
                                        else
                                        {
-                                               /* Message */
 #ifdef JP
                                                msg_print("店主は新たな在庫を取り出した。");
 #else
@@ -3833,9 +3804,8 @@ msg_format("%sを $%ldで購入しました。", o_name, (long)price);
                /* Describe just the result */
                object_desc(o_name, &inventory[item_new], 0);
 
-               /* Message */
 #ifdef JP
-                               msg_format("%s(%c)を取った。",
+               msg_format("%s(%c)を取った。",
 #else
                msg_format("You have %s (%c).",
 #endif
@@ -3892,10 +3862,11 @@ msg_format("%sを $%ldで購入しました。", o_name, (long)price);
 static void store_sell(void)
 {
        int choice;
-       int item, item_pos;
+       OBJECT_IDX item;
+       int item_pos;
        int amt;
 
-       s32b price, value, dummy;
+       PRICE price, value, dummy;
 
        object_type forge;
        object_type *q_ptr;
@@ -3934,7 +3905,6 @@ static void store_sell(void)
        /* Only allow items the store will buy */
        item_tester_hook = store_will_buy;
 
-       /* Get an item */
        /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
        if (cur_store_num == STORE_HOME)
        {
@@ -3979,7 +3949,6 @@ static void store_sell(void)
        /* Hack -- Cannot remove cursed items */
        if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
        {
-               /* Oops */
 #ifdef JP
                msg_print("ふーむ、どうやらそれは呪われているようだね。");
 #else
@@ -3987,7 +3956,6 @@ static void store_sell(void)
 #endif
 
 
-               /* Nope */
                return;
        }
 
@@ -4296,7 +4264,7 @@ msg_format("%sを $%ldで売却しました。", o_name, (long)price);
 static void store_examine(void)
 {
        int         i;
-       int         item;
+       COMMAND_CODE item;
        object_type *o_ptr;
        char        o_name[MAX_NLEN];
        char        out_val[160];
@@ -4398,7 +4366,7 @@ msg_print("特に変わったところはないようだ。");
 static void museum_remove_object(void)
 {
        int         i;
-       int         item;
+       COMMAND_CODE item;
        object_type *o_ptr;
        char        o_name[MAX_NLEN];
        char        out_val[160];
@@ -4448,7 +4416,6 @@ static void museum_remove_object(void)
        if (!get_check(format("Really order to remove %s from the Museum? ", o_name))) return;
 #endif
 
-       /* Message */
 #ifdef JP
        msg_format("%sの展示をやめさせた。", o_name);
 #else
@@ -4496,13 +4463,9 @@ static bool leave_store = FALSE;
  */
 static void store_process_command(void)
 {
-#ifdef ALLOW_REPEAT /* TNB */
-
        /* Handle repeating the last command */
        repeat_check();
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        if (rogue_like_commands && command_cmd == 'l')
        {
                command_cmd = 'x';      /* hack! */
@@ -5060,7 +5023,7 @@ void do_cmd_store(void)
 #endif
                }
 
-               /* Shop commands XXX XXX XXX */
+               /* Shop commands */
                else
                {
 #ifdef JP
@@ -5128,17 +5091,16 @@ void do_cmd_store(void)
                /* Handle stuff */
                handle_stuff();
 
-               /* XXX XXX XXX Pack Overflow */
+               /* Pack Overflow */
                if (inventory[INVEN_PACK].k_idx)
                {
-                       int item = INVEN_PACK;
+                       INVENTORY_IDX item = INVEN_PACK;
 
                        object_type *o_ptr = &inventory[item];
 
                        /* Hack -- Flee from the store */
                        if (cur_store_num != STORE_HOME)
                        {
-                               /* Message */
 #ifdef JP
                                if (cur_store_num == STORE_MUSEUM)
                                        msg_print("ザックからアイテムがあふれそうなので、あわてて博物館から出た...");
@@ -5159,7 +5121,6 @@ void do_cmd_store(void)
                        /* Hack -- Flee from the home */
                        else if (!store_check_num(o_ptr))
                        {
-                               /* Message */
 #ifdef JP
                                msg_print("ザックからアイテムがあふれそうなので、あわてて家から出た...");
 #else
@@ -5199,7 +5160,6 @@ void do_cmd_store(void)
                                /* Describe it */
                                object_desc(o_name, q_ptr, 0);
 
-                               /* Message */
 #ifdef JP
                                msg_format("%sが落ちた。(%c)", o_name, index_to_label(item));
 #else
@@ -5239,7 +5199,7 @@ void do_cmd_store(void)
 
        p_ptr->town_num = old_town_num;
 
-       /* Free turn XXX XXX XXX */
+       /* Free turn */
        p_ptr->energy_use = 100;
 
 
@@ -5256,7 +5216,7 @@ void do_cmd_store(void)
        /* Allow expanding macros */
        get_com_no_macros = FALSE;
 
-       /* Flush messages XXX XXX XXX */
+       /* Flush messages */
        msg_print(NULL);
 
 
@@ -5274,7 +5234,6 @@ void do_cmd_store(void)
        /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
 
-       /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 }
 
@@ -5332,7 +5291,6 @@ void store_shuffle(int which)
        {
                object_type *o_ptr;
 
-               /* Get the item */
                o_ptr = &st_ptr->stock[i];
 
                if (!object_is_artifact(o_ptr))
@@ -5344,11 +5302,7 @@ void store_shuffle(int which)
                        o_ptr->ident &= ~(IDENT_FIXED);
 
                        /* Mega-Hack -- Note that the item is "on sale" */
-#ifdef JP
-                       o_ptr->inscription = quark_add("売出中");
-#else
-                       o_ptr->inscription = quark_add("on sale");
-#endif
+                       o_ptr->inscription = quark_add(_("売出中", "on sale"));
                }
        }
 }
@@ -5363,7 +5317,7 @@ void store_shuffle(int which)
  */
 void store_maint(int town_num, int store_num)
 {
-       int             j;
+       INVENTORY_IDX j;
 
        cur_store_num = store_num;