OSDN Git Service

upgrade to 3.6.1
[jnethack/source.git] / include / dungeon.h
1 /* NetHack 3.6  dungeon.h       $NHDT-Date: 1447755969 2015/11/17 10:26:09 $  $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Michael Allison, 2006. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 #ifndef DUNGEON_H
7 #define DUNGEON_H
8
9 typedef struct d_flags {     /* dungeon/level type flags */
10     Bitfield(town, 1);       /* is this a town? (levels only) */
11     Bitfield(hellish, 1);    /* is this part of hell? */
12     Bitfield(maze_like, 1);  /* is this a maze? */
13     Bitfield(rogue_like, 1); /* is this an old-fashioned presentation? */
14     Bitfield(align, 3);      /* dungeon alignment. */
15     Bitfield(unused, 1);     /* etc... */
16 } d_flags;
17
18 typedef struct d_level { /* basic dungeon level element */
19     xchar dnum;          /* dungeon number */
20     xchar dlevel;        /* level number */
21 } d_level;
22
23 typedef struct s_level { /* special dungeon level element */
24     struct s_level *next;
25     d_level dlevel; /* dungeon & level numbers */
26     char proto[15]; /* name of prototype file (eg. "tower") */
27     char boneid;    /* character to id level in bones files */
28     uchar rndlevs;  /* no. of randomly available similar levels */
29     d_flags flags;  /* type flags */
30 } s_level;
31
32 typedef struct stairway { /* basic stairway identifier */
33     xchar sx, sy;         /* x / y location of the stair */
34     d_level tolev;        /* where does it go */
35     char up;              /* what type of stairway (up/down) */
36 } stairway;
37
38 /* level region types */
39 enum level_region_types {
40     LR_DOWNSTAIR = 0,
41     LR_UPSTAIR,
42     LR_PORTAL,
43     LR_BRANCH,
44     LR_TELE,
45     LR_UPTELE,
46     LR_DOWNTELE
47 };
48
49 typedef struct dest_area { /* non-stairway level change identifier */
50     xchar lx, ly;          /* "lower" left corner (near [0,0]) */
51     xchar hx, hy;          /* "upper" right corner (near [COLNO,ROWNO]) */
52     xchar nlx, nly;        /* outline of invalid area */
53     xchar nhx, nhy;        /* opposite corner of invalid area */
54 } dest_area;
55
56 typedef struct dungeon {   /* basic dungeon identifier */
57     char dname[24];        /* name of the dungeon (eg. "Hell") */
58     char proto[15];        /* name of prototype file (eg. "tower") */
59     char boneid;           /* character to id dungeon in bones files */
60     d_flags flags;         /* dungeon flags */
61     xchar entry_lev;       /* entry level */
62     xchar num_dunlevs;     /* number of levels in this dungeon */
63     xchar dunlev_ureached; /* how deep you have been in this dungeon */
64     int ledger_start,      /* the starting depth in "real" terms */
65         depth_start;       /* the starting depth in "logical" terms */
66 } dungeon;
67
68 /*
69  * A branch structure defines the connection between two dungeons.  They
70  * will be ordered by the dungeon number/level number of 'end1'.  Ties
71  * are resolved by 'end2'.  'Type' uses 'end1' arbitrarily as the primary
72  * point.
73  */
74 typedef struct branch {
75     struct branch *next; /* next in the branch chain */
76     int id;              /* branch identifier */
77     int type;            /* type of branch */
78     d_level end1;        /* "primary" end point */
79     d_level end2;        /* other end point */
80     boolean end1_up;     /* does end1 go up? */
81 } branch;
82
83 /* branch types */
84 #define BR_STAIR 0   /* "Regular" connection, 2 staircases. */
85 #define BR_NO_END1 1 /* "Regular" connection.  However, no stair from
86                         end1 to end2.  There is a stair from end2 to end1. */
87 #define BR_NO_END2 2 /* "Regular" connection.  However, no stair from
88                         end2 to end1.  There is a stair from end1 to end2. */
89 #define BR_PORTAL 3  /* Connection by magic portals (traps) */
90
91 /* A particular dungeon contains num_dunlevs d_levels with dlevel 1..
92  * num_dunlevs.  Ledger_start and depth_start are bases that are added
93  * to the dlevel of a particular d_level to get the effective ledger_no
94  * and depth for that d_level.
95  *
96  * Ledger_no is a bookkeeping number that gives a unique identifier for a
97  * particular d_level (for level.?? files, e.g.).
98  *
99  * Depth corresponds to the number of floors below the surface.
100  */
101 #define Is_astralevel(x) (on_level(x, &astral_level))
102 #define Is_earthlevel(x) (on_level(x, &earth_level))
103 #define Is_waterlevel(x) (on_level(x, &water_level))
104 #define Is_firelevel(x) (on_level(x, &fire_level))
105 #define Is_airlevel(x) (on_level(x, &air_level))
106 #define Is_medusa_level(x) (on_level(x, &medusa_level))
107 #define Is_oracle_level(x) (on_level(x, &oracle_level))
108 #define Is_valley(x) (on_level(x, &valley_level))
109 #define Is_juiblex_level(x) (on_level(x, &juiblex_level))
110 #define Is_asmo_level(x) (on_level(x, &asmodeus_level))
111 #define Is_baal_level(x) (on_level(x, &baalzebub_level))
112 #define Is_wiz1_level(x) (on_level(x, &wiz1_level))
113 #define Is_wiz2_level(x) (on_level(x, &wiz2_level))
114 #define Is_wiz3_level(x) (on_level(x, &wiz3_level))
115 #define Is_sanctum(x) (on_level(x, &sanctum_level))
116 #define Is_portal_level(x) (on_level(x, &portal_level))
117 #define Is_rogue_level(x) (on_level(x, &rogue_level))
118 #define Is_stronghold(x) (on_level(x, &stronghold_level))
119 #define Is_bigroom(x) (on_level(x, &bigroom_level))
120 #define Is_qstart(x) (on_level(x, &qstart_level))
121 #define Is_qlocate(x) (on_level(x, &qlocate_level))
122 #define Is_nemesis(x) (on_level(x, &nemesis_level))
123 #define Is_knox(x) (on_level(x, &knox_level))
124 #define Is_mineend_level(x) (on_level(x, &mineend_level))
125 #define Is_sokoend_level(x) (on_level(x, &sokoend_level))
126
127 #define In_sokoban(x) ((x)->dnum == sokoban_dnum)
128 #define Inhell In_hell(&u.uz) /* now gehennom */
129 #define In_endgame(x) ((x)->dnum == astral_level.dnum)
130
131 #define within_bounded_area(X, Y, LX, LY, HX, HY) \
132     ((X) >= (LX) && (X) <= (HX) && (Y) >= (LY) && (Y) <= (HY))
133
134 /* monster and object migration codes */
135
136 #define MIGR_NOWHERE (-1) /* failure flag for down_gate() */
137 #define MIGR_RANDOM 0
138 #define MIGR_APPROX_XY 1 /* approximate coordinates */
139 #define MIGR_EXACT_XY 2  /* specific coordinates */
140 #define MIGR_STAIRS_UP 3
141 #define MIGR_STAIRS_DOWN 4
142 #define MIGR_LADDER_UP 5
143 #define MIGR_LADDER_DOWN 6
144 #define MIGR_SSTAIRS 7      /* dungeon branch */
145 #define MIGR_PORTAL 8       /* magic portal */
146 #define MIGR_WITH_HERO 9    /* mon: followers; obj: trap door */
147 #define MIGR_NOBREAK 1024   /* bitmask: don't break on delivery */
148 #define MIGR_NOSCATTER 2048 /* don't scatter on delivery */
149
150 /* level information (saved via ledger number) */
151
152 struct linfo {
153     unsigned char flags;
154 #define VISITED 0x01      /* hero has visited this level */
155 #define FORGOTTEN 0x02    /* hero will forget this level when reached */
156 #define LFILE_EXISTS 0x04 /* a level file exists for this level */
157         /* Note:  VISITED and LFILE_EXISTS are currently almost always
158          * set at the same time.  However they _mean_ different things.
159          */
160 #ifdef MFLOPPY
161 #define FROMPERM 1 /* for ramdisk use */
162 #define TOPERM 2   /* for ramdisk use */
163 #define ACTIVE 1
164 #define SWAPPED 2
165     int where;
166     long time;
167     long size;
168 #endif /* MFLOPPY */
169 };
170
171 /* types and structures for dungeon map recording
172  *
173  * It is designed to eliminate the need for an external notes file for some
174  * mundane dungeon elements.  "Where was the last altar I passed?" etc...
175  * Presumably the character can remember this sort of thing even if, months
176  * later in real time picking up an old save game, I can't.
177  *
178  * To be consistent, one can assume that this map is in the player's mind and
179  * has no physical correspondence (eliminating illiteracy/blind/hands/hands
180  * free concerns).  Therefore, this map is not exhaustive nor detailed ("some
181  * fountains").  This makes it also subject to player conditions (amnesia).
182  */
183
184 /* Because clearly Nethack needs more ways to specify alignment */
185 #define Amask2msa(x) ((x) == 4 ? 3 : (x) &AM_MASK)
186 #define Msa2amask(x) ((x) == 3 ? 4 : (x))
187 #define MSA_NONE 0 /* unaligned or multiple alignments */
188 #define MSA_LAWFUL 1
189 #define MSA_NEUTRAL 2
190 #define MSA_CHAOTIC 3
191
192 /* what the player knows about a single dungeon level */
193 /* initialized in mklev() */
194 typedef struct mapseen {
195     struct mapseen *next; /* next map in the chain */
196     branch *br;           /* knows about branch via taking it in goto_level */
197     d_level lev;          /* corresponding dungeon level */
198     struct mapseen_feat {
199         /* feature knowledge that must be calculated from levl array */
200         Bitfield(nfount, 2);
201         Bitfield(nsink, 2);
202         Bitfield(naltar, 2);
203         Bitfield(nthrone, 2);
204
205         Bitfield(ngrave, 2);
206         Bitfield(ntree, 2);
207         Bitfield(water, 2);
208         Bitfield(lava, 2);
209
210         Bitfield(ice, 2);
211         /* calculated from rooms array */
212         Bitfield(nshop, 2);
213         Bitfield(ntemple, 2);
214         /* altar alignment; MSA_NONE if there is more than one and
215            they aren't all the same */
216         Bitfield(msalign, 2);
217
218         Bitfield(shoptype, 5);
219     } feat;
220     struct mapseen_flags {
221         Bitfield(unreachable, 1); /* can't get back to this level */
222         Bitfield(forgot, 1);      /* player has forgotten about this level */
223         Bitfield(knownbones, 1);  /* player aware of bones */
224         Bitfield(oracle, 1);
225         Bitfield(sokosolved, 1);
226         Bitfield(bigroom, 1);
227         Bitfield(castle, 1);
228         Bitfield(castletune, 1); /* add tune hint to castle annotation */
229
230         Bitfield(valley, 1);
231         Bitfield(msanctum, 1);
232         Bitfield(ludios, 1);
233         Bitfield(roguelevel, 1);
234         /* quest annotations: quest_summons is for main dungeon level
235            with entry portal and is reset once quest has been finished;
236            questing is for quest home (level 1) */
237         Bitfield(quest_summons, 1); /* heard summons from leader */
238         Bitfield(questing, 1); /* quest leader has unlocked quest stairs */
239     } flags;
240     /* custom naming */
241     char *custom;
242     unsigned custom_lth;
243     struct mapseen_rooms {
244         Bitfield(seen, 1);
245         Bitfield(untended, 1);         /* flag for shop without shk */
246     } msrooms[(MAXNROFROOMS + 1) * 2]; /* same size as rooms[] */
247     /* dead heroes; might not have graves or ghosts */
248     struct cemetery *final_resting_place; /* same as level.bonesinfo */
249 } mapseen;
250
251 #endif /* DUNGEON_H */