Crossfire Server, Trunk  R20513
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
object.h File Reference

Object structure, the core of Crossfire. More...

#include "dialog.h"
Include dependency graph for object.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _key_value
 Each object (this also means archetypes!) could have a few of these "dangling" from it; this could also end up containing 'parse errors'. More...
 
struct  archt
 The archetype structure is a set of rules on how to generate and manipulate objects which point to archetypes. More...
 
struct  body_locations_struct
 One body location. More...
 
struct  obj
 Main Crossfire structure, one ingame object. More...
 
struct  oblinkpt
 Used to link together several object links. More...
 
struct  oblnk
 Used to link together several objects. More...
 

Macros

#define ARCH_DEPLETION   "depletion"
 Archetype for depletion. More...
 
#define ARCH_DETECT_MAGIC   "detect_magic"
 Archetype for detect magic spell. More...
 
#define ARCH_PORTAL_FAILED   "town_portal_failed"
 Archetype for town portal failure. More...
 
#define ARCH_SINGULARITY   "singularity"
 Archetype for singularity. More...
 
#define ARCH_SINGULARITY_LEN   11
 Length of ARCH_SINGULARITY. More...
 
#define ARCH_SPELL_BLOCKED   "spell_blocked"
 Archetype when a spell is blocked (unholy ground or non magic). More...
 
#define ARCH_SPELL_BUNGLE   "spell_bungle"
 Archetype when player bungles a spell. More...
 
#define ARCH_SYMPTOM   "symptom"
 Archetype for disease symptom. More...
 
#define BODY_ARMS   1
 This should be the index of the arms. More...
 
#define FREE_OBJ_DROP_ABOVE_FLOOR   4
 If FREE_OBJ_FREE_INVENTORY is not set, drop inventory just above ground instead on top. More...
 
#define FREE_OBJ_FREE_INVENTORY   1
 Free inventory objects; if not set, drop inventory. More...
 
#define FREE_OBJ_NO_DESTROY_CALLBACK   2
 Do not run the destroy callback. More...
 
#define HEAD(op)   ((op)->head != NULL ? (op)->head : (op))
 Returns the head part of an object. More...
 
#define INS_ABOVE_FLOOR_ONLY   0x0002
 Put object immediatly above the floor. More...
 
#define INS_BELOW_ORIGINATOR   0x0010
 Insert new object immediately below originator. More...
 
#define INS_MAP_LOAD   0x0020
 Disable lots of checkings. More...
 
#define INS_NO_MERGE   0x0001
 Don't try to merge with other items. More...
 
#define INS_NO_WALK_ON   0x0004
 Don't call check_walk_on against the originator. More...
 
#define INS_ON_TOP   0x0008
 Always put object on top. More...
 
#define LOOK_OBJ(ob)   (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)
 This returns TRUE if the object is something that should be displayed in the look window. More...
 
#define NUM_BODY_LOCATIONS   13
 Number of body locations. More...
 
#define OB_SPELL_TAG_HASH(op, count)   (op->spell_tags[count&0xf])
 Get the hash on an object for a specified count. More...
 
#define OB_SPELL_TAG_MATCH(op, count)   (op->spell_tags[count&0xf] == count)
 Check whether a tag matches in the tags. More...
 
#define object_was_destroyed(op, old_tag)   (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))
 Checks if an object still exists. More...
 
#define SPELL_TAG_SIZE   16
 Defines default size of the *spell_tags pointer. More...
 
#define UP_OBJ_CHANGE   3
 Object changed. More...
 
#define UP_OBJ_FACE   4
 Only thing that changed was the face. More...
 
#define UP_OBJ_INSERT   1
 Object was inserted. More...
 
#define UP_OBJ_REMOVE   2
 Object was removed. More...
 
#define WILL_APPLY_DOOR   0x8
 Open non-locked doors. More...
 
#define WILL_APPLY_EARTHWALL   0x4
 Destroy earthwalls. More...
 
#define WILL_APPLY_FOOD   0x10
 Eat food (not drinks). More...
 
#define WILL_APPLY_HANDLE   0x1
 Apply handles and triggers. More...
 
#define WILL_APPLY_TREASURE   0x2
 Open chests. More...
 

Typedefs

typedef struct archt archetype
 The archetype structure is a set of rules on how to generate and manipulate objects which point to archetypes. More...
 
typedef struct body_locations_struct body_locations_struct
 One body location. More...
 
typedef struct _key_value key_value
 Each object (this also means archetypes!) could have a few of these "dangling" from it; this could also end up containing 'parse errors'. More...
 
