Crossfire Server, Trunk  R20513
Functions
rproto.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers)
 Create a bottom-centered layout. More...
 
void bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers)
 Create a bottom-right-centered layout. More...
 
int can_make_wall (char **maze, int dx, int dy, int dir, RMParms *RP)
 Checks the layout to see if we can stick a horizontal (dir = 0) wall (or vertical, dir == 1) here which ends up on other walls sensibly. More...
 
void centered_onion (char **maze, int xsize, int ysize, int option, int layers)
 Creates a centered onion layout. More...
 
void connect_spirals (int xsize, int ysize, int sym, char **layout)
 Connects disjoint spirals which may result from the symmetrization process. More...
 
void doorify_layout (char **maze, RMParms *RP)
 Puts doors at appropriate locations in a layout. More...
 
void draw_onion (char **maze, float *xlocations, float *ylocations, int layers)
 Draws the lines in the maze defining the onion layers. More...
 
void dump_layout (char **layout, RMParms *RP)
 Dumps specified layout using printf(). More...
 
char ** expand2x (char **layout, int xsize, int ysize)
 Expands the layout be a factor 2. More...
 
objectfind_closest_monster (mapstruct *map, int x, int y, RMParms *RP)
 finds the closest monster and returns him, regardless of doors or walls More...
 
object ** find_doors_in_room (mapstruct *map, int x, int y, RMParms *RP)
 Gets all doors in a room. More...
 
void find_doors_in_room_recursive (char **layout, mapstruct *map, int x, int y, object **doorlist, int *ndoors, RMParms *RP)
 The workhorse routine, which finds the doors in a room. More...
 
void find_enclosed_spot (mapstruct *map, int *cx, int *cy, RMParms *RP)
 Searches the map for a spot with walls around it. More...
 
void find_in_layout (int mode, char target, int *fx, int *fy, char **layout, RMParms *RP)
 Find a character in the layout. More...
 
objectfind_monster_in_room (mapstruct *map, int x, int y, RMParms *RP)
 Find a monster in a room. More...
 
objectfind_monster_in_room_recursive (char **layout, mapstruct *map, int x, int y, RMParms *RP)
 A recursive routine which will return a monster, eventually, if there is one. More...
 
int find_spot_for_submap (mapstruct *map, char **layout, int *ix, int *iy, int xsize, int ysize)
 Finds a place to put a submap into. More...
 
int find_spot_in_room (mapstruct *map, int x, int y, int *kx, int *ky, RMParms *RP)
 Find a random non-blocked spot in this room to drop a key. More...
 
mapstructfind_style (const char *dirname, const char *stylename, int difficulty)
 Loads and returns the map requested. More...
 
void find_top_left_corner (char **maze, int *cx, int *cy)
 This starts from within a centered onion layer (or between two layers), and looks up until it finds a wall, and then looks right until it finds a vertical wall, i.e., the corner. More...
 
void free_style_maps (void)
 Frees cached style maps. More...
 
mapstructgenerate_random_map (const char *OutFileName, RMParms *RP, char **use_layout)
 Main random map routine. More...
 
void include_map_in_map (mapstruct *dest_map, const mapstruct *in_map, int x, int y)
 Copy in_map into dest_map at point x,y. More...
 
int keyplace (mapstruct *map, int x, int y, char *keycode, int door_flag, int n_keys, RMParms *RP)
 Places keys in the map, preferably in something alive. More...
 
char ** layoutgen (RMParms *RP)
 This function builds the actual layout. More...
 
int load_dir (const char *dir, char ***namelist, int skip_dirs)
 This is our own version of scandir/select_regular_files/sort. More...
 
mapstructload_style_map (char *style_name)
 Loads specified map (or take it from cache list). More...
 
void lock_and_hide_doors (object **doorlist, mapstruct *map, int opts, RMParms *RP)
 Locks and/or hides all the doors in doorlist, or does nothing if opts doesn't say to lock/hide doors. More...
 
void make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options)
 Add doors to the layout. More...
 
mapstructmake_map_floor (char **layout, char *floorstyle, RMParms *RP)
 Creates the Crossfire mapstruct object from the layout, and adds the floor. More...
 
void make_map_walls (mapstruct *map, char **layout, char *w_style, RMParms *RP)
 takes a map and a layout, and puts walls in the map (picked from w_style) at '#' marks. More...
 
char ** make_snake_layout (int xsize, int ysize)
 Generate a snake-like layout. More...
 
char ** make_square_spiral_layout (int xsize, int ysize)
 Generates a square-spiral layout. More...
 
int make_wall (char **maze, int x, int y, int dir)
 Cuts the layout horizontally or vertically by a wall with a door. More...
 
char ** map_gen_onion (int xsize, int ysize, int option, int layers)
 Generates an onion layout. More...
 
char ** map_gen_spiral (int xsize, int ysize, int option)
 Generates a spiral layout. More...
 
char ** maze_gen (int xsize, int ysize, int option)
 This function generates a random blocked maze with the property that there is only one path from one spot to any other, and there is always a path from one spot to any other. More...
 
void nuke_map_region (mapstruct *map, int xstart, int ystart, int xsize, int ysize)
 Erases all objects (except floor) in the given rectangle. More...
 
int obj_count_in_map (mapstruct *map, int x, int y)
 Count objects at a spot. More...
 
objectpick_joined_wall (object *the_wall, char **layout, int i, int j, RMParms *RP)
 Picks the right wall type for this square, to make it look nice, and have everything nicely joined. More...
 
objectpick_random_object (mapstruct *style)
 Picks a random object from a style map. More...
 
objectplace_chest (int treasureoptions, int x, int y, mapstruct *map, mapstruct *style_map, int n_treasures, RMParms *RP)
 Put a chest into the map. More...
 
void place_exits (mapstruct *map, char **maze, char *exitstyle, int orientation, RMParms *RP)
 Place exits in the map. More...
 
