summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-22 21:57:11 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-22 21:57:11 +0000
commit49857c60dad6dd03a0f83ef4839304273f1e418c (patch)
tree8612b4a86814982a3434d1d19b09460e28d1cafd
parenta4d7a2e926fd6cb93e044b7e35de6e86bc91ea36 (diff)
downloadcrawl-ref-49857c60dad6dd03a0f83ef4839304273f1e418c.tar.gz
crawl-ref-49857c60dad6dd03a0f83ef4839304273f1e418c.zip
Fixed the bug when dropping too much gold.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@80 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/items.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 4439e8d4c9..13cc34ac2e 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1667,6 +1667,9 @@ bool move_top_item( int src_x, int src_y, int dest_x, int dest_y )
//---------------------------------------------------------------
static void drop_gold(unsigned int amount)
{
+ const unsigned long BIGGEST_QUANT_VALUE =
+ ((1L << (sizeof(mitm[0].quantity)*8 - 1)) - 1000);
+
if (you.gold > 0)
{
if (amount > you.gold)
@@ -1683,6 +1686,13 @@ static void drop_gold(unsigned int amount)
{
if (mitm[i].base_type == OBJ_GOLD)
{
+ if ( mitm[i].quantity + amount > BIGGEST_QUANT_VALUE ) {
+ amount = BIGGEST_QUANT_VALUE - mitm[i].quantity;
+ snprintf(info, INFO_SIZE,
+ "But there's only room for %d.", amount);
+ mpr(info);
+
+ }
inc_mitm_item_quantity( i, amount );
you.gold -= amount;
you.redraw_gold = 1;
@@ -1701,6 +1711,12 @@ static void drop_gold(unsigned int amount)
mpr( "Too many items on this level, not dropping the gold." );
return;
}
+ if (amount > BIGGEST_QUANT_VALUE) {
+ amount = BIGGEST_QUANT_VALUE;
+ snprintf(info, INFO_SIZE,
+ "But there's only room for %d.", amount);
+ mpr(info);
+ }
mitm[i].base_type = OBJ_GOLD;
mitm[i].quantity = amount;