--- deliantra/server/include/object.h 2009/01/01 19:42:43 1.194 +++ deliantra/server/include/object.h 2009/01/11 06:08:40 1.198 @@ -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 * @@ -138,6 +138,19 @@ signed char used:4; /* Calculated value based on items equipped */ }; +typedef struct oblnk +{ /* Used to link together several objects */ + object_ptr ob; + struct oblnk *next; +} objectlink; + +typedef struct oblinkpt +{ /* Used to link together several object links */ + struct oblnk *link; + struct oblinkpt *next; + shstr id; /* Used as connected value in buttons/gates */ +} oblinkpt; + INTERFACE_CLASS (object) // these are being copied struct object_copy : attachable @@ -280,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 @@ -367,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 () @@ -417,6 +436,10 @@ MTH object *force_find (shstr_tmp name); MTH object *force_add (shstr_tmp name, int duration = 0); + oblinkpt *find_link () const; + MTH void add_link (maptile *map, shstr_tmp id); + MTH void remove_link (); + // overwrite the attachable should_invoke function with a version that also checks ev_want_type bool should_invoke (event_type event) { @@ -508,19 +531,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 (); @@ -528,12 +551,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; } @@ -558,6 +581,11 @@ return glow_radius || flag [FLAG_BLOCKSVIEW]; } + MTH bool has_carried_lights () const + { + return glow_radius; + } + // returns the player that cna see this object, if any MTH object *visible_to () const; @@ -566,6 +594,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 @@ -694,19 +727,6 @@ return ob; } -typedef struct oblnk -{ /* Used to link together several objects */ - object_ptr ob; - struct oblnk *next; -} objectlink; - -typedef struct oblinkpt -{ /* Used to link together several object links */ - struct oblnk *link; - sint32 value; /* Used as connected value in buttons/gates */ - struct oblinkpt *next; -} oblinkpt; - object *find_skill_by_name_fuzzy (object *who, const char *name); object *find_skill_by_name (object *who, shstr_cmp sh); object *find_skill_by_number (object *who, int skillno);