Atrinik Server 2.5
Functions
random_maps/random_map.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

void dump_layout (char **layout, RMParms *RP)
mapstructgenerate_random_map (char *OutFileName, RMParms *RP)
char ** layoutgen (RMParms *RP)
char ** symmetrize_layout (char **maze, int sym, RMParms *RP)
char ** rotate_layout (char **maze, int rotation, RMParms *RP)
void roomify_layout (char **maze, RMParms *RP)
int can_make_wall (char **maze, int dx, int dy, int dir, RMParms *RP)
int make_wall (char **maze, int x, int y, int dir)
void doorify_layout (char **maze, RMParms *RP)
void write_map_parameters_to_string (char *buf, RMParms *RP)

Detailed Description

Random map generation main routines.

Todo:
Explain process, layout signs (# C D < >) and such.

Definition in file random_map.c.


Function Documentation

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.
dxX coordinate to check
dyY coordinate to check
dirDirection:
  • 0: Horizontally.
  • 1: Vertically.
RPRandom map parameters.
Returns:
-1 if wall can't be made, possibly wall length otherwise.

Definition at line 647 of file random_map.c.

void doorify_layout ( char **  maze,
RMParms RP 
)

Puts doors at appropriate locations in a layout.

Parameters:
mazeLayout.
RPRandom map parameters.

Definition at line 829 of file random_map.c.

void dump_layout ( char **  layout,
RMParms RP 
)

Dumps specified layout using printf().

Parameters:
layoutThe layout to dump.
RPLayout parameters.

Definition at line 37 of file random_map.c.

mapstruct* generate_random_map ( char *  OutFileName,
RMParms RP 
)

Main random map routine. Generates a random map based on specified parameters.

Parameters:
OutFileNameThe path the map should have.
RPParameters for generation.
Returns:
Pointer to the generated map.

Definition at line 68 of file random_map.c.

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:
The built layout, must be freed by caller.

Definition at line 162 of file random_map.c.

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.
xX position where to put the door.
yY position where to put the door.
dirWall direction:
  • 0: Horizontally.
  • 1: Vertically.
Returns:
Always returns 0.

Definition at line 784 of file random_map.c.

void roomify_layout ( char **  maze,
RMParms RP 
)

Take a layout and make some rooms in it. Works best on onions.

Parameters:
mazeLayout to alter.
RPRandom map parameters.

Definition at line 588 of file random_map.c.

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 freed by this function.
rotationHow to rotate:
  • 0: Don't do anything.
  • 1: Rotate 90 degrees clockwise.
  • 2: Rotate 180 degrees.
  • 3: Rotate 90 degrees counter-clockwise.
RPRandom map parameters.
Returns:
New layout, must be freed be caller. NULL if invalid rotation.

Definition at line 490 of file random_map.c.

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.

Parameters:
mazeLayout to symmetrize. Will be freed by this function.
symhow to make symmetric, a Random map symmetry value.
RPRandom map parameters.
Returns:
New layout, must be freed by caller.

Definition at line 386 of file random_map.c.

void write_map_parameters_to_string ( char *  buf,
RMParms RP 
)

Creates a suitable message for exit from RP.

Parameters:
bufBuffer that will contain RP's values.
RPParameters to convert to message.

Definition at line 890 of file random_map.c.