Atrinik Server  4.0
Data Structures | Functions
rogue_layout.c File Reference
#include <global.h>

Go to the source code of this file.

Data Structures

struct  Room
 

Functions

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

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
xsizeX size of the wanted layout size.
ysizeY size of the wanted layout size.
options2 to have circular rooms, 1 for rectangular ones, another value for random choice.
Returns
Generated layout.

Definition at line 108 of file rogue_layout.c.

static void roguelike_link_rooms ( Room Rooms,
char **  maze 
)
static

Link generated rooms with corridors.

Parameters
RoomsRoom list.
mazeMaze.
xsizeX size of the maze.
ysizeY size of the maze.

Definition at line 364 of file rogue_layout.c.

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 rectangular ones, another value for random choice.

Definition at line 316 of file rogue_layout.c.

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.
xsizeX size of the layout.
ysizeY size of the layout.
nroomsWanted number of room, used to determine size.
Returns
0 if no room could be generated, 1 otherwise.

Definition at line 230 of file rogue_layout.c.

int surround_check ( char **  layout,
int  i,
int  j,
int  Xsize,
int  Ysize 
)

Checks free spots around a spot.

Parameters
layoutMap layout.
iX coordinate to check.
jY coordinate to check.
XsizeX size of the layout.
YsizeY size 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

Definition at line 71 of file rogue_layout.c.