--- deliantra/server/include/object.h 2008/05/04 15:22:14 1.174 +++ deliantra/server/include/object.h 2008/09/29 10:31:32 1.184 @@ -177,7 +177,7 @@ 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 */ + sint32 ACC (RW, nrof); /* How many of the objects */ /* This next big block is basically used for monsters and equipment */ uint16 ACC (RW, client_type); /* Public type information. see doc/Developers/objects */ @@ -262,15 +262,17 @@ uint16 ACC (RW, animation_id);/* An index into the animation array */ uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ uint8 ACC (RW, last_anim); /* last sequence used to draw face */ - sint16 ACC (RW, elevation); /* elevation of this terrain - not currently used */ uint8 ACC (RW, smoothlevel); /* how to smooth this square around */ uint8 ACC (RW, will_apply); /* See crossfire.doc */ + uint16 ACC (RW, cached_sp); /* cached spell points used for a spell, used by esrv_update_spells */ + uint16 ACC (RW, cached_grace);/* cached grace points used for a spell, used by esrv_update_spells */ + uint16 ACC (RW, cached_eat); /* cached food, used by esrv_update_spells */ }; struct object : zero_initialised, object_copy { // These variables are not changed by ->copy_to - maptile_ptr ACC (RW, map); /* Pointer to the map in which this object is present */ + maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. int ACC (RO, count); @@ -345,6 +347,11 @@ void do_destroy (); void gather_callbacks (AV *&callbacks, event_type event) const; MTH void destroy (bool destroy_inventory = false); + MTH void drop_and_destroy () + { + destroy_inv (true); + destroy (); + } // recursively destroy all objects in inventory, optionally dropping them to the ground instead MTH void destroy_inv (bool drop_to_ground = false); @@ -441,6 +448,7 @@ / dominant_material ()->density; } + MTH bool is_wiz () const { return flag [FLAG_WIZ]; } MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET || type == CLOAK || type == BOOTS || type == GLOVES @@ -467,20 +475,28 @@ */ MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } + MTH bool has_dialogue () const { return *&msg == '@'; } + // returns the outermost owner, never returns 0 MTH object *outer_owner () { - for (object *op = this; ; op = op->owner) - if (!op->owner) - return op; + object *op; + + for (op = this; op->owner; op = op->owner) + ; + + return op; } // returns the outermost environment, never returns 0 MTH object *outer_env () { - for (object *op = this; ; op = op->env) - if (!op->env) - return op; + object *op; + + for (op = this; op->env; op = op->env) + ; + + return op; } // returns the player that has this object in his inventory, or 0 @@ -680,7 +696,7 @@ MTH void link (); MTH void unlink (); - MTH static object *get (const char *name); // find()->instance() + MTH static object *get (const char *name); // (find() || singularity)->instance() MTH object *instance (); object_vector_index ACC (RW, archid); // index in archvector @@ -695,6 +711,13 @@ static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ }; +// compatbiility, remove once replaced by ->instance +inline object * +arch_to_object (archetype *at) +{ + return at->instance (); +} + inline void object_freezer::put (keyword k, archetype *v) { @@ -709,15 +732,20 @@ extern activevec actives; extern archvec archetypes; -#define for_all_objects(var) \ +// "safely" iterate over inv in a way such that the current item is removable +// quite horrible, thats why its hidden in some macro +#define for_inv_removable(op,var) \ + for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) + +#define for_all_objects(var) \ for (unsigned _i = 0; _i < objects.size (); ++_i) \ statementvar (object *, var, objects [_i]) -#define for_all_actives(var) \ +#define for_all_actives(var) \ for (unsigned _i = 0; _i < actives.size (); ++_i) \ statementvar (object *, var, actives [_i]) -#define for_all_archetypes(var) \ +#define for_all_archetypes(var) \ for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ statementvar (archetype *, var, archetypes [_i])