summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-09 14:55:40 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-05-09 14:55:40 +0000
commit523f4a0a5478fe3146086a980afa5a8f8ff3d052 (patch)
tree8edcb3caf9df66bc6beec9558dba60da3b9b5a4f /crawl-ref/source
parent7dfc7ccd3de424f1aab582578aabe0cdfa2f9504 (diff)
downloadcrawl-ref-523f4a0a5478fe3146086a980afa5a8f8ff3d052.tar.gz
crawl-ref-523f4a0a5478fe3146086a980afa5a8f8ff3d052.zip
Interlevel travel tweaks:
* ^P at branch prompt selects the parent branch of the branch you're in (or the main dungeon if you're in the main dungeon). * The depth prompt is always shown, even for single-level branches. This may need to be rolled back if it's too annoying. * At the depth prompt, you can use < to go one level above the default (navigating up into the parent branch if necessary) and > to go one level below the default (never navigating into deeper branches). - or p or ^P will change the default to the level closest to the current default in the parent branch. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1437 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/branch.cc55
-rw-r--r--crawl-ref/source/branch.h1
-rw-r--r--crawl-ref/source/hiscores.cc18
-rw-r--r--crawl-ref/source/hiscores.h6
-rw-r--r--crawl-ref/source/libutil.cc3
-rw-r--r--crawl-ref/source/misc.cc8
-rw-r--r--crawl-ref/source/misc.h4
-rw-r--r--crawl-ref/source/tags.cc4
-rw-r--r--crawl-ref/source/travel.cc170
-rw-r--r--crawl-ref/source/travel.h32
10 files changed, 175 insertions, 126 deletions
diff --git a/crawl-ref/source/branch.cc b/crawl-ref/source/branch.cc
index d9b71afd1d..298431f866 100644
--- a/crawl-ref/source/branch.cc
+++ b/crawl-ref/source/branch.cc
@@ -20,8 +20,7 @@ Branch branches[] = {
NULL,
true, true, LIGHTGREY, BROWN,
mons_standard_rare, mons_standard_level,
- 8, 'D'
- },
+ 8, 'D', false },
{ BRANCH_ECUMENICAL_TEMPLE, BRANCH_MAIN_DUNGEON, 1, 5,
DNGN_ENTER_TEMPLE, DNGN_RETURN_FROM_TEMPLE,
@@ -29,7 +28,7 @@ Branch branches[] = {
NULL,
false, false, LIGHTGREY, LIGHTGREY,
mons_standard_rare, mons_standard_level,
- 0, 'T' },
+ 0, 'T', false },
{ BRANCH_ORCISH_MINES, BRANCH_MAIN_DUNGEON, 4, 6,
DNGN_ENTER_ORCISH_MINES, DNGN_RETURN_FROM_ORCISH_MINES,
@@ -37,7 +36,7 @@ Branch branches[] = {
NULL,
true, false, BROWN, BROWN,
mons_mineorc_rare, mons_mineorc_level,
- 20, 'O' },
+ 20, 'O', false },
{ BRANCH_ELVEN_HALLS, BRANCH_ORCISH_MINES, 7, 4,
DNGN_ENTER_ELVEN_HALLS, DNGN_RETURN_FROM_ELVEN_HALLS,
@@ -45,7 +44,7 @@ Branch branches[] = {
NULL,
true, true, DARKGREY, LIGHTGREY,
mons_hallelf_rare, mons_hallelf_level,
- 8, 'E' },
+ 8, 'E', false },
{ BRANCH_LAIR, BRANCH_MAIN_DUNGEON, 10, 8,
DNGN_ENTER_LAIR, DNGN_RETURN_FROM_LAIR,
@@ -53,7 +52,7 @@ Branch branches[] = {
NULL,
true, false, GREEN, BROWN,
mons_lair_rare, mons_lair_level,
- 5, 'L' },
+ 5, 'L', false },
{ BRANCH_SWAMP, BRANCH_LAIR, 5, 3,
DNGN_ENTER_SWAMP, DNGN_RETURN_FROM_SWAMP,
@@ -61,7 +60,7 @@ Branch branches[] = {
NULL,
true, true, BROWN, BROWN,
mons_swamp_rare, mons_swamp_level,
- 0, 'S' },
+ 0, 'S', false },
{ BRANCH_SHOALS, BRANCH_LAIR, 5, 4,
DNGN_ENTER_SHOALS, DNGN_RETURN_FROM_SHOALS,
@@ -69,7 +68,7 @@ Branch branches[] = {
NULL,
true, true, BROWN, BROWN,
mons_shoals_rare, mons_shoals_level,
- 0, 'A' },
+ 0, 'A', false },
{ BRANCH_SLIME_PITS, BRANCH_LAIR, 6, 4,
DNGN_ENTER_SLIME_PITS, DNGN_RETURN_FROM_SLIME_PITS,
@@ -77,7 +76,7 @@ Branch branches[] = {
NULL,
false, false, GREEN, LIGHTGREEN,
mons_pitslime_rare, mons_pitslime_level,
- 5, 'M' },
+ 5, 'M', false },
{ BRANCH_SNAKE_PIT, BRANCH_LAIR, 5, 7,
DNGN_ENTER_SNAKE_PIT, DNGN_RETURN_FROM_SNAKE_PIT,
@@ -85,7 +84,7 @@ Branch branches[] = {
NULL,
true, true, LIGHTGREEN, YELLOW,
mons_pitsnake_rare, mons_pitsnake_level,
- 10, 'P' },
+ 10, 'P', false },
{ BRANCH_HIVE, BRANCH_MAIN_DUNGEON, 4, 15,
DNGN_ENTER_HIVE, DNGN_RETURN_FROM_HIVE,
@@ -93,7 +92,7 @@ Branch branches[] = {
"You hear a buzzing sound coming from all directions.",
false, false, YELLOW, BROWN,
mons_hive_rare, mons_hive_level,
- 0, 'H' },
+ 0, 'H', false },
{ BRANCH_VAULTS, BRANCH_MAIN_DUNGEON, 8, 17,
DNGN_ENTER_VAULTS, DNGN_RETURN_FROM_VAULTS,
@@ -101,7 +100,7 @@ Branch branches[] = {
NULL,
true, true, LIGHTGREY, BROWN,
mons_standard_rare, mons_standard_level,
- 5, 'V' },
+ 5, 'V', false },
{ BRANCH_HALL_OF_BLADES, BRANCH_VAULTS, 1, 4,
@@ -110,7 +109,7 @@ Branch branches[] = {
NULL,
false, true, LIGHTGREY, LIGHTGREY,
mons_hallblade_rare, mons_hallblade_level,
- 0, 'B' },
+ 0, 'B', false },
{ BRANCH_CRYPT, BRANCH_VAULTS, 5, 3,
DNGN_ENTER_CRYPT, DNGN_RETURN_FROM_CRYPT,
@@ -118,7 +117,7 @@ Branch branches[] = {
NULL,
false, true, LIGHTGREY, LIGHTGREY,
mons_crypt_rare, mons_crypt_level,
- 5, 'C' },
+ 5, 'C', false },
{ BRANCH_TOMB, BRANCH_CRYPT, 3, 5,
DNGN_ENTER_TOMB, DNGN_RETURN_FROM_TOMB,
@@ -126,7 +125,7 @@ Branch branches[] = {
NULL,
false, true, YELLOW, LIGHTGREY,
mons_tomb_rare, mons_tomb_level,
- 0, 'G' },
+ 0, 'G', false },
{ BRANCH_VESTIBULE_OF_HELL, BRANCH_MAIN_DUNGEON, 1, -1,
DNGN_ENTER_HELL, NUM_FEATURES, // sentinel
@@ -134,8 +133,7 @@ Branch branches[] = {
NULL,
false, true, LIGHTGREY, LIGHTGREY,
mons_standard_rare, mons_standard_level,
- 0, 'U'
- },
+ 0, 'U', false },
{ BRANCH_DIS, BRANCH_VESTIBULE_OF_HELL, 7, -1,
DNGN_ENTER_DIS, NUM_FEATURES, // sentinel
@@ -143,8 +141,7 @@ Branch branches[] = {
NULL,
false, false, CYAN, CYAN,
mons_dis_rare, mons_dis_level,
- 0, 'I'
- },
+ 0, 'I', true },
{ BRANCH_GEHENNA, BRANCH_VESTIBULE_OF_HELL, 7, -1,
DNGN_ENTER_GEHENNA, NUM_FEATURES, // sentinel
@@ -152,8 +149,7 @@ Branch branches[] = {
NULL,
false, false, DARKGREY, RED,
mons_gehenna_rare, mons_gehenna_level,
- 0, 'N'
- },
+ 0, 'N', true },
{ BRANCH_COCYTUS, BRANCH_VESTIBULE_OF_HELL, 7, -1,
DNGN_ENTER_COCYTUS, NUM_FEATURES, // sentinel
@@ -161,8 +157,7 @@ Branch branches[] = {
NULL,
false, false, LIGHTBLUE, LIGHTCYAN,
mons_cocytus_rare, mons_cocytus_level,
- 0, 'X'
- },
+ 0, 'X', true },
{ BRANCH_TARTARUS, BRANCH_VESTIBULE_OF_HELL, 7, -1,
DNGN_ENTER_TARTARUS, NUM_FEATURES, // sentinel
@@ -170,8 +165,7 @@ Branch branches[] = {
NULL,
false, false, DARKGREY, DARKGREY,
mons_tartarus_rare, mons_tartarus_level,
- 0, 'Y'
- },
+ 0, 'Y', true },
{ BRANCH_INFERNO, BRANCH_MAIN_DUNGEON, -1, -1,
NUM_FEATURES, NUM_FEATURES,
@@ -179,8 +173,7 @@ Branch branches[] = {
NULL,
false, false, BLACK, BLACK,
NULL, NULL,
- 0, 'R'
- },
+ 0, 'R', false },
{ BRANCH_THE_PIT, BRANCH_MAIN_DUNGEON, -1, -1,
NUM_FEATURES, NUM_FEATURES,
@@ -188,8 +181,7 @@ Branch branches[] = {
NULL,
false, false, BLACK, BLACK,
NULL, NULL,
- 0, '0'
- },
+ 0, '0', false },
{ BRANCH_HALL_OF_ZOT, BRANCH_MAIN_DUNGEON, 5, 27,
DNGN_ENTER_ZOT, DNGN_RETURN_FROM_ZOT,
@@ -197,7 +189,7 @@ Branch branches[] = {
NULL,
false, true, BLACK, BLACK,
mons_hallzot_rare, mons_hallzot_level,
- 1, 'Z' },
+ 1, 'Z', false },
{ BRANCH_CAVERNS, BRANCH_MAIN_DUNGEON, -1, -1,
NUM_FEATURES, NUM_FEATURES,
@@ -205,6 +197,5 @@ Branch branches[] = {
NULL,
false, false, BLACK, BLACK,
NULL, NULL,
- 0, 0
- }
+ 0, 0, false }
};
diff --git a/crawl-ref/source/branch.h b/crawl-ref/source/branch.h
index b9fe0774f8..d1e3ca7c7c 100644
--- a/crawl-ref/source/branch.h
+++ b/crawl-ref/source/branch.h
@@ -33,6 +33,7 @@ struct Branch
int (*mons_level_function)(int);
int altar_chance; // in percent
int travel_shortcut; // which key to press for travel
+ bool any_upstair_exits; // any upstair exits the branch (Hell branches)
};
extern Branch branches[];
diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc
index db78f5d592..50e697b100 100644
--- a/crawl-ref/source/hiscores.cc
+++ b/crawl-ref/source/hiscores.cc
@@ -631,12 +631,12 @@ static const char *short_branch_name(int branch)
return ("");
}
-static int str_to_branch(const std::string &branch)
+static branch_type str_to_branch(const std::string &branch)
{
for (int i = 0; i < NUM_BRANCHES; ++i)
{
if (branches[i].abbrevname && branches[i].abbrevname == branch)
- return (i);
+ return (static_cast<branch_type>(i));
}
return (BRANCH_MAIN_DUNGEON);
}
@@ -653,11 +653,11 @@ static const char *level_area_type_name(int level_type)
return ("");
}
-static int str_to_level_area_type(const std::string &s)
+static level_area_type str_to_level_area_type(const std::string &s)
{
for (int i = 0; i < NUM_LEVEL_AREA_TYPES; ++i)
if (s == level_type_names[i])
- return (i);
+ return (static_cast<level_area_type>(i));
return (LEVEL_DUNGEON);
}
@@ -833,9 +833,9 @@ std::string scorefile_entry::short_kill_message() const
// Maps a 0.1.x branch id to a 0.2 branch id. Ugh. Fortunately we need this
// only to read old logfiles/scorefiles.
-int scorefile_entry::kludge_branch(int branch_01) const
+branch_type scorefile_entry::kludge_branch(int branch_01) const
{
- static int branch_map[] = {
+ static branch_type branch_map[] = {
BRANCH_MAIN_DUNGEON, BRANCH_DIS, BRANCH_GEHENNA,
BRANCH_VESTIBULE_OF_HELL, BRANCH_COCYTUS, BRANCH_TARTARUS,
BRANCH_INFERNO, BRANCH_THE_PIT, BRANCH_MAIN_DUNGEON,
@@ -898,7 +898,7 @@ bool scorefile_entry::parse_obsolete_scoreline(const std::string &line)
auxkilldata[0] = 0;
dlvl = hs_nextint(inbuf);
- level_type = hs_nextint(inbuf);
+ level_type = static_cast<level_area_type>(hs_nextint(inbuf));
branch = kludge_branch( hs_nextint(inbuf) );
final_hp = hs_nextint(inbuf);
@@ -1019,8 +1019,8 @@ void scorefile_entry::reset()
death_source_name[0] = 0;
auxkilldata[0] = 0;
dlvl = 0;
- level_type = 0;
- branch = 0;
+ level_type = LEVEL_DUNGEON;
+ branch = BRANCH_MAIN_DUNGEON;
final_hp = -1;
final_max_hp = -1;
final_max_max_hp = -1;
diff --git a/crawl-ref/source/hiscores.h b/crawl-ref/source/hiscores.h
index 806265e928..88fac529d0 100644
--- a/crawl-ref/source/hiscores.h
+++ b/crawl-ref/source/hiscores.h
@@ -100,8 +100,8 @@ public:
std::string death_source_name; // overrides death_source
std::string auxkilldata; // weapon wielded, spell cast, etc
char dlvl; // dungeon level (relative)
- char level_type; // what kind of level died on..
- char branch; // dungeon branch
+ level_area_type level_type; // what kind of level died on..
+ branch_type branch; // dungeon branch
int final_hp; // actual current HPs (probably <= 0)
int final_max_hp; // net HPs after rot
int final_max_max_hp; // gross HPs before rot
@@ -181,7 +181,7 @@ private:
void init_from(const scorefile_entry &other);
- int kludge_branch(int branch_01) const;
+ branch_type kludge_branch(int branch_01) const;
};
#endif // HISCORES_H
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc
index 010602dfca..a2fa623530 100644
--- a/crawl-ref/source/libutil.cc
+++ b/crawl-ref/source/libutil.cc
@@ -840,8 +840,9 @@ int line_reader::process_key(int ch)
{
switch (ch)
{
+ case CONTROL('G'):
case CK_ESCAPE:
- return (ch);
+ return (CK_ESCAPE);
case CK_UP:
case CK_DOWN:
{
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 316f8e1c90..a7a7887402 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1944,14 +1944,14 @@ int place_depth(unsigned short place)
return lev == 0xFF? -1 : lev;
}
-unsigned short get_packed_place( unsigned char branch, int subdepth,
- char level_type )
+unsigned short get_packed_place( branch_type branch, int subdepth,
+ level_area_type level_type )
{
unsigned short place = (unsigned short)
- ( (branch << 8) | (subdepth & 0xFF) );
+ ( (static_cast<int>(branch) << 8) | (subdepth & 0xFF) );
if (level_type == LEVEL_ABYSS || level_type == LEVEL_PANDEMONIUM
|| level_type == LEVEL_LABYRINTH)
- place = (unsigned short) ( (level_type << 8) | 0xFF );
+ place = (unsigned short) ( (static_cast<int>(level_type) << 8) | 0xFF );
return place;
}
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index 2f2a3c1911..59d1e5a2b8 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -165,8 +165,8 @@ void run_environment_effects();
//
unsigned short get_packed_place();
-unsigned short get_packed_place( unsigned char branch, int subdepth,
- char level_type );
+unsigned short get_packed_place( branch_type branch, int subdepth,
+ level_area_type level_type );
int place_branch(unsigned short place);
int place_depth(unsigned short place);
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index aefe3e7e70..a9be5532a7 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -264,9 +264,9 @@ T unmarshall_long_as( struct tagHeader& th )
level_id unmarshall_level_id( tagHeader& th )
{
level_id id;
- id.branch = unmarshallByte(th);
+ id.branch = static_cast<branch_type>(unmarshallByte(th));
id.depth = unmarshallLong(th);
- id.level_type = unmarshallByte(th);
+ id.level_type = static_cast<level_area_type>(unmarshallByte(th));
return (id);
}
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index ef84c2dc5a..af6c26a87e 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -1573,28 +1573,21 @@ void find_travel_pos(int youx, int youy,
* Given a branch id, returns the parent branch. If the branch id is not found,
* returns BRANCH_MAIN_DUNGEON.
*/
-int find_parent_branch(int br)
+branch_type find_parent_branch(branch_type br)
{
return branches[br].parent_branch;
}
extern std::map<branch_type, level_id> stair_level;
-void find_parent_branch(int br, int depth,
- int *pb, int *pd)
+void find_parent_branch(branch_type br, int depth,
+ branch_type *pb, int *pd)
{
- const branch_type bran = static_cast<branch_type>(br);
- if ( stair_level.find(bran) == stair_level.end() )
- {
- *pb = 0;
- *pd = 0; // Check depth before using *pb.
- }
+ *pb = find_parent_branch(br); // Check depth before using *pb.
+ if ( stair_level.find(br) == stair_level.end() )
+ *pd = 0;
else
- {
- // XXX XXX FIXME Just read this from our data...
- *pb = find_parent_branch(bran);
- *pd = stair_level[bran].depth;
- }
+ *pd = stair_level[br].depth;
}
// Appends the passed in branch/depth to the given vector, then attempts to
@@ -1611,7 +1604,7 @@ void find_parent_branch(int br, int depth,
// (Assuming, of course, that the vector started out empty.)
//
void trackback(std::vector<level_id> &vec,
- int branch, int subdepth)
+ branch_type branch, int subdepth)
{
if (subdepth < 1 || subdepth > MAX_LEVELS) return;
@@ -1620,7 +1613,7 @@ void trackback(std::vector<level_id> &vec,
if (branch != BRANCH_MAIN_DUNGEON)
{
- int pb;
+ branch_type pb;
int pd;
find_parent_branch(branch, subdepth, &pb, &pd);
if (pd)
@@ -1632,7 +1625,7 @@ void track_intersect(std::vector<level_id> &cur,
std::vector<level_id> &targ,
level_id *cx)
{
- cx->branch = 0;
+ cx->branch = BRANCH_MAIN_DUNGEON;
cx->depth = -1;
int us = int(cur.size()) - 1, them = int(targ.size()) - 1;
@@ -1814,7 +1807,7 @@ static bool is_valid_branch(const Branch &br)
static int prompt_travel_branch(int prompt_flags)
{
- unsigned char branch = BRANCH_MAIN_DUNGEON; // Default
+ int branch = BRANCH_MAIN_DUNGEON; // Default
std::vector<branch_type> br =
get_branches(
(prompt_flags & TPF_SHOW_ALL_BRANCHES)?
@@ -1831,7 +1824,8 @@ static int prompt_travel_branch(int prompt_flags)
bool waypoint_list = false;
const int waycount = allow_waypoints? travel_cache.get_waypoint_count() : 0;
-
+
+ level_id curr = level_id::current();
for ( ; ; )
{
mesclr(true);
@@ -1891,6 +1885,8 @@ static int prompt_travel_branch(int prompt_flags)
return (allow_updown? ID_UP : ID_CANCEL);
case '>':
return (allow_updown? ID_DOWN : ID_CANCEL);
+ case CONTROL('P'):
+ return find_parent_branch(curr.branch);
case '*':
if (waypoint_list || waycount)
waypoint_list = !waypoint_list;
@@ -1912,47 +1908,32 @@ static int prompt_travel_branch(int prompt_flags)
}
}
-static int prompt_travel_depth(branch_type branch)
+static int travel_depth_keyfilter(int &c)
{
- // Handle one-level branches by not prompting.
- if (single_level_branch(branch))
- return 1;
-
- char buf[100];
- int depth = get_nearest_level_depth(branch);
-
- snprintf(buf, sizeof buf, "What level of %s do you want to go to? "
- "[default %d] ", branches[branch].longname, depth);
- mesclr();
- mpr(buf, MSGCH_PROMPT);
-
- if (cancelable_get_line( buf, sizeof buf ))
- return 0;
-
- if (*buf)
- depth = atoi(buf);
-
- return depth;
+ switch (c)
+ {
+ case '<': case '>':
+ return (-1);
+ case '-':
+ case CONTROL('P'): case 'p':
+ c = '-'; // Make uniform.
+ return (-1);
+ default:
+ return (1);
+ }
}
-static bool is_hell_branch(int branch)
+static bool is_easy_exiting_branch(int branch)
{
- return branch == BRANCH_DIS || branch == BRANCH_TARTARUS
- || branch == BRANCH_COCYTUS || branch == BRANCH_GEHENNA;
-
+ return branches[branch].any_upstair_exits;
}
-static level_pos find_up_level()
+static level_id find_up_level(level_id curr, bool up_branch = false)
{
- level_id curr = level_id::current();
- curr.depth--;
+ --curr.depth;
- if (is_hell_branch(curr.branch))
- {
- curr.branch = BRANCH_VESTIBULE_OF_HELL;
- curr.depth = 1;
- return (curr);
- }
+ if (up_branch || is_easy_exiting_branch(curr.branch))
+ curr.depth = 0;
if (curr.depth < 1)
{
@@ -1970,19 +1951,83 @@ static level_pos find_up_level()
return (parent);
}
}
- return level_pos();
+ return level_id();
}
return (curr);
}
-static level_pos find_down_level()
+static level_id find_up_level()
{
- level_id curr = level_id::current();
- curr.depth++;
+ return (find_up_level(level_id::current()));
+}
+
+static level_id find_down_level(level_id curr)
+{
+ if (curr.depth < branches[curr.branch].depth)
+ ++curr.depth;
return (curr);
}
+static level_id find_down_level()
+{
+ return (find_down_level(level_id::current()));
+}
+
+static void travel_depth_munge(int munge_method, branch_type *br, int *depth)
+{
+ level_id lid(*br, *depth);
+ switch (munge_method)
+ {
+ case '<':
+ lid = find_up_level(lid);
+ break;
+ case '>':
+ lid = find_down_level(lid);
+ break;
+ case '-':
+ lid = find_up_level(lid, true);
+ break;
+ }
+ *br = lid.branch;
+ *depth = lid.depth;
+ if (*depth < 1)
+ *depth = 1;
+}
+
+static level_id prompt_travel_depth(const level_id &id)
+{
+ branch_type branch = id.branch;
+ // Handle one-level branches by not prompting.
+ // if (single_level_branch(branch))
+ // return level_id(branch, 1);
+
+ int depth = get_nearest_level_depth(branch);
+ for (;;)
+ {
+ mesclr();
+ mprf(MSGCH_PROMPT, "What level of %s? "
+ "(default %d) ", branches[branch].longname, depth);
+
+ char buf[100];
+ const int response =
+ cancelable_get_line( buf, sizeof buf, get_number_of_cols(),
+ NULL, travel_depth_keyfilter );
+
+ if (!response)
+ {
+ if (*buf)
+ depth = atoi(buf);
+ return level_id(branch, depth);
+ }
+
+ if (response == ESCAPE)
+ return level_id(BRANCH_MAIN_DUNGEON, 0);
+
+ travel_depth_munge(response, &branch, &depth);
+ }
+}
+
level_pos prompt_translevel_target(int prompt_flags)
{
level_pos target;
@@ -2020,11 +2065,10 @@ level_pos prompt_translevel_target(int prompt_flags)
return target;
}
- target.id.branch = branch;
+ target.id.branch = static_cast<branch_type>(branch);
// User's chosen a branch, so now we ask for a level.
- target.id.depth =
- prompt_travel_depth(static_cast<branch_type>(target.id.branch));
+ target.id = prompt_travel_depth(target.id);
if (target.id.depth < 1 || target.id.depth >= MAX_LEVELS)
target.id.depth = -1;
@@ -2538,14 +2582,14 @@ level_id level_id::current()
level_id level_id::get_next_level_id(const coord_def &pos)
{
- unsigned char gridc = grd[pos.x][pos.y];
+ int gridc = grd[pos.x][pos.y];
level_id id = current();
for ( int i = 0; i < NUM_BRANCHES; ++i )
{
if ( gridc == branches[i].entry_stairs )
{
- id.branch = i;
+ id.branch = static_cast<branch_type>(i);
id.depth = 1;
break;
}
@@ -2592,9 +2636,9 @@ void level_id::save(FILE *file) const
void level_id::load(FILE *file)
{
- branch = readShort(file);
+ branch = static_cast<branch_type>(readShort(file));
depth = readShort(file);
- level_type = readShort(file);
+ level_type = static_cast<level_area_type>(readShort(file));
}
void level_pos::save(FILE *file) const
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index ebb49b69a6..1375b4caf6 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -138,9 +138,9 @@ enum explore_stop_type
struct level_id
{
public:
- int branch; // The branch in which the level is.
- int depth; // What depth (in this branch - starting from 1)
- int level_type;
+ branch_type branch; // The branch in which the level is.
+ int depth; // What depth (in this branch - starting from 1)
+ level_area_type level_type;
public:
// Returns the level_id of the current level.
@@ -150,28 +150,39 @@ public:
// 'pos' on the current level leads to.
static level_id get_next_level_id(const coord_def &pos);
- level_id() : branch(0), depth(-1), level_type(LEVEL_DUNGEON) { }
- level_id(int br, int dep, int ltype = LEVEL_DUNGEON)
+ level_id()
+ : branch(BRANCH_MAIN_DUNGEON), depth(-1),
+ level_type(LEVEL_DUNGEON)
+ {
+ }
+ level_id(branch_type br, int dep, level_area_type ltype = LEVEL_DUNGEON)
: branch(br), depth(dep), level_type(ltype)
{
if (level_type != LEVEL_DUNGEON)
- branch = depth = -1;
+ {
+ depth = -1;
+ branch = NUM_BRANCHES;
+ }
+ }
+ level_id(level_area_type ltype)
+ : branch(BRANCH_MAIN_DUNGEON), depth(-1), level_type(ltype)
+ {
}
- level_id(int ltype) : branch(-1), depth(-1), level_type(ltype) { }
unsigned short packed_place() const;
std::string describe(bool long_name = false, bool with_number = true) const;
void reset()
{
- branch = 0;
+ branch = BRANCH_MAIN_DUNGEON;
depth = -1;
level_type = LEVEL_DUNGEON;
}
bool is_valid() const
{
- return (branch != -1 && depth != -1) || level_type != LEVEL_DUNGEON;
+ return (branch != NUM_BRANCHES && depth != -1)
+ || level_type != LEVEL_DUNGEON;
}
bool operator == ( const level_id &id ) const
@@ -384,7 +395,8 @@ public:
// Get the LevelInfo for the specified level (defaults to the current
// level).
- LevelInfo& get_level_info(unsigned char branch = 0, int depth = -1)
+ LevelInfo& get_level_info(branch_type branch = BRANCH_MAIN_DUNGEON,
+ int depth = -1)
{
return get_level_info( level_id(branch, depth) );
}