Crossfire Server, Trunk
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 
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 GENERATE_TYPE(xyz) ((xyz)->stats.sp)
437 #define GENERATE_SPEED(xyz) ((xyz)->stats.maxsp) /* if(!RANDOM()%<speed>) */
438 
439 #define EXIT_PATH(xyz) (xyz)->slaying
440 #define EXIT_LEVEL(xyz) (xyz)->stats.food
441 #define EXIT_X(xyz) (xyz)->stats.hp
442 #define EXIT_Y(xyz) (xyz)->stats.sp
443 #define EXIT_ALT_X(xyz) (xyz)->stats.maxhp
444 #define EXIT_ALT_Y(xyz) (xyz)->stats.maxsp
445 
450 #define MAX_LIGHT_RADII 4
451 
454 #define MAX_DARKNESS 5
455 
459 #define MAX_WEAPON_ITEM_POWER 100
460 
461 static const int32_t MAX_FOOD = 999;
462 
463 #define DIRX(xyz) freearr_x[(xyz)->direction]
464 #define DIRY(xyz) freearr_y[(xyz)->direction]
465 
466 #define ARMOUR_SPEED(xyz) (xyz)->last_sp
467 #define ARMOUR_SPELLS(xyz) (xyz)->gen_sp_armour
468 #define WEAPON_SPEED(xyz) (xyz)->last_sp
469 
477 /*
478  * The following definitions are for the attack_movement variable in monsters.
479  * If the attack_variable movement is left out of the monster archetype, or is
480  * set to zero, the standard mode of movement from previous versions of
481  * Crossfire will be used. The upper four bits of movement data are not in
482  * effect when the monster has an enemy. These should only be used for non
483  * agressive monsters. To program a monsters movement add the attack movement
484  * numbers to the movement numbers example a monster that moves in a circle
485  * until attacked and then attacks from a distance:
486  * CIRCLE1 = 32
487  * + DISTATT = 1
488  * -------------------
489  * attack_movement = 33
490  */
491 #define DISTATT 1
493 #define RUNATT 2
494 #define HITRUN 3
495 #define WAITATT 4
496 #define RUSH 5
497 #define ALLRUN 6
498 #define DISTHIT 7
499 #define WAIT2 8
501 #define PETMOVE 16
509 #define CIRCLE1 32
513 #define CIRCLE2 48
514 #define PACEH 64
516 #define PACEH2 80
520 #define RANDO 96
523 #define RANDO2 112
524 #define PACEV 128
526 #define PACEV2 144
530 #define LO4 15
531 #define HI4 240
532 
541 #define ST_PLAYING 0
542 #define ST_PLAY_AGAIN 1
543 #define ST_ROLL_STAT 2
544 #define ST_CHANGE_CLASS 3
545 #define ST_CONFIRM_QUIT 4
546 #define ST_GET_NAME 6
547 #define ST_GET_PASSWORD 7
548 #define ST_CONFIRM_PASSWORD 8
549 #define ST_GET_PARTY_PASSWORD 10
550 #define ST_CHANGE_PASSWORD_OLD 11
551 #define ST_CHANGE_PASSWORD_NEW 12
552 #define ST_CHANGE_PASSWORD_CONFIRM 13
554 
555 #define BLANK_FACE_NAME "blank.111"
556 #define EMPTY_FACE_NAME "empty.111"
557 #define SMOOTH_FACE_NAME "default_smoothed.111"
558 
559 /*
560  * Defines for the luck/random functions to make things more readable
561  */
562 
563 #define PREFER_HIGH 1
564 #define PREFER_LOW 0
565 
572 /* Basic flags, always use one of these */
573 #define AP_NULL 0
574 #define AP_APPLY 1
575 #define AP_UNAPPLY 2
576 #define AP_OPEN 3
578 #define AP_BASIC_FLAGS 15
579 
580 /* Optional flags, for bitwise or with a basic flag */
581 #define AP_NO_MERGE 16
582 #define AP_IGNORE_CURSE 32
583 #define AP_PRINT 64
585 #define AP_NOPRINT 128
588 
589 
596 #define AC_PLAYER_STAT_LIMIT 1
597 #define AC_PLAYER_STAT_NO_CHANGE 2
599 
600 
630 #define CAN_APPLY_NEVER 0x1
631 #define CAN_APPLY_RESTRICTION 0x2
632 #define CAN_APPLY_NOT_MASK 0xf
633 #define CAN_APPLY_UNAPPLY 0x10
634 #define CAN_APPLY_UNAPPLY_MULT 0x20
635 #define CAN_APPLY_UNAPPLY_CHOICE 0x40
636 
639 #define MIN_ACTIVE_SPEED 0.00001
640 
641 uint32_t cf_random(void);
642 void cf_srandom(unsigned long seed);
643 
644 #define RANDOM() cf_random()
645 #define SRANDOM(seed) cf_srandom(seed)
646 
651 #define WEIGHT(op) (op->nrof ? op->weight : op->weight+op->carrying)
652 
670 #define FOR_INV_PREPARE(op_, it_) \
671  do { \
672  object *it_ = (op_)->inv; \
673  FOR_OB_AND_BELOW_PREPARE(it_);
674 
677 #define FOR_INV_FINISH() \
678  FOR_OB_AND_BELOW_FINISH(); \
679  } while(0)
680 
687 #define FOR_ABOVE_PREPARE(op_, it_) \
688  do { \
689  object *it_ = (op_)->above; \
690  FOR_OB_AND_ABOVE_PREPARE(it_);
691 
694 #define FOR_ABOVE_FINISH() \
695  FOR_OB_AND_ABOVE_FINISH(); \
696  } while(0)
697 
704 #define FOR_BELOW_PREPARE(op_, it_) \
705  do { \
706  object *it_ = (op_)->below; \
707  FOR_OB_AND_BELOW_PREPARE(it_);
708 
711 #define FOR_BELOW_FINISH() \
712  FOR_OB_AND_BELOW_FINISH(); \
713  } while(0)
714 
723 #define FOR_MAP_PREPARE(map_, mx_, my_, it_) \
724  do { \
725  object *it_ = GET_MAP_OB((map_), (mx_), (my_)); \
726  FOR_OB_AND_ABOVE_PREPARE(it_);
727 
730 #define FOR_MAP_FINISH() \
731  FOR_OB_AND_ABOVE_FINISH(); \
732  } while(0)
733 
739 #define FOR_OB_AND_ABOVE_PREPARE(op_) FOR_OB_PREPARE(op_, above, __LINE__)
740 
743 #define FOR_OB_AND_ABOVE_FINISH() FOR_OB_FINISH()
744 
750 #define FOR_OB_AND_BELOW_PREPARE(op_) FOR_OB_PREPARE(op_, below, __LINE__)
751 
754 #define FOR_OB_AND_BELOW_FINISH() FOR_OB_FINISH()
755 
763 #define FOR_OB_PREPARE(op_, field_, suffix_) FOR_OB_PREPARE2(op_, field_, suffix_)
764 
771 #define FOR_OB_PREPARE2(op_, field_, suffix_) \
772  do { \
773  object *next##suffix_ = (op_); \
774  tag_t next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;\
775  while (((op_) = next##suffix_) != NULL) { \
776  if (object_was_destroyed(next##suffix_, next_tag##suffix_)) {\
777  break; \
778  } \
779  next##suffix_ = next##suffix_->field_; \
780  next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;
781 
784 #define FOR_OB_FINISH() \
785  } \
786  } while(0)
787 
788 #endif /* DEFINE_H */
cf_random
uint32_t cf_random(void)
Definition: cf_random.cpp:5
typedata::identifyskill
int identifyskill
Definition: define.h:93
MoveType
unsigned char MoveType
Definition: define.h:417
typedata::name
const char * name
Definition: define.h:91
typedata::name_pl
const char * name_pl
Definition: define.h:92
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
typedata
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
Definition: define.h:90
typedata::identifyskill2
int identifyskill2
Definition: define.h:94
fatal_error
fatal_error
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:461
autoconf.h