typedef struct obj object
 Main Crossfire structure, one ingame object. More...
 
typedef struct oblnk objectlink
 Used to link together several objects. More...
 
typedef struct oblinkpt oblinkpt
 Used to link together several object links. More...
 
typedef uint32_t tag_t
 Object tag, unique during the whole game. More...
 

Enumerations

enum  object_type {
  PLAYER = 1, TRANSPORT = 2, ROD = 3, TREASURE = 4,
  POTION = 5, FOOD = 6, POISON = 7, BOOK = 8,
  CLOCK = 9, DRAGON_FOCUS = 10, ARROW = 13, BOW = 14,
  WEAPON = 15, ARMOUR = 16, PEDESTAL = 17, ALTAR = 18,
  LOCKED_DOOR = 20, SPECIAL_KEY = 21, MAP = 22, DOOR = 23,
  KEY = 24, TIMED_GATE = 26, TRIGGER = 27, GRIMREAPER = 28,
  MAGIC_EAR = 29, TRIGGER_BUTTON = 30, TRIGGER_ALTAR = 31, TRIGGER_PEDESTAL = 32,
  SHIELD = 33, HELMET = 34, MONEY = 36, CLASS = 37,
  AMULET = 39, PLAYERMOVER = 40, TELEPORTER = 41, CREATOR = 42,
  SKILL = 43, EARTHWALL = 45, GOLEM = 46, THROWN_OBJ = 48,
  BLINDNESS = 49, GOD = 50, DETECTOR = 51, TRIGGER_MARKER = 52,
  DEAD_OBJECT = 53, DRINK = 54, MARKER = 55, HOLY_ALTAR = 56,
  PLAYER_CHANGER = 57, BATTLEGROUND = 58, PEACEMAKER = 59, GEM = 60,
  FIREWALL = 62, CHECK_INV = 64, MOOD_FLOOR = 65, EXIT = 66,
  ENCOUNTER = 67, SHOP_FLOOR = 68, SHOP_MAT = 69, RING = 70,
  FLOOR = 71, FLESH = 72, INORGANIC = 73, SKILL_TOOL = 74,
  LIGHTER = 75, WALL = 77, MISC_OBJECT = 79, MONSTER = 80,
  LAMP = 82, DUPLICATOR = 83, SPELLBOOK = 85, CLOAK = 87,
  SPINNER = 90, GATE = 91, BUTTON = 92, CF_HANDLE = 93,
  HOLE = 94, TRAPDOOR = 95, SIGN = 98, BOOTS = 99,
  GLOVES = 100, SPELL = 101, SPELL_EFFECT = 102, CONVERTER = 103,
  BRACERS = 104, POISONING = 105, SAVEBED = 106, WAND = 109,
  SCROLL = 111, DIRECTOR = 112, GIRDLE = 113, FORCE = 114,
  POTION_RESIST_EFFECT = 115, EVENT_CONNECTOR = 116, CLOSE_CON = 121, CONTAINER = 122,
  ARMOUR_IMPROVER = 123, WEAPON_IMPROVER = 124, SKILLSCROLL = 130, DEEP_SWAMP = 138,
  IDENTIFY_ALTAR = 139, SHOP_INVENTORY = 150, RUNE = 154, TRAP = 155,
  POWER_CRYSTAL = 156, CORPSE = 157, DISEASE = 158, SYMPTOM = 159,
  BUILDER = 160, MATERIAL = 161, OBJECT_TYPE_MAX = 162
}
 Only add new values to this list if somewhere in the program code, it is actually needed. More...
 

Functions

static void clear_flag (object *op, int flag)
 
static int compare_flags (const object *p, const object *q)
 
static int query_flag (const object *op, int flag)
 
static void set_flag (object *op, int flag)
 

Variables

objectactive_objects
 List of active objects that need to be processed. More...
 
body_locations_struct body_locations [NUM_BODY_LOCATIONS]
 The ordering of this is actually doesn't make a difference However, for ease of use, new entries should go at the end so those people that debug the code that get used to something being in the location 4 don't get confused. More...
 
objectfree_objects
 Pointer to the list of unused objects. More...
 
const char *const move_name []
 Maps the MOVE_* values to names. More...
 
int nrofallocobjects
 How many OBs allocated (free + used) More...
 
int nroffreeobjects
 How many OBs allocated and free (free) More...
 
object objarray [STARTMAX]
 All objects, allocated this way at first. More...
 
objectobjects
 Pointer to the list of used objects. More...
 

