diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-01-01 05:02:09 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-01-03 04:45:59 +0100 |
commit | 405e9b68034c5e8793f6c169cbed7dd90d4ac8ba (patch) | |
tree | 792e3efe617bb42cfd8dadfb2c20947cad734e74 | |
parent | 29969a4f936d3357f5f25971cbff31c026872a29 (diff) | |
download | crawl-ref-405e9b68034c5e8793f6c169cbed7dd90d4ac8ba.tar.gz crawl-ref-405e9b68034c5e8793f6c169cbed7dd90d4ac8ba.zip |
Use branch depth rather than absolute depth as the authoritative one.
46 files changed, 202 insertions, 245 deletions
diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc index 5c0fdb9a6c..5734f9d612 100644 --- a/crawl-ref/source/arena.cc +++ b/crawl-ref/source/arena.cc @@ -200,7 +200,7 @@ namespace arena if (!in_bounds(loc)) break; - const int imon = dgn_place_monster(spec, you.absdepth0, + const int imon = dgn_place_monster(spec, -1, loc, false, true, false); if (imon == -1) { @@ -238,7 +238,7 @@ namespace arena if (place.is_valid()) { you.where_are_you = place.branch; - you.absdepth0 = place.absdepth(); + you.depth = place.depth; } dgn_reset_level(); @@ -758,8 +758,7 @@ namespace arena if (fac.friendly) spec.attitude = ATT_FRIENDLY; - int idx = dgn_place_monster(spec, you.absdepth0, pos, false, - true); + int idx = dgn_place_monster(spec, -1, pos, false, true); if (idx == -1 && fac.active_members == 0 && monster_at(pos)) @@ -790,8 +789,7 @@ namespace arena monster_teleport(other, true); } - idx = dgn_place_monster(spec, you.absdepth0, pos, false, - true); + idx = dgn_place_monster(spec, -1, pos, false, true); } if (idx != -1) diff --git a/crawl-ref/source/branch.cc b/crawl-ref/source/branch.cc index 99dea92117..7cac78d88b 100644 --- a/crawl-ref/source/branch.cc +++ b/crawl-ref/source/branch.cc @@ -19,21 +19,16 @@ const Branch& your_branch() bool at_branch_bottom() { - return brdepth[you.where_are_you] == player_branch_depth(); + return brdepth[you.where_are_you] == you.depth; } level_id branch_entry_level(branch_type branch) { // Hell and its subbranches need obnoxious special-casing: if (branch == BRANCH_VESTIBULE_OF_HELL) - { - return level_id(you.hell_branch, - subdungeon_depth(you.hell_branch, you.hell_exit)); - } + return level_id(you.hell_branch, you.hell_exit); else if (is_hell_subbranch(branch)) - { return level_id(BRANCH_VESTIBULE_OF_HELL, 1); - } const branch_type parent = branches[branch].parent_branch; const int subdepth = startdepth[branch]; diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 440defe6ba..bba96cc6ef 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -628,11 +628,8 @@ static void _sdump_notes(dump_params &par) //--------------------------------------------------------------- static void _sdump_location(dump_params &par) { - if (you.absdepth0 == -1 - && player_in_branch(BRANCH_MAIN_DUNGEON)) - { + if (you.depth == 0 && player_in_branch(BRANCH_MAIN_DUNGEON)) par.text += "You escaped"; - } else if (par.se) par.text += "You were " + prep_branch_level_name(); else diff --git a/crawl-ref/source/dat/des/builder/layout.des b/crawl-ref/source/dat/des/builder/layout.des index 932983f525..3063927d55 100644 --- a/crawl-ref/source/dat/des/builder/layout.des +++ b/crawl-ref/source/dat/des/builder/layout.des @@ -363,7 +363,7 @@ TAGS: overwritable layout allow_dup unrand end end - if (you.in_branch("D") and you.subdepth() > 21 or you.where() == "Pan") + if (you.in_branch("D") and you.depth() > 21 or you.where() == "Pan") and crawl.coinflip() then mapgrd[40][36] = 'O' diff --git a/crawl-ref/source/dat/des/portals/icecave.des b/crawl-ref/source/dat/des/portals/icecave.des index d025d81d09..389c789943 100644 --- a/crawl-ref/source/dat/des/portals/icecave.des +++ b/crawl-ref/source/dat/des/portals/icecave.des @@ -44,14 +44,14 @@ function ice_cave_portal(e) local difficulty = "ice_cave_easy" -- Handle overlapping depths for easy and hard maps with a coinflip. - if you.branch() == "D" and you.subdepth() == 14 or - you.branch() == "Elf" and you.subdepth() < 3 then + if you.branch() == "D" and you.depth() == 14 or + you.branch() == "Elf" and you.depth() < 3 then if crawl.coinflip() then difficulty = "ice_cave_hard" end end - if you.branch() == "D" and you.subdepth() >= 15 or + if you.branch() == "D" and you.depth() >= 15 or you.branch() == "Elf" or you.branch() == "Vault" then difficulty = "ice_cave_hard" diff --git a/crawl-ref/source/dbg-asrt.cc b/crawl-ref/source/dbg-asrt.cc index 657ea487ac..4c372ec86e 100644 --- a/crawl-ref/source/dbg-asrt.cc +++ b/crawl-ref/source/dbg-asrt.cc @@ -100,8 +100,8 @@ static void _dump_level_info(FILE* file) fprintf(file, "Place info:\n"); - fprintf(file, "absdepth0 = %d, branch = %d\n\n", - you.absdepth0, (int) you.where_are_you); + fprintf(file, "branch = %d, depth = %d\n\n", + (int)you.where_are_you, you.depth); std::string place = level_id::current().describe(); std::string orig_place; diff --git a/crawl-ref/source/dbg-maps.cc b/crawl-ref/source/dbg-maps.cc index ab71849d20..7c0d8c5603 100644 --- a/crawl-ref/source/dbg-maps.cc +++ b/crawl-ref/source/dbg-maps.cc @@ -162,8 +162,8 @@ static bool mg_build_dungeon() for (int i = 0, size = places.size(); i < size; ++i) { const level_id &lid = places[i]; - you.absdepth0 = absdungeon_depth(lid.branch, lid.depth); you.where_are_you = lid.branch; + you.depth = lid.depth; if (!mg_do_build_level(1)) return (false); } diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index fbc154fe9e..cc67800fec 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -3147,10 +3147,9 @@ void shuffle_all_decks_on_level() if (item.defined() && is_deck(item)) { #ifdef DEBUG_DIAGNOSTICS - mprf(MSGCH_DIAGNOSTICS, "Shuffling: %s on level %d, branch %d", + mprf(MSGCH_DIAGNOSTICS, "Shuffling: %s on %s", item.name(DESC_PLAIN).c_str(), - static_cast<int>(you.absdepth0), - static_cast<int>(you.where_are_you)); + level_id::current().describe().c_str()); #endif _unmark_and_shuffle_deck(item); } diff --git a/crawl-ref/source/dgn-labyrinth.cc b/crawl-ref/source/dgn-labyrinth.cc index 00d44f88e4..380f08c268 100644 --- a/crawl-ref/source/dgn-labyrinth.cc +++ b/crawl-ref/source/dgn-labyrinth.cc @@ -15,6 +15,7 @@ #include "misc.h" #include "mon-pathfind.h" #include "mon-place.h" +#include "place.h" typedef std::list<coord_def> coord_list; @@ -108,7 +109,7 @@ static void _labyrinth_place_items(const coord_def &end) const int treasure_item = items(1, glopop, OBJ_RANDOM, true, - one_chance_in(3)? you.absdepth0 * 3 : MAKE_GOOD_ITEM, + one_chance_in(3)? absdungeon_depth() * 3 : MAKE_GOOD_ITEM, MAKE_ITEM_RANDOM_RACE); if (treasure_item != NON_ITEM) diff --git a/crawl-ref/source/dgn-layouts.cc b/crawl-ref/source/dgn-layouts.cc index b1836f735a..bd8240f516 100644 --- a/crawl-ref/source/dgn-layouts.cc +++ b/crawl-ref/source/dgn-layouts.cc @@ -5,10 +5,11 @@ #include "AppHdr.h" +#include "coordit.h" #include "dungeon.h" -#include "traps.h" #include "libutil.h" -#include "coordit.h" +#include "place.h" +#include "traps.h" static bool _find_forbidden_in_area(dgn_region& area, unsigned int mask); static int _count_antifeature_in_box(int x0, int y0, int x1, int y1, @@ -42,8 +43,10 @@ static bool _may_overwrite_pos(coord_def c); static void _build_river(dungeon_feature_type river_type); static void _build_lake(dungeon_feature_type lake_type); -void dgn_build_basic_level(int level_number) +void dgn_build_basic_level() { + int level_number = absdungeon_depth(); + env.level_build_method += " basic"; env.level_layout_types.insert("basic"); diff --git a/crawl-ref/source/dgn-layouts.h b/crawl-ref/source/dgn-layouts.h index 8d6167ef18..bb4d5c53c5 100644 --- a/crawl-ref/source/dgn-layouts.h +++ b/crawl-ref/source/dgn-layouts.h @@ -3,7 +3,7 @@ #include "enum.h" -void dgn_build_basic_level(int level_number); +void dgn_build_basic_level(); void dgn_build_bigger_room_level(void); void dgn_build_chaotic_city_level(dungeon_feature_type force_wall); void dgn_build_rooms_level(int nrooms); diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc index 56279abb20..f55a6530db 100644 --- a/crawl-ref/source/dgn-shoals.cc +++ b/crawl-ref/source/dgn-shoals.cc @@ -685,12 +685,12 @@ void dgn_shoals_generate_flora() } } -void dgn_build_shoals_level(int level_number) +void dgn_build_shoals_level() { - env.level_build_method += make_stringf(" shoals+ [%d]", level_number); + env.level_build_method += make_stringf(" shoals+ [%d]", you.depth); env.level_layout_types.insert("shoals"); - const int shoals_depth = level_id::current().depth - 1; + const int shoals_depth = you.depth - 1; dgn_replace_area(0, 0, GXM-1, GYM-1, DNGN_ROCK_WALL, DNGN_OPEN_SEA); _shoals_init_heights(); _shoals_init_islands(shoals_depth); diff --git a/crawl-ref/source/dgn-shoals.h b/crawl-ref/source/dgn-shoals.h index bee5f85d07..24e17da41a 100644 --- a/crawl-ref/source/dgn-shoals.h +++ b/crawl-ref/source/dgn-shoals.h @@ -1,7 +1,7 @@ #ifndef DGN_SHOALS_H #define DGN_SHOALS_H -void dgn_build_shoals_level(int level_number); +void dgn_build_shoals_level(); void dgn_shoals_generate_flora(); void shoals_postprocess_level(); void shoals_apply_tides(int turns_elapsed, bool force, diff --git a/crawl-ref/source/dgn-swamp.cc b/crawl-ref/source/dgn-swamp.cc index 079ea6eeed..2550f2d55e 100644 --- a/crawl-ref/source/dgn-swamp.cc +++ b/crawl-ref/source/dgn-swamp.cc @@ -56,12 +56,12 @@ static void _swamp_apply_features(int margin) } } -void dgn_build_swamp_level(int level) +void dgn_build_swamp_level() { env.level_build_method += " swamp"; env.level_layout_types.insert("swamp"); - const int swamp_depth = level_id::current().depth - 1; + const int swamp_depth = you.depth - 1; dgn_initialise_heightmap(-17); _swamp_slushy_patches(swamp_depth * 3); dgn_smooth_heights(); diff --git a/crawl-ref/source/dgn-swamp.h b/crawl-ref/source/dgn-swamp.h index 9cb8894a98..609b0b14b0 100644 --- a/crawl-ref/source/dgn-swamp.h +++ b/crawl-ref/source/dgn-swamp.h @@ -1,6 +1,6 @@ #ifndef DGN_SWAMP_H #define DGN_SWAMP_H -void dgn_build_swamp_level(int level); +void dgn_build_swamp_level(); #endif diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 3e3a55edc7..0aebba2452 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -1110,7 +1110,7 @@ static bool _valid_dungeon_level() // D:1 only. // Also, what's the point of this check? Regular connectivity should // do that already. - if (you.absdepth0 == 0) + if (player_in_branch(BRANCH_MAIN_DUNGEON) && you.depth == 1) return _is_level_stair_connected(branches[BRANCH_MAIN_DUNGEON].exit_stairs); return (true); @@ -1288,13 +1288,11 @@ static void _fixup_walls() case BRANCH_VAULTS: { - const int bdepth = player_branch_depth(); - - if (bdepth > 6 && one_chance_in(10)) + if (you.depth > 6 && one_chance_in(10)) wall_type = DNGN_GREEN_CRYSTAL_WALL; - else if (bdepth > 4) + else if (you.depth > 4) wall_type = DNGN_METAL_WALL; - else if (bdepth > 2) + else if (you.depth > 2) wall_type = DNGN_STONE_WALL; break; @@ -1356,7 +1354,7 @@ static void _fixup_branch_stairs() // Top level of branch levels - replaces up stairs with stairs back to // dungeon or wherever: if (your_branch().exit_stairs != NUM_FEATURES - && player_branch_depth() == 1 + && you.depth == 1 && player_in_connected_branch()) { const dungeon_feature_type exit = your_branch().exit_stairs; @@ -1796,10 +1794,10 @@ static void _build_overflow_temples() CrawlVector &levels = you.props[OVERFLOW_TEMPLES_KEY].get_vector(); // Are we deeper than the last overflow temple? - if (you.absdepth0 >= levels.size()) + if (you.depth >= levels.size() + 1) return; - CrawlStoreValue &val = levels[you.absdepth0]; + CrawlStoreValue &val = levels[you.depth - 1]; // Does this level have an overflow temple? if (val.get_flags() & SFLAG_UNSET) @@ -2072,7 +2070,7 @@ static void _place_feature_mimics(dungeon_feature_type dest_stairs_type) // If this is the real branch entry, don't mimic it. if (feat_is_branch_stairs(feat) - && player_branch_depth() == startdepth[get_branch_at(pos)]) + && you.depth == startdepth[get_branch_at(pos)]) { continue; } @@ -2153,7 +2151,7 @@ static void _build_dungeon_level(dungeon_feature_type dest_stairs_type) if (player_in_branch(BRANCH_LAIR)) { - int depth = player_branch_depth() + 1; + int depth = you.depth + 1; do { _ruin_level(rectangle_iterator(1), MMT_VAULT, @@ -2992,7 +2990,7 @@ static void _place_traps() { int max_webs = 400 - num_traps - 50; // Adjust for branch depth - max_webs = max_webs / (6 - player_branch_depth()) / 2; + max_webs = max_webs / (6 - you.depth) / 2; // Vary from 1/2 to full max amount place_webs(max_webs + random2(max_webs)); } @@ -3184,13 +3182,13 @@ static void _place_branch_entrances() const bool mimic = !branch_is_unfinished(b->id) && !is_hell_subbranch(b->id) && dlevel >= FEATURE_MIMIC_DEPTH - && player_branch_depth() >= b->mindepth - && player_branch_depth() <= b->maxdepth + && you.depth >= b->mindepth + && you.depth <= b->maxdepth && one_chance_in(FEATURE_MIMIC_CHANCE); if (b->entry_stairs != NUM_FEATURES && player_in_branch(b->parent_branch) - && (player_branch_depth() == startdepth[i] || mimic)) + && (you.depth == startdepth[i] || mimic)) { // Place a stair. dprf("Placing stair to %s", b->shortname); @@ -3356,7 +3354,7 @@ static void _place_aquatic_monsters() if (player_in_branch(BRANCH_SHOALS) || player_in_branch(BRANCH_ABYSS) || (player_in_branch(BRANCH_MAIN_DUNGEON) - && you.absdepth0 < 5)) + && level_number < 5)) { return; } @@ -3847,7 +3845,7 @@ static void _build_postvault_level(vault_placement &place) if (place.map.has_tag("dis")) dgn_build_chaotic_city_level(DNGN_METAL_WALL); else if (player_in_branch(BRANCH_SWAMP)) - dgn_build_swamp_level(place.level_number); + dgn_build_swamp_level(); else { dgn_build_rooms_level(random_range(25, 100)); @@ -3879,7 +3877,7 @@ int dgn_item_corpse(const item_spec &ispec, const coord_def where) { if (tries > 200) return NON_ITEM; - int mindex = dgn_place_monster(mspec, you.absdepth0, coord_def(), true); + int mindex = dgn_place_monster(mspec, -1, coord_def(), true); if (invalid_monster_index(mindex)) continue; menv[mindex].position = where; @@ -3922,7 +3920,7 @@ int dgn_place_item(const item_spec &spec, return (NON_ITEM); if (level == INVALID_ABSDEPTH) - level = you.absdepth0; + level = absdungeon_depth(); object_class_type base_type = spec.base_type; bool acquire = false; @@ -4223,6 +4221,9 @@ int dgn_place_monster(mons_spec &mspec, const bool m_patrolling = (patrolling || mspec.patrolling); const bool m_band = mspec.band; + if (monster_level == -1) + monster_level = absdungeon_depth(); + const int mlev = mspec.mlevel; if (mlev) { @@ -5875,8 +5876,8 @@ static bool _fixup_interlevel_connectivity() return (true); StairConnectivity prev_con; - if (player_branch_depth() > 1) - prev_con = connectivity[your_branch().id][player_branch_depth() - 2]; + if (you.depth > 1) + prev_con = connectivity[your_branch().id][you.depth - 2]; StairConnectivity this_con; FixedVector<coord_def, 3> up_gc; @@ -6125,9 +6126,9 @@ static bool _fixup_interlevel_connectivity() } // Save the connectivity. - if (player_branch_depth() > 1) - connectivity[your_branch().id][player_branch_depth() - 2] = prev_con; - connectivity[your_branch().id][player_branch_depth() - 1] = this_con; + if (you.depth > 1) + connectivity[your_branch().id][you.depth - 2] = prev_con; + connectivity[your_branch().id][you.depth - 1] = this_con; return (true); } diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 1327ded746..ff50fd8255 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -2267,7 +2267,7 @@ void handle_time() } if (player_in_branch(BRANCH_SPIDER_NEST) && coinflip()) - place_webs(random2(20 / (6 - player_branch_depth())), true); + place_webs(random2(20 / (6 - you.depth)), true); } // Move monsters around to fake them walking around while player was @@ -3140,9 +3140,7 @@ void recharge_rods(int aut, bool level_only) void slime_wall_damage(actor* act, int delay) { - const int depth = player_in_branch(BRANCH_SLIME_PITS) - ? player_branch_depth() - : 1; + const int depth = player_in_branch(BRANCH_SLIME_PITS) ? you.depth : 1; int walls = 0; for (adjacent_iterator ai(act->pos()); ai; ++ai) diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 01e4d68e70..3c3d4e401a 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -1138,7 +1138,7 @@ bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode, #ifdef DEBUG_LEVEL_LOAD mprf(MSGCH_DIAGNOSTICS, "Loading... branch: %d, level: %d", - you.where_are_you, you.absdepth0); + you.where_are_you, you.depth); #endif // Destination position for hatch. @@ -1210,10 +1210,8 @@ bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode, && player_in_branch(BRANCH_MAIN_DUNGEON)) { // If we're leaving the Abyss for the first time as a Chaos - // Knight of Lugonu (who start out there), force a return - // into the first dungeon level and enable normal monster + // Knight of Lugonu (who start out there), enable normal monster // generation. - you.absdepth0 = 0; you.char_direction = GDT_DESCENDING; } @@ -1233,7 +1231,7 @@ bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode, just_created_level = true; if (!crawl_state.game_is_tutorial() - && you.absdepth0 > 1 + && (!player_in_branch(BRANCH_MAIN_DUNGEON) || you.depth > 2) && one_chance_in(3)) { load_ghost(true); @@ -1825,7 +1823,7 @@ static void _load_level(const level_id &level) { // Load the given level. you.where_are_you = level.branch; - you.absdepth0 = level.absdepth(); + you.depth = level.depth; load_level(DNGN_STONE_STAIRS_DOWN_I, LOAD_VISITOR, level_id()); } @@ -2015,9 +2013,7 @@ static bool _restore_tagged_chunk(package *save, const std::string name, return false; } else - { end(-1, false, "\n%s %s\n", complaint, reason.c_str()); - } } crawl_state.minorVersion = inf.getMinorVersion(); @@ -2083,8 +2079,8 @@ void save_ghost(bool force) #endif // BONES_DIAGNOSTICS - // No ghosts on levels 1, 2, or the ET. - if (!force && (you.absdepth0 < 2 + // No ghosts on D:1, D:2, or the Temple. + if (!force && (you.depth < 3 && player_in_branch(BRANCH_MAIN_DUNGEON) || player_in_branch(BRANCH_ECUMENICAL_TEMPLE))) { return; diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc index 69c4bb006f..c25881c633 100644 --- a/crawl-ref/source/ghost.cc +++ b/crawl-ref/source/ghost.cc @@ -22,6 +22,7 @@ #include "spl-cast.h" #include "mon-util.h" #include "mon-transit.h" +#include "place.h" #include "player.h" #include "religion.h" @@ -927,7 +928,7 @@ void ghost_demon::find_extra_ghosts(std::vector<ghost_demon> &gs, int n) // Returns the number of extra ghosts allowed on the level. int ghost_demon::n_extra_ghosts() { - if (you.absdepth0 < 10) + if (absdungeon_depth() < 10) return (0); return (MAX_GHOSTS - 1); diff --git a/crawl-ref/source/godprayer.cc b/crawl-ref/source/godprayer.cc index 5055a846b2..04fc4c1cfb 100644 --- a/crawl-ref/source/godprayer.cc +++ b/crawl-ref/source/godprayer.cc @@ -26,6 +26,7 @@ #include "monster.h" #include "notes.h" #include "options.h" +#include "place.h" #include "random.h" #include "religion.h" #include "stash.h" @@ -458,7 +459,7 @@ int zin_tithe(item_def& item, int quant, bool quiet) } // Avg gold pile value: 10 + depth/2. tithe *= 47; - denom *= 20 + you.absdepth0; + denom *= 20 + absdungeon_depth(); } gain_piety(tithe * 3, denom); } diff --git a/crawl-ref/source/hints.cc b/crawl-ref/source/hints.cc index 233f48acbe..1bd95f854b 100644 --- a/crawl-ref/source/hints.cc +++ b/crawl-ref/source/hints.cc @@ -39,6 +39,7 @@ #include "mutation.h" #include "options.h" #include "jobs.h" +#include "place.h" #include "player.h" #include "random.h" #include "religion.h" @@ -4401,35 +4402,32 @@ static void _hints_describe_feature(int x, int y) Hints.hints_events[HINT_SEEN_STAIRS] = false; break; + case DNGN_EXIT_DUNGEON: + ostr << "These stairs lead out of the dungeon. Following them " + "will end the game. The only way to win is to " + "transport the fabled Orb of Zot outside."; + break; + case DNGN_STONE_STAIRS_UP_I: case DNGN_STONE_STAIRS_UP_II: case DNGN_STONE_STAIRS_UP_III: - if (you.absdepth0 < 1) - { - ostr << "These stairs lead out of the dungeon. Following them " - "will end the game. The only way to win is to " - "transport the fabled Orb of Zot outside."; - } - else - { - ostr << "You can enter the previous (shallower) level by " - "following these up (<w><<</w>). This is ideal for " - "retreating or finding a safe resting spot, since the " - "previous level will have less monsters and monsters " - "on this level can't follow you up unless they're " - "standing right next to you. To get back to this " - "level again, press <w>></w> while standing on the " - "downstairs."; + ostr << "You can enter the previous (shallower) level by " + "following these up (<w><<</w>). This is ideal for " + "retreating or finding a safe resting spot, since the " + "previous level will have less monsters and monsters " + "on this level can't follow you up unless they're " + "standing right next to you. To get back to this " + "level again, press <w>></w> while standing on the " + "downstairs."; #ifdef USE_TILE - ostr << " In Tiles, you can perform either action simply by " - "clicking the <w>left mouse button</w> while pressing " - "<w>Shift</w> instead. "; + ostr << " In Tiles, you can perform either action simply by " + "clicking the <w>left mouse button</w> while pressing " + "<w>Shift</w> instead. "; #endif - if (is_unknown_stair(where)) - { - ostr << "\n\nYou have not yet passed through this " - "particular set of stairs. "; - } + if (is_unknown_stair(where)) + { + ostr << "\n\nYou have not yet passed through this " + "particular set of stairs. "; } Hints.hints_events[HINT_SEEN_STAIRS] = false; break; @@ -4677,7 +4675,7 @@ bool hints_monster_interesting(const monster* mons) return (true); // The monster is (seriously) out of depth. - return (mons_level(mons->type) >= you.absdepth0 + 8); + return (mons_level(mons->type) >= absdungeon_depth() + 8); } void hints_describe_monster(const monster_info& mi, bool has_stat_desc) @@ -4722,7 +4720,8 @@ void hints_describe_monster(const monster_info& mi, bool has_stat_desc) // 8 is the default value for the note-taking of OOD monsters. // Since I'm too lazy to come up with any measurement of my own // I'll simply reuse that one. - const int level_diff = mons_level(mi.type) - (you.absdepth0 + 8); + const int level_diff = mons_level(mi.type) + - (absdungeon_depth() + 8); if (level_diff >= 0) { diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index 70f45952b0..34efbbd211 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -1263,11 +1263,10 @@ void scorefile_entry::init(time_t dt) penance = you.penance[you.religion]; } - // main dungeon: level is simply level - dlvl = player_branch_depth(); branch = you.where_are_you; // no adjustments necessary. + dlvl = you.depth; - absdepth = you.absdepth0 + 1; // 1-based absolute depth. + absdepth = absdungeon_depth() + 1; // 1-based absolute depth. if (const vault_placement *vp = dgn_vault_at(you.pos())) { diff --git a/crawl-ref/source/l_debug.cc b/crawl-ref/source/l_debug.cc index 823fef78e3..46fb4b2716 100644 --- a/crawl-ref/source/l_debug.cc +++ b/crawl-ref/source/l_debug.cc @@ -63,8 +63,8 @@ LUAFN(debug_enter_dungeon) { init_level_connectivity(); - you.absdepth0 = 0; you.where_are_you = BRANCH_MAIN_DUNGEON; + you.depth = 1; load_level(DNGN_STONE_STAIRS_DOWN_I, LOAD_START_GAME, level_id()); return (0); diff --git a/crawl-ref/source/l_dgnbld.cc b/crawl-ref/source/l_dgnbld.cc index 4b2576d378..41dee33dbb 100644 --- a/crawl-ref/source/l_dgnbld.cc +++ b/crawl-ref/source/l_dgnbld.cc @@ -988,7 +988,7 @@ LUAFN(dgn_farthest_from) LUAFN(dgn_layout_basic) { - dgn_build_basic_level(you.absdepth0); + dgn_build_basic_level(); return 0; } @@ -1006,13 +1006,13 @@ LUAFN(dgn_layout_chaotic_city) LUAFN(dgn_layout_shoals) { - dgn_build_shoals_level(you.absdepth0); + dgn_build_shoals_level(); return 0; } LUAFN(dgn_layout_swamp) { - dgn_build_swamp_level(you.absdepth0); + dgn_build_swamp_level(); return 0; } diff --git a/crawl-ref/source/l_dgnit.cc b/crawl-ref/source/l_dgnit.cc index 6dbdbf2a08..e945750dc5 100644 --- a/crawl-ref/source/l_dgnit.cc +++ b/crawl-ref/source/l_dgnit.cc @@ -15,6 +15,7 @@ #include "libutil.h" #include "mapdef.h" #include "stash.h" +#include "place.h" #define ITEMLIST_METATABLE "crawldgn.item_list" @@ -83,7 +84,7 @@ static int dgn_create_item(lua_State *ls) item_list ilist = _lua_get_ilist(ls, 3); const int level = - lua_isnumber(ls, 4) ? lua_tointeger(ls, 4) : you.absdepth0; + lua_isnumber(ls, 4) ? lua_tointeger(ls, 4) : absdungeon_depth(); dgn_place_multiple_items(ilist, c, level); link_items(); @@ -93,9 +94,7 @@ static int dgn_create_item(lua_State *ls) static int dgn_item_property_remove(lua_State *ls) { if (item_def *item = clua_get_item(ls, 1)) - { item->props.erase(luaL_checkstring(ls, 2)); - } return (0); } diff --git a/crawl-ref/source/l_dgnmon.cc b/crawl-ref/source/l_dgnmon.cc index d404afa1e3..6992a10d4f 100644 --- a/crawl-ref/source/l_dgnmon.cc +++ b/crawl-ref/source/l_dgnmon.cc @@ -208,11 +208,10 @@ static int dgn_create_monster(lua_State *ls) for (int i = 0, size = mlist.size(); i < size; ++i) { mons_spec mspec = mlist.get_monster(i); - const int mid = dgn_place_monster(mspec, you.absdepth0, c, - false, false, false); - if (mid != -1) + const int midx = dgn_place_monster(mspec, -1, c, false, false, false); + if (midx != -1) { - push_monster(ls, &menv[mid]); + push_monster(ls, &menv[midx]); return (1); } } diff --git a/crawl-ref/source/l_you.cc b/crawl-ref/source/l_you.cc index 26e4f5526b..62c959d4ae 100644 --- a/crawl-ref/source/l_you.cc +++ b/crawl-ref/source/l_you.cc @@ -24,6 +24,7 @@ #include "mutation.h" #include "jobs.h" #include "ouch.h" +#include "place.h" #include "religion.h" #include "shopping.h" #include "species.h" @@ -173,11 +174,12 @@ LUARET1(you_lives, number, you.lives) LUARET1(you_where, string, level_id::current().describe().c_str()) LUARET1(you_branch, string, level_id::current().describe(false, false).c_str()) -LUARET1(you_subdepth, number, level_id::current().depth) +LUARET1(you_depth, number, you.depth) // [ds] Absolute depth is 1-based for Lua to match things like DEPTH: // which are also 1-based. Yes, this is confusing. FIXME: eventually // change you.absdepth0 to be 1-based as well. -LUARET1(you_absdepth, number, you.absdepth0 + 1) +// [1KB] FIXME: eventually eliminate the notion of absolute depth at all. +LUARET1(you_absdepth, number, absdungeon_depth() + 1) LUAWRAP(you_stop_activity, interrupt_activity(AI_FORCE_INTERRUPT)) LUARET1(you_taking_stairs, boolean, current_delay_action() == DELAY_ASCENDING_STAIRS @@ -387,7 +389,7 @@ static const struct luaL_reg you_clib[] = { "where", you_where }, { "branch", you_branch }, - { "subdepth", you_subdepth }, + { "depth", you_depth }, { "absdepth", you_absdepth }, { "can_smell", you_can_smell }, diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index fd02204132..b2d31d2ed5 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -28,6 +28,7 @@ #include "misc.h" #include "mon-stuff.h" #include "mon-util.h" +#include "place.h" #include "player.h" #include "random.h" #include "spl-book.h" @@ -1628,7 +1629,7 @@ brand_ok: { // Brand is set as for "good" items. set_item_ego_type(item, OBJ_WEAPONS, - _determine_weapon_brand(item, 2+2*you.absdepth0)); + _determine_weapon_brand(item, 2 + 2 * absdungeon_depth())); } item.plus -= 1 + random2(3); item.plus2 -= 1 + random2(3); @@ -2373,7 +2374,8 @@ static void _generate_armour_item(item_def& item, bool allow_uniques, { // Brand is set as for "good" items. set_item_ego_type(item, OBJ_ARMOUR, - _determine_armour_ego(item, item.sub_type, 2+2*you.absdepth0)); + _determine_armour_ego(item, item.sub_type, + 2 + 2 * absdungeon_depth())); } item.plus -= 1 + random2(3); diff --git a/crawl-ref/source/mgen_data.h b/crawl-ref/source/mgen_data.h index 5db27f555c..bc67c1c4e5 100644 --- a/crawl-ref/source/mgen_data.h +++ b/crawl-ref/source/mgen_data.h @@ -128,7 +128,7 @@ struct mgen_data monster_type base = MONS_NO_MONSTER, int monnumber = 0, int moncolour = BLACK, - int monpower = you.absdepth0, + int monpower = -1, proximity_type prox = PROX_ANYWHERE, level_id _place = level_id::current(), int mhd = 0, int mhp = 0, @@ -182,7 +182,7 @@ struct mgen_data { return mgen_data(mt, BEH_HOSTILE, 0, abj, st, p, alert ? MHITYOU : MHITNOT, - genflags, ngod, base, 0, BLACK, you.absdepth0, + genflags, ngod, base, 0, BLACK, -1, PROX_ANYWHERE, level_id::current(), 0, 0, 0, "", nsummoner, RANDOM_MONSTER); } diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc index f477aff034..c57ae65ebd 100644 --- a/crawl-ref/source/mon-abil.cc +++ b/crawl-ref/source/mon-abil.cc @@ -1305,7 +1305,7 @@ static void _establish_connection(int tentacle, mgen_data(connector_type, SAME_ATTITUDE(main), main, 0, 0, last->pos, main->foe, MG_FORCE_PLACE, main->god, MONS_NO_MONSTER, tentacle, - main->colour, you.absdepth0, PROX_CLOSE_TO_PLAYER)); + main->colour, -1, PROX_CLOSE_TO_PLAYER)); if (connect < 0) { @@ -1352,7 +1352,7 @@ static void _establish_connection(int tentacle, mgen_data(connector_type, SAME_ATTITUDE(main), main, 0, 0, current->pos, main->foe, MG_FORCE_PLACE, main->god, MONS_NO_MONSTER, tentacle, - main->colour, you.absdepth0, PROX_CLOSE_TO_PLAYER)); + main->colour, -1, PROX_CLOSE_TO_PLAYER)); if (connect >= 0) { diff --git a/crawl-ref/source/mon-cast.cc b/crawl-ref/source/mon-cast.cc index 48f8c0c982..26d9a85fc3 100644 --- a/crawl-ref/source/mon-cast.cc +++ b/crawl-ref/source/mon-cast.cc @@ -38,6 +38,7 @@ #include "mon-stuff.h" #include "mon-util.h" #include "monster.h" +#include "place.h" #include "random.h" #include "religion.h" #include "shout.h" @@ -2139,7 +2140,7 @@ void mons_cast_spectral_orcs(monster* mons) orc->number = (int) mon; // give gear using the base type - give_item(created, you.absdepth0, true, true); + give_item(created, absdungeon_depth(), true, true); // set gear as summoned orc->mark_summoned(abj, true, SPELL_SUMMON_SPECTRAL_ORCS); @@ -2908,7 +2909,7 @@ void mons_cast(monster* mons, bolt &pbolt, spell_type spell_cast, mgen_data(MONS_KRAKEN_TENTACLE, SAME_ATTITUDE(mons), mons, 0, 0, adj_squares[i], mons->foe, MG_FORCE_PLACE, god, MONS_NO_MONSTER, kraken_index, - mons->colour, you.absdepth0, PROX_CLOSE_TO_PLAYER)); + mons->colour, -1, PROX_CLOSE_TO_PLAYER)); if (tentacle != -1) { diff --git a/crawl-ref/source/mon-gear.cc b/crawl-ref/source/mon-gear.cc index 8f7b5ca7d2..c535fc8a5e 100644 --- a/crawl-ref/source/mon-gear.cc +++ b/crawl-ref/source/mon-gear.cc @@ -2133,6 +2133,8 @@ void give_weapon(int mid, int level_number, bool mons_summoned, bool spectral_or void give_item(int mid, int level_number, bool mons_summoned, bool spectral_orcs) { + ASSERT(level_number > -1); // debugging absdepth0 changes + monster* mons = &menv[mid]; if (mons->type == MONS_MAURICE || mons->type == MONS_DEEP_DWARF_SCION) diff --git a/crawl-ref/source/mon-place.cc b/crawl-ref/source/mon-place.cc index 1b413d079c..2af5469d79 100644 --- a/crawl-ref/source/mon-place.cc +++ b/crawl-ref/source/mon-place.cc @@ -34,6 +34,7 @@ #include "mon-pick.h" #include "mon-util.h" #include "mon-stuff.h" +#include "place.h" #include "player.h" #include "random.h" #include "religion.h" @@ -752,7 +753,7 @@ static monster_type _resolve_monster_type(monster_type mon_type, // which for a portal vault using its own definition // of random monsters means "the depth of whatever place // we're using for picking the random monster". - if (*lev_mons == you.absdepth0) + if (*lev_mons == absdungeon_depth()) *lev_mons = place.absdepth(); // pick_random_monster() is called below } @@ -780,7 +781,7 @@ static monster_type _resolve_monster_type(monster_type mon_type, // from where we were. place.branch = BRANCH_MAIN_DUNGEON; place.depth = startdepth[you.where_are_you]; - *lev_mons = you.absdepth0; + *lev_mons = absdungeon_depth(); } int tries = 0; @@ -867,7 +868,7 @@ monster_type resolve_monster_type(monster_type mon_type, coord_def dummy(GXM - 1, GYM - 1); unwind_var<dungeon_feature_type> dummgrid(grd(dummy), feat); dungeon_char_type stair_type = NUM_DCHAR_TYPES; - int level = you.absdepth0; + int level = absdungeon_depth(); bool chose_ood = false; return _resolve_monster_type(mon_type, PROX_ANYWHERE, base, @@ -956,7 +957,7 @@ static bool _valid_monster_generation_location(mgen_data &mg) // OOD packs, based on depth and time spent on-level. static bool _in_ood_pack_protected_place() { - return (env.turns_on_level < 1400 - you.absdepth0 * 117); + return (env.turns_on_level < 1400 - absdungeon_depth() * 117); } int place_monster(mgen_data mg, bool force_pos, bool dont_place) @@ -973,6 +974,9 @@ int place_monster(mgen_data mg, bool force_pos, bool dont_place) if (mg.use_position() && monster_at(mg.pos)) return (-1); + if (mg.power == -1) + mg.power = absdungeon_depth(); + bool chose_ood_monster = false; mg.cls = _resolve_monster_type(mg.cls, mg.proximity, mg.base_type, mg.pos, mg.map_mask, @@ -2235,7 +2239,7 @@ static band_type _choose_band(int mon_type, int power, int &band_size, band_size = 4 + random2(4); break; case MONS_GNOLL: - if (you.absdepth0 != 0) + if (!player_in_branch(BRANCH_MAIN_DUNGEON) || you.depth > 1) { band = BAND_GNOLLS; band_size = (coinflip() ? 3 : 2); @@ -2959,7 +2963,7 @@ void mark_interesting_monst(monster* mons, beh_type behaviour) } else if (player_in_branch(BRANCH_MAIN_DUNGEON) && !crawl_state.game_is_zotdef() - && mons_level(mons->type) >= you.absdepth0 + Options.ood_interesting + && mons_level(mons->type) >= absdungeon_depth() + Options.ood_interesting && mons_level(mons->type) < 99 && !(mons->type >= MONS_EARTH_ELEMENTAL && mons->type <= MONS_AIR_ELEMENTAL) @@ -3071,9 +3075,9 @@ int mons_place(mgen_data mg) if (mg.cls == MONS_DANCING_WEAPON && mg.summoner) ; // It's an animated weapon, don't touch the power else if (crawl_state.game_is_zotdef()) - mg.power = you.num_turns / (CYCLE_LENGTH * 3); + mg.power = you.num_turns / (CYCLE_LENGTH * 3); else - mg.power = you.absdepth0; + mg.power = -1; if (mg.behaviour == BEH_COPY) { diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index d3eea24e42..7823aba037 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -909,7 +909,7 @@ static std::string _level_description_string_hud() std::string short_name = branches[place.branch].shortname; if (brdepth[place.branch] > 1) - short_name += make_stringf(":%d", player_branch_depth()); + short_name += make_stringf(":%d", you.depth); // Definite articles else if (place.branch == BRANCH_ABYSS) short_name.insert(0, "The "); @@ -927,7 +927,7 @@ void print_stats_level() textcolor(HUD_VALUE_COLOUR); #ifdef DEBUG_DIAGNOSTICS - cprintf("(%d) ", you.absdepth0 + 1); + cprintf("(%d) ", absdungeon_depth() + 1); #endif cprintf("%s", _level_description_string_hud().c_str()); clear_to_end_of_line(); diff --git a/crawl-ref/source/place.cc b/crawl-ref/source/place.cc index bf63f6292c..2e762309a1 100644 --- a/crawl-ref/source/place.cc +++ b/crawl-ref/source/place.cc @@ -9,8 +9,8 @@ #include "branch.h" #include "libutil.h" -#include "place.h" #include "player.h" +#include "place.h" #include "travel.h" std::string short_place_name(level_id id) @@ -35,8 +35,7 @@ unsigned short get_packed_place(branch_type branch, int subdepth) unsigned short get_packed_place() { - return get_packed_place(you.where_are_you, - subdungeon_depth(you.where_are_you, you.absdepth0)); + return get_packed_place(you.where_are_you, you.depth); } bool single_level_branch(branch_type branch) @@ -101,39 +100,16 @@ int absdungeon_depth(branch_type branch, int subdepth) { if (branch >= BRANCH_VESTIBULE_OF_HELL && branch <= BRANCH_LAST_HELL) return subdepth + 27 - (branch == BRANCH_VESTIBULE_OF_HELL); - else + + --subdepth; + while (branch != BRANCH_MAIN_DUNGEON && branch != NUM_BRANCHES) { - --subdepth; - while (branch != BRANCH_MAIN_DUNGEON && branch != NUM_BRANCHES) - { - subdepth += startdepth[branch]; - branch = branches[branch].parent_branch; - } + subdepth += startdepth[branch]; + branch = branches[branch].parent_branch; } return subdepth; } -int subdungeon_depth(branch_type branch, int depth) -{ - int d = depth - absdungeon_depth(branch, 0); - // FIXME: assert instead once bugs are gone - if (d < 1) - d = 1; - else if (d > brdepth[branch]) - d = brdepth[branch]; - return d; -} - -int absdungeon_depth() -{ - return you.absdepth0; -} - -int player_branch_depth() -{ - return subdungeon_depth(you.where_are_you, you.absdepth0); -} - // Returns true if exits from this type of level involve going upstairs. bool branch_exits_up(branch_type branch) { diff --git a/crawl-ref/source/place.h b/crawl-ref/source/place.h index b5825bf2ac..746c2b65ba 100644 --- a/crawl-ref/source/place.h +++ b/crawl-ref/source/place.h @@ -28,17 +28,11 @@ std::string place_name(unsigned short place, bool long_name = false, std::string prep_branch_level_name(unsigned short packed_place); std::string prep_branch_level_name(); -// Get displayable depth in the current branch, given the absolute -// depth. -int subdungeon_depth(branch_type branch, int depth); - -// Get absolute depth given the displayable depth in the branch. -int absdungeon_depth(branch_type branch, int subdepth); - -int absdungeon_depth(); - -// Get displayable depth in the current branch. -int player_branch_depth(); +// Get some kind of "absolute depth" given the depth in the branch. +// It's mostly the difficulty of a given level and the quality of items +// you can find. +int absdungeon_depth(branch_type branch = you.where_are_you, + int depth = you.depth); bool single_level_branch(branch_type branch); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 5aef0ab484..4ab4c0cb88 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5409,8 +5409,6 @@ void player::init() pet_target = MHITNOT; - absdepth0 = 0; - duration.init(0); rotting = 0; berserk_penalty = 0; @@ -5466,6 +5464,7 @@ void player::init() kills = new KillMaster(); where_are_you = BRANCH_MAIN_DUNGEON; + depth = 1; branch_stairs.init(0); @@ -7296,7 +7295,9 @@ void player::set_duration(duration_type dur, int turns, void player::goto_place(const level_id &lid) { where_are_you = static_cast<branch_type>(lid.branch); - absdepth0 = absdungeon_depth(lid.branch, lid.depth); + depth = lid.depth; + ASSERT(depth >= 1); + ASSERT(depth <= brdepth[you.where_are_you]); } void player::accum_been_constricted() diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 5c6022b7d6..4119a82647 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -98,8 +98,6 @@ public: unsigned short pet_target; - int absdepth0; // offset by one (-1 == 0, 0 == 1, etc.) for display - durations_t duration; int rotting; int berserk_penalty; // penalty for moving while berserk @@ -170,6 +168,7 @@ public: KillMaster* kills; branch_type where_are_you; + int depth; FixedVector<uint8_t, 30> branch_stairs; diff --git a/crawl-ref/source/stairs.cc b/crawl-ref/source/stairs.cc index 3cc1232bf5..3c9f0a98af 100644 --- a/crawl-ref/source/stairs.cc +++ b/crawl-ref/source/stairs.cc @@ -110,7 +110,7 @@ static void _player_change_level_reset() static void _player_change_level_upstairs(dungeon_feature_type stair_find) { if (player_in_connected_branch()) - you.absdepth0--; + you.depth--; // Make sure we return to our main dungeon level... labyrinth entrances // in the abyss or pandemonium are a bit trouble (well the labyrinth does @@ -124,31 +124,27 @@ static void _player_change_level_upstairs(dungeon_feature_type stair_find) if (player_in_branch(BRANCH_VESTIBULE_OF_HELL)) { you.where_are_you = you.hell_branch; - you.absdepth0 = you.hell_exit; + you.depth = you.hell_exit; } if (player_in_hell()) { you.where_are_you = BRANCH_VESTIBULE_OF_HELL; - you.absdepth0 = 27; + you.depth = 1; } - // Did we take a branch stair? - for (int i = 0; i < NUM_BRANCHES; ++i) + if (you.depth == 0) { - if (branches[i].exit_stairs == stair_find - && you.where_are_you == i) + you.depth = startdepth[you.where_are_you]; + if (you.depth == -1) { - you.where_are_you = branches[i].parent_branch; - - // If leaving a branch which wasn't generated in this - // particular game (like the Swamp or Shoals), then - // its startdepth is set to -1; compensate for that, - // so we don't end up on "level -1". - if (brdepth[i] == -1) - you.absdepth0 += 2; - break; + // Wizmode, the branch wasn't generated this game. + // Pick the middle of the range instead. + you.depth = (branches[you.where_are_you].mindepth + + branches[you.where_are_you].maxdepth) / 2; } + you.where_are_you = branches[you.where_are_you].parent_branch; + ASSERT(you.where_are_you < NUM_BRANCHES); } } @@ -284,7 +280,7 @@ static void _leaving_level_now(dungeon_feature_type stair_used) { if (player_in_branch(BRANCH_ZIGGURAT) && stair_used == DNGN_EXIT_PORTAL_VAULT - && player_branch_depth() == 27) + && you.depth == 27) { you.zigs_completed++; } @@ -450,11 +446,9 @@ void up_stairs(dungeon_feature_type force_stair) old_level_info.update(); } - _player_change_level_reset(); - _player_change_level_upstairs(stair_find); - - if (you.absdepth0 < 0) + if (player_in_branch(BRANCH_MAIN_DUNGEON) && you.depth == 1) { + you.depth = 0; mpr("You have escaped!"); for (int i = 0; i < ENDOFPACK; i++) @@ -469,6 +463,9 @@ void up_stairs(dungeon_feature_type force_stair) ouch(INSTANT_DEATH, NON_MONSTER, KILLED_BY_LEAVING); } + _player_change_level_reset(); + _player_change_level_upstairs(stair_find); + if (old_level.branch == BRANCH_VESTIBULE_OF_HELL && !player_in_branch(BRANCH_VESTIBULE_OF_HELL)) { @@ -557,7 +554,7 @@ static level_id _downstairs_destination(dungeon_feature_type stair_find, case DNGN_ENTER_HELL: you.hell_branch = you.where_are_you; - you.hell_exit = you.absdepth0; + you.hell_exit = you.depth; return level_id(BRANCH_VESTIBULE_OF_HELL); default: @@ -578,7 +575,7 @@ static void _player_change_level_downstairs(dungeon_feature_type stair_find, const std::string &dst) { level_id lev = _downstairs_destination(stair_find, dst); - you.absdepth0 = lev.absdepth(); + you.depth = lev.depth; you.where_are_you = lev.branch; } @@ -607,7 +604,6 @@ void down_stairs(dungeon_feature_type force_stair) && get_trap_type(you.pos()) == TRAP_SHAFT || force_stair == DNGN_TRAP_NATURAL); level_id shaft_dest; - int shaft_level = -1; // Up and down both work for shops. if (stair_find == DNGN_ENTER_SHOP) @@ -686,9 +682,8 @@ void down_stairs(dungeon_feature_type force_stair) _maybe_destroy_trap(you.pos()); return; } - shaft_level = absdungeon_depth(shaft_dest.branch, shaft_dest.depth); - if (!known_trap && shaft_level - you.absdepth0 > 1) + if (!known_trap && shaft_dest.depth - you.depth > 1) mark_milestone("shaft", "fell down a shaft to " + short_place_name(shaft_dest) + "."); @@ -800,13 +795,10 @@ void down_stairs(dungeon_feature_type force_stair) _mark_portal_return_point(you.pos()); } - const int shaft_depth = (shaft ? shaft_level - you.absdepth0 : 1); + const int shaft_depth = (shaft ? shaft_dest.depth - you.depth : 1); _player_change_level_reset(); if (shaft) - { - you.absdepth0 = shaft_level; - you.where_are_you = shaft_dest.branch; - } + you.depth = shaft_dest.depth; else _player_change_level_downstairs(stair_find, dst); @@ -1062,7 +1054,7 @@ void new_level(bool restore) take_note(Note(NOTE_DUNGEON_LEVEL_CHANGE)); if (player_in_branch(BRANCH_ZIGGURAT)) - you.zig_max = std::max(you.zig_max, player_branch_depth()); + you.zig_max = std::max(you.zig_max, you.depth); } // Returns a hatch or stair (up or down) @@ -1077,7 +1069,7 @@ dungeon_feature_type random_stair(bool do_place_check) DNGN_STONE_STAIRS_UP_I+random2( DNGN_ESCAPE_HATCH_UP-DNGN_STONE_STAIRS_UP_I+1))); } - else if (player_branch_depth() == 1) + else if (you.depth == 1) { return (static_cast<dungeon_feature_type>( DNGN_STONE_STAIRS_DOWN_I+random2( diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 0e56531387..90fee77ecd 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -1045,11 +1045,11 @@ static void tag_construct_you(writer &th) marshallByte(th, you.max_level); marshallByte(th, you.where_are_you); + marshallByte(th, you.depth); marshallByte(th, you.char_direction); marshallByte(th, you.opened_zot); marshallByte(th, you.royal_jelly_dead); marshallByte(th, you.transform_uncancellable); - marshallByte(th, you.absdepth0); marshallByte(th, you.is_undead); marshallShort(th, you.unrand_reacts); marshallByte(th, you.berserk_penalty); @@ -1766,6 +1766,8 @@ static void tag_read_you(reader &th) you.max_level = unmarshallByte(th); you.where_are_you = static_cast<branch_type>(unmarshallUByte(th)); ASSERT(you.where_are_you < NUM_BRANCHES); + you.depth = unmarshallByte(th); + ASSERT(you.depth > 0); you.char_direction = static_cast<game_direction_type>(unmarshallUByte(th)); ASSERT(you.char_direction <= GDT_ASCENDING); @@ -1773,7 +1775,6 @@ static void tag_read_you(reader &th) you.royal_jelly_dead = unmarshallBoolean(th); you.transform_uncancellable = unmarshallBoolean(th); - you.absdepth0 = unmarshallByte(th); you.is_undead = static_cast<undead_state_type>(unmarshallUByte(th)); ASSERT(you.is_undead <= US_SEMI_UNDEAD); you.unrand_reacts = unmarshallShort(th); @@ -2572,6 +2573,7 @@ static void tag_read_you_dungeon(reader &th) brdepth[j] = unmarshallInt(th); startdepth[j] = unmarshallInt(th); } + ASSERT(you.depth <= brdepth[you.where_are_you]); unmarshallMap(th, stair_level, unmarshall_long_as<branch_type>, diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index e186f8cc38..e4037b8da8 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -683,7 +683,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) else { mpr("A huge blade swings out and slices into you!"); - const int damage = (you.absdepth0 * 2) + random2avg(29, 2) + const int damage = (absdungeon_depth() * 2) + random2avg(29, 2) - random2(1 + you.armour_class()); std::string n = name(DESC_A) + " trap"; ouch(damage, NON_MONSTER, KILLED_BY_TRAP, n.c_str()); @@ -1027,7 +1027,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) int trap_def::max_damage(const actor& act) { - int level = you.absdepth0; + int level = absdungeon_depth(); // Trap damage to monsters is not a function of level, because // they are fairly stupid and tend to have fewer hp than @@ -1176,11 +1176,11 @@ void disarm_trap(const coord_def& where) // Make the actual attempt you.turn_is_over = true; - if (random2(you.skill_rdiv(SK_TRAPS_DOORS) + 2) <= random2(you.absdepth0 + 5)) + if (random2(you.skill_rdiv(SK_TRAPS_DOORS) + 2) <= random2(absdungeon_depth() + 5)) { mpr("You failed to disarm the trap."); - if (random2(you.dex()) > 5 + random2(5 + you.absdepth0)) - practise(EX_TRAP_DISARM_FAIL, you.absdepth0); + if (random2(you.dex()) > 5 + random2(5 + absdungeon_depth())) + practise(EX_TRAP_DISARM_FAIL, absdungeon_depth()); else { if ((trap.type == TRAP_NET || trap.type==TRAP_WEB) @@ -1202,7 +1202,7 @@ void disarm_trap(const coord_def& where) { mpr("You have disarmed the trap."); trap.disarm(); - practise(EX_TRAP_DISARM, you.absdepth0); + practise(EX_TRAP_DISARM, absdungeon_depth()); } } @@ -1574,7 +1574,7 @@ void trap_def::shoot_ammo(actor& act, bool was_known) item_def shot = generate_trap_item(); - int trap_hit = (20 + (you.absdepth0*2)) * random2(200) / 100; + int trap_hit = (20 + (absdungeon_depth()*2)) * random2(200) / 100; if (int defl = act.missile_deflection()) trap_hit = random2(trap_hit / defl); @@ -1723,7 +1723,7 @@ bool is_valid_shaft_level(const level_id &place) // Shafts are now allowed on the first two levels, as they have a // good chance of being detected. You'll also fall less deep. - /* if (place == BRANCH_MAIN_DUNGEON && you.absdepth0 < 2) + /* if (place == BRANCH_MAIN_DUNGEON && you.depth < 3) return (false); */ // Don't generate shafts in branches where teleport control diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 47034b4de5..2d256ad5b9 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -233,11 +233,8 @@ bool is_unknown_stair(const coord_def &p) // While the stairs out of the dungeon are not precisely known // to the travel cache, the player does know where they lead. - if (player_branch_depth() == 1 - && feat_stair_direction(feat) == CMD_GO_UPSTAIRS) - { + if (you.depth == 1 && feat_stair_direction(feat) == CMD_GO_UPSTAIRS) return (false); - } return (feat_is_travelable_stair(feat) && !travel_cache.know_stair(p)); } @@ -1976,7 +1973,8 @@ static int _get_nearest_level_depth(uint8_t branch) || player_in_branch(BRANCH_DIS) || player_in_branch(BRANCH_GEHENNA))) { - return you.hell_exit + 1; + // BUG: hell gates in the Lair + return you.hell_exit; } level_id id = level_id::current(); @@ -2999,8 +2997,7 @@ void arrange_features(std::vector<coord_def> &features) level_id level_id::current() { - const level_id id(you.where_are_you, - subdungeon_depth(you.where_are_you, you.absdepth0)); + const level_id id(you.where_are_you, you.depth); return id; } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index c98084b243..48d77de8e6 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -376,7 +376,7 @@ static const FixedArray<uint8_t, GXM, GYM>& _tile_difficulties(bool random) static int cache_seed = -1; int seed = random ? -1 : - (static_cast<int>(you.where_are_you) << 8) + you.absdepth0 - 1731813538; + (static_cast<int>(you.where_are_you) << 8) + you.depth - 1731813538; if (seed == cache_seed && !random) { diff --git a/crawl-ref/source/viewmap.cc b/crawl-ref/source/viewmap.cc index 31570c8182..92f32849f6 100644 --- a/crawl-ref/source/viewmap.cc +++ b/crawl-ref/source/viewmap.cc @@ -1291,7 +1291,7 @@ bool emphasise(const coord_def& where) { dungeon_feature_type feat = env.map_knowledge(where).feat(); return (is_unknown_stair(where) - && (you.absdepth0 || feat_stair_direction(feat) == CMD_GO_DOWNSTAIRS) + && feat_stair_direction(feat) == CMD_GO_DOWNSTAIRS && !player_in_branch(BRANCH_VESTIBULE_OF_HELL)); } diff --git a/crawl-ref/source/wiz-dgn.cc b/crawl-ref/source/wiz-dgn.cc index 2a435429ab..d08467b3af 100644 --- a/crawl-ref/source/wiz-dgn.cc +++ b/crawl-ref/source/wiz-dgn.cc @@ -41,7 +41,7 @@ static dungeon_feature_type _find_appropriate_stairs(bool down) { if (player_in_connected_branch()) { - int depth = subdungeon_depth(you.where_are_you, you.absdepth0); + int depth = you.depth; if (down) depth++; else @@ -146,10 +146,9 @@ void wizard_level_travel(bool down) static void _wizard_go_to_level(const level_pos &pos) { - const int abs_depth = absdungeon_depth(pos.id.branch, pos.id.depth); dungeon_feature_type stair_taken = - abs_depth > you.absdepth0? DNGN_STONE_STAIRS_DOWN_I - : DNGN_STONE_STAIRS_UP_I; + absdungeon_depth(pos.id.branch, pos.id.depth) > absdungeon_depth() ? + DNGN_STONE_STAIRS_DOWN_I : DNGN_STONE_STAIRS_UP_I; if (pos.id.depth == brdepth[pos.id.branch]) stair_taken = DNGN_STONE_STAIRS_DOWN_I; @@ -164,7 +163,7 @@ static void _wizard_go_to_level(const level_pos &pos) const bool keep_travel_data = can_travel_interlevel(); you.where_are_you = static_cast<branch_type>(pos.id.branch); - you.absdepth0 = abs_depth; + you.depth = pos.id.depth; const bool newlevel = load_level(stair_taken, LOAD_ENTER_LEVEL, old_level); tile_new_level(newlevel); diff --git a/crawl-ref/source/wiz-mon.cc b/crawl-ref/source/wiz-mon.cc index e6a0ab1cdc..bc036b95a8 100644 --- a/crawl-ref/source/wiz-mon.cc +++ b/crawl-ref/source/wiz-mon.cc @@ -253,7 +253,7 @@ void wizard_create_spec_monster_name() if (mons_is_unique(mspec.mid) && you.unique_creatures[mspec.mid]) you.unique_creatures[mspec.mid] = false; - if (dgn_place_monster(mspec, you.absdepth0, place, true, false) == -1) + if (dgn_place_monster(mspec, -1, place, true, false) == -1) { mpr("Unable to place monster.", MSGCH_DIAGNOSTICS); return; |