diff --git a/include/display.h b/include/display.h index 256ba1d36..c17fadae4 100644 --- a/include/display.h +++ b/include/display.h @@ -582,6 +582,8 @@ enum glyph_offsets { : ((expltyp) == EXPL_NOXIOUS) ? GLYPH_EXPLODE_NOXIOUS_OFF \ : GLYPH_EXPLODE_FIERY_OFF)) +/* cmap_walls_to_glyph(): return the glyph number for specified wall + symbol; result varies by dungeon branch */ #define cmap_walls_to_glyph(cmap_idx) \ ((cmap_idx) - S_vwall \ + (In_mines(&u.uz) ? GLYPH_CMAP_MINES_OFF \ @@ -590,6 +592,12 @@ enum glyph_offsets { : In_sokoban(&u.uz) ? GLYPH_CMAP_SOKO_OFF \ : GLYPH_CMAP_MAIN_OFF)) +/* cmap_D0walls_to_glyph(): simpler version of cmap_walls_to_glyph() + which returns the glyph that would be used in the main dungeon, + regardless of hero's current location */ +#define cmap_D0walls_to_glyph(cmap_idx) \ + ((cmap_idx) - S_vwall + GLYPH_CMAP_MAIN_OFF) + #define cmap_a_to_glyph(cmap_idx) \ (((cmap_idx) - S_ndoor) + GLYPH_CMAP_A_OFF) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 889d430f5..e3532b7e0 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3842,7 +3842,8 @@ RESTORE_WARNING_FORMAT_NONLITERAL static void tty_invent_box_glyph_init(struct WinDesc *cw) { - int row, col, glyph; + int row, col; + uchar sym; struct tty_perminvent_cell *cell; for (row = 0; row < cw->maxrow; ++row) @@ -3852,46 +3853,52 @@ tty_invent_box_glyph_init(struct WinDesc *cw) a glyph_info structure rather than just a char */ if (!cell->glyph) continue; - glyph = 0; + /* sym will always get another value; if for some reason it + doesn't, this default is valid for cmap_walls_to_glyph() */ + sym = S_crwall; /* note: for top and bottom, check [border_right] before [border_middle] because they could be the same and if so we want corner rather than tee */ if (row == 0) { if (col == bordercol[border_left]) - glyph = cmap_to_glyph(S_tlcorn); + sym = S_tlcorn; else if (col == bordercol[border_right]) - glyph = cmap_to_glyph(S_trcorn); + sym = S_trcorn; else if (col == bordercol[border_middle]) - glyph = cmap_to_glyph(S_tdwall); + sym = S_tdwall; else /*if ((col > bordercol[border_left] && col < bordercol[border_middle]) || (col > bordercol[border_middle] && col < bordercol[border_right]))*/ - glyph = cmap_to_glyph(S_hwall); + sym = S_hwall; } else if (row == (cw->maxrow - 1)) { if (col == bordercol[border_left]) - glyph = cmap_to_glyph(S_blcorn); + sym = S_blcorn; else if (col == bordercol[border_right]) - glyph = cmap_to_glyph(S_brcorn); + sym = S_brcorn; else if (col == bordercol[border_middle]) - glyph = cmap_to_glyph(S_tuwall); + sym = S_tuwall; else /*if ((col > bordercol[border_left] && col < bordercol[border_middle]) || (col > bordercol[border_middle] && col < bordercol[border_right]))*/ - glyph = cmap_to_glyph(S_hwall); + sym = S_hwall; } else { if (col == bordercol[border_left] || col == bordercol[border_middle] || col == bordercol[border_right]) - glyph = cmap_to_glyph(S_vwall); + sym = S_vwall; } - if (glyph) { + + /* to get here, cell->glyph is 1 and cell->content union has gi */ + { int oldsymidx = cell->content.gi->gm.sym.symidx; #ifdef ENHANCED_SYMBOLS - struct unicode_representation *oldgmu = - cell->content.gi->gm.u; + struct unicode_representation * + oldgmu = cell->content.gi->gm.u; #endif + int glyph = cmap_D0walls_to_glyph(sym); + map_glyphinfo(0, 0, glyph, 0, cell->content.gi); if ( #ifdef ENHANCED_SYMBOLS @@ -3901,10 +3908,6 @@ tty_invent_box_glyph_init(struct WinDesc *cw) cell->refresh = 1; cell->glyph = 1; /* (redundant) */ cell->text = 0; - } else { - /* we can only get here when cell->glyph is 1; - not assigning anything in that situation is a bug */ - impossible("tty invent: expected glyph"); } } done_tty_perm_invent_init = TRUE;