void place_fountain_with_specials (mapstruct *map)
 Places a special fountain on the map. More...
 
void place_monsters (mapstruct *map, char *monsterstyle, int difficulty, RMParms *RP)
 Place some monsters into the map. More...
 
void place_special_exit (mapstruct *map, int hole_type, const RMParms *RP)
 Place an exit with a resource map. More...
 
void place_specials_in_map (mapstruct *map, char **layout, RMParms *RP)
 Main function for specials. More...
 
void place_treasure (mapstruct *map, char **layout, char *treasure_style, int treasureoptions, RMParms *RP)
 Place treasures in the map. More...
 
void put_decor (mapstruct *map, char **maze, char *decorstyle, int decor_option, RMParms *RP)
 Put the decor into the map. More...
 
void put_doors (mapstruct *the_map, char **maze, const char *doorstyle, RMParms *RP)
 Add doors to a map. More...
 
void remove_monsters (int x, int y, mapstruct *map)
 Remove living things on specified spot. More...
 
objectretrofit_joined_wall (mapstruct *the_map, int i, int j, int insert_flag, RMParms *RP)
 this takes a map, and changes an existing wall to match what's blocked around it, counting only doors and walls as blocked. More...
 
char ** roguelike_layout_gen (int xsize, int ysize, int options)
 Actually make the rogue layout. More...
 
void roomify_layout (char **maze, RMParms *RP)
 Take a layout and make some rooms in it. More...
 
char ** rotate_layout (char **maze, int rotation, RMParms *RP)
 Takes a map and rotates it. More...
 
int surround_check (char **layout, int i, int j, int Xsize, int Ysize)
 Checks free spots around a spot. More...
 
int surround_check2 (char **layout, int i, int j, int Xsize, int Ysize)
 Serch for doors or walls around a spot. More...
 
int surround_flag (char **layout, int i, int j, RMParms *RP)
 Given a layout and a coordinate, tell me which squares up/down/right/left are occupied. More...
 
int surround_flag2 (char **layout, int i, int j, RMParms *RP)
 Given a layout and a coordinate, tell me which squares up/down/right/left are occupied by walls. More...
 
int surround_flag3 (mapstruct *map, int i, int j, RMParms *RP)
 Check a map for blocked spots. More...
 
int surround_flag4 (mapstruct *map, int i, int j, RMParms *RP)
 Check a map for spots with walls. More...
 
char ** symmetrize_layout (char **maze, int sym, RMParms *RP)
 Takes a map and makes it symmetric: adjusts Xsize and Ysize to produce a symmetric map. More...
 
void unblock_exits (mapstruct *map, char **maze, RMParms *RP)
 This function unblocks the exits. More...
 
int wall_blocked (mapstruct *m, int x, int y)
 Returns true if square x,y has P_NO_PASS set, which is true for walls and doors but not monsters. More...
 
StringBufferwrite_map_parameters_to_string (const RMParms *RP)
 Creates a suitable message for exit from RP. More...
 

Function Documentation

void bottom_centered_onion ( char **  maze,
int  xsize,
int  ysize,
int  option,
int  layers 
)

Create a bottom-centered layout.

Parameters
mazelayout.
xsize
ysizelayout size.
optioncombination of OPT_xxx values.
layersnumber of layers to create.

Definition at line 219 of file room_gen_onion.c.

References draw_onion(), make_doors(), MIN, OPT_IRR_SPACE, and RANDOM.

Referenced by map_gen_onion().

Here is the call graph for this function:

Here is the caller graph for this function:

void bottom_right_centered_onion ( char **  maze,
int  xsize,
int  ysize,
int  option,
int  layers 
)

Create a bottom-right-centered layout.

Parameters
mazelayout.
xsize
ysizelayout size.
optioncombination of OPT_xxx values.
layersnumber of layers to create.

Definition at line 471 of file room_gen_onion.c.

References draw_onion(), make_doors(), MIN, OPT_IRR_SPACE, and RANDOM.

Referenced by map_gen_onion().

Here is the call graph for this function:

Here is the caller graph for this function:

int can_make_wall ( char **  maze,
int  dx,
int  dy,
int  dir,
RMParms RP 
)

Checks the layout to see if we can stick a horizontal (dir = 0) wall (or vertical, dir == 1) here which ends up on other walls sensibly.

Parameters
mazelayout.
dx
dycoordinates to check
dirdirection:
  • 0: horizontally.
  • 1: vertically.
RPrandom map parameters.
Returns
-1 if wall can't be made, possibly wall length else.

Definition at line 544 of file random_map.c.

References surround_flag2(), RMParms::Xsize, and RMParms::Ysize.

Referenced by roomify_layout().

Here is the call graph for this function:

Here is the caller graph for this function:

void centered_onion ( char **  maze,
int  xsize,
int  ysize,
int  option,
int  layers 
)

Creates a centered onion layout.

Parameters
mazelayout.
xsize
ysizelayout size.
optioncombination of OPT_xxx values.
layersnumber of layers to create.

Definition at line 141 of file room_gen_onion.c.

References draw_onion(), make_doors(), MIN, OPT_IRR_SPACE, and RANDOM.

Referenced by map_gen_onion().

Here is the call graph for this function:

Here is the caller graph for this function:

void connect_spirals ( int  xsize,
int  ysize,
int  sym,
char **  layout 
)

Connects disjoint spirals which may result from the symmetrization process.

Parameters
xsize
ysizelayout size.
symone of the SYM_xxx values.
layoutlayout to alter.

Definition at line 156 of file room_gen_spiral.c.

References surround_check(), X_SYM, XY_SYM, and Y_SYM.

Referenced by symmetrize_layout().

Here is the call graph for this function:

Here is the caller graph for this function:

void doorify_layout ( char **  maze,
RMParms RP 
)

