diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-23 15:42:11 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-23 15:42:11 +0200 |
| commit | 9c209afd81e4c51e4fc2717c0eeff4a5d116bcb0 (patch) | |
| tree | e590922e2bd34cb802cef96c1c8d8ba935da4f75 /src/nissy.c | |
| parent | 039267a278bb9e0580e8aebd85ef5f3ed774688f (diff) | |
| download | nissy-core-9c209afd81e4c51e4fc2717c0eeff4a5d116bcb0.tar.gz nissy-core-9c209afd81e4c51e4fc2717c0eeff4a5d116bcb0.zip | |
Added orientation to getcube
Diffstat (limited to '')
| -rw-r--r-- | src/nissy.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nissy.c b/src/nissy.c index f1d4cd1..2dd5a41 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -26,7 +26,8 @@ STATIC long long nissy_gendata_unsafe( | |||
| 26 | #define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } | 26 | #define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } |
| 27 | struct { | 27 | struct { |
| 28 | char *option; | 28 | char *option; |
| 29 | void (*fix)(long long *, long long *, long long *, long long *); | 29 | void (*fix)(long long *, long long *, |
| 30 | long long *, long long *, long long *); | ||
| 30 | } getcube_options[] = { | 31 | } getcube_options[] = { |
| 31 | GETCUBE_OPTIONS("fix", getcube_fix), | 32 | GETCUBE_OPTIONS("fix", getcube_fix), |
| 32 | GETCUBE_OPTIONS(NULL, NULL) | 33 | GETCUBE_OPTIONS(NULL, NULL) |
| @@ -254,12 +255,13 @@ nissy_getcube( | |||
| 254 | long long eo, | 255 | long long eo, |
| 255 | long long cp, | 256 | long long cp, |
| 256 | long long co, | 257 | long long co, |
| 258 | long long orient, | ||
| 257 | const char *options, | 259 | const char *options, |
| 258 | char result[static NISSY_SIZE_CUBE] | 260 | char result[static NISSY_SIZE_CUBE] |
| 259 | ) | 261 | ) |
| 260 | { | 262 | { |
| 261 | int i; | 263 | int i; |
| 262 | cube_t c; | 264 | oriented_cube_t oc; |
| 263 | 265 | ||
| 264 | if (options == NULL) { | 266 | if (options == NULL) { |
| 265 | LOG("[getcube] Error: 'options' argument is NULL\n"); | 267 | LOG("[getcube] Error: 'options' argument is NULL\n"); |
| @@ -268,18 +270,19 @@ nissy_getcube( | |||
| 268 | 270 | ||
| 269 | for (i = 0; getcube_options[i].option != NULL; i++) | 271 | for (i = 0; getcube_options[i].option != NULL; i++) |
| 270 | if (!strcmp(options, getcube_options[i].option)) | 272 | if (!strcmp(options, getcube_options[i].option)) |
| 271 | getcube_options[i].fix(&ep, &eo, &cp, &co); | 273 | getcube_options[i].fix(&ep, &eo, &cp, &co, &orient); |
| 272 | 274 | ||
| 273 | c = getcube(ep, eo, cp, co); | 275 | oc.cube = getcube(ep, eo, cp, co); |
| 276 | oc.orientation = orient; | ||
| 274 | 277 | ||
| 275 | if (!isconsistent((oriented_cube_t){ .cube = c, .orientation = 0 })) { | 278 | if (!isconsistent(oc)) { |
| 276 | LOG("[getcube] Error: could not get cube with ep=%lld, " | 279 | LOG("[getcube] Error: could not get cube with ep=%lld, " |
| 277 | "eo=%lld, cp=%lld, co=%lld.\n", ep, eo, cp, co); | 280 | "eo=%lld, cp=%lld, co=%lld, orient=%lld.\n", |
| 281 | ep, eo, cp, co, orient); | ||
| 278 | return NISSY_ERROR_OPTIONS; | 282 | return NISSY_ERROR_OPTIONS; |
| 279 | } | 283 | } |
| 280 | 284 | ||
| 281 | /* TODO: should support orientation */ | 285 | return write_result(oc, result); |
| 282 | return write_result((oriented_cube_t){.cube = c, .orientation = 0}, result); | ||
| 283 | } | 286 | } |
| 284 | 287 | ||
| 285 | long long | 288 | long long |
