to pick stuff up gracefully.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@541 c06c8d41-db1a-0410-9941-cceddc491573
TJISAZK5RWKXIIC5UTQNY4KT3UX3ASGBUQQNWZ7ZDULPRYFRZXQQC mprf("Spotted %s.",item_name( mitm[ igrd[x + 1][y + 1] ], DESC_NOCAP_A ));if (prompt_stop_explore(ES_ITEM))return (true);
bool valid_stop = true;if (you.running == RMODE_EXPLORE_GREEDY){// The things we need to do...const LevelStashes *lev = stashes.find_current_level();if (lev && lev->needs_visit(x + 1, y + 1))valid_stop = false;}if (valid_stop){mprf("Found %s.",item_name( mitm[ igrd[x + 1][y + 1] ], DESC_NOCAP_A ));if (prompt_stop_explore(ES_ITEM))return (true);}
}static bool is_valid_explore_target(int x, int y){// If an adjacent square is unmapped, it's valid.for (int yi = -1; yi <= 1; ++yi){for (int xi = -1; xi <= 1; ++xi){if (!xi && !yi)continue;const int ax = x + xi, ay = y + yi;if (!in_bounds(ax, ay))continue;if (!is_player_mapped( get_envmap_char(ax, ay) ))return (true);}}if (you.running == RMODE_EXPLORE_GREEDY){LevelStashes *lev = stashes.find_current_level();return (lev && lev->needs_visit(x, y));}return (false);
you.running.x = 0;find_travel_pos(you.x_pos, you.y_pos, NULL, NULL);// No place to go?if (!you.running.x)stop_running();
// Speed up explore by not doing a double-floodfill if we have// a valid target.if (!you.running.x|| (you.running.x == you.x_pos && you.running.y == you.y_pos)|| !is_valid_explore_target(you.running.x, you.running.y)){you.running.x = 0;find_travel_pos(you.x_pos, you.y_pos, NULL, NULL);// No place to go?if (!you.running.x)stop_running();}
you.running.x = x;you.running.y = y;
if (you.running != RMODE_EXPLORE_GREEDY){you.running.x = x;you.running.y = y;return;}if (ex_dist == -10000){e_x = x;e_y = y;ex_dist =traveled_distance + Options.explore_item_greed;}}else if (you.running == RMODE_EXPLORE_GREEDY&& ix_dist == -10000&& is_greed_inducing_square(lev, dx, dy)){i_x = dx;i_y = dy;ix_dist = traveled_distance + 1;}// Short-circuit if we can.if (you.running == RMODE_EXPLORE_GREEDY){const int refdist =Options.explore_item_greed > 0? ex_dist: ix_dist;if (refdist != -10000&& traveled_distance > refdist){if (Options.explore_item_greed > 0)ix_dist = 10000;elseex_dist = 10000;}