| 669 code = net_recieve_code(opponent); |
669 code = net_recieve_code(opponent); |
| 670 if (code == NETCODE_DECLINE_MOVE) { |
670 if (code == NETCODE_DECLINE_MOVE) { |
| 671 uint8_t reason; |
671 uint8_t reason; |
| 672 net_recieve_data(opponent, &reason, 1); |
672 net_recieve_data(opponent, &reason, 1); |
| 673 eval_move_failed_msg(reason); |
673 eval_move_failed_msg(reason); |
| 674 } else if (code == NETCODE_ACCEPT) { |
674 } else if (code == NETCODE_ACCEPT_MOVE) { |
| 675 format_move(gamestate, &move); |
675 format_move(gamestate, &move); |
| 676 apply_move(gamestate, &move); |
676 apply_move(gamestate, &move); |
| 677 /* switch to waiting, even when the game ended. |
677 /* switch to waiting, even when the game ended. |
| 678 * we want to receive the "game end" code from the |
678 * we want to receive the "game end" code from the |
| 679 * other party. |
679 * other party. |
| 816 Move move = ntoh_move(nmove); |
816 Move move = ntoh_move(nmove); |
| 817 code = validate_move(gamestate, &move); |
817 code = validate_move(gamestate, &move); |
| 818 if (code == VALID_MOVE_SEMANTICS) { |
818 if (code == VALID_MOVE_SEMANTICS) { |
| 819 format_move(gamestate, &move); |
819 format_move(gamestate, &move); |
| 820 apply_move(gamestate, &move); |
820 apply_move(gamestate, &move); |
| 821 net_send_code(opponent, NETCODE_ACCEPT); |
821 net_send_code(opponent, NETCODE_ACCEPT_MOVE); |
| 822 |
822 |
| 823 /* send a code for ending the game, if required */ |
823 /* send a code for ending the game, if required */ |
| 824 bool endgame = true; |
824 bool endgame = true; |
| 825 if (gamestate->checkmate) { |
825 if (gamestate->checkmate) { |
| 826 net_send_code(opponent, NETCODE_CHECKMATE); |
826 net_send_code(opponent, NETCODE_CHECKMATE); |