… | |
… | |
395 | #define SIZEOFFREE2 24 |
395 | #define SIZEOFFREE2 24 |
396 | #define SIZEOFFREE 49 |
396 | #define SIZEOFFREE 49 |
397 | |
397 | |
398 | #define NROF_SOUNDS (23 + NROFREALSPELLS) /* Number of sounds */ |
398 | #define NROF_SOUNDS (23 + NROFREALSPELLS) /* Number of sounds */ |
399 | |
399 | |
400 | /* Flag structure now changed. |
400 | /* |
401 | * Each flag is now a bit offset, starting at zero. The macros |
|
|
402 | * will update/read the appropriate flag element in the object |
|
|
403 | * structure. |
|
|
404 | * |
|
|
405 | * Hopefully, since these offsets are integer constants set at run time, |
|
|
406 | * the compiler will reduce the macros something as simple as the |
|
|
407 | * old system was. |
|
|
408 | * |
|
|
409 | * Flags now have FLAG as the prefix. This to be clearer, and also |
|
|
410 | * to make sure F_ names are not still being used anyplace. |
|
|
411 | * |
|
|
412 | * The macros below assume that the flag size for each element is 32 |
|
|
413 | * bits. IF it is smaller, bad things will happen. See structs.h |
|
|
414 | * for more info. |
|
|
415 | * |
|
|
416 | * All functions should use the macros below. In process of converting |
|
|
417 | * to the new system, I find several files that did not use the previous |
|
|
418 | * macros. |
|
|
419 | * |
|
|
420 | * 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 |
421 | * common/loader.l is updated. |
402 | * common/loader.l is updated. |
422 | * |
|
|
423 | * flags[0] is 0 to 31 |
|
|
424 | * flags[1] is 32 to 63 |
|
|
425 | * flags[2] is 64 to 95 |
|
|
426 | * flags[3] is 96 to 127 |
|
|
427 | */ |
403 | */ |
428 | |
404 | |
429 | /* Basic routines to do above */ |
405 | /* Basic routines to do above */ |
430 | #define SET_FLAG(obj, flag) (obj)->flags[flag] = 1 |
406 | #define SET_FLAG(obj, flag) (obj)->flags[flag] = 1 |
431 | #define CLEAR_FLAG(obj, flag) (obj)->flags[flag] = 0 |
407 | #define CLEAR_FLAG(obj, flag) (obj)->flags[flag] = 0 |
432 | #define QUERY_FLAG(obj, flag) (obj)->flags[flag] |
408 | #define QUERY_FLAG(obj, flag) (obj)->flags[flag] |
433 | |
|
|
434 | /* convenience macros to determine what kind of things we are dealing with */ |
|
|
435 | |
|
|
436 | #define IS_WEAPON(op) \ |
|
|
437 | (op->type == ARROW || op->type == BOW || op->type == WEAPON) |
|
|
438 | |
|
|
439 | #define IS_ARMOR(op) \ |
|
|
440 | (op->type == ARMOUR || op->type == SHIELD || op->type == HELMET || \ |
|
|
441 | op->type == CLOAK || op->type == BOOTS || op->type == GLOVES || \ |
|
|
442 | op->type == BRACERS || op->type == GIRDLE) |
|
|
443 | |
|
|
444 | #define IS_LIVE(op) \ |
|
|
445 | ((op->type == PLAYER || QUERY_FLAG(op, FLAG_MONSTER) || \ |
|
|
446 | (QUERY_FLAG(op, FLAG_ALIVE) && !QUERY_FLAG(op, FLAG_GENERATOR) && \ |
|
|
447 | !op->type == DOOR)) && (!QUERY_FLAG(op,FLAG_IS_A_TEMPLATE))) |
|
|
448 | |
|
|
449 | #define IS_ARROW(op) \ |
|
|
450 | (op->type==ARROW || \ |
|
|
451 | (op->type==SPELL_EFFECT && \ |
|
|
452 | (op->subtype == SP_BULLET || op->subtype == SP_MAGIC_MISSILE))) |
|
|
453 | |
|
|
454 | /* This return TRUE if object has still randomitems which |
|
|
455 | * could be expanded. |
|
|
456 | */ |
|
|
457 | #define HAS_RANDOM_ITEMS(op) (op->randomitems && (!QUERY_FLAG(op,FLAG_IS_A_TEMPLATE))) |
|
|
458 | |
409 | |
459 | /* the flags */ |
410 | /* the flags */ |
460 | |
411 | |
461 | #define FLAG_ALIVE 0 /* Object can fight (or be fought) */ |
412 | #define FLAG_ALIVE 0 /* Object can fight (or be fought) */ |
462 | #define FLAG_WIZ 1 /* Object has special privilegies */ |
413 | #define FLAG_WIZ 1 /* Object has special privilegies */ |
… | |
… | |
483 | |
434 | |
484 | #define FLAG_GENERATOR 16 /* Will generate type ob->stats.food */ |
435 | #define FLAG_GENERATOR 16 /* Will generate type ob->stats.food */ |
485 | #define FLAG_IS_THROWN 17 /* Object is designed to be thrown. */ |
436 | #define FLAG_IS_THROWN 17 /* Object is designed to be thrown. */ |
486 | #define FLAG_AUTO_APPLY 18 |
437 | #define FLAG_AUTO_APPLY 18 |
487 | /* Will be applied when created */ |
438 | /* Will be applied when created */ |
488 | #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 */ |
489 | #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. */ |
490 | #define FLAG_SEE_INVISIBLE 21 /* Will see invisible player */ |
441 | #define FLAG_SEE_INVISIBLE 21 /* Will see invisible player */ |
491 | #define FLAG_CAN_ROLL 22 /* Object can be rolled */ |
442 | #define FLAG_CAN_ROLL 22 /* Object can be rolled */ |
492 | #define FLAG_OVERLAY_FLOOR 23 /* Object is an overlay floor */ |
443 | #define FLAG_OVERLAY_FLOOR 23 /* Object is an overlay floor */ |
493 | #define FLAG_IS_TURNABLE 24 /* Object can change face with direction */ |
444 | #define FLAG_IS_TURNABLE 24 /* Object can change face with direction */ |