--- deliantra/server/include/object.h 2008/04/20 23:25:09 1.163 +++ deliantra/server/include/object.h 2008/04/21 06:16:02 1.164 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * @@ -206,7 +206,7 @@ sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ 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 */ + sint32 ACC (RW, carrying); /* How much weight this object contains, must be 0 if nrof == 0 */ sint64 ACC (RW, perm_exp); /* Permanent exp */ uint32 ACC (RW, weapontype); /* type of weapon */ uint32 ACC (RW, tooltype); /* type of tool or build facility */ @@ -314,7 +314,7 @@ // recursively destroy all objects in inventory, optionally dropping them to the ground instead MTH void destroy_inv (bool drop_to_ground = false); MTH object *insert (object *item); // insert into inventory - MTH void play_sound (faceidx sound) const; + MTH void play_sound (faceidx sound); void do_remove (); MTH void remove () @@ -379,6 +379,9 @@ 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 int number_of () const { return nrof ? nrof : 1; @@ -386,7 +389,7 @@ MTH sint32 total_weight () const { - return weight * number_of () + carrying; + return (weight + carrying) * number_of (); } MTH void update_weight (); @@ -438,13 +441,12 @@ } // returns the player that has this object in his inventory, or 0 - MTH object *in_player () const + // we assume the player is always the outer env + MTH object *in_player () { - for (object *op = env; op; op = op->env) - if (op->type == PLAYER) - return op; + object *op = outer_env (); - return 0; + return op->type == PLAYER ? op : 0; } // "temporary" helper function @@ -458,6 +460,11 @@ return head_ () == this; } + MTH bool is_on_map () const + { + return !env && !flag [FLAG_REMOVED]; + } + MTH std::string long_desc (object *who = 0); MTH std::string describe_monster (object *who = 0); MTH std::string describe_item (object *who = 0);