1.1 --- a/src/game.c Wed Aug 29 17:31:36 2018 +0200 1.2 +++ b/src/game.c Tue Sep 18 15:02:08 2018 +0200 1.3 @@ -71,7 +71,9 @@ 1.4 return 0; 1.5 } 1.6 1.7 -static void draw_board(GameState *gamestate, uint8_t perspective) { 1.8 +static void draw_board(GameState *gamestate, 1.9 + uint8_t perspective, 1.10 + _Bool unicode) { 1.11 char fen[90]; 1.12 compute_fen(fen, gamestate); 1.13 mvaddstr(0, 0, fen); 1.14 @@ -80,11 +82,18 @@ 1.15 for (uint8_t x = 0 ; x < 8 ; x++) { 1.16 uint8_t col = gamestate->board[y][x] & COLOR_MASK; 1.17 uint8_t piece = gamestate->board[y][x] & PIECE_MASK; 1.18 - char piecec; 1.19 + unsigned char piecestr[5]; 1.20 if (piece) { 1.21 - piecec = piece == PAWN ? 'P' : getpiecechr(piece); 1.22 + if (unicode) { 1.23 + unsigned char* uc = getpieceunicode(piece); 1.24 + strncpy(piecestr, uc, 5); 1.25 + } else { 1.26 + piecestr[0] = piece == PAWN ? 'P' : getpiecechr(piece); 1.27 + piecestr[1] = '\0'; 1.28 + } 1.29 } else { 1.30 - piecec = ' '; 1.31 + piecestr[0] = ' '; 1.32 + piecestr[1] = '\0'; 1.33 } 1.34 1.35 _Bool boardblack = (y&1)==(x&1); 1.36 @@ -97,9 +106,7 @@ 1.37 1.38 int cy = perspective == WHITE ? boardy-y : boardy-7+y; 1.39 int cx = perspective == WHITE ? boardx+x*3 : boardx+21-x*3; 1.40 - mvaddch(cy, cx, ' '); 1.41 - mvaddch(cy, cx+1, piecec); 1.42 - mvaddch(cy, cx+2, ' '); 1.43 + mvprintw(cy, cx, " %s ", piecestr); 1.44 } 1.45 } 1.46 1.47 @@ -460,9 +467,11 @@ 1.48 } 1.49 } 1.50 1.51 -static void post_game(GameState *gamestate, GameInfo *gameinfo) { 1.52 +static void post_game(Settings* settings, GameState *gamestate) { 1.53 + GameInfo *gameinfo = &(settings->gameinfo); 1.54 + 1.55 move(0,0); 1.56 - draw_board(gamestate, WHITE); 1.57 + draw_board(gamestate, WHITE, settings->unicode); 1.58 1.59 // TODO: network connection is still open here - think about it! 1.60 1.61 @@ -520,13 +529,13 @@ 1.62 _Bool running; 1.63 do { 1.64 clear(); 1.65 - draw_board(&gamestate, curcol); 1.66 + draw_board(&gamestate, curcol, settings->unicode); 1.67 running = !domove_singlemachine(&gamestate, 1.68 &(settings->gameinfo), curcol); 1.69 curcol = opponent_color(curcol); 1.70 } while (running); 1.71 1.72 - post_game(&gamestate, &(settings->gameinfo)); 1.73 + post_game(settings, &gamestate); 1.74 } 1.75 1.76 void game_continue(Settings *settings, int opponent, GameState *gamestate) { 1.77 @@ -541,7 +550,7 @@ 1.78 _Bool running; 1.79 do { 1.80 clear(); 1.81 - draw_board(gamestate, mycolor); 1.82 + draw_board(gamestate, mycolor, settings->unicode); 1.83 if (myturn) { 1.84 running = !sendmove(gamestate, &(settings->gameinfo), 1.85 opponent, mycolor); 1.86 @@ -551,7 +560,7 @@ 1.87 myturn ^= TRUE; 1.88 } while (running); 1.89 1.90 - post_game(gamestate, &(settings->gameinfo)); 1.91 + post_game(settings, gamestate); 1.92 } 1.93 1.94 void game_start(Settings *settings, int opponent) {