Crossfire Server, Branches 1.12  R18729
define.h
Go to the documentation of this file.
1 /*
2  * static char *rcsid_define_h =
3  * "$Id: define.h 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  CrossFire, A Multiplayer game for X-windows
8 
9  Copyright (C) 2003-2005 Mark Wedel & Crossfire Development Team
10  Copyright (C) 1992 Frank Tore Johansen
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 
26  The authors can be reached via e-mail at crossfire-devel@real-time.com
27 */
28 
42 #ifndef DEFINE_H
43 #define DEFINE_H
44 
45 /*
46  * Crossfire requires ANSI-C, but some compilers "forget" to define it.
47  * Thus the prototypes made by cextract don't get included correctly.
48  */
49 #if !defined(__STDC__)
50 /* Removed # from start of following line. makedepend was picking it up.
51  * The following should still hopefully result in an error.
52  */
53 error - Your ANSI C compiler should be defining __STDC__;
54 #endif
55 
56 #ifndef WIN32 /* ---win32 exclude unix configuration part */
57 #include <autoconf.h>
58 #endif
59 
61 #define FABS(x) ((x) < 0 ? -(x) : (x))
62 
63 #ifdef __NetBSD__
64 #include <sys/param.h>
65 #endif
66 #ifndef MIN
67 #define MIN(x, y) ((x) < (y) ? (x) : (y))
68 #endif
69 #ifndef MAX
70 #define MAX(x, y) ((x) > (y) ? (x) : (y))
71 #endif
72 
74 #ifndef NAME_MAX
75 #define NAME_MAX 255
76 #endif
77 
78 #define MAX_STAT 30
79 #define MIN_STAT 1
81 #define MAX_BUF 256
82 #define VERY_BIG_BUF 1024
83 #define HUGE_BUF 4096
85 #define MAX_ANIMATIONS 256
86 
87 #define MAX_NAME 48
88 #define BIG_NAME 32
89 
94 #define OUT_OF_MEMORY 0
95 #define MAP_ERROR 1
96 #define ARCHTABLE_TOO_SMALL 2
97 
113 #define PLAYER 1
114 #define TRANSPORT 2
115 #define ROD 3
116 #define TREASURE 4
117 #define POTION 5
118 #define FOOD 6
119 #define POISON 7
120 #define BOOK 8
121 #define CLOCK 9
122 /*#define FBULLET 10 */
123 /*#define FBALL 11 */
124 /*#define LIGHTNING 12 */
125 #define ARROW 13
126 #define BOW 14
127 #define WEAPON 15
128 #define ARMOUR 16
129 #define PEDESTAL 17
130 #define ALTAR 18
131 /*#define CONFUSION 19 */
132 #define LOCKED_DOOR 20
133 #define SPECIAL_KEY 21
134 #define MAP 22
135 #define DOOR 23
136 #define KEY 24
137 /*#define MMISSILE 25 */
138 #define TIMED_GATE 26
139 #define TRIGGER 27
140 #define GRIMREAPER 28
141 #define MAGIC_EAR 29
142 #define TRIGGER_BUTTON 30
143 #define TRIGGER_ALTAR 31
144 #define TRIGGER_PEDESTAL 32
145 #define SHIELD 33
146 #define HELMET 34
147 #define HORN 35
148 #define MONEY 36
149 #define CLASS 37
151 /*#define GRAVESTONE 38 */
152 #define AMULET 39
153 #define PLAYERMOVER 40
154 #define TELEPORTER 41
155 #define CREATOR 42
156 #define SKILL 43
157 #define EXPERIENCE 44
162 #define EARTHWALL 45
163 #define GOLEM 46
164 /*#define BOMB 47 */
165 #define THROWN_OBJ 48
166 #define BLINDNESS 49
167 #define GOD 50
169 #define DETECTOR 51
173 #define TRIGGER_MARKER 52
176 #define DEAD_OBJECT 53
177 #define DRINK 54
178 #define MARKER 55
181 #define HOLY_ALTAR 56
182 #define PLAYER_CHANGER 57
183 #define BATTLEGROUND 58
185 #define PEACEMAKER 59
188 #define GEM 60
189 /*#define FIRECHEST 61 */ /* FIRECHEST folded into FIREWALL */
190 #define FIREWALL 62
191 /*#define ANVIL 63 */
192 #define CHECK_INV 64
193 #define MOOD_FLOOR 65
204 #define EXIT 66
205 #define ENCOUNTER 67
206 #define SHOP_FLOOR 68
207 #define SHOP_MAT 69
208 #define RING 70
209 #define FLOOR 71
210 #define FLESH 72
211 #define INORGANIC 73
212 #define SKILL_TOOL 74
213 #define LIGHTER 75
214 
215 /* The trap_part, wall, light_source, misc_object, monster, and spawn_generator
216  * types are not used in any archetypes, and should perhaps be removed.
217  */
218 /*#define TRAP_PART 76 */ /* Needed by set traps skill -b.t. */
219 
220 #define WALL 77
222 /*#define LIGHT_SOURCE 78 */ /* torches, lamps, etc. */
223 #define MISC_OBJECT 79
230 #define MONSTER 80
231 /*#define SPAWN_GENERATOR 81 */ /* Spawn point or monster generator */
232 #define LAMP 82
233 #define DUPLICATOR 83
234 /*#define TOOL 84 */ /* Tool for building objects */
235 #define SPELLBOOK 85
236 /*#define BUILDFAC 86 */ /* Facilities for building objects */
237 #define CLOAK 87
238 /*#define CONE 88 */
239 /*#define AURA 89 */ /* Aura spell object */
240 
241 #define SPINNER 90
242 #define GATE 91
243 #define BUTTON 92
244 #define CF_HANDLE 93
245 #define HOLE 94 /* When open, objects fall through */
246 #define TRAPDOOR 95
247 /*#define WORD_OF_RECALL 96 */
248 /*#define PARAIMAGE 97 */
249 #define SIGN 98
250 #define BOOTS 99
251 #define GLOVES 100
252 #define SPELL 101
253 #define SPELL_EFFECT 102
254 #define CONVERTER 103
255 #define BRACERS 104
256 #define POISONING 105
257 #define SAVEBED 106
258 /*#define POISONCLOUD 107*/
259 /*#define FIREHOLES 108*/
260 #define WAND 109
261 /*#define ABILITY 110*/
262 #define SCROLL 111
263 #define DIRECTOR 112
264 #define GIRDLE 113
265 #define FORCE 114
266 #define POTION_EFFECT 115
268 #define EVENT_CONNECTOR 116
270 #define CLOSE_CON 121
272 #define CONTAINER 122
273 #define ARMOUR_IMPROVER 123
274 #define WEAPON_IMPROVER 124
276 /* unused: 125 - 129
277  * type 125 was MONEY_CHANGER
278  */
279 #define SKILLSCROLL 130
281 #define DEEP_SWAMP 138
282 #define IDENTIFY_ALTAR 139
283 /*#define CANCELLATION 141*/ /* not used with new spell code */
284 #define SHOP_INVENTORY 150
286 /*#define BALL_LIGHTNING 151*/ /* peterm: ball lightning and color
287  * spray */
288 /*#define SWARM_SPELL 153*/
289 #define RUNE 154
290 #define TRAP 155
292 #define POWER_CRYSTAL 156
293 #define CORPSE 157
295 #define DISEASE 158
296 #define SYMPTOM 159
298 #define BUILDER 160
300 #define MATERIAL 161
302 #define OBJECT_TYPE_MAX 162
303 /* END TYPE DEFINE */
304 
310 #define ST_BD_BUILD 1
311 #define ST_BD_REMOVE 2
314 
318 #define ST_MAT_FLOOR 1
319 #define ST_MAT_WALL 2
320 #define ST_MAT_ITEM 3
321 #define ST_MAT_WINDOW 4
323 
324 
328 #define WEAP_HIT 0
329 #define WEAP_SLASH 1
330 #define WEAP_PIERCE 2
331 #define WEAP_CLEAVE 3
332 #define WEAP_SLICE 4
333 #define WEAP_STAB 5
334 #define WEAP_WHIP 6
335 #define WEAP_CRUSH 7
336 #define WEAP_BLUD 8
338 
340 typedef struct typedata {
341  int number;
342  const char *name;
343  const char *name_pl;
344  int identifyskill;
345  int identifyskill2;
346 } typedata;
356 /* high bit as flag for new pickup options */
357 #define PU_NOTHING 0x00000000
359 #define PU_DEBUG 0x10000000
360 #define PU_INHIBIT 0x20000000
361 #define PU_STOP 0x40000000
362 #define PU_NEWMODE 0x80000000
363 
364 #define PU_RATIO 0x0000000F
366 #define PU_FOOD 0x00000010
367 #define PU_DRINK 0x00000020
368 #define PU_VALUABLES 0x00000040
369 #define PU_BOW 0x00000080
371 #define PU_ARROW 0x00000100
372 #define PU_HELMET 0x00000200
373 #define PU_SHIELD 0x00000400
374 #define PU_ARMOUR 0x00000800
375 
376 #define PU_BOOTS 0x00001000
377 #define PU_GLOVES 0x00002000
378 #define PU_CLOAK 0x00004000
379 #define PU_KEY 0x00008000
381 #define PU_MISSILEWEAPON 0x00010000
382 #define PU_ALLWEAPON 0x00020000
383 #define PU_MAGICAL 0x00040000
384 #define PU_POTION 0x00080000
385 
386 #define PU_SPELLBOOK 0x00100000
387 #define PU_SKILLSCROLL 0x00200000
388 #define PU_READABLES 0x00400000
389 #define PU_MAGIC_DEVICE 0x00800000
390 
391 #define PU_NOT_CURSED 0x01000000
392 #define PU_JEWELS 0x02000000
393 #define PU_FLESH 0x04000000
396 /* Instead of using arbitrary constants for indexing the
397  * freearr, add these values. <= SIZEOFFREE1 will get you
398  * within 1 space. <= SIZEOFFREE2 wll get you withing
399  * 2 spaces, and the entire array (< SIZEOFFREE) is
400  * three spaces
401  */
402 #define SIZEOFFREE1 8
403 #define SIZEOFFREE2 24
404 #define SIZEOFFREE 49
406 #define NROF_SOUNDS (23+NROFREALSPELLS) /* Number of sounds */
407 
412 #define IS_WEAPON(op) \
413  (op->type == ARROW || op->type == BOW || op->type == WEAPON)
415 #define IS_ARMOR(op) \
416  (op->type == ARMOUR || op->type == HELMET || \
417  op->type == BOOTS || op->type == GLOVES)
419 #define IS_SHIELD(op) \
420  (op->type == SHIELD)
422 #define IS_LIVE(op) \
423  ((op->type == PLAYER || QUERY_FLAG(op, FLAG_MONSTER) || \
424  (QUERY_FLAG(op, FLAG_ALIVE) && !QUERY_FLAG(op, FLAG_GENERATOR) && \
425  !op->type == DOOR)) && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
427 #define IS_ARROW(op) \
428  (op->type == ARROW || \
429  (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_MAGIC_MISSILE)))
433 #define HAS_RANDOM_ITEMS(op) (op->randomitems && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
434 
473 #define SET_FLAG(xyz, p) \
474  ((xyz)->flags[p/32] |= (1U<<(p%32)))
475 #define CLEAR_FLAG(xyz, p) \
476  ((xyz)->flags[p/32] &= ~(1U<<(p%32)))
477 #define QUERY_FLAG(xyz, p) \
478  ((xyz)->flags[p/32]&(1U<<(p%32)))
479 #define COMPARE_FLAGS(p, q) \
480  ( \
481  ((p)->flags[0] == (q)->flags[0]) && \
482  ((p)->flags[1] == (q)->flags[1]) && \
483  ((p)->flags[2] == (q)->flags[2]) && \
484  ((p)->flags[3] == (q)->flags[3]) \
485  )
486 
487 /* the flags themselves. */
488 
489 #define FLAG_ALIVE 0
490 #define FLAG_WIZ 1
491 #define FLAG_REMOVED 2
492 #define FLAG_FREED 3
493 #define FLAG_WAS_WIZ 4
494 #define FLAG_APPLIED 5
495 #define FLAG_UNPAID 6
496 #define FLAG_USE_SHIELD 7
498 #define FLAG_NO_PICK 8
499 #define FLAG_CLIENT_ANIM_SYNC 9
500 #define FLAG_CLIENT_ANIM_RANDOM 10
501 #define FLAG_ANIMATE 11
502 #define FLAG_DIALOG_PARSED 12
503 /*#define FLAG_FLYING 13*//* Not affected by WALK_ON or SLOW_MOVE) */
504 #define FLAG_MONSTER 14
505 #define FLAG_FRIENDLY 15
507 #define FLAG_GENERATOR 16
508 #define FLAG_IS_THROWN 17
509 #define FLAG_AUTO_APPLY 18
510 #define FLAG_TREASURE 19
511 #define FLAG_PLAYER_SOLD 20
512 #define FLAG_SEE_INVISIBLE 21
513 #define FLAG_CAN_ROLL 22
514 #define FLAG_OVERLAY_FLOOR 23
515 #define FLAG_IS_TURNABLE 24
516 /*#define FLAG_WALK_OFF 25*//* Object is applied when left */
517 /*#define FLAG_FLY_ON 26*//* As WALK_ON, but only with FLAG_FLYING */
518 /*#define FLAG_FLY_OFF 27*//* As WALK_OFF, but only with FLAG_FLYING */
519 #define FLAG_IS_USED_UP 28
520 #define FLAG_IDENTIFIED 29
521 #define FLAG_REFLECTING 30
522 #define FLAG_CHANGING 31
524 /* Start of values in flags[1] */
525 #define FLAG_SPLITTING 32
526 #define FLAG_HITBACK 33
527 #define FLAG_STARTEQUIP 34
528 #define FLAG_BLOCKSVIEW 35
529 #define FLAG_UNDEAD 36
530 #define FLAG_SCARED 37
531 #define FLAG_UNAGGRESSIVE 38
532 #define FLAG_REFL_MISSILE 39
534 #define FLAG_REFL_SPELL 40
535 #define FLAG_NO_MAGIC 41
536 #define FLAG_NO_FIX_PLAYER 42
537 #define FLAG_IS_LIGHTABLE 43
538 #define FLAG_TEAR_DOWN 44
539 #define FLAG_RUN_AWAY 45
541 /*#define FLAG_PASS_THRU 46*/ /* Objects with can_pass_thru can pass \
542  thru this object as if it wasn't there */
543 /*#define FLAG_CAN_PASS_THRU 47*/ /* Can pass thru... */
545 /*#define FLAG_PICK_UP 48*/ /* Can pick up */
546 #define FLAG_UNIQUE 49
547 #define FLAG_NO_DROP 50
548 #define FLAG_WIZCAST 51
549 #define FLAG_CAST_SPELL 52
550 #define FLAG_USE_SCROLL 53
551 #define FLAG_USE_RANGE 54
552 #define FLAG_USE_BOW 55
554 #define FLAG_USE_ARMOUR 56
555 #define FLAG_USE_WEAPON 57
556 #define FLAG_USE_RING 58
557 #define FLAG_READY_RANGE 59
558 #define FLAG_READY_BOW 60
559 #define FLAG_XRAYS 61
560 #define FLAG_NO_APPLY 62
561 #define FLAG_IS_FLOOR 63
563 /* Start of values in flags[2] */
564 #define FLAG_LIFESAVE 64
565 #define FLAG_NO_STRENGTH 65
566 #define FLAG_SLEEP 66
567 #define FLAG_STAND_STILL 67
568 #define FLAG_RANDOM_MOVE 68
569 #define FLAG_ONLY_ATTACK 69
570 #define FLAG_CONFUSED 70
571 #define FLAG_STEALTH 71
573 #define FLAG_WIZPASS 72
574 #define FLAG_IS_LINKED 73
575 #define FLAG_CURSED 74
576 #define FLAG_DAMNED 75
577 #define FLAG_SEE_ANYWHERE 76
578 #define FLAG_KNOWN_MAGICAL 77
579 #define FLAG_KNOWN_CURSED 78
580 #define FLAG_CAN_USE_SKILL 79
582 #define FLAG_BEEN_APPLIED 80
583 #define FLAG_READY_SCROLL 81
584 #define FLAG_USE_ROD 82
585 /*#define FLAG_READY_HORN 83 unused (Monster) has a horn readied */
586 #define FLAG_USE_HORN 84
587 #define FLAG_MAKE_INVIS 85
588 #define FLAG_INV_LOCKED 86
589 #define FLAG_IS_WOODED 87
591 #define FLAG_IS_HILLY 88
592 #define FLAG_READY_SKILL 89
593 #define FLAG_READY_WEAPON 90
594 #define FLAG_NO_SKILL_IDENT 91
595 #define FLAG_BLIND 92
596 #define FLAG_SEE_IN_DARK 93
597 #define FLAG_IS_CAULDRON 94
598 /*#define FLAG_DUST 95 *//* item is a 'powder', effects throwing */
600 /* Start of values in flags[3] */
601 #define FLAG_NO_STEAL 96
602 #define FLAG_ONE_HIT 97
605 #define FLAG_CLIENT_SENT 98
611 #define FLAG_BERSERK 99
613 #define FLAG_NEUTRAL 100
614 #define FLAG_NO_ATTACK 101
615 #define FLAG_NO_DAMAGE 102
616 #define FLAG_OBJ_ORIGINAL 103
618 /*#define FLAG_OBJ_SAVE_ON_OVL 104 *//* this object should be saved on
619  * the overlay, and is not subject to
620  * decay. */
621 #define FLAG_ACTIVATE_ON_PUSH 105
622 #define FLAG_ACTIVATE_ON_RELEASE 106
623 #define FLAG_IS_WATER 107
624 #define FLAG_CONTENT_ON_GEN 108
625 #define FLAG_IS_A_TEMPLATE 109
626 #define FLAG_IS_BUILDABLE 110
627 #define FLAG_AFK 111
628 #define FLAG_BLESSED 112
629 #define FLAG_KNOWN_BLESSED 113
630 #define NUM_FLAGS 113
637 
638 #define NROFNEWOBJS(xyz) ((xyz)->stats.food)
650 #define MOVE_WALK 0x1
651 #define MOVE_FLY_LOW 0x2
652 #define MOVE_FLY_HIGH 0x4
653 #define MOVE_FLYING 0x6
654 #define MOVE_SWIM 0x8
655 #define MOVE_BOAT 0x10
656 #define MOVE_ALL 0x1f
667 #define MOVE_BLOCK_DEFAULT MOVE_SWIM
675 typedef unsigned char MoveType;
681 #define OB_MOVE_BLOCK(ob1, ob2) \
682  ((ob1->move_type&ob2->move_block) == ob1->move_type)
683 
690 #define OB_TYPE_MOVE_BLOCK(ob1, type) \
691  ((type != 0) && (ob1->move_type&type) == ob1->move_type)
692 
694 #define SET_GENERATE_TYPE(xyz, va) (xyz)->stats.sp = (va)
695 #define GENERATE_TYPE(xyz) ((xyz)->stats.sp)
696 #define GENERATE_SPEED(xyz) ((xyz)->stats.maxsp) /* if(!RANDOM()%<speed>) */
697 
698 #define EXIT_PATH(xyz) (xyz)->slaying
699 #define EXIT_LEVEL(xyz) (xyz)->stats.food
700 #define EXIT_X(xyz) (xyz)->stats.hp
701 #define EXIT_Y(xyz) (xyz)->stats.sp
702 #define EXIT_ALT_X(xyz) (xyz)->stats.maxhp
703 #define EXIT_ALT_Y(xyz) (xyz)->stats.maxsp
709 #define MAX_LIGHT_RADII 4
710 
713 #define MAX_DARKNESS 5
714 
718 #define MAX_WEAPON_ITEM_POWER 100
719 
725 #define F_BUY 0
726 #define F_SELL 1
727 #define F_TRUE 2
728 #define F_NO_BARGAIN 4
729 #define F_IDENTIFIED 8
730 #define F_NOT_CURSED 16
731 #define F_APPROX 32
732 #define F_SHOP 64
734 
735 #define DIRX(xyz) freearr_x[(xyz)->direction]
736 #define DIRY(xyz) freearr_y[(xyz)->direction]
737 
738 #define ARMOUR_SPEED(xyz) (xyz)->last_sp
739 #define ARMOUR_SPELLS(xyz) (xyz)->gen_sp_armour
740 #define WEAPON_SPEED(xyz) (xyz)->last_sp
741 
749 /******************************************************************************/
750 /* the following definitions are for the attack_movement variable in monsters */
751 /* if the attack_variable movement is left out of the monster archetype, or is*/
752 /* set to zero */
753 /* the standard mode of movement from previous versions of crossfire will be */
754 /* used. the upper four bits of movement data are not in effect when the monst*/
755 /* er has an enemy. these should only be used for non agressive monsters. */
756 /* to program a monsters movement add the attack movement numbers to the movem*/
757 /* ment numbers example a monster that moves in a circle until attacked and */
758 /* then attacks from a distance: */
759 /* CIRCLE1 = 32 */
760 /* + DISTATT = 1 */
761 /* ------------------- */
762 /* attack_movement = 33 */
763 /******************************************************************************/
764 #define DISTATT 1
766 #define RUNATT 2
767 #define HITRUN 3
768 #define WAITATT 4
769 #define RUSH 5
770 #define ALLRUN 6
771 #define DISTHIT 7
772 #define WAIT2 8
774 #define PETMOVE 16
782 #define CIRCLE1 32
786 #define CIRCLE2 48
787 #define PACEH 64
789 #define PACEH2 80
793 #define RANDO 96
796 #define RANDO2 112
797 #define PACEV 128
799 #define PACEV2 144
803 #define LO4 15
804 #define HI4 240
805 
814 #define ST_PLAYING 0
815 #define ST_PLAY_AGAIN 1
816 #define ST_ROLL_STAT 2
817 #define ST_CHANGE_CLASS 3
818 #define ST_CONFIRM_QUIT 4
819 #define ST_GET_NAME 6
820 #define ST_GET_PASSWORD 7
821 #define ST_CONFIRM_PASSWORD 8
822 #define ST_GET_PARTY_PASSWORD 10
823 #define ST_CHANGE_PASSWORD_OLD 11
824 #define ST_CHANGE_PASSWORD_NEW 12
825 #define ST_CHANGE_PASSWORD_CONFIRM 13
827 
828 #define BLANK_FACE_NAME "blank.111"
829 #define EMPTY_FACE_NAME "empty.111"
830 #define SMOOTH_FACE_NAME "default_smoothed.111"
831 
832 /*
833  * Defines for the luck/random functions to make things more readable
834  */
835 
836 #define PREFER_HIGH 1
837 #define PREFER_LOW 0
838 
852 static inline void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen) {
853  if (*curlen == (maxlen-1))
854  return;
855  strncpy(dest+*curlen, orig, maxlen-*curlen-1);
856  dest[maxlen-1] = 0;
857  *curlen += strlen(orig);
858  if (*curlen > (maxlen-1))
859  *curlen = maxlen-1;
860 }
861 
862 /* The SAFE versions of these call the safe_strcat function above.
863  * Ideally, all functions should use the SAFE functions, but they
864  * require some extra support in the calling function to remain as
865  * efficient.
866  */
867 #define DESCRIBE_ABILITY_SAFE(retbuf, variable, name, len, maxlen) \
868  if (variable) { \
869  int i, j = 0; \
870  safe_strcat(retbuf, "(" name ": ", len, maxlen); \
871  for (i = 0; i < NROFATTACKS; i++) \
872  if (variable&(1<<i)) { \
873  if (j) \
874  safe_strcat(retbuf, ", ", len, maxlen); \
875  else \
876  j = 1; \
877  safe_strcat(retbuf, attacks[i], len, maxlen); \
878  } \
879  safe_strcat(retbuf, ")", len, maxlen); \
880  }
881 
882 /* separated this from the common/item.c file. b.t. Dec 1995 */
883 
884 #define DESCRIBE_ABILITY(retbuf, variable, name) \
885  if (variable) { \
886  int i, j = 0; \
887  strcat(retbuf, "(" name ": "); \
888  for (i = 0; i < NROFATTACKS; i++) \
889  if (variable&(1<<i)) { \
890  if (j) \
891  strcat(retbuf, ", "); \
892  else \
893  j = 1; \
894  strcat(retbuf, attacks[i]); \
895  } \
896  strcat(retbuf, ")"); \
897  }
898 
899 #define DESCRIBE_PATH(retbuf, variable, name) \
900  if (variable) { \
901  int i, j = 0; \
902  strcat(retbuf, "(" name ": "); \
903  for (i = 0; i < NRSPELLPATHS; i++) \
904  if (variable&(1<<i)) { \
905  if (j) \
906  strcat(retbuf, ", "); \
907  else \
908  j = 1; \
909  strcat(retbuf, spellpathnames[i]); \
910  } \
911  strcat(retbuf, ")"); \
912  }
913 
914 #define DESCRIBE_PATH_SAFE(retbuf, variable, name, len, maxlen) \
915  if (variable) { \
916  int i, j = 0; \
917  safe_strcat(retbuf, "(" name ": ", len, maxlen); \
918  for (i = 0; i < NRSPELLPATHS; i++) \
919  if (variable&(1<<i)) { \
920  if (j) \
921  safe_strcat(retbuf, ", ", len, maxlen); \
922  else \
923  j = 1; \
924  safe_strcat(retbuf, spellpathnames[i], len, maxlen); \
925  } \
926  safe_strcat(retbuf, ")", len, maxlen); \
927  }
928 
935 /* Basic flags, always use one of these */
936 #define AP_NULL 0
937 #define AP_APPLY 1
938 #define AP_UNAPPLY 2
940 #define AP_BASIC_FLAGS 15
941 
942 /* Optional flags, for bitwise or with a basic flag */
943 #define AP_NO_MERGE 16
944 #define AP_IGNORE_CURSE 32
945 #define AP_PRINT 64
947 #define AP_NOPRINT 128
950 
951 
980 #define CAN_APPLY_NEVER 0x1
981 #define CAN_APPLY_RESTRICTION 0x2
982 #define CAN_APPLY_NOT_MASK 0xf
983 #define CAN_APPLY_UNAPPLY 0x10
984 #define CAN_APPLY_UNAPPLY_MULT 0x20
985 #define CAN_APPLY_UNAPPLY_CHOICE 0x40
989 #define MIN_ACTIVE_SPEED 0.00001
990 
991 /*
992  * random() is much better than rand(). If you have random(), use it instead.
993  * You shouldn't need to change any of this
994  *
995  * 0.93.3: It looks like linux has random (previously, it was set below
996  * to use rand). Perhaps old version of linux lack rand? IF you run into
997  * problems, add || defined(__linux__) the #if immediately below.
998  *
999  * 0.94.2 - you probably shouldn't need to change any of the rand stuff
1000  * here.
1001  */
1002 
1003 #ifdef HAVE_SRANDOM
1004 #define RANDOM() random()
1005 #define SRANDOM(xyz) srandom(xyz)
1006 #else
1007 # ifdef HAVE_SRAND48
1008 # define RANDOM() lrand48()
1009 # define SRANDOM(xyz) srand48(xyz)
1010 # else
1011 # ifdef HAVE_SRAND
1012 # define RANDOM() rand()
1013 # define SRANDOM(xyz) srand(xyz)
1014 # else
1015 # error "Could not find a usable random routine"
1016 # endif
1017 # endif
1018 #endif
1019 
1024 #define WEIGHT(op) (op->nrof ? op->weight : op->weight+op->carrying)
1025 
1039 #define PREPARE_FASTCAT(buf__) buf__+strlen(buf__)
1040 #define FAST_STRNCAT(buf__, buf2__, size__) { memcpy(buf__, buf2__, size__); buf__ += size__; }
1041 #define FAST_STRCAT(buf__, buf2__) { memcpy(buf__, buf2__, strlen(buf2__)); buf__ += strlen(buf2__); }
1042 #define FINISH_FASTCAT(buf__) buf__[0] = '\0';
1043 
1044 /* You may uncomment following define to check sanity of code.
1045  * But use as debug only (loses all speed gained by those macros)
1046  */
1047 /*#define FAST_STRNCAT(buf__, buf2__, size__) { \
1048  memcpy (buf__, buf2__, size__); \
1049  buf__ += size__; \
1050  if (size__ != strlen(buf2__)) \
1051  LOG(llevError, "Error, bad length for %s\n", buf2__); \
1052 }*/
1055 #endif /* DEFINE_H */
int identifyskill
Definition: define.h:381
struct typedata typedata
const char * name_pl
Definition: define.h:380
unsigned char MoveType
Definition: define.h:725
static void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen)
Definition: define.h:924
error Your ANSI C compiler should be defining __STDC__
Definition: define.h:53
int identifyskill2
Definition: define.h:382
const char * name
Definition: define.h:379
int number
Definition: define.h:378