From 87b16bb06d3f693ec3f6d727a50bdadf4df5c138 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Mon, 24 Nov 2008 05:05:29 +0000 Subject: For items that originate in a portal vault, store the string describing their origin place in "portal_vault_origin" in the item's prop hash table, so that (for example) an item bought in a bazaar will display its origin as "in a bazaar" after exiting the bazaar, instead of "in a Portal Vault". The string can be made different than the default with the "dstorigin" property of the entrance portal marker, or via the lua function dgn.set_level_type_origin(). Ziggurat items now say "on level X of a ziggurat", and sewer items "in the sewers", with other portal vaults using the default. Breaks savefile compatibilty. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7577 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/items.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'crawl-ref/source/items.cc') diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index fc10c34971..8d5b6a9d4a 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -68,6 +68,8 @@ #include "view.h" #include "xom.h" +#define PORTAL_VAULT_ORIGIN_KEY "portal_vault_origin" + static bool _invisible_to_player( const item_def& item ); static void _autoinscribe_item( item_def& item ); static void _autoinscribe_floor_items(); @@ -874,6 +876,14 @@ void origin_set_startequip(item_def &item) } } +void _origin_set_portal_vault(item_def &item) +{ + if (you.level_type != LEVEL_PORTAL_VAULT) + return; + + item.props[PORTAL_VAULT_ORIGIN_KEY] = you.level_type_origin; +} + void origin_set_monster(item_def &item, const monsters *monster) { if (!origin_known(item)) @@ -881,6 +891,7 @@ void origin_set_monster(item_def &item, const monsters *monster) if (!item.orig_monnum) item.orig_monnum = monster->type + 1; item.orig_place = get_packed_place(); + _origin_set_portal_vault(item); } } @@ -888,6 +899,7 @@ void origin_purchased(item_def &item) { // We don't need to check origin_known if it's a shop purchase item.orig_place = get_packed_place(); + _origin_set_portal_vault(item); // Hackiness item.orig_monnum = -1; } @@ -896,6 +908,7 @@ void origin_acquired(item_def &item, int agent) { // We don't need to check origin_known if it's a divine gift item.orig_place = get_packed_place(); + _origin_set_portal_vault(item); // Hackiness item.orig_monnum = -2 - agent; } @@ -990,6 +1003,7 @@ static void _origin_freeze(item_def &item, const coord_def& where) origin_set_monstercorpse(item, where); item.orig_place = get_packed_place(); + _origin_set_portal_vault(item); _check_note_item(item); #ifdef DGL_MILESTONES @@ -1010,6 +1024,12 @@ std::string origin_monster_name(const item_def &item) static std::string _origin_place_desc(const item_def &item) { + if (place_type(item.orig_place) == LEVEL_PORTAL_VAULT + && item.props.exists(PORTAL_VAULT_ORIGIN_KEY)) + { + return item.props[PORTAL_VAULT_ORIGIN_KEY].get_string(); + } + return prep_branch_level_name(item.orig_place); } -- cgit v1.2.3-54-g00ecf