Crossfire Server  1.75.0
room_gen_spiral.cpp File Reference

The spiral room generator: More...

#include "global.h"
#include <stdlib.h>
#include "random_map.h"
#include <math.h>

Go to the source code of this file.

Macros

#define FINE_SPIRAL   2
 uses the min. More...
 
#define FIT_SPIRAL   4
 scale to a rectangular region, not square More...
 
#define MAX(x, y)   (((x) < (y)) ? (y) : (x))
 
#define MAX_FINE   .454545
 
#define MAX_SPIRAL_OPT   8
 this should be 2x the last real option More...
 
#define MIN(x, y)   (((x) < (y)) ? (x) : (y))
 
#define RANDOM_OPTIONS   0
 Pick random options below. More...
 
#define REGULAR_SPIRAL   1
 Regular spiral–distance increases constantly. More...
 

Functions

void connect_spirals (int xsize, int ysize, int sym, char **layout)
 Connects disjoint spirals which may result from the symmetrization process. More...
 
char ** map_gen_spiral (int xsize, int ysize, int option, int _unused_layers)
 Generates a spiral layout. More...
 
int surround_check (char **maze, int i, int j, int xsize, int ysize)
 Checks free spots around a spot. More...
 

Detailed Description

The spiral room generator:

Todo:
Check if MAX_FINE can't be removed.

Definition in file room_gen_spiral.cpp.

Macro Definition Documentation

◆ MAX

#define MAX (   x,
 
)    (((x) < (y)) ? (y) : (x))

Definition at line 44 of file room_gen_spiral.cpp.

◆ MAX_FINE

#define MAX_FINE   .454545

Definition at line 47 of file room_gen_spiral.cpp.

Referenced by map_gen_spiral().

◆ MIN

#define MIN (   x,
 
)    (((x) < (y)) ? (x) : (y))

Definition at line 41 of file room_gen_spiral.cpp.

Referenced by map_gen_spiral().

Function Documentation

◆ connect_spirals()

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 159 of file room_gen_spiral.cpp.

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

Referenced by symmetrize_layout().

◆ map_gen_spiral()

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

Generates a spiral layout.

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

Definition at line 62 of file room_gen_spiral.cpp.

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

Referenced by layoutgen().

◆ surround_check()

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 280 of file rogue_layout.cpp.

Referenced by connect_spirals(), and roguelike_layout_gen().