Crossfire Server, Branch 1.12  R12190
define.h
Go to the documentation of this file.
00001 /*
00002  * static char *rcsid_define_h =
00003  *   "$Id: define.h 11578 2009-02-23 22:02:27Z lalo $";
00004  */
00005 
00006 /*
00007     CrossFire, A Multiplayer game for X-windows
00008 
00009     Copyright (C) 2003-2005 Mark Wedel & Crossfire Development Team
00010     Copyright (C) 1992 Frank Tore Johansen
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025 
00026     The authors can be reached via e-mail at crossfire-devel@real-time.com
00027 */
00028 
00042 #ifndef DEFINE_H
00043 #define DEFINE_H
00044 
00045 /*
00046  * Crossfire requires ANSI-C, but some compilers "forget" to define it.
00047  * Thus the prototypes made by cextract don't get included correctly.
00048  */
00049 #if !defined(__STDC__)
00050 /* Removed # from start of following line.  makedepend was picking it up.
00051  * The following should still hopefully result in an error.
00052  */
00053 error - Your ANSI C compiler should be defining __STDC__;
00054 #endif
00055 
00056 #ifndef WIN32 /* ---win32 exclude unix configuration part */
00057 #include <autoconf.h>
00058 #endif
00059 
00061 #define FABS(x) ((x) < 0 ? -(x) : (x))
00062 
00063 #ifdef __NetBSD__
00064 #include <sys/param.h>
00065 #endif
00066 #ifndef MIN
00067 #define MIN(x, y) ((x) < (y) ? (x) : (y))
00068 #endif
00069 #ifndef MAX
00070 #define MAX(x, y) ((x) > (y) ? (x) : (y))
00071 #endif
00072 
00074 #ifndef NAME_MAX
00075 #define NAME_MAX 255
00076 #endif
00077 
00078 #define MAX_STAT                30      
00079 #define MIN_STAT                1       
00081 #define MAX_BUF                 256     
00082 #define VERY_BIG_BUF            1024
00083 #define HUGE_BUF                4096    
00085 #define MAX_ANIMATIONS          256
00086 
00087 #define MAX_NAME 48
00088 #define BIG_NAME 32
00089 
00094 #define OUT_OF_MEMORY           0
00095 #define MAP_ERROR               1
00096 #define ARCHTABLE_TOO_SMALL     2
00097 
00113 #define PLAYER                      1
00114 #define TRANSPORT                   2     
00115 #define ROD                         3
00116 #define TREASURE                    4
00117 #define POTION                      5
00118 #define FOOD                        6
00119 #define POISON                      7
00120 #define BOOK                        8
00121 #define CLOCK                       9
00122 /*#define FBULLET                   10 */
00123 /*#define FBALL                     11 */
00124 /*#define LIGHTNING                 12 */
00125 #define ARROW                       13
00126 #define BOW                         14
00127 #define WEAPON                      15
00128 #define ARMOUR                      16
00129 #define PEDESTAL                    17
00130 #define ALTAR                       18
00131 /*#define CONFUSION                 19 */
00132 #define LOCKED_DOOR                 20
00133 #define SPECIAL_KEY                 21
00134 #define MAP                         22
00135 #define DOOR                        23
00136 #define KEY                         24
00137 /*#define MMISSILE                  25 */
00138 #define TIMED_GATE                  26
00139 #define TRIGGER                     27
00140 #define GRIMREAPER                  28
00141 #define MAGIC_EAR                   29
00142 #define TRIGGER_BUTTON              30
00143 #define TRIGGER_ALTAR               31
00144 #define TRIGGER_PEDESTAL            32
00145 #define SHIELD                      33
00146 #define HELMET                      34
00147 #define HORN                        35
00148 #define MONEY                       36
00149 #define CLASS                       37    
00151 /*#define GRAVESTONE                38 */
00152 #define AMULET                      39
00153 #define PLAYERMOVER                 40
00154 #define TELEPORTER                  41
00155 #define CREATOR                     42
00156 #define SKILL                       43    
00157 #define EXPERIENCE                  44    
00162 #define EARTHWALL                   45
00163 #define GOLEM                       46
00164 /*#define BOMB                      47 */
00165 #define THROWN_OBJ                  48
00166 #define BLINDNESS                   49
00167 #define GOD                         50
00168 
00169 #define DETECTOR                    51    
00173 #define TRIGGER_MARKER              52    
00176 #define DEAD_OBJECT                 53
00177 #define DRINK                       54
00178 #define MARKER                      55    
00181 #define HOLY_ALTAR                  56
00182 #define PLAYER_CHANGER              57
00183 #define BATTLEGROUND                58    
00185 #define PEACEMAKER                  59    
00188 #define GEM                         60
00189 /*#define FIRECHEST                 61 */ /* FIRECHEST folded into FIREWALL */
00190 #define FIREWALL                    62
00191 /*#define ANVIL                     63 */
00192 #define CHECK_INV                   64    
00193 #define MOOD_FLOOR                  65    
00204 #define EXIT                        66
00205 #define ENCOUNTER                   67
00206 #define SHOP_FLOOR                  68
00207 #define SHOP_MAT                    69
00208 #define RING                        70
00209 #define FLOOR                       71    
00210 #define FLESH                       72    
00211 #define INORGANIC                   73    
00212 #define SKILL_TOOL                  74    
00213 #define LIGHTER                     75
00214 
00215 /* The trap_part, wall, light_source, misc_object, monster, and spawn_generator
00216  * types are not used in any archetypes, and should perhaps be removed.
00217  */
00218 /*#define TRAP_PART                 76 */ /* Needed by set traps skill -b.t. */
00219 
00220 #define WALL                        77    
00222 /*#define LIGHT_SOURCE              78 */ /* torches, lamps, etc. */
00223 #define MISC_OBJECT                 79    
00230 #define MONSTER                     80    
00231 /*#define SPAWN_GENERATOR           81 */ /* Spawn point or monster generator */
00232 #define LAMP                        82    
00233 #define DUPLICATOR                  83    
00234 /*#define TOOL                      84 */ /* Tool for building objects */
00235 #define SPELLBOOK                   85
00236 /*#define BUILDFAC                  86 */ /* Facilities for building objects */
00237 #define CLOAK                       87
00238 /*#define CONE                      88 */
00239 /*#define AURA                      89 */ /* Aura spell object */
00240 
00241 #define SPINNER                     90
00242 #define GATE                        91
00243 #define BUTTON                      92
00244 #define CF_HANDLE                   93
00245 #define HOLE                        94    /* When open, objects fall through */
00246 #define TRAPDOOR                    95
00247 /*#define WORD_OF_RECALL            96 */
00248 /*#define PARAIMAGE                 97 */
00249 #define SIGN                        98
00250 #define BOOTS                       99
00251 #define GLOVES                      100
00252 #define SPELL                       101
00253 #define SPELL_EFFECT                102
00254 #define CONVERTER                   103
00255 #define BRACERS                     104
00256 #define POISONING                   105
00257 #define SAVEBED                     106
00258 /*#define POISONCLOUD               107*/
00259 /*#define FIREHOLES                 108*/
00260 #define WAND                        109
00261 /*#define ABILITY                   110*/
00262 #define SCROLL                      111
00263 #define DIRECTOR                    112
00264 #define GIRDLE                      113
00265 #define FORCE                       114
00266 #define POTION_EFFECT               115   
00268 #define EVENT_CONNECTOR             116   
00270 #define CLOSE_CON                   121   
00272 #define CONTAINER                   122
00273 #define ARMOUR_IMPROVER             123
00274 #define WEAPON_IMPROVER             124
00275 
00276 /* unused: 125 - 129
00277  * type 125 was MONEY_CHANGER
00278  */
00279 #define SKILLSCROLL                 130   
00281 #define DEEP_SWAMP                  138
00282 #define IDENTIFY_ALTAR              139
00283 /*#define CANCELLATION              141*/ /* not used with new spell code */
00284 #define SHOP_INVENTORY              150   
00286 /*#define BALL_LIGHTNING            151*/ /* peterm:  ball lightning and color
00287                                            * spray */
00288 /*#define SWARM_SPELL               153*/
00289 #define RUNE                        154
00290 #define TRAP                        155
00291 
00292 #define POWER_CRYSTAL               156
00293 #define CORPSE                      157
00294 
00295 #define DISEASE                     158
00296 #define SYMPTOM                     159
00297 
00298 #define BUILDER                     160   
00300 #define MATERIAL                    161   
00302 #define OBJECT_TYPE_MAX             162   
00303 /* END TYPE DEFINE */
00304 
00310 #define ST_BD_BUILD      1 
00311 #define ST_BD_REMOVE     2 
00313 
00314 
00318 #define ST_MAT_FLOOR    1 
00319 #define ST_MAT_WALL     2 
00320 #define ST_MAT_ITEM     3 
00321 #define ST_MAT_WINDOW   4 
00323 
00324 
00328 #define WEAP_HIT        0  
00329 #define WEAP_SLASH      1  
00330 #define WEAP_PIERCE     2  
00331 #define WEAP_CLEAVE     3  
00332 #define WEAP_SLICE      4  
00333 #define WEAP_STAB       5  
00334 #define WEAP_WHIP       6  
00335 #define WEAP_CRUSH      7  
00336 #define WEAP_BLUD       8  
00338 
00339 
00340 typedef struct typedata {
00341     int number;         
00342     const char *name;   
00343     const char *name_pl;
00344     int identifyskill;  
00345     int identifyskill2; 
00346 } typedata;
00347 
00348 
00356 /* high bit as flag for new pickup options */
00357 #define PU_NOTHING              0x00000000
00358 
00359 #define PU_DEBUG                0x10000000
00360 #define PU_INHIBIT              0x20000000
00361 #define PU_STOP                 0x40000000
00362 #define PU_NEWMODE              0x80000000
00363 
00364 #define PU_RATIO                0x0000000F
00365 
00366 #define PU_FOOD                 0x00000010
00367 #define PU_DRINK                0x00000020
00368 #define PU_VALUABLES            0x00000040
00369 #define PU_BOW                  0x00000080
00370 
00371 #define PU_ARROW                0x00000100
00372 #define PU_HELMET               0x00000200
00373 #define PU_SHIELD               0x00000400
00374 #define PU_ARMOUR               0x00000800
00375 
00376 #define PU_BOOTS                0x00001000
00377 #define PU_GLOVES               0x00002000
00378 #define PU_CLOAK                0x00004000
00379 #define PU_KEY                  0x00008000
00380 
00381 #define PU_MISSILEWEAPON        0x00010000
00382 #define PU_ALLWEAPON            0x00020000
00383 #define PU_MAGICAL              0x00040000
00384 #define PU_POTION               0x00080000
00385 
00386 #define PU_SPELLBOOK            0x00100000
00387 #define PU_SKILLSCROLL          0x00200000
00388 #define PU_READABLES            0x00400000
00389 #define PU_MAGIC_DEVICE         0x00800000
00390 
00391 #define PU_NOT_CURSED           0x01000000
00392 #define PU_JEWELS               0x02000000
00393 #define PU_FLESH                0x04000000
00394 
00396 /* Instead of using arbitrary constants for indexing the
00397  * freearr, add these values.  <= SIZEOFFREE1 will get you
00398  * within 1 space.  <= SIZEOFFREE2 wll get you withing
00399  * 2 spaces, and the entire array (< SIZEOFFREE) is
00400  * three spaces
00401  */
00402 #define SIZEOFFREE1 8
00403 #define SIZEOFFREE2 24
00404 #define SIZEOFFREE 49
00405 
00406 #define NROF_SOUNDS (23+NROFREALSPELLS) /* Number of sounds */
00407 
00412 #define IS_WEAPON(op) \
00413         (op->type == ARROW || op->type == BOW || op->type == WEAPON)
00414 
00415 #define IS_ARMOR(op) \
00416         (op->type == ARMOUR || op->type == HELMET || \
00417          op->type == BOOTS || op->type == GLOVES)
00418 
00419 #define IS_SHIELD(op) \
00420         (op->type == SHIELD)
00421 
00422 #define IS_LIVE(op) \
00423         ((op->type == PLAYER || QUERY_FLAG(op, FLAG_MONSTER) || \
00424         (QUERY_FLAG(op, FLAG_ALIVE) && !QUERY_FLAG(op, FLAG_GENERATOR) && \
00425         !op->type == DOOR)) && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
00426 
00427 #define IS_ARROW(op) \
00428         (op->type == ARROW || \
00429         (op->type == SPELL_EFFECT && (op->subtype == SP_BULLET || op->subtype == SP_MAGIC_MISSILE)))
00430 
00433 #define HAS_RANDOM_ITEMS(op) (op->randomitems && (!QUERY_FLAG(op, FLAG_IS_A_TEMPLATE)))
00434 
00473 #define SET_FLAG(xyz, p) \
00474     ((xyz)->flags[p/32] |= (1U<<(p%32)))
00475 #define CLEAR_FLAG(xyz, p) \
00476     ((xyz)->flags[p/32] &= ~(1U<<(p%32)))
00477 #define QUERY_FLAG(xyz, p) \
00478     ((xyz)->flags[p/32]&(1U<<(p%32)))
00479 #define COMPARE_FLAGS(p, q) \
00480     (                                                \
00481         ((p)->flags[0] == (q)->flags[0]) &&          \
00482         ((p)->flags[1] == (q)->flags[1]) &&          \
00483         ((p)->flags[2] == (q)->flags[2]) &&          \
00484         ((p)->flags[3] == (q)->flags[3])             \
00485     )
00486 
00487 /* the flags themselves. */
00488 
00489 #define FLAG_ALIVE              0  
00490 #define FLAG_WIZ                1  
00491 #define FLAG_REMOVED            2  
00492 #define FLAG_FREED              3  
00493 #define FLAG_WAS_WIZ            4  
00494 #define FLAG_APPLIED            5  
00495 #define FLAG_UNPAID             6  
00496 #define FLAG_USE_SHIELD         7  
00498 #define FLAG_NO_PICK            8  
00499 #define FLAG_CLIENT_ANIM_SYNC   9  
00500 #define FLAG_CLIENT_ANIM_RANDOM 10 
00501 #define FLAG_ANIMATE            11 
00502 #define FLAG_DIALOG_PARSED      12 
00503 /*#define FLAG_FLYING           13*//* Not affected by WALK_ON or SLOW_MOVE) */
00504 #define FLAG_MONSTER            14 
00505 #define FLAG_FRIENDLY           15 
00507 #define FLAG_GENERATOR          16 
00508 #define FLAG_IS_THROWN          17 
00509 #define FLAG_AUTO_APPLY         18 
00510 #define FLAG_TREASURE           19 
00511 #define FLAG_PLAYER_SOLD        20 
00512 #define FLAG_SEE_INVISIBLE      21 
00513 #define FLAG_CAN_ROLL           22 
00514 #define FLAG_OVERLAY_FLOOR      23 
00515 #define FLAG_IS_TURNABLE        24 
00516 /*#define FLAG_WALK_OFF         25*//* Object is applied when left */
00517 /*#define FLAG_FLY_ON           26*//* As WALK_ON, but only with FLAG_FLYING */
00518 /*#define FLAG_FLY_OFF          27*//* As WALK_OFF, but only with FLAG_FLYING */
00519 #define FLAG_IS_USED_UP         28 
00520 #define FLAG_IDENTIFIED         29 
00521 #define FLAG_REFLECTING         30 
00522 #define FLAG_CHANGING           31 
00524 /* Start of values in flags[1] */
00525 #define FLAG_SPLITTING          32 
00526 #define FLAG_HITBACK            33 
00527 #define FLAG_STARTEQUIP         34 
00528 #define FLAG_BLOCKSVIEW         35 
00529 #define FLAG_UNDEAD             36 
00530 #define FLAG_SCARED             37 
00531 #define FLAG_UNAGGRESSIVE       38 
00532 #define FLAG_REFL_MISSILE       39 
00534 #define FLAG_REFL_SPELL         40 
00535 #define FLAG_NO_MAGIC           41 
00536 #define FLAG_NO_FIX_PLAYER      42 
00537 #define FLAG_IS_LIGHTABLE       43 
00538 #define FLAG_TEAR_DOWN          44 
00539 #define FLAG_RUN_AWAY           45 
00541 /*#define FLAG_PASS_THRU        46*/ /* Objects with can_pass_thru can pass \
00542                                       thru this object as if it wasn't there */
00543 /*#define FLAG_CAN_PASS_THRU    47*/ /* Can pass thru... */
00544 
00545 /*#define FLAG_PICK_UP          48*/ /* Can pick up */
00546 #define FLAG_UNIQUE             49 
00547 #define FLAG_NO_DROP            50 
00548 #define FLAG_WIZCAST            51 
00549 #define FLAG_CAST_SPELL         52 
00550 #define FLAG_USE_SCROLL         53 
00551 #define FLAG_USE_RANGE          54 
00552 #define FLAG_USE_BOW            55 
00554 #define FLAG_USE_ARMOUR         56 
00555 #define FLAG_USE_WEAPON         57 
00556 #define FLAG_USE_RING           58 
00557 #define FLAG_READY_RANGE        59 
00558 #define FLAG_READY_BOW          60 
00559 #define FLAG_XRAYS              61 
00560 #define FLAG_NO_APPLY           62 
00561 #define FLAG_IS_FLOOR           63 
00563 /* Start of values in flags[2] */
00564 #define FLAG_LIFESAVE           64 
00565 #define FLAG_NO_STRENGTH        65 
00566 #define FLAG_SLEEP              66 
00567 #define FLAG_STAND_STILL        67 
00568 #define FLAG_RANDOM_MOVE        68 
00569 #define FLAG_ONLY_ATTACK        69 
00570 #define FLAG_CONFUSED           70 
00571 #define FLAG_STEALTH            71 
00573 #define FLAG_WIZPASS            72 
00574 #define FLAG_IS_LINKED          73 
00575 #define FLAG_CURSED             74 
00576 #define FLAG_DAMNED             75 
00577 #define FLAG_SEE_ANYWHERE       76 
00578 #define FLAG_KNOWN_MAGICAL      77 
00579 #define FLAG_KNOWN_CURSED       78 
00580 #define FLAG_CAN_USE_SKILL      79 
00582 #define FLAG_BEEN_APPLIED       80 
00583 #define FLAG_READY_SCROLL       81 
00584 #define FLAG_USE_ROD            82 
00585 /*#define FLAG_READY_HORN       83 unused (Monster) has a horn readied */
00586 #define FLAG_USE_HORN           84 
00587 #define FLAG_MAKE_INVIS         85 
00588 #define FLAG_INV_LOCKED         86 
00589 #define FLAG_IS_WOODED          87 
00591 #define FLAG_IS_HILLY           88 
00592 #define FLAG_READY_SKILL        89 
00593 #define FLAG_READY_WEAPON       90 
00594 #define FLAG_NO_SKILL_IDENT     91 
00595 #define FLAG_BLIND              92 
00596 #define FLAG_SEE_IN_DARK        93 
00597 #define FLAG_IS_CAULDRON        94 
00598 /*#define FLAG_DUST             95 *//* item is a 'powder', effects throwing */
00599 
00600 /* Start of values in flags[3] */
00601 #define FLAG_NO_STEAL           96 
00602 #define FLAG_ONE_HIT            97 
00605 #define FLAG_CLIENT_SENT        98 
00611 #define FLAG_BERSERK            99  
00613 #define FLAG_NEUTRAL            100 
00614 #define FLAG_NO_ATTACK          101 
00615 #define FLAG_NO_DAMAGE          102 
00616 #define FLAG_OBJ_ORIGINAL       103 
00618 /*#define FLAG_OBJ_SAVE_ON_OVL    104 *//* this object should be saved on
00619                                      * the overlay, and is not subject to
00620                                      * decay. */
00621 #define FLAG_ACTIVATE_ON_PUSH    105 
00622 #define FLAG_ACTIVATE_ON_RELEASE 106 
00623 #define FLAG_IS_WATER            107
00624 #define FLAG_CONTENT_ON_GEN      108
00625 #define FLAG_IS_A_TEMPLATE       109 
00626 #define FLAG_IS_BUILDABLE        110 
00627 #define FLAG_AFK                 111 
00628 #define FLAG_BLESSED             112 
00629 #define FLAG_KNOWN_BLESSED       113 
00630 #define NUM_FLAGS                113 
00637 
00638 #define NROFNEWOBJS(xyz)        ((xyz)->stats.food)
00639 
00650 #define MOVE_WALK       0x1     
00651 #define MOVE_FLY_LOW    0x2     
00652 #define MOVE_FLY_HIGH   0x4     
00653 #define MOVE_FLYING     0x6     
00654 #define MOVE_SWIM       0x8     
00655 #define MOVE_BOAT       0x10    
00656 #define MOVE_ALL        0x1f    
00667 #define MOVE_BLOCK_DEFAULT MOVE_SWIM
00668 
00675 typedef unsigned char MoveType;
00676 
00681 #define OB_MOVE_BLOCK(ob1, ob2) \
00682     ((ob1->move_type&ob2->move_block) == ob1->move_type)
00683 
00690 #define OB_TYPE_MOVE_BLOCK(ob1, type) \
00691     ((type != 0) && (ob1->move_type&type) == ob1->move_type)
00692 
00694 #define SET_GENERATE_TYPE(xyz, va) (xyz)->stats.sp = (va)
00695 #define GENERATE_TYPE(xyz)      ((xyz)->stats.sp)
00696 #define GENERATE_SPEED(xyz)     ((xyz)->stats.maxsp) /* if(!RANDOM()%<speed>) */
00697 
00698 #define EXIT_PATH(xyz)          (xyz)->slaying
00699 #define EXIT_LEVEL(xyz)         (xyz)->stats.food
00700 #define EXIT_X(xyz)             (xyz)->stats.hp
00701 #define EXIT_Y(xyz)             (xyz)->stats.sp
00702 #define EXIT_ALT_X(xyz)         (xyz)->stats.maxhp
00703 #define EXIT_ALT_Y(xyz)         (xyz)->stats.maxsp
00704 
00709 #define MAX_LIGHT_RADII         4
00710 
00713 #define MAX_DARKNESS            5
00714 
00718 #define MAX_WEAPON_ITEM_POWER   100
00719 
00725 #define F_BUY           0   
00726 #define F_SELL          1   
00727 #define F_TRUE          2   
00728 #define F_NO_BARGAIN    4   
00729 #define F_IDENTIFIED    8   
00730 #define F_NOT_CURSED    16  
00731 #define F_APPROX        32  
00732 #define F_SHOP          64  
00734 
00735 #define DIRX(xyz)       freearr_x[(xyz)->direction]
00736 #define DIRY(xyz)       freearr_y[(xyz)->direction]
00737 
00738 #define ARMOUR_SPEED(xyz)       (xyz)->last_sp
00739 #define ARMOUR_SPELLS(xyz)      (xyz)->gen_sp_armour
00740 #define WEAPON_SPEED(xyz)       (xyz)->last_sp
00741 
00749 /******************************************************************************/
00750 /* the following definitions are for the attack_movement variable in monsters */
00751 /* if the attack_variable movement is left out of the monster archetype, or is*/
00752 /* set to zero                                                                */
00753 /* the standard mode of movement from previous versions of crossfire will be  */
00754 /* used. the upper four bits of movement data are not in effect when the monst*/
00755 /* er has an enemy. these should only be used for non agressive monsters.     */
00756 /* to program a monsters movement add the attack movement numbers to the movem*/
00757 /* ment numbers example a monster that moves in a circle until attacked and   */
00758 /* then attacks from a distance:                                              */
00759 /*                                                      CIRCLE1 = 32          */
00760 /*                                              +       DISTATT = 1           */
00761 /*                                      -------------------                   */
00762 /*                      attack_movement = 33                                  */
00763 /******************************************************************************/
00764 #define DISTATT  1 
00766 #define RUNATT   2 
00767 #define HITRUN   3 
00768 #define WAITATT  4 
00769 #define RUSH     5 
00770 #define ALLRUN   6 
00771 #define DISTHIT  7 
00772 #define WAIT2    8 
00774 #define PETMOVE 16 
00782 #define CIRCLE1 32 
00786 #define CIRCLE2 48 
00787 #define PACEH   64 
00789 #define PACEH2  80 
00793 #define RANDO   96 
00796 #define RANDO2 112 
00797 #define PACEV  128 
00799 #define PACEV2 144 
00803 #define LO4     15 
00804 #define HI4    240
00805 
00814 #define ST_PLAYING                  0   
00815 #define ST_PLAY_AGAIN               1   
00816 #define ST_ROLL_STAT                2   
00817 #define ST_CHANGE_CLASS             3   
00818 #define ST_CONFIRM_QUIT             4   
00819 #define ST_GET_NAME                 6   
00820 #define ST_GET_PASSWORD             7   
00821 #define ST_CONFIRM_PASSWORD         8   
00822 #define ST_GET_PARTY_PASSWORD       10  
00823 #define ST_CHANGE_PASSWORD_OLD      11  
00824 #define ST_CHANGE_PASSWORD_NEW      12  
00825 #define ST_CHANGE_PASSWORD_CONFIRM  13  
00827 
00828 #define BLANK_FACE_NAME "blank.111"
00829 #define EMPTY_FACE_NAME "empty.111"
00830 #define SMOOTH_FACE_NAME "default_smoothed.111"
00831 
00832 /*
00833  * Defines for the luck/random functions to make things more readable
00834  */
00835 
00836 #define PREFER_HIGH     1
00837 #define PREFER_LOW      0
00838 
00852 static inline void safe_strcat(char *dest, const char *orig, size_t *curlen, size_t maxlen) {
00853     if (*curlen == (maxlen-1))
00854         return;
00855     strncpy(dest+*curlen, orig, maxlen-*curlen-1);
00856     dest[maxlen-1] = 0;
00857     *curlen += strlen(orig);
00858     if (*curlen > (maxlen-1))
00859         *curlen = maxlen-1;
00860 }
00861 
00862 /* The SAFE versions of these call the safe_strcat function above.
00863  * Ideally, all functions should use the SAFE functions, but they
00864  * require some extra support in the calling function to remain as
00865  * efficient.
00866  */
00867 #define DESCRIBE_ABILITY_SAFE(retbuf, variable, name, len, maxlen) \
00868     if (variable) {                                                \
00869         int i, j = 0;                                              \
00870         safe_strcat(retbuf, "(" name ": ", len, maxlen);           \
00871         for (i = 0; i < NROFATTACKS; i++)                          \
00872             if (variable&(1<<i)) {                                 \
00873                 if (j)                                             \
00874                     safe_strcat(retbuf, ", ", len, maxlen);        \
00875                 else                                               \
00876                     j = 1;                                         \
00877                 safe_strcat(retbuf, attacks[i], len, maxlen);      \
00878             }                                                      \
00879         safe_strcat(retbuf, ")", len, maxlen);                     \
00880     }
00881 
00882 /* separated this from the common/item.c file. b.t. Dec 1995 */
00883 
00884 #define DESCRIBE_ABILITY(retbuf, variable, name)                   \
00885     if (variable) {                                                \
00886         int i, j = 0;                                              \
00887         strcat(retbuf, "(" name ": ");                             \
00888         for (i = 0; i < NROFATTACKS; i++)                          \
00889             if (variable&(1<<i)) {                                 \
00890                 if (j)                                             \
00891                     strcat(retbuf, ", ");                          \
00892                 else                                               \
00893                     j = 1;                                         \
00894                 strcat(retbuf, attacks[i]);                        \
00895             }                                                      \
00896         strcat(retbuf, ")");                                       \
00897     }
00898 
00899 #define DESCRIBE_PATH(retbuf, variable, name)                      \
00900     if (variable) {                                                \
00901         int i, j = 0;                                              \
00902         strcat(retbuf, "(" name ": ");                             \
00903         for (i = 0; i < NRSPELLPATHS; i++)                         \
00904             if (variable&(1<<i)) {                                 \
00905                 if (j)                                             \
00906                     strcat(retbuf, ", ");                          \
00907                 else                                               \
00908                     j = 1;                                         \
00909                 strcat(retbuf, spellpathnames[i]);                 \
00910             }                                                      \
00911         strcat(retbuf, ")");                                       \
00912     }
00913 
00914 #define DESCRIBE_PATH_SAFE(retbuf, variable, name, len, maxlen)    \
00915     if (variable) {                                                \
00916         int i, j = 0;                                              \
00917         safe_strcat(retbuf, "(" name ": ", len, maxlen);           \
00918         for (i = 0; i < NRSPELLPATHS; i++)                         \
00919             if (variable&(1<<i)) {                                 \
00920                 if (j)                                             \
00921                     safe_strcat(retbuf, ", ", len, maxlen);        \
00922                 else                                               \
00923                     j = 1;                                         \
00924                 safe_strcat(retbuf, spellpathnames[i], len, maxlen); \
00925             }                                                      \
00926         safe_strcat(retbuf, ")", len, maxlen);                     \
00927     }
00928 
00935 /* Basic flags, always use one of these */
00936 #define AP_NULL         0   
00937 #define AP_APPLY        1   
00938 #define AP_UNAPPLY      2   
00940 #define AP_BASIC_FLAGS  15
00941 
00942 /* Optional flags, for bitwise or with a basic flag */
00943 #define AP_NO_MERGE     16  
00944 #define AP_IGNORE_CURSE 32  
00945 #define AP_PRINT        64  
00947 #define AP_NOPRINT      128 
00950 
00951 
00980 #define CAN_APPLY_NEVER             0x1
00981 #define CAN_APPLY_RESTRICTION       0x2
00982 #define CAN_APPLY_NOT_MASK          0xf
00983 #define CAN_APPLY_UNAPPLY           0x10
00984 #define CAN_APPLY_UNAPPLY_MULT      0x20
00985 #define CAN_APPLY_UNAPPLY_CHOICE    0x40
00986 
00989 #define MIN_ACTIVE_SPEED        0.00001
00990 
00991 /*
00992  * random() is much better than rand().  If you have random(), use it instead.
00993  * You shouldn't need to change any of this
00994  *
00995  * 0.93.3: It looks like linux has random (previously, it was set below
00996  * to use rand).  Perhaps old version of linux lack rand?  IF you run into
00997  * problems, add || defined(__linux__) the #if immediately below.
00998  *
00999  * 0.94.2 - you probably shouldn't need to change any of the rand stuff
01000  * here.
01001  */
01002 
01003 #ifdef HAVE_SRANDOM
01004 #define RANDOM() random()
01005 #define SRANDOM(xyz) srandom(xyz)
01006 #else
01007 #  ifdef HAVE_SRAND48
01008 #  define RANDOM() lrand48()
01009 #  define SRANDOM(xyz) srand48(xyz)
01010 #  else
01011 #    ifdef HAVE_SRAND
01012 #      define RANDOM() rand()
01013 #      define SRANDOM(xyz) srand(xyz)
01014 #    else
01015 #      error "Could not find a usable random routine"
01016 #    endif
01017 #  endif
01018 #endif
01019 
01024 #define WEIGHT(op) (op->nrof ? op->weight : op->weight+op->carrying)
01025 
01039 #define PREPARE_FASTCAT(buf__) buf__+strlen(buf__)
01040 #define FAST_STRNCAT(buf__, buf2__, size__) { memcpy(buf__, buf2__, size__); buf__ += size__; }
01041 #define FAST_STRCAT(buf__, buf2__) { memcpy(buf__, buf2__, strlen(buf2__)); buf__ += strlen(buf2__); }
01042 #define FINISH_FASTCAT(buf__) buf__[0] = '\0';
01043 
01044 /* You may uncomment following define to check sanity of code.
01045  * But use as debug only (loses all speed gained by those macros)
01046  */
01047 /*#define FAST_STRNCAT(buf__, buf2__, size__) { \
01048     memcpy (buf__, buf2__, size__); \
01049     buf__ += size__; \
01050     if (size__ != strlen(buf2__)) \
01051         LOG(llevError, "Error, bad length for %s\n", buf2__); \
01052 }*/
01055 #endif /* DEFINE_H */