[Package Index | Mudlib Index | Effect Index]

File /obj/handlers/terrain_handler.c

This is the terrain handler method documentation. For a more general introduction to the terrain handler, please see the help for terrains.

See also:
help::terrains .c

Written by Sin, Turrican and others...

Inherits

This class inherits the following classes /std/object.c

Includes

This class includes the following files /include/terrain.h, /include/map.h and /include/dirs.h

Method index

Public Functions

These are functions that everyone can access.

add_fixed_location
int add_fixed_location(string terrain,
                       string file,
                       int * co_ords)

This method adds a new fixed location for a terrain.

Parameters:
terrain - the terrain name
file - the file name
co_ords - the coordinates for the location

Returns:
1 if it succeeds, 0 if it fails (wrong coordinates or location already present)

See also:
add_floating_location() and modify_fixed_location()


add_floating_location
int add_floating_location(string terrain,
                          string file,
                          int * co_ords,
                          int level)

This method adds a new floating location for a terrain.

Parameters:
terrain - the terrain name
file - the file name
co_ords - the coordinates for the location (either a single coordinate or 2 forming a bounding rectangle)
level - the level of this location

Returns:
1 if it succeeds, 0 if it fails (wrong coordinates or location already present)

See also:
add_fixed_location()


clear_cloned_locations
void clear_cloned_locations(string terrain)

This method clears the cloned locations cache for a given terrain.

Parameters:
terrain - the terrain name

See also:
clear_connections()


clear_connections
void clear_connections(string terrain)

This method clears all connections for a given terrain. This needs to be done when a terrain was modified.

Parameters:
terrain - the terrain name

See also:
clear_cloned_locations()


delete_cloned_location
int delete_cloned_location(string terrain,
                           string file)

This method deletes a cloned location for a terrain from the cache. It is meant to be called when a cloned location is destructed.

Parameters:
terrain - the terrain name
file - the file name

Returns:
1 if it succeeds, 0 if it fails (location not present)

See also:
delete_fixed_location() and delete_floating_location()


delete_fixed_location
int delete_fixed_location(string terrain,
                          string file)

This method deletes a fixed location for a terrain.

Parameters:
terrain - the terrain name
file - the file name

Returns:
1 if it succeeds, 0 if it fails (location not present)

See also:
delete_cloned_location() and delete_floating_location()


delete_floating_location
int delete_floating_location(string terrain,
                             string file,
                             int * co_ords)

This method deletes a floating location for a terrain.

Parameters:
terrain - the terrain name
file - the file name
co_ords - the coordinates for the location (either a single coordinate or 2 forming a bounding rectangle)

Returns:
1 if it succeeds, 0 if it fails (location not present)

See also:
delete_cloned_location() and delete_fixed_location()


find_location
object find_location(string terrain,
                     int * co_ords)

This method is the main entry point for the terrain handler. It loads the room that is associated with the given terrain and coordinates.

Parameters:
terrain - the terrain name
co_ords - the coordinates to look up

Returns:
the room that was found or loaded

See also:
setup_location()


get_data_file
int get_data_file(string word)

This method loads the data file for a given terrain.

Parameters:
word - the terrain to load the data for

Returns:
1 if the terrain exists, 0 if it didn't


get_room_size
int get_room_size(string file,
                  int level)

This method returns the room size for a given room. It uses a cache to speed things up.

Parameters:
file - the file name of the room
level - the recursion level

Returns:
the size of the room


member_cloned_locations
string member_cloned_locations(int * co_ords)

This method checks wether there is a cloned location which matches the given coordinates.

Parameters:
co_ords - the coordinates to find the room for

Returns:
the file name of the room with the given coordinates, or 0 if it is not found

See also:
member_fixed_locations() and member_floating_locations()


member_fixed_locations
string member_fixed_locations(int * co_ords)

This method checks wether there is a fixed location which matches the given coordinates.

Parameters:
co_ords - the coordinates to find the room for

Returns:
the file name of the room with the given coordinates, or 0 if it is not found

See also:
member_cloned_locations() and member_floating_locations()


member_floating_locations
mixed * member_floating_locations(int * co_ords)

This method checks wether there are floating locations which match the given coordinates.

Parameters:
co_ords - the coordinates to find the rooms for

Returns:
an array with the file names of the rooms and the levels, or the empty array if none are found

See also:
member_cloned_locations() and member_fixed_locations()


modify_fixed_location
int modify_fixed_location(string terrain,
                          string file,
                          int * co_ords)

This method modifies an existing fixed location for a terrain.

Parameters:
terrain - the terrain name
file - the file name
co_ords - the coordinates for the location

Returns:
1 if it succeeds, 0 if it fails (wrong coordinates or location not found)

See also:
add_fixed_location()


query_cloned_locations
mapping query_cloned_locations(string terrain)

This method returns the cloned_locations mapping for a given terrain.

Parameters:
word - the terrain name

Returns:
the cloned_locations mapping; keys are the file names, values are the coordinates for the files. There are also keys on x coordinates to facilitate faster coordinate lookups.

See also:
query_fixed_locations() and query_floating_locations()


query_co_ord
int * query_co_ord(string terrain,
                   string file)

This method returns the coordinates for a given terrain and fixed location filename.

Parameters:
terrain - the terrain name
file - the file name of the location

Returns:
the coordinates


query_connected
int query_connected(string terrain,
                    int * co_ords)

This method returns wether the given coordinates is connected to another room in the terrain handler system.

Parameters:
terrain - the terrain name
co_ords - the coordinates

Returns:
1 if it is found, 0 otherwise

See also:
query_connection()


query_connection
string query_connection(string terrain,
                        int * co_ords,
                        string direc)

This method returns the connecting room for the given coordinates and direction.

Parameters:
terrain - the terrain name
co_ords - the coordinates
direc - the direction to find the room for

Returns:
the file name of the connecting room or 0 if none was found

See also:
query_connected()


query_fixed_locations
mapping query_fixed_locations(string word)

This method returns the fixed_locations mapping for the given terrain.

Parameters:
word - the terrain name

Returns:
the fixed_locations mapping; keys are the file names, values are the coordinates for the files

See also:
query_cloned_locations() and query_floating_locations()


query_floating_locations
mixed * query_floating_locations(string word)

This method returns the floating_locations array for the given terrain.

Parameters:
word - the terrain name

Returns:
the floating_locations array; this is an array of arrays where each array consists of the file name, an array of 6 coordinates forming a bounding box or normal coordinates for the location and the level of the floating location

See also:
query_cloned_locations() and query_fixed_locations()


setup_location
void setup_location(object place,
                    string terrain)

This method is called when a normal room is loaded which is part of a terrain. The terrain handler needs to know about this to be able to calculate the exits into the floating portion of the terrain. It also sets the coordinates of the room to the values as saved in the terrain.

Parameters:
place - the room object which is a fixed location in the terrain
terrain - the terrain name

See also:
find_location()


top_floating_location
string top_floating_location(int * co_ords)

This method searches the top level floating location for the given coordinates.

Parameters:
co_ords - the coordinates to find the top level for

Returns:
the file name of the top level room with the given coordinates, or 0 if none was found

See also:
member_floating_locations()