--- deliantra/server/include/object.h 2006/08/31 09:19:34 1.13
+++ deliantra/server/include/object.h 2012/11/21 12:12:03 1.267
@@ -1,59 +1,67 @@
/*
- * static char *rcsid_object_h =
- * "$Id$";
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
+ *
+ * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ * 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
+ * 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the Affero GNU General Public License
+ * and the GNU General Public License along with this program. If not, see
+ * .
+ *
+ * The authors can be reached via e-mail to
*/
-/*
- CrossFire, A Multiplayer game for X-windows
-
- 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
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 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
- 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-devel@real-time.com
-*/
-
#ifndef OBJECT_H
#define OBJECT_H
#include "cfperl.h"
#include "shstr.h"
-typedef uint32 tag_t;
-#define NUM_BODY_LOCATIONS 12
-#define BODY_ARMS 1
+//+GPL
+
+typedef int tag_t;
+
+// also see common/item.C
+enum
+{
+# define def(name, use, nonuse) body_ ## name,
+# include "slotinc.h"
+# undef def
+ NUM_BODY_LOCATIONS
+};
/* See common/item.c */
-typedef struct Body_Locations {
- const char *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;
+struct Body_Locations
+{
+ const char *name; /* Short name/identifier */
+ keyword kw; /* 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 */
+};
extern Body_Locations body_locations[NUM_BODY_LOCATIONS];
-typedef struct _event
-{
- int type;
- const char *hook;
- const char *plugin;
- const char *options;
- struct _event *next;
-} event;
+// for each set of directions (1 == up, 2 == right, 4 == down, 8 == left)
+// contains the wall suffix (0, 1_3, 1_4 and so on).
+extern const char *wall_suffix[16];
+
+#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
@@ -61,223 +69,791 @@
*
* key and value are shared-strings.
*
- * Please use get_ob_key_value(), set_ob_key_value() from object.c rather than
+ * Please use kv_get/kv_set/kv_del from object rather than
* accessing the list directly.
* Exception is if you want to walk this list for some reason.
*/
-typedef struct _key_value {
- const char * key;
- const char * value;
- struct _key_value * next;
-} key_value;
+struct key_value : slice_allocated
+{
+ key_value *next; // must be first element
+ shstr key, value;
+};
+// "crossfires version of a perl hash."
+struct key_values
+{
+ key_value *first; // must be first element
-/* Definition for WILL_APPLY values. Replaces having harcoded values
- * sprinkled in the code. Note that some of these also replace fields
- * that were in the can_apply area. What is the point of having both
- * can_apply and will_apply?
- */
-#define WILL_APPLY_HANDLE 0x1
-#define WILL_APPLY_TREASURE 0x2
-#define WILL_APPLY_EARTHWALL 0x4
-#define WILL_APPLY_DOOR 0x8
-#define WILL_APPLY_FOOD 0x10
+ bool empty() const
+ {
+ return !first;
+ }
+ void clear ();
+ shstr_tmp get (shstr_tmp key) const;
+ void del (shstr_tmp key);
+ void set (shstr_tmp key, shstr_tmp value);
+
+ void add (shstr_tmp key, shstr_tmp value); // liek set, but doesn't check for duplicates
+ void reverse (); // reverses the ordering, to be used after loading an object
+ key_values &operator =(const key_values &kv);
-/* Note that the ordering of this structure is sort of relevent -
- * copy_object copies everything over beyond 'name' using memcpy.
- * Thus, values that need to be copied need to be located beyond that
- * point.
- *
- * 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-object
- *
- * I've tried to clean up this structure a bit (in terms of formatting)
- * by making it more consistent. I've also tried to locate some of the fields
- * more logically together (put the item related ones together, the monster
- * related ones, etc.
- * This structure is best viewed with about a 100 width screen.
- * MSW 2002-07-05
- */
+ // custom extra fields management
+ struct access_proxy
+ {
+ key_values &kv;
+ shstr_tmp key;
-struct object_simple : attachable