Crossfire Server, Branches 1.12  R18729
rogue_layout.c File Reference
#include <global.h>
#include <random_map.h>
#include <math.h>
+ Include dependency graph for rogue_layout.c:

Go to the source code of this file.

Data Structures

struct  Room
 

Functions

char ** roguelike_layout_gen (int xsize, int ysize, int options)
 
static void roguelike_link_rooms (Room *Rooms, char **maze, int xsize, int ysize)
 
static void roguelike_make_rooms (Room *Rooms, char **maze, int options)
 
static int roguelike_place_room (Room *Rooms, int xsize, int ysize, int nrooms)
 
int surround_check (char **layout, int i, int j, int Xsize, int Ysize)
 

Detailed Description

Rogue/nethack-like layout generation

Definition in file rogue_layout.c.

Function Documentation

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 69 of file rogue_layout.c.

References 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:

static void roguelike_link_rooms ( Room Rooms,
char **  maze,
int  xsize,
int  ysize 
)
static

Link generated rooms with corridors.

Parameters
Roomsroom list.
mazemaze.
xsize
ysizemaze size.

Definition at line 300 of file rogue_layout.c.

References MAX, MIN, Room::x, and Room::y.

Referenced by roguelike_layout_gen().

+ Here is the caller graph for this function:

static void roguelike_make_rooms ( Room Rooms,
char **  maze,
int  options 
)
static

Write all the rooms into the maze.

Parameters
Roomslist of rooms to write.
mazewhere to write to.
options2 to have circular rooms, 1 for rectanglar ones, another value for random choice.

Definition at line 254 of file rogue_layout.c.

References Room::ax, Room::ay, Room::sx, Room::sy, Room::x, and Room::y.

Referenced by roguelike_layout_gen().

+ Here is the caller graph for this function:

static int roguelike_place_room ( Room Rooms,
int  xsize,
int  ysize,
int  nrooms 
)
static

Place a room in the layout.

Parameters
Roomslist of existing rooms, new room will be added to it.
xsize
ysizelayout size.
nroomswanted number of room, used to determine size.
Returns
0 if no room could be generated, 1 else.

Definition at line 180 of file rogue_layout.c.

References Room::ax, Room::ay, isqrt(), Room::sx, Room::sy, Room::x, Room::y, Room::zx, and Room::zy.

Referenced by roguelike_layout_gen().

+ Here is the call graph for this function:

+ 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 44 of file rogue_layout.c.

Referenced by connect_spirals(), and roguelike_layout_gen().

+ Here is the caller graph for this function: