Source:NetHack 5.0.0/include/align.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to align.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/align.h#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 5.0	align.h	$NHDT-Date: 1604269810 2020/11/01 22:30:10 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.15 $ */
2. /* Copyright (c) Mike Stephenson, Izchak Miller  1991.            */
3. /* NetHack may be freely redistributed.  See license for details. */
4. 
5. #ifndef ALIGN_H
6. #define ALIGN_H
7. 
8. typedef schar aligntyp; /* basic alignment type */
9. 
10. typedef struct align { /* alignment & record */
11.     aligntyp type;
12.     int record;
13.     unsigned abuse;
14. } align;
15. 
16. /* bounds for "record" -- respect initial alignments of 10 */
17. #define ALIGNLIM (10L + (svm.moves / 200L))
18. 
19. #define A_NONE (-128) /* the value range of type */
20. 
21. #define A_CHAOTIC (-1)
22. #define A_NEUTRAL 0
23. #define A_LAWFUL 1
24. 
25. #define A_COALIGNED 1
26. #define A_OPALIGNED (-1)
27. 
28. /* align masks */
29. #define AM_NONE         0x00
30. #define AM_CHAOTIC      0x01
31. #define AM_NEUTRAL      0x02
32. #define AM_LAWFUL       0x04
33. #define AM_MASK         0x07 /* mask for "normal" alignment values */
34. 
35. /* Some altars are considered shrines, add a flag for that
36.    for the altarmask field of struct rm. */
37. #define AM_SHRINE       0x08
38. /* High altar on Astral plane or Moloch's sanctum */
39. #define AM_SANCTUM      0x10
40. 
41. /* special level flags, gone by the time the level has been loaded */
42. #define AM_SPLEV_CO     0x20 /* co-aligned: force alignment to match hero's  */
43. #define AM_SPLEV_NONCO  0x40 /* non-co-aligned: force alignment to not match */
44. #define AM_SPLEV_RANDOM 0x80
45. 
46. #define Amask2align(x) \
47.     ((aligntyp) ((((x) & AM_MASK) == 0) ? A_NONE                \
48.                  : (((x) & AM_MASK) == AM_LAWFUL) ? A_LAWFUL    \
49.                    : ((int) ((x) & AM_MASK)) - 2)) /* 2 => 0, 1 => -1 */
50. #define Align2amask(x) \
51.     ((unsigned) (((x) == A_NONE) ? AM_NONE                      \
52.                  : ((x) == A_LAWFUL) ? AM_LAWFUL                \
53.                    : ((x) + 2))) /* -1 => 1, 0 => 2 */
54. 
55. /* Because clearly Nethack needs more ways to specify alignment...
56.    Amask2msa(): 1, 2, 4 converted to 1, 2, 3 to fit within a width 2 bitfield;
57.    Msa2amask(): 1, 2, 3 converted back to 1, 2, 4;
58.    For Amask2msa(), 'x' might have the shrine bit set so strip that off. */
59. #define Amask2msa(x) ((((x) & AM_MASK) == 4) ? 3 : (x) & AM_MASK)
60. #define Msa2amask(x) (((x) == 3) ? 4 : (x))
61. #define MSA_NONE    0  /* unaligned or multiple alignments */
62. 
63. /* alignment change reasons for uchangealign(attrib.c) */
64. enum uchangealign_reasons {
65.     A_CG_CONVERT  = 0, /* permanently converted */
66.     A_CG_HELM_ON  = 1, /* donned helm of opposite alignment */
67.     A_CG_HELM_OFF = 2, /* doffed helm of opposite alignment */
68. };
69. 
70. #endif /* ALIGN_H */