shithub: moonfish

Download patch

ref: 75f379d9d670a061180aee2dec724b54718b87f7
parent: 6fdd2222daf7d93d01d89ef733aeaa2d59a5e3c5
author: zamfofex <zamfofex@twdb.moe>
date: Tue Dec 3 09:36:05 EST 2024

make small style modifications

--- a/chess.c
+++ b/chess.c
@@ -205,24 +205,23 @@
 	moves0 = moves;
 	piece = chess->board[from];
 	
-	if (chess->white ? piece / 16 == 1 : piece / 16 == 2) {
+	if (chess->white ? piece / 16 != 1 : piece / 16 != 2) return 0;
+	
+	moonfish_deltas(chess, &moves, from, deltas[piece % 16 - 1], steps[piece % 16 - 1], 1);
+	moonfish_deltas(chess, &moves, from, deltas[piece % 16 - 1], steps[piece % 16 - 1], -1);
+	
+	if (piece % 16 == moonfish_pawn) moonfish_move_pawn(chess, &moves, from);
+	
+	if (piece % 16 == moonfish_king) {
 		
-		moonfish_deltas(chess, &moves, from, deltas[piece % 16 - 1], steps[piece % 16 - 1], 1);
-		moonfish_deltas(chess, &moves, from, deltas[piece % 16 - 1], steps[piece % 16 - 1], -1);
+		moonfish_castle_high(chess, &moves, from);
+		moonfish_castle_low(chess, &moves, from);
 		
-		if (piece % 16 == moonfish_pawn) moonfish_move_pawn(chess, &moves, from);
+		count = moves - moves0;
 		
-		if (piece % 16 == moonfish_king) {
-			
-			moonfish_castle_high(chess, &moves, from);
-			moonfish_castle_low(chess, &moves, from);
-			
-			count = moves - moves0;
-			
-			for (i = 0 ; i < count ; i++) {
-				moves0[i].chess.oo[1 - chess->white] = 0;
-				moves0[i].chess.ooo[1 - chess->white] = 0;
-			}
+		for (i = 0 ; i < count ; i++) {
+			moves0[i].chess.oo[chess->white ^ 1] = 0;
+			moves0[i].chess.ooo[chess->white ^ 1] = 0;
 		}
 	}
 	
--