Crossfire Server, Trunk  R20513
Data Structures | Functions
rogue_layout.c File Reference

Rogue/NetHack style room generation. More...

#include "global.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include "random_map.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)
 Actually make the rogue layout. More...
 
static void roguelike_link_rooms (Room *Rooms, char **maze, int xsize, int ysize)
 Link generated rooms with corridors. More...
 
static void roguelike_make_rooms (Room *Rooms, char **maze, int options)
 Write all the rooms into the maze. More...
 
static int roguelike_place_room (Room *Rooms, int xsize, int ysize, int nrooms)
 Place a room in the layout. More...
 
int surround_check (char **layout, int i, int j, int Xsize, int Ysize)
 Checks free spots around a spot. More...
 

Detailed Description

Rogue/NetHack style room 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 332 of file rogue_layout.c.

References RANDOM, 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 180 of file rogue_layout.c.

References MAX, MIN, RANDOM, 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 132 of file rogue_layout.c.

References Room::ax, Room::ay, RANDOM, 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 53 of file rogue_layout.c.

References Room::ax, Room::ay, isqrt(), RANDOM, 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 303 of file rogue_layout.c.

Referenced by connect_spirals(), and roguelike_layout_gen().

Here is the caller graph for this function: