| 348 } |
348 } |
| 349 |
349 |
| 350 /* does piece exist */ |
350 /* does piece exist */ |
| 351 if ((msrc(gamestate->board, move)&(PIECE_MASK|COLOR_MASK)) |
351 if ((msrc(gamestate->board, move)&(PIECE_MASK|COLOR_MASK)) |
| 352 != (move->piece&(PIECE_MASK|COLOR_MASK))) { |
352 != (move->piece&(PIECE_MASK|COLOR_MASK))) { |
| 353 return INVALID_POSITION; |
353 return PIECE_NOT_FOUND; |
| 354 } |
354 } |
| 355 |
355 |
| 356 /* can't capture own pieces */ |
356 /* can't capture own pieces */ |
| 357 if ((mdst(gamestate->board, move) & COLOR_MASK) |
357 if ((mdst(gamestate->board, move) & COLOR_MASK) |
| 358 == (move->piece & COLOR_MASK)) { |
358 == (move->piece & COLOR_MASK)) { |
| 681 uint8_t threatcount; |
681 uint8_t threatcount; |
| 682 |
682 |
| 683 if (get_threats(gamestate, move->torow, move->tofile, color, |
683 if (get_threats(gamestate, move->torow, move->tofile, color, |
| 684 threats, &threatcount)) { |
684 threats, &threatcount)) { |
| 685 |
685 |
| 686 int reason = INVALID_POSITION; |
686 int reason = PIECE_NOT_FOUND; |
| 687 |
687 |
| 688 /* find threats for the specified position */ |
688 /* find threats for the specified position */ |
| 689 for (uint8_t i = 0 ; i < threatcount ; i++) { |
689 for (uint8_t i = 0 ; i < threatcount ; i++) { |
| 690 if (threats[i].piece == move->piece && |
690 if (threats[i].piece == move->piece && |
| 691 (move->fromrow == POS_UNSPECIFIED || |
691 (move->fromrow == POS_UNSPECIFIED || |
| 716 /* found a threat, copy the source location */ |
716 /* found a threat, copy the source location */ |
| 717 move->fromrow = threat->fromrow; |
717 move->fromrow = threat->fromrow; |
| 718 move->fromfile = threat->fromfile; |
718 move->fromfile = threat->fromfile; |
| 719 return VALID_MOVE_SYNTAX; |
719 return VALID_MOVE_SYNTAX; |
| 720 } else { |
720 } else { |
| 721 return INVALID_POSITION; |
721 return PIECE_NOT_FOUND; |
| 722 } |
722 } |
| 723 } |
723 } |
| 724 |
724 |
| 725 static int eval_move1(const char *pstr, Move *move, uint8_t color) { |
725 static int eval_move1(const char *pstr, Move *move, uint8_t color) { |
| 726 memset(move, 0, sizeof(Move)); |
726 memset(move, 0, sizeof(Move)); |