/** * Light or Darken the town */ void cave_illuminate(struct chunk *c, bool daytime) { int y, x, i; /* Apply light or darkness */ for (y = 0; y < c->height; y++) for (x = 0; x < c->width; x++) { int d; bool light = FALSE; feature_type *f_ptr = &f_info[c->squares[y][x].feat]; /* Skip grids with no surrounding floors or stairs */ for (d = 0; d < 9; d++) { /* Extract adjacent (legal) location */ int yy = y + ddy_ddd[d]; int xx = x + ddx_ddd[d]; /* Paranoia */ if (!square_in_bounds_fully(c, yy, xx)) continue; /* Test */ if (square_isfloor(c, yy, xx) || square_isstairs(c, yy, xx)) light = TRUE; } if (!light) continue; /* Only interesting grids at night */ if (daytime || !tf_has(f_ptr->flags, TF_FLOOR)) { sqinfo_on(c->squares[y][x].info, SQUARE_GLOW); sqinfo_on(c->squares[y][x].info, SQUARE_MARK); } else { sqinfo_off(c->squares[y][x].info, SQUARE_GLOW); sqinfo_off(c->squares[y][x].info, SQUARE_MARK); } } /* Light shop doorways */ for (y = 0; y < c->height; y++) { for (x = 0; x < c->width; x++) { if (!square_isshop(c, y, x)) continue; for (i = 0; i < 8; i++) { int yy = y + ddy_ddd[i]; int xx = x + ddx_ddd[i]; sqinfo_on(c->squares[yy][xx].info, SQUARE_GLOW); sqinfo_on(c->squares[yy][xx].info, SQUARE_MARK); } } } /* Fully update the visuals */ player->upkeep->update |= (PU_FORGET_VIEW | PU_UPDATE_VIEW | PU_MONSTERS); /* Redraw map, monster list */ player->upkeep->redraw |= (PR_MAP | PR_MONLIST | PR_ITEMLIST); }
/** * Determine if a given location may be "destroyed" * * Used by destruction spells, and for placing stairs, etc. */ bool square_changeable(struct chunk *c, int y, int x) { object_type *obj; /* Forbid perma-grids */ if (square_isperm(c, y, x) || square_isshop(c, y, x) || square_isstairs(c, y, x)) return (FALSE); /* Check objects */ for (obj = square_object(c, y, x); obj; obj = obj->next) /* Forbid artifact grids */ if (obj->artifact) return (FALSE); /* Accept */ return (TRUE); }
/** * Place the player at a random starting location. * \param c current chunk * \param p the player */ void new_player_spot(struct chunk *c, struct player *p) { int y, x; /* Try to find a good place to put the player */ if (OPT(p, birth_levels_persist) && square_in_bounds_fully(c, p->py, p->px) && square_isstairs(c, p->py, p->px)) { y = p->py; x = p->px; } else if (!find_start(c, &y, &x)) { quit("Failed to place player!"); } /* Create stairs the player came down if allowed and necessary */ if (!OPT(p, birth_connect_stairs)) ; else if (p->upkeep->create_down_stair) square_set_feat(c, y, x, FEAT_MORE); else if (p->upkeep->create_up_stair) square_set_feat(c, y, x, FEAT_LESS); player_place(c, p, y, x); }