]> granicus.if.org Git - nethack/commitdiff
add an mgflags parameter to mapglyph() to alter how it behaves internally
authornhmall <nhmall@nethack.org>
Sun, 17 Nov 2019 03:49:36 +0000 (22:49 -0500)
committernhmall <nhmall@nethack.org>
Sun, 17 Nov 2019 03:49:36 +0000 (22:49 -0500)
avoid a recent save-value,call,restore-value kludge by adding
an mgflags parameter to mapglyph() to control its behavior

 Changes to be committed:
modified:   doc/window.doc
modified:   include/extern.h
modified:   include/hack.h
modified:   src/detect.c
modified:   src/mapglyph.c
modified:   src/pager.c
modified:   sys/amiga/winfuncs.c
modified:   sys/wince/mhmap.c
modified:   win/Qt/qt_win.cpp
modified:   win/Qt4/qt4map.cpp
modified:   win/X11/winmap.c
modified:   win/curses/cursdial.c
modified:   win/curses/cursinvt.c
modified:   win/curses/cursmain.c
modified:   win/gem/wingem.c
modified:   win/tty/wintty.c
modified:   win/win32/mhmap.c
modified:   win/win32/mswproc.c

18 files changed:
doc/window.doc
include/extern.h
include/hack.h
src/detect.c
src/mapglyph.c
src/pager.c
sys/amiga/winfuncs.c
sys/wince/mhmap.c
win/Qt/qt_win.cpp
win/Qt4/qt4map.cpp
win/X11/winmap.c
win/curses/cursdial.c
win/curses/cursinvt.c
win/curses/cursmain.c
win/gem/wingem.c
win/tty/wintty.c
win/win32/mhmap.c
win/win32/mswproc.c

index 0b7cbf52f2e1335564a6ab789124ef3ba936129c..da1790253d2741bb6f87abf57fdb1846537442c9 100644 (file)
@@ -926,7 +926,8 @@ These are not part of the interface. They may be called by your
 window port routines to perform the desired task, instead of duplicating
 the necessary code in each window port.
 
-int mapglyph(int glyph, int *ochar, int *ocolor, unsigned *special, int x, int y)
+int mapglyph(int glyph, int *ochar, int *ocolor, unsigned *special, 
+             int x, int y, unsigned mgflags)
                -- Maps glyph at x,y to NetHack ascii character and color.
                   The return value is an index into the showsyms[] array, in
                   case a port wants to index into its own alternative 
index 0a2fa788de20aff555f396d40ab3f6a9bf176672..4316a6f6254f8be0fb307cdaf50ea738a712c418 100644 (file)
@@ -1209,7 +1209,7 @@ E boolean FDECL(usmellmon, (struct permonst *));
 
 /* ### mapglyph.c ### */
 
-E int FDECL(mapglyph, (int, int *, int *, unsigned *, int, int));
+E int FDECL(mapglyph, (int, int *, int *, unsigned *, int, int, unsigned));
 E char *FDECL(encglyph, (int));
 E char *FDECL(decode_mixed, (char *, const char *));
 E void FDECL(genl_putmixed, (winid, int, const char *));
index 5ba3bb9a0227bd0a62c78089374d030078724fcf..b0e44dde69c6aca45bf33408f3df174d739e5eb5 100644 (file)
@@ -69,6 +69,10 @@ enum dismount_types {
     DISMOUNT_BYCHOICE = 6
 };
 
+/* mgflags for mapglyph() */
+#define MG_FLAG_NORMAL     0x00
+#define MG_FLAG_NOOVERRIDE 0x01
+
 /* Special returns from mapglyph() */
 #define MG_CORPSE  0x01
 #define MG_INVIS   0x02
index 0afaa9373ddeaec99c49af4e7460940f46534c62..8ddf0a0614f8203b9a039a289a67d3d1ed04e53a 100644 (file)
@@ -1934,7 +1934,7 @@ dump_map()
 
             glyph = reveal_terrain_getglyph(x, y, FALSE, u.uswallow,
                                             default_glyph, subset);
