OSDN Git Service

[Refactor] #38997 IS_INVULN() に player_type * 引数を追加. / Add player_type * argument...
[hengband/hengband.git] / src / store.c
index 514cff9..da42430 100644 (file)
@@ -29,6 +29,7 @@
 #include "rumor.h"
 #include "player-status.h"
 #include "player-class.h"
+#include "player-inventory.h"
 #include "object-flavor.h"
 #include "object-hook.h"
 #include "floor-events.h"
@@ -1892,8 +1893,8 @@ static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
        if ((value <= 0) && (price > value))
        {
                msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
-               chg_virtue(V_HONOUR, -1);
-               chg_virtue(V_JUSTICE, -1);
+               chg_virtue(p_ptr, V_HONOUR, -1);
+               chg_virtue(p_ptr, V_JUSTICE, -1);
                sound(SOUND_STORE1);
        }
 
@@ -1901,8 +1902,8 @@ static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
        else if ((value < guess) && (price > value))
        {
                msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
-               chg_virtue(V_JUSTICE, -1);
-               if (one_in_(4)) chg_virtue(V_HONOUR, -1);
+               chg_virtue(p_ptr, V_JUSTICE, -1);
+               if (one_in_(4)) chg_virtue(p_ptr, V_HONOUR, -1);
                sound(SOUND_STORE2);
        }
 
@@ -1910,8 +1911,8 @@ static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
        else if ((value > guess) && (value < (4 * guess)) && (price < value))
        {
                msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
-               if (one_in_(4)) chg_virtue(V_HONOUR, -1);
-               else if (one_in_(4)) chg_virtue(V_HONOUR, 1);
+               if (one_in_(4)) chg_virtue(p_ptr, V_HONOUR, -1);
+               else if (one_in_(4)) chg_virtue(p_ptr, V_HONOUR, 1);
                sound(SOUND_STORE3);
        }
 
@@ -1919,9 +1920,9 @@ static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
        else if ((value > guess) && (price < value))
        {
                msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
-               if (one_in_(2)) chg_virtue(V_HONOUR, -1);
-               if (one_in_(4)) chg_virtue(V_HONOUR, 1);
-               if (10 * price < value) chg_virtue(V_SACRIFICE, 1);
+               if (one_in_(2)) chg_virtue(p_ptr, V_HONOUR, -1);
+               if (one_in_(4)) chg_virtue(p_ptr, V_HONOUR, 1);
+               if (10 * price < value) chg_virtue(p_ptr, V_SACRIFICE, 1);
                sound(SOUND_STORE4);
        }
 }
@@ -3015,7 +3016,7 @@ bool combine_and_reorder_home(int store_num)
 
 /*!
  * @brief 我が家にオブジェクトを加える /
- * Add the item "o_ptr" to the p_ptr->inventory_list of the "Home"
+ * Add the item "o_ptr" to the inventory of the "Home"
  * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
  * @return 収めた先のID
  * @details
@@ -3109,7 +3110,7 @@ static int home_carry(object_type *o_ptr)
        /* Insert the new item */
        st_ptr->stock[slot] = *o_ptr;
 
-       chg_virtue(V_SACRIFICE, -1);
+       chg_virtue(p_ptr, V_SACRIFICE, -1);
 
        (void)combine_and_reorder_home(cur_store_num);
 
@@ -3120,7 +3121,7 @@ static int home_carry(object_type *o_ptr)
 
 /*!
  * @brief 店舗にオブジェクトを加える /
- * Add the item "o_ptr" to a real stores p_ptr->inventory_list.
+ * Add the item "o_ptr" to a real stores inventory.
  * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
  * @return 収めた先のID
  * @details
@@ -3225,7 +3226,7 @@ static int store_carry(object_type *o_ptr)
 
 /*!
  * @brief 店舗のオブジェクト数を増やす /
- * Add the item "o_ptr" to a real stores p_ptr->inventory_list.
+ * Add the item "o_ptr" to a real stores inventory.
  * @param item 増やしたいアイテムのID
  * @param num 増やしたい数
  * @return なし
@@ -3684,7 +3685,7 @@ static void display_entry(int pos)
 
 /*!
  * @brief 店の商品リストを表示する /
- * Displays a store's p_ptr->inventory_list            -RAK-
+ * Displays a store's inventory -RAK-
  * @return なし
  * @details
  * All prices are listed as "per individual object".  -BEN-
@@ -3829,8 +3830,6 @@ static void display_store(void)
 
        /* Display the current gold */
        store_prt_gold();
-
-       /* Draw in the p_ptr->inventory_list */
        display_inventory();
 }
 
@@ -4708,9 +4707,9 @@ static void store_purchase(void)
                                say_comment_1();
 
                                if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
