From 4779ce0e5239186180f9139678ef090b0fc7b856 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 25 Nov 2008 12:05:29 +0000 Subject: The "Place:" for ziggurats now displays as "Ziggurat:1"/"Ziggurat:2"/etc instead of "A Ziggurat". Notes now remember which type of portal you entered: 153 | Portal | Entered level 1 of a ziggurat. 168 | Portal | Entered level 2 of a ziggurat. 189 | Bazaar | Entered a bazaar. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7606 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/dat/clua/ziggurat.lua | 2 ++ crawl-ref/source/luadgn.cc | 20 +++++++++++++++++++ crawl-ref/source/misc.cc | 36 +++++++++++++++++++++++++++++++++- crawl-ref/source/notes.cc | 13 +++++++++--- crawl-ref/source/output.cc | 10 +++++++++- 5 files changed, 76 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/dat/clua/ziggurat.lua b/crawl-ref/source/dat/clua/ziggurat.lua index 65927e7b1f..23df58a59a 100644 --- a/crawl-ref/source/dat/clua/ziggurat.lua +++ b/crawl-ref/source/dat/clua/ziggurat.lua @@ -62,6 +62,7 @@ end function zig_depth_increment() zig().depth = zig().depth + 1 zig().level = { } + dgn.set_level_type_name ("Ziggurat:" .. zig().depth) dgn.set_level_type_origin("on level " .. zig().depth .. " of a ziggurat") end @@ -76,6 +77,7 @@ function ziggurat_portal(e) return one_way_stair { desc = "gateway to a ziggurat", dst = "ziggurat", + dstname = "Ziggurat:1", dstorigin = "on level 1 of a ziggurat", floor = "stone_arch", onclimb = ziggurat_initialiser diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index 53194de4ea..f760a90e0d 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -2232,6 +2232,25 @@ LUAFN(dgn_level_name) return (1); } +LUAFN(dgn_set_level_type_name) +{ + if (you.level_type != LEVEL_PORTAL_VAULT) + { + luaL_error(ls, "Can only set level type name on portal vaults"); + return(0); + } + + if (!lua_isstring(ls, 1)) + { + luaL_argerror(ls, 1, "Expected string for level type name"); + return(0); + } + + you.level_type_name = luaL_checkstring(ls, 1); + + return(0); +} + LUAFN(dgn_set_level_type_origin) { if (you.level_type != LEVEL_PORTAL_VAULT) @@ -2492,6 +2511,7 @@ static const struct luaL_reg dgn_lib[] = { "level_id", dgn_level_id }, { "level_name", dgn_level_name }, + { "set_level_type_name", dgn_set_level_type_name }, { "set_level_type_origin", dgn_set_level_type_origin }, { "map_by_tag", dgn_map_by_tag }, { "map_in_depth", dgn_map_in_depth }, diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index c5e0878a52..d7d8fb9c1b 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1356,6 +1356,7 @@ static void leaving_level_now() const std::string newtype = env.markers.property_at(you.pos(), MAT_ANY, "dst"); + const std::string oldname = you.level_type_name; std::string newname = env.markers.property_at(you.pos(), MAT_ANY, "dstname"); @@ -1367,6 +1368,10 @@ static void leaving_level_now() dungeon_events.fire_position_event(DET_PLAYER_CLIMBS, you.pos()); dungeon_events.fire_event(DET_LEAVING_LEVEL); + // Lua scripts explicitly set level_type_na,e so use that. + if (you.level_type_name != oldname) + newname = you.level_type_name; + // Lua scripts explicitly set level_type_origin, so use that. if (!you.level_type_origin.empty()) neworigin = you.level_type_origin; @@ -2400,7 +2405,36 @@ void trackers_init_new_level(bool transit) void new_level(void) { - take_note(Note(NOTE_DUNGEON_LEVEL_CHANGE)); + if (you.level_type == LEVEL_PORTAL_VAULT) + { + std::string name = "Portal"; + if (you.level_type_name.length() <= 7 + && you.level_type_name.find(":") == std::string::npos) + { + name = uppercase_first(you.level_type_name); + } + else if (you.level_type_tag.length() <= 7) + { + name = uppercase_first(you.level_type_tag); + name = replace_all(name, "_", " "); + } + + // If there's more than one word in level_type_origin then skip + // the first, since it's most likely a preposition. + std::string desc = "Entered "; + size_t space = you.level_type_origin.find(" "); + if (space == std::string::npos) + desc += you.level_type_origin; + else + desc += you.level_type_origin.substr(space + 1); + desc += "."; + + take_note(Note(NOTE_DUNGEON_LEVEL_CHANGE, 0, 0, name.c_str(), + desc.c_str())); + } + else + take_note(Note(NOTE_DUNGEON_LEVEL_CHANGE)); + print_stats_level(); #ifdef DGL_WHEREIS whereis_record(); diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc index dbdb0bcdca..e3018971e3 100644 --- a/crawl-ref/source/notes.cc +++ b/crawl-ref/source/notes.cc @@ -249,8 +249,12 @@ std::string Note::describe( bool when, bool where, bool what ) const if (where) { - result << "| " << std::setw(7) << std::left - << short_place_name(packed_place) << " | "; + if (type == NOTE_DUNGEON_LEVEL_CHANGE && !name.empty()) + result << "| " << std::setw(7) << std::left + << name << " | "; + else + result << "| " << std::setw(7) << std::left + << short_place_name(packed_place) << " | "; } if (what) @@ -276,7 +280,10 @@ std::string Note::describe( bool when, bool where, bool what ) const result << "Reached XP level " << first << ". " << name; break; case NOTE_DUNGEON_LEVEL_CHANGE: - result << "Entered " << place_name(packed_place, true, true); + if ( !desc.empty() ) + result << desc; + else + result << "Entered " << place_name(packed_place, true, true); break; case NOTE_LEARN_SPELL: result << "Learned a level " diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 39b0fb8c9e..b6b5d4795f 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -900,7 +900,15 @@ static std::string _level_description_string_hud() || place.level_type == LEVEL_LABYRINTH) { if (!you.level_type_name.empty()) - short_name = article_a(upcase_first(you.level_type_name), false); + { + // If the level name is faking a dungeon depth + // (i.e., "Ziggurat:3") then don't add an article + if (you.level_type_name.find(":") != std::string::npos) + short_name = you.level_type_name; + else + short_name = article_a(upcase_first(you.level_type_name), + false); + } else short_name.insert(0, "A "); } -- cgit v1.2.3-54-g00ecf