Angband
Macros | Functions | Variables
generate.c File Reference

Dungeon generation. More...

#include "angband.h"
#include "cave.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-util.h"
#include "object.h"
#include "parser.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)   { a, build_##b },

Functions

static enum parser_error parse_profile_name (struct parser *p)
 Parsing functions for dungeon_profile.txt.
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_n (struct parser *p)
 Parsing functions for room_template.txt.
static enum parser_error parse_room_x (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_v_n (struct parser *p)
static enum parser_error parse_v_x (struct parser *p)
static enum parser_error parse_v_d (struct parser *p)
struct parserinit_parse_v (void)
static errr run_parse_v (struct parser *p)
static errr finish_parse_v (struct parser *p)
static void cleanup_v (void)
static void run_template_parser (void)
static void place_feeling (struct chunk *c)
 Place hidden squares that will be used to generate feeling.
static int calc_obj_feeling (struct chunk *c)
 Calculate the level feeling for objects.
static int calc_mon_feeling (struct chunk *c)
 Calculate the level feeling for monsters.
bool labyrinth_check (int depth)
 Do d_m's prime check for labyrinths.
struct cave_profilefind_cave_profile (char *name)
 Find a cave_profile by name.
struct cave_profilechoose_profile (int depth)
 Choose a cave profile.
void cave_generate (struct chunk **c, struct player *p)
 Generate a random level.

Variables

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

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,
 
)    { a, build_##b },

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)
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().

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

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, 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_v ( void  )
static
struct cave_profile* find_cave_profile ( char *  name)
read

Find a cave_profile by name.

Parameters
nameis the name of the cave_profile being looked for

References i, cave_profile::name, 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
static errr finish_parse_v ( struct parser p)
static

References parser_destroy(), and parser_priv().

static struct parser* init_parse_profile ( void  )
staticread
static struct parser* init_parse_room ( void  )
staticread
struct parser* init_parse_v ( void  )
read
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 FALSE, is_quest(), randint0, and TRUE.

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_n ( struct parser p)
static
static enum parser_error parse_room_x ( struct parser p)
static
static enum parser_error parse_v_d ( struct parser p)
static
static enum parser_error parse_v_n ( struct parser p)
static
static enum parser_error parse_v_x ( 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

References parse_file().

static errr run_parse_room ( struct parser p)
static

References parse_file().

static errr run_parse_v ( struct parser p)
static

References parse_file().

static void run_template_parser ( void  )
static

Variable Documentation

room_builder builder
struct { ... } cave_builders[]

Referenced by parse_profile_name().

struct cave_profile* cave_profiles
struct init_module generate_module
Initial value:
{
.name = "generate",
.cleanup = NULL
}

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

struct pit_profile* pit_info
struct file_parser profile_parser
static
struct { ... } room_builders[]

Referenced by parse_profile_room().

struct file_parser room_parser
static
Initial value:
struct file_parser v_parser
static
Initial value:
struct vault* vaults

Referenced by random_vault().