Angband
Macros | Functions | Variables
generate.c File Reference

Dungeon generation. More...

#include "angband.h"
#include "cave.h"
#include "datafile.h"
#include "game-event.h"
#include "game-input.h"
#include "game-world.h"
#include "generate.h"
#include "init.h"
#include "math.h"
#include "mon-make.h"
#include "mon-spell.h"
#include "monster.h"
#include "obj-tval.h"
#include "obj-util.h"
#include "object.h"
#include "player-history.h"
#include "trap.h"
#include "z-queue.h"
#include "z-type.h"
#include "list-dun-profiles.h"
#include "list-rooms.h"

Macros

#define DUN(a, b)   { a, b##_gen },
 
#define ROOM(a, b, c, d)   { a, b, c, build_##d },
 

Functions

static enum parser_error parse_profile_name (struct parser *p)
 Parsing functions for dungeon_profile.txt. More...
 
static enum parser_error parse_profile_params (struct parser *p)
 
static enum parser_error parse_profile_tunnel (struct parser *p)
 
static enum parser_error parse_profile_streamer (struct parser *p)
 
static enum parser_error parse_profile_room (struct parser *p)
 
static enum parser_error parse_profile_cutoff (struct parser *p)
 
static struct parserinit_parse_profile (void)
 
static errr run_parse_profile (struct parser *p)
 
static errr finish_parse_profile (struct parser *p)
 
static void cleanup_profile (void)
 
static enum parser_error parse_room_name (struct parser *p)
 Parsing functions for room_template.txt. More...
 
static enum parser_error parse_room_type (struct parser *p)
 
static enum parser_error parse_room_rating (struct parser *p)
 
static enum parser_error parse_room_height (struct parser *p)
 
static enum parser_error parse_room_width (struct parser *p)
 
static enum parser_error parse_room_doors (struct parser *p)
 
static enum parser_error parse_room_tval (struct parser *p)
 
static enum parser_error parse_room_d (struct parser *p)
 
static struct parserinit_parse_room (void)
 
static errr run_parse_room (struct parser *p)
 
static errr finish_parse_room (struct parser *p)
 
static void cleanup_room (void)
 
static enum parser_error parse_vault_name (struct parser *p)
 Parsing functions for vault.txt. More...
 
static enum parser_error parse_vault_type (struct parser *p)
 
static enum parser_error parse_vault_rating (struct parser *p)
 
static enum parser_error parse_vault_rows (struct parser *p)
 
static enum parser_error parse_vault_columns (struct parser *p)
 
static enum parser_error parse_vault_min_depth (struct parser *p)
 
static enum parser_error parse_vault_max_depth (struct parser *p)
 
static enum parser_error parse_vault_d (struct parser *p)
 
struct parserinit_parse_vault (void)
 
static errr run_parse_vault (struct parser *p)
 
static errr finish_parse_vault (struct parser *p)
 
static void cleanup_vault (void)
 
static void run_template_parser (void)
 
static void cleanup_template_parser (void)
 Free the template arrays. More...
 
static void place_feeling (struct chunk *c)
 Place hidden squares that will be used to generate feeling. More...
 
static int calc_obj_feeling (struct chunk *c, struct player *p)
 Calculate the level feeling for objects. More...
 
static int calc_mon_feeling (struct chunk *c)
 Calculate the level feeling for monsters. More...
 
bool labyrinth_check (int depth)
 Do d_m's prime check for labyrinths. More...
 
const struct cave_profilefind_cave_profile (char *name)
 Find a cave_profile by name. More...
 
const struct cave_profilechoose_profile (int depth)
 Choose a cave profile. More...
 
static void cave_clear (struct chunk *c, struct player *p)
 Clear the dungeon, ready for generation to begin. More...
 
void cave_generate (struct chunk **c, struct player *p)
 Generate a random level. More...
 

Variables

struct pit_profilepit_info
 
struct vaultvaults
 
static struct cave_profilecave_profiles
 
struct dun_datadun
 
struct room_templateroom_templates
 
struct {
   const char *   name
 
   cave_builder   builder
 
cave_builders []
 
struct {
   const char *   name
 
   int   max_height
 
   int   max_width
 
   room_builder   builder
 
room_builders []
 
static struct file_parser profile_parser
 
static struct file_parser room_parser
 
static struct file_parser vault_parser
 
struct init_module generate_module
 The generate module, which initialises template rooms and vaults Should it clean up? More...
 

Detailed Description

Dungeon generation.

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.

This is the top level dungeon generation file, which contains room profiles (for determining what rooms are available and their parameters), cave profiles (for determining the level generation function and parameters for different styles of levels), initialisation functions for template rooms and vaults, and the main level generation function (which calls the level builders from gen-cave.c).

See the "vault.txt" file for more on vault generation. See the "room_template.txt" file for more room templates.

Macro Definition Documentation

#define DUN (   a,
 
)    { a, b##_gen },
#define ROOM (   a,
  b,
  c,
 
)    { a, b, c, build_##d },

Function Documentation

static int calc_mon_feeling ( struct chunk c)
static

Calculate the level feeling for monsters.

Parameters
cis the cave where the feeling is being measured

References chunk::depth, and chunk::mon_rating.

Referenced by cave_generate().

static int calc_obj_feeling ( struct chunk c,
struct player p 
)
static

Calculate the level feeling for objects.

Parameters
cis the cave where the feeling is being measured

References chunk::depth, chunk::good_item, chunk::obj_rating, and OPT.

Referenced by cave_generate().

static void cave_clear ( struct chunk c,
struct player p 
)
static

Clear the dungeon, ready for generation to begin.

References cave_free(), and wipe_mon_list().

Referenced by cave_generate().

void cave_generate ( struct chunk **  c,
struct player p 
)
const struct cave_profile* choose_profile ( int  depth)

Choose a cave profile.

Parameters
depthis the depth of the cave the profile will be used to generate

References cave_profile::cutoff, find_cave_profile(), get_string(), i, is_quest(), labyrinth_check(), player::noscore, NOSCORE_JUMPING, NULL, one_in_, profile, angband_constants::profile_max, quit(), randint0, and z_info.

Referenced by cave_generate().

static void cleanup_profile ( void  )
static
static void cleanup_room ( void  )
static
static void cleanup_template_parser ( void  )
static

Free the template arrays.

References cleanup_parser().

static void cleanup_vault ( void  )
static
const struct cave_profile* find_cave_profile ( char *  name)

Find a cave_profile by name.

Parameters
nameis the name of the cave_profile being looked for

References i, cave_profile::name, NULL, profile, angband_constants::profile_max, and z_info.

Referenced by choose_profile().

static errr finish_parse_profile ( struct parser p)
static
static errr finish_parse_room ( struct parser p)
static

References parser_destroy(), and parser_priv().

static errr finish_parse_vault ( struct parser p)
static

References parser_destroy(), and parser_priv().

static struct parser* init_parse_profile ( void  )
static
static struct parser* init_parse_room ( void  )
static
struct parser* init_parse_vault ( void  )
bool labyrinth_check ( int  depth)

Do d_m's prime check for labyrinths.

Parameters
depthis the depth where we're trying to generate a labyrinth

References is_quest(), and randint0.

Referenced by choose_profile().

static enum parser_error parse_profile_cutoff ( struct parser p)
static
static enum parser_error parse_profile_name ( struct parser p)
static
static enum parser_error parse_profile_params ( struct parser p)
static
static enum parser_error parse_profile_room ( struct parser p)
static
static enum parser_error parse_profile_streamer ( struct parser p)
static
static enum parser_error parse_profile_tunnel ( struct parser p)
static
static enum parser_error parse_room_d ( struct parser p)
static
static enum parser_error parse_room_doors ( struct parser p)
static
static enum parser_error parse_room_height ( struct parser p)
static
static enum parser_error parse_room_name ( struct parser p)
static

Parsing functions for room_template.txt.

References h, mem_zalloc(), room_template::name, room_template::next, parser_getstr(), parser_priv(), parser_setpriv(), and string_make().

Referenced by init_parse_room().

static enum parser_error parse_room_rating ( struct parser p)
static
static enum parser_error parse_room_tval ( struct parser p)
static
static enum parser_error parse_room_type ( struct parser p)
static
static enum parser_error parse_room_width ( struct parser p)
static
static enum parser_error parse_vault_columns ( struct parser p)
static
static enum parser_error parse_vault_d ( struct parser p)
static
static enum parser_error parse_vault_max_depth ( struct parser p)
static
static enum parser_error parse_vault_min_depth ( struct parser p)
static
static enum parser_error parse_vault_name ( struct parser p)
static

Parsing functions for vault.txt.

References h, mem_zalloc(), vault::name, vault::next, parser_getstr(), parser_priv(), parser_setpriv(), and string_make().

Referenced by init_parse_vault().

static enum parser_error parse_vault_rating ( struct parser p)
static

References parser_getint(), parser_priv(), and vault::rat.

Referenced by init_parse_vault().

static enum parser_error parse_vault_rows ( struct parser p)
static
static enum parser_error parse_vault_type ( struct parser p)
static
static void place_feeling ( struct chunk c)
static

Place hidden squares that will be used to generate feeling.

Parameters
cis the cave struct the feeling squares are being placed in

References chunk::feeling_squares, angband_constants::feeling_total, chunk::height, i, square::info, randint0, sqinfo_on, square_isfeel(), square_iswall(), chunk::squares, chunk::width, and z_info.

Referenced by cave_generate().

static errr run_parse_profile ( struct parser p)
static
static errr run_parse_room ( struct parser p)
static
static errr run_parse_vault ( struct parser p)
static
static void run_template_parser ( void  )
static

Variable Documentation

room_builder builder
const { ... } cave_builders[]
Initial value:
= {
#define DUN(a, b)
}

Referenced by parse_profile_name().

struct cave_profile* cave_profiles
static
struct dun_data* dun
struct init_module generate_module
Initial value:
= {
.name = "generate",
}
static void cleanup_template_parser(void)
Free the template arrays.
Definition: generate.c:619
static void run_template_parser(void)
Definition: generate.c:595

The generate module, which initialises template rooms and vaults Should it clean up?

int max_height
int max_width
struct pit_profile* pit_info
struct file_parser profile_parser
static
Initial value:
= {
"dungeon_profile",
}
static void cleanup_profile(void)
Definition: generate.c:283
static struct parser * init_parse_profile(void)
Definition: generate.c:187
static errr finish_parse_profile(struct parser *p)
Definition: generate.c:203
static errr run_parse_profile(struct parser *p)
Definition: generate.c:199
const { ... } room_builders[]
Initial value:
= {
#define ROOM(a, b, c, d)
}

Referenced by parse_profile_room(), parse_room_height(), parse_room_width(), parse_vault_columns(), and parse_vault_rows().

struct file_parser room_parser
static
Initial value:
= {
"room_template",
}
static void cleanup_room(void)
Definition: generate.c:428
static errr run_parse_room(struct parser *p)
Definition: generate.c:418
static struct parser * init_parse_room(void)
Definition: generate.c:404
static errr finish_parse_room(struct parser *p)
Definition: generate.c:422
struct room_template* room_templates

Referenced by random_room_template().

struct file_parser vault_parser
static
Initial value:
= {
"vault",
}
static void cleanup_vault(void)
Definition: generate.c:575
struct parser * init_parse_vault(void)
Definition: generate.c:551
static errr finish_parse_vault(struct parser *p)
Definition: generate.c:569
static errr run_parse_vault(struct parser *p)
Definition: generate.c:565
struct vault* vaults

Referenced by random_vault().