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C
TZ55IZNANEJO2WDTKYWVLY2W2VV6BR7WKIN7XLNISAMMFT6LG2WQC
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;
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)
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;
{
// XXX XXX FIXME Just read this from our data...
*pb = find_parent_branch(bran);
*pd = stair_level[bran].depth;
}
*pd = stair_level[br].depth;
// 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 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);
}
}