OSDN Git Service

Implementing MCI command for BGM playing.
[hengband/hengband.git] / src / store.c
index 4ee37b6..ed1b998 100644 (file)
@@ -1,25 +1,27 @@
-/* File: store.c */
-
-/* Purpose: Store commands */
-
-/*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
- *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+/*!
+ * @file store.c
+ * @brief Å¹¤Î½èÍý / Store commands
+ * @date 2014/02/02
+ * @author
+ * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
+ * This software may be copied and distributed for educational, research, and\n
+ * not for profit purposes provided that this copyright and statement are\n
+ * included in all such copies.\n
+ * 2014 Deskull rearranged comment for Doxygen.
  */
 
 #include "angband.h"
 
+#define MIN_STOCK 12
 
-#ifdef JP
-/* ²¼¤ÎÊý¤«¤é°ÜÆ°¤·¤Æ¤­¤Þ¤·¤¿ */
 static int cur_store_num = 0;
 static int store_top = 0;
+static int store_bottom = 0;
+static int xtra_stock = 0;
 static store_type *st_ptr = NULL;
-static owner_type *ot_ptr = NULL;
-#endif
+static const owner_type *ot_ptr = NULL;
+static s16b old_town_num = 0;
+static s16b inner_town_num = 0;
 #define RUMOR_CHANCE 8
 
 #define MAX_COMMENT_1  6
@@ -45,7 +47,7 @@ static cptr comment_1[MAX_COMMENT_1] =
 };
 
 #ifdef JP
-/* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÄɲåá¥Ã¥»¡¼¥¸¡Ê¾µÂú¡Ë */
+/*! ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÄɲåá¥Ã¥»¡¼¥¸¡Ê¾µÂú¡Ë */
 static cptr comment_1_B[MAX_COMMENT_1] = {
        "¤Þ¤¢¡¢¤½¤ì¤Ç¤¤¤¤¤ä¡£",
        "º£Æü¤Ï¤½¤ì¤Ç´ªÊÛ¤·¤Æ¤ä¤ë¡£",
@@ -104,7 +106,7 @@ static cptr comment_2b[MAX_COMMENT_2B] =
 };
 
 #ifdef JP
-/* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇä¤ë¤È¤­¡Ë */
+/*! ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇä¤ë¤È¤­¡Ë */
 static cptr comment_2b_B[MAX_COMMENT_2B] = {
        "¤¤¤¯¤é²¶Íͤ¬¤ª¿Í¹¥¤·¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¤Í¡£·ù¤Ê¤éµ¢¤ê¤Ê¡£",
        "¶â¤¬¤Ê¤¤¤Î¤«¤¤¡¢¤¢¤ó¤¿¡©¤Þ¤º¤Ï²È¤Ëµ¢¤Ã¤Æ $%s Â·¤¨¤Æ¤­¤Ê¡£",
@@ -170,7 +172,7 @@ static cptr comment_3b[MAX_COMMENT_3B] =
 };
 
 #ifdef JP
-/* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇ㤤¼è¤ê¡Ë */
+/*! ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇ㤤¼è¤ê¡Ë */
 static cptr comment_3b_B[MAX_COMMENT_3B] = {
        " $%s ¤Ã¤Æ¤È¤³¤í¤À¤Í¡£¤½¤Î¤É¤¦¤·¤è¤¦¤â¤Ê¤¤¥¬¥é¥¯¥¿¤Ï¡£",
        "¤³¤Î²¶¤¬ $%s ¤Ã¤Æ¸À¤Ã¤Æ¤¤¤ë¤ó¤À¤«¤é¡¢¤½¤ÎÄ̤ê¤Ë¤·¤¿Êý¤¬¿È¤Î¤¿¤á¤À¤¾¡£",
@@ -205,7 +207,7 @@ static cptr comment_4a[MAX_COMMENT_4A] =
 };
 
 #ifdef JP
-/* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¤ÎĺÅÀ¡Ë */
+/*! ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¤ÎĺÅÀ¡Ë */
 static cptr comment_4a_B[MAX_COMMENT_4A] = {
        "¤Ê¤á¤ä¤¬¤Ã¤Æ¡ª²¹¸ü¤Ê²¶ÍͤǤâ¸Â³¦¤¬¤¢¤ë¤Ã¤Æ¤³¤È¤òÃΤ졪",
        "²¶¤ò¤³¤³¤Þ¤ÇÅܤ餻¤Æ...Ì¿¤¬¤¢¤ë¤À¤±¤Ç¤â¤¢¤ê¤¬¤¿¤¤¤È»×¤¨¡ª",
@@ -232,7 +234,7 @@ static cptr comment_4b[MAX_COMMENT_4B] =
 };
 
 #ifdef JP
-/* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÄɤ¤½Ð¤·¡Ë */
+/*! ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÄɤ¤½Ð¤·¡Ë */
 static cptr comment_4b_B[MAX_COMMENT_4B] = {
        "ÆóÅ٤Ȥ¦¤Á¤ËÍè¤ë¤ó¤¸¤ã¤Í¤¨¡ª¡ª",
        "¤È¤Ã¤È¤È¡¢¤É¤Ã¤«¤Ø¼º¤»¤í¡ª¡ª",
@@ -267,7 +269,7 @@ static cptr comment_5[MAX_COMMENT_5] =
 };
 
 #ifdef JP
-/* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¡Ë */
+/*! ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¡Ë */
 static cptr comment_5_B[MAX_COMMENT_5] = {
        "»þ´Ö¤Î̵Â̤À¤Ê¡¢¤³¤ì¤Ï¡£",
        "Ìñ²ð¤Ê¤ªµÒÍͤÀ¤Ê¡ª",
@@ -299,21 +301,21 @@ static cptr comment_6[MAX_COMMENT_6] =
 
 
 
-/*
+/*!
+ * @brief ¼è°úÀ®¸ù»þ¤ÎŹ¼ç¤Î¥á¥Ã¥»¡¼¥¸½èÍý /
  * Successful haggle.
+ * @return ¤Ê¤·
  */
 static void say_comment_1(void)
 {
-       char rumour[1024];
-
 #ifdef JP
-        /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤­¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
-        if ( cur_store_num == STORE_BLACK ) {
-                msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
-        }
-        else{
-                msg_print(comment_1[randint0(MAX_COMMENT_1)]);
-        }
+       /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤­¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
+       if ( cur_store_num == STORE_BLACK ) {
+               msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
+       }
+       else{
+               msg_print(comment_1[randint0(MAX_COMMENT_1)]);
+       }
 #else
        msg_print(comment_1[randint0(MAX_COMMENT_1)]);
 #endif
@@ -322,25 +324,21 @@ static void say_comment_1(void)
        if (one_in_(RUMOR_CHANCE))
        {
 #ifdef JP
-msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
+               msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
 #else
                msg_print("The shopkeeper whispers something into your ear:");
 #endif
-
-
-#ifdef JP
-if (!get_rnd_line_jonly("rumors_j.txt", 0, rumour, 10))
-#else
-               if (!get_rnd_line("rumors.txt", 0, rumour))
-#endif
-
-                       msg_print(rumour);
+               display_rumor(TRUE);
        }
 }
 
 
-/*
+/*!
+ * @brief ¥×¥ì¥¤¥ä¡¼¤¬¥¢¥¤¥Æ¥à¤òÇ㤦»þ¤Î²Á³ÊÂå°Æ¥á¥Ã¥»¡¼¥¸½èÍý /
  * Continue haggling (player is buying)
+ * @param value Å¹¼ç¤ÎÄ󼨲Á³Ê
+ * @param annoyed Å¹¼ç¤Î¤¤¤é¤Ä¤­ÅÙ
+ * @return ¤Ê¤·
  */
 static void say_comment_2(s32b value, int annoyed)
 {
@@ -376,8 +374,12 @@ static void say_comment_2(s32b value, int annoyed)
 }
 
 
-/*
+/*!
+ * @brief ¥×¥ì¥¤¥ä¡¼¤¬¥¢¥¤¥Æ¥à¤òÇä¤ë»þ¤Î²Á³ÊÂå°Æ¥á¥Ã¥»¡¼¥¸½èÍý /
  * Continue haggling (player is selling)
+ * @param value Å¹¼ç¤ÎÄ󼨲Á³Ê
+ * @param annoyed Å¹¼ç¤Î¤¤¤é¤Ä¤­ÅÙ
+ * @return ¤Ê¤·
  */
 static void say_comment_3(s32b value, int annoyed)
 {
@@ -413,21 +415,23 @@ static void say_comment_3(s32b value, int annoyed)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤¬¥×¥ì¥¤¥ä¡¼¤òÄɤ¤½Ð¤¹»þ¤Î¥á¥Ã¥»¡¼¥¸½èÍý /
  * Kick 'da bum out.                                   -RAK-
+ * @return ¤Ê¤·
  */
 static void say_comment_4(void)
 {
 #ifdef JP
-        /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
-        if ( cur_store_num == STORE_BLACK ){
-                msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
-                msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
-        }
-        else{
-                msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
-                msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
-        }
+       /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
+       if ( cur_store_num == STORE_BLACK ){
+               msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
+               msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
+       }
+       else{
+               msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
+               msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
+       }
 #else
        msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
        msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
@@ -436,19 +440,21 @@ static void say_comment_4(void)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤¬¥×¥ì¥¤¥ä¡¼¤Ë¼è¤ê¹ç¤ï¤Ê¤¤»þ¤Î¥á¥Ã¥»¡¼¥¸½èÍý /
  * You are insulting me
+ * @return ¤Ê¤·
  */
 static void say_comment_5(void)
 {
 #ifdef JP
-        /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
-        if ( cur_store_num == STORE_BLACK ){
-                msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
-        }
-        else{
-                msg_print(comment_5[randint0(MAX_COMMENT_5)]);
-        }
+       /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
+       if ( cur_store_num == STORE_BLACK ){
+               msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
+       }
+       else{
+               msg_print(comment_5[randint0(MAX_COMMENT_5)]);
+       }
 #else
        msg_print(comment_5[randint0(MAX_COMMENT_5)]);
 #endif
@@ -456,8 +462,10 @@ static void say_comment_5(void)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤¬¥×¥ì¥¤¥ä¡¼¤ÎÄ󼨤òÍý²ò¤Ç¤­¤Ê¤«¤Ã¤¿»þ¤Î¥á¥Ã¥»¡¼¥¸½èÍý /
  * That makes no sense.
+ * @return ¤Ê¤·
  */
 static void say_comment_6(void)
 {
@@ -465,11 +473,6 @@ static void say_comment_6(void)
 }
 
 
-
-/*
- * Messages for reacting to purchase prices.
- */
-
 #define MAX_COMMENT_7A 4
 
 static cptr comment_7a[MAX_COMMENT_7A] =
@@ -543,9 +546,14 @@ static cptr comment_7d[MAX_COMMENT_7D] =
 };
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤¬¸ò¾Ä¤ò½ª¤¨¤¿ºÝ¤ÎÈ¿±þ¤òÊÖ¤¹½èÍý /
  * Let a shop-keeper React to a purchase
- *
+ * @param price ¥¢¥¤¥Æ¥à¤Î¼è°ú³Û
+ * @param value ¥¢¥¤¥Æ¥à¤Î¼ÂºÝ²ÁÃÍ
+ * @param guess Å¹¼ç¤¬Åö½éͽÁÛ¤·¤Æ¤¤¤¿²ÁÃÍ
+ * @return ¤Ê¤·
+ * @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)
@@ -613,36 +621,10 @@ static void purchase_analyze(s32b price, s32b value, s32b guess)
 
 
 
-
-
-#ifdef JP
-/* ÆüËܸìÈǤξì¹ç¤Ï¾å¤ÎÊý¤Ë°ÜÆ°¤·¤Æ¤¢¤ê¤Þ¤¹ */
-#else
 /*
- * We store the current "store number" here so everyone can access it
+ * We store the current "store feat" here so everyone can access it
  */
-static int cur_store_num = 7;
-
-/*
- * We store the current "store page" here so everyone can access it
- */
-static int store_top = 0;
-
-/*
- * We store the current "store pointer" here so everyone can access it
- */
-static store_type *st_ptr = NULL;
-
-/*
- * We store the current "owner type" here so everyone can access it
- */
-static owner_type *ot_ptr = NULL;
-#endif
-
-
-
-
-
+static int cur_store_feat;
 
 
 /*
@@ -654,7 +636,7 @@ static byte rgold_adj[MAX_RACES][MAX_RACES] =
        /*Hum, HfE, Elf,  Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
         HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
         Imp,  Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
-        Angel, Demon, Kuta*/
+        Angel, Demon, Kuta*/
 
        /* Human */
        { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
@@ -866,7 +848,7 @@ static byte rgold_adj[MAX_RACES][MAX_RACES] =
          110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
          110, 101, 115, 110 },
 
-       /* Kuta */
+       /* Kutar */
        { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
          115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
          115, 115, 125, 125, 125, 125, 105, 115, 105,  95, 140,
@@ -881,25 +863,27 @@ static byte rgold_adj[MAX_RACES][MAX_RACES] =
 
 
 
-
-/*
+/*!
+ * @brief Å¹ÊÞ²Á³Ê¤ò·èÄꤹ¤ë /
  * Determine the price of an item (qty one) in a store.
- *
+ * @param o_ptr Å¹ÊÞ¤Ëʤ٤륪¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
+ * @param greed Å¹¼ç¤Î¶¯ÍßÅÙ
+ * @param flip TRUE¤Ê¤é¤ÐŹ¼ç¤Ë¤È¤Ã¤Æ¤ÎÇã¼è²Á³Ê¡¢FALSE¤Ê¤éÇä½Ð²Á³Ê¤ò·×»»
+ * @return ¤Ê¤·
+ * @details 
+ * <pre>
  * This function takes into account the player's charisma, and the
  * shop-keepers friendliness, and the shop-keeper's base greed, but
  * never lets a shop-keeper lose money in a transaction.
- *
  * The "greed" value should exceed 100 when the player is "buying" the
  * item, and should be less than 100 when the player is "selling" it.
- *
  * Hack -- the black market always charges twice as much as it should.
- *
  * Charisma adjustment runs from 80 to 130
  * Racial adjustment runs from 95 to 130
- *
  * Since greed/charisma/racial adjustments are centered at 100, we need
  * to adjust (by 200) to extract a usable multiplier.  Note that the
  * "greed" value is always something (?).
+ * </pre>
  */
 static s32b price_item(object_type *o_ptr, int greed, bool flip)
 {
@@ -934,6 +918,10 @@ static s32b price_item(object_type *o_ptr, int greed, bool flip)
                /* Mega-Hack -- Black market sucks */
                if (cur_store_num == STORE_BLACK)
                        price = price / 2;
+
+               /* Compute the final price (with rounding) */
+               /* Hack -- prevent underflow */
+               price = (price * adjust + 50L) / 100L;
        }
 
        /* Shop is selling */
@@ -948,10 +936,11 @@ static s32b price_item(object_type *o_ptr, int greed, bool flip)
                /* Mega-Hack -- Black market sucks */
                if (cur_store_num == STORE_BLACK)
                        price = price * 2;
-       }
 
-       /* Compute the final price (with rounding) */
-       price = (price * adjust + 50L) / 100L;
+               /* Compute the final price (with rounding) */
+               /* Hack -- prevent overflow */
+               price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
+       }
 
        /* Note -- Never become "free" */
        if (price <= 0L) return (1L);
@@ -961,9 +950,15 @@ static s32b price_item(object_type *o_ptr, int greed, bool flip)
 }
 
 
