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
47
enum
fatal_error
{
48
OUT_OF_MEMORY
= 0,
49
MAP_ERROR
= 1,
50
ARCHTABLE_TOO_SMALL
= 2,
51
ARCHETYPE_ISSUE
= 3,
52
SEE_LAST_ERROR
= 4,
53
};
54
59
#define ST_BD_BUILD 1
60
#define ST_BD_REMOVE 2
67
#define ST_MAT_FLOOR 1
68
#define ST_MAT_WALL 2
69
#define ST_MAT_ITEM 3
70
#define ST_MAT_WINDOW 4
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
89
struct typedata {
90
int
number
;
91
const
char
*
name
;
92
const
char
*
name_pl
;
93
int
identifyskill
;
94
int
identifyskill2
;
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
217
#define FLAG_ALIVE 0
218
#define FLAG_WIZ 1
219
#define FLAG_REMOVED 2
220
#define FLAG_FREED 3
221
#define FLAG_WAS_WIZ 4
222
#define FLAG_APPLIED 5
223
#define FLAG_UNPAID 6
224
#define FLAG_USE_SHIELD 7
226
#define FLAG_NO_PICK 8
227
#define FLAG_CLIENT_ANIM_SYNC 9
228
#define FLAG_CLIENT_ANIM_RANDOM 10
229
#define FLAG_ANIMATE 11
230
#define FLAG_DIALOG_PARSED 12
231
#define FLAG_NO_SAVE 13
232
#define FLAG_MONSTER 14
233
#define FLAG_FRIENDLY 15
235
#define FLAG_GENERATOR 16
236
#define FLAG_IS_THROWN 17
237
#define FLAG_AUTO_APPLY 18
238
#define FLAG_TREASURE 19
239
#define FLAG_PLAYER_SOLD 20
240
#define FLAG_SEE_INVISIBLE 21
241
#define FLAG_CAN_ROLL 22
242
#define FLAG_OVERLAY_FLOOR 23
243
#define FLAG_IS_TURNABLE 24
244
#define FLAG_PROBE 25
245
/*#define FLAG_FLY_ON 26*/
/* As WALK_ON, but only with FLAG_FLYING */
246
/*#define FLAG_FLY_OFF 27*/
/* As WALK_OFF, but only with FLAG_FLYING */
247
#define FLAG_IS_USED_UP 28
248
#define FLAG_IDENTIFIED 29
249
#define FLAG_REFLECTING 30
250
#define FLAG_CHANGING 31
252
/* Start of values in flags[1] */
253
#define FLAG_SPLITTING 32
254
#define FLAG_HITBACK 33
255
#define FLAG_STARTEQUIP 34
256
#define FLAG_BLOCKSVIEW 35
257
#define FLAG_UNDEAD 36
258
#define FLAG_SCARED 37
259
#define FLAG_UNAGGRESSIVE 38
260
#define FLAG_REFL_MISSILE 39
262
#define FLAG_REFL_SPELL 40
263
#define FLAG_NO_MAGIC 41
264
#define FLAG_NO_FIX_PLAYER 42
265
#define FLAG_IS_LIGHTABLE 43
266
#define FLAG_TEAR_DOWN 44
267
#define FLAG_RUN_AWAY 45
269
/*#define FLAG_PASS_THRU 46*/
/* Objects with can_pass_thru can pass \
270
thru this object as if it wasn't there */
271
/*#define FLAG_CAN_PASS_THRU 47*/
/* Can pass thru... */
272
273
/*#define FLAG_PICK_UP 48*/
/* Can pick up */
274
#define FLAG_UNIQUE 49
275
#define FLAG_NO_DROP 50
276
#define FLAG_WIZCAST 51
277
#define FLAG_CAST_SPELL 52
278
#define FLAG_USE_SCROLL 53
279
#define FLAG_USE_RANGE 54
280
#define FLAG_USE_BOW 55
282
#define FLAG_USE_ARMOUR 56
283
#define FLAG_USE_WEAPON 57
284
#define FLAG_USE_RING 58
285
#define FLAG_READY_RANGE 59
286
#define FLAG_READY_BOW 60
287
#define FLAG_XRAYS 61
288
#define FLAG_NO_APPLY 62
289
#define FLAG_IS_FLOOR 63
291
/* Start of values in flags[2] */
292
#define FLAG_LIFESAVE 64
293
#define FLAG_NO_STRENGTH 65
294
#define FLAG_SLEEP 66
295
#define FLAG_STAND_STILL 67
296
#define FLAG_RANDOM_MOVE 68
297
#define FLAG_ONLY_ATTACK 69
298
#define FLAG_CONFUSED 70
299
#define FLAG_STEALTH 71
301
#define FLAG_WIZPASS 72
302
#define FLAG_IS_LINKED 73
303
#define FLAG_CURSED 74
304
#define FLAG_DAMNED 75
305
#define FLAG_SEE_ANYWHERE 76
306
#define FLAG_KNOWN_MAGICAL 77
307
#define FLAG_KNOWN_CURSED 78
308
#define FLAG_CAN_USE_SKILL 79
310
#define FLAG_BEEN_APPLIED 80
311
#define FLAG_READY_SCROLL 81
312
/*#define FLAG_USE_ROD 82 unused (Monster) can apply and use rods */
313
/*#define FLAG_READY_HORN 83 unused (Monster) has a horn readied */
314
/*#define FLAG_USE_HORN 84 unused (Monster) can apply and use horns */
315
#define FLAG_MAKE_INVIS 85
316
#define FLAG_INV_LOCKED 86
317
#define FLAG_IS_WOODED 87
319
#define FLAG_IS_HILLY 88
320
#define FLAG_READY_SKILL 89
321
#define FLAG_READY_WEAPON 90
322
#define FLAG_NO_SKILL_IDENT 91
323
#define FLAG_BLIND 92
324
#define FLAG_SEE_IN_DARK 93
325
#define FLAG_IS_CAULDRON 94
326
/*#define FLAG_DUST 95 */
/* item is a 'powder', effects throwing */
327
328
/* Start of values in flags[3] */
329
#define FLAG_NO_STEAL 96
330
#define FLAG_ONE_HIT 97
333
#define FLAG_CLIENT_SENT 98
339
#define FLAG_BERSERK 99
341
#define FLAG_NEUTRAL 100
342
#define FLAG_NO_ATTACK 101
343
#define FLAG_NO_DAMAGE 102
344
#define FLAG_OBJ_ORIGINAL 103
346
/*#define FLAG_OBJ_SAVE_ON_OVL 104 */
/* this object should be saved on
347
* the overlay, and is not subject to
348
* decay. */
349
#define FLAG_ACTIVATE_ON_PUSH 105
350
#define FLAG_ACTIVATE_ON_RELEASE 106
351
#define FLAG_IS_WATER 107
352
#define FLAG_CONTENT_ON_GEN 108
353
#define FLAG_IS_A_TEMPLATE 109
354
#define FLAG_IS_BUILDABLE 110
355
#define FLAG_AFK 111
356
#define FLAG_BLESSED 112
357
#define FLAG_KNOWN_BLESSED 113
358
#define FLAG_PARALYZED 114
361
#define NUM_FLAGS 114
369
#define SET_FLAG(xyz, p) set_flag(xyz, p)
370
#define CLEAR_FLAG(xyz, p) clear_flag(xyz, p)
371
#define QUERY_FLAG(xyz, p) query_flag(xyz, p)
372
383
#define MOVE_WALK 0x1
384
#define MOVE_FLY_LOW 0x2
385
#define MOVE_FLY_HIGH 0x4
386
#define MOVE_FLYING 0x6
387
#define MOVE_SWIM 0x8
388
#define MOVE_BOAT 0x10
389
#define MOVE_ALL 0x1f
401
#define MOVE_BLOCK_DEFAULT MOVE_SWIM
402
409
typedef
unsigned
char
MoveType
;
410
#define OB_MOVE_BLOCK(ob1, ob2) ob_move_block(ob1, ob2)
411
418
#define OB_TYPE_MOVE_BLOCK(ob1, type) \
419
((type != 0) && (ob1->move_type&type) == ob1->move_type)
420
421
#define GENERATE_TYPE(xyz) ((xyz)->stats.sp)
422
#define GENERATE_SPEED(xyz) ((xyz)->stats.maxsp)
/* if(!RANDOM()%<speed>) */
423
424
#define EXIT_PATH(xyz) (xyz)->slaying
425
#define EXIT_LEVEL(xyz) (xyz)->stats.food
426
#define EXIT_X(xyz) (xyz)->stats.hp
427
#define EXIT_Y(xyz) (xyz)->stats.sp
428
#define EXIT_ALT_X(xyz) (xyz)->stats.maxhp
429
#define EXIT_ALT_Y(xyz) (xyz)->stats.maxsp
430
435
#define MAX_LIGHT_RADII 4
436
439
#define MAX_DARKNESS 5
440
444
#define MAX_WEAPON_ITEM_POWER 100
445
446
static
const
int32_t
MAX_FOOD
= 999;
447
448
#define DIRX(xyz) freearr_x[(xyz)->direction]
449
#define DIRY(xyz) freearr_y[(xyz)->direction]
450
451
#define ARMOUR_SPEED(xyz) (xyz)->last_sp
452
#define ARMOUR_SPELLS(xyz) (xyz)->gen_sp_armour
453
#define WEAPON_SPEED(xyz) (xyz)->last_sp
454
475
#define DISTATT 1
477
#define RUNATT 2
478
#define HITRUN 3
479
#define WAITATT 4
480
#define RUSH 5
481
#define ALLRUN 6
482
#define DISTHIT 7
483
#define WAIT2 8
485
#define PETMOVE 16
493
#define CIRCLE1 32
497
#define CIRCLE2 48
498
#define PACEH 64
500
#define PACEH2 80
504
#define RANDO 96
507
#define RANDO2 112
508
#define PACEV 128
510
#define PACEV2 144
514
#define LO4 15
515
#define HI4 240
516
525
#define ST_PLAYING 0
526
#define ST_PLAY_AGAIN 1
527
#define ST_ROLL_STAT 2
528
#define ST_CHANGE_CLASS 3
529
#define ST_CONFIRM_QUIT 4
530
#define ST_GET_NAME 6
531
#define ST_GET_PASSWORD 7
532
#define ST_CONFIRM_PASSWORD 8
533
#define ST_GET_PARTY_PASSWORD 10
534
#define ST_CHANGE_PASSWORD_OLD 11
535
#define ST_CHANGE_PASSWORD_NEW 12
536
#define ST_CHANGE_PASSWORD_CONFIRM 13
539
#define BLANK_FACE_NAME "blank.111"
540
#define EMPTY_FACE_NAME "empty.111"
541
#define SMOOTH_FACE_NAME "default_smoothed.111"
542
543
/*
544
* Defines for the luck/random functions to make things more readable
545
*/
546
547
#define PREFER_HIGH 1
548
#define PREFER_LOW 0
549
556
/* Basic flags, always use one of these */
557
#define AP_NULL 0
558
#define AP_APPLY 1
559
#define AP_UNAPPLY 2
560
#define AP_OPEN 3
562
#define AP_BASIC_FLAGS 15
563
564
/* Optional flags, for bitwise or with a basic flag */
565
#define AP_NO_MERGE 16
566
#define AP_IGNORE_CURSE 32
567
#define AP_PRINT 64
569
#define AP_NOPRINT 128
580
#define AC_PLAYER_STAT_LIMIT 1
581
#define AC_PLAYER_STAT_NO_CHANGE 2
614
#define CAN_APPLY_NEVER 0x1
615
#define CAN_APPLY_RESTRICTION 0x2
616
#define CAN_APPLY_NOT_MASK 0xf
617
#define CAN_APPLY_UNAPPLY 0x10
618
#define CAN_APPLY_UNAPPLY_MULT 0x20
619
#define CAN_APPLY_UNAPPLY_CHOICE 0x40
620
623
#define MIN_ACTIVE_SPEED 0.00001
624
625
uint32_t
cf_random
(
void
);
626
void
cf_srandom
(
unsigned
long
seed);
627
628
#define RANDOM() cf_random()
629
#define SRANDOM(seed) cf_srandom(seed)
630
635
#define WEIGHT(op) (op->nrof ? op->weight : op->weight+op->carrying)
636
654
#define FOR_INV_PREPARE(op_, it_) \
655
do { \
656
object *it_ = (op_)->inv; \
657
FOR_OB_AND_BELOW_PREPARE(it_);
658
661
#define FOR_INV_FINISH() \
662
FOR_OB_AND_BELOW_FINISH(); \
663
} while(0)
664
671
#define FOR_ABOVE_PREPARE(op_, it_) \
672
do { \
673
object *it_ = (op_)->above; \
674
FOR_OB_AND_ABOVE_PREPARE(it_);
675
678
#define FOR_ABOVE_FINISH() \
679
FOR_OB_AND_ABOVE_FINISH(); \
680
} while(0)
681
688
#define FOR_BELOW_PREPARE(op_, it_) \
689
do { \
690
object *it_ = (op_)->below; \
691
FOR_OB_AND_BELOW_PREPARE(it_);
692
695
#define FOR_BELOW_FINISH() \
696
FOR_OB_AND_BELOW_FINISH(); \
697
} while(0)
698
707
#define FOR_MAP_PREPARE(map_, mx_, my_, it_) \
708
do { \
709
object *it_ = GET_MAP_OB((map_), (mx_), (my_)); \
710
FOR_OB_AND_ABOVE_PREPARE(it_);
711
714
#define FOR_MAP_FINISH() \
715
FOR_OB_AND_ABOVE_FINISH(); \
716
} while(0)
717
723
#define FOR_OB_AND_ABOVE_PREPARE(op_) FOR_OB_PREPARE(op_, above, __LINE__)
724
727
#define FOR_OB_AND_ABOVE_FINISH() FOR_OB_FINISH()
728
734
#define FOR_OB_AND_BELOW_PREPARE(op_) FOR_OB_PREPARE(op_, below, __LINE__)
735
738
#define FOR_OB_AND_BELOW_FINISH() FOR_OB_FINISH()
739
747
#define FOR_OB_PREPARE(op_, field_, suffix_) FOR_OB_PREPARE2(op_, field_, suffix_)
748
755
#define FOR_OB_PREPARE2(op_, field_, suffix_) \
756
do { \
757
object *next##suffix_ = (op_); \
758
tag_t next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;\
759
while (((op_) = next##suffix_) != NULL) { \
760
if (object_was_destroyed(next##suffix_, next_tag##suffix_)) {\
761
break; \
762
} \
763
next##suffix_ = next##suffix_->field_; \
764
next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;
765
768
#define FOR_OB_FINISH() \
769
} \
770
} while(0)
771
772
#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:409
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
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:446
autoconf.h
crossfire-crossfire-server
include
define.h
Generated on Fri Aug 1 2025 00:34:52 for Crossfire Server, Trunk by
1.8.17