diff options
-rw-r--r-- | crawl-ref/source/acr.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/misc.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/stash.cc | 20 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 27 | ||||
-rw-r--r-- | crawl-ref/source/travel.h | 1 |
6 files changed, 47 insertions, 17 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 9e73009b6a..427218a601 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2769,7 +2769,7 @@ static bool initialise(void) draw_border(); new_level(); - init_new_level(); + init_new_level(false); // Mark items in inventory as of unknown origin. origin_set_inventory(origin_set_unknown); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 56155c14e3..4283560459 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -669,7 +669,7 @@ void up_stairs(void) mpr( "You sense a powerful magical force warping space.", MSGCH_WARN ); // Tell the travel code that we're now on a new level - init_new_level(); + init_new_level(true); if (collect_travel_data) { // Update stair information for the stairs we just ascended, and the @@ -1109,7 +1109,7 @@ void down_stairs( bool remove_stairs, int old_level, bool force ) if (you.skills[SK_TRANSLOCATIONS] > 0 && !allow_control_teleport( true )) mpr( "You sense a powerful magical force warping space.", MSGCH_WARN ); - init_new_level(); + init_new_level(true); if (collect_travel_data) { // Update stair information for the stairs we just descended, and the @@ -1143,10 +1143,11 @@ void down_stairs( bool remove_stairs, int old_level, bool force ) } } // end down_stairs() -void init_new_level() +void init_new_level(bool transit) { travel_init_new_level(); - stash_init_new_level(); + if (transit) + stash_init_new_level(); } void new_level(void) @@ -2005,8 +2006,7 @@ bool i_feel_safe() // Do not attempt to use level_id if level_type != LEVEL_DUNGEON std::string short_place_name(level_id id) { - return short_place_name( - get_packed_place(id.branch, id.depth, LEVEL_DUNGEON)); + return id.describe(); } unsigned short get_packed_place( unsigned char branch, int subdepth, diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 18eefdafa6..0b543df2a0 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -86,7 +86,7 @@ void itrap(struct bolt &pbolt, int trapped); * *********************************************************************** */ void new_level(void); -void init_new_level(); +void init_new_level(bool transit); // last updated 12may2000 {dlb} /* *********************************************************************** diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index d9f59c6de6..f69b5285e1 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -856,7 +856,7 @@ std::ostream &operator << (std::ostream &os, const ShopInfo &s) return os; } -LevelStashes::LevelStashes() : place(), stashes(), shops() +LevelStashes::LevelStashes() : place(level_id::current()), stashes(), shops() { } @@ -1268,7 +1268,7 @@ void StashTracker::update_visible_stashes( int x = you.x_pos + cx - 17, y = you.y_pos + cy - 9; if (x < 0 || x >= GXM || y < 0 || y >= GYM) continue; - + if (!env.show[cx - 8][cy] && !(cx == 17 && cy == 9)) continue; @@ -1374,7 +1374,13 @@ void StashTracker::get_matching_stashes( level_id curr = level_id::current(); for (unsigned i = 0; i < results.size(); ++i) - results[i].player_distance = level_distance(curr, results[i].pos.id); + { + int ldist = level_distance(curr, results[i].pos.id); + if (ldist == -1) + ldist = 1000; + + results[i].player_distance = ldist; + } // Sort stashes so that closer stashes come first and stashes on the same // levels with more items come first. @@ -1487,15 +1493,15 @@ void StashTracker::display_search_results( if (res->shop) { dotravel = res->shop->show_menu(short_place_name(res->pos.id), - travelable); + can_travel_to(res->pos.id)); } else if (res->stash) { dotravel = res->stash->show_menu(short_place_name(res->pos.id), - travelable); + can_travel_to(res->pos.id)); } - if (dotravel && travelable) + if (dotravel && can_travel_to(res->pos.id)) { redraw_screen(); const level_pos lp = res->pos; @@ -1508,7 +1514,7 @@ void StashTracker::display_search_results( } redraw_screen(); - if (travelable && sel.size() == 1 && !stashmenu.meta_key) + if (sel.size() == 1 && !stashmenu.meta_key) { const stash_search_result *res = static_cast<stash_search_result *>(sel[0]->data); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 26a442ccac..c5b7a790cb 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -1466,7 +1466,7 @@ void track_intersect(std::vector<level_id> &cur, cx->branch = 0; cx->depth = -1; - int us = cur.size() - 1, them = targ.size() - 1; + int us = int(cur.size()) - 1, them = int(targ.size()) - 1; for ( ; us >= 0 && them >= 0; us--, them--) { @@ -1488,7 +1488,12 @@ void track_intersect(std::vector<level_id> &cur, */ int level_distance(level_id first, level_id second) { - if (first == second) return 0; + if (first == second + || (first.level_type != LEVEL_DUNGEON + && first.level_type == second.level_type)) + { + return 0; + } std::vector<level_id> fv, sv; @@ -1533,6 +1538,7 @@ int level_distance(level_id first, level_id second) } distance += sv[i].depth; } + return distance; } @@ -1938,6 +1944,15 @@ static level_pos prompt_translevel_target() void start_translevel_travel(const level_pos &pos) { + if (!can_travel_to(pos.id)) + return; + + if (!can_travel_interlevel()) + { + start_travel(pos.pos.x, pos.pos.y); + return; + } + travel_target = pos; if (pos.id != level_id::current()) @@ -3170,6 +3185,14 @@ void TravelCache::fixup_levels() i->second.fixup(); } +bool can_travel_to(const level_id &id) +{ + return ((id.level_type == LEVEL_DUNGEON + && can_travel_interlevel()) + || (id.level_type == LEVEL_PANDEMONIUM + && you.level_type == LEVEL_PANDEMONIUM)); +} + bool can_travel_interlevel() { return (player_in_mappable_area() && you.level_type != LEVEL_PANDEMONIUM); diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index c92dcbfb1a..02291b4735 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -409,6 +409,7 @@ private: int level_distance(level_id first, level_id second); +bool can_travel_to(const level_id &lid); bool can_travel_interlevel(); bool prompt_stop_explore(int es_why); |