-/*
+/*!
+ * @brief °Â²Á¤Ê¾ÃÌ×ÉʤÎÈÎÇä¿ô¤òÁý¤ä¤·¡¢Äã³ÎΨ¤Ç³ä°ú¤Ë¤¹¤ë /
  * Certain "cheap" objects should be created in "piles"
+ * @param o_ptr Å¹ÊÞ¤Ëʤ٤륪¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ¤Ê¤·
+ * @details 
+ * <pre>
  * Some objects can be sold at a "discount" (in small piles)
+ * </pre>
  */
 static void mass_produce(object_type *o_ptr)
 {
@@ -983,6 +978,7 @@ static void mass_produce(object_type *o_ptr)
                {
                        if (cost <= 5L) size += damroll(3, 5);
                        if (cost <= 20L) size += damroll(3, 5);
+                       if (cost <= 50L) size += damroll(2, 2);
                        break;
                }
 
@@ -1003,11 +999,12 @@ static void mass_produce(object_type *o_ptr)
                case TV_DEATH_BOOK:
                case TV_TRUMP_BOOK:
                case TV_ARCANE_BOOK:
-               case TV_ENCHANT_BOOK:
+               case TV_CRAFT_BOOK:
                case TV_DAEMON_BOOK:
                case TV_CRUSADE_BOOK:
                case TV_MUSIC_BOOK:
                case TV_HISSATSU_BOOK:
+               case TV_HEX_BOOK:
                {
                        if (cost <= 50L) size += damroll(2, 3);
                        if (cost <= 500L) size += damroll(1, 3);
@@ -1028,7 +1025,8 @@ static void mass_produce(object_type *o_ptr)
                case TV_DIGGING:
                case TV_BOW:
                {
-                       if (o_ptr->name2) break;
+                       if (object_is_artifact(o_ptr)) break;
+                       if (object_is_ego(o_ptr)) break;
                        if (cost <= 10L) size += damroll(3, 5);
                        if (cost <= 100L) size += damroll(3, 5);
                        break;
@@ -1074,12 +1072,6 @@ static void mass_produce(object_type *o_ptr)
                                if (cost < 1601L) size += damroll(1, 5);
                                else if (cost < 3201L) size += damroll(1, 3);
                        }
-
-                       /* 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 *= size;
-                       }
                        break;
                }
        }
@@ -1127,14 +1119,26 @@ msg_print("
 
        /* Save the total pile size */
        o_ptr->number = size - (size * discount / 100);
+
+       /* 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;
+       }
 }
 
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ¤Ëʤ٤¿ÉʤòƱ°ìÉʤǤ¢¤ë¤«¤É¤¦¤«È½Äꤹ¤ë /
  * Determine if a store item can "absorb" another item
- *
+ * @param o_ptr È½Äꤹ¤ë¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿1
+ * @param j_ptr È½Äꤹ¤ë¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿2
+ * @return Æ±°ì°·¤¤¤Ç¤­¤ë¤Ê¤éTRUE¤òÊÖ¤¹
+ * @details 
+ * <pre>
  * See "object_similar()" for the same function for the "player"
+ * </pre>
  */
 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
 {
@@ -1154,14 +1158,11 @@ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
        if (o_ptr->to_d != j_ptr->to_d) return (0);
        if (o_ptr->to_a != j_ptr->to_a) return (0);
 
-       /* Require identical "artifact" names */
-       if (o_ptr->name1 != j_ptr->name1) return (0);
-
        /* Require identical "ego-item" names */
        if (o_ptr->name2 != j_ptr->name2) return (0);
 
-       /* Random artifacts don't stack !*/
-       if (o_ptr->art_name || j_ptr->art_name) return (0);
+       /* Artifacts don't stack! */
+       if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
 
        /* Hack -- Identical art_flags! */
        for (i = 0; i < TR_FLAG_SIZE; i++)
@@ -1191,39 +1192,55 @@ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
 }
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ¤Ëʤ٤¿Éʤò½Å¤Í¹ç¤ï¤»¤Ç¤­¤ë¤«¤É¤¦¤«È½Äꤹ¤ë /
  * Allow a store item to absorb another item
+ * @param o_ptr È½Äꤹ¤ë¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿1
+ * @param j_ptr È½Äꤹ¤ë¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿2
+ * @return ½Å¤Í¹ç¤ï¤»¤Ç¤­¤ë¤Ê¤éTRUE¤òÊÖ¤¹
+ * @details 
+ * <pre>
+ * See "object_similar()" for the same function for the "player"
+ * </pre>
  */
 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
 {
+       int max_num = (o_ptr->tval == TV_ROD) ?
+               MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
        int total = o_ptr->number + j_ptr->number;
+       int diff = (total > max_num) ? total - max_num : 0;
 
        /* Combine quantity, lose excess items */
-       o_ptr->number = (total > 99) ? 99 : total;
+       o_ptr->number = (total > max_num) ? max_num : total;
 
        /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
        if (o_ptr->tval == TV_ROD)
        {
-               o_ptr->pval += j_ptr->pval;
+               o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
        }
 
        /* Hack -- if wands are stacking, combine the charges. -LM- */
        if (o_ptr->tval == TV_WAND)
        {
-               o_ptr->pval += j_ptr->pval;
+               o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
        }
 }
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ¤ËÉʤòÃÖ¤¯¥¹¥Ú¡¼¥¹¤¬¤¢¤ë¤«¤É¤¦¤«¤ÎȽÄê¤òÊÖ¤¹ /
  * Check to see if the shop will be carrying too many objects  -RAK-
+ * @param o_ptr Å¹ÊÞ¤ËÃÖ¤­¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ÃÖ¤­¾ì¤¬¤Ê¤¤¤Ê¤é0¡¢½Å¤Í¹ç¤ï¤»¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ë¤Ê¤é-1¡¢¥¹¥Ú¡¼¥¹¤¬¤¢¤ë¤Ê¤é1¤òÊÖ¤¹¡£
+ * @details 
+ * <pre>
  * Note that the shop, just like a player, will not accept things
  * it cannot hold.     Before, one could "nuke" potions this way.
- *
  * Return value is now int:
  *  0 : No space
  * -1 : Can be combined to existing slot.
  *  1 : Cannot be combined but there are empty spaces.
+ * </pre>
  */
 static int store_check_num(object_type *o_ptr)
 {
@@ -1233,6 +1250,15 @@ static int store_check_num(object_type *o_ptr)
        /* The "home" acts like the player */
        if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
        {
+               bool old_stack_force_notes = stack_force_notes;
+               bool old_stack_force_costs = stack_force_costs;
+
+               if (cur_store_num != STORE_HOME)
+               {
+                       stack_force_notes = FALSE;
+                       stack_force_costs = FALSE;
+               }
+
                /* Check all the items */
                for (i = 0; i < st_ptr->stock_num; i++)
                {
@@ -1240,7 +1266,22 @@ static int store_check_num(object_type *o_ptr)
                        j_ptr = &st_ptr->stock[i];
 
                        /* Can the new object be combined with the old one? */
-                       if (object_similar(j_ptr, o_ptr)) return -1;
+                       if (object_similar(j_ptr, o_ptr))
+                       {
+                               if (cur_store_num != STORE_HOME)
+                               {
+                                       stack_force_notes = old_stack_force_notes;
+                                       stack_force_costs = old_stack_force_costs;
+                               }
+
+                               return -1;
+                       }
+               }
+
+               if (cur_store_num != STORE_HOME)
+               {
+                       stack_force_notes = old_stack_force_notes;
+                       stack_force_costs = old_stack_force_costs;
                }
        }
 
@@ -1278,7 +1319,11 @@ static int store_check_num(object_type *o_ptr)
        return 0;
 }
 
-
+/*!
+ * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¤«¤ÎȽÄê¤òÊÖ¤¹ /
+ * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ¥¢¥¤¥Æ¥à¤¬½ËÊ¡¤µ¤ì¤¿¥¢¥¤¥Æ¥à¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
+ */
 static bool is_blessed(object_type *o_ptr)
 {
        u32b flgs[TR_FLAG_SIZE];
@@ -1289,9 +1334,12 @@ static bool is_blessed(object_type *o_ptr)
 
 
 
-/*
+/*!
+ * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬½êÄê¤ÎŹÊޤǰú¤­¼è¤ì¤ë¤«¤É¤¦¤«¤òÊÖ¤¹ /
  * Determine if the current store will purchase the given item
- *
+ * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ¥¢¥¤¥Æ¥à¤¬Ç㤤¼è¤ì¤ë¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
+ * @note
  * Note that a shop-keeper must refuse to buy "worthless" items
  */
 static bool store_will_buy(object_type *o_ptr)
@@ -1308,6 +1356,9 @@ static bool store_will_buy(object_type *o_ptr)
                        /* Analyze the type */
                        switch (o_ptr->tval)
                        {
+                               case TV_POTION:
+                                       if (o_ptr->sval != SV_POTION_WATER) return FALSE;
+
                                case TV_WHISTLE:
                                case TV_FOOD:
                                case TV_LITE:
@@ -1407,7 +1458,7 @@ static bool store_will_buy(object_type *o_ptr)
                                                if (r_ptr->flags3 & RF3_ANIMAL) break;
 
                                                /* Accept mimics */
-                                               if (strchr("?!", r_ptr->d_char)) break;
+                                               if (my_strchr("?!", r_ptr->d_char)) break;
                                        }
                                }
                                case TV_POLEARM:
@@ -1448,9 +1499,10 @@ static bool store_will_buy(object_type *o_ptr)
                                case TV_DEATH_BOOK:
                                case TV_TRUMP_BOOK:
                                case TV_ARCANE_BOOK:
-                               case TV_ENCHANT_BOOK:
+                               case TV_CRAFT_BOOK:
                                case TV_DAEMON_BOOK:
                                case TV_MUSIC_BOOK:
+                               case TV_HEX_BOOK:
                                case TV_AMULET:
                                case TV_RING:
                                case TV_STAFF:
@@ -1483,10 +1535,11 @@ static bool store_will_buy(object_type *o_ptr)
                                case TV_LIFE_BOOK:
                                case TV_TRUMP_BOOK:
                                case TV_ARCANE_BOOK:
-                               case TV_ENCHANT_BOOK:
+                               case TV_CRAFT_BOOK:
                                case TV_DAEMON_BOOK:
                                case TV_CRUSADE_BOOK:
                                case TV_MUSIC_BOOK:
+                               case TV_HEX_BOOK:
                                        break;
                                default:
                                        return (FALSE);
@@ -1503,24 +1556,196 @@ static bool store_will_buy(object_type *o_ptr)
 }
 
 
+/*!
+ * @brief ¸½ºß¤ÎÄ®¤Î»ØÄꤵ¤ì¤¿Å¹ÊޤΥ¢¥¤¥Æ¥à¤òÀ°Íý¤¹¤ë /
+ * Combine and reorder items in store.
+ * @param store_num Å¹ÊÞID
+ * @return ¼ÂºÝ¤ËÀ°Íý¤¬¹Ô¤ï¤ì¤¿¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ */
+bool combine_and_reorder_home(int store_num)
+{
+       int         i, j, k;
+       s32b        o_value;
+       object_type forge, *o_ptr, *j_ptr;
+       bool        flag = FALSE, combined;
+       store_type  *old_st_ptr = st_ptr;
+       bool        old_stack_force_notes = stack_force_notes;
+       bool        old_stack_force_costs = stack_force_costs;
+
+       st_ptr = &town[1].store[store_num];
+       if (store_num != STORE_HOME)
+       {
+               stack_force_notes = FALSE;
+               stack_force_costs = FALSE;
+       }
+
+       do
+       {
+               combined = FALSE;
+
+               /* 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 */
+                       if (!o_ptr->k_idx) continue;
 
-/*
+                       /* Scan the items above that item */
+                       for (j = 0; j < i; j++)
+                       {
+                               int max_num;
+
+                               /* Get the item */
+                               j_ptr = &st_ptr->stock[j];
+
+                               /* Skip empty items */
+                               if (!j_ptr->k_idx) continue;
+
+                               /*
+                                * Get maximum number of the stack if these
+                                * are similar, get zero otherwise.
+                                */
+                               max_num = object_similar_part(j_ptr, o_ptr);
+
+                               /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
+                               if (max_num && j_ptr->number < max_num)
+                               {
+                                       if (o_ptr->number + j_ptr->number <= max_num)
+                                       {
+                                               /* Add together the item counts */
+                                               object_absorb(j_ptr, o_ptr);
+
+                                               /* One object is gone */
+                                               st_ptr->stock_num--;
+
+                                               /* Slide everything down */
+                                               for (k = i; k < st_ptr->stock_num; k++)
+                                               {
+                                                       /* Structure copy */
+                                                       st_ptr->stock[k] = st_ptr->stock[k + 1];
+                                               }
+
+                                               /* Erase the "final" slot */
+                                               object_wipe(&st_ptr->stock[k]);
+                                       }
+                                       else
+                                       {
+                                               int old_num = o_ptr->number;
+                                               int remain = j_ptr->number + o_ptr->number - max_num;
+
+                                               /* Add together the item counts */
+                                               object_absorb(j_ptr, o_ptr);
+
+                                               o_ptr->number = remain;
+
+                                               /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
+                                               if (o_ptr->tval == TV_ROD)
+                                               {
+                                                       o_ptr->pval =  o_ptr->pval * remain / old_num;
+                                                       o_ptr->timeout = o_ptr->timeout * remain / old_num;
+                                               }
+
+                                               /* Hack -- if wands are stacking, combine the charges. -LM- */
+                                               else if (o_ptr->tval == TV_WAND)
+                                               {
+                                                       o_ptr->pval = o_ptr->pval * remain / old_num;
+                                               }
+                                       }
+
+                                       /* Take note */
+                                       combined = TRUE;
+
+                                       /* Done */
+                                       break;
+                               }
+                       }
+               }
+
+               flag |= combined;
+       }
+       while (combined);
+
+       /* 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 */
+               if (!o_ptr->k_idx) continue;
+
+               /* Get the "value" of the item */
+               o_value = object_value(o_ptr);
+
+               /* Scan every occupied slot */
+               for (j = 0; j < st_ptr->stock_num; j++)
+               {
+                       if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
+               }
+
+               /* Never move down */
+               if (j >= i) continue;
+
+               /* Take note */
+               flag = TRUE;
+
+               /* Get local object */
+               j_ptr = &forge;
+
+               /* Save a copy of the moving item */
+               object_copy(j_ptr, &st_ptr->stock[i]);
+
+               /* Slide the objects */
+               for (k = i; k > j; k--)
+               {
+                       /* Slide the item */
+                       object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
+               }
+
+               /* Insert the moving item */
+               object_copy(&st_ptr->stock[j], j_ptr);
+       }
+
+       st_ptr = old_st_ptr;
+       if (store_num != STORE_HOME)
+       {
+               stack_force_notes = old_stack_force_notes;
+               stack_force_costs = old_stack_force_costs;
+       }
+
+       return flag;
+}
+
+
+/*!
+ * @brief ²æ¤¬²È¤Ë¥ª¥Ö¥¸¥§¥¯¥È¤ò²Ã¤¨¤ë /
  * Add the item "o_ptr" to the inventory of the "Home"
- *
+ * @param o_ptr ²Ã¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ¼ý¤á¤¿Àè¤ÎID
+ * @details
+ * <pre>
  * In all cases, return the slot (or -1) where the object was placed
- *
  * Note that this is a hacked up version of "inven_carry()".
- *
  * Also note that it may not correctly "adapt" to "knowledge" bacoming
  * known, the player may have to pick stuff up and drop it again.
+ * </pre>
  */
 static int home_carry(object_type *o_ptr)
 {
        int                             slot;
-       s32b                       value, j_value;
+       s32b                       value;
        int     i;
        object_type *j_ptr;
+       bool old_stack_force_notes = stack_force_notes;
+       bool old_stack_force_costs = stack_force_costs;
 
+       if (cur_store_num != STORE_HOME)
+       {
+               stack_force_notes = FALSE;
+               stack_force_costs = FALSE;
+       }
 
        /* Check each existing item (try to combine) */
        for (slot = 0; slot < st_ptr->stock_num; slot++)
@@ -1534,18 +1759,30 @@ static int home_carry(object_type *o_ptr)
                        /* Save the new number of items */
                        object_absorb(j_ptr, o_ptr);
 
+                       if (cur_store_num != STORE_HOME)
+                       {
+                               stack_force_notes = old_stack_force_notes;
+                               stack_force_costs = old_stack_force_costs;
+                       }
+
                        /* All done */
                        return (slot);
                }
        }
 
