Angband
Macros | Functions | Variables
gen-cave.c File Reference

Generation of dungeon levels. More...

#include "angband.h"
#include "cave.h"
#include "datafile.h"
#include "game-event.h"
#include "game-world.h"
#include "generate.h"
#include "init.h"
#include "math.h"
#include "mon-make.h"
#include "mon-spell.h"
#include "player-util.h"
#include "store.h"
#include "trap.h"
#include "z-queue.h"
#include "z-type.h"

Macros

#define MAX_CAVERN_TRIES   10
 

Functions

static bool square_is_granite_with_flag (struct chunk *c, int y, int x, int flag)
 Check whether a square has one of the tunnelling helper flags. More...
 
static void build_streamer (struct chunk *c, int feat, int chance)
 Places a streamer of rock through dungeon. More...
 
static void build_tunnel (struct chunk *c, int row1, int col1, int row2, int col2)
 Constructs a tunnel between two points. More...
 
static int next_to_corr (struct chunk *c, int y1, int x1)
 Count the number of corridor grids adjacent to the given grid. More...
 
static bool possible_doorway (struct chunk *c, int y, int x)
 Returns whether a doorway can be built in a space. More...
 
static void try_door (struct chunk *c, int y, int x)
 Places door or trap at y, x position if at least 2 walls found. More...
 
struct chunkclassic_gen (struct player *p)
 Generate a new dungeon level. More...
 
static void lab_get_adjoin (int i, int w, int *a, int *b)
 Given an adjoining wall (a wall which separates two labyrinth cells) set a and b to point to the cell indices which are separated. More...
 
static bool lab_is_tunnel (struct chunk *c, int y, int x)
 Return whether (x, y) is in a tunnel. More...
 
struct chunklabyrinth_chunk (int depth, int h, int w, bool lit, bool soft)
 Build a labyrinth chunk of a given height and width. More...
 
struct chunklabyrinth_gen (struct player *p)
 Build a labyrinth level. More...
 
static void init_cavern (struct chunk *c, int density)
 Initialize the dungeon array, with a random percentage of squares open. More...
 
static int count_adj_walls (struct chunk *c, int y, int x)
 Return the number of walls (0-8) adjacent to this square. More...
 
static void mutate_cavern (struct chunk *c)
 Run a single pass of the cellular automata rules (4,5) on the dungeon. More...
 
static void array_filler (int data[], int value, int size)
 Fill an int[] with a single value. More...
 
static int ignore_point (struct chunk *c, int colors[], int y, int x)
 Determine if we need to worry about coloring a point, or can ignore it. More...
 
static void build_color_point (struct chunk *c, int colors[], int counts[], int y, int x, int color, bool diagonal)
 Color a particular point, and all adjacent points. More...
 
static void build_colors (struct chunk *c, int colors[], int counts[], bool diagonal)
 Create a color for each "NESW contiguous" region of the dungeon. More...
 
static void clear_small_regions (struct chunk *c, int colors[], int counts[])
 Find and delete all small (<9 square) open regions. More...
 
static int count_colors (int counts[], int size)
 Return the number of colors which have active cells. More...
 
static int first_color (int counts[], int size)
 Return the first color which has one or more active cells. More...
 
static void fix_colors (int colors[], int counts[], int from, int to, int size)
 Find all cells of 'fromcolor' and repaint them to 'tocolor'. More...
 
static void join_region (struct chunk *c, int colors[], int counts[], int color, int new_color)
 Create a tunnel connecting a region to one of its nearest neighbors. More...
 
static void join_regions (struct chunk *c, int colors[], int counts[])
 Start connecting regions, stopping when the cave is entirely connected. More...
 
void ensure_connectedness (struct chunk *c)
 Make sure that all the regions of the dungeon are connected. More...
 
struct chunkcavern_chunk (int depth, int h, int w)
 The cavern generator's main function. More...
 
struct chunkcavern_gen (struct player *p)
 Make a cavern level. More...
 
