OSDN Git Service

価格オーバーフローバグの修正でエンバグしており, 手動交渉で魅力が極端
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 15 Jul 2003 06:42:13 +0000 (06:42 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 15 Jul 2003 06:42:13 +0000 (06:42 +0000)
に低い場合などに提示価格がおかしくなるバグを修正. 売却時はadjustは負
になり得るのにu32bにしてしまっていたことが原因.

src/store.c

index ef95a34..5eee52c 100644 (file)
@@ -936,6 +936,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 */
@@ -950,11 +954,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) */
-       /* Hack -- prevent overflow */
-       price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
+               /* 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);