diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-05 10:46:50 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-05 10:46:50 +0000 |
commit | fe78ce443f48f2331296ade6253643719dc05141 (patch) | |
tree | 0f373f1c272acb22893ec70449f308a212a9303f | |
parent | 38cb4b1f9f75c3695a14723f129aa795a5d72b4f (diff) | |
download | crawl-ref-fe78ce443f48f2331296ade6253643719dc05141.tar.gz crawl-ref-fe78ce443f48f2331296ade6253643719dc05141.zip |
Speeded up greedy explore by moving can_explore out of the floodloop. Still
isn't exactly a speed demon.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@570 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/acr.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/travel.cc | 44 | ||||
-rw-r--r-- | crawl-ref/source/view.h | 1 |
6 files changed, 33 insertions, 25 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 66685465a1..49b5c4dc50 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1219,14 +1219,13 @@ void process_command( command_type cmd ) { break; case CMD_EXPLORE: - case CMD_EXPLORE_GREEDY: if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS) { mpr("It would help if you knew where you were, first."); break; } // Start exploring - start_explore(cmd == CMD_EXPLORE_GREEDY); + start_explore(Options.explore_greedy); break; case CMD_DISPLAY_MAP: @@ -2388,7 +2387,7 @@ command_type keycode_to_command( keycode_type key ) { case CONTROL('E'): return CMD_FORGET_STASH; case CONTROL('F'): return CMD_SEARCH_STASHES; case CONTROL('G'): return CMD_INTERLEVEL_TRAVEL; - case CONTROL('I'): return CMD_EXPLORE_GREEDY; + case CONTROL('I'): return CMD_NO_CMD; case CONTROL('M'): return CMD_NO_CMD; case CONTROL('O'): return CMD_EXPLORE; case CONTROL('P'): return CMD_REPLAY_MESSAGES; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index c647910f30..62aa3bd18c 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -636,7 +636,6 @@ enum command_type CMD_FORGET_STASH, CMD_SEARCH_STASHES, CMD_EXPLORE, - CMD_EXPLORE_GREEDY, CMD_INTERLEVEL_TRAVEL, CMD_FIX_WAYPOINT, diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index e310410274..b6254e7e76 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -850,6 +850,8 @@ public: int explore_stop_prompt; + bool explore_greedy; // Explore goes after items as well. + // How much more eager greedy-explore is for items than to explore. int explore_item_greed; diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index ee6dc4fcd5..db16281baa 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -630,6 +630,7 @@ void game_options::reset_options() explore_stop_prompt = ES_NONE; explore_item_greed = 10; + explore_greedy = false; safe_zero_exp = true; target_zero_exp = false; @@ -1998,6 +1999,10 @@ void game_options::read_option_line(const std::string &str, bool runscript) else if (explore_item_greed < -1000) explore_item_greed = -1000; } + else if (key == "explore_greedy") + { + explore_greedy = read_bool(field, explore_greedy); + } else if (key == "stash_tracking") { stash_tracking = diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 23ebe05ae1..e63a1ec1bf 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -270,11 +270,11 @@ unsigned char is_waypoint(int x, int y) return curr_waypoints[x][y]; } -inline bool is_stash(LevelStashes *ls, int x, int y) +inline bool is_stash(const LevelStashes *ls, int x, int y) { if (!ls) return (false); - Stash *s = ls->find_stash(x, y); + const Stash *s = ls->find_stash(x, y); return s && s->enabled; } @@ -365,18 +365,20 @@ static bool is_reseedable(int x, int y) */ static bool is_travel_ok(int x, int y, bool ignore_hostile) { - unsigned char grid = grd[x][y]; + const int grid = grd[x][y]; - unsigned char envc = (unsigned char) env.map[x - 1][y - 1]; - if (!envc) return false; + if (!is_terrain_known(x, y)) + return (false); // Special-case secret doors so that we don't run into awkwardness when // a monster opens a secret door without the hero seeing it, but the travel // code paths through the secret door because it looks at the actual grid, - // rather than the env overmap. Hopefully there won't be any more such - // cases. - // FIXME: is_terrain_changed ought to do this with the view.cc changes. - if (envc == get_sightmap_char(DNGN_SECRET_DOOR)) return false; + // rather than the env overmap. + if ((grid == DNGN_OPEN_DOOR || grid == DNGN_CLOSED_DOOR) + && is_terrain_changed(x, y)) + { + return (false); + } unsigned char mon = mgrd[x][y]; if (mon != NON_MONSTER) @@ -388,8 +390,8 @@ static bool is_travel_ok(int x, int y, bool ignore_hostile) // Arguably the utility of this feature is greater than // the information we're giving the player for free. // Navigate around plants and fungi. Yet another tasty hack. - if (player_monster_visible(&menv[mon]) && - mons_class_flag( menv[mon].type, M_NO_EXP_GAIN )) + if (player_monster_visible(&menv[mon]) + && mons_class_flag( menv[mon].type, M_NO_EXP_GAIN )) { extern short point_distance[GXM][GYM]; @@ -444,12 +446,12 @@ static bool is_safe(int x, int y) // b) Unfriendly, in which case we're in deep trouble, since travel // should have been aborted already by the checks in view.cc. } - const char cloud = env.cgrid[x][y]; + const int cloud = env.cgrid[x][y]; if (cloud == EMPTY_CLOUD) return true; // We can also safely run through smoke. - const char cloud_type = env.cloud[ cloud ].type; + const int cloud_type = env.cloud[ cloud ].type; return cloud_type == CLOUD_GREY_SMOKE || cloud_type == CLOUD_GREY_SMOKE_MON || cloud_type == CLOUD_BLUE_SMOKE || @@ -894,7 +896,7 @@ command_type travel() if (!you.running.x) { stop_running(); - mpr("There's nowhere new to go, done exploring."); + mpr("Done exploring."); } } } @@ -1058,7 +1060,7 @@ static void fill_exclude_radius(const coord_def &c) static bool is_greed_inducing_square(const LevelStashes *ls, int x, int y) { - return (ls && can_autopickup() && ls->needs_visit(x, y)); + return (ls && ls->needs_visit(x, y)); } /* @@ -1075,7 +1077,8 @@ void find_travel_pos(int youx, int youy, int dest_x = youx, dest_y = youy; bool floodout = false; unsigned char feature; - LevelStashes *lev = stashes.find_current_level(); + const LevelStashes *lev = stashes.find_current_level(); + const bool need_for_greed = you.running == RMODE_EXPLORE_GREEDY && can_autopickup(); // For greedy explore, keep track of the closest unexplored // territory and the closest greedy square. @@ -1194,7 +1197,7 @@ void find_travel_pos(int youx, int youy, { if (!is_player_mapped(envf)) { - if (you.running != RMODE_EXPLORE_GREEDY) + if (!need_for_greed) { you.running.x = x; you.running.y = y; @@ -1209,7 +1212,7 @@ void find_travel_pos(int youx, int youy, traveled_distance + Options.explore_item_greed; } } - else if (you.running == RMODE_EXPLORE_GREEDY + else if (need_for_greed && ix_dist == -10000 && is_greed_inducing_square(lev, dx, dy)) { @@ -1219,7 +1222,7 @@ void find_travel_pos(int youx, int youy, } // Short-circuit if we can. - if (you.running == RMODE_EXPLORE_GREEDY) + if (need_for_greed) { const int refdist = Options.explore_item_greed > 0? ex_dist: ix_dist; @@ -1361,8 +1364,7 @@ void find_travel_pos(int youx, int youy, } } - if (you.running == RMODE_EXPLORE_GREEDY - && (ex_dist != -10000 || ix_dist != -10000)) + if (need_for_greed && (ex_dist != -10000 || ix_dist != -10000)) { if (ix_dist != -10000) { diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h index 857cb2c1e7..4b7b37f1f7 100644 --- a/crawl-ref/source/view.h +++ b/crawl-ref/source/view.h @@ -126,6 +126,7 @@ void set_terrain_mapped( int x, int y ); void set_terrain_seen( int x, int y ); bool is_terrain_known( int x, int y ); bool is_terrain_seen( int x, int y ); +bool is_terrain_changed( int x, int y ); void clear_feature_overrides(); void add_feature_override(const std::string &text); |