-                                       chg_virtue(V_JUSTICE, -1);
+                                       chg_virtue(p_ptr, V_JUSTICE, -1);
                                if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
-                                       chg_virtue(V_NATURE, -1);
+                                       chg_virtue(p_ptr, V_NATURE, -1);
 
                                /* Make a sound */
                                sound(SOUND_BUY);
@@ -4738,10 +4737,10 @@ static void store_purchase(void)
                                strcpy(record_o_name, o_name);
                                record_turn = current_world_ptr->game_turn;
 
-                               if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
+                               if (record_buy) exe_write_diary(p_ptr, NIKKI_BUY, 0, o_name);
                                object_desc(o_name, o_ptr, OD_NAME_ONLY);
                                if(record_rand_art && o_ptr->art_name)
-                                       do_cmd_write_nikki(NIKKI_ART, 0, o_name);
+                                       exe_write_diary(p_ptr, NIKKI_ART, 0, o_name);
 
                                /* Erase the inscription */
                                j_ptr->inscription = 0;
@@ -4800,7 +4799,6 @@ static void store_purchase(void)
                                                msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
                                        }
 
-                                       /* New p_ptr->inventory_list */
                                        for (i = 0; i < 10; i++)
                                        {
                                                /* Maintain the store */
@@ -4882,7 +4880,7 @@ static void store_purchase(void)
                        else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
                        display_inventory();
 
-                       chg_virtue(V_SACRIFICE, 1);
+                       chg_virtue(p_ptr, V_SACRIFICE, 1);
                }
        }
 
@@ -4941,7 +4939,7 @@ static void store_sell(void)
                s = _("欲しい物がないですねえ。", "You have nothing that I want.");
        }
 
-       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
+       o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0);
        if (!o_ptr) return;
 
        /* Hack -- Cannot remove cursed items */
@@ -5027,10 +5025,10 @@ static void store_sell(void)
 
                        /* Be happy */
                        if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
-                               chg_virtue(V_JUSTICE, -1);
+                               chg_virtue(p_ptr, V_JUSTICE, -1);
 
                        if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
-                               chg_virtue(V_NATURE, 1);
+                               chg_virtue(p_ptr, V_NATURE, 1);
                        decrease_insults();
 
                        /* Get some money */
@@ -5042,7 +5040,7 @@ static void store_sell(void)
                        /* Get the "apparent" value */
                        dummy = object_value(q_ptr) * q_ptr->number;
 
-                       identify_item(o_ptr);
+                       identify_item(p_ptr, o_ptr);
                        q_ptr = &forge;
 
                        /* Get a copy of the object */
@@ -5072,7 +5070,7 @@ static void store_sell(void)
                        /* Describe the result (in message buffer) */
                        msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
 
-                       if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
+                       if (record_sell) exe_write_diary(p_ptr, NIKKI_SELL, 0, o_name);
 
                        if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
                        {
@@ -5129,7 +5127,7 @@ static void store_sell(void)
 
                if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
 
-               identify_item(q_ptr);
+               identify_item(p_ptr, q_ptr);
                q_ptr->ident |= IDENT_MENTAL;
 
                /* Distribute charges of wands/rods */
@@ -5137,10 +5135,7 @@ static void store_sell(void)
                msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
                choice = 0;
 
-               /* Take it from the players p_ptr->inventory_list */
-               inven_item_increase(item, -amt);
-               inven_item_describe(item);
-               inven_item_optimize(item);
+               vary_item(item, -amt);
                handle_stuff();
 
                /* Let the home carry it */
@@ -5162,10 +5157,7 @@ static void store_sell(void)
 
                choice = 0;
 
-               /* Take it from the players p_ptr->inventory_list */
-               inven_item_increase(item, -amt);
-               inven_item_describe(item);
-               inven_item_optimize(item);
+               vary_item(item, -amt);
                handle_stuff();
 
                /* Let the home carry it */
@@ -5181,8 +5173,8 @@ static void store_sell(void)
 
        if ((choice == 0) && (item >= INVEN_RARM))
        {
-               calc_android_exp();
-               kamaenaoshi(item);
+               calc_android_exp(p_ptr);
+               verify_equip_slot(p_ptr, item);
        }
 }
 
@@ -5321,6 +5313,7 @@ static bool leave_store = FALSE;
 /*!
  * @brief 店舗処理コマンド選択のメインルーチン /
  * Process a command in a store
+ * @param client_ptr 顧客となるクリーチャーの参照ポインタ
  * @return なし
  * @note
  * <pre>
@@ -5330,7 +5323,7 @@ static bool leave_store = FALSE;
  * but not in the stores, to prevent chaos.
  * </pre>
  */
