src/game.h

changeset 13
faec61c4901f
parent 12
84880c7e1ea6
child 14
970748b9a73b
equal deleted inserted replaced
12:84880c7e1ea6 13:faec61c4901f
76 _Bool capture; 76 _Bool capture;
77 } Move; 77 } Move;
78 78
79 #define POS_UNSPECIFIED UINT8_MAX 79 #define POS_UNSPECIFIED UINT8_MAX
80 80
81 #define isidx(idx) ((uint8_t)idx < 8)
82
81 #define isfile(file) (file >= 'a' && file <= 'h') 83 #define isfile(file) (file >= 'a' && file <= 'h')
82 #define isrow(row) (row >= '1' && row <= '8') 84 #define isrow(row) (row >= '1' && row <= '8')
85
83 #define rowidx(row) (row-'1') 86 #define rowidx(row) (row-'1')
84 #define fileidx(file) (file-'a') 87 #define fileidx(file) (file-'a')
88
89 #define chkidx(move) (isidx(move->fromfile) && isidx(move->fromrow) && \
90 isidx(move->tofile) && isidx(move->torow))
91
92 /* secure versions - use, if index is not checked with isidx() */
93 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED)
94 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED)
85 95
86 void game_start(Settings *settings, int opponent); 96 void game_start(Settings *settings, int opponent);
87 97
88 #ifdef __cplusplus 98 #ifdef __cplusplus
89 } 99 }

mercurial