static void mkshop(struct level *lev) { struct mkroom *sroom; int styp, j; char *ep = NULL; /* first determine shoptype */ styp = -1; for (sroom = &lev->rooms[0];; sroom++) { if (sroom->hx < 0) return; if (sroom - lev->rooms >= lev->nroom) { pline("lev->rooms not closed by -1?"); return; } if (sroom->rtype != OROOM) continue; if (has_dnstairs(lev, sroom) || has_upstairs(lev, sroom)) continue; if ((wizard && ep && sroom->doorct != 0) || sroom->doorct == 1) break; } if (!sroom->rlit) { int x, y; for (x = sroom->lx - 1; x <= sroom->hx + 1; x++) for (y = sroom->ly - 1; y <= sroom->hy + 1; y++) lev->locations[x][y].lit = 1; sroom->rlit = 1; } if (styp < 0) { /* pick a shop type at random */ j = 1 + mklev_rn2(100, lev); for (styp = 0; (j -= shtypes[styp].prob) > 0; styp++) continue; /* big rooms cannot be wand or book shops, so make them general stores */ if (isbig(sroom) && (shtypes[styp].symb == WAND_CLASS || shtypes[styp].symb == SPBOOK_CLASS)) styp = 0; } sroom->rtype = SHOPBASE + styp; /* set room bits before stocking the shop */ topologize(lev, sroom); /* stock the room with a shopkeeper and artifacts */ stock_room(styp, lev, sroom); }
static void mkshop(void) { struct mkroom *sroom; int i = -1; char *ep = (char *)0; /* (init == lint suppression) */ gottype: for (sroom = &rooms[0];; sroom++) { if (sroom->hx < 0) return; if (sroom - rooms >= nroom) { pline("rooms not closed by -1?"); return; } if (sroom->rtype != OROOM) continue; if (has_dnstairs(sroom) || has_upstairs(sroom)) continue; if ((flags.debug && ep && sroom->doorct != 0) || sroom->doorct == 1) break; } if (!sroom->rlit) { int x, y; for (x = sroom->lx - 1; x <= sroom->hx + 1; x++) for (y = sroom->ly - 1; y <= sroom->hy + 1; y++) levl[x][y].lit = 1; sroom->rlit = 1; } if (i < 0) { /* shoptype not yet determined */ int j; /* pick a shop type at random */ for (j = rnd(100), i = 0; (j -= shtypes[i].prob) > 0; i++) continue; /* big rooms cannot be wand or book shops, * - so make them general stores */ if (isbig(sroom) && (shtypes[i].symb == WAND_CLASS || shtypes[i].symb == SPBOOK_CLASS)) i = 0; } sroom->rtype = SHOPBASE + i; /* set room bits before stocking the shop */ topologize(sroom); /* stock the room with a shopkeeper and artifacts */ stock_room(i, sroom); }
static int get_start(t_env *e) { int ret; char *tmp; if ((ret = (get_next_line(0, &tmp)) > 0)) { if (is_room(tmp)) { e->rooms = ft_lst_push(e->rooms, stock_room(tmp, e, START)); free(tmp); return (1); } } return (ft_putstr_error("Error, Wrong format for starting room.\n")); }
int parse(t_env *e, char *line, int ret) { (void)ret; if (line[0] == '#') { if (line[1] == '#') return (start_end(&(line[2]), e)); else return (1); } else if (ft_isalnum(line[0])) { if (is_room(line)) e->rooms = ft_lst_push(e->rooms, stock_room(line, e, NORMAL)); else if (is_tube(line)) e->tubes = ft_lst_push(e->tubes, stock_tube(line)); else return (0); } else return (0); return (1); }