--- deliantra/server/include/object.h 2006/09/14 01:12:28 1.35 +++ deliantra/server/include/object.h 2006/09/16 22:24:12 1.40 @@ -86,30 +86,30 @@ ACC_CLASS (object) struct object_keep : refcounted { - tag_t ACC (RW, count); /* Unique object number for this object */ + tag_t ACC (RW, count); /* Generation count for this object */ 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 @@ -139,11 +139,11 @@ // these are being copied and also cleared struct object_pod { + New_Face *ACC (RW, face); /* Face with colors */ sint16 ACC (RW, x), ACC (RW, y); /* Position in the map for this object */ float ACC (RW, speed); /* The overall speed of this object */ float ACC (RW, speed_left); /* How much speed is left to spend this round */ uint32 ACC (RW, nrof); /* How many of the objects */ - New_Face *ACC (RW, face); /* Face with colors */ sint8 ACC (RW, direction); /* Means the object is moving that way. */ sint8 ACC (RW, facing); /* Object is oriented/facing that way. */ @@ -176,17 +176,15 @@ sint32 ACC (RW, weight); /* Attributes of the object */ sint32 ACC (RW, weight_limit); /* Weight-limit of object */ sint32 ACC (RW, carrying); /* How much weight this object contains */ - living ACC (RO, stats); /* Str, Con, Dex, etc */ sint64 ACC (RW, perm_exp); /* Permanent exp */ uint32 ACC (RW, weapontype); /* type of weapon */ uint32 ACC (RW, 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 */ + living ACC (RO, stats); /* Str, Con, Dex, etc */ /* See the doc/Developers/objects for more info about body locations */ /* Following mostly refers to fields only used for monsters */ - tag_t ACC (RW, ownercount); /* What count the owner had (in case owner has been freed) *///TODO: remove/fix - tag_t ACC (RW, attacked_by_count); /* the tag of attacker, so we can be sure */ uint32 ACC (RW, hide); /* The object is hidden, not invisible */ /* changes made by kholland@sunlab.cit.cornell.edu */ /* allows different movement patterns for attackers */ @@ -203,16 +201,16 @@ sint16 ACC (RW, duration); /* How long the spell lasts */ sint16 ACC (RW, casting_time); /* time left before spell goes off */ uint16 ACC (RW, start_holding); - char *ACC (RW, spellarg); uint8 ACC (RW, duration_modifier); /* how level modifies duration */ uint8 ACC (RW, dam_modifier); /* How going up in level effects damage */ sint8 ACC (RW, range); /* Range of the spell */ uint8 ACC (RW, range_modifier); /* How going up in level effects range */ + 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 */ @@ -234,6 +232,13 @@ struct object : zero_initialised, object_keep, object_copy, object_pod { + typedef unordered_vector vector; + + static vector mortals; + static vector active; // active objects, not yet used + static vector objects; // not used yet, use first->next->... + static object *first; // will be replaced by "objects" + static object *create (); void free (bool free_inventory = false); @@ -243,6 +248,8 @@ void clear (); void clone (object *destination); + bool destroyed () { return QUERY_FLAG (this, FLAG_FREED); } + void instantiate () { if (!uuid.seq) // HACK @@ -252,7 +259,6 @@ } void set_owner (object *owner); - object *get_owner (); // info must hold 256 * 3 bytes currently const char *debug_desc (char *info) const; @@ -308,14 +314,9 @@ #define free_object2(op, free_inv) (op)->free (free_inv) #define clear_owner(op) (op)->owner = 0 #define copy_owner(op,other) (op)->owner = (other)->owner +#define get_owner(op) (op)->owner #define clear_object(op) (op)->clear () -static inline object * -get_owner (object *op) -{ - return op->get_owner (); -} - static inline void set_owner (object *op, object *owner) { @@ -353,15 +354,17 @@ archetype (); ~archetype (); - 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 */ - struct archetype *ACC (RW, more); /* Next part of a linked object */ - object ACC (RO, clone); /* An object from which to do copy_object() */ - uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ - sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is - * in comparison to the head. - */ + static archetype *find (const char *arch); + + 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 */ + struct archetype *ACC (RW, more); /* Next part of a linked object */ + object ACC (RO, clone); /* An object from which to do copy_object() */ + uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ + sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is + * in comparison to the head. + */ }; extern object *objects;