Crossfire Server, Branches 1.12
R18729
|
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <global.h>
#include <maze_gen.h>
#include <room_gen.h>
#include <random_map.h>
#include <rproto.h>
#include <sproto.h>
Go to the source code of this file.
Functions | |
int | can_make_wall (char **maze, int dx, int dy, int dir, RMParms *RP) |
void | doorify_layout (char **maze, RMParms *RP) |
void | dump_layout (char **layout, RMParms *RP) |
mapstruct * | generate_random_map (const char *OutFileName, RMParms *RP, char **use_layout) |
char ** | layoutgen (RMParms *RP) |
int | make_wall (char **maze, int x, int y, int dir) |
void | roomify_layout (char **maze, RMParms *RP) |
char ** | rotate_layout (char **maze, int rotation, RMParms *RP) |
char ** | symmetrize_layout (char **maze, int sym, RMParms *RP) |
void | write_map_parameters_to_string (RMParms *RP, char *buf, int bufsize) |
void | write_parameters_to_string (char *buf, int xsize_n, int ysize_n, const char *wallstyle_n, const char *floorstyle_n, const char *monsterstyle_n, const char *treasurestyle_n, const char *layoutstyle_n, const char *decorstyle_n, const char *doorstyle_n, const char *exitstyle_n, const char *final_map_n, const char *exit_on_final_map_n, const char *this_map_n, int layoutoptions1_n, int layoutoptions2_n, int layoutoptions3_n, int symmetry_n, int dungeon_depth_n, int dungeon_level_n, int difficulty_n, int difficulty_given_n, int decoroptions_n, int orientation_n, int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) |
random map generation main routines.
Definition in file random_map.c.
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.
maze | layout. |
dx | |
dy | coordinates to check |
dir | direction:
|
RP | random map parameters. |
Definition at line 516 of file random_map.c.
References surround_flag2(), RMParms::Xsize, and RMParms::Ysize.
Referenced by roomify_layout().
void doorify_layout | ( | char ** | maze, |
RMParms * | RP | ||
) |
Puts doors at appropriate locations in a layout.
maze | layout. |
RP | map parameters. |
Definition at line 636 of file random_map.c.
References surround_flag(), RMParms::Xsize, and RMParms::Ysize.
Referenced by layoutgen().
void dump_layout | ( | char ** | layout, |
RMParms * | RP | ||
) |
Dumps specified layout using printf().
layout | layout to dump. |
RP | layout parameters. |
Definition at line 53 of file random_map.c.
References RMParms::Xsize, and RMParms::Ysize.
Referenced by generate_random_map(), and layoutgen().
Main random map routine. Generates a random map based on specified parameters.
OutFileName | the path the map should have. |
RP | parameters for generation. |
use_layout | if not NULL, this should be a suitable layout. |
Definition at line 80 of file random_map.c.
References calculate_difficulty(), RMParms::decoroptions, RMParms::decorstyle, RMParms::difficulty, mapdef::difficulty, RMParms::difficulty_given, RMParms::difficulty_increase, RMParms::doorstyle, dump_layout(), RMParms::dungeon_level, RMParms::exitstyle, RMParms::expand2x, fix_auto_apply(), RMParms::floorstyle, gettimeofday(), HUGE_BUF, mapdef::last_reset_time, layoutgen(), make_map_floor(), make_map_walls(), MIN_RANDOM_MAP_SIZE, RMParms::monsterstyle, mapdef::msg, RMParms::orientation, mapdef::path, place_exits(), place_monsters(), place_specials_in_map(), place_treasure(), put_decor(), put_doors(), RMParms::random_seed, RMParms::region, mapdef::region, rotate_layout(), strdup_local(), RMParms::treasureoptions, RMParms::treasurestyle, unblock_exits(), RMParms::wallstyle, write_map_parameters_to_string(), RMParms::Xsize, and RMParms::Ysize.
Referenced by cfapi_generate_random_map(), enter_random_map(), enter_random_template_map(), and main().
char** layoutgen | ( | RMParms * | RP | ) |
This function builds the actual layout. Selects the layout based on parameters and gives it whatever arguments it needs.
RP | random map parameters. |
Definition at line 203 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_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().
int make_wall | ( | char ** | maze, |
int | x, | ||
int | y, | ||
int | dir | ||
) |
Cuts the layout horizontally or vertically by a wall with a door.
maze | layout. |
x | |
y | where to put the door. |
dir | wall direction:
|
Definition at line 602 of file random_map.c.
Referenced by make_square_spiral_layout(), and roomify_layout().
void roomify_layout | ( | char ** | maze, |
RMParms * | RP | ||
) |
Take a layout and make some rooms in it. Works best on onions.
maze | layout to alter. |
RP | map parameters. |
Definition at line 471 of file random_map.c.
References can_make_wall(), make_wall(), RMParms::Xsize, and RMParms::Ysize.
Referenced by layoutgen().
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.
maze | layout to rotate, will be free()d by this function. |
rotation | how to rotate:
|
RP | random map parameters. |
Definition at line 403 of file random_map.c.
References RMParms::Xsize, and RMParms::Ysize.
Referenced by generate_random_map().
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.
maze | layout to symmetrize. Will be free()d by this function. |
sym | how to make symetric, a Random map symetry value. |
RP | map parameters. |
Definition at line 327 of file random_map.c.
References connect_spirals(), RMParms::map_layout_style, NO_SYM, ROGUELIKE_LAYOUT, SPIRAL_LAYOUT, RMParms::symmetry_used, X_SYM, RMParms::Xsize, XY_SYM, Y_SYM, and RMParms::Ysize.
Referenced by layoutgen().
void write_map_parameters_to_string | ( | RMParms * | RP, |
char * | buf, | ||
int | bufsize | ||
) |
Creates a suitable message for exit from RP.
RP | parameters to convert to message. |
buf | buffer that will contain RP's values. |
bufsize | length of buf. |
Definition at line 689 of file random_map.c.
References RMParms::decoroptions, RMParms::decorstyle, RMParms::difficulty, RMParms::difficulty_given, RMParms::difficulty_increase, RMParms::doorstyle, RMParms::dungeon_depth, RMParms::dungeon_level, RMParms::dungeon_name, RMParms::exit_on_final_map, RMParms::exitstyle, RMParms::expand2x, RMParms::final_exit_archetype, RMParms::final_map, RMParms::floorstyle, RMParms::layoutoptions1, RMParms::layoutoptions2, RMParms::layoutoptions3, RMParms::layoutstyle, RMParms::monsterstyle, RMParms::multiple_floors, RMParms::orientation, RMParms::origin_x, RMParms::origin_y, RMParms::random_seed, snprintf(), RMParms::symmetry, RMParms::this_map, RMParms::treasureoptions, RMParms::treasurestyle, RMParms::wallstyle, RMParms::Xsize, and RMParms::Ysize.
Referenced by generate_random_map(), and place_exits().
void write_parameters_to_string | ( | char * | buf, |
int | xsize_n, | ||
int | ysize_n, | ||
const char * | wallstyle_n, | ||
const char * | floorstyle_n, | ||
const char * | monsterstyle_n, | ||
const char * | treasurestyle_n, | ||
const char * | layoutstyle_n, | ||
const char * | decorstyle_n, | ||
const char * | doorstyle_n, | ||
const char * | exitstyle_n, | ||
const char * | final_map_n, | ||
const char * | exit_on_final_map_n, | ||
const char * | this_map_n, | ||
int | layoutoptions1_n, | ||
int | layoutoptions2_n, | ||
int | layoutoptions3_n, | ||
int | symmetry_n, | ||
int | dungeon_depth_n, | ||
int | dungeon_level_n, | ||
int | difficulty_n, | ||
int | difficulty_given_n, | ||
int | decoroptions_n, | ||
int | orientation_n, | ||
int | origin_x_n, | ||
int | origin_y_n, | ||
int | random_seed_n, | ||
int | treasureoptions_n, | ||
float | difficulty_increase | ||
) |
Converts various parameters to string suitable for an exit message.
buf | buffer to write to. |
xsize_n | |
ysize_n | |
wallstyle_n | |
floorstyle_n | |
monsterstyle_n | |
treasurestyle_n | |
layoutstyle_n | |
decorstyle_n | |
doorstyle_n | |
exitstyle_n | |
final_map_n | |
exit_on_final_map_n | |
this_map_n | |
layoutoptions1_n | |
layoutoptions2_n | |
layoutoptions3_n | |
symmetry_n | |
dungeon_depth_n | |
dungeon_level_n | |
difficulty_n | |
difficulty_given_n | |
decoroptions_n | |
orientation_n | |
origin_x_n | |
origin_y_n | |
random_seed_n | |
treasureoptions_n | |
difficulty_increase | random map parameters. |
Definition at line 877 of file random_map.c.
References snprintf().
Referenced by place_special_exit().