Puts doors at appropriate locations in a layout.

Parameters
mazelayout.
RPmap parameters.

Definition at line 683 of file random_map.c.

References RANDOM, surround_flag(), RMParms::Xsize, and RMParms::Ysize.

Referenced by layoutgen().

Here is the call graph for this function:

Here is the caller graph for this function:

void draw_onion ( char **  maze,
float *  xlocations,
float *  ylocations,
int  layers 
)

Draws the lines in the maze defining the onion layers.

Parameters
mazemap to draw to.
xlocations
ylocationsarray of locations.
layersnumber of layers.
Todo:
explain what locations arrays should be, and the meaning of layers.

Definition at line 306 of file room_gen_onion.c.

Referenced by bottom_centered_onion(), bottom_right_centered_onion(), and centered_onion().

Here is the caller graph for this function:

void dump_layout ( char **  layout,
RMParms RP 
)

Dumps specified layout using printf().

Parameters
layoutlayout to dump.
RPlayout parameters.

Definition at line 44 of file random_map.c.

References RMParms::Xsize, and RMParms::Ysize.

Referenced by generate_random_map(), and layoutgen().

Here is the caller graph for this function:

char** expand2x ( char **  layout,
int  xsize,
int  ysize 
)

Expands the layout be a factor 2.

Doors and walls are taken care of.

Parameters
layoutlayout to expand. Memory is free()d at the end, so pointer becomes invalid.
xsize
ysizelayout size.
Returns
new layout. Must be free()d by caller.

Definition at line 43 of file expand2x.c.

References expand_door(), expand_misc(), and expand_wall().

Here is the call graph for this function:

object* find_closest_monster ( mapstruct map,
int  x,
int  y,
RMParms RP 
)

finds the closest monster and returns him, regardless of doors or walls

Parameters
map
x
ywhere to look from.
RPparameters for random map.
Returns
monster, or NULL if none found.
Todo:
shouldn't it search further away?

Definition at line 319 of file treasure.c.

References FLAG_MONSTER, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, GET_MAP_FLAGS, P_IS_ALIVE, QUERY_FLAG, and SIZEOFFREE.

Referenced by keyplace().

Here is the caller graph for this function:

object** find_doors_in_room ( mapstruct map,
int  x,
int  y,
RMParms RP 
)

Gets all doors in a room.

Parameters
mapmap to look into.
x
ypoint of a room to find door for.
RPmap parameters.
Returns
door list. Should be free()d be caller. NULL-terminated.
Todo:
couldn't layout be given instead of being computed?

Definition at line 901 of file treasure.c.

References find_doors_in_room_recursive(), wall_blocked(), RMParms::Xsize, and RMParms::Ysize.

Referenced by place_treasure().

Here is the call graph for this function:

Here is the caller graph for this function:

void find_doors_in_room_recursive ( char **  layout,
mapstruct map,
int  x,
int  y,
object **  doorlist,
int *  ndoors,
RMParms RP 
)

The workhorse routine, which finds the doors in a room.

Parameters
layout
map
x
yrandom map to look into.
doorlistlist of doors.
ndoorsnumber of found doors.
RPmap parameters.

Definition at line 851 of file treasure.c.

References door_in_square(), freearr_x, freearr_y, llevError, LOG(), and RANDOM.

Referenced by find_doors_in_room().

Here is the call graph for this function:

Here is the caller graph for this function:

void find_enclosed_spot ( mapstruct map,
int *  cx,
int *  cy,
RMParms RP 
)

Searches the map for a spot with walls around it.

The more walls the better, but it'll settle for 1 wall, or even 0, but it'll return 0 if no FREE spots are found.

Parameters
mapwhere to look.
cx
cywhere to look, and coordinates of found spot. -1 if no spot found.
RPparameters of the random map.

Definition at line 675 of file treasure.c.

References find_archetype(), freearr_x, freearr_y, object_find_first_free_spot(), SIZEOFFREE1, and surround_flag3().

Referenced by place_treasure().

Here is the call graph for this function:

Here is the caller graph for this function:

void find_in_layout ( int  mode,
char  target,
int *  fx,
int *  fy,
char **  layout,
RMParms RP 
)

Find a character in the layout.

Parameters
modehow to look:
  • 1: from top/left to bottom/right.
  • 2: from top/right to bottom/left.
  • 3: from bottom/left to top/right.
  • 4: from bottom/right to top/left.
  • other value: one random order is chosen.
targetcharacter to search.
fx
fyposition of character, or -1 if not found.
layoutmaze.
RPmaze parameters.

Definition at line 47 of file exit.c.

References RANDOM, RMParms::Xsize, and RMParms::Ysize.

Referenced by place_exits().

Here is the caller graph for this function:

object* find_monster_in_room ( mapstruct map,
int  x,
int  y,
RMParms RP 
)

Find a monster in a room.

Real work is done by find_monster_in_room_recursive().

Parameters
mapgenerated map.
x
ywhere to look from.
RPrandom map parameters.
Returns
monster, or NULL if none found.
Todo:
couldn't the layout be given instead of being calculated?

Definition at line 527 of file treasure.c.

References find_monster_in_room_recursive(), wall_blocked(), RMParms::Xsize, and RMParms::Ysize.

Referenced by keyplace().

Here is the call graph for this function:

Here is the caller graph for this function:

object* find_monster_in_room_recursive ( char **  layout,
mapstruct map,
int  x,
int  y,
RMParms RP 
)

A recursive routine which will return a monster, eventually, if there is one.

One should really call find_monster_in_room().

Parameters
layoutmap layout.
mapgenerated map.
x
ywhere to look from.
RPrandom map parameters.
Returns
monster, or NULL if none found.

Definition at line 476 of file treasure.c.

References FLAG_ALIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, GET_MAP_FLAGS, HEAD, P_IS_ALIVE, QUERY_FLAG, and RANDOM.

