summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-02-09 13:02:06 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-02-09 13:02:06 +0000
commit052f906cf8253d9586caf5e735b1677a490833bb (patch)
tree0308a90f1de21977ab3b87b99307741f5ed84640
parent8c1ca155f86b9828efa8b10d703c2fd523d1e0d9 (diff)
downloadcrawl-ref-052f906cf8253d9586caf5e735b1677a490833bb.tar.gz
crawl-ref-052f906cf8253d9586caf5e735b1677a490833bb.zip
Modified wizmode &" and &~ commands so that you can jump to any level of any
branch instead of only up and down in the current branch. Wizmode &d, &u remains unchanged, although you can also hit &"> and &"< to do the same thing. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@946 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/acr.cc2
-rw-r--r--crawl-ref/source/dat/splev.des1
-rw-r--r--crawl-ref/source/debug.cc41
-rw-r--r--crawl-ref/source/debug.h2
-rw-r--r--crawl-ref/source/overmap.cc11
-rw-r--r--crawl-ref/source/overmap.h1
-rw-r--r--crawl-ref/source/travel.cc110
-rw-r--r--crawl-ref/source/travel.h15
8 files changed, 134 insertions, 49 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index ea6c8daeb1..3ae01782ac 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -542,7 +542,7 @@ static void handle_wizard_command( void )
case '\"':
case '~':
- level_travel(0);
+ wizard_interlevel_travel();
break;
case 'd':
diff --git a/crawl-ref/source/dat/splev.des b/crawl-ref/source/dat/splev.des
index 190718ae0d..28f64e8b32 100644
--- a/crawl-ref/source/dat/splev.des
+++ b/crawl-ref/source/dat/splev.des
@@ -2273,6 +2273,7 @@ MONS: random, random
NAME: swamp
PLACE: Swamp:5
ORIENT: southeast
+FLAGS: no_rotate
# NB - most of the 'x's here will be set to water in dungeon.cc
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index ba6a815086..c21d0e9eb7 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -34,10 +34,12 @@
#include "externs.h"
+#include "branch.h"
#include "direct.h"
#include "describe.h"
#include "dungeon.h"
#include "fight.h"
+#include "files.h"
#include "invent.h"
#include "itemname.h"
#include "itemprop.h"
@@ -58,6 +60,7 @@
#include "stuff.h"
#include "travel.h"
#include "version.h"
+#include "view.h"
#if DEBUG && WIN
#define MyDebugBreak() _asm {int 3}
@@ -654,6 +657,44 @@ void level_travel( int delta )
down_stairs(true, old_level);
untag_followers();
} // end level_travel()
+
+static void wizard_go_to_level(const level_pos &pos)
+{
+ const int abs_depth = absdungeon_depth(pos.id.branch, pos.id.depth);
+ const int stair_taken =
+ abs_depth > you.your_level? DNGN_STONE_STAIRS_DOWN_I
+ : DNGN_STONE_STAIRS_UP_I;
+
+ const int old_level = you.your_level;
+ const int old_where = you.where_are_you;
+ const bool was_a_labyrinth = you.level_type == LEVEL_LABYRINTH;
+
+ you.level_type = LEVEL_DUNGEON;
+ you.where_are_you = pos.id.branch;
+ you.your_level = abs_depth;
+
+ load(stair_taken, LOAD_ENTER_LEVEL, was_a_labyrinth, old_level, old_where);
+ save_game_state();
+ new_level();
+ viewwindow(1, true);
+ // Tell the travel code that we're now on a new level
+ init_new_level(true);
+}
+
+void wizard_interlevel_travel()
+{
+ const level_pos pos =
+ prompt_translevel_target(TPF_ALLOW_UPDOWN | TPF_SHOW_ALL_BRANCHES);
+
+ if (pos.id.depth < 1 || pos.id.depth > branches[pos.id.branch].depth)
+ {
+ canned_msg(MSG_OK);
+ return;
+ }
+
+ wizard_go_to_level(pos);
+}
+
#endif
#ifdef WIZARD
diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h
index f9516020a9..fbf138d6eb 100644
--- a/crawl-ref/source/debug.h
+++ b/crawl-ref/source/debug.h
@@ -134,7 +134,7 @@ void error_message_to_player(void);
* called from: acr
* *********************************************************************** */
void level_travel( int delta );
-
+void wizard_interlevel_travel();
// last updated 12may2000 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index 8d3d8527e2..0dfa0c47fe 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -197,6 +197,17 @@ static void get_matching_portals(
}
}
+bool overmap_knows_portal(dungeon_feature_type portal)
+{
+ for ( portal_map_type::const_iterator pl_iter = portals_present.begin();
+ pl_iter != portals_present.end(); ++pl_iter )
+ {
+ if (portal_to_feature(pl_iter->second) == portal)
+ return (true);
+ }
+ return (false);
+}
+
void get_matching_features(
const base_pattern &pattern, std::vector<stash_search_result> &results)
{
diff --git a/crawl-ref/source/overmap.h b/crawl-ref/source/overmap.h
index e08af57ffd..4703d37395 100644
--- a/crawl-ref/source/overmap.h
+++ b/crawl-ref/source/overmap.h
@@ -16,6 +16,7 @@
#include <vector>
void seen_notable_thing( int which_thing, int x, int y );
+bool overmap_knows_portal(dungeon_feature_type portal);
void display_overmap();
void unnotice_labyrinth_portal();
void unnotice_altar();
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 2c1e89e070..413e73d37a 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -1772,60 +1772,75 @@ static char trans_travel_dest[30];
// Returns true if the player character knows of the existence of the given
// branch (which would make the branch a valid target for interlevel travel).
-static bool is_known_branch(int branch)
+static bool is_known_branch_id(int branch)
{
// The main dungeon is always known.
- if (branch == BRANCH_MAIN_DUNGEON) return true;
+ if (branch == BRANCH_MAIN_DUNGEON)
+ return true;
// If we're in the branch, it darn well is known.
- if (you.where_are_you == branch) return true;
+ if (you.where_are_you == branch)
+ return true;
- // The Vestibule is special: there are no stairs to it, just
- // a portal
+ // The Vestibule is special: there are no stairs to it, just a
+ // portal
if (branch == BRANCH_VESTIBULE_OF_HELL)
- {
- // XXX There must be a better way to do this...
- std::vector<stash_search_result> tmp;
- get_matching_features(text_pattern("gateway to Hell"), tmp);
- return !tmp.empty();
- }
+ return overmap_knows_portal( DNGN_ENTER_HELL );
// If the overmap knows the stairs to this branch, we know the branch.
return ( stair_level.find(static_cast<branch_type>(branch)) !=
stair_level.end() );
}
+static bool is_known_branch(const Branch &br)
+{
+ return (is_known_branch_id(br.id));
+}
+
/*
* Returns a list of the branches that the player knows the location of the
* stairs to, in the same order as overmap.cc lists them.
*/
-static std::vector<branch_type> get_known_branches()
+static std::vector<branch_type> get_branches(bool (*selector)(const Branch &))
{
std::vector<branch_type> result;
for (int i = 0; i < NUM_BRANCHES; ++i)
- if (is_known_branch(branches[i].id))
+ if (selector(branches[i]))
result.push_back(branches[i].id);
return result;
}
-static int prompt_travel_branch()
+static bool is_valid_branch(const Branch &br)
+{
+ return (!!br.shortname);
+}
+
+static int prompt_travel_branch(int prompt_flags)
{
unsigned char branch = BRANCH_MAIN_DUNGEON; // Default
- std::vector<branch_type> br = get_known_branches();
+ std::vector<branch_type> br =
+ get_branches(
+ (prompt_flags & TPF_SHOW_ALL_BRANCHES)?
+ is_valid_branch : is_known_branch );
// Don't kill the prompt even if the only branch we know is the main dungeon
// This keeps things consistent for the player.
- if (br.size() < 1) return branch;
+ if (br.size() < 1)
+ return branch;
+ const bool allow_waypoints = (prompt_flags & TPF_ALLOW_WAYPOINTS);
+ const bool allow_updown = (prompt_flags & TPF_ALLOW_UPDOWN);
+ const bool remember_targ = (prompt_flags & TPF_REMEMBER_TARGET);
+
bool waypoint_list = false;
- int waycount = travel_cache.get_waypoint_count();
+ const int waycount = allow_waypoints? travel_cache.get_waypoint_count() : 0;
+
for ( ; ; )
{
mesclr(true);
- char buf[100];
if (waypoint_list)
travel_cache.list_waypoints();
else
@@ -1840,38 +1855,35 @@ static int prompt_travel_branch()
mpr(line.c_str());
line = "";
}
- snprintf(buf, sizeof buf, "(%c) %-14s ",
- branches[br[i]].travel_shortcut,
- branches[br[i]].shortname);
- line += buf;
+ line += make_stringf("(%c) %-14s ",
+ branches[br[i]].travel_shortcut,
+ branches[br[i]].shortname);
}
if (line.length())
mpr(line.c_str());
}
- char shortcuts[100];
- *shortcuts = 0;
- if (*trans_travel_dest || waycount || waypoint_list)
+ std::string shortcuts;
+ if ((*trans_travel_dest && remember_targ)
+ || (allow_waypoints && (waycount || waypoint_list)))
{
- strncpy(shortcuts, "(", sizeof shortcuts);
+ shortcuts = "(";
if (waypoint_list)
- strncat(shortcuts, "[*] lists branches", sizeof shortcuts);
+ shortcuts += "[*] lists branches";
else if (waycount)
- strncat(shortcuts, "[*] lists waypoints", sizeof shortcuts);
+ shortcuts += "[*] lists waypoints";
- if (*trans_travel_dest)
+ if (*trans_travel_dest && remember_targ)
{
- char travel_dest[60];
- snprintf(travel_dest, sizeof travel_dest, "[Enter] for %s",
- trans_travel_dest);
if (waypoint_list || waycount)
- strncat( shortcuts, ", ", sizeof shortcuts);
- strncat(shortcuts, travel_dest, sizeof shortcuts);
+ shortcuts += ", ";
+
+ shortcuts += make_stringf("[Enter] for %s",
+ trans_travel_dest);
}
- strncat(shortcuts, ") ", sizeof shortcuts);
+ shortcuts += ") ";
}
- snprintf(buf, sizeof buf, "Where do you want to go? %s", shortcuts);
- mpr(buf, MSGCH_PROMPT);
+ mprf(MSGCH_PROMPT, "Where do you want to go? %s", shortcuts.c_str());
int keyin = get_ch();
switch (keyin)
@@ -1881,9 +1893,9 @@ static int prompt_travel_branch()
case '\n': case '\r':
return (ID_REPEAT);
case '<':
- return (ID_UP);
+ return (allow_updown? ID_UP : ID_CANCEL);
case '>':
- return (ID_DOWN);
+ return (allow_updown? ID_DOWN : ID_CANCEL);
case '*':
if (waypoint_list || waycount)
waypoint_list = !waypoint_list;
@@ -1897,8 +1909,9 @@ static int prompt_travel_branch()
}
// Possibly a waypoint number?
- if (keyin >= '0' && keyin <= '9')
+ if ((keyin >= '0' && keyin <= '9') && allow_waypoints)
return (-1 - (keyin - '0'));
+
return (ID_CANCEL);
}
}
@@ -1975,10 +1988,11 @@ static level_pos find_down_level()
return (curr);
}
-static level_pos prompt_translevel_target()
+level_pos prompt_translevel_target(int prompt_flags)
{
level_pos target;
- int branch = prompt_travel_branch();
+ int branch = prompt_travel_branch(prompt_flags);
+ const bool remember_targ = (prompt_flags & TPF_REMEMBER_TARGET);
if (branch == ID_CANCEL)
return (target);
@@ -1990,7 +2004,7 @@ static level_pos prompt_translevel_target()
if (branch == ID_UP)
{
target = find_up_level();
- if (target.id.depth > -1)
+ if (target.id.depth > -1 && remember_targ)
set_trans_travel_dest(trans_travel_dest, sizeof trans_travel_dest,
target);
return (target);
@@ -1999,7 +2013,7 @@ static level_pos prompt_translevel_target()
if (branch == ID_DOWN)
{
target = find_down_level();
- if (target.id.depth > -1)
+ if (target.id.depth > -1 && remember_targ)
set_trans_travel_dest(trans_travel_dest, sizeof trans_travel_dest,
target);
return (target);
@@ -2019,9 +2033,9 @@ static level_pos prompt_translevel_target()
if (target.id.depth < 1 || target.id.depth >= MAX_LEVELS)
target.id.depth = -1;
- if (target.id.depth > -1)
+ if (target.id.depth > -1 && remember_targ)
set_trans_travel_dest(trans_travel_dest, sizeof trans_travel_dest,
- target);
+ target);
return target;
}
@@ -3041,8 +3055,10 @@ void TravelCache::travel_to_waypoint(int num)
if (waypoints[num].id.depth == -1) return;
travel_target = waypoints[num];
+
set_trans_travel_dest(trans_travel_dest, sizeof trans_travel_dest,
- travel_target);
+ travel_target);
+
LevelInfo &li = get_level_info(travel_target.id);
li.travel_to_waypoint(travel_target.pos);
}
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index e0e24d790f..28d980baef 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -81,6 +81,21 @@ bool can_travel_to(const level_id &lid);
bool can_travel_interlevel();
bool prompt_stop_explore(int es_why);
+enum translevel_prompt_flags
+{
+ TPF_NO_FLAGS = 0,
+
+ TPF_ALLOW_WAYPOINTS = 0x1,
+ TPF_ALLOW_UPDOWN = 0x2,
+ TPF_REMEMBER_TARGET = 0x4,
+ TPF_SHOW_ALL_BRANCHES = 0x8,
+
+ TPF_DEFAULT_OPTIONS = TPF_ALLOW_WAYPOINTS | TPF_ALLOW_UPDOWN
+ | TPF_REMEMBER_TARGET
+};
+
+level_pos prompt_translevel_target(int prompt_flags = TPF_DEFAULT_OPTIONS);
+
// Magic numbers for point_distance:
// This square is a trap