From: nothere Date: Tue, 15 Jul 2003 06:42:13 +0000 (+0000) Subject: 価格オーバーフローバグの修正でエンバグしており, 手動交渉で魅力が極端 X-Git-Tag: v2.1.2~1268 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=2bdbdcfb53f8ba35bc895b10d9642612585bb325;p=hengband%2Fhengband.git 価格オーバーフローバグの修正でエンバグしており, 手動交渉で魅力が極端 に低い場合などに提示価格がおかしくなるバグを修正. 売却時はadjustは負 になり得るのにu32bにしてしまっていたことが原因. --- diff --git a/src/store.c b/src/store.c index ef95a3434..5eee52c2c 100644 --- a/src/store.c +++ b/src/store.c @@ -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);