| 82 |
82 |
| 83 for (uint8_t y = 0 ; y < 8 ; y++) { |
83 for (uint8_t y = 0 ; y < 8 ; y++) { |
| 84 for (uint8_t x = 0 ; x < 8 ; x++) { |
84 for (uint8_t x = 0 ; x < 8 ; x++) { |
| 85 uint8_t col = gamestate->board[y][x] & COLOR_MASK; |
85 uint8_t col = gamestate->board[y][x] & COLOR_MASK; |
| 86 uint8_t piece = gamestate->board[y][x] & PIECE_MASK; |
86 uint8_t piece = gamestate->board[y][x] & PIECE_MASK; |
| 87 unsigned char piecestr[5]; |
87 char piecestr[5]; |
| 88 if (piece) { |
88 if (piece) { |
| 89 if (unicode) { |
89 if (unicode) { |
| 90 unsigned char* uc = getpieceunicode(piece); |
90 char* uc = getpieceunicode(piece); |
| 91 strncpy(piecestr, uc, 5); |
91 strncpy(piecestr, uc, 5); |
| 92 } else { |
92 } else { |
| 93 piecestr[0] = piece == PAWN ? 'P' : getpiecechr(piece); |
93 piecestr[0] = piece == PAWN ? 'P' : getpiecechr(piece); |
| 94 piecestr[1] = '\0'; |
94 piecestr[1] = '\0'; |
| 95 } |
95 } |
| 393 fd_set readfds; |
393 fd_set readfds; |
| 394 |
394 |
| 395 FD_ZERO(&readfds); |
395 FD_ZERO(&readfds); |
| 396 FD_SET(opponent, &readfds); |
396 FD_SET(opponent, &readfds); |
| 397 timeout.tv_sec = 0; |
397 timeout.tv_sec = 0; |
| 398 timeout.tv_usec = 1e5; |
398 timeout.tv_usec = 100000; |
| 399 |
399 |
| 400 // TODO: allow commands |
400 // TODO: allow commands while waiting (e.g. resign, offer draw) |
| 401 |
401 |
| 402 int result = select(opponent+1, &readfds, NULL, NULL, &timeout); |
402 int result = select(opponent+1, &readfds, NULL, NULL, &timeout); |
| 403 if (result == -1) { |
403 if (result == -1) { |
| 404 printw("\rCannot perform asynchronous network IO"); |
404 printw("\rCannot perform asynchronous network IO"); |
| 405 cbreak(); getch(); |
405 cbreak(); getch(); |