--- deliantra/server/include/object.h 2006/02/22 18:01:58 1.1.1.2 +++ deliantra/server/include/object.h 2006/08/25 17:11:53 1.5 @@ -97,32 +97,35 @@ * This structure is best viewed with about a 100 width screen. * MSW 2002-07-05 */ -typedef struct obj { + +struct object_simple { /* These variables are not changed by copy_object() */ struct pl *contr; /* Pointer to the player which control this object */ - struct obj *next; /* Pointer to the next object in the free/used list */ - struct obj *prev; /* Pointer to the previous object in the free/used list*/ - struct obj *active_next; /* Next & previous object in the 'active' */ - struct obj *active_prev; /* List. This is used in process_events */ + struct object *next; /* Pointer to the next object in the free/used list */ + struct object *prev; /* Pointer to the previous object in the free/used list*/ + struct object *active_next; /* Next & previous object in the 'active' */ + struct object *active_prev; /* List. This is used in process_events */ /* so that the entire object list does not */ /* need to be gone through. */ - struct obj *below; /* Pointer to the object stacked below this one */ - struct obj *above; /* Pointer to the object stacked above this one */ + struct object *below; /* Pointer to the object stacked below this one */ + struct object *above; /* Pointer to the object stacked above this one */ /* Note: stacked in the *same* environment*/ - struct obj *inv; /* Pointer to the first object in the inventory */ - struct obj *container; /* Current container being used. I think this + struct object *inv; /* Pointer to the first object in the inventory */ + struct object *container; /* Current container being used. I think this * is only used by the player right now. */ - struct obj *env; /* Pointer to the object which is the environment. + struct object *env; /* Pointer to the object which is the environment. * This is typically the container that the object is in. */ - struct obj *more; /* Pointer to the rest of a large body of objects */ - struct obj *head; /* Points to the main object of a large body */ - struct mapdef *map; /* Pointer to the map in which this object is present */ + struct object *more; /* Pointer to the rest of a large body of objects */ + struct object *head; /* Points to the main object of a large body */ + struct mapstruct *map; /* Pointer to the map in which this object is present */ tag_t count; /* Unique object number for this object */ uint16 refcount; /* How many objects points to this object */ +}; +struct object_special { /* These get an extra add_refcount(), after having been copied by memcpy(). * All fields beow this point are automatically copied by memcpy. If * adding something that needs a refcount updated, make sure you modify @@ -183,7 +186,7 @@ sint64 perm_exp; /* Permanent exp */ const char *current_weapon_script; /* The script of the currently used weapon. Executed */ /* each time the object attacks something */ - struct obj *current_weapon; /* Pointer to the weapon currently used */ + struct object *current_weapon; /* Pointer to the weapon currently used */ uint32 weapontype; /* type of weapon */ uint32 tooltype; /* type of tool or build facility */ sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ @@ -191,24 +194,24 @@ /* See the doc/Developers/objects for more info about body locations */ /* Following mostly refers to fields only used for monsters */ - struct obj *owner; /* Pointer to the object which controls this one */ + struct object *owner; /* Pointer to the object which controls this one */ /* Owner should not be referred to directly - */ /* get_owner should be used instead. */ tag_t ownercount; /* What count the owner had (in case owner */ /* has been freed) */ - struct obj *enemy; /* Monster/player to follow even if not closest */ - struct obj *attacked_by; /* This object start to attack us! only player & monster */ + struct object *enemy; /* Monster/player to follow even if not closest */ + struct object *attacked_by; /* This object start to attack us! only player & monster */ tag_t attacked_by_count; /* the tag of attacker, so we can be sure */ struct treasureliststruct *randomitems; /* Items to be generated */ uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ - struct obj *chosen_skill; /* the skill chosen to use */ + struct object *chosen_skill; /* the skill chosen to use */ uint32 hide; /* The object is hidden, not invisible */ /* changes made by kholland@sunlab.cit.cornell.edu */ /* allows different movement patterns for attackers */ sint32 move_status; /* What stage in attack mode */ uint16 attack_movement;/* What kind of attack movement */ uint8 will_apply; /* See crossfire.doc */ - struct obj *spellitem; /* Spell ability monster is choosing to use */ + struct object *spellitem; /* Spell ability monster is choosing to use */ double expmul; /* needed experience = (calc_exp*expmul) - means some */ /* races/classes can need less/more exp to gain levels */ @@ -219,7 +222,7 @@ sint16 duration; /* How long the spell lasts */ uint8 duration_modifier; /* how level modifies duration */ sint16 casting_time; /* time left before spell goes off */ - struct obj *spell; /* Spell that was being cast */ + struct object *spell; /* Spell that was being cast */ uint16 start_holding; char *spellarg; uint8 dam_modifier; /* How going up in level effects damage */ @@ -249,8 +252,11 @@ const char *custom_name; /* Custom name assigned by player */ key_value *key_values; /* Fields not explictly known by the loader. */ +}; -} object; +struct object : object_special, object_simple { + void *self, *cb; // CF+ perl's self and callback registry +}; typedef struct oblnk { /* Used to link together several objects */ object *ob; @@ -346,4 +352,6 @@ #define ARCH_DEPLETION "depletion" #define ARCH_SYMPTOM "symptom" +extern void (*object_free_callback)(object *ob); // called for every object_free + #endif