Rev 160 | Rev 174 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 160 | Rev 171 | ||
|---|---|---|---|
| Line 347... | Line 347... | ||
| 347 | { |
347 | { |
| 348 | the_scene.gui.central_text.disappear_time = current_time + 1.0f; // fade the "thinking" phrase out now (FIXME: ugly) |
348 | the_scene.gui.central_text.disappear_time = current_time + 1.0f; // fade the "thinking" phrase out now (FIXME: ugly) |
| 349 | the_scene.gui.want_spinwheel = false; // stop spinning wheel |
349 | the_scene.gui.want_spinwheel = false; // stop spinning wheel |
| 350 | 350 | ||
| 351 | Board_AppendMove (&the_board, the_board.selected_position[0], the_board.selected_position[1], the_board.hovered_position[0], the_board.hovered_position[1], move.promotion_type, NULL); |
351 | Board_AppendMove (&the_board, the_board.selected_position[0], the_board.selected_position[1], the_board.hovered_position[0], the_board.hovered_position[1], move.promotion_type, NULL); |
| 352 |
|
352 | Player_GetOpposite ()->should_wakeup = true; // do the movement and switch players |
| 353 | 353 | ||
| 354 | // forget the hovered and selected positions |
354 | // forget the hovered and selected positions |
| 355 | Board_SetSelectedAndHovered (&the_board, -1, -1, -1, -1); |
355 | Board_SetSelectedAndHovered (&the_board, -1, -1, -1, -1); |
| 356 | animation_endtime = current_time + ANIMATION_DURATION; // wait for animation time seconds |
356 | animation_endtime = current_time + ANIMATION_DURATION; // wait for animation time seconds |
| 357 | } |
357 | } |
| Line 426... | Line 426... | ||
| 426 | Debug_Log (L"===Got player SWAP notification from interface===\n"); |
426 | Debug_Log (L"===Got player SWAP notification from interface===\n"); |
| 427 | Player_SendBuffer_Add (player, 1000, program->command_go); // tell engine it's now the current player |
427 | Player_SendBuffer_Add (player, 1000, program->command_go); // tell engine it's now the current player |
| 428 | Player_SendBuffer_Add (player, 1000, L"\n"); // since the format string was read from the options, don't forget to end it with a carriage return |
428 | Player_SendBuffer_Add (player, 1000, L"\n"); // since the format string was read from the options, don't forget to end it with a carriage return |
| 429 | } |
429 | } |
| 430 | 430 | ||
| 431 | // have we been notified that the current player just changed ? |
431 | // have we been notified that the current player just changed AND is the animation finished ? |
| 432 | if ( |
432 | if (player->should_wakeup && (animation_endtime < current_time)) |
| 433 | { |
433 | { |
| 434 | Debug_Log (L"===Got player change notification from interface===\n"); |
434 | Debug_Log (L"===Got player change notification from interface===\n"); |
| 435 | 435 | ||
| 436 | // is the current player our color ? (meaning is it engine's turn to play) ? |
436 | // is the current player our color ? (meaning is it engine's turn to play) ? |
| 437 | if (Board_ColorToMove (&the_board) == player->color) |
437 | if (Board_ColorToMove (&the_board) == player->color) |
| Line 453... | Line 453... | ||
| 453 | { |
453 | { |
| 454 | Player_SendBuffer_Add (player, 1000, program->command_go); // so let's start the game |
454 | Player_SendBuffer_Add (player, 1000, program->command_go); // so let's start the game |
| 455 | Player_SendBuffer_Add (player, 1000, L"\n"); // since the format string was read from the options, don't forget to end it with a carriage return |
455 | Player_SendBuffer_Add (player, 1000, L"\n"); // since the format string was read from the options, don't forget to end it with a carriage return |
| 456 | } |
456 | } |
| 457 | } |
457 | } |
| - | 458 | ||
| - | 459 | player->should_wakeup = false; // remember we taken this notification in account |
|
| 458 | } |
460 | } |
| 459 | 461 | ||
| 460 | // END NOTIFICATIONS PROCESSING |
462 | // END NOTIFICATIONS PROCESSING |
| 461 | /////////////////////////////// |
463 | /////////////////////////////// |
| 462 | 464 | ||
| Line 534... | Line 536... | ||
| 534 | if ((player->ascii_recvbuffer[0] == '\r') || (player->ascii_recvbuffer[0] == '%')) |
536 | if ((player->ascii_recvbuffer[0] == '\r') || (player->ascii_recvbuffer[0] == '%')) |
| 535 | continue; // ignore carriage returns and percent signs |
537 | continue; // ignore carriage returns and percent signs |
| 536 | 538 | ||
| 537 | // convert the received character to wide char and append it to recvbuffer |
539 | // convert the received character to wide char and append it to recvbuffer |
| 538 | player->ascii_recvbuffer[1] = 0; // terminate the received string ourselves |
540 | player->ascii_recvbuffer[1] = 0; // terminate the received string ourselves |
| - | 541 | player->recvbuffer[length] = (wchar_t) player->ascii_recvbuffer[0]; |
|
| 539 | ConvertToWideChar |
542 | //ConvertToWideChar (&player->recvbuffer[length], player->recvbuffer_size - length, player->ascii_recvbuffer); |
| 540 | length++; // there's one more character in the player's recv buffer |
543 | length++; // there's one more character in the player's recv buffer |
| - | 544 | player->recvbuffer[length] = 0; // terminate the string ourselves |
|
| 541 | } |
545 | } |
| 542 | 546 | ||
| 543 | // write what we received (if we received anything) |
547 | // write what we received (if we received anything) |
| 544 | if (wcslen (player->recvbuffer) > initial_pos) |
548 | if (wcslen (player->recvbuffer) > initial_pos) |
| 545 | Debug_Log (L"===================================RECEIVED:===================================\n%s\n", &player->recvbuffer[initial_pos]); |
549 | Debug_Log (L"===================================RECEIVED:===================================\n%s\n", &player->recvbuffer[initial_pos]); |