--- deliantra/server/include/object.h 2008/04/21 06:16:02 1.164 +++ deliantra/server/include/object.h 2008/05/03 09:04:17 1.171 @@ -179,7 +179,7 @@ float ACC (RW, speed_left); /* How much speed is left to spend this round */ uint32 ACC (RW, nrof); /* How many of the objects */ - /* This next big block are basically used for monsters and equipment */ + /* This next big block is basically used for monsters and equipment */ uint16 ACC (RW, client_type); /* Public type information. see doc/Developers/objects */ sint16 ACC (RW, resist[NROFATTACKS]); /* Resistance adjustments for attacks */ @@ -304,7 +304,6 @@ MTH int slottype () const; MTH static object *create (); const mapxy &operator =(const mapxy &pos); - object &operator =(const object &src); MTH void copy_to (object *dst); MTH object *clone (); // create + copy_to void do_destroy (); @@ -379,8 +378,8 @@ MTH const char *debug_desc () const; // uses at least 3 round-robin buffers const char *flag_desc (char *desc, int len) const; - MTH bool decrease_nr (sint32 nr); - MTH object *split_nr (sint32 nr); + MTH bool decrease (sint32 nr = 1); // returns true if anything is left + MTH object *split (sint32 nr = 1); // return 0 on failure MTH int number_of () const { @@ -432,6 +431,14 @@ */ MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } + // returns the outermost owner, never returns 0 + MTH object *outer_owner () + { + for (object *op = this; ; op = op->owner) + if (!op->owner) + return op; + } + // returns the outermost environment, never returns 0 MTH object *outer_env () { @@ -465,6 +472,9 @@ return !env && !flag [FLAG_REMOVED]; } + // returns the player that cna see this object, if any + MTH object *visible_to () const; + MTH std::string long_desc (object *who = 0); MTH std::string describe_monster (object *who = 0); MTH std::string describe_item (object *who = 0); @@ -538,13 +548,19 @@ } /* This returns TRUE if the object is something that - * should be displayed in the floorbox/inventory window + * a client might want to know about. */ MTH bool client_visible () const { return !invisible && type != PLAYER; } + // the client does nrof * this weight + MTH sint32 client_weight () const + { + return weight + carrying; + } + MTH struct region *region () const; void statusmsg (const char *msg, int color = NDI_BLACK); @@ -561,6 +577,10 @@ object (); ~object (); + +private: + object &operator =(const object &); + object (const object &); }; // move this object to the top of its env's inventory to speed up @@ -623,6 +643,7 @@ MTH void link (); MTH void unlink (); + MTH static object *get (const char *name); // find()->instance() MTH object *instance (); object_vector_index ACC (RW, archid); // index in archvector