--- deliantra/server/include/object.h 2009/01/08 03:03:24 1.196 +++ deliantra/server/include/object.h 2009/06/27 03:51:05 1.201 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * @@ -268,7 +268,7 @@ // 8 free bits float ACC (RW, move_slow_penalty); /* How much this slows down the object */ - char *ACC (RW, spellarg); + shstr ACC (RW, spellarg); /* only used in arrows - get rid of it? */ /* Following are values used by any object */ /* this objects turns into or what this object creates */ @@ -293,6 +293,11 @@ shstr ACC (RW, custom_name); /* Custom name assigned by player */ }; +const char *query_weight (const object *op); +const char *query_short_name (const object *op); +const char *query_name (const object *op); +const char *query_base_name (const object *op, int plural); + struct object : zero_initialised, object_copy { // These variables are not changed by ->copy_to @@ -380,7 +385,8 @@ // 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); + MTH void play_sound (faceidx sound) const; + MTH void say_msg (const char *msg) const; void do_remove (); MTH void remove () @@ -418,6 +424,7 @@ MTH void set_owner (object *owner); MTH void set_speed (float speed); + MTH void set_glow_radius (sint8 rad); MTH bool change_weapon (object *ob); MTH bool change_skill (object *ob); @@ -525,19 +532,19 @@ } // returns the outermost environment, never returns 0 - MTH object *outer_env () + MTH object *outer_env () const { - object *op; + const object *op; for (op = this; op->env; op = op->env) ; - return op; + return const_cast(op); } // returns the player that has this object in his inventory, or 0 // we assume the player is always the outer env - MTH object *in_player () + MTH object *in_player () const { object *op = outer_env (); @@ -545,12 +552,12 @@ } // "temporary" helper function - MTH object *head_ () + MTH object *head_ () const { - return head ? head : this; + return head ? head : const_cast(this); } - MTH bool is_head () + MTH bool is_head () const { return head_ () == this; } @@ -588,6 +595,11 @@ MTH std::string describe_item (object *who = 0); MTH std::string describe (object *who = 0); + MTH const char *query_weight () { return ::query_weight (this); } + MTH const char *query_name () { return ::query_name (this); } + MTH const char *query_short_name () { return ::query_short_name (this); } + MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); } + // If this object has no extra parts but should have them, // add them, effectively expanding heads into multipart // objects. This method only works on objects not inserted @@ -685,6 +697,19 @@ // when they are invisible. MTH void make_noise (); + /* animation */ + bool has_anim () { return animation_id; } + const animation &anim () const { return animations [animation_id]; } + faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; } + void set_anim_frame (int frame) { face = get_anim_frame (frame); } + /* anim_frames () returns the number of animations allocated. The last + * usuable animation will be anim_frames () - 1 (for example, if an object + * has 8 animations, anim_frames () will return 8, but the values will + * range from 0 through 7. + */ + int anim_frames () const { return anim ().num_animations; } + int anim_facings () const { return anim ().facings; } + protected: void link (); void unlink ();