static void build_store (struct chunk *c, int n, int yy, int xx)
 Builds a store at a given pseudo-location. More...
 
static void town_gen_layout (struct chunk *c, struct player *p)
 Generate the town for the first time, and place the player. More...
 
struct chunktown_gen (struct player *p)
 Town logic flow for generation of new town. More...
 
struct chunkmodified_chunk (int depth, int height, int width)
 The main modified generation algorithm. More...
 
struct chunkmodified_gen (struct player *p)
 Generate a new dungeon level. More...
 
struct chunkmoria_chunk (int depth, int height, int width)
 The main moria generation algorithm. More...
 
struct chunkmoria_gen (struct player *p)
 Generate a new dungeon level. More...
 
struct chunkvault_chunk (struct player *p)
 Make a chunk consisting only of a greater vault. More...
 
void connect_caverns (struct chunk *c, struct loc floor[])
 Make sure that all the caverns surrounding the centre are connected. More...
 
struct chunkhard_centre_gen (struct player *p)
 Generate a hard centre level - a greater vault surrounded by caverns. More...
 
struct chunklair_gen (struct player *p)
 Generate a lair level - a regular cave generated with the modified algorithm, connected to a cavern with themed monsters. More...
 
struct chunkgauntlet_gen (struct player *p)
 Generate a gauntlet level - two separate caverns with an unmappable labyrinth between them, and no teleport and only upstairs from the side where the player starts. More...
 

Variables

static int xds [] = {0, 0, 1, -1, -1, -1, 1, 1}
 
static int yds [] = {1, -1, 0, 0, -1, 1, -1, 1}
 

Detailed Description

Generation of dungeon levels.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke Copyright (c) 2013 Erik Osheim, Nick McConnell

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

In this file, we use the SQUARE_WALL flags to the info field in cave->squares, which should only be applied to granite. SQUARE_WALL_SOLID indicates the wall should not be tunnelled; SQUARE_WALL_INNER is the inward-facing wall of a room; SQUARE_WALL_OUTER is the outer wall of a room.

We use SQUARE_WALL_SOLID to prevent multiple corridors from piercing a wall in two adjacent locations, which would be messy, and SQUARE_WALL_OUTER to indicate which walls surround rooms, and may thus be pierced by corridors entering or leaving the room.

Note that a tunnel which attempts to leave a room near the edge of the dungeon in a direction toward that edge will cause "silly" wall piercings, but will have no permanently incorrect effects, as long as the tunnel can eventually exit from another side. And note that the wall may not come back into the room by the hole it left through, so it must bend to the left or right and then optionally re-enter the room (at least 2 grids away). This is not a problem since every room that is large enough to block the passage of tunnels is also large enough to allow the tunnel to pierce the room itself several times.

Note that no two corridors may enter a room through adjacent grids, they must either share an entryway or else use entryways at least two grids apart. This prevents large (or "silly") doorways.

Traditionally, to create rooms in the dungeon, it was divided up into "blocks" of 11x11 grids each, and all rooms were required to occupy a rectangular group of blocks. As long as each room type reserved a sufficient number of blocks, the room building routines would not need to check bounds. Note that in classic generation most of the normal rooms actually only use 23x11 grids, and so reserve 33x11 grids.

Note that a lot of the original motivation for the block system was the fact that there was only one size of map available, 22x66 grids, and the dungeon level was divided up into nine of these in three rows of three. Now that the map can be resized and enlarged, and dungeon levels themselves can be different sizes, much of this original motivation has gone. Blocks can still be used, but different cave profiles can set their own block sizes. The classic generation method still uses the traditional blocks; the main motivation for using blocks now is for the aesthetic effect of placing rooms on a grid.

Macro Definition Documentation

#define MAX_CAVERN_TRIES   10

Referenced by cavern_chunk().

Function Documentation

static void array_filler ( int  data[],
int  value,
int  size 
)
static

Fill an int[] with a single value.

Parameters
datais the array
valueis what it's being filled with
sizeis the array length

References i, and size.

Referenced by build_color_point(), clear_small_regions(), and join_region().