Detailed Description

Object structure, the core of Crossfire.

Definition in file object.h.

Macro Definition Documentation

#define ARCH_DEPLETION   "depletion"
#define ARCH_DETECT_MAGIC   "detect_magic"

Archetype for detect magic spell.

Definition at line 578 of file object.h.

Referenced by cast_cause_disease().

#define ARCH_PORTAL_FAILED   "town_portal_failed"

Archetype for town portal failure.

Definition at line 581 of file object.h.

Referenced by cast_create_town_portal().

#define ARCH_SINGULARITY   "singularity"

Archetype for singularity.

Definition at line 576 of file object.h.

Referenced by create_singularity(), and START_TEST().

#define ARCH_SINGULARITY_LEN   11

Length of ARCH_SINGULARITY.

Definition at line 577 of file object.h.

#define ARCH_SPELL_BLOCKED   "spell_blocked"

Archetype when a spell is blocked (unholy ground or non magic).

Definition at line 582 of file object.h.

Referenced by cast_spell().

#define ARCH_SPELL_BUNGLE   "spell_bungle"

Archetype when player bungles a spell.

Definition at line 583 of file object.h.

Referenced by cast_spell().

#define ARCH_SYMPTOM   "symptom"

Archetype for disease symptom.

Definition at line 580 of file object.h.

Referenced by do_symptoms().

#define BODY_ARMS   1

This should be the index of the arms.

Definition at line 14 of file object.h.

Referenced by adj_stealchance().

#define HEAD (   op)    ((op)->head != NULL ? (op)->head : (op))
#define LOOK_OBJ (   ob)    (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)

This returns TRUE if the object is something that should be displayed in the look window.

Definition at line 507 of file object.h.

Referenced by command_examine(), esrv_draw_look(), esrv_send_inventory(), esrv_send_item(), esrv_update_item(), and object_remove().

#define NUM_BODY_LOCATIONS   13

Number of body locations.

Definition at line 13 of file object.h.

Referenced by apply_can_apply_object(), command_body(), command_possess(), examine(), fix_object(), get_ob_diff(), monster_can_pick(), and unapply_for_ob().

#define OB_SPELL_TAG_HASH (   op,
  count 
)    (op->spell_tags[count&0xf])

Get the hash on an object for a specified count.

Parameters
opwhat to check.
countitem to check the hash for.

Definition at line 87 of file object.h.

Referenced by object_merge_spell().

#define OB_SPELL_TAG_MATCH (   op,
  count 
)    (op->spell_tags[count&0xf] == count)

Check whether a tag matches in the tags.

Parameters
opitem to check against.
counttag to check.

Definition at line 93 of file object.h.

Referenced by object_merge_spell(), and ok_to_put_more().

#define object_was_destroyed (   op,
  old_tag 
)    (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))
#define SPELL_TAG_SIZE   16

Defines default size of the *spell_tags pointer.

The OB_SPELL_TAG_HASH is a simple mechanism to get/set the spell tags based on a simple hash - it should change if the tag size also changes. Note that since count is used for this, this value is effectively random or at least fairly evenly distributed, at least in the low bits. And a size of 16 lets us do a very fast operation.

Definition at line 81 of file object.h.

Referenced by object_copy(), object_merge_spell(), and ok_to_put_more().

Typedef Documentation

typedef struct archt archetype

The archetype structure is a set of rules on how to generate and manipulate objects which point to archetypes.

This probably belongs in arch.h, but there really doesn't appear to be much left in the archetype - all it really is is a holder for the object and pointers. This structure should get removed, and just replaced by the object structure

One body location.

See common/item.c.

typedef struct _key_value key_value

Each object (this also means archetypes!) could have a few of these "dangling" from it; this could also end up containing 'parse errors'.

key and value are shared-strings.

Please use object_get_value(), object_set_value() from object.c rather than accessing the list directly. Exception is if you want to walk this list for some reason.

typedef struct obj object

Main Crossfire structure, one ingame object.

Note that the ordering of this structure is sort of relevent - object_copy() copies everything over beyond 'name' using memcpy. Thus, values that need to be copied need to be located beyond that point.

However, if you're keeping a pointer of some sort, you probably don't just want it copied, so you'll need to add to common/object.c, e.g. copy-object

