--- deliantra/server/include/object.h 2010/03/26 00:05:45 1.227 +++ deliantra/server/include/object.h 2010/04/12 05:22:38 1.241 @@ -2,8 +2,8 @@ * This file is part of Deliantra, the Roguelike Realtime MMORPG. * * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team - * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team - * Copyright (©) 1992,2007 Frank Tore Johansen + * Copyright (©) 2001 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992 Frank Tore Johansen * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the @@ -25,8 +25,6 @@ #ifndef OBJECT_H #define OBJECT_H -#include - #include "cfperl.h" #include "shstr.h" @@ -34,7 +32,9 @@ typedef int tag_t; -enum { +// also see common/item.C +enum +{ body_skill, body_combat, body_range, @@ -52,13 +52,6 @@ NUM_BODY_LOCATIONS }; -enum slottype_t -{ - slot_none, - slot_combat, - slot_ranged, -}; - /* See common/item.c */ typedef struct Body_Locations @@ -291,14 +284,30 @@ const_utf8_string query_short_name (const object *op); const_utf8_string query_name (const object *op); const_utf8_string query_base_name (const object *op, int plural); +sint64 query_cost (const object *tmp, object *who, int flag); +const char *query_cost_string (const object *tmp, object *who, int flag); + +int change_ability_duration (object *spell, object *caster); +int min_casting_level (object *caster, object *spell); +int casting_level (object *caster, object *spell); +sint16 SP_level_spellpoint_cost (object *caster, object *spell, int flags); +int SP_level_dam_adjust (object *caster, object *spob); +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 @@ -320,6 +329,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); @@ -362,7 +381,6 @@ static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. bool write (object_freezer &f); - MTH int slottype () const; MTH static object *create (); const mapxy &operator =(const mapxy &pos); MTH void copy_to (object *dst); @@ -379,6 +397,7 @@ // recursively destroy all objects in inventory, optionally dropping them to the ground instead MTH void destroy_inv (bool drop_to_ground = false); + MTH void destroy_inv_fast (); // like destroy_inv (false), but only works when *this is destroyed, too MTH object *insert (object *item); // insert into inventory MTH void play_sound (faceidx sound) const; MTH void say_msg (const_utf8_string msg) const; @@ -399,7 +418,15 @@ insert_at (this, this); } - // high-level move functions, return true if successful + // high-level move method. + // object op is trying to move in direction dir. + // originator is typically the same as op, but + // can be different if originator is causing op to + // move (originator is pushing op) + // returns 0 if the object is not able to move to the + // desired space, 1 otherwise (in which case we also + // move the object accordingly. This function is + // very similiar to move_object. int move (int dir, object *originator); int move (int dir) @@ -408,7 +435,7 @@ } // changes move_type to a new value - handles move_on/move_off effects - void change_move_type (MoveType mt); + MTH void change_move_type (MoveType mt); static bool can_merge_slow (object *op1, object *op2); @@ -423,8 +450,6 @@ 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); MTH void open_container (object *new_container); MTH void close_container () @@ -525,6 +550,8 @@ MTH bool is_dragon () const; + MTH bool is_immunity () const { return invisible && type == SIGN; } + MTH bool has_active_speed () const { return speed >= MIN_ACTIVE_SPEED; } // temporary: wether the object can be saved in a map file @@ -605,6 +632,9 @@ return !!contr; } + /* elmex: this method checks whether the object is in a shop */ + MTH bool is_in_shop () const; + MTH bool affects_los () const { return glow_radius || flag [FLAG_BLOCKSVIEW]; @@ -654,6 +684,7 @@ void enter_exit (object *exit);//Perl MTH void enter_map (maptile *newmap, int x, int y); 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 // returns the mapspace this object is in mapspace &ms () const; @@ -716,6 +747,7 @@ void statusmsg (const_utf8_string msg, int color = NDI_BLACK); 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 = ""); @@ -742,10 +774,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 (); @@ -791,7 +833,7 @@ //-GPL INTERFACE_CLASS (archetype) -struct archetype : object +struct archetype : object, zero_initialised { static arch_ptr empty; // the empty_archetype MTH static void gc (); @@ -819,6 +861,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