static void build_color_point ( struct chunk c,
int  colors[],
int  counts[],
int  y,
int  x,
int  color,
bool  diagonal 
)
static

Color a particular point, and all adjacent points.

Parameters
cis the current chunk
colorsis the array of current point colors
countsis the array of current color counts
yare the co-ordinates
xare the co-ordinates
coloris the color we are coloring
diagonalcontrols whether we can progress diagonally

References array_filler(), h, chunk::height, i, i_to_yx(), ignore_point(), mem_free(), mem_zalloc(), q_free(), q_len(), q_new(), q_pop_int, q_push_int, size, w, chunk::width, xds, yds, and yx_to_i().

Referenced by build_colors().

static void build_colors ( struct chunk c,
int  colors[],
int  counts[],
bool  diagonal 
)
static

Create a color for each "NESW contiguous" region of the dungeon.

Parameters
cis the current chunk
colorsis the array of current point colors
countsis the array of current color counts
diagonalcontrols whether we can progress diagonally

References build_color_point(), h, chunk::height, ignore_point(), w, and chunk::width.

Referenced by cavern_chunk(), connect_caverns(), and ensure_connectedness().

static void build_store ( struct chunk c,
int  n,
int  yy,
int  xx 
)
static

Builds a store at a given pseudo-location.

Parameters
cis the current chunk
nis which shop it is
yythe row and column of this store in the store layout
xxthe row and column of this store in the store layout

Currently, there is a main street horizontally through the middle of town, and all the shops face it (e.g. the shops on the north side face south).

References f_info, angband_constants::f_max, feat_is_shop(), FEAT_PERM, fill_rectangle(), rand_range(), randint0, square_set_feat(), and z_info.

Referenced by town_gen_layout().

static void build_streamer ( struct chunk c,
int  feat,
int  chance 
)
static

Places a streamer of rock through dungeon.

Parameters
cis the current chunk
featis the base feature (FEAT_MAGMA or FEAT_QUARTZ)
chanceis the number of regular features per one gold

Note that their are actually six different terrain features used to represent streamers. Three each of magma and quartz, one for basic vein, one with hidden gold, and one with known gold. The hidden gold types are currently unused.

References ddd, ddx, ddy, streamer_profile::den, dun, find_nearby_grid(), chunk::height, i, one_in_, dun_data::profile, rand_spread, randint0, streamer_profile::rng, square_in_bounds(), square_isrock(), square_set_feat(), square_upgrade_mineral(), cave_profile::str, monster::tx, monster::ty, and chunk::width.

Referenced by classic_gen(), lair_gen(), modified_gen(), moria_gen(), and town_gen_layout().

static void build_tunnel ( struct chunk c,
int  row1,
int  col1,
int  row2,
int  col2 
)
static

Constructs a tunnel between two points.

Parameters
cis the current chunk
row1are the co-ordinates of the first point
col1are the co-ordinates of the first point
row2are the co-ordinates of the second point
col2are the co-ordinates of the second point

This function must be called BEFORE any streamers are created, since we use granite with the special SQUARE_WALL flags to keep track of legal places for corridors to pierce rooms.

We queue the tunnel grids to prevent door creation along a corridor which intersects itself.

We queue the wall piercing grids to prevent a corridor from leaving a room and then coming back in through the same entrance.

We pierce grids which are outer walls of rooms, and when we do so, we change all adjacent outer walls of rooms into solid walls so that no two corridors may use adjacent grids for exits.

The solid wall check prevents corridors from chopping the corners of rooms off, as well as silly door placement, and excessively wide room entrances.

References tunnel_profile::chg, tunnel_profile::con, correct_dir(), dun_data::door, dun_data::door_n, dun, FEAT_FLOOR, i, angband_constants::level_door_max, tunnel_profile::pen, place_random_door(), dun_data::profile, rand_dir(), randint0, tunnel_profile::rnd, row1, set_marked_granite(), square_in_bounds(), square_is_granite_with_flag(), square_isgranite(), square_isperm(), square_isroom(), square_set_feat(), cave_profile::tun, dun_data::tunn, angband_constants::tunn_grid_max, dun_data::tunn_n, dun_data::wall, dun_data::wall_n, angband_constants::wall_pierce_max, loc::x, loc::y, and z_info.

