diff --git a/src/gmtool.c b/src/gmtool.c index 3af7814a2..a14c8cb29 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -51,6 +51,7 @@ #include #include +#include #include #include #include @@ -77,6 +78,40 @@ state *current_state = NULL; static WINDOW *hstatus; +static void simplify(const char *rp, char *wp) { + while (*rp) { + if (*rp & 0x80) { + while (*rp & 0x80) ++rp; + *wp++ = '?'; + } + else { + *wp++ = *rp++; + } + } + *wp = 0; +} + +int umvwprintw(WINDOW *win, int y, int x, const char *format, ...) { + char buffer[128]; + int result; + va_list args; + + va_start(args, format); + memset(buffer, 0, sizeof(buffer)); + result = vsnprintf(buffer, sizeof(buffer)-1, format, args); + va_end(args); + + simplify(buffer, buffer); + + return mvwaddstr(win, y, x, buffer); +} + +int umvwaddnstr(WINDOW *w, int y, int x, const char * str, int len) { + char buffer[128]; + simplify(str, buffer); + return mvwaddnstr(w, y, x, buffer, len); +} + static void init_curses(void) { int fg, bg; @@ -354,7 +389,7 @@ static void paint_status(window * wnd, const state * st) terrain = mr->r->terrain->_name; } cnormalize(&st->cursor, &nx, &ny); - mvwprintw(win, 0, 0, "%4d %4d | %.4s | %.20s (%d)", nx, ny, terrain, name, + umvwprintw(win, 0, 0, "%4d %4d | %.4s | %.20s (%d)", nx, ny, terrain, name, uid); wclrtoeol(win); } @@ -377,13 +412,13 @@ static void paint_info_region(window * wnd, const state * st) if (mr && mr->r) { const region *r = mr->r; if (r->land) { - mvwaddnstr(win, line++, 1, (char *)r->land->name, size); + umvwaddnstr(win, line++, 1, (char *)r->land->name, size); } else { - mvwaddnstr(win, line++, 1, r->terrain->_name, size); + umvwaddnstr(win, line++, 1, r->terrain->_name, size); } line++; - mvwprintw(win, line++, 1, "%s, age %d", r->terrain->_name, r->age); + umvwprintw(win, line++, 1, "%s, age %d", r->terrain->_name, r->age); if (r->land) { mvwprintw(win, line++, 1, "$:%6d P:%5d", rmoney(r), rpeasants(r)); mvwprintw(win, line++, 1, "H:%6d %s:%5d", rhorses(r), @@ -398,7 +433,7 @@ static void paint_info_region(window * wnd, const state * st) wattroff(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); for (sh = r->ships; sh && line < maxline; sh = sh->next) { mvwprintw(win, line, 1, "%.4s ", itoa36(sh->no)); - mvwaddnstr(win, line++, 6, (char *)sh->type->_name, size - 5); + umvwaddnstr(win, line++, 6, (char *)sh->type->_name, size - 5); } } if (r->units && (st->info_flags & IFL_FACTIONS)) { @@ -409,7 +444,7 @@ static void paint_info_region(window * wnd, const state * st) for (u = r->units; u && line < maxline; u = u->next) { if (!fval(u->faction, FFL_MARK)) { mvwprintw(win, line, 1, "%.4s ", itoa36(u->faction->no)); - mvwaddnstr(win, line++, 6, (char *)u->faction->name, size - 5); + umvwaddnstr(win, line++, 6, (char *)u->faction->name, size - 5); fset(u->faction, FFL_MARK); } } @@ -424,7 +459,7 @@ static void paint_info_region(window * wnd, const state * st) wattroff(win, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); for (u = r->units; u && line < maxline; u = u->next) { mvwprintw(win, line, 1, "%.4s ", itoa36(u->no)); - mvwaddnstr(win, line++, 6, unit_getname(u), size - 5); + umvwaddnstr(win, line++, 6, unit_getname(u), size - 5); } } }