]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/mapread.c
wwww still working on it! wwww
[16.git] / src / lib / mapread.c
index eee0fd008c46dc3c64f8239815bf1651a0ce2047..d3fdbdaec3bc911af675fb5012b85b94b62224d1 100644 (file)
@@ -9,8 +9,9 @@ static int jsoneq(const char *json, jsmntok_t *tok, const char *s) {
 }
 
 //this function is quite messy ^^; sorry! it is a quick and dirty fix~
-static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *js_sv,*/ map_t *map, int q/*, int *w*/) {
+static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *js_sv,*/ map_t *map, int q) {
        int i, j, k;
+       bitmap_t bp;
        if (count == 0) {
                return 0;
        }
@@ -48,8 +49,16 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *
 //                     printf("\n%.*s[xx[%d|%d]xx]\n", (t+1)->end - (t+1)->start, js+(t+1)->start, &(t+1)->size, (t+1)->size);
                        map->data = malloc(sizeof(byte) * (t+1)->size);
                        map->tiles = malloc(sizeof(tiles_t));
-                       map->tiles->data = malloc(sizeof(bitmap_t));
-                       map->tiles->data->data = malloc((16/**2*/)*16);
+                       //map->tiles->data = malloc(sizeof(bitmap_t));
+                       bp = bitmapLoadPcx("data/ed.pcx");
+                       map->tiles->data = &bp;
+                       //map->tiles->data->data = malloc((16/**2*/)*16);
+                       //map->tiles->data->width = (16/**2*/);\r
+                       //map->tiles->data->height= 16;\r
+                       map->tiles->tileHeight = 16;\r
+                       map->tiles->tileWidth = 16;\r
+                       map->tiles->rows = 1;\r
+                       map->tiles->cols = 1;
                        js_sv="data";//strdup(js+t->start);//, t->end - t->start);
                }
                else
@@ -66,9 +75,9 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *
                j = 0;
                for (i = 0; i < t->size; i++) {
                        //for (k = 0; k < indent; k++) printf("\t");
-                       j += dump(js, t+1+j, count-j, indent+1, map, i/*, w*/);
+                       j += dump(js, t+1+j, count-j, indent+1, map, i);
                        //printf(": ");
-                       j += dump(js, t+1+j, count-j, indent+1, map, i/*, w*/);
+                       j += dump(js, t+1+j, count-j, indent+1, map, i);
                        //printf("\n");
                }
                return j+1;
@@ -78,7 +87,7 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *
                for (i = 0; i < t->size; i++) {
                        //for (k = 0; k < indent-1; k++) printf("\t");
                        //printf("\t-");
-                       j += dump(js, t+1+j, count-j, indent+1, map, i/*, &t->size*/);
+                       j += dump(js, t+1+j, count-j, indent+1, map, i);
                        //printf("==\n");
                }
                return j+1;
@@ -86,7 +95,7 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *
        return 0;
 }
 
-static int loadmap(char *mn, map_t *map/*, word w*/)
+static int loadmap(char *mn, map_t *map)
 {
        int r;
        int eof_expected = 0;