5 struct level *init_level(const char *descstr)
7 const char *str, *line;
8 int i, j, ncols = 0, nrows = 0;
16 if(ncols > 0 && str > line && str - line != ncols) {
17 panic(get_pc(), "init_level: inconsistent ncols (%d != %d)\n", str - line, ncols);
21 while(*++str == '\n');
29 panic(get_pc(), "init_level: width is not pow2 (%d)\n", ncols);
32 lvl = malloc_nf(sizeof *lvl);
34 lvl->xmask = ncols - 1;
36 lvl->cells = calloc_nf(ncols * nrows, sizeof *lvl->cells);
43 for(i=0; i<nrows; i++) {
44 for(j=0; j<ncols; j++) {
48 cell->type = CELL_SOLID;
50 cell->type = CELL_WALK;
53 while(*++str == '\n') str++;
60 void free_level(struct level *lvl)
68 lvl->mobs = lvl->mobs->next;
73 lvl->items = lvl->items->next;