Crossfire Server, Trunk  R20513
define.h
Go to the documentation of this file.
1 
14 #ifndef DEFINE_H
15 #define DEFINE_H
16 
17 #ifndef WIN32 /* ---win32 exclude unix configuration part */
18 #include <autoconf.h>
19 #endif
20 
22 #define FABS(x) ((x) < 0 ? -(x) : (x))
23 
24 #ifdef __NetBSD__
25 #include <sys/param.h>
26 #endif
27 
29 #ifndef NAME_MAX
30 #define NAME_MAX 255
31 #endif
32 
33 #define MIN_STAT 1
35 #define MAX_BUF 256
36 #define VERY_BIG_BUF 1024
37 #define HUGE_BUF 4096
39 #define MAX_ANIMATIONS 256
40 
41 #define MAX_NAME 48
42 #define BIG_NAME 32
43 
49  MAP_ERROR = 1,
53 };
54 
59 #define ST_BD_BUILD 1
60 #define ST_BD_REMOVE 2
62 
63 
67 #define ST_MAT_FLOOR 1
68 #define ST_MAT_WALL 2
69 #define ST_MAT_ITEM 3
70 #define ST_MAT_WINDOW 4
72 
73 
77 #define WEAP_HIT 0
78 #define WEAP_SLASH 1
79 #define WEAP_PIERCE 2
80 #define WEAP_CLEAVE 3
81 #define WEAP_SLICE 4
82 #define WEAP_STAB 5
83 #define WEAP_WHIP 6
84 #define WEAP_CRUSH 7
85 #define WEAP_BLUD 8
87 
88 
89 typedef struct typedata {
90  int number;
91  const char *name;
92  const char *name_pl;
95 } typedata;
96 
97 
105 /* high bit as flag for new pickup options */
106 #define PU_NOTHING 0x00000000
107 
108 #define PU_DEBUG 0x10000000
109 #define PU_INHIBIT 0x20000000
110 #define PU_STOP 0x40000000
111 #define PU_NEWMODE 0x80000000
112 
113 #define PU_RATIO 0x0000000F
114 
115 #define PU_FOOD 0x00000010
116 #define PU_DRINK 0x00000020
117 #define PU_VALUABLES 0x00000040
118 #define PU_BOW 0x00000080
119 
120 #define PU_ARROW 0x00000100
121 #define PU_HELMET 0x00000200
122 #define PU_SHIELD 0x00000400
123 #define PU_ARMOUR 0x00000800
124 
125 #define PU_BOOTS 0x00001000
126 #define PU_GLOVES 0x00002000
127 #define PU_CLOAK 0x00004000
128 #define PU_KEY 0x00008000
129 
130 #define PU_MISSILEWEAPON 0x00010000
131 #define PU_MELEEWEAPON 0x00020000
132 #define PU_MAGICAL 0x00040000
133 #define PU_POTION 0x00080000
134 
135 #define PU_SPELLBOOK 0x00100000
136 #define PU_SKILLSCROLL 0x00200000
137 #define PU_READABLES 0x00400000
138 #define PU_MAGIC_DEVICE 0x00800000
139 
140 #define PU_NOT_CURSED 0x01000000
141 #define PU_JEWELS 0x02000000
142 #define PU_FLESH 0x04000000
143 #define PU_CONTAINER 0x08000000
144 
146 /* Instead of using arbitrary constants for indexing the
147  * freearr, add these values. <= SIZEOFFREE1 will get you
148  * within 1 space. <= SIZEOFFREE2 wll get you withing
149  * 2 spaces, and the entire array (< SIZEOFFREE) is
150  * three spaces
151  */
152 #define SIZEOFFREE1 8
153 #define SIZEOFFREE2 24
154 #define SIZEOFFREE 49
155 
156 #define NROF_SOUNDS (23+NROFREALSPELLS) /* Number of sounds */
157 
162 #define IS_WEAPON(op) \
163  (op->type == ARROW || op->type == BOW || op->type == WEAPON)
164 
165 #define IS_ARMOR(op) \
166  (op->type == ARMOUR || op->type == HELMET || \
167  op->type == BOOTS || op->type == GLOVES)
168 
169 #define IS_SHIELD(op) \
170  (op->type == SHIELD)
171 
172 #define IS_LIVE(op) \
173  ((op->type == PLAYER || QUERY_FLAG(op, FLAG_MONSTER) || \
174  (QUERY_FLAG(op, FLAG_ALIVE) && !QUERY_FLAG(op, FLAG_GENERATOR) && \
175  !(op->type == DOOR))) && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
176 
177 #define IS_ARROW(op) \
178  (op->type == ARROW || \
179  (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_MAGIC_MISSILE)))
180 
183 #define HAS_RANDOM_ITEMS(op) (op->randomitems && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
184 
223 #define SET_FLAG(xyz, p) set_flag(xyz, p)
224 #define CLEAR_FLAG(xyz, p) clear_flag(xyz, p)
225 #define QUERY_FLAG(xyz, p) query_flag(xyz, p)
226 #define COMPARE_FLAGS(p, q) compare_flags(p, q)
227 
228 /* the flags themselves. */
229 
230 #define FLAG_ALIVE 0
231 #define FLAG_WIZ 1
232 #define FLAG_REMOVED 2
233 #define FLAG_FREED 3
234 #define FLAG_WAS_WIZ 4
235 #define FLAG_APPLIED 5
236 #define FLAG_UNPAID 6
237 #define FLAG_USE_SHIELD 7
239 #define FLAG_NO_PICK 8
240 #define FLAG_CLIENT_ANIM_SYNC 9
241 #define FLAG_CLIENT_ANIM_RANDOM 10
242 #define FLAG_ANIMATE 11
243 #define FLAG_DIALOG_PARSED 12
244 #define FLAG_NO_SAVE 13
245 #define FLAG_MONSTER 14
246 #define FLAG_FRIENDLY 15
248 #define FLAG_GENERATOR 16
249 #define FLAG_IS_THROWN 17
250 #define FLAG_AUTO_APPLY 18
251 #define FLAG_TREASURE 19
252 #define FLAG_PLAYER_SOLD 20
253 #define FLAG_SEE_INVISIBLE 21
254 #define FLAG_CAN_ROLL 22
255 #define FLAG_OVERLAY_FLOOR 23
256 #define FLAG_IS_TURNABLE 24
257 #define FLAG_PROBE 25
258 /*#define FLAG_FLY_ON 26*//* As WALK_ON, but only with FLAG_FLYING */
259 /*#define FLAG_FLY_OFF 27*//* As WALK_OFF, but only with FLAG_FLYING */
260 #define FLAG_IS_USED_UP 28
261 #define FLAG_IDENTIFIED 29
262 #define FLAG_REFLECTING 30
263 #define FLAG_CHANGING 31
265 /* Start of values in flags[1] */
266 #define FLAG_SPLITTING 32
267 #define FLAG_HITBACK 33
268 #define FLAG_STARTEQUIP 34
269 #define FLAG_BLOCKSVIEW 35
270 #define FLAG_UNDEAD 36
271 #define FLAG_SCARED 37
272 #define FLAG_UNAGGRESSIVE 38
273 #define FLAG_REFL_MISSILE 39
275 #define FLAG_REFL_SPELL 40
276 #define FLAG_NO_MAGIC 41
277 #define FLAG_NO_FIX_PLAYER 42
278 #define FLAG_IS_LIGHTABLE 43
279 #define FLAG_TEAR_DOWN 44
280 #define FLAG_RUN_AWAY 45
282 /*#define FLAG_PASS_THRU 46*/ /* Objects with can_pass_thru can pass \
283  thru this object as if it wasn't there */
284 /*#define FLAG_CAN_PASS_THRU 47*/ /* Can pass thru... */
285 
286 /*#define FLAG_PICK_UP 48*/ /* Can pick up */
287 #define FLAG_UNIQUE 49
288 #define FLAG_NO_DROP 50
289 #define FLAG_WIZCAST 51
290 #define FLAG_CAST_SPELL 52
291 #define FLAG_USE_SCROLL 53
292 #define FLAG_USE_RANGE 54
293 #define FLAG_USE_BOW 55
295 #define FLAG_USE_ARMOUR 56
296 #define FLAG_USE_WEAPON 57
297 #define FLAG_USE_RING 58
298 #define FLAG_READY_RANGE 59
299 #define FLAG_READY_BOW 60
300 #define FLAG_XRAYS 61
301 #define FLAG_NO_APPLY 62
302 #define FLAG_IS_FLOOR 63
304 /* Start of values in flags[2] */
305 #define FLAG_LIFESAVE 64
306 #define FLAG_NO_STRENGTH 65
307 #define FLAG_SLEEP 66
308 #define FLAG_STAND_STILL 67
309 #define FLAG_RANDOM_MOVE 68
310 #define FLAG_ONLY_ATTACK 69
311 #define FLAG_CONFUSED 70
312 #define FLAG_STEALTH 71
314 #define FLAG_WIZPASS 72
315 #define FLAG_IS_LINKED 73
316 #define FLAG_CURSED 74
317 #define FLAG_DAMNED 75
318 #define FLAG_SEE_ANYWHERE 76
319 #define FLAG_KNOWN_MAGICAL 77
320 #define FLAG_KNOWN_CURSED 78
321 #define FLAG_CAN_USE_SKILL 79
323 #define FLAG_BEEN_APPLIED 80
324 #define FLAG_READY_SCROLL 81
325 /*#define FLAG_USE_ROD 82 unused (Monster) can apply and use rods */
326 /*#define FLAG_READY_HORN 83 unused (Monster) has a horn readied */
327 /*#define FLAG_USE_HORN 84 unused (Monster) can apply and use horns */
328 #define FLAG_MAKE_INVIS 85
329 #define FLAG_INV_LOCKED 86
330 #define FLAG_IS_WOODED 87
332 #define FLAG_IS_HILLY 88
333 #define FLAG_READY_SKILL 89
334 #define FLAG_READY_WEAPON 90
335 #define FLAG_NO_SKILL_IDENT 91
336 #define FLAG_BLIND 92
337 #define FLAG_SEE_IN_DARK 93
338 #define FLAG_IS_CAULDRON 94
339 /*#define FLAG_DUST 95 *//* item is a 'powder', effects throwing */
340 
341 /* Start of values in flags[3] */
342 #define FLAG_NO_STEAL 96
343 #define FLAG_ONE_HIT 97
346 #define FLAG_CLIENT_SENT 98
352 #define FLAG_BERSERK 99
354 #define FLAG_NEUTRAL 100
355 #define FLAG_NO_ATTACK 101
356 #define FLAG_NO_DAMAGE 102
357 #define FLAG_OBJ_ORIGINAL 103
359 /*#define FLAG_OBJ_SAVE_ON_OVL 104 *//* this object should be saved on
360  * the overlay, and is not subject to
361  * decay. */
362 #define FLAG_ACTIVATE_ON_PUSH 105
363 #define FLAG_ACTIVATE_ON_RELEASE 106
364 #define FLAG_IS_WATER 107
365 #define FLAG_CONTENT_ON_GEN 108
366 #define FLAG_IS_A_TEMPLATE 109
367 #define FLAG_IS_BUILDABLE 110
368 #define FLAG_AFK 111
369 #define FLAG_BLESSED 112
370 #define FLAG_KNOWN_BLESSED 113
371 #define FLAG_PARALYZED 114
374 #define NUM_FLAGS 114
381 
382 
392 #define MOVE_WALK 0x1
393 #define MOVE_FLY_LOW 0x2
394 #define MOVE_FLY_HIGH 0x4
395 #define MOVE_FLYING 0x6
396 #define MOVE_SWIM 0x8
397 #define MOVE_BOAT 0x10
398 #define MOVE_ALL 0x1f
409 #define MOVE_BLOCK_DEFAULT MOVE_SWIM
417 typedef unsigned char MoveType;
418 
423 #define OB_MOVE_BLOCK(ob1, ob2) \
424  ((ob1->move_type&ob2->move_block) == ob1->move_type)
425 
432 #define OB_TYPE_MOVE_BLOCK(ob1, type) \
433  ((type != 0) && (ob1->move_type&type) == ob1->move_type)
434 
436 #define SET_GENERATE_TYPE(xyz, va) (xyz)->stats.sp = (va)
437 #define GENERATE_TYPE(xyz) ((xyz)->stats.sp)
438 #define GENERATE_SPEED(xyz) ((xyz)->stats.maxsp) /* if(!RANDOM()%<speed>) */
439 
440 #define EXIT_PATH(xyz) (xyz)->slaying
441 #define EXIT_LEVEL(xyz) (xyz)->stats.food
442 #define EXIT_X(xyz) (xyz)->stats.hp
443 #define EXIT_Y(xyz) (xyz)->stats.sp
444 #define EXIT_ALT_X(xyz) (xyz)->stats.maxhp
445 #define EXIT_ALT_Y(xyz) (xyz)->stats.maxsp
446 
451 #define MAX_LIGHT_RADII 4
455 #define MAX_DARKNESS 5
460 #define MAX_WEAPON_ITEM_POWER 100
461 
462 #define DIRX(xyz) freearr_x[(xyz)->direction]
463 #define DIRY(xyz) freearr_y[(xyz)->direction]
464 
465 #define ARMOUR_SPEED(xyz) (xyz)->last_sp
466 #define ARMOUR_SPELLS(xyz) (xyz)->gen_sp_armour
467 #define WEAPON_SPEED(xyz) (xyz)->last_sp
468 
476 /*
477  * The following definitions are for the attack_movement variable in monsters.
478  * If the attack_variable movement is left out of the monster archetype, or is
479  * set to zero, the standard mode of movement from previous versions of
480  * Crossfire will be used. The upper four bits of movement data are not in
481  * effect when the monster has an enemy. These should only be used for non
482  * agressive monsters. To program a monsters movement add the attack movement
483  * numbers to the movement numbers example a monster that moves in a circle
484  * until attacked and then attacks from a distance:
485  * CIRCLE1 = 32
486  * + DISTATT = 1
487  * -------------------
488  * attack_movement = 33
489  */
490 #define DISTATT 1
492 #define RUNATT 2
493 #define HITRUN 3
494 #define WAITATT 4
495 #define RUSH 5
496 #define ALLRUN 6
497 #define DISTHIT 7
498 #define WAIT2 8
500 #define PETMOVE 16
508 #define CIRCLE1 32
512 #define CIRCLE2 48
513 #define PACEH 64
515 #define PACEH2 80
519 #define RANDO 96
522 #define RANDO2 112
523 #define PACEV 128
525 #define PACEV2 144
529 #define LO4 15
530 #define HI4 240
531 
540 #define ST_PLAYING 0
541 #define ST_PLAY_AGAIN 1
542 #define ST_ROLL_STAT 2
543 #define ST_CHANGE_CLASS 3
544 #define ST_CONFIRM_QUIT 4
545 #define ST_GET_NAME 6
546 #define ST_GET_PASSWORD 7
547 #define ST_CONFIRM_PASSWORD 8
548 #define ST_GET_PARTY_PASSWORD 10
549 #define ST_CHANGE_PASSWORD_OLD 11
550 #define ST_CHANGE_PASSWORD_NEW 12
551 #define ST_CHANGE_PASSWORD_CONFIRM 13
553 
554 #define BLANK_FACE_NAME "blank.111"
555 #define EMPTY_FACE_NAME "empty.111"
556 #define SMOOTH_FACE_NAME "default_smoothed.111"
557 
558 /*
559  * Defines for the luck/random functions to make things more readable
560  */
561 
562 #define PREFER_HIGH 1
563 #define PREFER_LOW 0
564 
571 /* Basic flags, always use one of these */
572 #define AP_NULL 0
573 #define AP_APPLY 1
574 #define AP_UNAPPLY 2
576 #define AP_BASIC_FLAGS 15
578 /* Optional flags, for bitwise or with a basic flag */
579 #define AP_NO_MERGE 16
580 #define AP_IGNORE_CURSE 32
581 #define AP_PRINT 64
583 #define AP_NOPRINT 128
593 #define AC_PLAYER_STAT_LIMIT 1
594 #define AC_PLAYER_STAT_NO_CHANGE 2
626 #define CAN_APPLY_NEVER 0x1
627 #define CAN_APPLY_RESTRICTION 0x2
628 #define CAN_APPLY_NOT_MASK 0xf
629 #define CAN_APPLY_UNAPPLY 0x10
630 #define CAN_APPLY_UNAPPLY_MULT 0x20
631 #define CAN_APPLY_UNAPPLY_CHOICE 0x40
635 #define MIN_ACTIVE_SPEED 0.00001
636 
637 uint32_t cf_random(void);
638 void cf_srandom(unsigned long seed);
639 
640 #define RANDOM() cf_random()
641 #define SRANDOM(seed) cf_srandom(seed)
642 
647 #define WEIGHT(op) (op->nrof ? op->weight : op->weight+op->carrying)
648 
666 #define FOR_INV_PREPARE(op_, it_) \
667  do { \
668  object *it_ = (op_)->inv; \
669  FOR_OB_AND_BELOW_PREPARE(it_);
673 #define FOR_INV_FINISH() \
674  FOR_OB_AND_BELOW_FINISH(); \
675  } while(0)
676 
683 #define FOR_ABOVE_PREPARE(op_, it_) \
684  do { \
685  object *it_ = (op_)->above; \
686  FOR_OB_AND_ABOVE_PREPARE(it_);
687 
690 #define FOR_ABOVE_FINISH() \
691  FOR_OB_AND_ABOVE_FINISH(); \
692  } while(0)
693 
700 #define FOR_BELOW_PREPARE(op_, it_) \
701  do { \
702  object *it_ = (op_)->below; \
703  FOR_OB_AND_BELOW_PREPARE(it_);
704 
707 #define FOR_BELOW_FINISH() \
708  FOR_OB_AND_BELOW_FINISH(); \
709  } while(0)
710 
719 #define FOR_MAP_PREPARE(map_, mx_, my_, it_) \
720  do { \
721  object *it_ = GET_MAP_OB((map_), (mx_), (my_)); \
722  FOR_OB_AND_ABOVE_PREPARE(it_);
723 
726 #define FOR_MAP_FINISH() \
727  FOR_OB_AND_ABOVE_FINISH(); \
728  } while(0)
735 #define FOR_OB_AND_ABOVE_PREPARE(op_) FOR_OB_PREPARE(op_, above, __LINE__)
736 
739 #define FOR_OB_AND_ABOVE_FINISH() FOR_OB_FINISH()
740 
746 #define FOR_OB_AND_BELOW_PREPARE(op_) FOR_OB_PREPARE(op_, below, __LINE__)
747 
750 #define FOR_OB_AND_BELOW_FINISH() FOR_OB_FINISH()
751 
759 #define FOR_OB_PREPARE(op_, field_, suffix_) FOR_OB_PREPARE2(op_, field_, suffix_)
760 
767 #define FOR_OB_PREPARE2(op_, field_, suffix_) \
768  do { \
769  object *next##suffix_ = (op_); \
770  tag_t next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;\
771  while (((op_) = next##suffix_) != NULL) { \
772  if (object_was_destroyed(next##suffix_, next_tag##suffix_)) {\
773  break; \
774  } \
775  next##suffix_ = next##suffix_->field_; \
776  next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;
777 
780 #define FOR_OB_FINISH() \
781  } \
782  } while(0)
783 
784 #endif /* DEFINE_H */
void cf_srandom(unsigned long seed)
Definition: cf_random.c:16
int identifyskill
Skill used to identify this object class.
Definition: define.h:93
struct typedata typedata
Link an object type with skill needed to identify, and general name.
const char * name_pl
Plural name.
Definition: define.h:92
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:432
Link an object type with skill needed to identify, and general name.
Definition: define.h:89
uint32_t cf_random(void)
Definition: cf_random.c:6
int identifyskill2
Second skill used to identify this object class.
Definition: define.h:94
unsigned int uint32_t
Definition: win32.h:162
const char * name
Object name.
Definition: define.h:91
int number
Type.
Definition: define.h:90
fatal_error
Fatal variables; used as arguments to fatal().
Definition: define.h:47