Crossfire Server, Trunk
rogue_layout.c File Reference
#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

static int rn2 (int x)
 
char ** roguelike_layout_gen (int xsize, int ysize, int _unused_options, int _unused_layers)
 
static void roguelike_link_rooms (Room *Rooms, char **maze)
 
static void roguelike_make_rooms (Room *Rooms, char **maze)
 
static int roguelike_place_room (Room *Rooms, int xsize, int ysize)
 
int surround_check (char **layout, int i, int j, int Xsize, int Ysize)
 

Detailed Description

Rogue/NetHack style room generation.

Definition in file rogue_layout.c.

Function Documentation

◆ rn2()

static int rn2 ( int  x)
static

Definition at line 41 of file rogue_layout.c.

References RANDOM, and diamondslots::x.

Referenced by roguelike_place_room().

+ Here is the caller graph for this function:

◆ roguelike_layout_gen()

char** roguelike_layout_gen ( int  xsize,
int  ysize,
int  _unused_options,
int  _unused_layers 
)

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.
_unused_optionsunused.
_unused_layersunused.
Returns
generated layout.

Definition at line 309 of file rogue_layout.c.

References RANDOM, roguelike_link_rooms(), roguelike_make_rooms(), roguelike_place_room(), surround_check(), nlohmann::detail::void(), 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:

◆ roguelike_link_rooms()

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

Link generated rooms with corridors.

Parameters
Roomsroom list.
mazemaze.

Definition at line 157 of file rogue_layout.c.

References MAX, MIN, RANDOM, diamondslots::x, Room::x, guild_entry::x1, diamondslots::y, Room::y, and guild_entry::y1.

Referenced by roguelike_layout_gen().

+ Here is the caller graph for this function:

◆ roguelike_make_rooms()

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

Write all the rooms into the maze.

Parameters
Roomslist of rooms to write.
mazewhere to write to.

Definition at line 127 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:

◆ roguelike_place_room()

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

Place a room in the layout.

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

Definition at line 55 of file rogue_layout.c.

References Room::ax, Room::ay, RANDOM, rn2(), 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:

◆ 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.c.

Referenced by connect_spirals(), and roguelike_layout_gen().

+ Here is the caller graph for this function: