OSDN Git Service

悪夢モードでモンスターからの経験値が約2倍入手できていたバグを修正.
[hengband/hengband.git] / src / store.c
index 6bb67ca..11d76df 100644 (file)
@@ -1,15 +1,15 @@
 /* File: store.c */
 
-/* Purpose: Store commands */
-
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, 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.
+ * 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.  Other copyrights may also apply.
  */
 
+/* Purpose: Store commands */
+
 #include "angband.h"
 
 
@@ -20,6 +20,8 @@ static int store_top = 0;
 static store_type *st_ptr = NULL;
 static owner_type *ot_ptr = NULL;
 #endif
+static s16b old_town_num = 0;
+static s16b inner_town_num = 0;
 #define RUMOR_CHANCE 8
 
 #define MAX_COMMENT_1  6
@@ -639,6 +641,11 @@ static store_type *st_ptr = NULL;
 static owner_type *ot_ptr = NULL;
 #endif
 
+/*
+ * We store the current "store feat" here so everyone can access it
+ */
+static int cur_store_feat;
+
 
 
 
@@ -934,6 +941,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 +959,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);
@@ -983,6 +995,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,7 +1016,7 @@ 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:
@@ -1028,7 +1041,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;
@@ -1154,14 +1168,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++)
@@ -1196,21 +1207,24 @@ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
  */
 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;
        }
 }
 
@@ -1410,7 +1424,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:
@@ -1451,7 +1465,7 @@ 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_AMULET:
@@ -1486,7 +1500,7 @@ 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:
@@ -1580,16 +1594,16 @@ static int home_carry(object_type *o_ptr)
                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;
+               if (!object_is_aware(o_ptr)) continue;
+               if (!object_is_aware(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;
+               if (!object_is_known(o_ptr)) continue;
+               if (!object_is_known(j_ptr)) break;
 
                /*
                 * Hack:  otherwise identical rods sort by
@@ -1799,7 +1813,7 @@ 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);
@@ -1916,7 +1930,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;
@@ -1933,7 +1947,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;
@@ -2064,13 +2078,7 @@ 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);
                cur_col += 2;
        }
 
@@ -2083,7 +2091,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);
 
@@ -2113,7 +2121,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);
 
@@ -2323,7 +2331,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;
 
@@ -2585,11 +2593,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 */;
@@ -3333,7 +3355,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
@@ -3360,8 +3382,6 @@ msg_format("%s(%c)
                        /* Player can afford it */
                        if (p_ptr->au >= price)
                        {
-                               int idx;
-
                                /* Say "okay" */
                                say_comment_1();
 
@@ -3389,7 +3409,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
@@ -3402,7 +3422,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);
 
@@ -3411,12 +3431,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
@@ -3427,8 +3447,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))
@@ -3469,7 +3488,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);
                                        }
 
@@ -3541,7 +3560,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
@@ -3680,7 +3699,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
@@ -3727,7 +3746,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))
@@ -3820,6 +3839,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-
@@ -3833,7 +3855,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
@@ -3862,6 +3884,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 */
@@ -3883,7 +3910,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))
                {
@@ -3974,8 +4001,12 @@ msg_format("%s
                        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);
+       }
 }
 
 
@@ -4056,7 +4087,7 @@ msg_print("
        }
 
        /* Description */
-       object_desc(o_name, o_ptr, TRUE, 3);
+       object_desc(o_name, o_ptr, 0);
 
        /* Describe */
 #ifdef JP
@@ -4067,7 +4098,7 @@ msg_format("%s
 
 
        /* Describe it fully */
-       if (!screen_object(o_ptr, TRUE))
+       if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
 #ifdef JP
 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
 #else
@@ -4080,6 +4111,88 @@ msg_print("
 
 
 /*
+ * Remove an item from museum (Originally from TOband)
+ */
+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 > 12) i = 12;
+
+       /* 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);
+
+       /* 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 -= 12;
+
+       /* Redraw everything */
+       display_inventory();
+
+       return;
+}
+
+
+/*
  * Hack -- set this to leave the store
  */
 static bool leave_store = FALSE;
@@ -4273,7 +4386,16 @@ 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);
+                       else do_cmd_browse();
                        break;
                }
 
@@ -4312,7 +4434,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;
                }
@@ -4330,28 +4454,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;
                }
 
@@ -4429,11 +4561,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;
                }
@@ -4455,19 +4594,16 @@ 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 */
 
 
        /* 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("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
@@ -4479,12 +4615,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) ||
@@ -4501,7 +4637,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;
@@ -4540,6 +4676,9 @@ void do_cmd_store(void)
        /* 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];
@@ -4560,9 +4699,6 @@ 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);
 
@@ -4592,28 +4728,28 @@ 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, 27);
+                       prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
+                       prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,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, 27);
+                       prt("d) Drop an item.", 22, 27);
+                       prt("x) eXamine an item in the home.", 23,27);
 #endif
-
                }
 
                /* Museum commands */
                else if (cur_store_num == STORE_MUSEUM)
                {
 #ifdef JP
-                  prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
-                  prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
+                       prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
+                       prt("r) ¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤ë", 22, 27);
+                       prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23, 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, 27);
+                       prt("r) order to Remove an item.", 22, 27);
+                       prt("x) eXamine an item in the museum.", 23, 27);
 #endif
-
                }
 
                /* Shop commands XXX XXX XXX */
@@ -4624,11 +4760,10 @@ void do_cmd_store(void)
                        prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
                        prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,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, 30);
+                       prt("s) Sell an item.", 22, 30);
+                       prt("x) eXamine an item in the shop", 23,30);
 #endif
-
                }
 
 #ifdef JP
@@ -4636,7 +4771,7 @@ void do_cmd_store(void)
 
                prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
 
-               if( rogue_like_commands == TRUE )
+               if (rogue_like_commands)
                {
                        prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
                }
@@ -4647,7 +4782,7 @@ void do_cmd_store(void)
 #else
                prt("i/e) Inventry/Equipment list", 21, 56);
 
-               if( rogue_like_commands == TRUE )
+               if (rogue_like_commands)
                {
                        prt("w/T) Wear/Take off equipment", 22, 56);
                }
@@ -4670,6 +4805,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;
 
@@ -4748,7 +4889,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
@@ -4779,7 +4920,8 @@ void do_cmd_store(void)
                }
 
                /* 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;
@@ -4811,7 +4953,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 */
@@ -4878,20 +5020,21 @@ 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
-
+               }
        }
 }
 
@@ -4903,8 +5046,6 @@ void store_maint(int town_num, int store_num)
 {
        int             j;
 
-       int     old_rating = rating;
-
        cur_store_num = store_num;
 
        /* Ignore home */
@@ -4975,10 +5116,6 @@ 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;
 }
 
 
@@ -5026,7 +5163,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++)
@@ -5043,7 +5180,7 @@ 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);