Crossfire Server, Trunk
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include "global.h"
#include "maze_gen.h"
#include "random_map.h"
#include "room_gen.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, sstring reset_group) |
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) |
StringBuffer * | write_map_parameters_to_string (const RMParms *RP) |
Routines for random map generation.
Definition in file random_map.cpp.
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 558 of file random_map.cpp.
References surround_flag2(), diamondslots::x, RMParms::Xsize, diamondslots::y, 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 697 of file random_map.cpp.
References RANDOM, 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 43 of file random_map.cpp.
References RMParms::Xsize, and RMParms::Ysize.
Referenced by generate_random_map(), and layoutgen().
mapstruct* generate_random_map | ( | const char * | OutFileName, |
RMParms * | RP, | ||
char ** | use_layout, | ||
sstring | reset_group | ||
) |
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. |
reset_group | if not NULL, the reset group this map will be part of, else the path will be used. |
Definition at line 75 of file random_map.cpp.
References add_string(), apply_auto_fix(), buf, calculate_difficulty(), change_map_light(), RMParms::darkness, RMParms::decoroptions, RMParms::decorstyle, RMParms::difficulty, mapstruct::difficulty, RMParms::difficulty_given, RMParms::difficulty_increase, RMParms::doorstyle, dump_layout(), RMParms::dungeon_level, RMParms::exitstyle, RMParms::expand2x, RMParms::floorstyle, make_face_from_files::int, mapstruct::last_reset_time, layoutgen(), make_map_floor(), make_map_walls(), RMParms::map_layout_style, MIN_RANDOM_MAP_SIZE, RMParms::monsterstyle, mapstruct::msg, RMParms::orientation, mapstruct::outdoor, mapstruct::path, place_exits(), place_monsters(), place_specials_in_map(), place_treasure(), put_decor(), put_doors(), RANDOM, RMParms::random_seed, RMParms::region, mapstruct::region, mapstruct::reset_group, ROGUELIKE_LAYOUT, rotate_layout(), safe_strncpy, seconds(), set_darkness_map(), SRANDOM, stringbuffer_finish(), 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 generate_map().
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 225 of file random_map.cpp.
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().
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 658 of file random_map.cpp.
References diamondslots::x, and diamondslots::y.
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 510 of file random_map.cpp.
References can_make_wall(), make_wall(), RANDOM, 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 441 of file random_map.cpp.
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 360 of file random_map.cpp.
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().
StringBuffer* write_map_parameters_to_string | ( | const RMParms * | RP | ) |
Creates a suitable message for exit from RP.
RP | parameters to convert to message. |
Definition at line 749 of file random_map.cpp.
References buf, RMParms::cheststyle, RMParms::darkness, 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::layoutstyle, RMParms::link_source_map, RMParms::monsterstyle, RMParms::multiple_floors, RMParms::orientation, RMParms::origin_x, RMParms::origin_y, RMParms::outdoor, RMParms::random_seed, stringbuffer_append_printf(), stringbuffer_new(), RMParms::symmetry, RMParms::this_map, RMParms::treasureoptions, RMParms::treasurestyle, RMParms::wallstyle, RMParms::Xsize, and RMParms::Ysize.
Referenced by generate_random_map(), place_exits(), place_special_exit(), CREMapInformationManager::storeCache(), and CRERandomMapPanel::updateItem().