Crossfire Server, Branch 1.12  R12190


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...

Objects in Crossfire are represented by the ::obj 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.

link to types, flags, ...

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:

Multipart objects

write :)

Unique objects

Object manipulation functions

Most of the object manipulation functions are defined in the object.c file.

Object construction

An object can be obtained:

Object destruction

An object will be freed, thus become invalid:

Object and remote client

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 remove_ob(), insert_ob_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

Various functions exist to manipulate objects. They should be used instead of modifying the field directly, because the field has side-effects.

Special objects

There are special objects that, even if they use the ::obj structure, should not be manipulated through the usual functions.

Archetypes have a archetype::clone field that is an ::obj 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.