diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-11-05 08:40:35 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-11-05 08:40:35 +0000 |
commit | ad5845fd609dfa4c6b3bbdeeb522de5ae229f133 (patch) | |
tree | 05669b075e99a84a14aabdb0cc040ef55097ecd8 /games/boggle | |
parent | 4b70165318fbb2e7c3898c85a1eb9b42ebe12637 (diff) |
ctype functions take unsigned char values.
Fix redrawing of the challenge cube (-c option) when <esc>word is used.
ok mmcc@
Diffstat (limited to 'games/boggle')
-rw-r--r-- | games/boggle/boggle/mach.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/games/boggle/boggle/mach.c b/games/boggle/boggle/mach.c index 3b1424a654c..708dab77195 100644 --- a/games/boggle/boggle/mach.c +++ b/games/boggle/boggle/mach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mach.c,v 1.15 2015/10/24 18:51:40 mmcc Exp $ */ +/* $OpenBSD: mach.c,v 1.16 2015/11/05 08:40:34 guenther Exp $ */ /* $NetBSD: mach.c,v 1.5 1995/04/28 22:28:48 mycroft Exp $ */ /*- @@ -415,6 +415,39 @@ showword(int n) } /* + * Walk the path of a word, refreshing the letters, + * optionally pausing after each + */ +static void +doword(int pause, int r, int c) +{ + extern char *board; + extern int wordpath[]; + int i, row, col; + unsigned char ch; + + for (i = 0; wordpath[i] != -1; i++) { + row = BOARD_LINE + (wordpath[i] / 4) * 2 + 1; + col = BOARD_COL + (wordpath[i] % 4) * 4 + 2; + move(row, col); + ch = board[wordpath[i]]; + if (HISET(ch)) + attron(A_BOLD); + if (SEVENBIT(ch) == 'q') + printw("Qu"); + else + printw("%c", toupper(SEVENBIT(ch))); + if (HISET(ch)) + attroff(A_BOLD); + if (pause) { + move(r, c); + refresh(); + delay(5); + } + } +} + +/* * Get a word from the user and check if it is in either of the two * word lists * If it's found, show the word on the board for a short time and then @@ -427,7 +460,6 @@ findword(void) { int c, col, found, i, r, row; char buf[MAXWORDLEN + 1]; - extern char *board; extern int usedbits, wordpath[]; extern char **mword, **pword; extern int nmwords, npwords; @@ -465,30 +497,10 @@ findword(void) } standout(); - for (i = 0; wordpath[i] != -1; i++) { - row = BOARD_LINE + (wordpath[i] / 4) * 2 + 1; - col = BOARD_COL + (wordpath[i] % 4) * 4 + 2; - move(row, col); - if (board[wordpath[i]] == 'q') - printw("Qu"); - else - printw("%c", toupper(board[wordpath[i]])); - move(r, c); - refresh(); - delay(5); - } - + doword(1, r, c); standend(); + doword(0, r, c); - for (i = 0; wordpath[i] != -1; i++) { - row = BOARD_LINE + (wordpath[i] / 4) * 2 + 1; - col = BOARD_COL + (wordpath[i] % 4) * 4 + 2; - move(row, col); - if (board[wordpath[i]] == 'q') - printw("Qu"); - else - printw("%c", toupper(board[wordpath[i]])); - } move(r, c); clrtoeol(); refresh(); |