… | |
… | |
16 | |
16 | |
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
20 | |
21 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at crossfire@schmorp.de |
22 | */ |
22 | */ |
23 | |
23 | |
24 | /* This file is best viewed with a window width of about 100 character */ |
24 | /* This file is best viewed with a window width of about 100 character */ |
25 | |
25 | |
26 | /* This file is really too large. With all the .h files |
26 | /* This file is really too large. With all the .h files |
… | |
… | |
43 | * The following should still hopefully result in an error. |
43 | * The following should still hopefully result in an error. |
44 | */ |
44 | */ |
45 | error - Your ANSI C compiler should be defining __STDC__; |
45 | error - Your ANSI C compiler should be defining __STDC__; |
46 | #endif |
46 | #endif |
47 | |
47 | |
48 | #ifndef WIN32 /* ---win32 exclude unix configuration part */ |
|
|
49 | # include <autoconf.h> |
48 | #include <autoconf.h> |
50 | #endif |
|
|
51 | |
49 | |
52 | #define FONTDIR "" |
50 | #define FONTDIR "" |
53 | #define FONTNAME "" |
51 | #define FONTNAME "" |
54 | |
52 | |
55 | /* Decstations have trouble with fabs()... */ |
53 | /* Decstations have trouble with fabs()... */ |
… | |
… | |
382 | #define PU_READABLES 0x00400000 |
380 | #define PU_READABLES 0x00400000 |
383 | #define PU_MAGIC_DEVICE 0x00800000 |
381 | #define PU_MAGIC_DEVICE 0x00800000 |
384 | |
382 | |
385 | #define PU_NOT_CURSED 0x01000000 |
383 | #define PU_NOT_CURSED 0x01000000 |
386 | #define PU_JEWELS 0x02000000 |
384 | #define PU_JEWELS 0x02000000 |
|
|
385 | #define PU_FLESH 0x04000000 |
387 | |
386 | |
388 | |
387 | |
389 | /* Instead of using arbitrary constants for indexing the |
388 | /* Instead of using arbitrary constants for indexing the |
390 | * freearr, add these values. <= SIZEOFFREE1 will get you |
389 | * freearr, add these values. <= SIZEOFFREE1 will get you |
391 | * within 1 space. <= SIZEOFFREE2 wll get you withing |
390 | * within 1 space. <= SIZEOFFREE2 wll get you withing |
… | |
… | |
396 | #define SIZEOFFREE2 24 |
395 | #define SIZEOFFREE2 24 |
397 | #define SIZEOFFREE 49 |
396 | #define SIZEOFFREE 49 |
398 | |
397 | |
399 | #define NROF_SOUNDS (23 + NROFREALSPELLS) /* Number of sounds */ |
398 | #define NROF_SOUNDS (23 + NROFREALSPELLS) /* Number of sounds */ |
400 | |
399 | |
401 | /* Flag structure now changed. |
400 | /* |
402 | * Each flag is now a bit offset, starting at zero. The macros |
|
|
403 | * will update/read the appropriate flag element in the object |
|
|
404 | * structure. |
|
|
405 | * |
|
|
406 | * Hopefully, since these offsets are integer constants set at run time, |
|
|
407 | * the compiler will reduce the macros something as simple as the |
|
|
408 | * old system was. |
|
|
409 | * |
|
|
410 | * Flags now have FLAG as the prefix. This to be clearer, and also |
|
|
411 | * to make sure F_ names are not still being used anyplace. |
|
|
412 | * |
|
|
413 | * The macros below assume that the flag size for each element is 32 |
|
|
414 | * bits. IF it is smaller, bad things will happen. See structs.h |
|
|
415 | * for more info. |
|
|
416 | * |
|
|
417 | * All functions should use the macros below. In process of converting |
|
|
418 | * to the new system, I find several files that did not use the previous |
|
|
419 | * macros. |
|
|
420 | * |
|
|
421 | * If any FLAG's are or changed, make sure the flag_names structure in |
401 | * If any FLAG's are added or changed, make sure the flag_names structure in |
422 | * common/loader.l is updated. |
402 | * common/loader.l is updated. |
423 | * |
|
|
424 | * flags[0] is 0 to 31 |
|
|
425 | * flags[1] is 32 to 63 |
|
|
426 | * flags[2] is 64 to 95 |
|
|
427 | * flags[3] is 96 to 127 |
|
|
428 | */ |
403 | */ |
429 | |
404 | |
430 | /* Basic routines to do above */ |
405 | /* Basic routines to do above */ |
431 | #define SET_FLAG(xyz, p) \ |
406 | #define SET_FLAG(obj, flag) (obj)->flags[flag] = 1 |
432 | ((xyz)->flags[p/32] |= (1U << (p % 32))) |
407 | #define CLEAR_FLAG(obj, flag) (obj)->flags[flag] = 0 |
433 | #define CLEAR_FLAG(xyz, p) \ |
408 | #define QUERY_FLAG(obj, flag) (obj)->flags[flag] |
434 | ((xyz)->flags[p/32] &= ~(1U << (p % 32))) |
|
|
435 | #define QUERY_FLAG(xyz, p) \ |
|
|
436 | ((xyz)->flags[p/32] & (1U << (p % 32))) |
|
|
437 | #define COMPARE_FLAGS(p,q) \ |
|
|
438 | ( \ |
|
|
439 | ((p)->flags[0] == (q)->flags[0]) && \ |
|
|
440 | ((p)->flags[1] == (q)->flags[1]) && \ |
|
|
441 | ((p)->flags[2] == (q)->flags[2]) && \ |
|
|
442 | ((p)->flags[3] == (q)->flags[3]) \ |
|
|
443 | ) |
|
|
444 | |
|
|
445 | /* convenience macros to determine what kind of things we are dealing with */ |
|
|
446 | |
|
|
447 | #define IS_WEAPON(op) \ |
|
|
448 | (op->type == ARROW || op->type == BOW || op->type == WEAPON) |
|
|
449 | |
|
|
450 | #define IS_ARMOR(op) \ |
|
|
451 | (op->type == ARMOUR || op->type == SHIELD || op->type == HELMET || \ |
|
|
452 | op->type == CLOAK || op->type == BOOTS || op->type == GLOVES || \ |
|
|
453 | op->type == BRACERS || op->type == GIRDLE) |
|
|
454 | |
|
|
455 | #define IS_LIVE(op) \ |
|
|
456 | ((op->type == PLAYER || QUERY_FLAG(op, FLAG_MONSTER) || \ |
|
|
457 | (QUERY_FLAG(op, FLAG_ALIVE) && !QUERY_FLAG(op, FLAG_GENERATOR) && \ |
|
|
458 | !op->type == DOOR)) && (!QUERY_FLAG(op,FLAG_IS_A_TEMPLATE))) |
|
|
459 | |
|
|
460 | #define IS_ARROW(op) \ |
|
|
461 | (op->type==ARROW || \ |
|
|
462 | (op->type==SPELL_EFFECT && \ |
|
|
463 | (op->subtype == SP_BULLET || op->subtype == SP_MAGIC_MISSILE))) |
|
|
464 | |
|
|
465 | /* This return TRUE if object has still randomitems which |
|
|
466 | * could be expanded. |
|
|
467 | */ |
|
|
468 | #define HAS_RANDOM_ITEMS(op) (op->randomitems && (!QUERY_FLAG(op,FLAG_IS_A_TEMPLATE))) |
|
|
469 | |
409 | |
470 | /* the flags */ |
410 | /* the flags */ |
471 | |
411 | |
472 | #define FLAG_ALIVE 0 /* Object can fight (or be fought) */ |
412 | #define FLAG_ALIVE 0 /* Object can fight (or be fought) */ |
473 | #define FLAG_WIZ 1 /* Object has special privilegies */ |
413 | #define FLAG_WIZ 1 /* Object has special privilegies */ |
… | |
… | |
494 | |
434 | |
495 | #define FLAG_GENERATOR 16 /* Will generate type ob->stats.food */ |
435 | #define FLAG_GENERATOR 16 /* Will generate type ob->stats.food */ |
496 | #define FLAG_IS_THROWN 17 /* Object is designed to be thrown. */ |
436 | #define FLAG_IS_THROWN 17 /* Object is designed to be thrown. */ |
497 | #define FLAG_AUTO_APPLY 18 |
437 | #define FLAG_AUTO_APPLY 18 |
498 | /* Will be applied when created */ |
438 | /* Will be applied when created */ |
499 | #define FLAG_TREASURE 19 /* Will generate treasure when applied */ |
439 | // not used anywhere in the code // #define FLAG_TREASURE 19 /* Will generate treasure when applied */ |
500 | #define FLAG_PLAYER_SOLD 20 /* Object was sold to a shop by a player. */ |
440 | #define FLAG_PLAYER_SOLD 20 /* Object was sold to a shop by a player. */ |
501 | #define FLAG_SEE_INVISIBLE 21 /* Will see invisible player */ |
441 | #define FLAG_SEE_INVISIBLE 21 /* Will see invisible player */ |
502 | #define FLAG_CAN_ROLL 22 /* Object can be rolled */ |
442 | #define FLAG_CAN_ROLL 22 /* Object can be rolled */ |
503 | #define FLAG_OVERLAY_FLOOR 23 /* Object is an overlay floor */ |
443 | #define FLAG_OVERLAY_FLOOR 23 /* Object is an overlay floor */ |
504 | #define FLAG_IS_TURNABLE 24 /* Object can change face with direction */ |
444 | #define FLAG_IS_TURNABLE 24 /* Object can change face with direction */ |
… | |
… | |
1031 | * |
971 | * |
1032 | * 0.94.2 - you probably shouldn't need to change any of the rand stuff |
972 | * 0.94.2 - you probably shouldn't need to change any of the rand stuff |
1033 | * here. |
973 | * here. |
1034 | */ |
974 | */ |
1035 | |
975 | |
1036 | #ifdef HAVE_SRANDOM |
|
|
1037 | # define RANDOM() random() |
976 | #define RANDOM() random() |
1038 | # define SRANDOM(xyz) srandom(xyz) |
977 | #define SRANDOM(xyz) srandom(xyz) |
1039 | #else |
|
|
1040 | # ifdef HAVE_SRAND48 |
|
|
1041 | # define RANDOM() lrand48() |
|
|
1042 | # define SRANDOM(xyz) srand48(xyz) |
|
|
1043 | # else |
|
|
1044 | # ifdef HAVE_SRAND |
|
|
1045 | # define RANDOM() rand() |
|
|
1046 | # define SRANDOM(xyz) srand(xyz) |
|
|
1047 | # else |
|
|
1048 | # error "Could not find a usable random routine" |
|
|
1049 | # endif |
|
|
1050 | # endif |
|
|
1051 | #endif |
|
|
1052 | |
978 | |
1053 | /* Returns the weight of the given object. Note: it does not take the number of |
979 | /* Returns the weight of the given object. Note: it does not take the number of |
1054 | * items (nrof) into account. |
980 | * items (nrof) into account. |
1055 | */ |
981 | */ |
1056 | #define WEIGHT(op) (op->nrof?op->weight:op->weight+op->carrying) |
982 | #define WEIGHT(op) (op->nrof?op->weight:op->weight+op->carrying) |