From a6e4d3b9c8c04d5fabeca21c6a5b7d98c77c452f Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 11 Jul 2007 13:11:54 +0000 Subject: Fixed $ not correctly setting the deepest depth in branches from the ^G depth prompt under certain circumstances (Erik). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1837 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/stash.cc | 2 +- crawl-ref/source/travel.cc | 13 +++++++++++-- crawl-ref/source/travel.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 8068af9c6f..0889f3006b 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -53,7 +53,7 @@ std::string userdef_annotate_item(const char *s, const item_def *item, if (exclusive) lua_set_exclusive_item(item); std::string ann; - if (!clua.callfn(s, "u>s", item, &ann)) + if (!clua.callfn(s, "u>s", item, &ann) && !clua.error.empty()) mprf(MSGCH_WARN, "Lua error: %s", clua.error.c_str()); if (exclusive) lua_set_exclusive_item(NULL); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 8c1c8e9324..130d74451c 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -2018,7 +2018,8 @@ static level_id find_deepest_explored(level_id curr) for (int i = branches[curr.branch].depth; i > 0; --i) { const level_id lid(curr.branch, i); - if (travel_cache.find_level_info(lid)) + const LevelInfo *linf = travel_cache.find_level_info(lid); + if (linf && !linf->empty()) return (lid); } return (curr); @@ -2175,8 +2176,11 @@ travel_target prompt_translevel_target(int prompt_flags) // User's chosen a branch, so now we ask for a level. target = prompt_travel_depth(target.p.id); - if (target.p.id.depth < 1 || target.p.id.depth >= MAX_LEVELS) + if (target.p.id.depth < 1 || + target.p.id.depth > branches[target.p.id.branch].depth) + { target.p.id.depth = -1; + } if (target.p.id.depth > -1 && remember_targ) trans_travel_dest = get_trans_travel_dest(target); @@ -2791,6 +2795,11 @@ void LevelInfo::set_level_excludes() curr_excludes = excludes; } +bool LevelInfo::empty() const +{ + return (stairs.empty() && excludes.empty()); +} + void LevelInfo::update() { // First, set excludes, so that stair distances will be correctly populated. diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index 4aeac12c68..a2e5bc328a 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -399,6 +399,7 @@ struct LevelInfo stair_info *get_stair(int x, int y); stair_info *get_stair(const coord_def &pos); + bool empty() const; bool know_stair(const coord_def &pos) const; int get_stair_index(const coord_def &pos) const; -- cgit v1.2.3-54-g00ecf