--- deliantra/server/include/object.h 2007/05/28 21:15:56 1.128 +++ deliantra/server/include/object.h 2007/06/05 13:05:02 1.131 @@ -402,6 +402,11 @@ return head ? head : this; } + MTH bool is_head () + { + return head_ () == this; + } + MTH std::string long_desc (object *who = 0); MTH std::string describe_monster (object *who = 0); MTH std::string describe_item (object *who = 0); @@ -484,9 +489,7 @@ MTH struct region *region () const; protected: - friend struct archetype; - - void link (); + void link (); void unlink (); object (); @@ -512,20 +515,6 @@ return ob; } -typedef object_vector objectvec; -typedef object_vector activevec; - -extern objectvec objects; -extern activevec actives; - -#define for_all_objects(var) \ - for (unsigned _i = 0; _i < objects.size (); ++_i) \ - declvar (object *, var, objects [_i]) - -#define for_all_actives(var) \ - for (unsigned _i = 0; _i < actives.size (); ++_i) \ - declvar (object *, var, actives [_i]) - typedef struct oblnk { /* Used to link together several objects */ object_ptr ob; @@ -553,9 +542,9 @@ */ INTERFACE_CLASS (archetype) -struct archetype : zero_initialised, attachable +struct archetype : object { - archetype (); + archetype (const char *name); ~archetype (); void gather_callbacks (AV *&callbacks, event_type event) const; @@ -563,21 +552,38 @@ static archetype *get (const char *name); // find or create static archetype *find (const char *name); - void hash_add (); // add to hashtable - void hash_del (); // remove from hashtable + void link (); + void unlink (); - 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_to () */ + int ACC (RW, archid); // index in archvector + shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ + bool ACC (RW, stub); // if true, this is an invalid archetype uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ - bool ACC (RW, linked); // linked into list of heads - sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is - * in comparison to the head. - */ + + sint8 ACC (RW, min_x), ACC (RW, min_y); /* extents, compared to the head (min_x, min_y should be zero, but aren't...) */ + sint8 ACC (RW, max_x), ACC (RW, max_y); }; +typedef object_vector objectvec; +typedef object_vector activevec; +typedef object_vector archvec; + +extern objectvec objects; +extern activevec actives; +extern archvec archetypes; + +#define for_all_objects(var) \ + for (unsigned _i = 0; _i < objects.size (); ++_i) \ + statementvar (object *, var, objects [_i]) + +#define for_all_actives(var) \ + for (unsigned _i = 0; _i < actives.size (); ++_i) \ + statementvar (object *, var, actives [_i]) + +#define for_all_archetypes(var) \ + for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ + statementvar (archetype *, var, archetypes [_i]) + /* Used by update_object to know if the object being passed is * being added or removed. */