OSDN Git Service

多数のロッドを所持したときにpvalがオーバフローする不具合を修正。
[hengband/hengband.git] / src / store.c
index 445619c..a33cd5e 100644 (file)
@@ -307,13 +307,13 @@ 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
@@ -419,15 +419,15 @@ static void say_comment_3(s32b value, int annoyed)
 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)]);
@@ -442,13 +442,13 @@ static void say_comment_4(void)
 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
@@ -983,6 +983,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;
                }
 
@@ -1138,6 +1139,8 @@ msg_print("
  */
 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
 {
+       int i;
+
        /* Hack -- Identical items cannot be stacked */
        if (o_ptr == j_ptr) return (0);
 
@@ -1162,10 +1165,8 @@ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
        if (o_ptr->art_name || j_ptr->art_name) return (0);
 
        /* Hack -- Identical art_flags! */
-       if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
-               (o_ptr->art_flags2 != j_ptr->art_flags2) ||
-               (o_ptr->art_flags3 != j_ptr->art_flags3))
-                       return (0);
+       for (i = 0; i < TR_FLAG_SIZE; i++)
+               if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
 
        /* Hack -- Never stack "powerful" items */
        if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
@@ -1196,21 +1197,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;
        }
 }
 
@@ -1281,9 +1285,9 @@ static int store_check_num(object_type *o_ptr)
 
 static bool is_blessed(object_type *o_ptr)
 {
-       u32b f1, f2, f3;
-       object_flags(o_ptr, &f1, &f2, &f3);
-       if (f3 & TR3_BLESSED) return (TRUE);
+       u32b flgs[TR_FLAG_SIZE];
+       object_flags(o_ptr, flgs);
+       if (have_flag(flgs, TR_BLESSED)) return (TRUE);
        else return (FALSE);
 }
 
@@ -1308,6 +1312,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:
@@ -1485,6 +1492,7 @@ static bool store_will_buy(object_type *o_ptr)
                                case TV_ARCANE_BOOK:
                                case TV_ENCHANT_BOOK:
                                case TV_DAEMON_BOOK:
+                               case TV_CRUSADE_BOOK:
                                case TV_MUSIC_BOOK:
                                        break;
                                default:
@@ -2089,8 +2097,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);
@@ -2119,8 +2127,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);
@@ -2401,8 +2409,8 @@ static int get_stock(int *com_val, cptr pmt, int i, int j)
 
        /* Build the prompt */
 #ifdef JP
-        (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
-                (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"), 
+       (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
+               (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"), 
                                  I2A(i), I2A(j), pmt);
 #else
        (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
@@ -2659,8 +2667,8 @@ static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
  * 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)
@@ -2800,7 +2808,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)
                        {
@@ -3116,7 +3124,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
@@ -3197,18 +3205,18 @@ static void store_purchase(void)
 
        /* 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)
        {
@@ -3992,21 +4000,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
 
-               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
@@ -4063,7 +4071,7 @@ msg_format("%s
 
 
        /* Describe it fully */
-       if (!identify_fully_aux(o_ptr))
+       if (!screen_object(o_ptr, TRUE))
 #ifdef JP
 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
 #else
@@ -4150,23 +4158,23 @@ 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;
-                                }
+                               /*
+                                * ±£¤·¥ª¥×¥·¥ç¥ó(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();
                        }
@@ -4588,8 +4596,8 @@ void do_cmd_store(void)
                if (cur_store_num == STORE_HOME)
                {
 #ifdef JP
-                   prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
-                   prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
+                  prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
+                  prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
                   prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
 #else
                   prt("g) Get an item.", 21, 27);
@@ -4603,7 +4611,7 @@ void do_cmd_store(void)
                else if (cur_store_num == STORE_MUSEUM)
                {
 #ifdef JP
-                   prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
+                  prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
                   prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
 #else
                   prt("d) Drop an item.", 21, 27);
@@ -4616,8 +4624,8 @@ void do_cmd_store(void)
                else
                {
 #ifdef JP
-                        prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
-                        prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
+                       prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
+                       prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
                        prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30);
 #else
                   prt("p) Purchase an item.", 21, 30);
@@ -4628,29 +4636,29 @@ void do_cmd_store(void)
                }
 
 #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, 56);
+
+               if( rogue_like_commands == TRUE )
+               {
+                       prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
+               }
+               else
+               {
+                       prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 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, 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);
+               }
 #endif
                /* Prompt */
 #ifdef JP