-static void store_process_command(void)
+static void store_process_command(player_type *client_ptr)
 {
        /* Handle repeating the last command */
        repeat_check();
@@ -5355,7 +5348,7 @@ static void store_process_command(void)
                case '-':
                {
                        if (st_ptr->stock_num <= store_bottom) {
-                               msg_print(_("これで全部です。", "Entire p_ptr->inventory_list is shown."));
+                               msg_print(_("これで全部です。", "Entire client_ptr->inventory_list is shown."));
                        }
                        else{
                                store_top -= store_bottom;
@@ -5373,7 +5366,7 @@ static void store_process_command(void)
                {
                        if (st_ptr->stock_num <= store_bottom)
                        {
-                               msg_print(_("これで全部です。", "Entire p_ptr->inventory_list is shown."));
+                               msg_print(_("これで全部です。", "Entire client_ptr->inventory_list is shown."));
                        }
                        else
                        {
@@ -5403,7 +5396,7 @@ static void store_process_command(void)
 
                case KTRL('R'):
                {
-                       do_cmd_redraw();
+                       do_cmd_redraw(client_ptr);
                        display_store();
                        break;
                }
@@ -5440,35 +5433,35 @@ static void store_process_command(void)
                /* Wear/wield equipment */
                case 'w':
                {
-                       do_cmd_wield();
+                       do_cmd_wield(client_ptr);
                        break;
                }
 
                /* Take off equipment */
                case 't':
                {
-                       do_cmd_takeoff();
+                       do_cmd_takeoff(client_ptr);
                        break;
                }
 
                /* Destroy an item */
                case 'k':
                {
-                       do_cmd_destroy();
+                       do_cmd_destroy(client_ptr);
                        break;
                }
 
                /* Equipment list */
                case 'e':
                {
-                       do_cmd_equip();
+                       do_cmd_equip(client_ptr);
                        break;
                }
 
                /* Inventory list */
                case 'i':
                {
-                       do_cmd_inven();
+                       do_cmd_inven(client_ptr);
                        break;
                }
 
@@ -5478,14 +5471,13 @@ static void store_process_command(void)
                /* Identify an object */
                case 'I':
                {
-                       do_cmd_observe();
+                       do_cmd_observe(client_ptr);
                        break;
                }
 
-               /* Hack -- toggle windows */
                case KTRL('I'):
                {
-                       toggle_inven_equip();
+                       toggle_inven_equip(client_ptr);
                        break;
                }
 
@@ -5494,32 +5486,32 @@ static void store_process_command(void)
                /* Browse a book */
                case 'b':
                {
-                       if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
-                            (p_ptr->pclass == CLASS_BERSERKER) ||
-                            (p_ptr->pclass == CLASS_NINJA) ||
-                            (p_ptr->pclass == CLASS_MIRROR_MASTER) 
+                       if ( (client_ptr->pclass == CLASS_MINDCRAFTER) ||
+                            (client_ptr->pclass == CLASS_BERSERKER) ||
+                            (client_ptr->pclass == CLASS_NINJA) ||
+                            (client_ptr->pclass == CLASS_MIRROR_MASTER) 
                             ) do_cmd_mind_browse();
-                       else if (p_ptr->pclass == CLASS_SMITH)
-                               do_cmd_kaji(TRUE);
-                       else if (p_ptr->pclass == CLASS_MAGIC_EATER)
-                               do_cmd_magic_eater(TRUE, FALSE);
-                       else if (p_ptr->pclass == CLASS_SNIPER)
-                               do_cmd_snipe_browse();
-                       else do_cmd_browse();
+                       else if (client_ptr->pclass == CLASS_SMITH)
+                               do_cmd_kaji(client_ptr, TRUE);
+                       else if (client_ptr->pclass == CLASS_MAGIC_EATER)
+                               do_cmd_magic_eater(client_ptr, TRUE, FALSE);
+                       else if (client_ptr->pclass == CLASS_SNIPER)
+                               do_cmd_snipe_browse(client_ptr);
+                       else do_cmd_browse(client_ptr);
                        break;
                }
 
                /* Inscribe an object */
                case '{':
                {
-                       do_cmd_inscribe();
+                       do_cmd_inscribe(client_ptr);
                        break;
                }
 
                /* Uninscribe an object */
                case '}':
                {
-                       do_cmd_uninscribe();
+                       do_cmd_uninscribe(client_ptr);
                        break;
                }
 
@@ -5544,9 +5536,9 @@ static void store_process_command(void)
                /* Character description */
                case 'C':
                {
-                       p_ptr->town_num = old_town_num;
-                       do_cmd_player_status();
-                       p_ptr->town_num = inner_town_num;
+                       client_ptr->town_num = old_town_num;
+                       do_cmd_player_status(client_ptr);
+                       client_ptr->town_num = inner_town_num;
                        display_store();
                        break;
                }
@@ -5564,36 +5556,36 @@ static void store_process_command(void)
                /* Single line from a pref file */
                case '"':
                {
-                       p_ptr->town_num = old_town_num;
+                       client_ptr->town_num = old_town_num;
                        do_cmd_pref();
-                       p_ptr->town_num = inner_town_num;
+                       client_ptr->town_num = inner_town_num;
                        break;
                }
 
                /* Interact with macros */
                case '@':
                {
-                       p_ptr->town_num = old_town_num;
-                       do_cmd_macros();
-                       p_ptr->town_num = inner_town_num;
+                       client_ptr->town_num = old_town_num;
+                       do_cmd_macros(client_ptr);
+                       client_ptr->town_num = inner_town_num;
                        break;
                }
 
                /* Interact with visuals */
                case '%':
                {
-                       p_ptr->town_num = old_town_num;
-                       do_cmd_visuals();
-                       p_ptr->town_num = inner_town_num;
+                       client_ptr->town_num = old_town_num;
+                       do_cmd_visuals(client_ptr);
+                       client_ptr->town_num = inner_town_num;
                        break;
                }
 
                /* Interact with colors */
                case '&':
                {
-                       p_ptr->town_num = old_town_num;
-                       do_cmd_colors();
-                       p_ptr->town_num = inner_town_num;
+                       client_ptr->town_num = old_town_num;
+                       do_cmd_colors(client_ptr);
+                       client_ptr->town_num = inner_town_num;
                        break;
                }
 
@@ -5602,7 +5594,7 @@ static void store_process_command(void)
                {
                        do_cmd_options();
                        (void)combine_and_reorder_home(STORE_HOME);
-                       do_cmd_redraw();
+                       do_cmd_redraw(client_ptr);
                        display_store();
                        break;
                }
@@ -5626,7 +5618,7 @@ static void store_process_command(void)
                /* Repeat level feeling */
                case KTRL('F'):
                {
-                       do_cmd_feeling();
+                       do_cmd_feeling(client_ptr);
                        break;
                }
 
@@ -5719,7 +5711,7 @@ void do_cmd_store(void)
        store_bottom = MIN_STOCK + xtra_stock;
 
        /* Access the player grid */
-       g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
+       g_ptr = &p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
 
        /* Verify a store */
        if (!cave_have_flag_grid(g_ptr, FF_STORE))
@@ -5733,7 +5725,7 @@ void do_cmd_store(void)
 
        old_town_num = p_ptr->town_num;
        if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
-       if (current_floor_ptr->dun_level) p_ptr->town_num = NO_TOWN;
+       if (p_ptr->current_floor_ptr->dun_level) p_ptr->town_num = NO_TOWN;
        inner_town_num = p_ptr->town_num;
 
        /* Hack -- Check the "locked doors" */
@@ -5761,8 +5753,8 @@ void do_cmd_store(void)
                town_info[p_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
        }
 
-       forget_lite();
-       forget_view();
+       forget_lite(p_ptr->current_floor_ptr);
+       forget_view(p_ptr->current_floor_ptr);
 
        /* Hack -- Character is in "icky" mode */
        current_world_ptr->character_icky = TRUE;
@@ -5800,8 +5792,6 @@ void do_cmd_store(void)
        {
                /* Hack -- Clear line 1 */
                prt("", 1, 0);
-
-               /* Clear */
                clear_from(20 + xtra_stock);
 
                /* Basic commands */
@@ -5856,7 +5846,7 @@ void do_cmd_store(void)
                request_command(TRUE);
 
                /* Process the command */
-               store_process_command();
+               store_process_command(p_ptr);
 
                /*
                 * Hack -- To redraw missiles damage and prices in store
@@ -5916,10 +5906,7 @@ void do_cmd_store(void)
 
                                msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
 
-                               /* Remove it from the players p_ptr->inventory_list */
-                               inven_item_increase(item, -255);
-                               inven_item_describe(item);
-                               inven_item_optimize(item);
+                               vary_item(item, -255);
                                handle_stuff();
 
                                /* Let the home carry it */
@@ -5942,7 +5929,7 @@ void do_cmd_store(void)
                if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
        }
 
-       select_floor_music();
+       select_floor_music(p_ptr);
 
        p_ptr->town_num = old_town_num;
 
@@ -6046,7 +6033,7 @@ void store_shuffle(int which)
 
 /*!
  * @brief 店の品揃えを変化させる /
- * Maintain the p_ptr->inventory_list at the stores.
+ * Maintain the inventory at the stores.
  * @param town_num 町のID
  * @param store_num 店舗種類のID
  * @return なし