Referenced by find_monster_in_room().

Here is the caller graph for this function:

int find_spot_for_submap ( mapstruct map,
char **  layout,
int *  ix,
int *  iy,
int  xsize,
int  ysize 
)

Finds a place to put a submap into.

Parameters
mapmap to insert.
layoutwhere to insert into.
ix
iycoordinates of suitable location if return is 1.
xsize
ysizesize of layout.
Returns
0 if no space found, 1 else.

Definition at line 154 of file special.c.

References MAP_HEIGHT, MAP_WIDTH, RANDOM, settings, and Settings::special_break_map.

Referenced by place_specials_in_map().

Here is the caller graph for this function:

int find_spot_in_room ( mapstruct map,
int  x,
int  y,
int *  kx,
int *  ky,
RMParms RP 
)

Find a random non-blocked spot in this room to drop a key.

Returns 1 if success, 0 else.

Parameters
mapmap to look into.
x
ywhere to look from.
[out]kx
[out]kyfound spot if 1 is returned.
RPrandom map parameters.
Returns
1 if spot found, 0 else.
Todo:
couldn't layout be given instead of being computed?

Definition at line 619 of file treasure.c.

References find_spot_in_room_recursive(), free_spots_struct::number_of_free_spots_in_room, RANDOM, free_spots_struct::room_free_spots_x, free_spots_struct::room_free_spots_y, wall_blocked(), RMParms::Xsize, and RMParms::Ysize.

Referenced by keyplace().

Here is the call graph for this function:

Here is the caller graph for this function:

mapstruct* find_style ( const char *  dirname,
const char *  stylename,
int  difficulty 
)

Loads and returns the map requested.

Dirname, for example, is "/styles/wallstyles", stylename, is, for example, "castle", difficulty is -1 when difficulty is irrelevant to the style. If dirname is given, but stylename isn't, and difficult is -1, it returns a random style map. Otherwise, it tries to match the difficulty given with a style file, named style_name_# where # is an integer

Parameters
dirnamewhere to look.
stylenamestyle to use, can be NULL.
difficultystyle difficulty.
Returns
style, or NULL if none suitable.
Todo:
better document.

Definition at line 180 of file style.c.

References Settings::datadir, load_dir(), load_style_map(), RANDOM, S_ISDIR, settings, and snprintf.

Referenced by make_map_floor(), make_map_walls(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), place_specials_in_map(), place_treasure(), put_decor(), and put_doors().

Here is the call graph for this function:

Here is the caller graph for this function:

void find_top_left_corner ( char **  maze,
int *  cx,
int *  cy 
)

This starts from within a centered onion layer (or between two layers), and looks up until it finds a wall, and then looks right until it finds a vertical wall, i.e., the corner.

It sets cx and cy to that. it also starts from cx and cy.

Parameters
mazewhere to look.
cx
cywhere to start from, and detected corner.

Definition at line 53 of file square_spiral.c.

Referenced by make_square_spiral_layout().

Here is the caller graph for this function:

void free_style_maps ( void  )

Frees cached style maps.

Definition at line 309 of file style.c.

References delete_map(), llevDebug, LOG(), and mapdef::next.

Referenced by cleanup().

Here is the call graph for this function:

Here is the caller graph for this function:

mapstruct* generate_random_map ( const char *  OutFileName,
RMParms RP,
char **  use_layout 
)
void include_map_in_map ( mapstruct dest_map,
const mapstruct in_map,
int  x,
int  y 
)

Copy in_map into dest_map at point x,y.

This also copies shop information if set in in_map.

Parameters
dest_mapmap where to copy to.
in_mapmap to copy from.
x
ycoordinates to put in_map to.

Definition at line 86 of file special.c.

References add_button_link(), CALLOC, FLAG_IS_LINKED, FOR_MAP_FINISH, FOR_MAP_PREPARE, FREE_AND_CLEAR, shopitem::index, INS_NO_MERGE, INS_NO_WALK_ON, MAP_HEIGHT, MAP_WIDTH, nuke_map_region(), object_copy_with_inv(), object_create_arch(), object_insert_in_map_at(), QUERY_FLAG, mapdef::shopgreed, mapdef::shopitems, mapdef::shopmax, mapdef::shopmin, mapdef::shoprace, and strdup_local.

Referenced by place_specials_in_map().

Here is the call graph for this function:

Here is the caller graph for this function:

int keyplace ( mapstruct map,
int  x,
int  y,
char *  keycode,
int  door_flag,
int  n_keys,
RMParms RP 
)

Places keys in the map, preferably in something alive.

The idea is that you call keyplace on x,y where a door is, and it'll make sure a key is placed on both sides of the door.

Parameters
map
x
ywhere to put a key.
keycodekeycode is the key's code.
door_flagif NO_PASS_DOORS won't cross doors or walls to keyplace, PASS_DOORS will. if PASS_DOORS is set, the x & y values that are passed in are basically meaningless - IMO, it is a bit of misnomer, as when it is set, it just randomly chooses spaces on the map, ideally finding a close monster, to put the key in. In fact, if PASS_DOORS is set, there is no guarantee that the keys will be on both sides of the door - it may happen by randomness, but the code doesn't work to make sure it happens.
n_keysnumber of keys to place. If 1, it will place 1 key. Else, it will place 2-4 keys.
RPrandom map parameters.
Returns
1 if key was successfully placed, 0 else.

Definition at line 369 of file treasure.c.

References add_string(), create_archetype(), RMParms::dungeon_level, RMParms::dungeon_name, find_closest_monster(), find_monster_in_room(), find_spot_in_room(), free_string(), freearr_x, freearr_y, obj::name, NO_PASS_DOORS, object_find_first_free_spot(), object_insert_in_map_at(), object_insert_in_ob(), PASS_DOORS, RANDOM, obj::slaying, snprintf, wall_blocked(), RMParms::Xsize, and RMParms::Ysize.

