--- deliantra/server/include/object.h 2010/04/10 04:54:09 1.238 +++ deliantra/server/include/object.h 2010/04/17 02:50:21 1.247 @@ -66,6 +66,9 @@ #define NUM_COINS 4 /* number of coin types */ extern const char *const coins[NUM_COINS + 1]; +// restart server when object_count reaches this value +#define RESTART_COUNT 0xe0000000 + /* * Each object (this also means archetypes!) could have a few of these * "dangling" from it; this could also end up containing 'parse errors'. @@ -295,13 +298,19 @@ int SP_level_duration_adjust (object *caster, object *spob); int SP_level_range_adjust (object *caster, object *spob); -struct object : zero_initialised, object_copy +struct freelist_item +{ + freelist_item *next; + uint32_t count; +}; + +struct object : object_copy { // These variables are not changed by ->copy_to maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. - int ACC (RO, count); + uint32_t ACC (RO, count); object_vector_index ACC (RO, index); // index into objects object_vector_index ACC (RO, active); // index into actives @@ -323,6 +332,16 @@ object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different key_value *key_values; /* Fields not explictly known by the loader. */ + MTH void set_flag (int flagnum) + { + flag [flagnum] = true; + } + + MTH void clr_flag (int flagnum) + { + flag [flagnum] = false; + } + // privates / perl shstr_tmp kv_get (shstr_tmp key) const; void kv_del (shstr_tmp key); @@ -434,7 +453,6 @@ MTH void set_owner (object *owner); MTH void set_speed (float speed); MTH void set_glow_radius (sint8 rad); - MTH bool change_skill (object *ob); // deprecated? MTH void open_container (object *new_container); MTH void close_container () @@ -554,6 +572,12 @@ MTH bool has_dialogue () const { return msg_has_dialogue (&msg); } + /* need_identify returns true if the item should be identified. This + * function really should not exist - by default, any item not identified + * should need it. + */ + MTH bool need_identify () const; + // returns the outermost owner, never returns 0 MTH object *outer_owner () { @@ -630,7 +654,7 @@ return glow_radius; } - // returns the player that cna see this object, if any + // returns the player that can see this object, if any MTH object *visible_to () const; MTH std::string long_desc (object *who = 0); // query_name . " " . describe @@ -651,6 +675,12 @@ MTH void create_treasure (treasurelist *tl, int flags = 0); + // makes sure the player has the named skill, + // and also makes it innate if can_use is true. + // returns the new skill or 0 if no such skill exists. + MTH object *give_skill (shstr_cmp name, bool can_use = false); + MTH void become_follower (object *new_god); + // insert object at same map position as 'where' // handles both inventory and map "positions" MTH object *insert_at (object *where, object *originator = 0, int flags = 0); @@ -671,6 +701,8 @@ void player_goto (const_utf8_string path, int x, int y); // only for players MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0 + MTH object *mark () const; + // returns the mapspace this object is in mapspace &ms () const; @@ -730,14 +762,14 @@ MTH struct region *region () const; - void statusmsg (const_utf8_string msg, int color = NDI_BLACK); - void failmsg (const_utf8_string msg, int color = NDI_RED); + MTH void statusmsg (const_utf8_string msg, int color = NDI_BLACK); + MTH void failmsg (const_utf8_string msg, int color = NDI_RED); void failmsgf (const_utf8_string format, ...); // always NDI_RED... - const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = ""); + MTH const_utf8_string query_inventory (object *who = 0, const_utf8_string indent = ""); MTH const_octet_string ref () const; // creates and returns a consistent persistent object reference - static object *deref (const_octet_string ref); // returns the object from the generated refreence, if possible + static object *deref (const_octet_string ref); // returns the object from the generated reference, if possible // make some noise with given item into direction dir, // currently only used for players to make them temporarily visible @@ -759,10 +791,20 @@ MTH utf8_string as_string (); + // low-level management, statistics, ... + static uint32_t ACC (RW, object_count); + static uint32_t ACC (RW, free_count); + static uint32_t ACC (RW, create_count); + static uint32_t ACC (RW, destroy_count); + static freelist_item *freelist; + MTH static void freelist_free (int count); + protected: void link (); void unlink (); + void do_delete (); + object (); ~object (); @@ -808,7 +850,7 @@ //-GPL INTERFACE_CLASS (archetype) -struct archetype : object +struct archetype : object, zero_initialised { static arch_ptr empty; // the empty_archetype MTH static void gc (); @@ -836,6 +878,9 @@ static archetype *read (object_thawer &f); MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ + +protected: + void do_delete (); }; // returns whether the object is a dragon player, which are often specialcased