--- deliantra/server/include/object.h 2006/12/25 11:25:49 1.68 +++ deliantra/server/include/object.h 2006/12/30 21:07:46 1.74 @@ -246,31 +246,32 @@ static vector objects; // not used yet, use first->next->... static object *first; // will be replaced by "objects" - static object *create (); - void copy_to (object *dst); - object *clone (); // create + copy_to + MTH static object *create (); + MTH void copy_to (object *dst); + MTH object *clone (); // create + copy_to void do_destroy (); void gather_callbacks (AV *&callbacks, event_type event) const; - void destroy (bool destroy_inventory = false); + MTH void destroy (bool destroy_inventory = false); // recursively destroy all objects in inventory, optionally dropping them to the ground instead - void destroy_inv (bool drop_to_ground = false); - void remove (); - object *insert (object *item); // insert into inventory + MTH void destroy_inv (bool drop_to_ground = false); + MTH void remove (); + MTH object *insert (object *item); // insert into inventory static bool can_merge_slow (object *op1, object *op2); // this is often used in time-critical code, so optimise - static bool can_merge (object *op1, object *op2) + MTH static bool can_merge (object *op1, object *op2) { return op1->value == op2->value && op1->name == op2->name && can_merge_slow (op1, op2); } - void set_owner (object *owner); + MTH void set_owner (object *owner); + MTH void set_speed (float speed); - void instantiate () + MTH void instantiate () { if (!uuid.seq) // HACK uuid = gen_uuid (); @@ -279,38 +280,47 @@ } // recalculate all stats - void update_stats (); - void roll_stats (); - void swap_stats (int a, int b); - void add_statbonus (); - void remove_statbonus (); - void drain_stat (); - void drain_specific_stat (int deplete_stats); - void change_luck (int value); + MTH void update_stats (); + MTH void roll_stats (); + MTH void swap_stats (int a, int b); + MTH void add_statbonus (); + MTH void remove_statbonus (); + MTH void drain_stat (); + MTH void drain_specific_stat (int deplete_stats); + MTH void change_luck (int value); // info must hold 256 * 3 bytes currently const char *debug_desc (char *info) const; - const char *debug_desc () const; + MTH const char *debug_desc () const; + const char *object::flag_desc (char *desc, int len) const; - bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } - bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET - || type == CLOAK || type == BOOTS || type == GLOVES - || type == BRACERS || type == GIRDLE; } - bool is_alive () const { return (type == PLAYER - || flag [FLAG_MONSTER] - || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) - && !flag [FLAG_IS_A_TEMPLATE]; } - bool is_arrow () const { return type == ARROW - || (type == SPELL_EFFECT - && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } + 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 + || type == BRACERS || type == GIRDLE; } + MTH bool is_alive () const { return (type == PLAYER + || flag [FLAG_MONSTER] + || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) + && !flag [FLAG_IS_A_TEMPLATE]; } + MTH bool is_arrow () const { return type == ARROW + || (type == SPELL_EFFECT + && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } + + MTH bool has_active_speed () const { return FABS(speed) >= MIN_ACTIVE_SPEED; } + + // temporary: wether the objetc can be saved in a map file + // contr => is a player + // head => only save head of a multitile object + // owner => can not reference owner yet + MTH bool can_map_save () const { return !contr && !head && !owner; } /* This return true if object has still randomitems which * could be expanded. */ - bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } + MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } // returns the player that has this object in his inventory, or 0 - object *in_player () const + MTH object *in_player () const { for (object *op = env; op; op = op->env) if (op->type == PLAYER) @@ -319,6 +329,22 @@ return 0; } + // "temporary" helper function + MTH object *head_ () + { + return head ? head : this; + } + + // insert object at same map position as 'where' + // handles both inventory and map "positions" + MTH object *insert_at (object *where, object *originator = 0, int flags = 0); + + MTH void activate (bool recursive = true); + MTH void deactivate (bool recursive = true); + + void enter_exit (object *exit);//PERL + MTH void enter_map (maptile *newmap, int x, int y); + // returns the mapspace this object is in mapspace &ms () const;