Referenced by lock_and_hide_doors(), and place_chest().

Here is the call graph for this function:

Here is the caller graph for this function:

char** layoutgen ( RMParms RP)

This function builds the actual layout.

Selects the layout based on parameters and gives it whatever arguments it needs.

Parameters
RPrandom map parameters.
Returns
layout, must be free()d be caller.
Todo:
use an array for name/style mapping. Refactor to call only one function for each (will make it easier to override later on).

Definition at line 208 of file random_map.c.

References doorify_layout(), dump_layout(), expand2x(), RMParms::expand2x, RMParms::layoutoptions1, RMParms::layoutoptions2, RMParms::layoutstyle, make_snake_layout(), make_square_spiral_layout(), map_gen_onion(), map_gen_spiral(), RMParms::map_layout_style, maze_gen(), MAZE_LAYOUT, MIN_RANDOM_MAP_SIZE, NO_SYM, NROFLAYOUTS, ONION_LAYOUT, OPT_WALLS_ONLY, RANDOM, RANDOM_SYM, ROGUELIKE_LAYOUT, roguelike_layout_gen(), roomify_layout(), SNAKE_LAYOUT, SPIRAL_LAYOUT, SQUARE_SPIRAL_LAYOUT, symmetrize_layout(), RMParms::symmetry, RMParms::symmetry_used, X_SYM, RMParms::Xsize, XY_SYM, Y_SYM, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

int load_dir ( const char *  dir,
char ***  namelist,
int  skip_dirs 
)

This is our own version of scandir/select_regular_files/sort.

To support having subdirectories in styles, we need to know if in fact the directory we read is a subdirectory. However, we can't get that through the normal dirent entry. So instead, we do our own where we do have the full directory path so can do stat calls to see if in fact it is a directory. dir is the name of the director to scan. namelist is the array of file names returned. IT needs to be freed by the caller. skip_dirs controls our behavioru - if nonzero, we don't skip any subdirectories - if zero, we store those away, since there are cases where we want to choose a random directory.

Parameters
dirdirectory to list.
[out]namelistlist of files found.
skip_dirsif non 0, don't list directories.
Returns
-1 if dir is invalid, number of files else.

Definition at line 74 of file style.c.

References closedir(), dirent::d_name, NAME_MAX, opendir(), pointer_strcmp(), readdir(), S_ISDIR, snprintf, and strdup_local.

Referenced by find_style().

Here is the call graph for this function:

Here is the caller graph for this function:

mapstruct* load_style_map ( char *  style_name)

Loads specified map (or take it from cache list).

Parameters
style_namemap to load.
Returns
map.

Definition at line 131 of file style.c.

References first_map, MAP_STYLE, mapfile_load(), mapdef::next, mapdef::path, and styles.

Referenced by find_style().

Here is the call graph for this function:

Here is the caller graph for this function:

void lock_and_hide_doors ( object **  doorlist,
mapstruct map,
int  opts,
RMParms RP 
)

Locks and/or hides all the doors in doorlist, or does nothing if opts doesn't say to lock/hide doors.

Note that some doors can be not locked if no good spot to put a key was found.

Parameters
doorlistdoors to list. NULL-terminated.
mapmap we're working on.
optsoptions.
RPmap parameters.
Todo:
document opts. Isn't it part of RP?

Definition at line 986 of file treasure.c.

References add_string(), create_archetype(), DOORED, obj::face, FLAG_REMOVED, HIDDEN, keyplace(), NO_PASS_DOORS, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), QUERY_FLAG, RANDOM, remove_adjacent_doors(), retrofit_joined_wall(), obj::slaying, snprintf, obj::x, and obj::y.

Referenced by place_treasure().

Here is the call graph for this function:

Here is the caller graph for this function:

void make_doors ( char **  maze,
float *  xlocations,
float *  ylocations,
int  layers,
int  options 
)

Add doors to the layout.

Parameters
mazemap to draw to.
xlocations
ylocationsarray of locations. Will be free()d.
layersnumber of layers.
optionscombination of OPT_xxx values.
Todo:
explain what locations arrays should be, and the meaning of layers.

Definition at line 345 of file room_gen_onion.c.

References cleanup(), OPT_BOTTOM_C, OPT_BOTTOM_R, OPT_LINEAR, OPT_NO_DOORS, and RANDOM.

Referenced by bottom_centered_onion(), bottom_right_centered_onion(), and centered_onion().

Here is the call graph for this function:

Here is the caller graph for this function:

mapstruct* make_map_floor ( char **  layout,
char *  floorstyle,
RMParms RP 
)

Creates the Crossfire mapstruct object from the layout, and adds the floor.

Parameters
layoutgenerated layout.
floorstylefloor style. Can be NULL, in which case a random one is chosen.
RPparameters of the random map.
Returns
Crossfire map.

Definition at line 75 of file floor.c.

References obj::arch, arch_to_object(), find_style(), get_empty_map(), GET_MAP_OB, INS_NO_MERGE, INS_NO_WALK_ON, RMParms::multiple_floors, object_insert_in_map_at(), pick_random_object(), put_floor(), snprintf, RMParms::Xsize, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void make_map_walls ( mapstruct map,
char **  layout,
char *  w_style,
RMParms RP 
)

takes a map and a layout, and puts walls in the map (picked from w_style) at '#' marks.

Parameters
mapmap where walls will be put.
layoutlayout containing walls and such.
w_stylewall style. Must not be NULL, can be "none".
RPmap parameters.

Definition at line 184 of file wall.c.

References obj::arch, arch_to_object(), find_style(), INS_NO_MERGE, INS_NO_WALK_ON, MOVE_ALL, obj::move_allow, obj::move_block, archt::name, object_insert_in_map_at(), pick_joined_wall(), pick_random_object(), snprintf, RMParms::wall_name, RMParms::Xsize, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

