Crossfire Server, Branch 1.12  R12190
Data Structures | Files | Typedefs | Functions | Variables
Random house generation plugin

This plugin links unused exits to random maps. More...

Data Structures

struct  house_zone_struct
 Link between a map and the exits to generate for it. More...

Files

file  cfrhg.c
 

This file is part of the random house generation plugin.


file  cfrhg.h
 

This file is part of the random house generation plugin.


Typedefs

typedef struct house_zone_struct house_zone_struct
 Link between a map and the exits to generate for it.

Functions

static void add_exit_to_item (object *exit, const house_zone_struct *zone, const mapstruct *map)
 Change an empty exit to point to a random map.
static void add_exits_to_map (const mapstruct *map)
 Checks if the map should be processed, and if so process it.
CF_PLUGIN void * cfrhg_globalEventListener (int *type,...)
 Global server event handling.
CF_PLUGIN int cfrhg_runPluginCommand (object *op, char *params)
 Unused.
CF_PLUGIN int closePlugin (void)
 Unloading of plugin.
CF_PLUGIN void * eventListener (int *type,...)
 Unused.
static int get_exit_seed (const object *exit, const mapstruct *map)
 Get the random map seed.
static const house_zone_structget_map_zone (const mapstruct *map)
 Get the random map parameters of a map.
CF_PLUGIN void * getPluginProperty (int *type,...)
 Get the plugin identification or full name.
CF_PLUGIN int initPlugin (const char *iversion, f_plug_api gethooksptr)
 Plugin initialization.
static int is_suitable_exit (object *exit)
 Should we add a random map to this exit?
CF_PLUGIN int postInitPlugin (void)
 Plugin initialisation.

Variables

static const house_zone_struct zones []
 Maps we work on.

Detailed Description

This plugin 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

Typedef Documentation

Link between a map and the exits to generate for it.


Function Documentation

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 150 of file cfrhg.c.

References cf_object_set_string_property(), CFAPI_OBJECT_PROP_MESSAGE, CFAPI_OBJECT_PROP_SLAYING, get_exit_seed(), MAX_BUF, house_zone_struct::monsterstyle, and snprintf().

Referenced by add_exits_to_map().

Here is the call graph for this function:

Here is the caller graph for this function:

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 176 of file cfrhg.c.

References add_exit_to_item(), GET_MAP_OB, get_map_zone(), is_suitable_exit(), MAP_HEIGHT, and MAP_WIDTH.

Referenced by cfrhg_globalEventListener().

Here is the call graph for this function:

Here is the caller graph for this function:

CF_PLUGIN void* cfrhg_globalEventListener ( int *  type,
  ... 
)

Global server event handling.

Only uses EVENT_MAPLOAD.

Parameters:
typeunused.
Returns:
pointer to integer with value 0.

Definition at line 204 of file cfrhg.c.

References add_exits_to_map(), and EVENT_MAPLOAD.

Referenced by postInitPlugin().

Here is the call graph for this function:

Here is the caller graph for this function:

CF_PLUGIN int cfrhg_runPluginCommand ( object *  op,
char *  params 
)

Unused.

Parameters:
opunused.
paramsunused.
Returns:
-1.

Definition at line 296 of file cfrhg.c.

CF_PLUGIN int closePlugin ( void  )

Unloading of plugin.

Close the plugin.

Returns:
0.

Definition at line 318 of file cfrhg.c.

References cf_log(), llevDebug, and PLUGIN_VERSION.

Here is the call graph for this function:

CF_PLUGIN void* eventListener ( int *  type,
  ... 
)

Unused.

Handles an object-related event.

Parameters:
typeunused.
Returns:
NULL.
Todo:
build from current map's path, probably

Definition at line 233 of file cfrhg.c.

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 124 of file cfrhg.c.

References mapdef::path, and snprintf().

Referenced by add_exit_to_item().

Here is the call graph for this function:

Here is the caller graph for this function:

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 86 of file cfrhg.c.

References house_zone_struct::mappath, and mapdef::path.

Referenced by add_exits_to_map().

Here is the caller graph for this function:

CF_PLUGIN void* getPluginProperty ( int *  type,
  ... 
)

Get the plugin identification or full name.

Gets a plugin property.

Parameters:
typeunused.
Returns:
NULL.

Definition at line 261 of file cfrhg.c.

References PLUGIN_NAME, PLUGIN_VERSION, and snprintf().

Here is the call graph for this function:

CF_PLUGIN int initPlugin ( const char *  iversion,
f_plug_api  gethooksptr 
)

Plugin initialization.

Plugin initialisation function.

Parameters:
iversionserver version.
gethooksptrfunction to get hooks.
Returns:
0.

Definition at line 246 of file cfrhg.c.

References cf_init_plugin(), cf_log(), llevDebug, and PLUGIN_VERSION.

Here is the call graph for this function:

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 104 of file cfrhg.c.

References cf_object_get_int_property(), cf_object_get_sstring_property(), CFAPI_OBJECT_PROP_MESSAGE, CFAPI_OBJECT_PROP_SLAYING, CFAPI_OBJECT_PROP_TYPE, and EXIT.

Referenced by add_exits_to_map().

Here is the call graph for this function:

Here is the caller graph for this function:

CF_PLUGIN int postInitPlugin ( void  )

Plugin initialisation.

Plugin was initialized, now to finish.

Returns:
0.

Definition at line 305 of file cfrhg.c.

References cf_log(), cf_system_register_global_event(), cfrhg_globalEventListener(), EVENT_MAPLOAD, llevDebug, PLUGIN_NAME, and PLUGIN_VERSION.

Here is the call graph for this function:


Variable Documentation

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 65 of file cfrhg.c.

Referenced by add_npc_to_random_map().