Crossfire Server, Branch 1.12
R12190
|
Region management. More...
Go to the source code of this file.
Functions | |
static void | assign_region_parents (void) |
Links child with their parent from the parent_name field. | |
object * | get_jail_exit (object *op) |
Returns an object which is an exit through which the player represented by op should be sent in order to be imprisoned. | |
const char * | get_name_of_region_for_map (const mapstruct *m) |
Gets the name of a region for a map. | |
region * | get_region_by_map (mapstruct *m) |
Gets a region from a map. | |
region * | get_region_by_name (const char *region_name) |
Gets a region by name. | |
region * | get_region_from_string (const char *name) |
Tries to find a region that 'name' corresponds to. | |
const char * | get_region_longname (const region *r) |
Gets the longname of a region. | |
const char * | get_region_msg (const region *r) |
Gets a message for a region. | |
region * | get_region_struct (void) |
Allocates and zeros a region struct, this isn't free()'d anywhere, so might be a memory leak, but it shouldn't matter too much since it isn't called that often.... | |
void | init_regions (void) |
Initialises regions from the regions file. | |
static void | parse_regions (FILE *fp) |
Reads/parses the region file, and copies into a linked list of region structs. | |
int | region_is_child_of_region (const region *child, const region *r) |
Checks if a region is a child of another. |
Region management.
A region is a group of maps. It includes a "parent" region.
Definition in file region.c.
static void assign_region_parents | ( | void | ) | [static] |
Links child with their parent from the parent_name field.
Definition at line 469 of file region.c.
References first_region, get_region_by_name(), llevDebug, LOG(), regiondef::next, regiondef::parent, regiondef::parent_name, and region_count.
Referenced by init_regions().
object* get_jail_exit | ( | object * | op | ) |
Returns an object which is an exit through which the player represented by op should be sent in order to be imprisoned.
If there is no suitable place to which an exit can be constructed, then NULL will be returned. The caller is responsible for freeing the object created by this function.
op | Object we want to jail. Must be a player. |
Definition at line 272 of file region.c.
References add_string(), EXIT_PATH, EXIT_X, EXIT_Y, FLAG_DAMNED, get_object(), get_region_by_map(), regiondef::jailmap, regiondef::jailx, regiondef::jaily, llevDebug, llevError, LOG(), regiondef::name, regiondef::parent, PLAYER, and SET_FLAG.
Referenced by command_arrest().
const char* get_name_of_region_for_map | ( | const mapstruct * | m | ) |
Gets the name of a region for a map.
Since we won't assume all maps have a region set properly, we need an explicit check that it is, this is much nicer here than scattered throughout the map code.
m | map |
Definition at line 103 of file region.c.
References regiondef::fallback, first_region, llevInfo, LOG(), regiondef::name, mapdef::name, regiondef::next, and mapdef::region.
Referenced by current_region_info(), get_region_by_map(), and get_who_escape_code_value().
region* get_region_by_map | ( | mapstruct * | m | ) |
Gets a region from a map.
m | map we want the region of. |
Definition at line 85 of file region.c.
References get_name_of_region_for_map(), and get_region_by_name().
Referenced by add_region_link(), cfapi_map_get_map_property(), command_whereabouts(), current_map_info(), enter_random_map(), enter_random_template_map(), get_jail_exit(), get_who_escape_code_value(), list_players(), and process_map().
region* get_region_by_name | ( | const char * | region_name | ) |
Gets a region by name.
Used by the map parsing code.
region_name | name of region. |
Definition at line 57 of file region.c.
References regiondef::fallback, first_region, llevDebug, llevInfo, LOG(), regiondef::name, and regiondef::next.
Referenced by assign_region_parents(), current_region_info(), get_region_by_map(), and load_map_header().
region* get_region_from_string | ( | const char * | name | ) |
Tries to find a region that 'name' corresponds to.
It looks, in order, for:
name | region we're searching. Can be NULL. |
Definition at line 132 of file region.c.
References first_region, regiondef::longname, regiondef::name, regiondef::next, regiondef::parent, and strcasecmp().
Referenced by command_who().
const char* get_region_longname | ( | const region * | r | ) |
Gets the longname of a region.
The longname of a region is not a required field, any given region may want to not set it and use the parent's one instead.
r | region we're searching the longname. |
Definition at line 229 of file region.c.
References get_region_longname(), llevDebug, LOG(), regiondef::longname, regiondef::name, and regiondef::parent.
Referenced by command_whereabouts(), current_map_info(), current_region_info(), get_region_longname(), get_who_escape_code_value(), write_map_page(), write_region_index(), and write_region_page().
const char* get_region_msg | ( | const region * | r | ) |
Gets a message for a region.
r | region. Can't be NULL. |
Definition at line 250 of file region.c.
References get_region_msg(), llevDebug, LOG(), regiondef::msg, regiondef::name, and regiondef::parent.
Referenced by current_region_info(), get_region_msg(), and write_region_page().
region* get_region_struct | ( | void | ) |
Allocates and zeros a region struct, this isn't free()'d anywhere, so might be a memory leak, but it shouldn't matter too much since it isn't called that often....
Definition at line 336 of file region.c.
References CALLOC, fatal(), and OUT_OF_MEMORY.
Referenced by main(), and parse_regions().
void init_regions | ( | void | ) |
Initialises regions from the regions file.
Definition at line 301 of file region.c.
References assign_region_parents(), close_and_delete(), Settings::datadir, first_region, llevDebug, llevError, LOG(), Settings::mapdir, MAX_BUF, open_and_uncompress(), parse_regions(), Settings::regions, settings, and snprintf().
Referenced by init_beforeplay(), and main().
static void parse_regions | ( | FILE * | fp | ) | [static] |
Reads/parses the region file, and copies into a linked list of region structs.
fp | opened file to read from. |
Definition at line 355 of file region.c.
References first_region, get_region_struct(), HUGE_BUF, llevError, LOG(), MAX_BUF, regiondef::next, and strdup_local().
Referenced by init_regions().
int region_is_child_of_region | ( | const region * | child, |
const region * | r | ||
) |
Checks if a region is a child of another.
child | region we want to test. |
r | potential parent. |
Definition at line 201 of file region.c.
References regiondef::name, regiondef::parent, and region_is_child_of_region().
Referenced by list_players(), and region_is_child_of_region().