Crossfire Server, Trunk
|
Objects are one of the main structures in Crossfire. They represent every item the player can interact with, including skills, experience, spells and their effects, monsters, walls, including the player as a character in the map...
Objects in Crossfire are represented by the object structure. One important field is object::type, which defines the object type (wall, monster, exit, ...). Another important field is object::flags "the flags", that indicate some special properties of the object.
This structure should not be created directly, but managed through suitable functions (see Object manipulation functions below).
An object can exist in the following states:
Objects are managed on lists, one object can be on different lists.
The following global object lists are defined, the object::next and object::prev fields are used to link to the other objects:
The following local object lists are defined:
Most of the object manipulation functions are defined in the object::c file.
An object can be obtained:
An object will be freed, thus become invalid:
When you manipulate an object that interacts with a player, thus with a remote client, the client needs to be informed of changes to the manipulated object.
The general object manipulation functions like object_remove(), object_insert_in_ob() and such will automatically update the client's status if needed when used with such an obecjt.
If you change some fields of the objets that the client knows about (name, weight, cursed status, ...), you need to call esrv_update_item() with the correct flags. See this section for fields the client knows about.
Various functions exist to manipulate objects. They should be used instead of modifying the field directly, because the field has side-effects.
There are special objects that, even if they use the object structure, should not be manipulated through the usual functions.
Archetypes have a archetype::clone field that is an object structure. This object is never on any list, even if active.
Artifacts have a malloc()'d artifact::item object structure, that isn't on any list either. Those objects should never be manipulated directly.