+       if (cur_store_num != STORE_HOME)
+       {
+               stack_force_notes = old_stack_force_notes;
+               stack_force_costs = old_stack_force_costs;
+       }
+
        /* No space? */
        /*
         * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
         *           ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
         */
        /* No space? */
-       if ( powerup_home == TRUE) {
+       if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
                if (st_ptr->stock_num >= st_ptr->stock_size) {
                        return (-1);
                }
@@ -1563,50 +1800,7 @@ static int home_carry(object_type *o_ptr)
        /* Check existing slots to see if we must "slide" */
        for (slot = 0; slot < st_ptr->stock_num; slot++)
        {
-               /* Get that item */
-               j_ptr = &st_ptr->stock[slot];
-
-               /* Hack -- readable books always come first */
-               if ((o_ptr->tval == mp_ptr->spell_book) &&
-                       (j_ptr->tval != mp_ptr->spell_book)) break;
-               if ((j_ptr->tval == mp_ptr->spell_book) &&
-                       (o_ptr->tval != mp_ptr->spell_book)) continue;
-
-               /* Objects sort by decreasing type */
-               if (o_ptr->tval > j_ptr->tval) break;
-               if (o_ptr->tval < j_ptr->tval) continue;
-
-               /* Can happen in the home */
-               if (!object_aware_p(o_ptr)) continue;
-               if (!object_aware_p(j_ptr)) break;
-
-               /* Objects sort by increasing sval */
-               if (o_ptr->sval < j_ptr->sval) break;
-               if (o_ptr->sval > j_ptr->sval) continue;
-
-               /* Objects in the home can be unknown */
-               if (!object_known_p(o_ptr)) continue;
-               if (!object_known_p(j_ptr)) break;
-
-               /*
-                * Hack:  otherwise identical rods sort by
-                * increasing recharge time --dsb
-                */
-               if (o_ptr->tval == TV_ROD)
-               {
-                       if (o_ptr->pval < j_ptr->pval) break;
-                       if (o_ptr->pval > j_ptr->pval) continue;
-               }
-               if ((o_ptr->tval == TV_CORPSE) || (o_ptr->tval == TV_FIGURINE) || (o_ptr->tval == TV_STATUE))
-               {
-                       if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) break;
-                       if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) break;
-               }
-
-               /* Objects sort by decreasing value */
-               j_value = object_value(j_ptr);
-               if (value > j_value) break;
-               if (value < j_value) continue;
+               if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
        }
 
        /* Slide the others up */
