]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_map.c
JSMN_STATIC is commented out for more memory
[16.git] / src / lib / 16_map.c
index 1799921951aa23dc37ada73ca08ce32c3f84e8dd..33c27d1446fb98d81c362e15519466160c1bd331 100755 (executable)
@@ -1,5 +1,5 @@
 /* Project 16 Source Code~\r
- * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+ * Copyright (C) 2012-2019 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
  *\r
  * This file is part of Project 16.\r
  *\r
@@ -23,6 +23,8 @@
 //TODO USE CA AND THIS FILE FORMAT\r
 \r
 #include "src/lib/16_map.h"\r
+//#define JSMN_STATIC\r
+#include "src/lib/jsmn/jsmn.h"\r
 #include <malloc.h>\r
 \r
 // Ideally, preprocess json during compilation and read serialized data\r
@@ -180,7 +182,7 @@ int newloadmap(char *mn, map_t *map) {
        int status;\r
 \r
        /* Prepare parser */\r
-       jsmn_init((jsmn_parser *)&p);\r
+       jsmn_init(&p);\r
 \r
        file_s = filesize(fh);\r
        js = malloc(file_s);//TODO: USE MM_ CA_ AND PM_\r
@@ -195,11 +197,11 @@ int newloadmap(char *mn, map_t *map) {
                fclose(fh);\r
                return 1;\r
        }\r
-       tokcount = jsmn_parse((jsmn_parser *)&p, js, file_s, NULL, 0);\r
+       tokcount = jsmn_parse(&p, js, file_s, NULL, 0);\r
        tok = malloc(tokcount*sizeof(jsmntok_t));//TODO: USE MM_ CA_ AND PM_\r
        printf("Allocated %d tokens", tokcount);\r
-       jsmn_init((jsmn_parser *)&p);\r
-       if((status = jsmn_parse((jsmn_parser *)&p, js, file_s, tok, tokcount)) < 0)\r
+       jsmn_init(&p);\r
+       if((status = jsmn_parse(&p, js, file_s, tok, tokcount)) < 0)\r
        {\r
                printf("Error: %d\n", status);\r
                return status;\r
@@ -228,15 +230,15 @@ int CA_loadmap(char *mn, map_t *map, global_game_variables_t *gvar)
        int status;\r
 \r
        /* Prepare parser */\r
-       jsmn_init((jsmn_parser *)&p);\r
+       jsmn_init(&p);\r
 \r
        file_s = filesize(fh);\r
        CA_LoadFile(mn, MEMPTRCONV MAPSEGINLM, gvar);\r
-       tokcount = jsmn_parse((jsmn_parser *)&p, (char const *)MAPSEGINLM, file_s, NULL, 0);\r
+       tokcount = jsmn_parse(&p, (char const *)MAPSEGINLM, file_s, NULL, 0);\r
        tok = malloc(tokcount*sizeof(jsmntok_t));//TODO: USE MM_ CA_ AND PM_\r
 //     printf("Allocated %d tokens", tokcount);\r
-       jsmn_init((jsmn_parser *)&p);\r
-       if((status = jsmn_parse((jsmn_parser *)&p, (char const *)MAPSEGINLM, file_s, tok, tokcount)) < 0)\r
+       jsmn_init(&p);\r
+       if((status = jsmn_parse(&p, (char const *)MAPSEGINLM, file_s, tok, tokcount)) < 0)\r
        {\r
                printf("Error: %d\n", status);\r
                return status;\r