starts to sortof look like a dungeon if you squint
authorJohn Tsiombikas <nuclear@member.fsf.org>
Thu, 16 Sep 2021 21:18:41 +0000 (00:18 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Thu, 16 Sep 2021 21:18:41 +0000 (00:18 +0300)
src/level.c
src/mesh.c

index ced5b69..383ebb5 100644 (file)
@@ -109,16 +109,16 @@ int load_level(struct level *lvl, const char *fname)
                        node = (struct ts_node*)cell->next;
                        cell->next = 0;
 
-                       if(j <= 0 || cell[-1].type == CELL_SOLID) {
+                       if(i >= lvl->height - 1 || cell[lvl->width].type == CELL_SOLID) {
                                cell->wall[0] = TILE_STRAIGHT;
                        }
-                       if(i <= 0 || cell[-lvl->width].type == CELL_SOLID) {
+                       if(j >= lvl->width - 1 || cell[1].type == CELL_SOLID) {
                                cell->wall[1] = TILE_STRAIGHT;
                        }
-                       if(j >= lvl->width - 1 || cell[1].type == CELL_SOLID) {
+                       if(i <= 0 || cell[-lvl->width].type == CELL_SOLID) {
                                cell->wall[2] = TILE_STRAIGHT;
                        }
-                       if(i >= lvl->height - 1 || cell[lvl->width].type == CELL_SOLID) {
+                       if(j <= 0 || cell[-1].type == CELL_SOLID) {
                                cell->wall[3] = TILE_STRAIGHT;
                        }
 
index dbafcbd..9f208a4 100644 (file)
@@ -302,7 +302,7 @@ static int update_mesh_vbo(struct mesh *m)
 
 static int update_meshgroup_vbo(struct meshgroup *mg)
 {
-       int i;
+       int i, j, idx0 = 0;
        struct vertex *varr, *vptr;
        unsigned int *iarr = 0, *iptr;
        struct mesh *m;
@@ -337,8 +337,10 @@ static int update_meshgroup_vbo(struct meshgroup *mg)
                vptr += m->num_verts;
 
                if(iarr) {
-                       memcpy(iptr, m->iarr, m->num_idx * sizeof *iptr);
-                       iptr += m->num_idx;
+                       for(j=0; j<m->num_idx; j++) {
+                               *iptr++ = m->iarr[j] + idx0;
+                       }
+                       idx0 += m->num_idx;
                }
        }