Referenced by classic_gen(), modified_chunk(), and moria_chunk().

struct chunk* cavern_chunk ( int  depth,
int  h,
int  w 
)

The cavern generator's main function.

Parameters
depththe chunk's native depth
hthe chunk's dimensions
wthe chunk's dimensions
Returns
a pointer to the generated chunk

References build_colors(), cave_free(), cave_new(), clear_small_regions(), chunk::depth, chunk::feat_count, FEAT_FLOOR, i, init_cavern(), join_regions(), MAX_CAVERN_TRIES, mem_free(), mem_zalloc(), mutate_cavern(), NULL, rand_range(), ROOM_LOG, size, and w.

Referenced by cavern_gen(), gauntlet_gen(), hard_centre_gen(), and lair_gen().

struct chunk* cavern_gen ( struct player p)
struct chunk* classic_gen ( struct player p)
static void clear_small_regions ( struct chunk c,
int  colors[],
int  counts[] 
)
static

Find and delete all small (<9 square) open regions.

Parameters
cis the current chunk
colorsis the array of current point colors
countsis the array of current color counts

References array_filler(), h, chunk::height, i, mem_free(), mem_zalloc(), set_marked_granite(), size, w, chunk::width, and yx_to_i().

Referenced by cavern_chunk().

void connect_caverns ( struct chunk c,
struct loc  floor[] 
)

Make sure that all the caverns surrounding the centre are connected.

Parameters
cis the entire current chunk (containing the caverns)
flooris an array of sample floor grids, one from each cavern in the order left, upper, lower, right

References build_colors(), chunk::height, i, join_region(), mem_free(), mem_zalloc(), size, chunk::width, and yx_to_i().

Referenced by hard_centre_gen().

static int count_adj_walls ( struct chunk c,
int  y,
int  x 
)
static

Return the number of walls (0-8) adjacent to this square.

Parameters
cis the current chunk
yare the co-ordinates
xare the co-ordinates

References square_isfloor().

Referenced by mutate_cavern().

static int count_colors ( int  counts[],
int  size 
)
static

Return the number of colors which have active cells.

Parameters
countsis the array of current color counts
sizeis the total area

References i, and num.

Referenced by join_regions().

void ensure_connectedness ( struct chunk c)

Make sure that all the regions of the dungeon are connected.

Parameters
cis the current chunk

This function colors each connected region of the dungeon, then uses that information to join them into one conected region.

References build_colors(), chunk::height, join_regions(), mem_free(), mem_zalloc(), size, and chunk::width.

Referenced by classic_gen(), gauntlet_gen(), hard_centre_gen(), lair_gen(), modified_chunk(), and moria_chunk().

static int first_color ( int  counts[],
int  size 
)
static

Return the first color which has one or more active cells.

Parameters
countsis the array of current color counts
sizeis the total area

References i.

Referenced by join_regions().

static void fix_colors ( int  colors[],
int  counts[],
int  from,
int  to,
int  size 
)
static

Find all cells of 'fromcolor' and repaint them to 'tocolor'.

Parameters
colorsis the array of current point colors
countsis the array of current color counts
fromis the color to change
tois the color to change to
sizeis the total area

References i, and size.

Referenced by join_region().

struct chunk* gauntlet_gen ( struct player p)
struct chunk* hard_centre_gen ( struct player p)
static int ignore_point ( struct chunk c,
int  colors[],
int  y,
int  x 
)
static

Determine if we need to worry about coloring a point, or can ignore it.

Parameters
cis the current chunk
colorsis the array of current point colors
yare the co-ordinates
xare the co-ordinates

References h, chunk::height, square_isdoor(), square_ispassable(), w, chunk::width, and yx_to_i().

Referenced by build_color_point(), and build_colors().

