Make piece-type testable by bitmask
[gnushogi.git] / gnushogi / init.c
index 679b382..ac870a5 100644 (file)
@@ -87,6 +87,20 @@ const small_short sweep[NO_PIECES] =
     false, true, true, false
 };
 
+const int typeMask[NO_PIECES] =
+{
+    0, T_PAWN,
+#ifndef MINISHOGI
+    T_LANCE, T_KNIGHT,
+#endif
+    T_SILVER, T_GOLD, T_BISHOP, T_ROOK,
+    T_PPAWN,
+#ifndef MINISHOGI
+    T_PLANCE, T_PKNIGHT,
+#endif
+    T_PSILVER, T_PBISHOP, T_PROOK, T_KING
+};
+
 
 #ifdef SAVE_DISTDATA
 short
@@ -485,9 +499,10 @@ NewGame(void)
     compptr = oppptr = 0;
     stage = 0;
     stage2 = -1;    /* the game is not yet started */
-    flag.illegal = flag.mate = flag.post = flag.quit
+    flag.illegal = flag.mate = flag.quit
         = flag.reverse = flag.bothsides = flag.onemove = flag.force
         = false;
+    flag.post &= xboard; /* xboard: do not alter post status on 'new' */
     flag.material = flag.coords = flag.hash = flag.easy
         = flag.beep = flag.rcptr
         = true;