Crossfire Server, Trunk  R20608
object.h
Go to the documentation of this file.
1 
6 #include "dialog.h"
7 
8 #ifndef OBJECT_H
9 #define OBJECT_H
10 
12 typedef uint32_t tag_t;
13 #define NUM_BODY_LOCATIONS 13
14 #define BODY_ARMS 1
20 typedef struct body_locations_struct {
21  const char *save_name;
22  const char *use_name;
23  const char *nonuse_name;
25 
27 
28 extern const char *const move_name[];
29 
40 typedef struct _key_value {
41  const char *key;
42  const char *value;
43  struct _key_value *next;
44 } key_value;
45 
52 #define WILL_APPLY_HANDLE 0x1
53 #define WILL_APPLY_TREASURE 0x2
54 #define WILL_APPLY_EARTHWALL 0x4
55 #define WILL_APPLY_DOOR 0x8
56 #define WILL_APPLY_FOOD 0x10
58 
59 
68 #define object_was_destroyed(op, old_tag) \
69  (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))
70 
71 
81 #define SPELL_TAG_SIZE 16
82 
87 #define OB_SPELL_TAG_HASH(op, count) (op->spell_tags[count&0xf])
88 
93 #define OB_SPELL_TAG_MATCH(op, count) (op->spell_tags[count&0xf] == count)
94 
107  PLAYER = 1,
108  TRANSPORT = 2,
109  ROD = 3,
110  TREASURE = 4,
111  POTION = 5,
112  FOOD = 6,
113  POISON = 7,
114  BOOK = 8,
115  CLOCK = 9,
117  ARROW = 13,
118  BOW = 14,
119  WEAPON = 15,
120  ARMOUR = 16,
121  PEDESTAL = 17,
122  ALTAR = 18,
125  MAP = 22,
126  DOOR = 23,
127  KEY = 24,
129  TRIGGER = 27,
131  MAGIC_EAR = 29,
135  SHIELD = 33,
136  HELMET = 34,
137  MONEY = 36,
138  CLASS = 37,
139  AMULET = 39,
142  CREATOR = 42,
143  SKILL = 43,
144  EARTHWALL = 45,
145  GOLEM = 46,
147  BLINDNESS = 49,
148  GOD = 50,
149  DETECTOR = 51,
157  DRINK = 54,
158  MARKER = 55,
164  PEACEMAKER = 59,
167  GEM = 60,
168  FIREWALL = 62,
169  CHECK_INV = 64,
170  MOOD_FLOOR = 65,
181  EXIT = 66,
182  ENCOUNTER = 67,
184  SHOP_MAT = 69,
185  RING = 70,
186  FLOOR = 71,
187  FLESH = 72,
188  INORGANIC = 73,
189  SKILL_TOOL = 74,
190  LIGHTER = 75,
191  WALL = 77,
193  MISC_OBJECT = 79,
200  MONSTER = 80,
201  LAMP = 82,
202  DUPLICATOR = 83,
203  SPELLBOOK = 85,
204  CLOAK = 87,
205  SPINNER = 90,
206  GATE = 91,
207  BUTTON = 92,
208  CF_HANDLE = 93,
209  HOLE = 94, /* When open, objects fall through */
210  TRAPDOOR = 95,
211  SIGN = 98,
212  BOOTS = 99,
213  GLOVES = 100,
214  SPELL = 101,
216  CONVERTER = 103,
217  BRACERS = 104,
218  POISONING = 105,
219  SAVEBED = 106,
220  WAND = 109,
221  SCROLL = 111,
222  DIRECTOR = 112,
223  GIRDLE = 113,
224  FORCE = 114,
229  CLOSE_CON = 121,
231  CONTAINER = 122,
234  SKILLSCROLL = 130,
236  DEEP_SWAMP = 138,
240  RUNE = 154,
241  TRAP = 155,
243  CORPSE = 157,
244  DISEASE = 158,
245  SYMPTOM = 159,
246  BUILDER = 160,
248  MATERIAL = 161,
249  MIMIC = 162,
251 };
252 
274 typedef struct obj {
275  /* These variables are not changed by object_copy() */
276  struct pl *contr;
277  struct obj *next;
278  struct obj *prev;
279  struct obj *active_next;
283  struct obj *active_prev;
287  struct obj *below;
288  struct obj *above;
289  /* Note: stacked in the *same *environment*/
290  struct obj *inv;
291  struct obj *container;
293  struct obj *env;
295  struct obj *more;
296  struct obj *head;
297  struct mapdef *map;
303  /* These get an extra add_refcount(), after having been copied by memcpy().
304  *
305  * Fields below name (included) are copied by memcpy in object_copy().
306  *
307  * If adding something that needs a refcount updated, make sure you modify
308  * object_copy() to do so.
309  * Everything below here also gets cleared by object_clear().
310  */
311  const char *name;
312  /* Place new attributes that should get copied and cleared below name */
313 
315  const char *name_pl;
316  const char *anim_suffix;
317  const char *title;
318  const char *race;
319  const char *slaying;
321  const char *skill;
322  const char *msg;
323  const char *lore;
328  float speed;
329  float speed_left;
330  float weapon_speed;
332  const New_Face *face;
337  /* This next big block are basically used for monsters and equipment */
346  const char *materialname;
353  /* Note that the last_.. values are sometimes used for non obvious
354  * meanings by some objects, eg, sp penalty, permanent exp.
355  */
370  struct obj *current_weapon;
374  /* See the doc/Developers/objects for more info about body locations */
375 
376  /* Following mostly refers to fields only used for monsters */
377  struct obj *owner;
381  struct obj *enemy;
382  struct obj *attacked_by;
386  struct obj *chosen_skill;
388  /* changes made by kholland@sunlab.cit.cornell.edu */
389  /* allows different movement patterns for attackers */
394  struct obj *spellitem;
395  double expmul;
398  /* Spell related information, may be useful elsewhere
399  * Note that other fields are used - these files are basically
400  * only used in spells.
401  */
408  struct obj *spell;
409  char *spellarg;
411  /* Following are values used by any object */
412  struct archt *arch;
413  struct archt *other_arch;
432  const char *custom_name;
437 } object;
438 
442 typedef struct oblnk {
443  object *ob;
444  struct oblnk *next;
446 } objectlink;
447 
451 typedef struct oblinkpt {
452  struct oblnk *link;
453  long value;
454  struct oblinkpt *next;
455 } oblinkpt;
456 
465 typedef struct archt {
466  const char *name;
467  struct archt *next;
468  struct archt *head;
469  struct archt *more;
470  object clone;
474 } archetype;
475 
476 extern object *objects;
477 extern object *active_objects;
478 extern object *free_objects;
479 extern object objarray[STARTMAX];
480 
481 extern int nrofallocobjects;
482 extern int nroffreeobjects;
483 
484 static inline int compare_flags(const object *p, const object *q) {
485  return ((p)->flags[0] == (q)->flags[0]) &&
486  ((p)->flags[1] == (q)->flags[1]) &&
487  ((p)->flags[2] == (q)->flags[2]) &&
488  ((p)->flags[3] == (q)->flags[3]);
489 }
490 
491 static inline int query_flag(const object *op, int flag) {
492  return op->flags[flag / 32] & (1U << (flag % 32));
493 }
494 
495 static inline void clear_flag(object *op, int flag) {
496  op->flags[flag / 32] &= ~(1U << (flag % 32));
497 }
498 
499 static inline void set_flag(object *op, int flag) {
500  op->flags[flag / 32] |= (1U << (flag % 32));
501 }
502 
507 #define LOOK_OBJ(ob) (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)
508 
516 #define UP_OBJ_INSERT 1
517 #define UP_OBJ_REMOVE 2
518 #define UP_OBJ_CHANGE 3
519 #define UP_OBJ_FACE 4
523 
524 
530 #define FREE_OBJ_FREE_INVENTORY 1
531 #define FREE_OBJ_NO_DESTROY_CALLBACK 2
532 #define FREE_OBJ_DROP_ABOVE_FLOOR 4
535 
566 #define INS_NO_MERGE 0x0001
567 #define INS_ABOVE_FLOOR_ONLY 0x0002
568 #define INS_NO_WALK_ON 0x0004
569 #define INS_ON_TOP 0x0008
570 #define INS_BELOW_ORIGINATOR 0x0010
571 #define INS_MAP_LOAD 0x0020
574 #define ARCH_SINGULARITY "singularity"
575 #define ARCH_SINGULARITY_LEN 11
576 #define ARCH_DETECT_MAGIC "detect_magic"
577 #define ARCH_DEPLETION "depletion"
578 #define ARCH_SYMPTOM "symptom"
579 #define ARCH_PORTAL_FAILED "town_portal_failed"
580 #define ARCH_SPELL_BLOCKED "spell_blocked"
581 #define ARCH_SPELL_BUNGLE "spell_bungle"
592 #define HEAD(op) ((op)->head != NULL ? (op)->head : (op))
593 
594 #endif /* OBJECT_H */
float weapon_speed_left
Definition: object.h:331
Definition: object.h:274
int reference_count
Definition: object.h:473
static int compare_flags(const object *p, const object *q)
Definition: object.h:484
#define NUM_BODY_LOCATIONS
Definition: object.h:13
Definition: player.h:92
struct _key_value * next
Definition: object.h:43
int32_t weight_limit
Definition: object.h:366
tag_t ownercount
Definition: object.h:380
MoveType move_type
Definition: object.h:424
Definition: object.h:127
uint8_t dam_modifier
Definition: object.h:407
MoveType move_on
Definition: object.h:427
Definition: object.h:185
int8_t tail_x
Definition: object.h:471
Definition: object.h:125
Definition: object.h:442
const char * race
Definition: object.h:318
uint16_t attack_movement
Definition: object.h:391
tag_t attacked_by_count
Definition: object.h:383
MoveType move_allow
Definition: object.h:426
int nrofallocobjects
Definition: object.c:57
unsigned char uint8_t
Definition: win32.h:161
Definition: object.h:221
uint16_t animation_id
Definition: object.h:416
uint16_t material
Definition: object.h:347
tag_t * spell_tags
Definition: object.h:436
uint8_t anim_speed
Definition: object.h:417
sstring artifact
Definition: object.h:314
Definition: object.h:204
Definition: object.h:112
struct obj * container
Definition: object.h:291
uint8_t last_anim
Definition: object.h:418
Definition: object.h:117
int8_t range
Definition: object.h:405
unsigned char MoveType
Definition: define.h:432
int32_t last_heal
Definition: object.h:357
Definition: object.h:137
struct treasureliststruct * randomitems
Definition: object.h:385
object clone
Definition: object.h:470
int16_t duration
Definition: object.h:403
int16_t invisible
Definition: object.h:360
uint8_t duration_modifier
Definition: object.h:404
Definition: object.h:240
Definition: object.h:119
const char * key
Definition: object.h:41
struct obj * prev
Definition: object.h:278
Definition: object.h:136
const char * slaying
Definition: object.h:319
Definition: object.h:138
int32_t last_sp
Definition: object.h:358
object * free_objects
Definition: object.c:61
uint8_t subtype
Definition: object.h:339
Definition: object.h:109
uint8_t hide
Definition: object.h:387
struct obj * above
Definition: object.h:288
struct oblinkpt oblinkpt
double expmul
Definition: object.h:395
Definition: object.h:157
Definition: object.h:223
Definition: living.h:34
Definition: object.h:139
Definition: object.h:249
Definition: object.h:191
uint32_t path_attuned
Definition: object.h:343
uint8_t temp_anim_speed
Definition: object.h:420
uint8_t smoothlevel
Definition: object.h:421
Definition: object.h:187
uint32_t path_repelled
Definition: object.h:344
Definition: object.h:212
struct obj * enemy
Definition: object.h:381
struct archt * other_arch
Definition: object.h:413
long value
Definition: object.h:453
struct obj object
tag_t id
Definition: object.h:445
Definition: object.h:465
Definition: object.h:220
uint16_t temp_animation_id
Definition: object.h:419
int8_t tail_y
Definition: object.h:471
struct oblnk * link
Definition: object.h:452
object * ob
Definition: object.h:443
int16_t * discrete_damage
Definition: object.h:435
Definition: object.h:241
const char * lore
Definition: object.h:323
struct obj * chosen_skill
Definition: object.h:386
const char * title
Definition: object.h:317
int16_t y
Definition: object.h:326
static int query_flag(const object *op, int flag)
Definition: object.h:491
struct oblinkpt * next
Definition: object.h:454
Definition: object.h:186
Definition: object.h:118
uint32_t path_denied
Definition: object.h:345
Definition: object.h:211
#define STARTMAX
Definition: config.h:573
Definition: object.h:114
Definition: object.h:181
struct obj * spell
Definition: object.h:408
const char * name_pl
Definition: object.h:315
const char * save_name
Definition: object.h:21
float speed_left
Definition: object.h:329
Definition: object.h:158
signed short int16_t
Definition: win32.h:160
int16_t ox
Definition: object.h:327
const char * materialname
Definition: object.h:346
int32_t weight
Definition: object.h:365
const char * anim_suffix
Definition: object.h:316
uint8_t range_modifier
Definition: object.h:406
uint32_t flags[4]
Definition: object.h:415
Definition: object.h:115
struct mapdef * map
Definition: object.h:297
struct obj * active_prev
Definition: object.h:283
object * active_objects
Definition: object.c:62
uint8_t sound_chance
Definition: object.h:393
Definition: object.h:145
int32_t carrying
Definition: object.h:367
const char * name
Definition: object.h:311
struct obj * env
Definition: object.h:293
static void set_flag(object *op, int flag)
Definition: object.h:499
int64_t perm_exp
Definition: object.h:369
int8_t gen_sp_armour
Definition: object.h:363
uint8_t state
Definition: object.h:349
struct obj * below
Definition: object.h:287
struct archt * more
Definition: object.h:469
int16_t last_grace
Definition: object.h:359
struct obj * current_weapon
Definition: object.h:370
int8_t direction
Definition: object.h:334
uint32_t nrof
Definition: object.h:333
struct oblnk objectlink
struct archt * head
Definition: object.h:468
MoveType move_off
Definition: object.h:428
Definition: object.h:111
struct pl * contr
Definition: object.h:276
int8_t item_power
Definition: object.h:362
int16_t oy
Definition: object.h:327
const char * use_name
Definition: object.h:22
char * spellarg
Definition: object.h:409
uint32_t tag_t
Definition: object.h:12
float speed
Definition: object.h:328
Definition: object.h:214
struct obj * active_next
Definition: object.h:279
Definition: object.h:126
const char * nonuse_name
Definition: object.h:23
int16_t x
Definition: object.h:326
MoveType move_slow
Definition: object.h:429
const char * skill
Definition: object.h:321
int32_t last_eat
Definition: object.h:356
Definition: object.h:201
unsigned short uint16_t
Definition: win32.h:163
signed __int64 int64_t
Definition: win32.h:168
struct struct_dialog_information * dialog_information
Definition: object.h:300
static const flag_definition flags[]
key_value * key_values
Definition: object.h:433
struct obj * next
Definition: object.h:277
int16_t resist[NROFATTACKS]
Definition: object.h:341
const char * sstring
Definition: global.h:40
object_type
Definition: object.h:106
Definition: object.h:107
unsigned int uint32_t
Definition: win32.h:162
Definition: object.h:113
const char *const move_name[]
Definition: object.c:4716
Definition: object.h:135
int8_t body_info[NUM_BODY_LOCATIONS]
Definition: object.h:372
uint32_t attacktype
Definition: object.h:342
struct obj * spellitem
Definition: object.h:394
uint8_t map_layer
Definition: object.h:422
Definition: object.h:122
struct obj * owner
Definition: object.h:377
Definition: object.h:243
signed char int8_t
Definition: win32.h:158
Definition: object.h:143
const char * custom_name
Definition: object.h:432
struct body_locations_struct body_locations_struct
tag_t count
Definition: object.h:299
living stats
Definition: object.h:368
uint16_t client_type
Definition: object.h:340
struct archt * arch
Definition: object.h:412
object objarray[STARTMAX]
Definition: object.c:55
struct oblnk * next
Definition: object.h:444
Definition: object.h:207
Definition: object.h:206
uint8_t will_apply
Definition: object.h:392
static void clear_flag(object *op, int flag)
Definition: object.h:495
uint8_t type
Definition: object.h:338
struct archt * next
Definition: object.h:467
uint32_t weapontype
Definition: object.h:371
#define NROFATTACKS
Definition: attack.h:17
body_locations_struct body_locations[NUM_BODY_LOCATIONS]
Definition: item.c:54
signed int int32_t
Definition: win32.h:159
const char * msg
Definition: object.h:322
const char * value
Definition: object.h:42
int16_t casting_time
Definition: object.h:402
int8_t glow_radius
Definition: object.h:364
struct _key_value key_value
struct obj * inv
Definition: object.h:290
struct obj * head
Definition: object.h:296
Definition: object.h:213
uint8_t pick_up
Definition: object.h:361
int nroffreeobjects
Definition: object.c:56
MoveType move_block
Definition: object.h:425
uint8_t run_away
Definition: object.h:384
Definition: object.h:209
float move_slow_penalty
Definition: object.h:430
object * objects
Definition: object.c:60
Definition: map.h:325
const New_Face * face
Definition: object.h:332
Definition: object.h:167
Definition: object.h:120
int32_t move_status
Definition: object.h:390
int16_t level
Definition: object.h:351
int8_t facing
Definition: object.h:335
float weapon_speed
Definition: object.h:330
Definition: object.h:148
struct obj * more
Definition: object.h:295
int32_t value
Definition: object.h:350
int8_t magic
Definition: object.h:348
const char * name
Definition: object.h:466
struct archt archetype
struct obj * attacked_by
Definition: object.h:382
int8_t body_used[NUM_BODY_LOCATIONS]
Definition: object.h:373
Definition: object.h:224