]> git.draconx.ca Git - rrace.git/blobdiff - src/game.c
Report changed positions from game_do_move.
[rrace.git] / src / game.c
index bdd8f2b3ac103c6e2974fe138c1b23f342a81673..999d52674abd10007334811ec3a8d8562c40d801 100644 (file)
@@ -170,14 +170,14 @@ void game_reset(struct board *board)
        }
 }
 
-int game_do_move(struct board *board, int x, int y)
+uint_fast32_t game_do_move(struct board *board, int x, int y)
 {
        int bx = board->x, by = board->y;
-       uint_least32_t mask, val[4];
+       uint_least32_t ret = 0, mask, val[4];
        int i, shl, shr;
 
        if ((bx != x) == (by != y))
-               return -1;
+               return 0;
 
        if (bx == x) {
                mask = board_mask_v(x, by, y);
@@ -192,11 +192,13 @@ int game_do_move(struct board *board, int x, int y)
        for (i = 0; i < 4; i++) {
                board->game[i] ^= (val[i] = board->game[i] & mask);
                board->game[i] |= val[i] << shl >> shr;
+               ret |= board->game[i] ^ val[i];
        }
 
        board->x = x;
        board->y = y;
-       return 0;
+
+       return mask & ret;
 }
 
 uint_fast32_t game_check_goal(struct board *board)