Crossfire Server, Trunk
Random house generation module

This module links unused exits to random maps. The random map parameters vary based on the map it is in, but each exit will always use the same random seed to have the same layout and content. More...

Files

file  random_house_generator.cpp
 

Data Structures

struct  house_zone_struct
 

Functions

static void add_exit_to_item (object *exit, const house_zone_struct *zone, const mapstruct *map)
 
static void add_exits_to_map (const mapstruct *map)
 
static int cfrhg_globalEventListener (int *type,...)
 
static int get_exit_seed (const object *exit, const mapstruct *map)
 
static const house_zone_structget_map_zone (const mapstruct *map)
 
static int is_suitable_exit (object *exit)
 
void random_house_generator_close ()
 
void random_house_generator_init (Settings *settings)
 

Variables

static event_registration eg
 
const char * house_zone_struct::mappath
 
const char * house_zone_struct::monsterstyle
 
static const house_zone_struct zones []
 

Detailed Description

This module links unused exits to random maps. The random map parameters vary based on the map it is in, but each exit will always use the same random seed to have the same layout and content.

Exits will only point to a random map if both their slaying and msg fields are empty.

Todo:
  • make more parameters vary based on maps
  • add exits to all towns

Function Documentation

◆ add_exit_to_item()

static void add_exit_to_item ( object exit,
const house_zone_struct zone,
const mapstruct map 
)
static

Change an empty exit to point to a random map.

Parameters
exitexit to alter.
zonezone we're part of, to know the random map parameters.
mapmap the exit is on.

Definition at line 135 of file random_house_generator.cpp.

References add_string(), get_exit_seed(), disinfect::map, MAX_BUF, house_zone_struct::monsterstyle, object::msg, roll-o-matic::params, and object::slaying.

Referenced by add_exits_to_map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_exits_to_map()

static void add_exits_to_map ( const mapstruct map)
static

Checks if the map should be processed, and if so process it.

Parameters
mapmap to work on.

Definition at line 161 of file random_house_generator.cpp.

References add_exit_to_item(), FOR_MAP_FINISH, FOR_MAP_PREPARE, get_map_zone(), is_suitable_exit(), disinfect::map, MAP_HEIGHT, MAP_WIDTH, diamondslots::x, and diamondslots::y.

Referenced by cfrhg_globalEventListener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cfrhg_globalEventListener()

static int cfrhg_globalEventListener ( int *  type,
  ... 
)
static

Global server event handling. Only uses EVENT_MAPLOAD.

Parameters
typeunused.
Returns
0.

Definition at line 185 of file random_house_generator.cpp.

References add_exits_to_map(), make_face_from_files::args, EVENT_MAPLOAD, disinfect::map, and is_valid_types_gen::type.

Referenced by random_house_generator_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_exit_seed()

static int get_exit_seed ( const object exit,
const mapstruct map 
)
static

Get the random map seed. Will always yield the same value for the same (position included) exit.

Parameters
exitexit to get the seed of.
mapmap the exit is on.
Returns
random seed.

Definition at line 109 of file random_house_generator.cpp.

References object::arch, HUGE_BUF, make_face_from_files::int, disinfect::map, archetype::name, ring_occidental_mages::r, object::x, and object::y.

Referenced by add_exit_to_item().

+ Here is the caller graph for this function:

◆ get_map_zone()

static const house_zone_struct* get_map_zone ( const mapstruct map)
static

Get the random map parameters of a map.

Parameters
mapmap to get the zone of.
Returns
NULL if the map shouldn't be processed, else its parameters.

Definition at line 71 of file random_house_generator.cpp.

References disinfect::map, house_zone_struct::mappath, and zones.

Referenced by add_exits_to_map().

+ Here is the caller graph for this function:

◆ is_suitable_exit()

static int is_suitable_exit ( object exit)
static

Should we add a random map to this exit?

Parameters
exitexit to check.
Returns
1 if a map should be set, 0 else.

Definition at line 89 of file random_house_generator.cpp.

References EXIT, object::msg, object::slaying, and object::type.

Referenced by add_exits_to_map().

+ Here is the caller graph for this function:

◆ random_house_generator_close()

void random_house_generator_close ( )

Close the module.

Definition at line 220 of file random_house_generator.cpp.

References eg, EVENT_MAPLOAD, and events_unregister_global_handler().

+ Here is the call graph for this function:

◆ random_house_generator_init()

void random_house_generator_init ( Settings settings)

Module initialisation.

Definition at line 210 of file random_house_generator.cpp.

References cfrhg_globalEventListener(), Settings::disabled_plugins, eg, EVENT_MAPLOAD, events_register_global_handler(), and settings.

+ Here is the call graph for this function:

Variable Documentation

◆ eg

◆ mappath

const char* house_zone_struct::mappath

Full map path.

Definition at line 45 of file random_house_generator.cpp.

Referenced by get_map_zone().

◆ monsterstyle

const char* house_zone_struct::monsterstyle

Style of monsters.

Definition at line 46 of file random_house_generator.cpp.

Referenced by add_exit_to_item().

◆ zones

const house_zone_struct zones[]
static
Initial value:
= {
{ "/world/world_104_115", "city" },
{ "/world/world_105_115", "city" },
{ "/world/world_104_116", "city" },
{ "/world/world_105_116", "city" },
{ "/world/world_122_116", "city" },
{ "/world/world_121_116", "city" },
{ "/world/world_122_117", "city" },
{ "/world/world_121_117", "city" },
{ NULL, NULL }
}

Maps we work on.

Definition at line 50 of file random_house_generator.cpp.

Referenced by add_npc_to_random_map(), and get_map_zone().