| 61 #define fileidx(file) (file-'a') |
61 #define fileidx(file) (file-'a') |
| 62 |
62 |
| 63 #define rowchr(row) (row+'1') |
63 #define rowchr(row) (row+'1') |
| 64 #define filechr(file) (file+'a') |
64 #define filechr(file) (file+'a') |
| 65 |
65 |
| 66 #define chkidx(move) (isidx((move)->fromfile) && isidx((move)->fromrow) && \ |
66 #define chkidx_from(move) (isidx((move)->fromfile) && isidx((move)->fromrow)) |
| 67 isidx((move)->tofile) && isidx((move)->torow)) |
67 #define chkidx_to(move) (isidx((move)->tofile) && isidx((move)->torow)) |
| |
68 #define chkidx(move) (chkidx_from(move) && chkidx_to(move)) |
| 68 |
69 |
| 69 /* secure versions - use, if index is not checked with isidx() */ |
70 /* secure versions - use, if index is not checked with isidx() */ |
| 70 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) |
71 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED) |
| 71 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) |
72 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED) |
| 72 |
73 |
| 204 bool is_pinned(GameState *gamestate, Move *move); |
205 bool is_pinned(GameState *gamestate, Move *move); |
| 205 |
206 |
| 206 /** |
207 /** |
| 207 * Evaluates a move syntactically and stores the move data in the specified |
208 * Evaluates a move syntactically and stores the move data in the specified |
| 208 * object. |
209 * object. |
| |
210 * |
| |
211 * When short algebraic notation is used, the source position is determined by |
| |
212 * the evaluating the allowed moves according to the current game state. |
| |
213 * |
| |
214 * For a purely syntactic check, regardless of whether a piece exists that is |
| |
215 * allowed to move that way, use check_move(). |
| 209 * |
216 * |
| 210 * @param gamestate the current game state |
217 * @param gamestate the current game state |
| 211 * @param mstr the input string to parse |
218 * @param mstr the input string to parse |
| 212 * @param move a pointer to object where the move data shall be stored |
219 * @param move a pointer to object where the move data shall be stored |
| 213 * @param color the color of the player to evaluate the move for |
220 * @param color the color of the player to evaluate the move for |
| 214 * @return status code (see macros in this file for the list of codes) |
221 * @return status code (see macros in this file for the list of codes) |
| 215 */ |
222 */ |
| 216 int eval_move(GameState *gamestate, char *mstr, Move *move, uint8_t color); |
223 int eval_move(GameState *gamestate, char *mstr, Move *move, uint8_t color); |
| 217 |
224 |
| 218 /** |
225 /** |
| |
226 * Syntactically checks a move without verifying that a piece exists that is |
| |
227 * allowed to move that way. |
| |
228 * |
| |
229 * @param mstr the input string to parse |
| |
230 * @param color the color of the player to evaluate the move for |
| |
231 * @return status code (see macros in this file for the list of codes) |
| |
232 */ |
| |
233 int check_move(char *mstr, uint8_t color); |
| |
234 |
| |
235 /** |
| 219 * Validates move by applying chess rules. |
236 * Validates move by applying chess rules. |
| 220 * @param gamestate the current game state |
237 * @param gamestate the current game state |
| 221 * @param move the move to validate |
238 * @param move the move to validate |
| 222 * @return status code (see macros in this file for the list of codes) |
239 * @return status code (see macros in this file for the list of codes) |
| 223 */ |
240 */ |