--- deliantra/server/include/object.h 2008/12/23 18:52:57 1.191 +++ deliantra/server/include/object.h 2009/01/08 03:03:24 1.196 @@ -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 @@ -310,36 +323,36 @@ key_value *key_values; /* Fields not explictly known by the loader. */ // privates / perl - const shstr &kv_get (const shstr &key) const; - void kv_del (const shstr &key); - void kv_set (const shstr &key, const shstr &value); + shstr_tmp kv_get (shstr_tmp key) const; + void kv_del (shstr_tmp key); + void kv_set (shstr_tmp key, shstr_tmp value); // custom extra fields management struct key_value_access_proxy { object &ob; - shstr key; + shstr_tmp key; - key_value_access_proxy (object &ob, const shstr &key) + key_value_access_proxy (object &ob, shstr_tmp key) : ob (ob), key (key) { } - const key_value_access_proxy &operator =(const shstr &value) const + const key_value_access_proxy &operator =(shstr_tmp value) const { ob.kv_set (key, value); return *this; } - operator const shstr &() const { return ob.kv_get (key); } - operator const char *() const { return ob.kv_get (key); } + operator const shstr_tmp () const { return ob.kv_get (key); } + operator const char *() const { return ob.kv_get (key); } private: void operator =(int); }; // operator [] is too annoying to use - const key_value_access_proxy kv (const shstr &key) + const key_value_access_proxy kv (shstr_tmp key) { return key_value_access_proxy (*this, key); } @@ -385,6 +398,14 @@ insert_at (this, this); } + // high-level move functions, return true if successful + int move (int dir, object *originator); + + int move (int dir) + { + return move (dir, this); + } + static bool can_merge_slow (object *op1, object *op2); // this is often used in time-critical code, so optimise @@ -406,8 +427,12 @@ open_container (0); } - MTH object *force_find (const shstr name); - MTH object *force_add (const shstr name, int duration = 0); + 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) @@ -453,7 +478,7 @@ // return the volume of this object in cm³ MTH uint64 volume () const { - return total_weight () + return (uint64)total_weight () * 1000 * (type == CONTAINER ? 1000 : 1) / dominant_material ()->density; @@ -550,6 +575,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; @@ -686,21 +716,8 @@ 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 (object *who, const char *name); -object *find_skill_by_name (object *who, const shstr &sh); +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); /*