diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-15 16:55:01 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-15 17:21:49 +0100 |
| commit | 99b746a01c11e061c4bd42cf096d27be9507ae21 (patch) | |
| tree | a373a1930a987d5146b8a66abc993ce8a3c4644b /src/core/moves.h | |
| parent | de70dc746f16607e2110f2c6acee8ed8ba2507f8 (diff) | |
| download | nissy-core-99b746a01c11e061c4bd42cf096d27be9507ae21.tar.gz nissy-core-99b746a01c11e061c4bd42cf096d27be9507ae21.zip | |
Fix rare bug, but one more bug to go
Diffstat (limited to '')
| -rw-r--r-- | src/core/moves.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/moves.h b/src/core/moves.h index 037944b..3a1158b 100644 --- a/src/core/moves.h +++ b/src/core/moves.h | |||
| @@ -12,6 +12,7 @@ STATIC cube_t move(cube_t, uint8_t); | |||
| 12 | STATIC cube_t premove(cube_t, uint8_t); | 12 | STATIC cube_t premove(cube_t, uint8_t); |
| 13 | STATIC uint8_t inverse_move(uint8_t); | 13 | STATIC uint8_t inverse_move(uint8_t); |
| 14 | STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *); | 14 | STATIC void invertmoves(uint8_t *, uint8_t, uint8_t *); |
| 15 | STATIC void sortparallel(uint8_t *, uint8_t); | ||
| 15 | 16 | ||
| 16 | STATIC int readmoves(const char *, int, uint8_t *); | 17 | STATIC int readmoves(const char *, int, uint8_t *); |
| 17 | STATIC cube_t applymoves(cube_t, const char *); | 18 | STATIC cube_t applymoves(cube_t, const char *); |
| @@ -229,6 +230,17 @@ invertmoves(uint8_t *moves, uint8_t nmoves, uint8_t *ret) | |||
| 229 | } | 230 | } |
| 230 | #pragma GCC pop_options | 231 | #pragma GCC pop_options |
| 231 | 232 | ||
| 233 | STATIC void | ||
| 234 | sortparallel(uint8_t *moves, uint8_t n) | ||
| 235 | { | ||
| 236 | uint8_t i; | ||
| 237 | |||
| 238 | for (i = 0; i < n-1; i++) | ||
| 239 | if (moveaxis(moves[i]) == moveaxis(moves[i+1]) && | ||
| 240 | movebase(moves[i]) == movebase(moves[i+1]) + 1) | ||
| 241 | SWAP(moves[i], moves[i+1]); | ||
| 242 | } | ||
| 243 | |||
| 232 | STATIC int | 244 | STATIC int |
| 233 | readmoves(const char *buf, int max, uint8_t *ret) | 245 | readmoves(const char *buf, int max, uint8_t *ret) |
| 234 | { | 246 | { |
