Attached Files:
|
0001-Correctly-update-the-shopping-list-when-un-identifyi.patch [^] (3,839 bytes) 2014-03-22 03:39 [Show Content] [Hide Content]From 1ac4c0c05d47e466245035e811da3ca7b3094fb4 Mon Sep 17 00:00:00 2001
From: blackcustard <peterwicksstringfield@gmail.com>
Date: Wed, 19 Mar 2014 09:36:39 -0500
Subject: [PATCH] Correctly update the shopping list when (un)identifying
items.
Fixes at least one (wizmode) inconsistency and at least one (wizmode and
non-wizmode) crash.
Inconsistency: Add an identified item to your shopping list. Unidentify it
(wizmode). Note that the price in the shopping list has not updated.
This inconsistency does not manifest in normal play because identifiying
items updates the shopping list and you can not unidentify items outside
wizmode.
The crash: Empty your shopping list. Add an unidentified scroll you cannot
afford to your shopping list. This scroll is the only item on the shopping
list. Therefore it is the cheapest item on the shopping list that you
cannot afford. Identify another scroll of the same type, causing its price
to increase. Get enough gold to buy it at the old unknown price, but not
at the new known price. Watch the assertion failure when the shopping list
code concludes that you simultaneously can and can not afford to buy the
cheapest previously unaffordable item on your shopping list.
---
crawl-ref/source/itemname.cc | 12 +++++++++---
crawl-ref/source/shopping.cc | 12 ++++++++++--
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 371dca4..30117ab 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -2056,11 +2056,17 @@ bool set_ident_type(object_class_type basetype, int subtype,
you.type_ids[basetype][subtype] = setting;
request_autoinscribe();
- if (setting == ID_KNOWN_TYPE)
- {
+
+ // Our item knowledge changed in a way that could possibly affect shop
+ // prices. ID_UNKNOWN_TYPE is wizmode only.
+ if (setting == ID_KNOWN_TYPE || setting == ID_UNKNOWN_TYPE)
shopping_list.item_type_identified(basetype, subtype);
+
+ // We identified something, maybe we identified other things by process of
+ // elimination. This is a no-op if we call it when setting ==
+ // ID_UNKNOWN_TYPE.
+ if (setting == ID_KNOWN_TYPE)
_maybe_identify_pack_item();
- }
return true;
}
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index 37d8d40..4bc65d9 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -2443,6 +2443,9 @@ void ShoppingList::item_type_identified(object_class_type base_type,
thing[SHOPPING_THING_COST_KEY] =
_shop_get_item_value(item, shop->greed, false);
}
+
+ // Prices could have changed.
+ refresh();
}
int ShoppingList::size() const
@@ -2490,6 +2493,8 @@ void ShoppingList::forget_pos(const level_pos &pos)
i--;
}
}
+
+ // Maybe we just forgot about a shop.
refresh();
}
@@ -2531,12 +2536,12 @@ void ShoppingList::gold_changed(int old_amount, int new_amount)
", or ");
mpr("You can access your shopping list by pressing '$'.");
- // Reset max_buyable and min_unbuyable info
+ // Our gold has changed, maybe we can buy different things now.
refresh();
}
else if (new_amount < old_amount && new_amount < max_buyable_cost)
{
- // Reset max_buyable and min_unbuyable info
+ // As above.
refresh();
}
}
@@ -2763,6 +2768,9 @@ static bool _compare_shopping_things(const CrawlStoreValue& a,
return a_cost < b_cost;
}
+// Reset max_buyable and min_unbuyable info. Call this anytime any of the
+// player's gold, the shopping list, and the prices of the items on it
+// change.
void ShoppingList::refresh()
{
if (!you.props.exists(SHOPPING_LIST_KEY))
--
1.7.11.msysgit.1
|