X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=map.c;h=4c548e6fab02aacea66ed51fff6fdc228d490f14;hb=60d176bbc9199cf2b654c1823b341987f47d213b;hp=92a8d923008c333628594d3451d2ee10c8c0d097;hpb=2e8319ed96a300021169b81aacf3c1f7fcb9e1a1;p=dungeon1 diff --git a/map.c b/map.c index 92a8d92..4c548e6 100644 --- a/map.c +++ b/map.c @@ -20,8 +20,8 @@ readmap(char *fname) return NULL; } - for (y=0; ymap[y][x] = fgetc(fp); } if (fgetc(fp) != '\n') { @@ -39,8 +39,8 @@ beautifymap(struct map *map) int x, y; char c; - for (y=0; ymap[y][x]; if (c != '#') { continue; @@ -48,8 +48,8 @@ beautifymap(struct map *map) map->map[y][x] = getnewchar(map, y, x); } } - for (y=0; ymap[y][x]; if (c == '#') { map->map[y][x] = ' '; @@ -94,7 +94,7 @@ getnewchar(struct map *map, int y, int x) l = strchr(WALLCHARS, l) ? '#' : ' '; r = x+1 > W ? '#' : map->map[y][x+1]; r = strchr(WALLCHARS, r) ? '#' : ' '; - a = y-1 < T ? '#' : map->map[y-1][x]; + a = y-1 < 0 ? '#' : map->map[y-1][x]; a = strchr(WALLCHARS, a) ? '#' : ' '; b = y+1 > H ? '#' : map->map[y+1][x]; b = strchr(WALLCHARS, b) ? '#' : ' '; @@ -141,17 +141,17 @@ see(struct map *map, int ypos, int xpos) int y, x; for (y=ypos-SEEDIST; y <= ypos+SEEDIST; y++) { - if (y=H) { + if (y<0 || y>=MAPH) { continue; } for (x=xpos-SEEDIST; x <= xpos+SEEDIST; x++) { - if (x<0 || x>=W) { + if (x<0 || x>=MAPW) { continue; } - mvaddch(y, x, map->map[y][x]); + mvwaddch(w_map, y, x, map->map[y][x]); } } - move(ypos, xpos); + wmove(w_map, ypos, xpos); } void @@ -169,8 +169,8 @@ findchar(struct map *map, char c, int *yret, int *xret) { int y, x; - for (y=0; ymap[y][x] == c) { *yret = y; *xret = x; @@ -185,10 +185,10 @@ showmap(struct map *map) { int x, y; - mvprintw(0, 60, "map: %s", map->name); - for (y=T; ymap[y][x]); + mvwprintw(w_info, 1, 20, "map: %s", map->name); + for (y=0; ymap[y][x]); } } }