@@ -1623,22 +1817,25 @@ static int home_carry(object_type *o_ptr)
 
        chg_virtue(V_SACRIFICE, -1);
 
+       (void)combine_and_reorder_home(cur_store_num);
+
        /* Return the location */
        return (slot);
 }
 
 
-/*
+/*!
+ * @brief Å¹Êޤ˥ª¥Ö¥¸¥§¥¯¥È¤ò²Ã¤¨¤ë /
  * Add the item "o_ptr" to a real stores inventory.
- *
- * If the item is "worthless", it is thrown away (except in the home).
- *
- * If the item cannot be combined with an object already in the inventory,
- * make a new slot for it, and calculate its "per item" price. Note that
- * this price will be negative, since the price will not be "fixed" yet.
- * Adding an item to a "fixed" price stack will not change the fixed price.
- *
+ * @param o_ptr ²Ã¤¨¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ¼ý¤á¤¿Àè¤ÎID
+ * @details
+ * <pre>
  * In all cases, return the slot (or -1) where the object was placed
+ * Note that this is a hacked up version of "inven_carry()".
+ * Also note that it may not correctly "adapt" to "knowledge" bacoming
+ * known, the player may have to pick stuff up and drop it again.
+ * </pre>
  */
 static int store_carry(object_type *o_ptr)
 {
@@ -1732,9 +1929,17 @@ static int store_carry(object_type *o_ptr)
 }
 
 
-/*
+/*!
+ * @brief Å¹ÊޤΥª¥Ö¥¸¥§¥¯¥È¿ô¤òÁý¤ä¤¹ /
+ * Add the item "o_ptr" to a real stores inventory.
+ * @param item Áý¤ä¤·¤¿¤¤¥¢¥¤¥Æ¥à¤ÎID
+ * @param num Áý¤ä¤·¤¿¤¤¿ô
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * Increase, by a given amount, the number of a certain item
  * in a certain store. This can result in zero items.
+ * </pre>
  */
 static void store_item_increase(int item, int num)
 {
@@ -1755,8 +1960,11 @@ static void store_item_increase(int item, int num)
 }
 
 
-/*
+/*!
+ * @brief Å¹ÊޤΥª¥Ö¥¸¥§¥¯¥È¿ô¤òºï½ü¤¹¤ë /
  * Remove a slot if it is empty
+ * @param item ºï½ü¤·¤¿¤¤¥¢¥¤¥Æ¥à¤ÎID
+ * @return ¤Ê¤·
  */
 static void store_item_optimize(int item)
 {
@@ -1785,18 +1993,23 @@ static void store_item_optimize(int item)
        object_wipe(&st_ptr->stock[j]);
 }
 
-
-/*
+/*!
+ * @brief ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍѤÎ̵²ÁÃÍÉʤÎÇÓ½üȽÄê /
  * This function will keep 'crap' out of the black market.
+ * @param o_ptr È½Äꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Ë¤È¤Ã¤Æ̵²ÁÃͤÊÉʤʤé¤ÐTRUE¤òÊÖ¤¹
+ * @details
+ * <pre>
  * Crap is defined as any item that is "available" elsewhere
  * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
+ * </pre>
  */
 static bool black_market_crap(object_type *o_ptr)
 {
        int     i, j;
 
        /* Ego items are never crap */
-       if (o_ptr->name2) return (FALSE);
+       if (object_is_ego(o_ptr)) return (FALSE);
 
        /* Good items are never crap */
        if (o_ptr->to_a > 0) return (FALSE);
@@ -1824,9 +2037,14 @@ static bool black_market_crap(object_type *o_ptr)
 }
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ¤ÎÉÊ·¤¨ÊѲ½¤Î¤¿¤á¤Ë¥¢¥¤¥Æ¥à¤òºï½ü¤¹¤ë /
  * Attempt to delete (some of) a random item from the store
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * Hack -- we attempt to "maintain" piles of items when possible.
+ * </pre>
  */
 static void store_delete(void)
 {
@@ -1856,16 +2074,19 @@ static void store_delete(void)
 }
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ¤ÎÉÊ·¤¨ÊѲ½¤Î¤¿¤á¤Ë¥¢¥¤¥Æ¥à¤òÄɲ乤ë /
  * Creates a random item and gives it to a store
+ * @return ¤Ê¤·
+ * @details
+ * <pre>
  * This algorithm needs to be rethought.  A lot.
  * Currently, "normal" stores use a pre-built array.
- *
  * Note -- the "level" given to "obj_get_num()" is a "favored"
  * level, that is, there is a much higher chance of getting
  * items with a level approaching that of the given level...
- *
  * Should we check for "permission" to have the given item?
+ * </pre>
  */
 static void store_create(void)
 {
@@ -1913,7 +2134,7 @@ static void store_create(void)
                object_prep(q_ptr, i);
 
                /* Apply some "low-level" magic (no artifacts) */
-               apply_magic(q_ptr, level, FALSE, FALSE, FALSE, FALSE);
+               apply_magic(q_ptr, level, AM_NO_FIXED_ART);
 
                /* Require valid object */
                if (!store_will_buy(q_ptr)) continue;
@@ -1930,7 +2151,7 @@ static void store_create(void)
                object_known(q_ptr);
 
                /* Mark it storebought */
-               q_ptr->ident |= IDENT_STOREB;
+               q_ptr->ident |= IDENT_STORE;
 
                /* Mega-Hack -- no chests in stores */
                if (q_ptr->tval == TV_CHEST) continue;
@@ -1968,9 +2189,11 @@ static void store_create(void)
 }
 
 
-
-/*
+/*!
+ * @brief Å¹Êޤγä°úÂоݳ°¤Ë¤¹¤ë¤«¤É¤¦¤«¤òȽÄê /
  * Eliminate need to bargain if player has haggled well in the past
+ * @param minprice ¥¢¥¤¥Æ¥à¤ÎºÇÄãÈÎÇä²Á³Ê
+ * @return ³ä°ú¤ò¶Ø»ß¤¹¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool noneedtobargain(s32b minprice)
 {
@@ -1991,8 +2214,13 @@ static bool noneedtobargain(s32b minprice)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤Î»ý¤Ä¥×¥ì¥¤¥ä¡¼¤ËÂФ¹¤ëÇäÇã¤ÎÎɤ·°­¤··Ð¸³¤òµ­²±¤¹¤ë /
  * Update the bargain info
+ * @param price ¼ÂºÝ¤Î¼è°ú²Á³Ê
+ * @param minprice Å¹¼ç¤ÎÄ󼨤·¤¿²Á³Ê
+ * @param num ÇäÇã¿ô 
+ * @return ¤Ê¤·
  */
 static void updatebargain(s32b price, s32b minprice, int num)
 {
@@ -2024,9 +2252,11 @@ static void updatebargain(s32b price, s32b minprice, int num)
 }
 
 
