src/main.c

changeset 176
ef8c39362342
parent 175
e0e061cf4829
equal deleted inserted replaced
175:e0e061cf4829 176:ef8c39362342
617 code = net_recieve_code(opponent); 617 code = net_recieve_code(opponent);
618 /* we could validate the move's check/checkmate flag with 618 /* we could validate the move's check/checkmate flag with
619 * the network response code, but we choose not to do it */ 619 * the network response code, but we choose not to do it */
620 gamestate->checkmate = code == NETCODE_CHECKMATE; 620 gamestate->checkmate = code == NETCODE_CHECKMATE;
621 gamestate->stalemate = code == NETCODE_STALEMATE; 621 gamestate->stalemate = code == NETCODE_STALEMATE;
622 if (code == NETCODE_DECLINE) { 622 if (code == NETCODE_DECLINE_MOVE) {
623 uint32_t reason; 623 uint32_t reason;
624 net_recieve_data(opponent, &reason, sizeof(uint32_t)); 624 net_recieve_data(opponent, &reason, sizeof(uint32_t));
625 reason = ntohl(reason); 625 reason = ntohl(reason);
626 eval_move_failed_msg(reason); 626 eval_move_failed_msg(reason);
627 } else if (code == NETCODE_ACCEPT 627 } else if (code == NETCODE_ACCEPT
800 } else { 800 } else {
801 return 0; 801 return 0;
802 } 802 }
803 } else { 803 } else {
804 uint32_t reason = htonl(code); 804 uint32_t reason = htonl(code);
805 net_send_data(opponent, NETCODE_DECLINE, 805 net_send_data(opponent, NETCODE_DECLINE_MOVE,
806 &reason, sizeof(uint32_t)); 806 &reason, sizeof(uint32_t));
807 } 807 }
808 break; 808 break;
809 } 809 }
810 case NETCODE_ERROR: 810 case NETCODE_ERROR:

mercurial