char** make_snake_layout ( int  xsize,
int  ysize 
)

Generate a snake-like layout.

Parameters
xsize
ysizelayout size.
Returns
generated layout.

Definition at line 34 of file snake.c.

References RANDOM.

Referenced by layoutgen().

Here is the caller graph for this function:

char** make_square_spiral_layout ( int  xsize,
int  ysize 
)

Generates a square-spiral layout.

Parameters
xsize
ysizesize of the layout.
Returns
generated layout.
Todo:
use function in another file for character searching.

Definition at line 78 of file square_spiral.c.

References find_top_left_corner(), make_wall(), map_gen_onion(), OPT_CENTERED, OPT_NO_DOORS, and RANDOM.

Referenced by layoutgen().

Here is the call graph for this function:

Here is the caller graph for this function:

int make_wall ( char **  maze,
int  x,
int  y,
int  dir 
)

Cuts the layout horizontally or vertically by a wall with a door.

Parameters
mazelayout.
x
ywhere to put the door.
dirwall direction:
  • 0: horizontally.
  • 1: vertically.
Returns
0

Definition at line 644 of file random_map.c.

Referenced by make_square_spiral_layout(), and roomify_layout().

Here is the caller graph for this function:

char** map_gen_onion ( int  xsize,
int  ysize,
int  option,
int  layers 
)

Generates an onion layout.

Parameters
xsize
ysizelayout size.
optioncombination of OPT_xxx values.
layersnumber of layers the onion should have.
Returns
layout.

Definition at line 70 of file room_gen_onion.c.

char** map_gen_spiral ( int  xsize,
int  ysize,
int  option 
)

Generates a spiral layout.

Parameters
xsize
ysizelayout size.
optioncombination of SPIRAL_xxx values.
Returns
generated layout.

Definition at line 61 of file room_gen_spiral.c.

References FINE_SPIRAL, FIT_SPIRAL, MAX_FINE, MAX_SPIRAL_OPT, MIN, RANDOM, and REGULAR_SPIRAL.

Referenced by layoutgen().

Here is the caller graph for this function:

char** maze_gen ( int  xsize,
int  ysize,
int  option 
)

This function generates a random blocked maze with the property that there is only one path from one spot to any other, and there is always a path from one spot to any other.

Parameters
xsize
ysizewanted map size.
optionif 0, maze will be sparse (sizeable rooms), else totally filled.
Returns
a char** array with # and . for closed and open respectively. a char value of 0 represents a blank space: a '#' is a wall.

Definition at line 58 of file maze_gen.c.

References fill_maze_full(), fill_maze_sparse(), make_wall_free_list(), pop_wall_point(), free_walls_struct::wall_free_size, free_walls_struct::wall_x_list, and free_walls_struct::wall_y_list.

Here is the call graph for this function:

void nuke_map_region ( mapstruct map,
int  xstart,
int  ystart,
int  xsize,
int  ysize 
)

Erases all objects (except floor) in the given rectangle.

Parameters
mapmap to process.
xstart
ystarttop-left coordinates of zone.
xsize
ysizesize of zone.

Definition at line 59 of file special.c.

References FLAG_IS_FLOOR, FOR_MAP_FINISH, FOR_MAP_PREPARE, HEAD, object_free_drop_inventory(), object_remove(), and QUERY_FLAG.

Referenced by include_map_in_map().

Here is the call graph for this function:

Here is the caller graph for this function:

int obj_count_in_map ( mapstruct map,
int  x,
int  y 
)

Count objects at a spot.

Parameters
mapmap we want to check
x
ycoordinates
Returns
count of objects in the map at x,y.

Definition at line 39 of file decor.c.

References FOR_MAP_FINISH, and FOR_MAP_PREPARE.

Referenced by put_decor().

Here is the caller graph for this function:

object* pick_joined_wall ( object the_wall,
char **  layout,
int  i,
int  j,
RMParms RP 
)

Picks the right wall type for this square, to make it look nice, and have everything nicely joined.

It uses the layout.

Parameters
the_wallwall we want to insert.
layout
i
jwhere to insert.
RPmap parameters.
Returns
correct wall archetype to fit on the square.
Todo:
check if there isn't an equivalent function in the building code, merge?

Definition at line 256 of file wall.c.

References obj::arch, arch_to_object(), archt::name, surround_flag2(), try_find_archetype(), and wall_join.

Referenced by make_map_walls().

Here is the call graph for this function:

Here is the caller graph for this function:

object* pick_random_object ( mapstruct style)

Picks a random object from a style map.

Redone by MSW so it should be faster and not use static variables to generate tables.

Parameters
stylemap to pick from.
Returns
random object. Can be NULL.

Definition at line 286 of file style.c.

References GET_MAP_OB, HEAD, MAP_HEIGHT, MAP_WIDTH, and RANDOM.

Referenced by make_map_floor(), make_map_walls(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), put_decor(), and put_doors().

Here is the caller graph for this function:

object* place_chest ( int  treasureoptions,
int  x,
int  y,
mapstruct map,
mapstruct style_map,
int  n_treasures,
RMParms RP 
)

Put a chest into the map.

