From 45c785fc5a74ff3df82b88f01657f6b6ad50fc0b Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 18 Nov 2008 13:46:22 +0000 Subject: Portal vault and labyrinth exits will return to the point on the dungeon level where the entrance was. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7470 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/misc.cc | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/misc.cc') diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 1b950bc588..5414e6b14f 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -53,6 +53,7 @@ #include "lev-pand.h" #include "macro.h" #include "makeitem.h" +#include "mapmark.h" #include "message.h" #include "mon-util.h" #include "monstuff.h" @@ -1691,6 +1692,26 @@ void up_stairs(dungeon_feature_type force_stair, request_autopickup(); } // end up_stairs() +// Adds a dungeon marker at the point of the level where returning from +// a labyrinth or portal vault should drop the player. +static void _mark_portal_return_point(const coord_def &pos) +{ + // First toss all markers of this type. Stale markers are possible + // if the player goes to the Abyss from a portal vault / + // labyrinth, thus returning to this level without activating a + // previous portal vault exit marker. + const std::vector markers = env.markers.get_all(MAT_FEATURE); + for (int i = 0, size = markers.size(); i < size; ++i) + env.markers.remove(markers[i]); + + if (!env.markers.find(pos, MAT_FEATURE)) + { + map_feature_marker *mfeat = + new map_feature_marker(pos, DNGN_EXIT_PORTAL_VAULT); + env.markers.add(mfeat); + } +} + void down_stairs( int old_level, dungeon_feature_type force_stair, entry_cause_type entry_cause ) { @@ -1825,9 +1846,9 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, } // Interlevel travel data. - bool collect_travel_data = can_travel_interlevel(); + const bool collect_travel_data = can_travel_interlevel(); - level_id old_level_id = level_id::current(); + const level_id old_level_id = level_id::current(); LevelInfo &old_level_info = travel_cache.get_level_info(old_level_id); const coord_def stair_pos = you.pos(); if (collect_travel_data) @@ -1872,7 +1893,13 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, } if (stair_find == DNGN_ENTER_LABYRINTH) - dungeon_terrain_changed(you.pos(), DNGN_FLOOR); + dungeon_terrain_changed(you.pos(), DNGN_STONE_ARCH); + + if (stair_find == DNGN_ENTER_LABYRINTH + || stair_find == DNGN_ENTER_PORTAL_VAULT) + { + _mark_portal_return_point(you.pos()); + } if (stair_find == DNGN_ENTER_LABYRINTH) you.level_type = LEVEL_LABYRINTH; -- cgit v1.2.3-54-g00ecf