--- deliantra/server/include/object.h 2007/05/12 13:27:37 1.119
+++ deliantra/server/include/object.h 2007/08/27 06:29:17 1.146
@@ -1,25 +1,24 @@
/*
- * CrossFire, A Multiplayer Online RPG
- *
- * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
- * Copyright (C) 2001 Mark Wedel & Crossfire Development Team
- * Copyright (C) 1992 Frank Tore Johansen
- *
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
+ *
+ * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
+ * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
+ * Copyright (©) 1992,2007 Frank Tore Johansen
+ *
+ * Crossfire TRT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * The authors can be reached via e-mail at crossfire@schmorp.de
+ * along with this program. If not, see .
+ *
+ * The authors can be reached via e-mail to
*/
#ifndef OBJECT_H
@@ -33,14 +32,14 @@
typedef int tag_t;
enum {
+ body_skill,
+ body_combat,
body_range,
body_shield,
- body_combat,
body_arm,
body_torso,
body_head,
body_neck,
- body_skill,
body_finger,
body_shoulder,
body_foot,
@@ -50,11 +49,18 @@
NUM_BODY_LOCATIONS
};
+enum slottype_t
+{
+ slot_none,
+ slot_combat,
+ slot_ranged,
+};
+
/* See common/item.c */
typedef struct Body_Locations
{
- const char *save_name; /* Name used to load/save it to disk */
+ keyword save_name; /* Name used to load/save it to disk */
const char *use_name; /* Name used when describing an item we can use */
const char *nonuse_name; /* Name to describe objects we can't use */
} Body_Locations;
@@ -102,11 +108,6 @@
#define WILL_APPLY_DOOR 0x08
#define WILL_APPLY_FOOD 0x10
-/* However, if you're keeping a pointer of some sort, you probably
- * don't just want it copied, so you'll need to add to common/object.C,
- * e.g. ->copy_to ()
- */
-
struct body_slot
{
signed char info:4; /* body info as loaded from the file */
@@ -185,7 +186,9 @@
uint32 ACC (RW, weapontype); /* type of weapon */
uint32 ACC (RW, tooltype); /* type of tool or build facility */
body_slot slot [NUM_BODY_LOCATIONS];
- faceidx ACC (RW, face); /* Face with colors */
+ faceidx ACC (RW, face); /* the graphical face */
+ faceidx ACC (RW, sound); /* the sound face */
+ faceidx ACC (RW, sound_destroy); /* played on destroy */
living ACC (RO, stats); /* Str, Con, Dex, etc */
/* See the pod/objects.pod for more info about body locations */
@@ -246,10 +249,10 @@
UUID ACC (RW, uuid); // Unique Identifier, survives saves etc.
int ACC (RO, count);
- int ACC (RO, index); // index into objects
- int ACC (RO, active); // index into actives
+ object_vector_index ACC (RO, index); // index into objects
+ object_vector_index ACC (RO, active); // index into actives
- player_ptr ACC (RW, contr); /* Pointer to the player which control this object */
+ player_ptr ACC (RW, contr); /* Pointer to the player which control this object, ALWAYS set *iff* type == PLAYER */
object *ACC (RW, below); /* Pointer to the object stacked below this one */
object *ACC (RW, above); /* Pointer to the object stacked above this one */
@@ -273,7 +276,9 @@
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);
object &operator =(const object &src);
MTH void copy_to (object *dst);
MTH object *clone (); // create + copy_to
@@ -284,6 +289,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) const;
+
void do_remove ();
MTH void remove ()
{
@@ -291,20 +298,11 @@
do_remove ();
}
- // move this object to the top of its env's inventory to speed up
- // searches for it.
- MTH void inv_splay ()
- {
- if (env && env->inv != this)
- {
- if (above) above->below = below;
- if (below) below->above = above;
-
- above = 0;
- below = env->inv;
- below->above = this;
- env->inv = this;
- }
+ void move_to (const mapxy &pos)
+ {
+ remove ();
+ *this = pos;
+ insert_at (this, this);
}
static bool can_merge_slow (object *op1, object *op2);
@@ -319,7 +317,8 @@
MTH void set_owner (object *owner);
MTH void set_speed (float speed);
- MTH void set_weapon (object *ob);
+ MTH bool change_weapon (object *ob);
+ MTH bool change_skill (object *ob);
MTH void open_container (object *new_container);
MTH void close_container ()
@@ -327,6 +326,15 @@
open_container (0);
}
+ MTH object *force_find (const shstr name);
+ MTH void force_add (const shstr name, int duration = 0);
+
+ // overwrite the attachable should_invoke function with a version that also checks ev_want_type
+ bool should_invoke (event_type event)
+ {
+ return ev_want_event [event] || ev_want_type [type] || cb;
+ }
+
MTH void instantiate ();
// recalculate all stats
@@ -385,7 +393,7 @@
// contr => is a player
// head => only save head of a multitile object
// owner => can not reference owner yet
- MTH bool can_map_save () const { return !contr && !head && !owner && !flag [FLAG_NO_MAP_SAVE]; }
+ MTH bool can_map_save () const { return !head && (!owner || owner->contr) && !contr && !flag [FLAG_NO_MAP_SAVE]; }
/* This return true if object has still randomitems which
* could be expanded.
@@ -408,6 +416,11 @@
return head ? head : this;
}
+ MTH bool is_head ()
+ {
+ return head_ () == this;
+ }
+
MTH std::string long_desc (object *who = 0);
MTH std::string describe_monster (object *who = 0);
MTH std::string describe_item (object *who = 0);
@@ -424,6 +437,7 @@
// 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);
+ MTH void drop_unpaid_items ();
MTH void activate ();
MTH void deactivate ();
@@ -489,29 +503,35 @@
MTH struct region *region () const;
-protected:
- friend struct archetype;
+ void statusmsg (const char *msg, int color = NDI_BLACK);
+ void failmsg (const char *msg, int color = NDI_RED);
- void link ();
+protected:
+ void link ();
void unlink ();
object ();
~object ();
};
-typedef object_vector