near x and y, with the treasure style determined (may be null, or may be a treasure list from lib/treasures, if the global variable "treasurestyle" is set to that treasure list's name

Parameters
treasureoptionsoptions.
x
yaround which spot to put treasure.
mapmap to put on.
style_mapunused.
n_treasures?
RPparameters the map was generated from.
Returns
inserted chest, NULL for failure.
Todo:
document treasureoptions. Clean parameters. Check meaning of chest hp's field.

Definition at line 233 of file treasure.c.

References add_string(), BC_RANDOM, liv::Cha, create_archetype(), RMParms::difficulty, find_style(), find_treasurelist(), freearr_x, freearr_y, liv::hp, keyplace(), KEYREQUIRED, obj::level, object_copy_with_inv(), object_find_first_free_spot(), object_free_drop_inventory(), object_insert_in_map_at(), object_insert_in_ob(), object_new(), PASS_DOORS, pick_random_object(), RANDOM, obj::randomitems, obj::slaying, snprintf, obj::stats, TRAPPED, wall_blocked(), obj::x, and obj::y.

Referenced by place_treasure().

Here is the call graph for this function:

Here is the caller graph for this function:

void place_exits ( mapstruct map,
char **  maze,
char *  exitstyle,
int  orientation,
RMParms RP 
)

Place exits in the map.

Parameters
mapmap to put exits into.
mazemap layout.
exitstylewhat style to use. If NULL uses a random one.
orientationhow exits should be oriented:
  • 0 means random.
  • 1 means descending dungeon.
  • 2 means ascending dungeon.
  • 3 means rightward.
  • 4 means leftward.
  • 5 means northward.
  • 6 means southward.
RPmap parameters.
Note
unblock_exits() should be called at some point, as exits will be blocking everything to avoid putting other objects on them.
Todo:
add orientations 3-6 or fix previous comment.

Definition at line 144 of file exit.c.

References add_string(), obj::arch, arch_to_object(), create_archetype(), RMParms::dungeon_depth, RMParms::dungeon_level, EXIT, RMParms::exit_on_final_map, EXIT_PATH, EXIT_X, EXIT_Y, RMParms::final_exit_archetype, RMParms::final_map, find_archetype(), find_in_layout(), find_style(), FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, liv::hp, MAP_ENTER_X, MAP_ENTER_Y, MOVE_ALL, obj::move_block, object_find_first_free_spot(), object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_set_msg(), RMParms::origin_map, RMParms::origin_x, RMParms::origin_y, mapdef::path, pick_random_object(), RANDOM, ready_map_name(), set_map_timeout(), obj::slaying, snprintf, liv::sp, obj::stats, stringbuffer_finish(), wall_blocked(), write_map_parameters_to_string(), obj::x, RMParms::Xsize, obj::y, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void place_fountain_with_specials ( mapstruct map)
void place_monsters ( mapstruct map,
char *  monsterstyle,
int  difficulty,
RMParms RP 
)

Place some monsters into the map.

Their experience is linked to difficulty to insert a suitable number of critters.

Parameters
mapwhere to put monsters on.
monsterstylestyle. Can be NULL, in which case a random one is used.
difficultyhow difficult the monsters should be, and how many there should be.
RPrandom map parameters.

Definition at line 38 of file monster.c.

References obj::arch, liv::exp, find_style(), freearr_x, freearr_y, liv::hp, INS_NO_MERGE, INS_NO_WALK_ON, level_exp(), MAP_HEIGHT, MAP_WIDTH, archt::more, object_copy_with_inv(), object_create_arch(), object_find_first_free_spot(), object_insert_in_map_at(), pick_random_object(), RANDOM, snprintf, obj::stats, RMParms::total_map_hp, RMParms::Xsize, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void place_special_exit ( mapstruct map,
int  hole_type,
const RMParms RP 
)
void place_specials_in_map ( mapstruct map,
char **  layout,
RMParms RP 
)

Main function for specials.

Parameters
mapmap to alter.
layoutlayout the map was generated from.
RPparameters the map was generated from.

Definition at line 393 of file special.c.

References RMParms::difficulty, find_spot_for_submap(), find_style(), include_map_in_map(), MAP_HEIGHT, MAP_WIDTH, NUM_OF_SPECIAL_TYPES, place_fountain_with_specials(), place_special_exit(), RANDOM, SPECIAL_EXIT, SPECIAL_FOUNTAIN, and SPECIAL_SUBMAP.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void place_treasure ( mapstruct map,
char **  layout,
char *  treasure_style,
int  treasureoptions,
RMParms RP 
)

Place treasures in the map.

map, (required) layout, (required) treasure style (may be empty or NULL, or "none" to cause no treasure.) treasureoptions (may be 0 for random choices or positive)

Parameters
mapwhere to insert to.
layoutlayout the map was generated from.
treasure_styletreasure style. May be empty or NULL for random style, or "none" for no treasures.
treasureoptionstreasure options.
RPrandom map parameters.
Todo:
flags for treasureoptions.

Definition at line 92 of file treasure.c.

References BC_RANDOM, CONCENTRATED, RMParms::difficulty, DOORED, find_doors_in_room(), find_enclosed_spot(), find_style(), HIDDEN, LAST_OPTION, lock_and_hide_doors(), RMParms::map_layout_style, ONION_LAYOUT, place_chest(), RANDOM, RICH, snprintf, SPARSE, SPIRAL_LAYOUT, SQUARE_SPIRAL_LAYOUT, surround_by_doors(), RMParms::symmetry_used, RMParms::total_map_hp, wall_blocked(), obj::x, RMParms::Xsize, obj::y, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void put_decor ( mapstruct map,
char **  maze,
char *  decorstyle,
int  decor_option,
RMParms RP 
)

Put the decor into the map.

Right now, it's very primitive.

Parameters
mapmap to add decor to.
mazelayout of the map, as was generated.
decorstylestyle to use. Can be NULL.
decor_optionhow to place decor:
  • 0 means no decor.
  • 1 means to place randomly decor.
  • other means to fill the map with decor.
RPparameters of the random map.

Definition at line 65 of file decor.c.

References obj::arch, arch_to_object(), find_style(), NR_DECOR_OPTIONS, obj_count_in_map(), object_copy(), object_insert_in_map_at(), pick_random_object(), RANDOM, snprintf, RMParms::Xsize, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void put_doors ( mapstruct the_map,
char **  maze,
const char *  doorstyle,
RMParms RP 
)

Add doors to a map.

Parameters
the_mapmap we're adding doors to.
mazemaze layout.
doorstyledoor style to be. If "none", won't do anything. If NULL, will choose one randomly.
RPrandom map parameters.

Definition at line 73 of file door.c.

References obj::arch, arch_to_object(), find_style(), object_copy(), object_insert_in_map_at(), mapdef::path, pick_random_object(), snprintf, surround_check2(), RMParms::Xsize, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_monsters ( int  x,
int  y,
mapstruct map 
)

Remove living things on specified spot.

Parameters
x
y
mapwhere to remove.

Definition at line 745 of file treasure.c.

References FLAG_ALIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, GET_MAP_OB, HEAD, object_free_drop_inventory(), object_remove(), and QUERY_FLAG.

Referenced by surround_by_doors().

Here is the call graph for this function:

Here is the caller graph for this function:

object* retrofit_joined_wall ( mapstruct the_map,
int  i,
int  j,
int  insert_flag,
RMParms RP 
)

this takes a map, and changes an existing wall to match what's blocked around it, counting only doors and walls as blocked.

If insert_flag is 1, . If not, it will only return the wall which would belong there, and doesn't remove anything. It depends on the global, previously-set variable, "wall_name"

Parameters
the_map
i
jwhere to look.
insert_flagif 1, insert the correct wall into the map, else don't insert.
RPmap parameters.
Returns
correct wall for spot.
Todo:
merge with pick_joined_wall()?

Definition at line 315 of file wall.c.

References arch_to_object(), DOOR, EXIT, FOR_MAP_FINISH, FOR_MAP_PREPARE, INS_NO_MERGE, INS_NO_WALK_ON, LOCKED_DOOR, obj::map, MOVE_ALL, obj::move_block, MOVE_WALK, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), surround_flag4(), TELEPORTER, try_find_archetype(), obj::type, wall_join, and RMParms::wall_name.