I've tried to clean up this structure a bit (in terms of formatting) by making it more consistent. I've also tried to locate some of the fields more logically together (put the item related ones together, the monster related ones, etc. This structure is best viewed with about a 100 width screen. MSW 2002-07-05

See the documentation page for more details.

typedef struct oblnk objectlink

Used to link together several objects.

typedef struct oblinkpt oblinkpt

Used to link together several object links.

typedef uint32_t tag_t

Object tag, unique during the whole game.

Definition at line 12 of file object.h.

Enumeration Type Documentation

Only add new values to this list if somewhere in the program code, it is actually needed.

Just because you add a new monster does not mean it has to have a type defined here. That only needs to happen if in some .c file, it needs to do certain special actions based on the monster type, that can not be handled by any of the numerous flags. Also, if you add new entries, try and fill up the holes in this list. Additionally, when you add a new entry, include it in the table in common/item.c

type 0 is undefined and indicates non-valid type information.

Enumerator
PLAYER 

See Player.

TRANSPORT 

see doc/Developers/objects

See Transport.

ROD 

See Rod.

TREASURE 

See Treasure.

POTION 

See Potion.

FOOD 

See Food.

POISON 

See Poison Food.

BOOK 

See Book.

CLOCK 

See Clock.

DRAGON_FOCUS 

Used during character creation.

ARROW 

See Projectile.

BOW 

See Shooting Weapon.

WEAPON 

See Weapon.

ARMOUR 

See Breastplate Armor.

PEDESTAL 

See Pedestal.

ALTAR 

See Altar.

LOCKED_DOOR 

See Locked Door.

SPECIAL_KEY 

See Special Key.

MAP 
DOOR 

See Door.

KEY 

See Key.

TIMED_GATE 

See Timed Gate.

TRIGGER 

See Handle Trigger.

GRIMREAPER 

See Monster (Grimreaper).

MAGIC_EAR 

See Magic Ear.

TRIGGER_BUTTON 

See Button Trigger.

TRIGGER_ALTAR 

See Altar Trigger.

TRIGGER_PEDESTAL 
SHIELD 

See Shield.

HELMET 

See Helmet.

MONEY 

See Money.

CLASS 

Object for applying character class modifications to someone.

See Class Changer.

AMULET 

See Amulet.

PLAYERMOVER 

See Mover.

TELEPORTER 

See Teleporter.

CREATOR 

See Creator.

SKILL 

Also see SKILL_TOOL (74) below.

See Skill.

EARTHWALL 
GOLEM 
THROWN_OBJ 
BLINDNESS 
GOD 
DETECTOR 

peterm: detector is an object which notices the presense of another object and is triggered like buttons.

See Detector.

TRIGGER_MARKER 

inserts an invisible, weightless force into a player with a specified string WHEN TRIGGERED.

See Trigger Marker.

DEAD_OBJECT 
DRINK 

See Drink.

MARKER 

inserts an invisible, weightless force into a player with a specified string.

See Marker.

HOLY_ALTAR 

See Holy Altar.

PLAYER_CHANGER 
BATTLEGROUND 

battleground, by Andreas Vogl

See Battleground.

PEACEMAKER 

Object owned by a player which can convert a monster into a peaceful being incapable of attack.

GEM 

See Jewel.

FIREWALL 

See Magic Wall.

CHECK_INV 

b.t.

See Inventory Checker.

thoma.nosp@m.s@no.nosp@m.mad.a.nosp@m.stro.nosp@m..psu..nosp@m.edu

MOOD_FLOOR 

b.t.

See Mood Floor.

thoma.nosp@m.s@no.nosp@m.mad.a.nosp@m.stro.nosp@m..psu..nosp@m.edu values of last_sp set how to change: 0 = furious, all monsters become aggressive 1 = angry, all but friendly become aggressive 2 = calm, all aggressive monsters calm down 3 = sleep, all monsters fall asleep 4 = charm, monsters become pets

EXIT 

See Exit.

ENCOUNTER 

See Floor (Encounter).

SHOP_FLOOR 

See Shop Floor.

SHOP_MAT 

See Shop Mat.

RING 

See Ring.

FLOOR 

Floor tile -> native layer 0.

FLESH 

animal 'body parts' -b.t.

See Flesh.

INORGANIC 

metals, minerals, dragon scales

See Inorganic.

SKILL_TOOL 

Allows the use of a skill.

LIGHTER 
WALL 

Wall.

Put it always in layer 1 if not set is_floor

MISC_OBJECT 

misc.

objects are for objects without a function in the engine. Like statues, clocks, chairs... If perhaps we create a function where we can sit on chairs, we create a new type and remove all chairs from here.

MONSTER 

A real, living creature.

LAMP 

Lamp.

DUPLICATOR 

Duplicator/multiplier object.

See Duplicator.

SPELLBOOK 

See Spellbook.

CLOAK 

See Cloak.

SPINNER 

See Spinner.

GATE 

See Gate.

BUTTON 

See Button.

CF_HANDLE 

See Handle.

HOLE 

See Pit.

TRAPDOOR 

See Trapdoor.

SIGN 

See Sign & Magic Mouth.

BOOTS 

See Boots.

GLOVES 

See Gloves.

SPELL 

See Spell.

SPELL_EFFECT 
CONVERTER 

See Converter.

BRACERS 

See Bracers.

POISONING 
SAVEBED 

See Savebed.

WAND 

See Wand & Staff.

SCROLL 

See Scroll.

DIRECTOR 

See Director.

GIRDLE 

See Girdle.

FORCE 
POTION_RESIST_EFFECT 

A force, holding the effect of a resistance potion.

EVENT_CONNECTOR 

Lauwenmark: an invisible object holding a plugin event hook.

See Event.

CLOSE_CON 

Eneq((at)csd.uu.se): Id for close_container archetype.

CONTAINER 

See Container.

ARMOUR_IMPROVER 
WEAPON_IMPROVER 
SKILLSCROLL 

can add a skill to player's inventory -bt.

See Skill Scroll.

DEEP_SWAMP 

See Swamp.

IDENTIFY_ALTAR 
SHOP_INVENTORY 

Mark Wedel (mark@.nosp@m.pyra.nosp@m.mid.c.nosp@m.om) Shop inventories.

RUNE 

See Rune.

TRAP 

See Trap.

POWER_CRYSTAL 

See Power Crystal.

CORPSE 
DISEASE 

See Disease.

SYMPTOM 
BUILDER 

Generic item builder, see subtypes below.

See Builder.

MATERIAL 

Material for building.

See Building material.

OBJECT_TYPE_MAX 

Update if you add new types.

Definition at line 106 of file object.h.

Function Documentation

static void clear_flag ( object op,
int  flag 
)
inlinestatic

Definition at line 495 of file object.h.

References obj::flags.

static int compare_flags ( const object p,
const object q 
)
inlinestatic

Definition at line 484 of file object.h.

References flags.

static int query_flag ( const object op,
int  flag 
)
inlinestatic

Definition at line 491 of file object.h.

References obj::flags.

static void set_flag ( object op,
int  flag 
)
inlinestatic

Definition at line 499 of file object.h.

References obj::flags.

Variable Documentation

object* active_objects

List of active objects that need to be processed.

Definition at line 62 of file object.c.

Referenced by cast_invisible(), init_objects(), object_count_active(), object_update_speed(), and process_events().

The ordering of this is actually doesn't make a difference However, for ease of use, new entries should go at the end so those people that debug the code that get used to something being in the location 4 don't get confused.

The ordering in save_name, use_name, nonuse_name. save_name is the name used to load/save it from files. It should match that of the doc/Developers/objects. The only real limitation is that it shouldn't have spaces or other characters that may mess up the match code. It must also start with body_ use_name is how we describe the location if we can use it. nonuse_name is how we describe it if we can't use it. I think the values below will make it pretty clear how those work out They are basically there to make life a little easier - if a character examines an item and it says it goes on 'your arm', its pretty clear they can use it. See the last sample (commented out) for a dragon Note that using the term 'human' may not be very accurate, humanoid may be better. Basically, for the use/nonuse, the code does something like: "This item goes %s\n", with the use/nonuse values filling in the s

Definition at line 54 of file item.c.

Referenced by command_body(), examine(), and get_ob_diff().

object* free_objects

Pointer to the list of unused objects.

Definition at line 61 of file object.c.

Referenced by init_objects(), object_count_free(), object_free2(), and object_new().

const char* const move_name[]

Maps the MOVE_* values to names.

Definition at line 4716 of file object.c.

Referenced by get_string_move_type().

int nrofallocobjects

How many OBs allocated (free + used)

Definition at line 57 of file object.c.

Referenced by expand_objects(), and object_free_all_data().

int nroffreeobjects

How many OBs allocated and free (free)

Definition at line 56 of file object.c.

Referenced by expand_objects(), object_free2(), object_free_all_data(), and object_new().

object objarray[STARTMAX]

All objects, allocated this way at first.

Definition at line 55 of file object.c.

Referenced by init_objects().

object* objects

Pointer to the list of used objects.

Definition at line 60 of file object.c.

Referenced by free_all_objects(), init_objects(), object_count_used(), and object_new().