]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_map.c
xcroll.exe needs testing on real hardware\!\!\!\! it is working but not flexible...
[16.git] / src / lib / 16_map.c
index 2616778109b6b2559e5ff25271e6c7cd049cf225..2d266df1d667f1b13bcf1dca438544f9849255fc 100755 (executable)
  *\r
  */\r
 \r
+//TODO USE CA AND THIS FILE FORMAT\r
+\r
 #include "src/lib/16_map.h"\r
+#include <malloc.h>\r
 \r
 // Ideally, preprocess json during compilation and read serialized data\r
 \r
@@ -202,9 +205,9 @@ int newloadmap(char *mn, map_t *map) {
        else if(status != tokcount) { printf("Warning: used %d tok\n", status);}\r
        extract_map(js, tok, tokcount, map);\r
 \r
-       free(js);\r
-       free(tok);\r
-       fclose(fh);\r
+       free(js);       //TODO: USE MM_ CA_ AND PM_\r
+       free(tok);      //TODO: USE MM_ CA_ AND PM_\r
+       fclose(fh);     //TODO: USE MM_ CA_ AND PM_\r
 \r
        return 0;\r
 }\r
@@ -213,7 +216,6 @@ int newloadmap(char *mn, map_t *map) {
 //======\r
 \r
 \r
-#define MAPBUFINLM (gvar->ca.camap.mapsegs)\r
 int CA_loadmap(char *mn, map_t *map, global_game_variables_t *gvar)\r
 {\r
        jsmn_parser p;\r
@@ -227,21 +229,23 @@ int CA_loadmap(char *mn, map_t *map, global_game_variables_t *gvar)
        jsmn_init(&p);\r
 \r
        file_s = filesize(fh);\r
-       CA_LoadFile(mn, &MAPBUFINLM, gvar);\r
-       tokcount = jsmn_parse(&p, MAPBUFINLM, file_s, NULL, 0);\r
-       tok = malloc(tokcount*sizeof(jsmntok_t));\r
+       CA_LoadFile(mn, MEMPTRCONV MAPSEGINLM, gvar);\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(&p);\r
-       if((status = jsmn_parse(&p, MAPBUFINLM, file_s, tok, tokcount)) < 0)\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
        }\r
        else if(status != tokcount) { printf("Warning: used %d tok\n", status);}\r
-       extract_map(MAPBUFINLM, tok, tokcount, map);\r
+       extract_map((char const *)MAPSEGINLM, tok, tokcount, map);\r
 \r
-       free(tok);\r
-       fclose(fh);\r
+//     printf("freeing tok\n");\r
+       free(tok);      //TODO: USE MM_ CA_ AND PM_\r
+//     printf("fclose fh\n");\r
+       fclose(fh);     //TODO: USE MM_ CA_ AND PM_\r
 \r
        return 0;\r
 }\r