Referenced by lock_and_hide_doors().

Here is the call graph for this function:

Here is the caller graph for this function:

char** roguelike_layout_gen ( int  xsize,
int  ysize,
int  options 
)

Actually make the rogue layout.

We work by a reduction process: first we make everything a wall, then we remove areas to make rooms

Parameters
xsize
ysizewanted layout size.
options2 to have circular rooms, 1 for rectanglar ones, another value for random choice.
Returns
generated layout.

Definition at line 332 of file rogue_layout.c.

References RANDOM, roguelike_link_rooms(), roguelike_make_rooms(), roguelike_place_room(), surround_check(), Room::x, and Room::y.

Referenced by layoutgen(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

void roomify_layout ( char **  maze,
RMParms RP 
)

Take a layout and make some rooms in it.

Works best on onions.

Parameters
mazelayout to alter.
RPmap parameters.

Definition at line 496 of file random_map.c.

References can_make_wall(), make_wall(), RANDOM, RMParms::Xsize, and RMParms::Ysize.

Referenced by layoutgen().

Here is the call graph for this function:

Here is the caller graph for this function:

char** rotate_layout ( char **  maze,
int  rotation,
RMParms RP 
)

Takes a map and rotates it.

This completes the onion layouts, making them possibly centered on any wall. It'll modify Xsize and Ysize if they're swapped.

Parameters
mazelayout to rotate, will be free()d by this function.
rotationhow to rotate:
  • 0: don't do anything.
  • 1: rotate 90 deg clockwise.
  • 2: rotate 180 deg.
  • 3: rotate 90 deg counter-clockwise.
RPrandom map parameters.
Returns
new layout, must be free()d be caller. NULL if invalid rotation.

Definition at line 424 of file random_map.c.

References RMParms::Xsize, and RMParms::Ysize.

Referenced by generate_random_map().

Here is the caller graph for this function:

int surround_check ( char **  layout,
int  i,
int  j,
int  Xsize,
int  Ysize 
)

Checks free spots around a spot.

Parameters
layoutmap layout.
i
jcoordinates to check.
Xsize
Ysizesize of the layout.
Returns
combination of the following values:
  • 1 = free space to left,
  • 2 = free space to right,
  • 4 = free space above
  • 8 = free space below
Todo:
there is an equivalent function in another layout, merge them together.

Definition at line 303 of file rogue_layout.c.

int surround_check2 ( char **  layout,
int  i,
int  j,
int  Xsize,
int  Ysize 
)

Serch for doors or walls around a spot.

Parameters
layoutmaze.
i
jcoordinates to check.
Xsize
Ysizemaze size.
Returns
Combination of flags:
  • 1 = door or wall to left.
  • 2 = door or wall to right.
  • 4 = door or wall above.
  • 8 = door or wall below.

Definition at line 43 of file door.c.

Referenced by put_doors().

Here is the caller graph for this function:

int surround_flag ( char **  layout,
int  i,
int  j,
RMParms RP 
)

Given a layout and a coordinate, tell me which squares up/down/right/left are occupied.

Parameters
layout
i
jspot to look.
RPmap parameters.
Returns
combination of:
  • 1 = something on left.
  • 2 = something on right.
  • 4 = something on above.
  • 8 = something on below.
Todo:
merge with surround_flag2() and friends, check if such a function doesn't exist in other files.

Definition at line 40 of file wall.c.

Referenced by doorify_layout().

Here is the caller graph for this function:

int surround_flag2 ( char **  layout,
int  i,
int  j,
RMParms RP 
)

Given a layout and a coordinate, tell me which squares up/down/right/left are occupied by walls.

Parameters
layout
i
jspot to look.
RPmap parameters.
Returns
combination of:
  • 1 = wall on left.
  • 2 = wall on right.
  • 4 = wall on above.
  • 8 = wall on below.
Todo:
merge with surround_flag() and friends, check if such a function doesn't exist in other files.

Definition at line 77 of file wall.c.

Referenced by can_make_wall(), and pick_joined_wall().

Here is the caller graph for this function: