src/chess/rules.h

changeset 153
bad2d6d4b861
parent 147
7e3f2d462bb6
child 154
5336e985bd69
--- a/src/chess/rules.h	Thu Jul 23 11:37:35 2026 +0200
+++ b/src/chess/rules.h	Fri Jul 24 12:42:57 2026 +0200
@@ -145,7 +145,10 @@
 #define mdst(b,m) b[(m)->torow][(m)->tofile]
 #define msrc(b,m) b[(m)->fromrow][(m)->fromfile]
 
+/** Checks if the index is specified and valid. */
 #define isidx(idx) ((uint8_t)(idx) < 8)
+/** Checks if the index is unspecified or valid. */
+#define isidxr(idx) ((idx) == POS_UNSPECIFIED || (uint8_t)(idx) < 8)
 
 #define isfile(file) (file >= 'a' && file <= 'h')
 #define isrow(row) (row >= '1' && row <= '8')
@@ -156,10 +159,6 @@
 #define rowchr(row) (row+'1')
 #define filechr(file) (file+'a')
 
-#define chkidx_from(move) (isidx((move)->fromfile) && isidx((move)->fromrow))
-#define chkidx_to(move) (isidx((move)->tofile) && isidx((move)->torow))
-#define chkidx(move) (chkidx_from(move) && chkidx_to(move))
-
 /* secure versions - use, if index is not checked with isidx() */
 #define fileidx_s(c) (isfile(c)?fileidx(c):POS_UNSPECIFIED)
 #define rowidx_s(c) (isrow(c)?rowidx(c):POS_UNSPECIFIED)

mercurial