-
-/*
+/*!
+ * @brief Å¹¤Î¾¦Éʥꥹ¥È¤òºÆɽ¼¨¤¹¤ë /
  * Re-displays a single store entry
+ * @param pos É½¼¨¹Ô
+ * @return ¤Ê¤·
  */
 static void display_entry(int pos)
 {
@@ -2044,10 +2274,10 @@ static void display_entry(int pos)
        o_ptr = &st_ptr->stock[pos];
 
        /* Get the "offset" */
-       i = (pos % 12);
+       i = (pos % store_bottom);
 
        /* Label it, clear the line --(-- */
-       (void)sprintf(out_val, "%c) ", I2A(i));
+       (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
        prt(out_val, i+6, 0);
 
        cur_col = 3;
@@ -2061,13 +2291,9 @@ static void display_entry(int pos)
                        a |= 0x40;
 #endif
 
-               Term_draw(cur_col, i + 6, a, c);
-               if (use_bigtile)
-               {
-                       cur_col++;
-                       if (a & 0x80)
-                               Term_draw(cur_col, i + 6, 255, -1);
-               }
+               Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
+               if (use_bigtile) cur_col++;
+
                cur_col += 2;
        }
 
@@ -2080,7 +2306,7 @@ static void display_entry(int pos)
                if (show_weights) maxwid -= 10;
 
                /* Describe the object */
-               object_desc(o_name, o_ptr, TRUE, 3);
+               object_desc(o_name, o_ptr, 0);
                o_name[maxwid] = '\0';
                c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
 
@@ -2090,8 +2316,8 @@ static void display_entry(int pos)
                        /* Only show the weight of an individual item */
                        int wgt = o_ptr->weight;
 #ifdef JP
-                        sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
-                        put_str(out_val, i+6, 67);
+                       sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
+                       put_str(out_val, i+6, 67);
 #else
                        (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
                        put_str(out_val, i+6, 68);
@@ -2110,7 +2336,7 @@ static void display_entry(int pos)
                if (show_weights) maxwid -= 7;
 
                /* Describe the object (fully) */
-               object_desc_store(o_name, o_ptr, TRUE, 3);
+               object_desc(o_name, o_ptr, 0);
                o_name[maxwid] = '\0';
                c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
 
@@ -2120,8 +2346,8 @@ static void display_entry(int pos)
                        /* Only show the weight of an individual item */
                        int wgt = o_ptr->weight;
 #ifdef JP
-                        sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
-                        put_str(out_val, i+6, 60);
+                       sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
+                       put_str(out_val, i+6, 60);
 #else
                        (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
                        put_str(out_val, i+6, 61);
@@ -2173,8 +2399,11 @@ static void display_entry(int pos)
 }
 
 
-/*
+/*!
+ * @brief Å¹¤Î¾¦Éʥꥹ¥È¤òɽ¼¨¤¹¤ë /
  * Displays a store's inventory                -RAK-
+ * @return ¤Ê¤·
+ * @details
  * All prices are listed as "per individual object".  -BEN-
  */
 static void display_inventory(void)
@@ -2182,7 +2411,7 @@ static void display_inventory(void)
        int i, k;
 
        /* Display the next 12 items */
-       for (k = 0; k < 12; k++)
+       for (k = 0; k < store_bottom; k++)
        {
                /* Do not display "dead" items */
                if (store_top + k >= st_ptr->stock_num) break;
@@ -2192,7 +2421,7 @@ static void display_inventory(void)
        }
 
        /* Erase the extra lines and the "more" prompt */
-       for (i = k; i < 13; i++) prt("", i + 6, 0);
+       for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
 
        /* Assume "no current page" */
 #ifdef JP
@@ -2203,7 +2432,7 @@ static void display_inventory(void)
 
 
        /* Visual reminder of "more items" */
-       if (st_ptr->stock_num > 12)
+       if (st_ptr->stock_num > store_bottom)
        {
                /* Show "more" reminder (after the last item) */
 #ifdef JP
@@ -2216,36 +2445,53 @@ static void display_inventory(void)
                /* Indicate the "current page" */
                /* Trailing spaces are to display (Page xx) and (Page x) */
 #ifdef JP
-               put_str(format("(%d¥Ú¡¼¥¸)  ", store_top/12 + 1), 5, 20);
+               put_str(format("(%d¥Ú¡¼¥¸)  ", store_top/store_bottom + 1), 5, 20);
 #else
-               put_str(format("(Page %d)  ", store_top/12 + 1), 5, 20);
+               put_str(format("(Page %d)  ", store_top/store_bottom + 1), 5, 20);
 #endif
 
        }
+
+       if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
+       {
+               k = st_ptr->stock_size;
+
+               if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
+#ifdef JP
+               put_str(format("¥¢¥¤¥Æ¥à¿ô:  %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
+#else
+               put_str(format("Objects:  %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
+#endif
+       }
 }
 
 
-/*
+/*!
+ * @brief ¥×¥ì¥¤¥ä¡¼¤Î½ê»ý¶â¤òɽ¼¨¤¹¤ë /
  * Displays players gold                                       -RAK-
+ * @return ¤Ê¤·
+ * @details
  */
 static void store_prt_gold(void)
 {
        char out_val[64];
 
 #ifdef JP
-       prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19, 53);
+       prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19 + xtra_stock, 53);
 #else
-       prt("Gold Remaining: ", 19, 53);
+       prt("Gold Remaining: ", 19 + xtra_stock, 53);
 #endif
 
 
        sprintf(out_val, "%9ld", (long)p_ptr->au);
-       prt(out_val, 19, 68);
+       prt(out_val, 19 + xtra_stock, 68);
 }
 
-
-/*
+/*!
+ * @brief Å¹ÊÞ¾ðÊóÁ´ÂΤòɽ¼¨¤¹¤ë¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Displays store (after clearing screen)              -RAK-
+ * @return ¤Ê¤·
+ * @details
  */
 static void display_store(void)
 {
@@ -2320,7 +2566,7 @@ static void display_store(void)
        /* Normal stores */
        else
        {
-               cptr store_name = (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name);
+               cptr store_name = (f_name + f_info[cur_store_feat].name);
                cptr owner_name = (ot_ptr->owner_name);
                cptr race_name = race_info[ot_ptr->owner_race].title;
 
@@ -2369,14 +2615,20 @@ static void display_store(void)
 
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ¤«¤é¥¢¥¤¥Æ¥à¤òÁªÂò¤¹¤ë /
  * Get the ID of a store item and return its value     -RAK-
+ * @param com_val ÁªÂòID¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @param pmt ¥á¥Ã¥»¡¼¥¸¥­¥ã¥×¥·¥ç¥ó
+ * @param i ÁªÂòÈϰϤκǾ®ÃÍ
+ * @param j ÁªÂòÈϰϤκÇÂçÃÍ
+ * @return ¼ÂºÝ¤ËÁªÂò¤·¤¿¤éTRUE¡¢¥­¥ã¥ó¥»¥ë¤·¤¿¤éFALSE
  */
 static int get_stock(int *com_val, cptr pmt, int i, int j)
 {
        char    command;
-
        char    out_val[160];
+       char    lo, hi;
 
 #ifdef ALLOW_REPEAT /* TNB */
 
@@ -2401,13 +2653,15 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
        *com_val = (-1);
 
        /* Build the prompt */
+       lo = I2A(i);
+       hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
 #ifdef JP
-        (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
-                (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"), 
-                                 I2A(i), I2A(j), pmt);
+       (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
+               (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"), 
+                                 lo, hi, pmt);
 #else
        (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
-                                 I2A(i), I2A(j), pmt);
+                                 lo, hi, pmt);
 #endif
 
 
@@ -2420,7 +2674,12 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
                if (!get_com(out_val, &command, FALSE)) break;
 
                /* Convert */
-               k = (islower(command) ? A2I(command) : -1);
+               if (islower(command))
+                       k = A2I(command);
+               else if (isupper(command))
+                       k = A2I(tolower(command)) + 26;
+               else
+                       k = -1;
 
                /* Legal responses */
                if ((k >= i) && (k <= j))
@@ -2450,8 +2709,10 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤ÎÉÔËþÅÙ¤òÁý¤ä¤·¡¢¥×¥ì¥¤¥ä¡¼¤òÄù¤á½Ð¤¹È½Äê¤È½èÍý¤ò¹Ô¤¦ /
  * Increase the insult counter and get angry if too many -RAK-
+ * @return ¥×¥ì¥¤¥ä¡¼¤òÄù¤á½Ð¤¹¾ì¹çTRUE¤òÊÖ¤¹
  */
 static int increase_insults(void)
 {
@@ -2481,8 +2742,10 @@ static int increase_insults(void)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤ÎÉÔËþÅÙ¤ò¸º¤é¤¹ /
  * Decrease insults                            -RAK-
+ * @return ¥×¥ì¥¤¥ä¡¼¤òÄù¤á½Ð¤¹¾ì¹çTRUE¤òÊÖ¤¹
  */
 static void decrease_insults(void)
 {
@@ -2491,8 +2754,10 @@ static void decrease_insults(void)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤ÎÉÔËþÅÙ¤¬Áý¤¨¤¿¾ì¹ç¤Î¤ß¤Î¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë /
  * Have insulted while haggling                        -RAK-
+ * @return ¥×¥ì¥¤¥ä¡¼¤òÄù¤á½Ð¤¹¾ì¹çTRUE¤òÊÖ¤¹
  */
 static int haggle_insults(void)
 {
@@ -2518,8 +2783,14 @@ static bool allow_inc = FALSE;
 static s32b last_inc = 0L;
 
 
-/*
+/*!
+ * @brief ¸ò¾Ä²Á³Ê¤ò³Îǧ¤Èǧ¾Ú¤ÎÀ§Èó¤ò¹Ô¤¦ /
  * Get a haggle
+ * @param pmt ¥á¥Ã¥»¡¼¥¸
+ * @param poffer ÊÌÅÓ²Á³ÊÄ󼨤ò¤·¤¿¾ì¹ç¤ÎÃͤòÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @param price ¸½ºß¤Î¸ò¾Ä²Á³Ê
+ * @param final ºÇ½ª³ÎÄê²Á³Ê¤Ê¤é¤ÐTRUE
+ * @return ¥×¥ì¥¤¥ä¡¼¤òÄù¤á½Ð¤¹¾ì¹çTRUE¤òÊÖ¤¹
  */
 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
 {
@@ -2582,11 +2853,25 @@ static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
        /* Ask until done */
        while (TRUE)
        {
+               bool res;
+
+               /* Display prompt */
+               prt(buf, 0, 0);
+
                /* Default */
                strcpy(out_val, "");
 
-               /* Ask the user for a response */
-               if (!get_string(buf, out_val, 32)) return (FALSE);
+               /*
+                * Ask the user for a response.
+                * Don't allow to use numpad as cursor key.
+                */
+               res = askfor_aux(out_val, 32, FALSE);
+
+               /* Clear prompt */
+               prt("", 0, 0);
+
+               /* Cancelled */
+               if (!res) return FALSE;
 
                /* Skip leading spaces */
                for (p = out_val; *p == ' '; p++) /* loop */;
@@ -2654,14 +2939,21 @@ static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
 }
 
 
-/*
+/*!
+ * @brief Å¹¼ç¤¬¥×¥ì¥¤¥ä¡¼¤«¤é¤Î¸ò¾Ä²Á³Ê¤òȽÃǤ¹¤ë /
  * Receive an offer (from the player)
- *
+ * @param pmt ¥á¥Ã¥»¡¼¥¸
+ * @param poffer Å¹¼ç¤«¤é¤Î¸ò¾Ä²Á³Ê¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @param last_offer ¸½ºß¤Î¸ò¾Ä²Á³Ê
+ * @param factor Å¹¼ç¤Î²Á³Ê´ð½àÇÜΨ
+ * @param price ¥¢¥¤¥Æ¥à¤Î¼Â²ÁÃÍ
+ * @param final ºÇ½ª²Á³Ê³ÎÄê¤Ê¤é¤ÐTRUE
+ * @return ¥×¥ì¥¤¥ä¡¼¤Î²Á³Ê¤ËÂФ·¤ÆÉÔÉþ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹ /
  * Return TRUE if offer is NOT okay
  */
 static bool receive_offer(cptr pmt, s32b *poffer,
-                          s32b last_offer, int factor,
-                          s32b price, int final)
+                         s32b last_offer, int factor,
+                         s32b price, int final)
 {
        /* Haggle till done */
        while (TRUE)
@@ -2684,9 +2976,12 @@ static bool receive_offer(cptr pmt, s32b *poffer,
 }
 
 
-/*
+/*!
+ * @brief ¥×¥ì¥¤¥ä¡¼¤¬¹ØÆþ¤¹¤ë»þ¤ÎÃÍÀÚ¤ê½èÍý¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Haggling routine                            -RAK-
- *
+ * @param o_ptr ¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param price ºÇ½ª²Á³Ê¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @return ¥×¥ì¥¤¥ä¡¼¤Î²Á³Ê¤ËÂФ·¤ÆŹ¼ç¤¬ÉÔÉþ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹ /
  * Return TRUE if purchase is NOT successful
  */
 static bool purchase_haggle(object_type *o_ptr, s32b *price)
@@ -2801,7 +3096,7 @@ static bool purchase_haggle(object_type *o_ptr, s32b *price)
                        cancel = receive_offer("What do you offer? ",
 #endif
 
-                                              &offer, last_offer, 1, cur_ask, final);
+                                              &offer, last_offer, 1, cur_ask, final);
 
                        if (cancel)
                        {
@@ -2899,9 +3194,12 @@ static bool purchase_haggle(object_type *o_ptr, s32b *price)
 }
 
 
-/*
+/*!
+ * @brief ¥×¥ì¥¤¥ä¡¼¤¬ÇäµÑ¤¹¤ë»þ¤ÎÃÍÀÚ¤ê½èÍý¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Haggling routine                            -RAK-
- *
+ * @param o_ptr ¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @param price ºÇ½ª²Á³Ê¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @return ¥×¥ì¥¤¥ä¡¼¤Î²Á³Ê¤ËÂФ·¤ÆŹ¼ç¤¬ÉÔÉþ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹ /
  * Return TRUE if purchase is NOT successful
  */
 static bool sell_haggle(object_type *o_ptr, s32b *price)
@@ -3117,7 +3415,7 @@ static bool sell_haggle(object_type *o_ptr, s32b *price)
                                prt("", 1, 0);
                                (void)sprintf(out_val,
 #ifdef JP
-                                             "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
+                                             "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
 #else
                                                          "Your last bid %ld", (long)last_offer);
 #endif
@@ -3139,8 +3437,10 @@ static bool sell_haggle(object_type *o_ptr, s32b *price)
 }
 
 
-/*
+/*!
+ * @brief Å¹¤«¤é¤Î¹ØÆþ½èÍý¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Buy an item from a store                    -RAK-
+ * @return ¤Ê¤·
  */
 static void store_purchase(void)
 {
@@ -3158,7 +3458,6 @@ static void store_purchase(void)
 
        char out_val[160];
 
-
        if (cur_store_num == STORE_MUSEUM)
        {
 #ifdef JP
@@ -3194,22 +3493,22 @@ static void store_purchase(void)
        i = (st_ptr->stock_num - store_top);
 
        /* And then restrict it to the current page */
-       if (i > 12) i = 12;
+       if (i > store_bottom) i = store_bottom;
 
        /* Prompt */
 #ifdef JP
-        /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
-        switch( cur_store_num ) {
-                case 7:
-                        sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
-                        break;
-                case 6:
-                        sprintf(out_val, "¤É¤ì? ");
-                        break;
-                default:
-                        sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
-                        break;
-        }
+       /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
+       switch( cur_store_num ) {
+               case 7:
+                       sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
+                       break;
+               case 6:
+                       sprintf(out_val, "¤É¤ì? ");
+                       break;
+               default:
+                       sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
+                       break;
+       }
 #else
        if (cur_store_num == STORE_HOME)
        {
@@ -3330,7 +3629,7 @@ msg_format("
                else
                {
                        /* Describe the object (fully) */
-                       object_desc_store(o_name, j_ptr, TRUE, 3);
+                       object_desc(o_name, j_ptr, 0);
 
                        /* Message */
 #ifdef JP
@@ -3357,8 +3656,6 @@ msg_format("%s(%c)
                        /* Player can afford it */
                        if (p_ptr->au >= price)
                        {
-                               int idx;
-
                                /* Say "okay" */
                                say_comment_1();
 
@@ -3386,7 +3683,7 @@ msg_format("%s(%c)
                                j_ptr->ident &= ~(IDENT_FIXED);
 
                                /* Describe the transaction */
-                               object_desc(o_name, j_ptr, TRUE, 3);
+                               object_desc(o_name, j_ptr, 0);
 
                                /* Message */
 #ifdef JP
@@ -3399,7 +3696,7 @@ msg_format("%s
                                record_turn = turn;
 
                                if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
-                               object_desc(o_name, o_ptr, TRUE, 0);
+                               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);
 
@@ -3408,12 +3705,12 @@ msg_format("%s
 
                                /* Erase the "feeling" */
                                j_ptr->feeling = FEEL_NONE;
-                               j_ptr->ident &= ~(IDENT_STOREB);
+                               j_ptr->ident &= ~(IDENT_STORE);
                                /* Give it to the player */
                                item_new = inven_carry(j_ptr);
 
                                /* Describe the final result */
-                               object_desc(o_name, &inventory[item_new], TRUE, 3);
+                               object_desc(o_name, &inventory[item_new], 0);
 
                                /* Message */
 #ifdef JP
@@ -3424,8 +3721,7 @@ msg_format("%s
 #endif
 
                                /* Auto-inscription */
-                               idx = is_autopick(&inventory[item_new]);
-                               auto_inscribe_item(item_new, idx);
+                               autopick_alter_item(item_new, FALSE);
 
                                /* Now, reduce the original stack's pval. */
                                if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
@@ -3466,7 +3762,7 @@ msg_format("%s
                                                        ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
                                                put_str(buf, 3, 10);
                                                sprintf(buf, "%s (%ld)",
-                                                       (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name), (long)(ot_ptr->max_cost));
+                                                       (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
                                                prt(buf, 3, 50);
                                        }
 
@@ -3500,7 +3796,7 @@ msg_format("%s
                                else if (st_ptr->stock_num != i)
                                {
                                        /* Pick the correct screen */
-                                       if (store_top >= st_ptr->stock_num) store_top -= 12;
+                                       if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
 
                                        /* Redraw everything */
                                        display_inventory();
@@ -3531,6 +3827,8 @@ msg_format("%s
        /* Home is much easier */
        else
        {
+               bool combined_or_reordered;
+
                /* Distribute charges of wands/rods */
                distribute_charges(o_ptr, j_ptr, amt);
 
@@ -3538,7 +3836,7 @@ msg_format("%s
                item_new = inven_carry(j_ptr);
 
                /* Describe just the result */
-               object_desc(o_name, &inventory[item_new], TRUE, 3);
+               object_desc(o_name, &inventory[item_new], 0);
 
                /* Message */
 #ifdef JP
@@ -3558,11 +3856,16 @@ msg_format("%s
                store_item_increase(item, -amt);
                store_item_optimize(item);
 
+               combined_or_reordered = combine_and_reorder_home(STORE_HOME);
+
                /* Hack -- Item is still here */
                if (i == st_ptr->stock_num)
                {
+                       /* Redraw everything */
+                       if (combined_or_reordered) display_inventory();
+
                        /* Redraw the item */
-                       display_entry(item);
+                       else display_entry(item);
                }
 
                /* The item is gone */
@@ -3572,7 +3875,7 @@ msg_format("%s
                        if (st_ptr->stock_num == 0) store_top = 0;
 
                        /* Nothing left on that screen */
-                       else if (store_top >= st_ptr->stock_num) store_top -= 12;
+                       else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
 
                        /* Redraw everything */
                        display_inventory();
@@ -3586,8 +3889,10 @@ msg_format("%s
 }
 
 
-/*
+/*!
+ * @brief Å¹¤«¤é¤ÎÇäµÑ½èÍý¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Sell an item to the store (or home)
+ * @return ¤Ê¤·
  */
 static void store_sell(void)
 {
@@ -3677,7 +3982,7 @@ static void store_sell(void)
 
 
        /* Hack -- Cannot remove cursed items */
-       if ((item >= INVEN_RARM) && cursed_p(o_ptr))
+       if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
        {
                /* Oops */
 #ifdef JP
@@ -3724,7 +4029,7 @@ static void store_sell(void)
        }
 
        /* Get a full description */
-       object_desc(o_name, q_ptr, TRUE, 3);
+       object_desc(o_name, q_ptr, 0);
 
        /* Remove any inscription, feeling for stores */
        if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
@@ -3817,6 +4122,9 @@ static void store_sell(void)
                        /* Modify quantity */
                        q_ptr->number = amt;
 
+                       /* Make it look like to be known */
+                       q_ptr->ident |= IDENT_STORE;
+
                        /*
                         * Hack -- If a rod or wand, let the shopkeeper know just
                         * how many charges he really paid for. -LM-
@@ -3830,7 +4138,7 @@ static void store_sell(void)
                        value = object_value(q_ptr) * q_ptr->number;
 
                        /* Get the description all over again */
-                       object_desc(o_name, q_ptr, TRUE, 3);
+                       object_desc(o_name, q_ptr, 0);
 
                        /* Describe the result (in message buffer) */
 #ifdef JP
@@ -3859,6 +4167,11 @@ msg_format("%s
                        /* Take the item from the player, describe the result */
                        inven_item_increase(item, -amt);
                        inven_item_describe(item);
+
+                       /* If items remain, auto-inscribe before optimizing */
+                       if (o_ptr->number > 0)
+                               autopick_alter_item(item, FALSE);
+
                        inven_item_optimize(item);
 
                        /* Handle stuff */
@@ -3870,7 +4183,7 @@ msg_format("%s
                        /* Re-display if item is now in store */
                        if (item_pos >= 0)
                        {
-                               store_top = (item_pos / 12) * 12;
+                               store_top = (item_pos / store_bottom) * store_bottom;
                                display_inventory();
                        }
                }
@@ -3880,7 +4193,7 @@ msg_format("%s
        else if (cur_store_num == STORE_MUSEUM)
        {
                char o2_name[MAX_NLEN];
-               object_desc(o2_name, q_ptr, TRUE, 0);
+               object_desc(o2_name, q_ptr, OD_NAME_ONLY);
 
                if (-1 == store_check_num(q_ptr))
                {
@@ -3934,7 +4247,7 @@ msg_format("%s
                /* Update store display */
                if (item_pos >= 0)
                {
-                       store_top = (item_pos / 12) * 12;
+                       store_top = (item_pos / store_bottom) * store_bottom;
                        display_inventory();
                }
        }
@@ -3967,17 +4280,23 @@ msg_format("%s
                /* Update store display */
                if (item_pos >= 0)
                {
-                       store_top = (item_pos / 12) * 12;
+                       store_top = (item_pos / store_bottom) * store_bottom;
                        display_inventory();
                }
        }
-       if (item >= INVEN_RARM) calc_android_exp();
-       if ((choice == 0) && ((item == INVEN_RARM) || (item == INVEN_LARM))) kamaenaoshi(item);
+
+       if ((choice == 0) && (item >= INVEN_RARM))
+       {
+               calc_android_exp();
+               kamaenaoshi(item);
+       }
 }
 
 
-/*
+/*!
+ * @brief Å¹¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Examine an item in a store                     -JDL-
+ * @return ¤Ê¤·
  */
 static void store_examine(void)
 {
@@ -3993,21 +4312,21 @@ static void store_examine(void)
        {
                if (cur_store_num == STORE_HOME)
 #ifdef JP
-                        msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
+                       msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
 #else
                        msg_print("Your home is empty.");
 #endif
 
-                else if (cur_store_num == STORE_MUSEUM)
+               else if (cur_store_num == STORE_MUSEUM)
 #ifdef JP
-                        msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
+                       msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
 #else
                        msg_print("Museum is empty.");
 #endif
 
                else
 #ifdef JP
-                        msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
+                       msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
 #else
                        msg_print("I am currently out of stock.");
 #endif
@@ -4020,7 +4339,7 @@ static void store_examine(void)
        i = (st_ptr->stock_num - store_top);
 
        /* And then restrict it to the current page */
-       if (i > 12) i = 12;
+       if (i > store_bottom) i = store_bottom;
 
        /* Prompt */
 #ifdef JP
@@ -4053,7 +4372,7 @@ msg_print("
        }
 
        /* Description */
-       object_desc(o_name, o_ptr, TRUE, 3);
+       object_desc(o_name, o_ptr, 0);
 
        /* Describe */
 #ifdef JP
@@ -4064,7 +4383,7 @@ msg_format("%s
 
 
        /* Describe it fully */
-       if (!identify_fully_aux(o_ptr))
+       if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
 #ifdef JP
 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
 #else
@@ -4076,19 +4395,109 @@ msg_print("
 }
 
 
+/*!
+ * @brief Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤ò½üµî¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
+ * Remove an item from museum (Originally from TOband)
+ * @return ¤Ê¤·
+ */
+static void museum_remove_object(void)
+{
+       int         i;
+       int         item;
+       object_type *o_ptr;
+       char        o_name[MAX_NLEN];
+       char        out_val[160];
+
+       /* Empty? */
+       if (st_ptr->stock_num <= 0)
+       {
+#ifdef JP
+               msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
+#else
+               msg_print("Museum is empty.");
+#endif
+
+               return;
+       }
+
+       /* Find the number of objects on this and following pages */
+       i = st_ptr->stock_num - store_top;
+
+       /* And then restrict it to the current page */
+       if (i > store_bottom) i = store_bottom;
+
+       /* Prompt */
+#ifdef JP
+       sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©");
+#else
+       sprintf(out_val, "Which item do you want to order to remove? ");
+#endif
+
+       /* Get the item number to be removed */
+       if (!get_stock(&item, out_val, 0, i - 1)) return;
+
+       /* Get the actual index */
+       item = item + store_top;
+
+       /* Get the actual item */
+       o_ptr = &st_ptr->stock[item];
+
+       /* Description */
+       object_desc(o_name, o_ptr, 0);
+
+#ifdef JP
+       msg_print("Ÿ¼¨¤ò¤ä¤á¤µ¤»¤¿¥¢¥¤¥Æ¥à¤ÏÆóÅ٤ȸ«¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡ª");
+       if (!get_check(format("ËÜÅö¤Ë%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©", o_name))) return;
+#else
+       msg_print("You cannot see items which is removed from the Museum!");
+       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
+       msg_format("You ordered to remove %s.", o_name);
+#endif
+
+       /* Remove the items from the home */
+       store_item_increase(item, -o_ptr->number);
+       store_item_optimize(item);
+
+       (void)combine_and_reorder_home(STORE_MUSEUM);
+
+       /* The item is gone */
+
+       /* Nothing left */
+       if (st_ptr->stock_num == 0) store_top = 0;
+
+       /* Nothing left on that screen */
+       else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
+
+       /* Redraw everything */
+       display_inventory();
+
+       return;
+}
+
+
 /*
  * Hack -- set this to leave the store
  */
 static bool leave_store = FALSE;
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ½èÍý¥³¥Þ¥ó¥ÉÁªÂò¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
  * Process a command in a store
- *
+ * @return ¤Ê¤·
+ * @note
+ * <pre>
  * Note that we must allow the use of a few "special" commands
  * in the stores which are not allowed in the dungeon, and we
  * must disable some commands which are allowed in the dungeon
  * but not in the stores, to prevent chaos.
+ * </pre>
  */
 static void store_process_command(void)
 {
@@ -4118,7 +4527,7 @@ static void store_process_command(void)
                /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
                case '-':
                {
-                       if (st_ptr->stock_num <= 12) {
+                       if (st_ptr->stock_num <= store_bottom) {
 #ifdef JP
                                msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
 #else
@@ -4126,11 +4535,11 @@ static void store_process_command(void)
 #endif
                        }
                        else{
-                               store_top -= 12;
+                               store_top -= store_bottom;
                                if ( store_top < 0 )
-                                       store_top = ((st_ptr->stock_num - 1 )/12) * 12;
+                                       store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
                                if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
-                                       if ( store_top >= 12 ) store_top = 12;
+                                       if ( store_top >= store_bottom ) store_top = store_bottom;
                                display_inventory();
                        }
                        break;
@@ -4139,7 +4548,7 @@ static void store_process_command(void)
                /* Browse */
                case ' ':
                {
-                       if (st_ptr->stock_num <= 12)
+                       if (st_ptr->stock_num <= store_bottom)
                        {
 #ifdef JP
                                msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
@@ -4150,24 +4559,24 @@ static void store_process_command(void)
                        }
                        else
                        {
-                               store_top += 12;
-                                /*
-                                 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤­¤Ï
-                                 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
-                                 */
-                                if ((cur_store_num == STORE_HOME) && 
-                                    (powerup_home == FALSE) && 
-                                        (st_ptr->stock_num >= STORE_INVEN_MAX))
-                                {
-                                        if (store_top >= (STORE_INVEN_MAX - 1))
-                                        {
-                                                store_top = 0;
-                                        }
-                                }
-                                else
-                                {
-                                        if (store_top >= st_ptr->stock_num) store_top = 0;
-                                }
+                               store_top += store_bottom;
+                               /*
+                                * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤­¤Ï
+                                * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
+                                */
+                               if ((cur_store_num == STORE_HOME) && 
+                                   (powerup_home == FALSE) && 
+                                       (st_ptr->stock_num >= STORE_INVEN_MAX))
+                               {
+                                       if (store_top >= (STORE_INVEN_MAX - 1))
+                                       {
+                                               store_top = 0;
+                                       }
+                               }
+                               else
+                               {
+                                       if (store_top >= st_ptr->stock_num) store_top = 0;
+                               }
 
                                display_inventory();
                        }
@@ -4270,7 +4679,18 @@ static void store_process_command(void)
                /* Browse a book */
                case 'b':
                {
-                       do_cmd_browse();
+                       if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
+                            (p_ptr->pclass == CLASS_BERSERKER) ||
+                            (p_ptr->pclass == CLASS_NINJA) ||
+                            (p_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();
                        break;
                }
 
@@ -4309,7 +4729,9 @@ static void store_process_command(void)
                /* Character description */
                case 'C':
                {
+                       p_ptr->town_num = old_town_num;
                        do_cmd_change_name();
+                       p_ptr->town_num = inner_town_num;
                        display_store();
                        break;
                }
@@ -4327,28 +4749,36 @@ static void store_process_command(void)
                /* Single line from a pref file */
                case '"':
                {
+                       p_ptr->town_num = old_town_num;
                        do_cmd_pref();
+                       p_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;
                        break;
                }
 
                /* Interact with visuals */
                case '%':
                {
+                       p_ptr->town_num = old_town_num;
                        do_cmd_visuals();
+                       p_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;
                        break;
                }
 
@@ -4356,6 +4786,9 @@ static void store_process_command(void)
                case '=':
                {
                        do_cmd_options();
+                       (void)combine_and_reorder_home(STORE_HOME);
+                       do_cmd_redraw();
+                       display_store();
                        break;
                }
 
@@ -4426,11 +4859,18 @@ static void store_process_command(void)
                /* Hack -- Unknown command */
                default:
                {
+                       if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
+                       {
+                               museum_remove_object();
+                       }
+                       else
+                       {
 #ifdef JP
-                       msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
+                               msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
 #else
-                       msg_print("That command does not work in stores.");
+                               msg_print("That command does not work in stores.");
 #endif
+                       }
 
                        break;
                }
@@ -4438,33 +4878,41 @@ static void store_process_command(void)
 }
 
 
-/*
- * Enter a store, and interact with it.
- *
+/*!
+ * @brief Å¹ÊÞ½èÍýÁ´ÂΤΥᥤ¥ó¥ë¡¼¥Á¥ó /
+ * Enter a store, and interact with it. *
+ * @return ¤Ê¤·
+ * @note
+ * <pre>
  * Note that we use the standard "request_command()" function
  * to get a command, allowing us to use "command_arg" and all
  * command macros and other nifty stuff, but we use the special
  * "shopping" argument, to force certain commands to be converted
  * into other commands, normally, we convert "p" (pray) and "m"
  * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
+ * </pre>
  */
 void do_cmd_store(void)
 {
        int         which;
        int         maintain_num;
-       int         tmp_chr;
        int         i;
        cave_type   *c_ptr;
-       s16b        old_town_num;
+       bool        need_redraw_store_inv; /* To redraw missiles damage and prices in store */
+       int w, h;
 
+       /* Get term size */
+       Term_get_size(&w, &h);
+
+       /* Calculate stocks per 1 page */
+       xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
+       store_bottom = MIN_STOCK + xtra_stock;
 
        /* Access the player grid */
        c_ptr = &cave[py][px];
 
        /* Verify a store */
-       if (!((c_ptr->feat >= FEAT_SHOP_HEAD) &&
-                 (c_ptr->feat <= FEAT_SHOP_TAIL)) &&
-           (c_ptr->feat != FEAT_MUSEUM))
+       if (!cave_have_flag_grid(c_ptr, FF_STORE))
        {
 #ifdef JP
                msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
@@ -4476,12 +4924,12 @@ void do_cmd_store(void)
        }
 
        /* Extract the store code */
-       if (c_ptr->feat == FEAT_MUSEUM) which = STORE_MUSEUM;
-       else which = (c_ptr->feat - FEAT_SHOP_HEAD);
+       which = f_info[c_ptr->feat].subtype;
 
        old_town_num = p_ptr->town_num;
        if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
        if (dun_level) p_ptr->town_num = NO_TOWN;
+       inner_town_num = p_ptr->town_num;
 
        /* Hack -- Check the "locked doors" */
        if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
@@ -4498,7 +4946,7 @@ void do_cmd_store(void)
        }
 
        /* Calculate the number of store maintainances since the last visit */
-       maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TURNS);
+       maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
 
        /* Maintain the store max. 10 times */
        if (maintain_num > 10) maintain_num = 10;
@@ -4533,10 +4981,15 @@ void do_cmd_store(void)
        /* No automatic command */
        command_new = 0;
 
+       /* Do not expand macros */
+       get_com_no_macros = TRUE;
 
        /* Save the store number */
        cur_store_num = which;
 
+       /* Hack -- save the store feature */
+       cur_store_feat = c_ptr->feat;
+
        /* Save the store and owner pointers */
        st_ptr = &town[p_ptr->town_num].store[cur_store_num];
        ot_ptr = &owners[cur_store_num][st_ptr->owner];
@@ -4557,30 +5010,27 @@ void do_cmd_store(void)
                /* Hack -- Clear line 1 */
                prt("", 1, 0);
 
-               /* Hack -- Check the charisma */
-               tmp_chr = p_ptr->stat_use[A_CHR];
-
                /* Clear */
-               clear_from(20);
+               clear_from(20 + xtra_stock);
 
 
                /* Basic commands */
 #ifdef JP
-               prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21, 0);
+               prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21 + xtra_stock, 0);
 #else
-               prt(" ESC) Exit from Building.", 21, 0);
+               prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
 #endif
 
 
                /* Browse if necessary */
-               if (st_ptr->stock_num > 12)
+               if (st_ptr->stock_num > store_bottom)
                {
 #ifdef JP
-                       prt(" -)Á°¥Ú¡¼¥¸", 22, 0);
-                       prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23, 0);
+                       prt(" -)Á°¥Ú¡¼¥¸", 22 + xtra_stock, 0);
+                       prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23 + xtra_stock, 0);
 #else
-                       prt(" -) Previous page", 22, 0);
-                       prt(" SPACE) Next page", 23, 0);
+                       prt(" -) Previous page", 22 + xtra_stock, 0);
+                       prt(" SPACE) Next page", 23 + xtra_stock, 0);
 #endif
 
                }
@@ -4589,75 +5039,74 @@ void do_cmd_store(void)
                if (cur_store_num == STORE_HOME)
                {
 #ifdef JP
-                   prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
-                   prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
-                  prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
+                       prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21 + xtra_stock, 27);
+                       prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22 + xtra_stock, 27);
+                       prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
 #else
-                  prt("g) Get an item.", 21, 27);
-                  prt("d) Drop an item.", 22, 27);
-                  prt("x) eXamine an item in the home.", 23,27);
+                       prt("g) Get an item.", 21 + xtra_stock, 27);
+                       prt("d) Drop an item.", 22 + xtra_stock, 27);
+                       prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
 #endif
-
                }
 
                /* Museum commands */
                else if (cur_store_num == STORE_MUSEUM)
                {
 #ifdef JP
-                   prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
-                  prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
+                       prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21 + xtra_stock, 27);
+                       prt("r) ¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤ë", 22 + xtra_stock, 27);
+                       prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
 #else
-                  prt("d) Drop an item.", 21, 27);
-                  prt("x) eXamine an item in the museum.", 23,27);
+                       prt("d) Drop an item.", 21 + xtra_stock, 27);
+                       prt("r) order to Remove an item.", 22 + xtra_stock, 27);
+                       prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
 #endif
-
                }
 
                /* Shop commands XXX XXX XXX */
                else
                {
 #ifdef JP
-                        prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
-                        prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
-                       prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30);
+                       prt("p) ¾¦ÉʤòÇ㤦", 21 + xtra_stock, 30);
+                       prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22 + xtra_stock, 30);
+                       prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23 + xtra_stock,30);
 #else
-                  prt("p) Purchase an item.", 21, 30);
-                  prt("s) Sell an item.", 22, 30);
-                  prt("x) eXamine an item in the shop", 23,30);
+                       prt("p) Purchase an item.", 21 + xtra_stock, 30);
+                       prt("s) Sell an item.", 22 + xtra_stock, 30);
+                       prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
 #endif
-
                }
 
 #ifdef JP
-                /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
-
-                prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
-
-                if( rogue_like_commands == TRUE )
-                {
-                        prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
-                }
-                else
-                {
-                        prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
-                }
+               /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
+
+               prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21 + xtra_stock, 56);
+
+               if (rogue_like_commands)
+               {
+                       prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
+               }
+               else
+               {
+                       prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
+               }
 #else
-                prt("i/e) Inventry/Equipment list", 21, 56);
-
-                if( rogue_like_commands == TRUE )
-                {
-                        prt("w/T) Wear/Take off equipment", 22, 56);
-                }
-                else
-                {
-                        prt("w/t) Wear/Take off equipment", 22, 56);
-                }
+               prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
+
+               if (rogue_like_commands)
+               {
+                       prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
+               }
+               else
+               {
+                       prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
+               }
 #endif
                /* Prompt */
 #ifdef JP
-               prt("¥³¥Þ¥ó¥É:", 20, 0);
+               prt("¥³¥Þ¥ó¥É:", 20 + xtra_stock, 0);
 #else
-               prt("You may: ", 20, 0);
+               prt("You may: ", 20 + xtra_stock, 0);
 #endif
 
 
@@ -4667,6 +5116,12 @@ void do_cmd_store(void)
                /* Process the command */
                store_process_command();
 
+               /*
+                * Hack -- To redraw missiles damage and prices in store
+                * If player's charisma changes, or if player changes a bow, PU_BONUS is set
+                */
+               need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
+
                /* Hack -- Character is still in "icky" mode */
                character_icky = TRUE;
 
@@ -4745,7 +5200,7 @@ void do_cmd_store(void)
                                object_copy(q_ptr, o_ptr);
 
                                /* Describe it */
-                               object_desc(o_name, q_ptr, TRUE, 3);
+                               object_desc(o_name, q_ptr, 0);
 
                                /* Message */
 #ifdef JP
@@ -4769,14 +5224,15 @@ void do_cmd_store(void)
                                /* Redraw the home */
                                if (item_pos >= 0)
                                {
-                                       store_top = (item_pos / 12) * 12;
+                                       store_top = (item_pos / store_bottom) * store_bottom;
                                        display_inventory();
                                }
                        }
                }
 
                /* Hack -- Redisplay store prices if charisma changes */
-               if (tmp_chr != p_ptr->stat_use[A_CHR]) display_inventory();
+               /* Hack -- Redraw missiles damage if player changes bow */
+               if (need_redraw_store_inv) display_inventory();
 
                /* Hack -- get kicked out of the store */
                if (st_ptr->store_open >= turn) leave_store = TRUE;
@@ -4798,6 +5254,8 @@ void do_cmd_store(void)
        /* Hack -- Cancel "see" mode */
        command_see = FALSE;
 
+       /* Allow expanding macros */
+       get_com_no_macros = FALSE;
 
        /* Flush messages XXX XXX XXX */
        msg_print(NULL);
@@ -4808,7 +5266,7 @@ void do_cmd_store(void)
 
 
        /* Update everything */
-       p_ptr->update |= (PU_VIEW | PU_LITE);
+       p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
        p_ptr->update |= (PU_MONSTERS);
 
        /* Redraw entire screen */
@@ -4823,8 +5281,11 @@ void do_cmd_store(void)
 
 
 
-/*
+/*!
+ * @brief ¸½ºß¤ÎÄ®¤ÎŹ¼ç¤ò¸òÂ夵¤»¤ë /
  * Shuffle one of the stores.
+ * @param which Å¹ÊÞ¼ïÎà¤ÎID
+ * @return ¤Ê¤·
  */
 void store_shuffle(int which)
 {
@@ -4875,33 +5336,36 @@ void store_shuffle(int which)
                /* Get the item */
                o_ptr = &st_ptr->stock[i];
 
-               /* Hack -- Sell all old items for "half price" */
-               if (!(o_ptr->art_name))
+               if (!object_is_artifact(o_ptr))
+               {
+                       /* Hack -- Sell all non-artifact old items for "half price" */
                        o_ptr->discount = 50;
 
-               /* Hack -- Items are no longer "fixed price" */
-               o_ptr->ident &= ~(IDENT_FIXED);
+                       /* Hack -- Items are no longer "fixed price" */
+                       o_ptr->ident &= ~(IDENT_FIXED);
 
-               /* Mega-Hack -- Note that the item is "on sale" */
+                       /* Mega-Hack -- Note that the item is "on sale" */
 #ifdef JP
-               o_ptr->inscription = quark_add("Çä½ÐÃæ");
+                       o_ptr->inscription = quark_add("Çä½ÐÃæ");
 #else
-               o_ptr->inscription = quark_add("on sale");
+                       o_ptr->inscription = quark_add("on sale");
 #endif
-
+               }
        }
 }
 
 
-/*
+/*!
+ * @brief Å¹¤ÎÉÊ·¤¨¤òÊѲ½¤µ¤»¤ë /
  * Maintain the inventory at the stores.
+ * @param town_num Ä®¤ÎID
+ * @param store_num Å¹ÊÞ¼ïÎà¤ÎID
+ * @return ¤Ê¤·
  */
 void store_maint(int town_num, int store_num)
 {
        int             j;
 
-       int     old_rating = rating;
-
        cur_store_num = store_num;
 
        /* Ignore home */
@@ -4972,15 +5436,15 @@ void store_maint(int town_num, int store_num)
 
        /* Acquire some new items */
        while (st_ptr->stock_num < j) store_create();
-
-
-       /* Hack -- Restore the rating */
-       rating = old_rating;
 }
 
 
-/*
+/*!
+ * @brief Å¹ÊÞ¾ðÊó¤ò½é´ü²½¤¹¤ë /
  * Initialize the stores
+ * @param town_num Ä®¤ÎID
+ * @param store_num Å¹ÊÞ¼ïÎà¤ÎID
+ * @return ¤Ê¤·
  */
 void store_init(int town_num, int store_num)
 {
@@ -5023,7 +5487,7 @@ void store_init(int town_num, int store_num)
         * MEGA-HACK - Last visit to store is
         * BEFORE player birth to enable store restocking
         */
-       st_ptr->last_visit = -200L * STORE_TURNS;
+       st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
 
        /* Clear any old items */
        for (k = 0; k < st_ptr->stock_size; k++)
@@ -5033,6 +5497,11 @@ void store_init(int town_num, int store_num)
 }
 
 
+/*!
+ * @brief ¥¢¥¤¥Æ¥à¤òÄ®¤Î¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Ë°ÜÆ°¤µ¤»¤ë /
+ * @param o_ptr °ÜÆ°¤µ¤»¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @return ¤Ê¤·
+ */
 void move_to_black_market(object_type *o_ptr)
 {
        /* Not in town */
@@ -5040,9 +5509,10 @@ void move_to_black_market(object_type *o_ptr)
 
        st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
 
-       o_ptr->ident |= IDENT_STOREB;
+       o_ptr->ident |= IDENT_STORE;
 
        (void)store_carry(o_ptr);
 
        object_wipe(o_ptr); /* Don't leave a bogus object behind... */
 }
+