12 map = calloc(1, sizeof(struct map));
13 map->name = strdup(fname);
15 snprintf(buf, sizeof(buf), "%s/%s", MAPDIR, fname);
16 if (!(fp = fopen(buf, "r"))) {
17 fprintf(stderr, "error fopen() %s\n", buf);
24 map->map[y][x] = fgetc(fp);
26 if (fgetc(fp) != '\n') {
27 fprintf(stderr, "error file format: no NL at y=%d x=%d\n", y, x);
39 map = calloc(1, sizeof(struct map));
40 map->name = strdup("(BLACK)");
41 memset(map->map, BLANKCHAR, sizeof(map->map));
46 see(struct map *map, int ypos, int xpos)
50 for (y=ypos-SEEDIST; y <= ypos+SEEDIST; y++) {
54 for (x=xpos-SEEDIST; x <= xpos+SEEDIST; x++) {
58 mvaddch(y, x, map->map[y][x]);
65 freemap(struct map *map)
75 findchar(struct map *map, char c, int *yret, int *xret)
81 if (map->map[y][x] == c) {
91 showmap(struct map *map)
95 mvprintw(0, 60, "map: %s", map->name);
98 mvaddch(y, x, map->map[y][x]);