behaviour of travel-to-cursor, which may disconcert folks used to its behaviour when targeting, but I suspect they'll get used to it.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@488 c06c8d41-db1a-0410-9941-cceddc491573
AJJ6D6JRV6ZAZOAUHYUM2IQG42V6PBALOD4KEMNKSVVAOJXAUCPQC // show_map() now centers the known map along x or y. This prevents// the player from getting "artificial" location clues by using the// map to see how close to the end they are. They'll need to explore// to get that. This function is still a mess, though. -- bwrvoid show_map( FixedVector<int, 2> &spec_place, bool travel_mode )
static void draw_level_map(int start_x, int start_y, int screen_y, bool travel_mode)
char move_x = 0;char move_y = 0;char getty = 0;#ifdef DOS_TERMchar buffer[4800];#endif// Vector to track all features we can travel to, in order of distance.std::vector<coord_def> features;if (travel_mode){travel_cache.update();find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, &features);// Sort features into the order the player is likely to prefer.arrange_features(features);}// buffer2[GYM * GXM * 2] segfaults my box {dlb}
const int half_screen = num_lines / 2 - 1;for (j = 0; j < GYM; j++){for (i = 0; i < GXM; i++){if (env.map[i][j]){if (!found_y){found_y = true;min_y = j;}max_y = j;if (i < min_x)min_x = i;if (i > max_x)max_x = i;}}}const int map_lines = max_y - min_y + 1;const int start_x = min_x + (max_x - min_x + 1) / 2 - 40; // no x scrollingconst int block_step = Options.level_map_cursor_step;int start_y; // y does scrollint screen_y = you.y_pos;// if close to top of known map, put min_y on top// else if close to bottom of known map, put max_y on bottom.//// The num_lines comparisons are done to keep things neat, by// keeping things at the top of the screen. By shifting an// additional one in the num_lines > map_lines case, we can// keep the top line clear... which makes things look a whole// lot better for small maps.if (num_lines > map_lines)screen_y = min_y + half_screen - 1;else if (num_lines == map_lines || screen_y - half_screen < min_y)screen_y = min_y + half_screen;else if (screen_y + half_screen > max_y)screen_y = max_y - half_screen;int curs_x = you.x_pos - start_x;int curs_y = you.y_pos - screen_y + half_screen;int search_feat = 0, search_found = 0, anchor_x = -1, anchor_y = -1;
gettything:getty = getchm(KC_LEVELMAP);
// show_map() now centers the known map along x or y. This prevents// the player from getting "artificial" location clues by using the// map to see how close to the end they are. They'll need to explore// to get that. This function is still a mess, though. -- bwrvoid show_map( FixedVector<int, 2> &spec_place, bool travel_mode ){int i, j;
if (travel_mode && getty != 0 && getty != '+' && getty != '-'&& getty != 'h' && getty != 'j' && getty != 'k' && getty != 'l'&& getty != 'y' && getty != 'u' && getty != 'b' && getty != 'n'&& getty != 'H' && getty != 'J' && getty != 'K' && getty != 'L'&& getty != 'Y' && getty != 'U' && getty != 'B' && getty != 'N'// Keystrokes to initiate travel&& getty != ',' && getty != '.' && getty != '\r' && getty != ';'
char move_x = 0;char move_y = 0;char getty = 0;
// Keystrokes for jumping to features&& getty != '<' && getty != '>' && getty != '@' && getty != '\t'&& getty != '^' && getty != '_'&& (getty < '0' || getty > '9')&& getty != CONTROL('X')&& getty != CONTROL('E')&& getty != CONTROL('F')&& getty != CONTROL('W')&& getty != CONTROL('C')&& getty != '?'&& getty != 'X' && getty != 'F' && getty != 'I' && getty != 'W'){goto putty;}
#ifdef DOS_TERMchar buffer[4800];#endif
if (!travel_mode && getty != 0 && getty != '+' && getty != '-'&& getty != 'h' && getty != 'j' && getty != 'k' && getty != 'l'&& getty != 'y' && getty != 'u' && getty != 'b' && getty != 'n'&& getty != 'H' && getty != 'J' && getty != 'K' && getty != 'L'&& getty != 'Y' && getty != 'U' && getty != 'B' && getty != 'N'&& getty != '.' && getty != 'S' && (getty < '0' || getty > '9')// Keystrokes for jumping to features&& getty != '<' && getty != '>' && getty != '@' && getty != '\t'&& getty != '^' && getty != '_')
// Vector to track all features we can travel to, in order of distance.std::vector<coord_def> features;if (travel_mode)
if (getty == 0){getty = getchm(KC_LEVELMAP);// [dshaligram] DOS madness.getty = dos_direction_unmunge(getty);
find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, &features);// Sort features into the order the player is likely to prefer.arrange_features(features);
#if defined(WIN32CONSOLE) || defined(DOS)// Translate shifted numpad to shifted vi keys. Yes,// this is horribly hacky.
char min_x = 80, max_x = 0, min_y = 0, max_y = 0;bool found_y = false;const int num_lines = get_number_of_lines();const int half_screen = num_lines / 2 - 1;for (j = 0; j < GYM; j++)
static int win_keypad[] = { 'B', 'J', 'N','H', '5', 'L','Y', 'K', 'U' };if (getty >= '1' && getty <= '9')getty = win_keypad[ getty - '1' ];
for (i = 0; i < GXM; i++){if (env.map[i][j]){if (!found_y){found_y = true;min_y = j;}max_y = j;if (i < min_x)min_x = i;if (i > max_x)max_x = i;}}
const int map_lines = max_y - min_y + 1;const int start_x = min_x + (max_x - min_x + 1) / 2 - 40; // no x scrollingconst int block_step = Options.level_map_cursor_step;int start_y = 0; // y does scrollint screen_y = you.y_pos;// if close to top of known map, put min_y on top// else if close to bottom of known map, put max_y on bottom.//// The num_lines comparisons are done to keep things neat, by// keeping things at the top of the screen. By shifting an// additional one in the num_lines > map_lines case, we can// keep the top line clear... which makes things look a whole// lot better for small maps.if (num_lines > map_lines)screen_y = min_y + half_screen - 1;else if (num_lines == map_lines || screen_y - half_screen < min_y)screen_y = min_y + half_screen;else if (screen_y + half_screen > max_y)screen_y = max_y - half_screen;int curs_x = you.x_pos - start_x;int curs_y = you.y_pos - screen_y + half_screen;int search_feat = 0, search_found = 0, anchor_x = -1, anchor_y = -1;bool map_alive = true;bool redraw_map = true;#ifdef DOS_TERMgettext(1, 1, 80, 25, buffer);window(1, 1, 80, 25);
case CONTROL('F'):case CONTROL('W'):travel_cache.add_waypoint(start_x + curs_x, start_y + curs_y);// We need to do this all over again so that the user can jump// to the waypoint he just created.features.clear();find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, &features);// Sort features into the order the player is likely to prefer.arrange_features(features);move_x = move_y = 0;break;case CONTROL('E'):case CONTROL('X'):
redraw_map = true;gotoxy(curs_x, curs_y);getty = getchm(KC_LEVELMAP);if (getty == 0){getty = getchm(KC_LEVELMAP);// [dshaligram] DOS madness.getty = dos_direction_unmunge(getty);}#if defined(WIN32CONSOLE) || defined(DOS)// Translate shifted numpad to shifted vi keys. Yes,// this is horribly hacky.{static int win_keypad[] = { 'B', 'J', 'N','H', '5', 'L','Y', 'K', 'U' };if (getty >= '1' && getty <= '9')getty = win_keypad[ getty - '1' ];}#endifswitch (getty)
// We now need to redo travel colours
case CONTROL('C'):clear_map();break;case CONTROL('F'):case CONTROL('W'):travel_cache.add_waypoint(start_x + curs_x, start_y + curs_y);// We need to do this all over again so that the user can jump// to the waypoint he just created.
move_x = move_y = 0;break;case CONTROL('E'):case CONTROL('X'):{int x = start_x + curs_x, y = start_y + curs_y;if (getty == CONTROL('X'))toggle_exclude(x, y);elseclear_excludes();// We now need to redo travel coloursfeatures.clear();find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, &features);// Sort features into the order the player is likely to prefer.arrange_features(features);move_x = move_y = 0;}break;case 'b':case '1':move_x = -1;move_y = 1;break;case 'j':case '2':move_y = 1;move_x = 0;break;
case 'H':move_x = -block_step;move_y = 0;break;
case '+':move_y = 20;move_x = 0;break;case '-':move_y = -20;move_x = 0;break;case '<':case '>':case '@':case '\t':case '^':case '_':case 'X':case 'F':case 'W':case 'I':case '*':case '/':case '\'':{bool forward = true;
case '+':move_y = 20;move_x = 0;break;case '-':move_y = -20;move_x = 0;break;case '<':case '>':case '@':case '\t':case '^':case '_':case 'X':case 'F':case 'W':case 'I':move_x = 0;move_y = 0;if (anchor_x == -1) {anchor_x = start_x + curs_x - 1;anchor_y = start_y + curs_y - 1;
move_x = 0;move_y = 0;if (anchor_x == -1) {anchor_x = start_x + curs_x - 1;anchor_y = start_y + curs_y - 1;}if (search_feat != getty) {search_feat = getty;search_found = 0;}if (travel_mode)search_found = find_feature(features, getty, curs_x, curs_y,start_x, start_y,search_found,&move_x, &move_y,forward);elsesearch_found = find_feature(getty, curs_x, curs_y,start_x, start_y,anchor_x, anchor_y,search_found, &move_x, &move_y);break;
if (search_feat != getty) {search_feat = getty;search_found = 0;}if (travel_mode)search_found = find_feature(features, getty, curs_x, curs_y,start_x, start_y,search_found, &move_x, &move_y);elsesearch_found = find_feature(getty, curs_x, curs_y,start_x, start_y,anchor_x, anchor_y,search_found, &move_x, &move_y);break;case '.':case '\r':case 'S':case ',':case ';':{int x = start_x + curs_x, y = start_y + curs_y;if (travel_mode && x == you.x_pos && y == you.y_pos)
case '.':case '\r':case 'S':case ',':case ';':
if (you.travel_x > 0 && you.travel_y > 0) {move_x = you.travel_x - x;move_y = you.travel_y - y;
int x = start_x + curs_x, y = start_y + curs_y;if (travel_mode && x == you.x_pos && y == you.y_pos){if (you.travel_x > 0 && you.travel_y > 0) {move_x = you.travel_x - x;move_y = you.travel_y - y;}break;
if (screen_y < min_y + half_screen) {move_y = screen_y - (min_y + half_screen);screen_y = min_y + half_screen;
if (screen_y < min_y + half_screen) {move_y = screen_y - (min_y + half_screen);screen_y = min_y + half_screen;}elsemove_y = 0;
if (screen_y > max_y - half_screen) {move_y = screen_y - (max_y - half_screen);screen_y = max_y - half_screen;
if (screen_y > max_y - half_screen) {move_y = screen_y - (max_y - half_screen);screen_y = max_y - half_screen;}elsemove_y = 0;