--- deliantra/server/include/object.h 2006/08/26 08:44:06 1.6 +++ deliantra/server/include/object.h 2006/08/31 09:19:34 1.13 @@ -30,6 +30,7 @@ #define OBJECT_H #include "cfperl.h" +#include "shstr.h" typedef uint32 tag_t; #define NUM_BODY_LOCATIONS 12 @@ -100,25 +101,25 @@ * MSW 2002-07-05 */ -struct object_simple { +struct object_simple : attachable { /* These variables are not changed by copy_object() */ struct pl *contr; /* Pointer to the player which control this object */ 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. */ + /* so that the entire object list does not */ + /* need to be gone through. */ 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*/ + /* Note: stacked in the *same* environment*/ 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. - */ + * is only used by the player right now. + */ struct object *env; /* Pointer to the object which is the environment. - * This is typically the container that the object is in. - */ + * This is typically the container that the object is in. + */ 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 */ @@ -127,9 +128,7 @@ uint16 refcount; /* How many objects points to this object */ }; -struct object_special : extendable { - data_type get_dt () const { return DT_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 @@ -141,11 +140,11 @@ const char *title; /* Of foo, etc */ const char *race; /* human, goblin, dragon, etc */ const char *slaying; /* Which race to do double damage to */ - /* If this is an exit, this is the filename */ + /* If this is an exit, this is the filename */ const char *skill; /* Name of the skill this object uses/grants */ const char *msg; /* If this is a book/sign/magic mouth/etc */ const char *lore; /* Obscure information about this object, */ - /* To get put into books and the like. */ + /* To get put into books and the like. */ sint16 x,y; /* Position in the map for this object */ sint16 ox,oy; /* For debugging: Where it was last inserted */ @@ -188,21 +187,19 @@ sint8 glow_radius; /* indicates the glow radius of the object */ living stats; /* Str, Con, Dex, etc */ 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 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 */ sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ - /* See the doc/Developers/objects for more info about body locations */ + /* See the doc/Developers/objects for more info about body locations */ /* Following mostly refers to fields only used for monsters */ struct object *owner; /* Pointer to the object which controls this one */ - /* Owner should not be referred to directly - */ - /* get_owner should be used instead. */ + /* 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) */ + /* has been freed) */ 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 */ @@ -217,7 +214,7 @@ uint8 will_apply; /* See crossfire.doc */ 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 */ + /* races/classes can need less/more exp to gain levels */ /* Spell related information, may be useful elsewhere * Note that other fields are used - these files are basically @@ -236,7 +233,7 @@ /* Following are values used by any object */ struct archt *arch; /* Pointer to archetype */ struct archt *other_arch; /* Pointer used for various things - mostly used for what */ - /* this objects turns into or what this object creates */ + /* this objects turns into or what this object creates */ uint32 flags[4]; /* various flags */ uint16 animation_id; /* An index into the animation array */ uint8 anim_speed; /* ticks between animation-frames */ @@ -259,6 +256,14 @@ }; struct object : object_special, object_simple { + void clone (object *destination) + { + if (attach) + destination->attach = add_refcount (attach); + + if (self || cb) + INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination)); + } }; typedef struct oblnk { /* Used to link together several objects */ @@ -290,8 +295,8 @@ object clone; /* An object from which to do copy_object() */ uint32 editable; /* editable flags (mainly for editor) */ sint8 tail_x, tail_y; /* Where the lower right most portion of the object is - * in comparison to the head. - */ + * in comparison to the head. + */ } archetype; extern object *objects;