Crossfire Server, Trunk  1.75.0
room_gen_crawl.cpp File Reference

Crossfire – cooperative multi-player graphical RPG and adventure game. More...

#include <queue>
#include <stdlib.h>
#include <global.h>
#include <random_map.h>
+ Include dependency graph for room_gen_crawl.cpp:

Go to the source code of this file.

Macros

#define MAP_CRAWL_ALL   15
 
#define MAP_CRAWL_EAST   2
 
#define MAP_CRAWL_NONE   0
 
#define MAP_CRAWL_NORTH   4
 
#define MAP_CRAWL_SOUTH   8
 
#define MAP_CRAWL_WEST   1
 

Functions

char ** map_gen_crawl (int xsize, int ysize, int iter, int hallway)
 Generator of the crawl maze. More...
 
static void print_debug_paths (uint8_t *paths, int x_eff, int y_eff)
 Function for helping to ensure parity between the compartmentalized and final versions of the map. More...
 

Detailed Description

Crossfire – cooperative multi-player graphical RPG and adventure game.

Copyright (c) 2013-2026 The Crossfire Development Team Copyright (c) 1999-2013 Mark Wedel and the Crossfire Development Team Copyright (c) 1992 Frank Tore Johansen

Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. For details, please see COPYING and LICENSE.

The authors can be reached via e-mail at cross.nosp@m.fire.nosp@m.@meta.nosp@m.lfor.nosp@m.ge.or.nosp@m.g.

Crawl room generator

Maze sprawls out and have many dead-ends. Uses an algorithm that differs from the classic maze generator. Loosely inspired by the dungeon layouts of Dragon Warrior Monsters 1.

TODO: Show what crawl mazes look like

Definition in file room_gen_crawl.cpp.

Macro Definition Documentation

◆ MAP_CRAWL_ALL

#define MAP_CRAWL_ALL   15

Definition at line 39 of file room_gen_crawl.cpp.

◆ MAP_CRAWL_EAST

#define MAP_CRAWL_EAST   2

Definition at line 35 of file room_gen_crawl.cpp.

◆ MAP_CRAWL_NONE

#define MAP_CRAWL_NONE   0

Definition at line 33 of file room_gen_crawl.cpp.

◆ MAP_CRAWL_NORTH

#define MAP_CRAWL_NORTH   4

Definition at line 36 of file room_gen_crawl.cpp.

◆ MAP_CRAWL_SOUTH

#define MAP_CRAWL_SOUTH   8

Definition at line 37 of file room_gen_crawl.cpp.

◆ MAP_CRAWL_WEST

#define MAP_CRAWL_WEST   1

Definition at line 34 of file room_gen_crawl.cpp.

Function Documentation

◆ map_gen_crawl()

char** map_gen_crawl ( int  xsize,
int  ysize,
int  iter,
int  hallway 
)

Generator of the crawl maze.

Parameters
xsize
ysizelayout size. Unused fractions from wide hallways will be evenly distributed at the edges. For size 1 hallways, odd numbers are best for use of space. For size 2 hallways, one more than a multiple of 3 works best (43, 46, 49, etc) For size 3 hallways, one more than a multiple of 4 works best (41, 45, 49, etc)
iterRecursion flag. If fewer than 1/5 of the map is filled, we try again once. If it fails again, just return the second try. Set to nonzero on the retry to denote it as such.
hallwayWidth of the hallway path inside the maze. Should be 1-3 under most circumstances. Larger values require large layouts to compensate.
Returns
Layout, as a two-dimensional array of characters. Must be freed by the caller.

Definition at line 139 of file room_gen_crawl.cpp.

References MAP_CRAWL_ALL, MAP_CRAWL_EAST, MAP_CRAWL_NONE, MAP_CRAWL_NORTH, MAP_CRAWL_SOUTH, MAP_CRAWL_WEST, paths, and RANDOM.

Referenced by layoutgen().

+ Here is the caller graph for this function:

◆ print_debug_paths()

static void print_debug_paths ( uint8_t *  paths,
int  x_eff,
int  y_eff 
)
static

Function for helping to ensure parity between the compartmentalized and final versions of the map.

Prints the layout of the internal paths determination.

Parameters
pathsThe array of path data to display.
x_effThe effective number of hallways we could have in the x direction.
y_effThe effective number of hallways we could have in the y direction.

Definition at line 55 of file room_gen_crawl.cpp.

References MAP_CRAWL_EAST, MAP_CRAWL_NONE, MAP_CRAWL_NORTH, MAP_CRAWL_SOUTH, MAP_CRAWL_WEST, and paths.