summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/misc.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-24 05:05:29 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-24 05:05:29 +0000
commit87b16bb06d3f693ec3f6d727a50bdadf4df5c138 (patch)
treead3445cac5278e9fa8c422f09d88639935159894 /crawl-ref/source/misc.cc
parent7facfd7958a3f544d702f12310b4d5f40563641b (diff)
downloadcrawl-ref-87b16bb06d3f693ec3f6d727a50bdadf4df5c138.tar.gz
crawl-ref-87b16bb06d3f693ec3f6d727a50bdadf4df5c138.zip
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
Diffstat (limited to 'crawl-ref/source/misc.cc')
-rw-r--r--crawl-ref/source/misc.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index c5cbf044fc..a5f5cc577b 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1359,9 +1359,18 @@ static void leaving_level_now()
std::string newname =
env.markers.property_at(you.pos(), MAT_ANY, "dstname");
+ std::string neworigin =
+ env.markers.property_at(you.pos(), MAT_ANY, "dstorigin");
+
+ you.level_type_origin = "";
+
dungeon_events.fire_position_event(DET_PLAYER_CLIMBS, you.pos());
dungeon_events.fire_event(DET_LEAVING_LEVEL);
+ // Lua scripts explicitly set level_type_origin, so use that.
+ if (!you.level_type_origin.empty())
+ neworigin = you.level_type_origin;
+
// Don't clobber level_type_name for stairs in portal vaults.
if (you.level_type_name.empty() || !newname.empty()
|| you.level_type != LEVEL_PORTAL_VAULT)
@@ -1377,6 +1386,37 @@ static void leaving_level_now()
if (!you.level_type_tag.empty() && you.level_type_name.empty())
you.level_type_name = you.level_type_tag;
+
+ if (!neworigin.empty())
+ you.level_type_origin = neworigin;
+ else if (!you.level_type_name.empty())
+ {
+ std::string lname = lowercase_string(you.level_type_name);
+ std::string article, prep;
+
+ if (starts_with(lname, "level "))
+ prep = "on ";
+ else
+ prep = "in ";
+
+ if (starts_with(lname, "a ") || starts_with(lname, "an ")
+ || starts_with(lname, "the ") || starts_with(lname, "level "))
+ {
+ ; // Doesn't need an article
+ }
+ else
+ {
+ char letter = you.level_type_name[0];
+ if (isupper(letter))
+ article = "the ";
+ else if (is_vowel(letter))
+ article = "an ";
+ else
+ article = "a ";
+ }
+
+ you.level_type_origin = prep + article + you.level_type_name;
+ }
}
static void set_entry_cause(entry_cause_type default_cause,