static void init_cavern ( struct chunk c,
int  density 
)
static

Initialize the dungeon array, with a random percentage of squares open.

Parameters
cis the current chunk
densityis the percentage of floors we are aiming for

References FEAT_FLOOR, FEAT_GRANITE, fill_rectangle(), h, chunk::height, randint1, size, square_isrock(), square_set_feat(), w, and chunk::width.

Referenced by cavern_chunk().

static void join_region ( struct chunk c,
int  colors[],
int  counts[],
int  color,
int  new_color 
)
static

Create a tunnel connecting a region to one of its nearest neighbors.

Set new_color = -1 for any neighbour, the required color for a specific one

Parameters
cis the current chunk
colorsis the array of current point colors
countsis the array of current color counts
coloris the color of the region we want to connect
new_coloris the color of the region we want to connect to (if used)

References array_filler(), FEAT_FLOOR, fix_colors(), h, chunk::height, i, i_to_yx(), mem_free(), mem_zalloc(), q_free(), q_len(), q_new(), q_pop_int, q_push_int, size, square_isperm(), square_isvault(), square_set_feat(), w, chunk::width, xds, yds, and yx_to_i().

Referenced by connect_caverns(), and join_regions().

static void join_regions ( struct chunk c,
int  colors[],
int  counts[] 
)
static

Start connecting regions, stopping when the cave is entirely connected.

Parameters
cis the current chunk
colorsis the array of current point colors
countsis the array of current color counts

References count_colors(), first_color(), h, chunk::height, join_region(), num, size, w, and chunk::width.

Referenced by cavern_chunk(), and ensure_connectedness().

static void lab_get_adjoin ( int  i,
int  w,
int a,
int b 
)
static

Given an adjoining wall (a wall which separates two labyrinth cells) set a and b to point to the cell indices which are separated.

Used by labyrinth_gen().

Parameters
iis the wall index
wis the width of the labyrinth
aare the two cell indices
bare the two cell indices

References i_to_yx(), and yx_to_i().

Referenced by labyrinth_chunk().

static bool lab_is_tunnel ( struct chunk c,
int  y,
int  x 
)
static

Return whether (x, y) is in a tunnel.

Parameters
cis the current chunk
yare the co-ordinates
xare the co-ordinates

For our purposes a tunnel is a horizontal or vertical path, not an intersection. Thus, we want the squares on either side to walls in one case (e.g. up/down) and open in the other case (e.g. left/right). We don't want a square that represents an intersection point.

The high-level idea is that these are squares which can't be avoided (by walking diagonally around them).

References square_isopen().

Referenced by labyrinth_chunk().

struct chunk* labyrinth_chunk ( int  depth,
int  h,
int  w,
bool  lit,
bool  soft 
)

Build a labyrinth chunk of a given height and width.

Parameters
depthis the native depth
hare the dimensions of the chunk
ware the dimensions of the chunk
litis whether the labyrinth is lit
softis true if we use regular walls, false if permanent walls
Returns
a pointer to the generated chunk

References alloc_objects(), cave_new(), chunk::depth, draw_rectangle(), FEAT_FLOOR, FEAT_GRANITE, FEAT_PERM, fill_rectangle(), find_empty(), h, i, i_to_yx(), square::info, lab_get_adjoin(), lab_is_tunnel(), mem_free(), mem_zalloc(), place_closed_door(), Rand_normal(), SET_BOTH, shuffle(), sqinfo_on, square_set_feat(), chunk::squares, TYP_GOOD, TYP_GREAT, w, and yx_to_i().

Referenced by gauntlet_gen(), and labyrinth_gen().

struct chunk* labyrinth_gen ( struct player p)

Build a labyrinth level.

Parameters
pis the player Note that if the function returns false, a level wasn't generated. Labyrinths use the dungeon level's number to determine whether to generate themselves (which means certain level numbers are more likely to generate labyrinths than others).

