about summary refs log tree commit diff stats
path: root/source/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/main.c')
-rw-r--r--source/main.c24
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
73inline u32 getPokedexFlag(const u32* data, int i)
74{
75 return (data[i >> 5] >> (i & 31) & 1);
76}
77
73cJSON* getConfig() 78cJSON* 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);