From 7f451cbd0fbcd54f465238e1ce5f43f83721c901 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Wed, 8 Nov 2006 10:57:10 +0000 Subject: Fixed level-map brokenness when using the DEC character set on Linux. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@364 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/initfile.cc | 2 +- crawl-ref/source/view.cc | 46 +++++++++++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index f95685b9f1..ce56d5b0fc 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -1289,7 +1289,7 @@ void parse_option_line(const std::string &str, bool runscript) else if (key.find("cset") == 0) { std::string cset = key.substr(4); - if (cset[0] == '_') + if (!cset.empty() && cset[0] == '_') cset = cset.substr(1); char_set_type cs = NUM_CSET; diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 2184acbf29..38bec13fb2 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -1803,6 +1803,29 @@ static int find_feature( const std::vector& features, return 0; } +#ifdef USE_CURSES +// NOTE: This affects libunix.cc draw state; use this just before setting +// textcolour and drawing a character and call set_altcharset(false) +// after you're done drawing. +// +static int cset_adjust(int raw) +{ + if (Options.char_set != CSET_ASCII) + { + // switch to alternate char set for 8-bit characters: + set_altcharset( raw > 127 ); + + // shift the DEC line drawing set: + if (Options.char_set == CSET_DEC + && raw >= 0xE0) + { + raw &= 0x7F; + } + } + return (raw); +} +#endif + // 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 @@ -1976,12 +1999,20 @@ void show_map( FixedVector &spec_place, bool travel_mode ) if (i == 0 && j > 0) gotoxy( 1, j + 1 ); + int ch = buffer2[bufcount2 - 2]; +#ifdef USE_CURSES + ch = cset_adjust( ch ); +#endif textcolor( buffer2[bufcount2 - 1] ); - putch( buffer2[bufcount2 - 2] ); + putch(ch); #endif } } +#ifdef USE_CURSES + set_altcharset(false); +#endif + #ifdef DOS_TERM puttext(1, 1, 80, 25, buffer2); #endif @@ -3468,18 +3499,7 @@ void viewwindow(bool draw_it, bool do_updates) for (count_x = 0; count_x < X_SIZE; count_x++) { #ifdef USE_CURSES - if (Options.char_set != CSET_ASCII) - { - // switch to alternate char set for 8-bit characters: - set_altcharset( (buffy[bufcount] > 127) ); - - // shift the DEC line drawing set: - if (Options.char_set == CSET_DEC - && buffy[bufcount] >= 0xE0) - { - buffy[bufcount] &= 0x7F; - } - } + buffy[bufcount] = cset_adjust( buffy[bufcount] ); #endif textcolor( buffy[bufcount + 1] ); putch( buffy[bufcount] ); -- cgit v1.2.3-54-g00ecf