--- deliantra/server/include/object.h 2006/09/14 21:16:12 1.38 +++ deliantra/server/include/object.h 2006/10/15 02:16:35 1.43 @@ -82,6 +82,8 @@ * e.g. copy_object. */ +typedef refptr object_ptr; + // these are not being copied ACC_CLASS (object) struct object_keep : refcounted @@ -90,26 +92,26 @@ UUID uuid; // Unique Identifier, survives saves etc. /* These variables are not changed by copy_object() */ - struct pl *ACC (RW, contr); /* Pointer to the player which control this object */ - struct object *ACC (RW, next); /* Pointer to the next object in the free/used list */ - struct object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ - struct object *ACC (RW, active_next); /* Next & previous object in the 'active' */ - struct object *ACC (RW, active_prev); /* List. This is used in process_events */ + player *ACC (RW, contr); /* Pointer to the player which control this object */ + object *ACC (RW, next); /* Pointer to the next object in the free/used list */ + object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ + object *ACC (RW, active_next); /* Next & previous object in the 'active' */ + object *ACC (RW, active_prev); /* List. This is used in process_events */ /* so that the entire object list does not */ /* need to be gone through. */ - struct object *ACC (RW, below); /* Pointer to the object stacked below this one */ - struct object *ACC (RW, above); /* Pointer to the object stacked above this one */ + object *ACC (RW, below); /* Pointer to the object stacked below this one */ + object *ACC (RW, above); /* Pointer to the object stacked above this one */ /* Note: stacked in the *same* environment */ - struct object *inv; /* Pointer to the first object in the inventory */ - struct object *ACC (RW, container); /* Current container being used. I think this + object *inv; /* Pointer to the first object in the inventory */ + object *ACC (RW, container); /* Current container being used. I think this * is only used by the player right now. */ - struct object *ACC (RW, env); /* Pointer to the object which is the environment. + object *ACC (RW, env); /* Pointer to the object which is the environment. * This is typically the container that the object is in. */ - struct object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ - struct object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different - struct mapstruct *ACC (RW, map); /* Pointer to the map in which this object is present */ + object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ + object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different + maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ }; // these are being copied @@ -127,13 +129,13 @@ /* To get put into books and the like. */ shstr ACC (RW, materialname); /* specific material name */ shstr ACC (RW, custom_name); /* Custom name assigned by player */ - refptr ACC (RW, owner); /* Pointer to the object which controls this one */ - refptr ACC (RW, enemy); /* Monster/player to follow even if not closest */ - refptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ - refptr ACC (RW, chosen_skill); /* the skill chosen to use */ - refptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */ - refptr ACC (RW, spell); /* Spell that was being cast */ - refptr ACC (RW, current_weapon); /* Pointer to the weapon currently used */ + object_ptr ACC (RW, owner); /* Pointer to the object which controls this one */ + object_ptr ACC (RW, enemy); /* Monster/player to follow even if not closest */ + object_ptr ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ + object_ptr ACC (RW, chosen_skill); /* the skill chosen to use */ + object_ptr ACC (RW, spellitem); /* Spell ability monster is choosing to use */ + object_ptr ACC (RW, spell); /* Spell that was being cast */ + object_ptr ACC (RW, current_weapon); /* Pointer to the weapon currently used */ }; // these are being copied and also cleared @@ -208,9 +210,9 @@ char *ACC (RW, spellarg); /* Following are values used by any object */ - struct treasureliststruct *ACC (RW, randomitems); /* Items to be generated */ - struct archetype *ACC (RW, arch); /* Pointer to archetype */ - struct archetype *ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ + treasurelist *ACC (RW, randomitems); /* Items to be generated */ + archetype *ACC (RW, arch); /* Pointer to archetype */ + archetype *ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ key_value *key_values; /* Fields not explictly known by the loader. */ /* this objects turns into or what this object creates */ uint32 flags[4]; /* various flags */ @@ -240,7 +242,7 @@ static object *first; // will be replaced by "objects" static object *create (); - void free (bool free_inventory = false); + void destroy (bool destroy_inventory = false); static void free_mortals (); static bool can_merge (object *op1, object *op2); @@ -248,6 +250,8 @@ void clear (); void clone (object *destination); + bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } + void instantiate () { if (!uuid.seq) // HACK @@ -308,8 +312,8 @@ }; #define get_object() object::create () -#define free_object(op) (op)->free (0) -#define free_object2(op, free_inv) (op)->free (free_inv) +#define free_object(op) (op)->destroy (0) +#define free_object2(op, free_inv) (op)->destroy (free_inv) #define clear_owner(op) (op)->owner = 0 #define copy_owner(op,other) (op)->owner = (other)->owner #define get_owner(op) (op)->owner @@ -325,9 +329,8 @@ typedef struct oblnk { /* Used to link together several objects */ - object *ob; + object_ptr ob; struct oblnk *next; - tag_t id; } objectlink; typedef struct oblinkpt