Crossfire Server, Branch 1.12  R12190
Maps

Maps are where the player and monsters roam.

They contain objects, and some pre-computed information for each map square.

All objects without the FLAG_REMOVED set are ultimately on a map, either directly or because their top-level container is on a map. The only exception are objects for archetypes and artifacts, which aren't anywhere.

Maps reset after some time, reverting to their default state. It is possible that the map is temporarily saved to disk to reclaim memory, in which case it will be reloaded when a player tried to enter it.

When a map resets, all objects on it are lost except when:

Maps can have different types:

Storage location for maps:

Map creation, load, save and reset

The mapstruct structure contains all the map information, objects it contains, precomputed fields for fast access.

The usual function to call to obtain a valid mapstruct structure is ready_map_name(). It is responsible for loading a map from disk, adding unique items and overlays, reloading a map if it was swapped out. The flag parameter controls what should or not be done.

Other ways to get a map are:

In any case the map is linked to the map list.

Random maps use get_empty_map() to create the map, and plugins can access both functions if needed.

Maps are reset when they have been loaded more than map::reset_timeout seconds for fixed reset, or when the last player left it more than mapstruct::reset_timeout seconds.

The saving mechanism, as implemented by save_map(), uses two files to store the map: one for regular items, one for unique items. For unique maps or when swapping a map, the two files are equals to save everything in the same place.

Unless the flag parameter is 2, the objects on the map will be removed.

When a map is to be deleted totally, delete_map() should be called to clean the structure and associated fields, and remove the map from the linked list.

Main map-related functions:

Style maps

Random maps use style maps to gather random objects, and to insert random submaps into generated maps. These style maps are loaded through ready_map_name() with the MAP_STYLE flag so that the active objects are not put on the active object list, then removed from the linked map list and put on the random map style list (first item is styles). Thus those special maps are not really part of the active maps.

Todo:
  • link plugin API, random map documentation, directory information
  • check save_map() flags and meaning