diff -Prub nethack-3.4.3/include/config.h nethack-3.4.3_LOS/include/config.h --- nethack-3.4.3/include/config.h 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/include/config.h 2004-09-08 20:03:59.000000000 +0200 @@ -350,6 +350,10 @@ /*#define GOLDOBJ */ /* Gold is kept on obj chains - Helge Hafting */ /*#define AUTOPICKUP_EXCEPTIONS */ /* exceptions to autopickup */ +#define LINEOFSIGHT /* Show line of sight */ +#ifdef LINEOFSIGHT +# define LINEOFSIGHT_COLOUR /* Allow selection of the colour used for shading */ +#endif /* End of Section 5 */ diff -Prub nethack-3.4.3/include/decl.h nethack-3.4.3_LOS/include/decl.h --- nethack-3.4.3/include/decl.h 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/include/decl.h 2004-09-07 16:37:24.000000000 +0200 @@ -326,6 +326,9 @@ /* Vision */ E NEARDATA boolean vision_full_recalc; /* TRUE if need vision recalc */ E NEARDATA char **viz_array; /* could see/in sight row pointers */ +#ifdef LINEOFSIGHT +E NEARDATA char **viz_array_old; /* could see/in sight row pointers previous */ +#endif /* Window system stuff */ E NEARDATA winid WIN_MESSAGE, WIN_STATUS; diff -Prub nethack-3.4.3/include/flag.h nethack-3.4.3_LOS/include/flag.h --- nethack-3.4.3/include/flag.h 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/include/flag.h 2004-09-08 20:05:32.000000000 +0200 @@ -220,6 +220,9 @@ * Window capability support. */ boolean wc_color; /* use color graphics */ +#ifdef LINEOFSIGHT + boolean wc_lineofsight; /* show line of sight */ +#endif boolean wc_hilite_pet; /* hilight pets */ boolean wc_ascii_map; /* show map using traditional ascii */ boolean wc_tiled_map; /* show map using tiles */ @@ -271,6 +274,9 @@ boolean showrace; /* show hero glyph by race rather than by role */ boolean travelcmd; /* allow travel command */ int runmode; /* update screen display during run moves */ +#ifdef LINEOFSIGHT_COLOUR + int los_colour; /* colour to use for shaded areas when lineofsight is on */ +#endif #ifdef AUTOPICKUP_EXCEPTIONS struct autopickup_exception *autopickup_exceptions[2]; #define AP_LEAVE 0 diff -Prub nethack-3.4.3/include/vision.h nethack-3.4.3_LOS/include/vision.h --- nethack-3.4.3/include/vision.h 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/include/vision.h 2004-09-08 19:05:08.000000000 +0200 @@ -29,6 +29,10 @@ */ #define cansee(x,y) (viz_array[y][x] & IN_SIGHT) #define couldsee(x,y) (viz_array[y][x] & COULD_SEE) +#ifdef LINEOFSIGHT +# define couldsee_old(x,y) (viz_array_old[y][x] & COULD_SEE) +# define cansee_old(x,y) (viz_array_old[y][x] & IN_SIGHT) +#endif #define templit(x,y) (viz_array[y][x] & TEMP_LIT) /* diff -Prub nethack-3.4.3/src/decl.c nethack-3.4.3_LOS/src/decl.c --- nethack-3.4.3/src/decl.c 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/src/decl.c 2004-09-07 16:39:03.000000000 +0200 @@ -254,6 +254,9 @@ /* Vision */ NEARDATA boolean vision_full_recalc = 0; NEARDATA char **viz_array = 0;/* used in cansee() and couldsee() macros */ +#ifdef LINEOFSIGHT +NEARDATA char **viz_array_old = 0;/* used in cansee() and couldsee() macros */ +#endif /* Global windowing data, defined here for multi-window-system support */ NEARDATA winid WIN_MESSAGE = WIN_ERR, WIN_STATUS = WIN_ERR; diff -Prub nethack-3.4.3/src/display.c nethack-3.4.3_LOS/src/display.c --- nethack-3.4.3/src/display.c 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/src/display.c 2004-09-08 19:06:20.000000000 +0200 @@ -1266,7 +1266,11 @@ return; } +#ifdef LINEOFSIGHT + if ((gbuf[y][x].glyph != glyph) || ((glyph!=cmap_to_glyph(S_stone)) && ((couldsee(x,y)!=couldsee_old(x,y)) || (cansee(x,y)!=cansee_old(x,y))))) { +#else if (gbuf[y][x].glyph != glyph) { +#endif gbuf[y][x].glyph = glyph; gbuf[y][x].new = 1; if (gbuf_start[y] > x) gbuf_start[y] = x; diff -Prub nethack-3.4.3/src/mapglyph.c nethack-3.4.3_LOS/src/mapglyph.c --- nethack-3.4.3/src/mapglyph.c 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/src/mapglyph.c 2004-09-08 20:42:20.000000000 +0200 @@ -125,9 +125,24 @@ #ifdef TEXTCOLOR /* provide a visible difference if normal and lit corridor * use the same symbol */ +# ifdef LINEOFSIGHT + if (iflags.use_color) { + if (iflags.wc_lineofsight) { + if (!couldsee(x,y) || !cansee(x,y) || (offset == S_corr)) +# ifdef LINEOFSIGHT_COLOUR + color = iflags.los_colour; +# else + color = CLR_BLUE; +# endif + } + else if (offset == S_litcorr && ch == showsyms[S_corr]) + color = CLR_WHITE; + } +# else if (iflags.use_color && offset == S_litcorr && ch == showsyms[S_corr]) color = CLR_WHITE; +# endif else #endif cmap_color(offset); diff -Prub nethack-3.4.3/src/options.c nethack-3.4.3_LOS/src/options.c --- nethack-3.4.3/src/options.c 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/src/options.c 2004-09-08 21:27:20.000000000 +0200 @@ -74,6 +74,9 @@ # else /* systems that support multiple terminals, many monochrome */ {"color", &iflags.wc_color, FALSE, SET_IN_GAME}, /*WC*/ # endif +#ifdef LINEOFSIGHT + {"lineofsight", &iflags.wc_lineofsight, TRUE, SET_IN_GAME}, +#endif {"confirm",&flags.confirm, TRUE, SET_IN_GAME}, #if defined(TERMLIB) && !defined(MAC_GRAPHICS_ENV) {"DECgraphics", &iflags.DECgraphics, FALSE, SET_IN_GAME}, @@ -301,6 +304,10 @@ PL_CSIZ, DISP_IN_GAME }, { "runmode", "display frequency when `running' or `travelling'", sizeof "teleport", SET_IN_GAME }, +#ifdef LINEOFSIGHT_COLOUR + { "los_colour", "colour of the shaded area when loneofsight is on", + sizeof "bright magenta", SET_IN_GAME }, +#endif { "scores", "the parts of the score list you wish to see", 32, SET_IN_GAME }, { "scroll_amount", "amount to scroll map when scroll_margin is reached", @@ -507,6 +514,9 @@ flags.end_top = 3; flags.end_around = 2; iflags.runmode = RUN_LEAP; +#ifdef LINEOFSIGHT_COLOUR + iflags.los_colour = CLR_BLUE; +#endif iflags.msg_history = 20; #ifdef TTY_GRAPHICS iflags.prevmsg_window = 's'; @@ -964,6 +974,13 @@ } } +#ifdef LINEOFSIGHT_COLOUR +static NEARDATA const char *lineofsight_colours[] = { + "black", "red", "green", "brown", "blue", "magenta", "cyan", "grey", + "no,colour", "orange", "bright green", "yellow", "bright blue", + "bright magenta", "bright cyan", "white" +}; +#endif void parseoptions(opts, tinitial, tfrom_file) register char *opts; @@ -974,6 +991,9 @@ boolean negated; int i; const char *fullname; +#ifdef LINEOFSIGHT_COLOUR + int los_colour; +#endif initial = tinitial; from_file = tfrom_file; @@ -1133,6 +1153,26 @@ return; } +#ifdef LINEOFSIGHT_COLOUR + fullname = "los_colour"; + if (match_optname(opts, fullname, 4, TRUE)) { + if (negated) { + iflags.los_colour = CLR_BLUE; + } else if ((op = string_for_opt(opts, FALSE)) != 0) { + if (!strncmpi(op, "gray", strlen(op))) + iflags.los_colour = CLR_GRAY; + else + for (los_colour=0; los_colour < CLR_MAX; los_colour++) { + if (!strncmpi(op, lineofsight_colours[los_colour], strlen(op))) { + iflags.los_colour = los_colour; + break; + } + if (los_colour == CLR_MAX-1) badoption(opts); + } + } + return; + } +#endif fullname = "msghistory"; if (match_optname(opts, fullname, 3, TRUE)) { op = string_for_env_opt(fullname, opts, negated); @@ -2240,6 +2280,11 @@ # endif } #endif +#ifdef LINEOFSIGHT + else if ((boolopt[i].addr) == &iflags.wc_lineofsight) { + need_redraw = TRUE; + } +#endif return; } @@ -2669,6 +2714,28 @@ } destroy_nhwindow(tmpwin); retval = TRUE; +#ifdef LINEOFSIGHT_COLOUR + } else if (!strcmp("los_colour", optname)) { + const char *mode_name; + menu_item *mode_pick = (menu_item *)0; + tmpwin = create_nhwindow(NHW_MENU); + start_menu(tmpwin); + for (i = 0; i < SIZE(lineofsight_colours); i++) { + mode_name = lineofsight_colours[i]; + any.a_int = i + 1; + if (i != NO_COLOR) + add_menu(tmpwin, NO_GLYPH, &any, 0, 0, + ATR_NONE, mode_name, MENU_UNSELECTED); + } + end_menu(tmpwin, "Select colour for LOS shading:"); + if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) { + iflags.los_colour = mode_pick->item.a_int - 1; + free((genericptr_t)mode_pick); + } + destroy_nhwindow(tmpwin); + need_redraw = TRUE; + retval = TRUE; +#endif } #ifdef TTY_GRAPHICS else if (!strcmp("msg_window", optname)) { @@ -3060,6 +3127,10 @@ Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m)); else if (!strcmp(optname, "runmode")) Sprintf(buf, "%s", runmodes[iflags.runmode]); +#ifdef LINEOFSIGHT_COLOUR + else if (!strcmp(optname, "los_colour")) + Sprintf(buf, "%s", lineofsight_colours[iflags.los_colour]); +#endif else if (!strcmp(optname, "scores")) { Sprintf(buf, "%d top/%d around%s", flags.end_top, flags.end_around, flags.end_own ? "/own" : ""); diff -Prub nethack-3.4.3/src/vision.c nethack-3.4.3_LOS/src/vision.c --- nethack-3.4.3/src/vision.c 2003-12-08 01:39:13.000000000 +0200 +++ nethack-3.4.3_LOS/src/vision.c 2004-09-07 18:00:49.000000000 +0200 @@ -130,7 +130,11 @@ } /* Start out with cs0 as our current array */ +#ifdef LINEOFSIGHT + viz_array_old = viz_array = cs_rows0; +#else viz_array = cs_rows0; +#endif viz_rmin = cs_rmin0; viz_rmax = cs_rmax0; @@ -199,7 +203,11 @@ register struct rm *lev; /* Start out with cs0 as our current array */ +#ifdef LINEOFSIGHT + viz_array_old = viz_array = cs_rows0; +#else viz_array = cs_rows0; +#endif viz_rmin = cs_rmin0; viz_rmax = cs_rmax0; @@ -492,7 +500,9 @@ vision_recalc(control) int control; { +#ifndef LINEOFSIGHT char **temp_array; /* points to the old vision array */ +#endif char **next_array; /* points to the new vision array */ char *next_row; /* row pointer for the new array */ char *old_row; /* row pointer for the old array */ @@ -548,11 +558,19 @@ * anything, so we only need update positions we used to be able * to see. */ +#ifdef LINEOFSIGHT + viz_array_old = viz_array; /* set viz_array so newsym() will work */ +#else temp_array = viz_array; /* set viz_array so newsym() will work */ +#endif viz_array = next_array; for (row = 0; row < ROWNO; row++) { +#ifdef LINEOFSIGHT + old_row = viz_array_old[row]; +#else old_row = temp_array[row]; +#endif /* Find the min and max positions on the row. */ start = min(viz_rmin[row], next_rmin[row]); @@ -676,7 +694,11 @@ /* * Make the viz_array the new array so that cansee() will work correctly. */ +#ifdef LINEOFSIGHT + viz_array_old = viz_array; +#else temp_array = viz_array; +#endif viz_array = next_array; /* @@ -698,7 +720,11 @@ colbump[u.ux] = colbump[u.ux+1] = 1; for (row = 0; row < ROWNO; row++) { dy = u.uy - row; dy = sign(dy); +#ifdef LINEOFSIGHT + next_row = next_array[row]; old_row = viz_array_old[row]; +#else next_row = next_array[row]; old_row = temp_array[row]; +#endif /* Find the min and max positions on the row. */ start = min(viz_rmin[row], next_rmin[row]);