References alloc_objects(), alloc_stairs(), cave_find(), chunk::depth, player::depth, angband_constants::dungeon_hgt, angband_constants::dungeon_wid, FEAT_LESS, FEAT_MORE, h, i, labyrinth_chunk(), angband_constants::level_monster_min, MAX, MIN, new_player_spot(), NULL, pick_and_place_distant_monster(), Rand_normal(), randint0, randint1, SET_BOTH, SET_CORR, square_isdownstairs(), square_isupstairs(), TYP_GOLD, TYP_GOOD, TYP_OBJECT, TYP_RUBBLE, TYP_TRAP, w, wiz_light(), and z_info.

struct chunk* lair_gen ( struct player p)
struct chunk* modified_chunk ( int  depth,
int  height,
int  width 
)
struct chunk* modified_gen ( struct player p)

Generate a new dungeon level.

Parameters
pis the player
Returns
a pointer to the generated chunk

This is sample code to illustrate some of the new dungeon generation methods; I think it actually produces quite nice levels. New stuff:

  • different sized levels
  • independence from block size: the block size can be set to any number from 1 (no blocks) to about 15; beyond that it struggles to generate enough floor space
  • the find_space function, called from the room builder functions, allows the room to find space for itself rather than the generation algorithm allocating it; this helps because the room knows better what size it is
  • a count is now kept of grids of the various terrains, allowing dungeon generation to terminate when enough floor is generated
  • there are three new room types - huge rooms, rooms of chambers and interesting rooms - as well as many new vaults
  • there is the ability to place specific monsters and objects in vaults and interesting rooms, as well as to make general monster restrictions in areas or the whole dungeon

References alloc_objects(), alloc_stairs(), dun_data::block_hgt, cave_profile::block_size, dun_data::block_wid, angband_constants::both_gold_av, angband_constants::both_item_av, build_streamer(), chunk::depth, player::depth, draw_rectangle(), dun, angband_constants::dungeon_hgt, angband_constants::dungeon_wid, FEAT_LESS, FEAT_MAGMA, FEAT_MORE, FEAT_PERM, FEAT_QUARTZ, chunk::height, i, is_quest(), angband_constants::level_monster_min, streamer_profile::mag, MAX, streamer_profile::mc, MIN, modified_chunk(), mon_restrict(), new_player_spot(), NULL, pick_and_place_distant_monster(), dun_data::profile, streamer_profile::qc, streamer_profile::qua, Rand_normal(), rand_range(), randint0, randint1, angband_constants::room_item_av, SET_BOTH, SET_CORR, SET_ROOM, cave_profile::str, TYP_GOLD, TYP_OBJECT, TYP_RUBBLE, TYP_TRAP, chunk::width, and z_info.

struct chunk* moria_chunk ( int  depth,
int  height,
int  width 
)
struct chunk* moria_gen ( struct player p)

Generate a new dungeon level.

Parameters
pis the player
Returns
a pointer to the generated chunk

This produces Oangband-style moria levels.

Most rooms on these levels are large, ragged-edged and roughly oval-shaped.

Monsters are mostly "Moria dwellers" - orcs, ogres, trolls and giants.

Apart from the room and monster changes, generation is similar to modified levels. A good way of selecting these instead of modified (similar to labyrinth levels are selected) would be if ((c->depth >= 10) && (c->depth < 40) && one_in_(40))

References alloc_objects(), alloc_stairs(), dun_data::block_hgt, cave_profile::block_size, dun_data::block_wid, angband_constants::both_gold_av, angband_constants::both_item_av, build_streamer(), chunk::depth, player::depth, draw_rectangle(), dun, angband_constants::dungeon_hgt, angband_constants::dungeon_wid, FEAT_LESS, FEAT_MAGMA, FEAT_MORE, FEAT_PERM, FEAT_QUARTZ, chunk::height, i, is_quest(), angband_constants::level_monster_min, streamer_profile::mag, MAX, streamer_profile::mc, MIN, mon_restrict(), moria_chunk(), new_player_spot(), NULL, pick_and_place_distant_monster(), dun_data::profile, streamer_profile::qc, streamer_profile::qua, Rand_normal(), rand_range(), randint0, randint1, angband_constants::room_item_av, SET_BOTH, SET_CORR, SET_ROOM, cave_profile::str, TYP_GOLD, TYP_OBJECT, TYP_RUBBLE, TYP_TRAP, void(), chunk::width, and z_info.