-            (void) mapglyph(glyph, &ch, &color, &special, x, y);
+            (void) mapglyph(glyph, &ch, &color, &special, x, y, 0);
             buf[x - 1] = ch;
             if (ch != ' ') {
                 blankrow = FALSE;
index d6a78bc2291d4e542909f683ee6af90a60d4e78d..388e318a0c8cbde7643257146e317a84165de7f8 100644 (file)
@@ -59,10 +59,11 @@ static const int explcolors[] = {
 
 /*ARGSUSED*/
 int
-mapglyph(glyph, ochar, ocolor, ospecial, x, y)
+mapglyph(glyph, ochar, ocolor, ospecial, x, y, mgflags)
 int glyph, *ocolor, x, y;
 int *ochar;
 unsigned *ospecial;
+unsigned mgflags;
 {
     register int offset, idx;
     int color = NO_COLOR;
@@ -223,7 +224,7 @@ unsigned *ospecial;
     }
 
     /* These were requested by a blind player to enhance screen reader use */
-    if (sysopt.accessibility == 1) {
+    if (sysopt.accessibility == 1 && !(mgflags & MG_FLAG_NOOVERRIDE)) {
         int ovidx;
 
         if ((special & MG_PET) != 0) {
@@ -300,7 +301,7 @@ const char *str;
                             gv = (gv * 16) + ((int) (dp - hex) / 2);
                         else
                             break;
-                    so = mapglyph(gv, &ch, &oc, &os, 0, 0);
+                    so = mapglyph(gv, &ch, &oc, &os, 0, 0, 0);
                     *put++ = showsyms[so];
                     /* 'str' is ready for the next loop iteration and '*str'
                        should not be copied at the end of this iteration */
index 647df5150dd884d0322e375d1dd708869809dc71..a7a3b200609345f30db44695fc810bb921e17573 100644 (file)
@@ -826,7 +826,7 @@ struct permonst **for_supplement;
 
         glyph = glyph_at(cc.x, cc.y);
         /* Convert glyph at selected position to a symbol for use below. */
-        (void) mapglyph(glyph, &sym, &oc, &os, cc.x, cc.y);
+        (void) mapglyph(glyph, &sym, &oc, &os, cc.x, cc.y, 0);
 
         Sprintf(prefix, "%s        ", encglyph(glyph));
     } else
@@ -1055,21 +1055,10 @@ struct permonst **for_supplement;
                         if (looked) {
                             int oc = 0, idx = SYM_PET_OVERRIDE + SYM_OFF_X;
                             unsigned os = 0;
-                            nhsym save_override;
-
-                            if (Is_rogue_level(&u.uz)) {
-                                save_override = ov_rogue_syms[idx];
-                                ov_rogue_syms[idx] = 0;
-                            } else {
-                                save_override = ov_primary_syms[idx];
-                                ov_primary_syms[idx] = 0;
-                            }
+
                             /* convert to symbol without override in effect */
-                            (void) mapglyph(glyph, &sym, &oc, &os, cc.x, cc.y);
-                            if (Is_rogue_level(&u.uz))
-                                ov_rogue_syms[idx] = save_override;
-                            else
-                                ov_primary_syms[idx] = save_override;
+                            (void) mapglyph(glyph, &sym, &oc, &os,
+                                                cc.x, cc.y, MG_FLAG_NOOVERRIDE);
                             goto check_monsters;
                         }
                         break;
index 84838ed22c2f34eae355e58e03137a0a73fc3f75..380954681045896e6242e22fa00bf32e49f91f6b 100644 (file)
@@ -1978,7 +1978,7 @@ if(u.uz.dlevel != x){
     } else /* AMII, or Rogue level in either version */
     {
         /* map glyph to character and color */
-        (void) mapglyph(glyph, &och, &color, &special, x, y);
+        (void) mapglyph(glyph, &och, &color, &special, x, y, 0);
         ch = (uchar) och;
         if (WINVERS_AMIV) { /* implies Rogue level here */
             amii_curs(win, x, y);
index 61a2b9f52e6535a0c4a90d7a2a7b9fd312c0f67d..dbdbb5f0b599f8368781b6e39fed55a574f5649f 100644 (file)
@@ -632,7 +632,7 @@ onPaint(HWND hWnd)
 #else
                         /* rely on NetHack core helper routine */
                         (void) mapglyph(data->map[i][j], &mgch, &color,
-                                        &special, i, j);
+                                        &special, i, j, 0);
                         ch = (char) mgch;
                         if (((special & MG_PET) && iflags.hilite_pet)
                             || ((special & MG_DETECT)
index 28a68207ad0e32894c21e7b440bedf5a3cb52cb6..ca2e5934325e261e071373b26c34259fdca62e05 100644 (file)
@@ -1688,7 +1688,7 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
 
                painter.setPen( green );
                /* map glyph to character and color */
-               (void)mapglyph(g, &och, &color, &special, i, j);
+               (void)mapglyph(g, &och, &color, &special, i, j, 0);
                ch = (uchar)och;
 #ifdef TEXTCOLOR
                painter.setPen( nhcolor_to_pen(color) );
index f3425bab2887a6a63f793ba7eee7a3435f5657f6..00598e79bd267353c2220f4b46793ac0debd96e2 100644 (file)
@@ -137,7 +137,7 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
 
                painter.setPen( Qt::green );
                /* map glyph to character and color */
-               mapglyph(g, &ch, &color, &special, i, j);
+               mapglyph(g, &ch, &color, &special, i, j, 0);
                ch = cp437(ch);
 #ifdef TEXTCOLOR
                painter.setPen( nhcolor_to_pen(color) );
@@ -176,7 +176,7 @@ void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
                int color;
                int ch;
                unsigned special;
-               mapglyph(g, &ch, &color, &special, i, j);
+               mapglyph(g, &ch, &color, &special, i, j, 0);
                qt_settings->glyphs().drawCell(painter, g, i, j);
 #ifdef TEXTCOLOR
                if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
@@ -829,7 +829,7 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
 
                painter.setPen( Qt::green );
                /* map glyph to character and color */
-               mapglyph(g, &ch, &color, &special, i, j);
+               mapglyph(g, &ch, &color, &special, i, j, 0);
 #ifdef TEXTCOLOR
                painter.setPen( nhcolor_to_pen(color) );
 #endif
@@ -859,7 +859,7 @@ void NetHackQtMapWindow::paintEvent(QPaintEvent* event)
                int color;
                int ch;
                unsigned special;
-               mapglyph(g, &ch, &color, &special, i, j);
+               mapglyph(g, &ch, &color, &special, i, j, 0);
                qt_settings->glyphs().drawCell(painter, g, i, j);
 #ifdef TEXTCOLOR
                if (((special & MG_PET) != 0) && ::iflags.hilite_pet) {
index 3d5ab1d99a4c743880a551ee75785a65bac59da1..b0eb620f8b811df76e849551faf750263ef27a06 100644 (file)
@@ -107,7 +107,7 @@ int bkglyph UNUSED;
 #endif
 
         /* map glyph to character and color */
-        (void) mapglyph(glyph, &och, &color, &special, x, y);
+        (void) mapglyph(glyph, &och, &color, &special, x, y, 0);
         ch = (uchar) och;
 
         if (special != map_info->tile_map.glyphs[y][x].special) {
index 864b29687d86b6db4deff42e2166283b0496ff26..7858ee618e183be078594405ecb782745d9dee7a 100644 (file)
@@ -1176,7 +1176,7 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num, char *selectors)
         if (menu_item_ptr->glyph != NO_GLYPH && iflags.use_menu_glyphs) {
             unsigned special;  /*notused */
 
-            mapglyph(menu_item_ptr->glyph, &curletter, &color, &special, 0, 0);
+            mapglyph(menu_item_ptr->glyph, &curletter, &color, &special, 0, 0, 0);
             curses_toggle_color_attr(win, color, NONE, ON);
             mvwaddch(win, menu_item_ptr->line_num + 1, start_col, curletter);
             curses_toggle_color_attr(win, color, NONE, OFF);
index c31effe4836f6c1a3e258fef6ecf2f21dfcb7e4c..64fd0197dbb85cec18fde06b3e3d8cf3e472634b 100644 (file)
@@ -125,7 +125,7 @@ curses_add_inv(int y,
         int symbol = 0;
         attr_t glyphclr;
 
-        mapglyph(glyph, &symbol, &color, &dummy, u.ux, u.uy);
+        mapglyph(glyph, &symbol, &color, &dummy, u.ux, u.uy, 0);
         glyphclr = curses_color_attr(color, 0);
         wattron(win, glyphclr);
         wprintw(win, "%c ", symbol);
index 6cf98fcb2599ba1ae060b2e0a87bc39403493c28..447255343d59b628e063e05a9ab62bd64be4a410 100644 (file)
@@ -665,7 +665,7 @@ curses_print_glyph(winid wid, XCHAR_P x, XCHAR_P y, int glyph,
     int attr = -1;
 
     /* map glyph to character and color */
-    mapglyph(glyph, &ch, &color, &special, x, y);
+    mapglyph(glyph, &ch, &color, &special, x, y, 0);
     if ((special & MG_PET) && iflags.hilite_pet) {
         attr = iflags.wc2_petattr;
     }
index 09567cda64321c665e355e18a74699298a9c7515..a83c7760fb18ffe25fae785966df9f95f229f674 100644 (file)
@@ -930,7 +930,7 @@ int glyph;
     unsigned special;
 
     /* map glyph to character and color */
-    (void) mapglyph(glyph, &ch, &color, &special, x, y);
+    (void) mapglyph(glyph, &ch, &color, &special, x, y, 0);
 
 #ifdef TEXTCOLOR
     /* Turn off color if rogue level. */
index c4deaa151d6015ea54127b617cf1efadd7b9fe53..7c95bfc3f46341064aa906c4ba9188013cb0da11 100644 (file)
@@ -3378,7 +3378,7 @@ int bkglyph UNUSED;
     }
 #endif
     /* map glyph to character and color */
-    (void) mapglyph(glyph, &ch, &color, &special, x, y);
+    (void) mapglyph(glyph, &ch, &color, &special, x, y, 0);
 
     print_vt_code2(AVTC_SELECT_WINDOW, window);
 
index 18bca2571439bddddcfacfa02b816372883a01b5..fdd7b3a33f53a441c192b1fba7ebe84282669f8a 100644 (file)
@@ -710,7 +710,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
                     mgch = ' ';
                 } else {
                     (void) mapglyph(data->map[col][row], &mgch, &color,
-                                    &special, col, row);
+                                    &special, col, row, 0);
                 }
                 msg_data->buffer[index] = mgch;
                 index++;
@@ -824,7 +824,7 @@ paintTile(PNHMapWindow data, int i, int j, RECT * rect)
 #ifdef USE_PILEMARK
     /* rely on NetHack core helper routine */
     (void) mapglyph(data->map[i][j], &mgch, &color, &special,
-                    i, j);
+                    i, j, 0);
     if ((glyph != NO_GLYPH) && (special & MG_PET)
 #else
     if ((glyph != NO_GLYPH) && glyph_is_pet(glyph)
@@ -899,7 +899,7 @@ paintGlyph(PNHMapWindow data, int i, int j, RECT * rect)
     #else
         /* rely on NetHack core helper routine */
         (void) mapglyph(data->map[i][j], &mgch, &color,
-                        &special, i, j);
+                        &special, i, j, 0);
         ch = (char) mgch;
         if (((special & MG_PET) && iflags.hilite_pet)
             || ((special & (MG_DETECT | MG_BW_LAVA))
index 38b4b0b29f75163c1fe4e0d6cb855b818a1e8cfb..65a7298915da0cc167d836e62791872e723a7491 100644 (file)
@@ -3091,7 +3091,7 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent, int color,
                 ochar = GOLD_SYM;
             else
                 mapglyph(objnum_to_glyph(GOLD_PIECE),
-                         &ochar, &ocolor, &ospecial, 0, 0);
+                         &ochar, &ocolor, &ospecial, 0, 0, 0);
             buf[0] = ochar;
             p = strchr(text, ':');
             if (p) {