diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-01-29 21:15:40 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-01-29 21:15:40 -0500 |
commit | 719274d56e971b99f06b50b3138282675b62a64d (patch) | |
tree | 33f991be3c636267b62785a172f002bac6627b39 | |
parent | 1157cef04da91242a2a83d83e5e09f0c2cda0060 (diff) | |
download | gen3uploader-719274d56e971b99f06b50b3138282675b62a64d.tar.gz gen3uploader-719274d56e971b99f06b50b3138282675b62a64d.tar.bz2 gen3uploader-719274d56e971b99f06b50b3138282675b62a64d.zip |
-rw-r--r-- | source/main.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/main.c b/source/main.c index 2b4a02a..8b97e12 100644 --- a/source/main.c +++ b/source/main.c | |||
@@ -70,6 +70,11 @@ void fatalError(char *msg) | |||
70 | exit(0); | 70 | exit(0); |
71 | } | 71 | } |
72 | 72 | ||
73 | inline u32 getPokedexFlag(const u32* data, int i) | ||
74 | { | ||
75 | return (data[i >> 5] >> (i & 31) & 1); | ||
76 | } | ||
77 | |||
73 | cJSON* getConfig() | 78 | cJSON* getConfig() |
74 | { | 79 | { |
75 | FILE* fp = fopen("/gen3uploader.cfg", "r"); | 80 | FILE* fp = fopen("/gen3uploader.cfg", "r"); |
@@ -314,23 +319,38 @@ void* extractor(void* userdata) | |||
314 | getMsgArr(pokedexCaught, 13); | 319 | getMsgArr(pokedexCaught, 13); |
315 | 320 | ||
316 | printf("Saw: "); | 321 | printf("Saw: "); |
322 | |||
323 | cJSON* jSeen = cJSON_CreateArray(); | ||
317 | for (int i=0; i<(13*32); i++) | 324 | for (int i=0; i<(13*32); i++) |
318 | { | 325 | { |
319 | if (pokedexSeen[i >> 5] >> (i & 31) & 1) | 326 | if (getPokedexFlag(pokedexSeen, i)) |
320 | { | 327 | { |
321 | printf("#%d, ", i+1); | 328 | printf("#%d, ", i+1); |
329 | |||
330 | if (!getPokedexFlag(pokedexCaught, i)) | ||
331 | { | ||
332 | cJSON_AddItemToArray(jSeen, cJSON_CreateNumber(i + 1)); | ||
333 | } | ||
322 | } | 334 | } |
323 | } | 335 | } |
324 | 336 | ||
337 | cJSON_AddItemToObject(root, "seen", jSeen); | ||
338 | |||
325 | printf("\nCaught: "); | 339 | printf("\nCaught: "); |
340 | |||
341 | cJSON* jCaught = cJSON_CreateArray(); | ||
326 | for (int i=0; i<(13*32); i++) | 342 | for (int i=0; i<(13*32); i++) |
327 | { | 343 | { |
328 | if (pokedexCaught[i >> 5] >> (i & 31) & 1) | 344 | if (getPokedexFlag(pokedexCaught, i)) |
329 | { | 345 | { |
330 | printf("#%d, ", i+1); | 346 | printf("#%d, ", i+1); |
347 | |||
348 | cJSON_AddItemToArray(jCaught, cJSON_CreateNumber(i + 1)); | ||
331 | } | 349 | } |
332 | } | 350 | } |
333 | 351 | ||
352 | cJSON_AddItemToObject(root, "caught", jCaught); | ||
353 | |||
334 | printf("\n"); | 354 | printf("\n"); |
335 | 355 | ||
336 | sendMsg(1); | 356 | sendMsg(1); |