static void mutate_cavern ( struct chunk c)
static

Run a single pass of the cellular automata rules (4,5) on the dungeon.

Parameters
cis the chunk being mutated

References count_adj_walls(), square::feat, FEAT_FLOOR, FEAT_GRANITE, h, chunk::height, mem_free(), mem_zalloc(), set_marked_granite(), square_set_feat(), chunk::squares, w, and chunk::width.

Referenced by cavern_chunk().

static int next_to_corr ( struct chunk c,
int  y1,
int  x1 
)
static

Count the number of corridor grids adjacent to the given grid.

This routine currently only counts actual "empty floor" grids which are not in rooms.

Parameters
cis the current chunk
y1are the co-ordinates
x1are the co-ordinates

TODO: count stairs, open doors, closed doors?

References ddx_ddd, ddy_ddd, i, square_in_bounds(), square_isfloor(), and square_isroom().

Referenced by possible_doorway().

static bool possible_doorway ( struct chunk c,
int  y,
int  x 
)
static

Returns whether a doorway can be built in a space.

Parameters
cis the current chunk
yare the co-ordinates
xare the co-ordinates

To have a doorway, a space must be adjacent to at least two corridors and be between two walls.

References next_to_corr(), square_in_bounds(), and square_isstrongwall().

Referenced by try_door().

static bool square_is_granite_with_flag ( struct chunk c,
int  y,
int  x,
int  flag 
)
static

Check whether a square has one of the tunnelling helper flags.

Parameters
cis the current chunk
yare the co-ordinates
xare the co-ordinates
flagis the relevant flag

References square::feat, FEAT_GRANITE, square::info, sqinfo_has, and chunk::squares.

Referenced by build_tunnel().

struct chunk* town_gen ( struct player p)

Town logic flow for generation of new town.

Parameters
pis the player
Returns
a pointer to the generated chunk We start with a fully wiped cave of normal floors. This function does NOT do anything about the owners of the stores, nor the contents thereof. It only handles the physical layout.

References cave_illuminate(), cave_new(), chunk_copy(), chunk_find_name(), chunk::depth, player::depth, square::feat, FEAT_MORE, chunk::height, i, is_daytime(), pick_and_place_distant_monster(), player_place(), quit_fmt(), chunk::squares, town_gen_layout(), angband_constants::town_hgt, angband_constants::town_monsters_day, angband_constants::town_monsters_night, angband_constants::town_wid, chunk::width, and z_info.

static void town_gen_layout ( struct chunk c,
struct player p 
)
static
static void try_door ( struct chunk c,
int  y,
int  x 
)
static

Places door or trap at y, x position if at least 2 walls found.

Parameters
cis the current chunk
yare the co-ordinates
xare the co-ordinates

References chunk::depth, dun, tunnel_profile::jct, place_random_door(), place_trap(), possible_doorway(), dun_data::profile, randint0, square_in_bounds(), square_isdoor(), square_isplayertrap(), square_isroom(), square_isstrongwall(), and cave_profile::tun.

Referenced by classic_gen(), modified_chunk(), and moria_chunk().

struct chunk* vault_chunk ( struct player p)

Make a chunk consisting only of a greater vault.

Parameters
pis the player
Returns
a pointer to the generated chunk

References build_vault(), cave_new(), chunk::depth, player::depth, vault::hgt, one_in_, random_vault(), and vault::wid.

Referenced by hard_centre_gen().

Variable Documentation

int xds[] = {0, 0, 1, -1, -1, -1, 1, 1}
static

Referenced by build_color_point(), and join_region().

int yds[] = {1, -1, 0, 0, -1, 1, -1, 1}
static

Referenced by build_color_point(), and join_region().