Crossfire Server, Branches 1.12  R18729
object.h File Reference
#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
 
struct  archt
 
struct  body_locations_struct
 
struct  obj
 
struct  oblinkpt
 
struct  oblnk
 

Macros

#define ARCH_DEPLETION   "depletion"
 
#define ARCH_DETECT_MAGIC   "detect_magic"
 
#define ARCH_SINGULARITY   "singularity"
 
#define ARCH_SINGULARITY_LEN   11
 
#define ARCH_SYMPTOM   "symptom"
 
#define BODY_ARMS   1
 
#define INS_ABOVE_FLOOR_ONLY   0x0002
 
#define INS_BELOW_ORIGINATOR   0x0010
 
#define INS_MAP_LOAD   0x0020
 
#define INS_NO_MERGE   0x0001
 
#define INS_NO_WALK_ON   0x0004
 
#define INS_ON_TOP   0x0008
 
#define LOOK_OBJ(ob)   (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)
 
#define NUM_BODY_LOCATIONS   13
 
#define OB_SPELL_TAG_HASH(op, count)   (op->spell_tags[count&0xf])
 
#define OB_SPELL_TAG_MATCH(op, count)   (op->spell_tags[count&0xf] == count)
 
#define SPELL_TAG_SIZE   16
 
#define UP_OBJ_CHANGE   3
 
#define UP_OBJ_FACE   4
 
#define UP_OBJ_INSERT   1
 
#define UP_OBJ_REMOVE   2
 
#define was_destroyed(op, old_tag)   (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))
 
#define WILL_APPLY_DOOR   0x8
 
#define WILL_APPLY_EARTHWALL   0x4
 
#define WILL_APPLY_FOOD   0x10
 
#define WILL_APPLY_HANDLE   0x1
 
#define WILL_APPLY_TREASURE   0x2
 

Typedefs

typedef struct archt archetype
 
typedef struct
body_locations_struct 
body_locations_struct
 
typedef struct _key_value key_value
 
typedef struct obj object
 
typedef struct oblnk objectlink
 
typedef struct oblinkpt oblinkpt
 
typedef uint32 tag_t
 

Variables

objectactive_objects
 
body_locations_struct body_locations [NUM_BODY_LOCATIONS]
 
objectfree_objects
 
int nrofallocobjects
 
int nroffreeobjects
 
object objarray [STARTMAX]
 
objectobjects
 

Detailed Description

Object structure, the core of Crossfire.

Definition in file object.h.

Macro Definition Documentation

#define ARCH_DEPLETION   "depletion"

Archetype for depletion.

Definition at line 405 of file object.h.

Referenced by drain_specific_stat(), god_intervention(), perceive_self(), potion_type_apply(), and START_TEST().

#define ARCH_DETECT_MAGIC   "detect_magic"

Archetype for detect magic spell.

Definition at line 404 of file object.h.

Referenced by cast_cause_disease().

#define ARCH_SINGULARITY   "singularity"

Archetype for singularity.

Definition at line 402 of file object.h.

Referenced by create_singularity(), and START_TEST().

#define ARCH_SINGULARITY_LEN   11

Length of ARCH_SINGULARITY.

Definition at line 403 of file object.h.

#define ARCH_SYMPTOM   "symptom"

Archetype for disease symptom.

Definition at line 406 of file object.h.

Referenced by do_symptoms().

#define BODY_ARMS   1

This should be the index of the arms.

Definition at line 42 of file object.h.

Referenced by adj_stealchance().

#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 344 of file object.h.

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

#define NUM_BODY_LOCATIONS   13

Number of body locations.

Definition at line 41 of file object.h.

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

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

Definition at line 108 of file object.h.

Referenced by merge_spell().

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

Definition at line 109 of file object.h.

Referenced by merge_spell(), and ok_to_put_more().

#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 107 of file object.h.

Referenced by copy_object(), merge_spell(), and ok_to_put_more().

#define was_destroyed (   op,
  old_tag 
)    (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))

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 get_ob_key_value(), set_ob_key_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 - copy_object 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 tag_t

Object tag, unique during the whole game.

Definition at line 40 of file object.h.

Variable Documentation

object* active_objects

List of active objects that need to be processed

Definition at line 72 of file object.c.

Referenced by cast_invisible(), count_active(), init_objects(), process_events(), and update_ob_speed().

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 64 of file item.c.

Referenced by command_body(), and examine().

object* free_objects

Pointer to the list of unused objects

Definition at line 71 of file object.c.

Referenced by count_free(), free_object2(), get_object(), and init_objects().

int nrofallocobjects

How many OBs allocated (free + used)

Definition at line 67 of file object.c.

Referenced by expand_objects(), and free_all_object_data().

int nroffreeobjects

How many OBs allocated and free (free)

Definition at line 66 of file object.c.

Referenced by expand_objects(), free_all_object_data(), free_object2(), and get_object().

object objarray[STARTMAX]

All objects, allocated this way at first

Definition at line 65 of file object.c.

Referenced by init_objects().

object* objects

Pointer to the list of used objects

Definition at line 70 of file object.c.

Referenced by count_used(), free_all_objects(), get_object(), and init_objects().