Crossfire Server, Trunk  1.75.0
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 struct typedata {
90  int number;
91  const char *name;
92  const char *name_pl;
95 };
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 #define PU_CURSED 0x10000000
145 
147 /* Instead of using arbitrary constants for indexing the
148  * freearr, add these values. <= SIZEOFFREE1 will get you
149  * within 1 space. <= SIZEOFFREE2 wll get you withing
150  * 2 spaces, and the entire array (< SIZEOFFREE) is
151  * three spaces
152  */
153 #define SIZEOFFREE1 8
154 #define SIZEOFFREE2 24
155 #define SIZEOFFREE 49
156 
157 #define NROF_SOUNDS (23+NROFREALSPELLS) /* Number of sounds */
158 
163 #define IS_WEAPON(op) \
164  (op->type == ARROW || op->type == BOW || op->type == WEAPON)
165 
166 #define IS_ARMOR(op) \
167  (op->type == ARMOUR || op->type == HELMET || \
168  op->type == BOOTS || op->type == GLOVES)
169 
170 #define IS_SHIELD(op) \
171  (op->type == SHIELD)
172 
173 #define IS_LIVE(op) \
174  ((op->type == PLAYER || QUERY_FLAG(op, FLAG_MONSTER) || \
175  (QUERY_FLAG(op, FLAG_ALIVE) && !QUERY_FLAG(op, FLAG_GENERATOR) && \
176  !(op->type == DOOR))) && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
177 
178 #define IS_ARROW(op) \
179  (op->type == ARROW || \
180  (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_MAGIC_MISSILE)))
181 
184 #define HAS_RANDOM_ITEMS(op) (op->randomitems && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
185 
224 #define SET_FLAG(xyz, p) set_flag(xyz, p)
225 #define CLEAR_FLAG(xyz, p) clear_flag(xyz, p)
226 #define QUERY_FLAG(xyz, p) query_flag(xyz, p)
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
410 
417 typedef unsigned char MoveType;
418 #define OB_MOVE_BLOCK(ob1, ob2) ob_move_block(ob1, ob2)
419 
426 #define OB_TYPE_MOVE_BLOCK(ob1, type) \
427  ((type != 0) && (ob1->move_type&type) == ob1->move_type)
428 
430 #define GENERATE_TYPE(xyz) ((xyz)->stats.sp)
431 #define GENERATE_SPEED(xyz) ((xyz)->stats.maxsp) /* if(!RANDOM()%<speed>) */
432 
433 #define EXIT_PATH(xyz) (xyz)->slaying
434 #define EXIT_LEVEL(xyz) (xyz)->stats.food
435 #define EXIT_X(xyz) (xyz)->stats.hp
436 #define EXIT_Y(xyz) (xyz)->stats.sp
437 #define EXIT_ALT_X(xyz) (xyz)->stats.maxhp
438 #define EXIT_ALT_Y(xyz) (xyz)->stats.maxsp
439 
444 #define MAX_LIGHT_RADII 4
445 
448 #define MAX_DARKNESS 5
449 
453 #define MAX_WEAPON_ITEM_POWER 100
454 
455 static const int32_t MAX_FOOD = 999;
456 
457 #define DIRX(xyz) freearr_x[(xyz)->direction]
458 #define DIRY(xyz) freearr_y[(xyz)->direction]
459 
460 #define ARMOUR_SPEED(xyz) (xyz)->last_sp
461 #define ARMOUR_SPELLS(xyz) (xyz)->gen_sp_armour
462 #define WEAPON_SPEED(xyz) (xyz)->last_sp
463 
471 /*
472  * The following definitions are for the attack_movement variable in monsters.
473  * If the attack_variable movement is left out of the monster archetype, or is
474  * set to zero, the standard mode of movement from previous versions of
475  * Crossfire will be used. The upper four bits of movement data are not in
476  * effect when the monster has an enemy. These should only be used for non
477  * agressive monsters. To program a monsters movement add the attack movement
478  * numbers to the movement numbers example a monster that moves in a circle
479  * until attacked and then attacks from a distance:
480  * CIRCLE1 = 32
481  * + DISTATT = 1
482  * -------------------
483  * attack_movement = 33
484  */
485 #define DISTATT 1
487 #define RUNATT 2
488 #define HITRUN 3
489 #define WAITATT 4
490 #define RUSH 5
491 #define ALLRUN 6
492 #define DISTHIT 7
493 #define WAIT2 8
495 #define PETMOVE 16
503 #define CIRCLE1 32
507 #define CIRCLE2 48
508 #define PACEH 64
510 #define PACEH2 80
514 #define RANDO 96
517 #define RANDO2 112
518 #define PACEV 128
520 #define PACEV2 144
524 #define LO4 15
525 #define HI4 240
526 
535 #define ST_PLAYING 0
536 #define ST_PLAY_AGAIN 1
537 #define ST_ROLL_STAT 2
538 #define ST_CHANGE_CLASS 3
539 #define ST_CONFIRM_QUIT 4
540 #define ST_GET_NAME 6
541 #define ST_GET_PASSWORD 7
542 #define ST_CONFIRM_PASSWORD 8
543 #define ST_GET_PARTY_PASSWORD 10
544 #define ST_CHANGE_PASSWORD_OLD 11
545 #define ST_CHANGE_PASSWORD_NEW 12
546 #define ST_CHANGE_PASSWORD_CONFIRM 13
548 
549 #define BLANK_FACE_NAME "blank.111"
550 #define EMPTY_FACE_NAME "empty.111"
551 #define SMOOTH_FACE_NAME "default_smoothed.111"
552 
553 /*
554  * Defines for the luck/random functions to make things more readable
555  */
556 
557 #define PREFER_HIGH 1
558 #define PREFER_LOW 0
559 
566 /* Basic flags, always use one of these */
567 #define AP_NULL 0
568 #define AP_APPLY 1
569 #define AP_UNAPPLY 2
570 #define AP_OPEN 3
572 #define AP_BASIC_FLAGS 15
573 
574 /* Optional flags, for bitwise or with a basic flag */
575 #define AP_NO_MERGE 16
576 #define AP_IGNORE_CURSE 32
577 #define AP_PRINT 64
579 #define AP_NOPRINT 128
582 
583 
590 #define AC_PLAYER_STAT_LIMIT 1
591 #define AC_PLAYER_STAT_NO_CHANGE 2
593 
594 
624 #define CAN_APPLY_NEVER 0x1
625 #define CAN_APPLY_RESTRICTION 0x2
626 #define CAN_APPLY_NOT_MASK 0xf
627 #define CAN_APPLY_UNAPPLY 0x10
628 #define CAN_APPLY_UNAPPLY_MULT 0x20
629 #define CAN_APPLY_UNAPPLY_CHOICE 0x40
630 
633 #define MIN_ACTIVE_SPEED 0.00001
634 
635 uint32_t cf_random(void);
636 void cf_srandom(unsigned long seed);
637 
638 #define RANDOM() cf_random()
639 #define SRANDOM(seed) cf_srandom(seed)
640 
645 #define WEIGHT(op) (op->nrof ? op->weight : op->weight+op->carrying)
646 
664 #define FOR_INV_PREPARE(op_, it_) \
665  do { \
666  object *it_ = (op_)->inv; \
667  FOR_OB_AND_BELOW_PREPARE(it_);
668 
671 #define FOR_INV_FINISH() \
672  FOR_OB_AND_BELOW_FINISH(); \
673  } while(0)
674 
681 #define FOR_ABOVE_PREPARE(op_, it_) \
682  do { \
683  object *it_ = (op_)->above; \
684  FOR_OB_AND_ABOVE_PREPARE(it_);
685 
688 #define FOR_ABOVE_FINISH() \
689  FOR_OB_AND_ABOVE_FINISH(); \
690  } while(0)
691 
698 #define FOR_BELOW_PREPARE(op_, it_) \
699  do { \
700  object *it_ = (op_)->below; \
701  FOR_OB_AND_BELOW_PREPARE(it_);
702 
705 #define FOR_BELOW_FINISH() \
706  FOR_OB_AND_BELOW_FINISH(); \
707  } while(0)
708 
717 #define FOR_MAP_PREPARE(map_, mx_, my_, it_) \
718  do { \
719  object *it_ = GET_MAP_OB((map_), (mx_), (my_)); \
720  FOR_OB_AND_ABOVE_PREPARE(it_);
721 
724 #define FOR_MAP_FINISH() \
725  FOR_OB_AND_ABOVE_FINISH(); \
726  } while(0)
727 
733 #define FOR_OB_AND_ABOVE_PREPARE(op_) FOR_OB_PREPARE(op_, above, __LINE__)
734 
737 #define FOR_OB_AND_ABOVE_FINISH() FOR_OB_FINISH()
738 
744 #define FOR_OB_AND_BELOW_PREPARE(op_) FOR_OB_PREPARE(op_, below, __LINE__)
745 
748 #define FOR_OB_AND_BELOW_FINISH() FOR_OB_FINISH()
749 
757 #define FOR_OB_PREPARE(op_, field_, suffix_) FOR_OB_PREPARE2(op_, field_, suffix_)
758 
765 #define FOR_OB_PREPARE2(op_, field_, suffix_) \
766  do { \
767  object *next##suffix_ = (op_); \
768  tag_t next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;\
769  while (((op_) = next##suffix_) != NULL) { \
770  if (object_was_destroyed(next##suffix_, next_tag##suffix_)) {\
771  break; \
772  } \
773  next##suffix_ = next##suffix_->field_; \
774  next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;
775 
778 #define FOR_OB_FINISH() \
779  } \
780  } while(0)
781 
782 #endif /* DEFINE_H */
cf_random
uint32_t cf_random(void)
Definition: cf_random.cpp:5
typedata::identifyskill
int identifyskill
Skill used to identify this object class.
Definition: define.h:93
MoveType
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:417
typedata::name
const char * name
Object name.
Definition: define.h:91
typedata::name_pl
const char * name_pl
Plural name.
Definition: define.h:92
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
typedata
Link an object type with skill needed to identify, and general name.
Definition: define.h:89
ARCHTABLE_TOO_SMALL
@ ARCHTABLE_TOO_SMALL
Definition: define.h:50
MAP_ERROR
@ MAP_ERROR
Definition: define.h:49
typedata::number
int number
Type.
Definition: define.h:90
typedata::identifyskill2
int identifyskill2
Second skill used to identify this object class.
Definition: define.h:94
fatal_error
fatal_error
Fatal variables; used as arguments to fatal().
Definition: define.h:47
ARCHETYPE_ISSUE
@ ARCHETYPE_ISSUE
Definition: define.h:51
cf_srandom
void cf_srandom(unsigned long seed)
Definition: cf_random.cpp:9
OUT_OF_MEMORY
@ OUT_OF_MEMORY
Definition: define.h:48
MAX_FOOD
static const int32_t MAX_FOOD
Definition: define.h:455
autoconf.h