diff -r -c angband-290-x11/src/cave.c angband-290/src/cave.c *** angband-290-x11/src/cave.c Fri Jun 2 21:38:07 2000 --- angband-290/src/cave.c Fri Apr 28 00:38:58 2000 *************** *** 409,446 **** return (image_object()); } } ! ! ! /* ! * The 16x16 tile of the terrain supports lighting ! */ ! bool feat_supports_lighting(byte feat) ! { ! if ((feat >= FEAT_TRAP_HEAD) && (feat <= FEAT_TRAP_TAIL)) ! return TRUE; ! ! switch (feat) ! { ! case FEAT_FLOOR: ! case FEAT_INVIS: ! case FEAT_SECRET: ! case FEAT_MAGMA: ! case FEAT_QUARTZ: ! case FEAT_MAGMA_H: ! case FEAT_QUARTZ_H: ! case FEAT_WALL_EXTRA: ! case FEAT_WALL_INNER: ! case FEAT_WALL_OUTER: ! case FEAT_WALL_SOLID: ! case FEAT_PERM_EXTRA: ! case FEAT_PERM_INNER: ! case FEAT_PERM_OUTER: ! case FEAT_PERM_SOLID: ! return TRUE; ! default: ! return FALSE; ! } ! } /* --- 409,446 ---- return (image_object()); } } ! ! ! /* ! * The 16x16 tile of the terrain supports lighting ! */ ! bool feat_supports_lighting(byte feat) ! { ! if ((feat >= FEAT_TRAP_HEAD) && (feat <= FEAT_TRAP_TAIL)) ! return TRUE; ! ! switch (feat) ! { ! case FEAT_FLOOR: ! case FEAT_INVIS: ! case FEAT_SECRET: ! case FEAT_MAGMA: ! case FEAT_QUARTZ: ! case FEAT_MAGMA_H: ! case FEAT_QUARTZ_H: ! case FEAT_WALL_EXTRA: ! case FEAT_WALL_INNER: ! case FEAT_WALL_OUTER: ! case FEAT_WALL_SOLID: ! case FEAT_PERM_EXTRA: ! case FEAT_PERM_INNER: ! case FEAT_PERM_OUTER: ! case FEAT_PERM_SOLID: ! return TRUE; ! default: ! return FALSE; ! } ! } /* *************** *** 630,638 **** int floor_num = 0; ! #ifdef USE_AB_TILES ! bool graf_new = ((strcmp(ANGBAND_GRAF, "new") == 0) && use_graphics); ! #endif /* USE_AB_TILES */ /* Monster/Player */ m_idx = cave_m_idx[y][x]; --- 630,637 ---- int floor_num = 0; ! /* Hack -- Assume that "new" means "Adam Bolt Tiles" */ ! bool graf_new = (use_graphics && streq(ANGBAND_GRAF, "new")); /* Monster/Player */ m_idx = cave_m_idx[y][x]; *************** *** 669,679 **** c = f_ptr->x_char; /* Special lighting effects */ - #ifdef USE_AB_TILES if (view_special_lite && ((a == TERM_WHITE) || graf_new)) - #else /* USE_AB_TILES */ - if (view_special_lite && (a == TERM_WHITE)) - #endif /* USE_AB_TILES */ { /* Handle "seen" grids */ if (info & (CAVE_SEEN)) --- 668,674 ---- *************** *** 681,694 **** /* Only lit by "torch" lite */ if (view_yellow_lite && !(info & (CAVE_GLOW))) { - #ifdef USE_AB_TILES if (graf_new) { /* Use a brightly lit tile */ c += 2; } else - #endif /* USE_AB_TILES */ { /* Use "yellow" */ a = TERM_YELLOW; --- 676,687 ---- *************** *** 699,712 **** /* Handle "blind" */ else if (p_ptr->blind) { - #ifdef USE_AB_TILES if (graf_new) { /* Use a dark tile */ ! c++; } else - #endif /* USE_AB_TILES */ { /* Use "dark gray" */ a = TERM_L_DARK; --- 692,703 ---- /* Handle "blind" */ else if (p_ptr->blind) { if (graf_new) { /* Use a dark tile */ ! c += 1; } else { /* Use "dark gray" */ a = TERM_L_DARK; *************** *** 716,729 **** /* Handle "dark" grids */ else if (!(info & (CAVE_GLOW))) { - #ifdef USE_AB_TILES if (graf_new) { /* Use a dark tile */ ! c++; } else - #endif /* USE_AB_TILES */ { /* Use "dark gray" */ a = TERM_L_DARK; --- 707,718 ---- /* Handle "dark" grids */ else if (!(info & (CAVE_GLOW))) { if (graf_new) { /* Use a dark tile */ ! c += 1; } else { /* Use "dark gray" */ a = TERM_L_DARK; *************** *** 733,746 **** /* Handle "view_bright_lite" */ else if (view_bright_lite) { - #ifdef USE_AB_TILES if (graf_new) { /* Use a dark tile */ ! c++; } else - #endif /* USE_AB_TILES */ { /* Use "gray" */ a = TERM_SLATE; --- 722,733 ---- /* Handle "view_bright_lite" */ else if (view_bright_lite) { if (graf_new) { /* Use a dark tile */ ! c += 1; } else { /* Use "gray" */ a = TERM_SLATE; *************** *** 782,806 **** c = f_ptr->x_char; /* Special lighting effects (walls only) */ ! #ifdef USE_AB_TILES ! if (view_granite_lite && ! (((a == TERM_WHITE) && !use_transparency && (feat >= FEAT_SECRET)) || ! (use_transparency && feat_supports_lighting(feat)))) ! #else /* USE_AB_TILES */ ! if (view_granite_lite && (a == TERM_WHITE) && (feat >= FEAT_SECRET)) ! #endif /* USE_AB_TILES */ { /* Handle "seen" grids */ if (info & (CAVE_SEEN)) { - #ifdef USE_AB_TILES if (graf_new) { /* Use a brightly lit tile */ c += 2; } else - #endif /* USE_AB_TILES */ { /* Use "white" */ } --- 769,787 ---- c = f_ptr->x_char; /* Special lighting effects (walls only) */ ! if (view_granite_lite && ! (((a == TERM_WHITE) && !use_transparency && (feat >= FEAT_SECRET)) || ! (use_transparency && feat_supports_lighting(feat)))) { /* Handle "seen" grids */ if (info & (CAVE_SEEN)) { if (graf_new) { /* Use a brightly lit tile */ c += 2; } else { /* Use "white" */ } *************** *** 809,822 **** /* Handle "blind" */ else if (p_ptr->blind) { - #ifdef USE_AB_TILES if (graf_new) { /* Use a dark tile */ ! c++; } else - #endif /* USE_AB_TILES */ { /* Use "dark gray" */ a = TERM_L_DARK; --- 790,801 ---- /* Handle "blind" */ else if (p_ptr->blind) { if (graf_new) { /* Use a dark tile */ ! c += 1; } else { /* Use "dark gray" */ a = TERM_L_DARK; *************** *** 826,838 **** /* Handle "view_bright_lite" */ else if (view_bright_lite) { - #ifdef USE_AB_TILES if (graf_new) { /* Use a lit tile */ } else - #endif /* USE_AB_TILES */ { /* Use "gray" */ a = TERM_SLATE; --- 805,815 ---- *************** *** 856,864 **** --- 833,843 ---- } #ifdef USE_TRANSPARENCY + /* Save the terrain info for the transparency effects */ (*tap) = a; (*tcp) = c; + #endif /* USE_TRANSPARENCY */ /* Objects */ *************** *** 1117,1122 **** --- 1096,1102 ---- #else /* USE_TRANSPARENCY */ Term_queue_char(vx, vy, a, c); #endif /* USE_TRANSPARENCY */ + } *************** *** 1244,1261 **** --- 1224,1246 ---- vx = kx + COL_MAP; #ifdef USE_TRANSPARENCY + /* Hack -- redraw the grid */ map_info(y, x, &a, &c, &ta, &tc); /* Hack -- Queue it */ Term_queue_char(vx, vy, a, c, ta, tc); + #else /* USE_TRANSPARENCY */ + /* Hack -- redraw the grid */ map_info(y, x, &a, &c); /* Hack -- Queue it */ Term_queue_char(vx, vy, a, c); + #endif /* USE_TRANSPARENCY */ + } *************** *** 1290,1308 **** --- 1275,1299 ---- { for (x = p_ptr->wx, vx = COL_MAP; vx < tx; vx++, x++) { + #ifdef USE_TRANSPARENCY + /* Determine what is there */ map_info(y, x, &a, &c, &ta, &tc); /* Hack -- Queue it */ Term_queue_char(vx, vy, a, c, ta, tc); + #else /* USE_TRANSPARENCY */ + /* Determine what is there */ map_info(y, x, &a, &c); /* Hack -- Queue it */ Term_queue_char(vx, vy, a, c); + #endif /* USE_TRANSPARENCY */ + } } } *************** *** 1312,1328 **** /* - * Display highest priority object in the RATIO by RATIO area - */ - #define RATIO 3 - - /* - * Display the entire map - */ - #define MAP_HGT (DUNGEON_HGT / RATIO) - #define MAP_WID (DUNGEON_WID / RATIO) - - /* * Hack -- priority array (see below) * * Note that all "walls" always look like "secret doors" (see "map_info()"). --- 1303,1308 ---- *************** *** 1401,1436 **** /* ! * Display a "small-scale" map of the dungeon in the active Term * ! * Note that this function must "disable" the special lighting ! * effects so that the "priority" function will work. * ! * Note the use of a specialized "priority" function to allow this ! * function to work with any graphic attr/char mappings, and the ! * attempts to optimize this function where possible. */ void display_map(int *cy, int *cx) { int py = p_ptr->py; int px = p_ptr->px; ! int i, j, x, y; byte ta; char tc; byte tp; ! byte ma[MAP_HGT + 2][MAP_WID + 2]; ! char mc[MAP_HGT + 2][MAP_WID + 2]; ! ! byte mp[MAP_HGT + 2][MAP_WID + 2]; bool old_view_special_lite; bool old_view_granite_lite; /* Save lighting effects */ old_view_special_lite = view_special_lite; old_view_granite_lite = view_granite_lite; --- 1381,1447 ---- /* ! * Maximum size of map. ! */ ! #define MAP_HGT (DUNGEON_HGT / 3) ! #define MAP_WID (DUNGEON_WID / 3) ! ! ! /* ! * Display a "small-scale" map of the dungeon in the active Term. * ! * Note that this function must "disable" the special lighting effects so ! * that the "priority" function will work. * ! * Note the use of a specialized "priority" function to allow this function ! * to work with any graphic attr/char mappings, and the attempts to optimize ! * this function where possible. ! * ! * If "cy" and "cx" are not NULL, then returns the screen location at which ! * the player was displayed, so the cursor can be moved to that location, ! * and restricts the horizontal map size to SCREEN_WID. Otherwise, nothing ! * is returned (obviously), and no restrictions are enforced. */ void display_map(int *cy, int *cx) { int py = p_ptr->py; int px = p_ptr->px; ! int map_hgt, map_wid; ! ! int row, col; ! ! int x, y; byte ta; char tc; byte tp; ! /* Large array on the stack */ ! byte mp[DUNGEON_HGT][DUNGEON_WID]; bool old_view_special_lite; bool old_view_granite_lite; + /* Desired map height */ + map_hgt = Term->hgt - 2; + map_wid = Term->wid - 2; + + /* Prevent accidents */ + if (map_hgt > DUNGEON_HGT) map_hgt = DUNGEON_HGT; + if (map_wid > DUNGEON_WID) map_wid = DUNGEON_WID; + + /* Silliness XXX XXX XXX */ + if ((cy != NULL) && (map_hgt > SCREEN_HGT)) map_hgt = SCREEN_HGT; + if ((cx != NULL) && (map_wid > SCREEN_WID)) map_wid = SCREEN_WID; + + + /* Prevent accidents */ + if ((map_wid < 1) || (map_hgt < 1)) return; + + /* Save lighting effects */ old_view_special_lite = view_special_lite; old_view_granite_lite = view_granite_lite; *************** *** 1440,1529 **** view_granite_lite = FALSE; ! /* Clear the chars and attributes */ ! for (y = 0; y < MAP_HGT+2; ++y) { ! for (x = 0; x < MAP_WID+2; ++x) { ! /* Nothing here */ ! ma[y][x] = TERM_WHITE; ! mc[y][x] = ' '; /* No priority */ mp[y][x] = 0; } } ! /* Fill in the map */ ! for (i = 0; i < DUNGEON_WID; ++i) { ! for (j = 0; j < DUNGEON_HGT; ++j) { ! /* Location */ ! x = i / RATIO + 1; ! y = j / RATIO + 1; - /* Extract the current attr/char at that map location */ #ifdef USE_TRANSPARENCY ! map_info(j, i, &ta, &tc, &ta, &tc); #else /* USE_TRANSPARENCY */ ! map_info(j, i, &ta, &tc); #endif /* USE_TRANSPARENCY */ ! /* Extract the priority of that attr/char */ tp = priority(ta, tc); /* Save "best" */ ! if (mp[y][x] < tp) { ! /* Save the char */ ! mc[y][x] = tc; ! ! /* Save the attr */ ! ma[y][x] = ta; /* Save priority */ ! mp[y][x] = tp; } } } ! /* Corners */ ! x = MAP_WID + 1; ! y = MAP_HGT + 1; ! ! /* Draw the corners */ ! mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+'; ! ! /* Draw the horizontal edges */ ! for (x = 1; x <= MAP_WID; x++) mc[0][x] = mc[y][x] = '-'; ! ! /* Draw the vertical edges */ ! for (y = 1; y <= MAP_HGT; y++) mc[y][0] = mc[y][x] = '|'; ! ! /* Display each map line in order */ ! for (y = 0; y < MAP_HGT+2; ++y) { ! /* Start a new line */ ! Term_gotoxy(0, y); ! /* Display the line */ ! for (x = 0; x < MAP_WID+2; ++x) ! { ! ta = ma[y][x]; ! tc = mc[y][x]; ! /* Add the character */ ! Term_addch(ta, tc); ! } ! } ! /* Player location */ ! (*cy) = py / RATIO + 1; ! (*cx) = px / RATIO + 1; /* Restore lighting effects */ --- 1451,1556 ---- view_granite_lite = FALSE; ! /* Nothing here */ ! ta = TERM_WHITE; ! tc = ' '; ! ! /* Clear the small scale map */ ! for (y = 0; y < map_hgt; ++y) { ! for (x = 0; x < map_wid; ++x) { ! /* Erase the grid */ ! Term_putch(x + 1, y + 1, ta, tc); /* No priority */ mp[y][x] = 0; } } ! /* Corners */ ! x = map_wid + 1; ! y = map_hgt + 1; ! ! /* Draw the corners */ ! Term_putch(0, 0, ta, '+'); ! Term_putch(x, 0, ta, '+'); ! Term_putch(0, y, ta, '+'); ! Term_putch(x, y, ta, '+'); ! ! /* Draw the horizontal edges */ ! for (x = 1; x <= map_wid; x++) ! { ! Term_putch(x, 0, ta, '-'); ! Term_putch(x, y, ta, '-'); ! } ! ! /* Draw the vertical edges */ ! for (y = 1; y <= map_hgt; y++) ! { ! Term_putch(0, y, ta, '|'); ! Term_putch(x, y, ta, '|'); ! } ! ! ! /* Analyze the actual map */ ! for (y = 0; y < DUNGEON_HGT; y++) { ! for (x = 0; x < DUNGEON_WID; x++) { ! row = (y * map_hgt / DUNGEON_HGT); ! col = (x * map_wid / DUNGEON_WID); #ifdef USE_TRANSPARENCY ! ! /* Get the attr/char at that map location */ ! map_info(y, x, &ta, &tc, &ta, &tc); ! #else /* USE_TRANSPARENCY */ ! ! /* Get the attr/char at that map location */ ! map_info(y, x, &ta, &tc); ! #endif /* USE_TRANSPARENCY */ ! /* Get the priority of that attr/char */ tp = priority(ta, tc); /* Save "best" */ ! if (mp[row][col] < tp) { ! /* Add the character */ ! Term_putch(col + 1, row + 1, ta, tc); /* Save priority */ ! mp[row][col] = tp; } } } ! /* Player location */ ! row = (py * map_hgt / DUNGEON_HGT); ! col = (px * map_wid / DUNGEON_WID); ! /* Make sure the player is visible */ ! if (TRUE) { ! monster_race *r_ptr = &r_info[0]; ! /* Get the "player" attr */ ! ta = r_ptr->x_attr; ! /* Get the "player" char */ ! tc = r_ptr->x_char; + /* Draw the player */ + Term_putch(col + 1, row + 1, ta, tc); + } ! /* Return player location */ ! if (cy != NULL) (*cy) = row + 1; ! if (cx != NULL) (*cx) = col + 1; /* Restore lighting effects */ *************** *** 1560,1566 **** put_str("Hit any key to continue", 23, 23); /* Hilite the player */ ! move_cursor(cy, cx); /* Get any key */ (void)inkey(); --- 1587,1593 ---- put_str("Hit any key to continue", 23, 23); /* Hilite the player */ ! Term_gotoxy(cx, cy); /* Get any key */ (void)inkey(); diff -r -c angband-290-x11/src/cmd3.c angband-290/src/cmd3.c *** angband-290-x11/src/cmd3.c Fri Jun 2 21:38:08 2000 --- angband-290/src/cmd3.c Sun Apr 23 21:54:56 2000 *************** *** 947,991 **** */ void do_cmd_locate(void) { ! int dir, y1, x1, y2, x2; ! char tmp_val[80]; ! char out_val[160]; - /* Start at current panel */ - y2 = y1 = p_ptr->wy; - x2 = x1 = p_ptr->wx; - /* Show panels until done */ - while (1) - { /* Describe the location */ ! if ((y2 == y1) && (x2 == x1)) { tmp_val[0] = '\0'; } else { sprintf(tmp_val, "%s%s of", ! ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""), ! ((x2 < x1) ? " West" : (x2 > x1) ? " East" : "")); } ! /* Prepare to ask which way to look */ ! sprintf(out_val, ! "Map sector [%d,%d], which is%s your sector. Direction?", ! (y2 / PANEL_HGT), (x2 / PANEL_WID), tmp_val); ! ! /* More detail */ if (center_player) { sprintf(out_val, "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?", ! (y2 / PANEL_HGT), (y2 % PANEL_HGT), ! (x2 / PANEL_WID), (x2 % PANEL_WID), tmp_val); } /* Assume no direction */ dir = 0; --- 947,996 ---- */ void do_cmd_locate(void) { ! int old_wy = p_ptr->wy; ! int old_wx = p_ptr->wx; ! /* Show panels until done */ ! while (1) ! { ! int wy = p_ptr->wy; ! int wx = p_ptr->wx; ! char tmp_val[80]; + char out_val[160]; + + int dir; /* Describe the location */ ! if ((wy == old_wy) && (wx == old_wx)) { tmp_val[0] = '\0'; } else { sprintf(tmp_val, "%s%s of", ! ((wy < old_wy) ? " North" : (wy > old_wy) ? " South" : ""), ! ((wx < old_wx) ? " West" : (wx > old_wx) ? " East" : "")); } ! /* Describe the panel */ if (center_player) { sprintf(out_val, "Map sector [%d(%02d),%d(%02d)], which is%s your sector. Direction?", ! (wy / PANEL_HGT), (wy % PANEL_HGT), ! (wx / PANEL_WID), (wx % PANEL_WID), tmp_val); } + else + { + /* Prepare to ask which way to look */ + sprintf(out_val, + "Map sector [%d,%d], which is%s your sector. Direction?", + (wy / PANEL_HGT), (wx / PANEL_WID), tmp_val); + } + /* Assume no direction */ dir = 0; *************** *** 1008,1038 **** /* No direction */ if (!dir) break; - /* Apply the motion */ - y2 += (ddy[dir] * PANEL_HGT); - x2 += (ddx[dir] * PANEL_WID); - - /* Verify the row */ - if (y2 < 0) y2 = 0; - if (y2 > DUNGEON_HGT - SCREEN_HGT) y2 = DUNGEON_HGT - SCREEN_HGT; - - /* Verify the col */ - if (x2 < 0) x2 = 0; - if (x2 > DUNGEON_WID - SCREEN_WID) x2 = DUNGEON_WID - SCREEN_WID; - /* Handle "changes" */ ! if ((p_ptr->wy != y2) || (p_ptr->wx != x2)) { - /* Update panel */ - p_ptr->wy = y2; - p_ptr->wx = x2; - - /* Redraw map */ - p_ptr->redraw |= (PR_MAP); - - /* Window stuff */ - p_ptr->window |= (PW_OVERHEAD); - /* Handle stuff */ handle_stuff(); } --- 1013,1021 ---- /* No direction */ if (!dir) break; /* Handle "changes" */ ! if (change_panel(dir)) { /* Handle stuff */ handle_stuff(); } diff -r -c angband-290-x11/src/config.h angband-290/src/config.h *** angband-290-x11/src/config.h Fri Jun 2 21:38:08 2000 --- angband-290/src/config.h Sun Apr 23 19:58:22 2000 *************** *** 255,266 **** /* - * OPTION: Allow scrolling while targetting. - */ - #define ALLOW_SCROLL_TARGET - - - /* * OPTION: Delay the loading of the "f_text" array until it is actually * needed, saving ~1K, since "feature" descriptions are unused. */ --- 255,260 ---- *************** *** 493,510 **** * OPTION: Default font (when using X11). */ #define DEFAULT_X11_FONT "9x15" - - /* - * OPTION: Default fonts (when using X11) - */ - #define DEFAULT_X11_FONT_0 "10x20" - #define DEFAULT_X11_FONT_1 "9x15" - #define DEFAULT_X11_FONT_2 "9x15" - #define DEFAULT_X11_FONT_3 "5x8" - #define DEFAULT_X11_FONT_4 "5x8" - #define DEFAULT_X11_FONT_5 "5x8" - #define DEFAULT_X11_FONT_6 "5x8" - #define DEFAULT_X11_FONT_7 "5x8" /* --- 487,492 ---- diff -r -c angband-290-x11/src/externs.h angband-290/src/externs.h *** angband-290-x11/src/externs.h Fri Jun 2 21:38:08 2000 --- angband-290/src/externs.h Sun Apr 23 21:45:55 2000 *************** *** 714,719 **** --- 714,722 ---- extern void lose_exp(s32b amount); extern void monster_death(int m_idx); extern bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note); + extern bool modify_panel(int wy, int wx); + extern bool adjust_panel(int y, int x); + extern bool change_panel(int dir); extern void verify_panel(void); extern cptr look_mon_desc(int m_idx); extern void ang_sort_aux(vptr u, vptr v, int p, int q); diff -r -c angband-290-x11/src/xtra1.c angband-290/src/xtra1.c *** angband-290-x11/src/xtra1.c Fri Jun 2 21:38:08 2000 --- angband-290/src/xtra1.c Wed Apr 26 02:23:18 2000 *************** *** 1025,1043 **** /* ! * Hack -- display overhead view in sub-windows * ! * Note that the "player" symbol does NOT appear on the map. */ static void fix_overhead(void) { - int py = p_ptr->py; - int px = p_ptr->px; - int j; - int cy, cx; - /* Scan windows */ for (j = 0; j < 8; j++) { --- 1025,1043 ---- /* ! * Hack -- display overhead view in sub-windows. * ! * This is most useful on a fast machine with the "center_player" option set, ! * which induces a call to this function every time the player moves. With ! * the "center_player" option not set, this function is only called when the ! * panel changes. ! * ! * The "display_map()" function handles NULL arguments in a special manner. */ static void fix_overhead(void) { int j; /* Scan windows */ for (j = 0; j < 8; j++) { *************** *** 1052,1065 **** /* Activate */ Term_activate(angband_term[j]); - /* Hack -- Hide player XXX XXX XXX */ - cave_m_idx[py][px] = 0; - /* Redraw map */ ! display_map(&cy, &cx); ! ! /* Hack -- Show player XXX XXX XXX */ ! cave_m_idx[py][px] = -1; /* Fresh */ Term_fresh(); --- 1052,1059 ---- /* Activate */ Term_activate(angband_term[j]); /* Redraw map */ ! display_map(NULL, NULL); /* Fresh */ Term_fresh(); diff -r -c angband-290-x11/src/xtra2.c angband-290/src/xtra2.c *** angband-290-x11/src/xtra2.c Fri Jun 2 21:38:08 2000 --- angband-290/src/xtra2.c Sun Apr 23 22:00:49 2000 *************** *** 2241,2388 **** return (FALSE); } /* ! * Handle a request to change the current panel * ! * Return TRUE if the panel was changed. */ ! static bool change_panel(int dir) { ! int y = p_ptr->wy + ddy[dir] * PANEL_HGT; ! int x = p_ptr->wx + ddx[dir] * PANEL_WID; ! ! /* Verify the row */ ! if (y < 0) y = 0; ! if (y > DUNGEON_HGT - SCREEN_HGT) y = DUNGEON_HGT - SCREEN_HGT; ! ! /* Verify the col */ ! if (x < 0) x = 0; ! if (x > DUNGEON_WID - SCREEN_WID) x = DUNGEON_WID - SCREEN_WID; ! ! /* Handle "changes" */ ! if ((p_ptr->wy != y) || (p_ptr->wx != x)) ! { ! /* Update panel */ ! p_ptr->wy = y; ! p_ptr->wx = x; ! ! /* Update stuff */ ! p_ptr->update |= (PU_MONSTERS); /* Redraw map */ p_ptr->redraw |= (PR_MAP); ! /* Handle stuff */ ! handle_stuff(); ! /* Success */ ! return TRUE; } /* No change */ ! return FALSE; } /* ! * Check for, and react to, the player leaving the panel * ! * When the player gets too close to the edge of a panel, the ! * map scrolls one panel in that direction so that the player * is no longer so close to the edge. */ void verify_panel(void) { int py = p_ptr->py; int px = p_ptr->px; ! int i; - bool scroll = FALSE; ! ! /* Initial row */ ! i = p_ptr->wy; ! ! /* Scroll screen when off-center */ if (center_player && (!p_ptr->running || !run_avoid_center) && ! (py != p_ptr->wy + SCREEN_HGT / 2)) ! { ! i = py - SCREEN_HGT / 2; ! if (i < 0) i = 0; ! if (i > DUNGEON_HGT - SCREEN_HGT) i = DUNGEON_HGT - SCREEN_HGT; ! } ! ! /* Scroll screen when 2 grids from top/bottom edge */ ! else if ((py < p_ptr->wy + 2) || (py >= p_ptr->wy + SCREEN_HGT - 2)) { ! i = ((py - PANEL_HGT / 2) / PANEL_HGT) * PANEL_HGT; ! if (i < 0) i = 0; ! if (i > DUNGEON_HGT - SCREEN_HGT) i = DUNGEON_HGT - SCREEN_HGT; } ! /* Hack -- handle town */ ! if (!p_ptr->depth) i = SCREEN_HGT; ! ! /* New panel row */ ! if (p_ptr->wy != i) { ! /* Update panel */ ! p_ptr->wy = i; ! ! /* Scroll */ ! scroll = TRUE; } ! /* Initial col */ ! i = p_ptr->wx; ! ! /* Scroll screen when off-center */ if (center_player && (!p_ptr->running || !run_avoid_center) && ! (px != p_ptr->wx + SCREEN_WID / 2)) ! { ! i = px - SCREEN_WID / 2; ! if (i < 0) i = 0; ! if (i > DUNGEON_WID - SCREEN_WID) i = DUNGEON_WID - SCREEN_WID; ! } ! ! /* Scroll screen when 4 grids from left/right edge */ ! else if ((px < p_ptr->wx + 4) || (px >= p_ptr->wx + SCREEN_WID - 4)) { ! i = ((px - PANEL_WID / 2) / PANEL_WID) * PANEL_WID; ! if (i < 0) i = 0; ! if (i > DUNGEON_WID - SCREEN_WID) i = DUNGEON_WID - SCREEN_WID; } ! /* Hack -- handle town */ ! if (!p_ptr->depth) i = SCREEN_WID; ! ! /* New panel col */ ! if (p_ptr->wx != i) { ! /* Update panel */ ! p_ptr->wx = i; ! ! /* Scroll */ ! scroll = TRUE; } ! /* Scroll */ ! if (scroll) { /* Optional disturb on "panel change" */ if (disturb_panel && !center_player) disturb(0, 0); - - /* Redraw map */ - p_ptr->redraw |= (PR_MAP); - - /* Window stuff */ - p_ptr->window |= (PW_OVERHEAD); } } --- 2241,2383 ---- return (FALSE); } + /* ! * Modify the current panel to the given coordinates, adjusting only to ! * ensure the coordinates are legal, and return TRUE if anything done. * ! * Hack -- The town should never be scrolled around. ! * ! * Note that monsters are no longer affected in any way by panel changes. ! * ! * As a total hack, whenever the current panel changes, we assume that ! * the "overhead view" window should be updated. */ ! bool modify_panel(int wy, int wx) { ! /* Verify wy, adjust if needed */ ! if (p_ptr->depth == 0) wy = SCREEN_HGT; ! else if (wy > DUNGEON_HGT - SCREEN_HGT) wy = DUNGEON_HGT - SCREEN_HGT; ! else if (wy < 0) wy = 0; ! ! /* Verify wx, adjust if needed */ ! if (p_ptr->depth == 0) wx = SCREEN_WID; ! else if (wx > DUNGEON_WID - SCREEN_WID) wx = DUNGEON_WID - SCREEN_WID; ! else if (wx < 0) wx = 0; ! ! /* React to changes */ ! if ((p_ptr->wy != wy) || (p_ptr->wx != wx)) ! { ! /* Save wy, wx */ ! p_ptr->wy = wy; ! p_ptr->wx = wx; /* Redraw map */ p_ptr->redraw |= (PR_MAP); ! /* Hack -- Window stuff */ ! p_ptr->window |= (PW_OVERHEAD); ! /* Changed */ ! return (TRUE); } /* No change */ ! return (FALSE); } + /* + * Perform the minimum "whole panel" adjustment to ensure that the given + * location is contained inside the current panel, and return TRUE if any + * such adjustment was performed. + */ + bool adjust_panel(int y, int x) + { + int wy = p_ptr->wy; + int wx = p_ptr->wx; + /* Adjust as needed */ + while (y >= wy + SCREEN_HGT) wy += SCREEN_HGT; + while (y < wy) wy -= SCREEN_HGT; + + /* Adjust as needed */ + while (x >= wx + SCREEN_WID) wx += SCREEN_WID; + while (x < wx) wx -= SCREEN_WID; + + /* Use "modify_panel" */ + return (modify_panel(wy, wx)); + } + + + /* + * Change the current panel to the panel lying in the given direction. + * + * Return TRUE if the panel was changed. + */ + bool change_panel(int dir) + { + int wy = p_ptr->wy + ddy[dir] * PANEL_HGT; + int wx = p_ptr->wx + ddx[dir] * PANEL_WID; + + /* Use "modify_panel" */ + return (modify_panel(wy, wx)); + } /* ! * Verify the current panel (relative to the player location). * ! * By default, when the player gets "too close" to the edge of the current ! * panel, the map scrolls one panel in that direction so that the player * is no longer so close to the edge. + * + * The "center_player" option allows the current panel to always be centered + * around the player, which is very expensive, and also has some interesting + * gameplay ramifications. */ void verify_panel(void) { int py = p_ptr->py; int px = p_ptr->px; ! int wy = p_ptr->wy; ! int wx = p_ptr->wx; ! /* Scroll screen vertically when off-center */ if (center_player && (!p_ptr->running || !run_avoid_center) && ! (py != wy + SCREEN_HGT / 2)) { ! wy = py - SCREEN_HGT / 2; } ! /* Scroll screen vertically when 2 grids from top/bottom edge */ ! else if ((py < wy + 2) || (py >= wy + SCREEN_HGT - 2)) { ! wy = ((py - PANEL_HGT / 2) / PANEL_HGT) * PANEL_HGT; } ! /* Scroll screen horizontally when off-center */ if (center_player && (!p_ptr->running || !run_avoid_center) && ! (px != wx + SCREEN_WID / 2)) { ! wx = px - SCREEN_WID / 2; } ! /* Scroll screen horizontally when 4 grids from left/right edge */ ! else if ((px < wx + 4) || (px >= wx + SCREEN_WID - 4)) { ! wx = ((px - PANEL_WID / 2) / PANEL_WID) * PANEL_WID; } ! /* Scroll if needed */ ! if (modify_panel(wy, wx)) { /* Optional disturb on "panel change" */ if (disturb_panel && !center_player) disturb(0, 0); } } *************** *** 2935,2943 **** temp_n = 0; /* Scan the current panel */ ! for (y = p_ptr->wy; y < p_ptr->wy+SCREEN_HGT; y++) { ! for (x = p_ptr->wx; x < p_ptr->wx+SCREEN_WID; x++) { /* Require line of sight, unless "look" is "expanded" */ if (!expand_look && !player_has_los_bold(y, x)) continue; --- 2930,2938 ---- temp_n = 0; /* Scan the current panel */ ! for (y = p_ptr->wy; y < p_ptr->wy + SCREEN_HGT; y++) { ! for (x = p_ptr->wx; x < p_ptr->wx + SCREEN_WID; x++) { /* Require line of sight, unless "look" is "expanded" */ if (!expand_look && !player_has_los_bold(y, x)) continue; *************** *** 3368,3378 **** * * Note that this code can be called from "get_aim_dir()". * ! * All locations must be on the current panel. XXX XXX XXX ! * ! * Perhaps consider the possibility of "auto-scrolling" the screen ! * while the cursor moves around. This may require dynamic updating ! * of the "temp" grid set. XXX XXX XXX * * Hack -- targetting/observing an "outer border grid" may induce * problems, so this is not currently allowed. --- 3363,3377 ---- * * Note that this code can be called from "get_aim_dir()". * ! * All locations must be on the current panel, unless the "scroll_target" ! * option is used, which allows changing the current panel during "look" ! * and "target" commands. Currently, when "flag" is true, that is, when ! * "interesting" grids are being used, and a directional key is used, we ! * only scroll by a single panel, in the direction requested, and check ! * for any interesting grids on that panel. The "correct" solution would ! * actually involve scanning a larger set of grids, including ones in ! * panels which are adjacent to the one currently scanned, but this is ! * overkill for this function. XXX XXX * * Hack -- targetting/observing an "outer border grid" may induce * problems, so this is not currently allowed. *************** *** 3499,3527 **** case 'p': { - - #ifdef ALLOW_SCROLL_TARGET - if (scroll_target) { ! /* Recenter the map around the player */ verify_panel(); - /* Update stuff */ - p_ptr->update |= (PU_MONSTERS); - - /* Redraw map */ - p_ptr->redraw |= (PR_MAP); - - /* Window stuff */ - p_ptr->window |= (PW_OVERHEAD); - /* Handle stuff */ handle_stuff(); } - #endif /* ALLOW_SCROLL_TARGET */ - y = py; x = px; } --- 3498,3512 ---- case 'p': { if (scroll_target) { ! /* Recenter around player */ verify_panel(); /* Handle stuff */ handle_stuff(); } y = py; x = px; } *************** *** 3572,3664 **** /* Hack -- move around */ if (d) { ! ! #ifdef ALLOW_SCROLL_TARGET ! ! int y2 = p_ptr->wy; ! int x2 = p_ptr->wx; ! ! #endif /* ALLOW_SCROLL_TARGET */ /* Find a new monster */ ! i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]); ! ! #ifdef ALLOW_SCROLL_TARGET ! /* Request to target past last interesting grid */ ! while (scroll_target && flag && (i < 0)) { ! /* Note the change */ if (change_panel(d)) { - int v = temp_y[m]; - int u = temp_x[m]; - /* Recalculate interesting grids */ target_set_interactive_prepare(mode); - /* Look at interesting grids */ - flag = TRUE; - /* Find a new monster */ ! i = target_pick(v, u, ddy[d], ddx[d]); ! ! /* Use that grid */ ! if (i >= 0) m = i; ! } ! ! /* Nothing interesting */ ! else ! { ! /* Restore previous position */ ! p_ptr->wy = y2; ! p_ptr->wx = x2; ! ! /* Update stuff */ ! p_ptr->update |= (PU_MONSTERS); ! /* Redraw map */ ! p_ptr->redraw |= (PR_MAP); ! /* Window stuff */ ! p_ptr->window |= (PW_OVERHEAD); /* Handle stuff */ handle_stuff(); - - /* Recalculate interesting grids */ - target_set_interactive_prepare(mode); - - /* Look at boring grids */ - flag = FALSE; - - /* Move */ - x += ddx[d]; - y += ddy[d]; - - /* Apply the motion */ - if ((y >= p_ptr->wy + SCREEN_HGT) || (y < p_ptr->wy) || - (x >= p_ptr->wx + SCREEN_WID) || (x < p_ptr->wx)) - { - if (change_panel(d)) - { - target_set_interactive_prepare(mode); - } - } - - /* Slide into legality */ - if (x >= DUNGEON_WID-1) x = DUNGEON_WID - 2; - else if (x <= 0) x = 1; - - /* Slide into legality */ - if (y >= DUNGEON_HGT-1) y = DUNGEON_HGT - 2; - else if (y <= 0) y = 1; } } ! #endif /* ALLOW_SCROLL_TARGET */ ! ! /* Use that grid */ if (i >= 0) m = i; } } --- 3557,3597 ---- /* Hack -- move around */ if (d) { ! int old_y = temp_y[m]; ! int old_x = temp_x[m]; /* Find a new monster */ ! i = target_pick(old_y, old_x, ddy[d], ddx[d]); ! /* Scroll to find interesting grid */ ! if (scroll_target && (i < 0)) { ! int old_wy = p_ptr->wy; ! int old_wx = p_ptr->wx; ! ! /* Change if legal */ if (change_panel(d)) { /* Recalculate interesting grids */ target_set_interactive_prepare(mode); /* Find a new monster */ ! i = target_pick(old_y, old_x, ddy[d], ddx[d]); ! /* Restore panel if needed */ ! if ((i < 0) && modify_panel(old_wy, old_wx)) ! { ! /* Recalculate interesting grids */ ! target_set_interactive_prepare(mode); ! } /* Handle stuff */ handle_stuff(); } } ! /* Use interesting grid if found */ if (i >= 0) m = i; } } *************** *** 3698,3726 **** case 'p': { - - #ifdef ALLOW_SCROLL_TARGET - if (scroll_target) { ! /* Recenter the map around the player */ verify_panel(); - /* Update stuff */ - p_ptr->update |= (PU_MONSTERS); - - /* Redraw map */ - p_ptr->redraw |= (PR_MAP); - - /* Window stuff */ - p_ptr->window |= (PW_OVERHEAD); - /* Handle stuff */ handle_stuff(); } - #endif /* ALLOW_SCROLL_TARGET */ - y = py; x = px; } --- 3631,3645 ---- case 'p': { if (scroll_target) { ! /* Recenter around player */ verify_panel(); /* Handle stuff */ handle_stuff(); } y = py; x = px; } *************** *** 3785,3807 **** x += ddx[d]; y += ddy[d]; ! /* Apply the motion */ ! if ((y >= p_ptr->wy + SCREEN_HGT) || (y < p_ptr->wy) || ! (x >= p_ptr->wx + SCREEN_WID) || (x < p_ptr->wx)) { ! if (change_panel(d)) { target_set_interactive_prepare(mode); } } ! /* Slide into legality */ ! if (x >= DUNGEON_WID-1) x = DUNGEON_WID - 2; ! else if (x <= 0) x = 1; ! ! /* Slide into legality */ ! if (y >= DUNGEON_HGT-1) y = DUNGEON_HGT - 2; ! else if (y <= 0) y = 1; } } } --- 3704,3740 ---- x += ddx[d]; y += ddy[d]; ! if (scroll_target) { ! /* Slide into legality */ ! if (x >= DUNGEON_WID - 1) x--; ! else if (x <= 0) x++; ! ! /* Slide into legality */ ! if (y >= DUNGEON_HGT - 1) y--; ! else if (y <= 0) y++; ! ! /* Adjust panel if needed */ ! if (adjust_panel(y, x)) { + /* Handle stuff */ + handle_stuff(); + + /* Recalculate interesting grids */ target_set_interactive_prepare(mode); } } ! else ! { ! /* Slide into legality */ ! if (x >= p_ptr->wx + SCREEN_WID) x--; ! else if (x < p_ptr->wx) x++; ! ! /* Slide into legality */ ! if (y >= p_ptr->wy + SCREEN_HGT) y--; ! else if (y < p_ptr->wy) y++; ! } } } } *************** *** 3812,3838 **** /* Clear the top line */ prt("", 0, 0); - #ifdef ALLOW_SCROLL_TARGET - if (scroll_target) { ! /* Recenter the map around the player */ verify_panel(); - /* Update stuff */ - p_ptr->update |= (PU_MONSTERS); - - /* Redraw map */ - p_ptr->redraw |= (PR_MAP); - - /* Window stuff */ - p_ptr->window |= (PW_OVERHEAD); - /* Handle stuff */ handle_stuff(); } - - #endif /* ALLOW_SCROLL_TARGET */ /* Failure to set target */ if (!p_ptr->target_set) return (FALSE); --- 3745,3758 ---- /* Clear the top line */ prt("", 0, 0); if (scroll_target) { ! /* Recenter around player */ verify_panel(); /* Handle stuff */ handle_stuff(); } /* Failure to set target */ if (!p_ptr->target_set) return (FALSE);