--- deliantra/server/include/object.h 2006/09/14 21:16:12 1.38 +++ deliantra/server/include/object.h 2006/11/17 19:40:54 1.44 @@ -82,6 +82,9 @@ * e.g. copy_object. */ +typedef refptr object_ptr; +typedef refptr arch_ptr; + // these are not being copied ACC_CLASS (object) struct object_keep : refcounted @@ -90,26 +93,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 +130,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 +211,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 */ + arch_ptr ACC (RW, arch); /* Pointer to archetype */ + arch_ptr 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 +243,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 +251,8 @@ void clear (); void clone (object *destination); + bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } + void instantiate () { if (!uuid.seq) // HACK @@ -308,8 +313,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 +330,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 @@ -346,14 +350,17 @@ * by the object structure */ -ACC_CLASS(archetype) -struct archetype : zero_initialised +ACC_CLASS (archetype) +struct archetype : zero_initialised, refcounted { archetype (); ~archetype (); static archetype *find (const char *arch); + void hash_add (); // add to hastable + void hash_del (); // remove from hashtable + shstr ACC (RW, name); /* More definite name, like "generate_kobold" */ struct archetype *ACC (RW, next); /* Next archetype in a linked list */ struct archetype *ACC (RW, head); /* The main part of a linked object */ @@ -424,3 +431,4 @@ #define ARCH_SYMPTOM "symptom" #endif +