X-Git-Url: http://git.draconx.ca/gitweb/rrace.git/blobdiff_plain/23aee3322744aa3c65de28c3ebe1509e291b8702..4ba1a1949117408cf81132b4f168a4e7f0a79ac3:/src/game.c diff --git a/src/game.c b/src/game.c index bdd8f2b..2ad3a7e 100644 --- a/src/game.c +++ b/src/game.c @@ -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) @@ -216,14 +218,14 @@ void game_begin(struct board *board) board->time_start = gethrxtime(); } -static int_fast32_t elapsed(struct board *board) +int_fast32_t game_elapsed(struct board *board) { return (gethrxtime() - board->time_start) / 1000000; } int_fast32_t game_finish(struct board *board) { - int_fast32_t t = elapsed(board); + int_fast32_t t = game_elapsed(board); int i; for (i = 0; i < 4; i++) {