OSDN Git Service

add missing "#ifdef X11LARGETILE"
[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
102 /* These both can't be zero, or dungeon_topology isn't init'd / restored */
103 #define Lassigned(y) ((y)->dlevel || (y)->dnum)
104 #define Lcheck(x,z) (Lassigned(z) && on_level(x, z))
105
106 #define Is_astralevel(x)    (Lcheck(x, &astral_level))
107 #define Is_earthlevel(x)    (Lcheck(x, &earth_level))
108 #define Is_waterlevel(x)    (Lcheck(x, &water_level))
109 #define Is_firelevel(x)     (Lcheck(x, &fire_level))
110 #define Is_airlevel(x)      (Lcheck(x, &air_level))
111 #define Is_medusa_level(x)  (Lcheck(x, &medusa_level))
112 #define Is_oracle_level(x)  (Lcheck(x, &oracle_level))
113 #define Is_valley(x)        (Lcheck(x, &valley_level))
114 #define Is_juiblex_level(x) (Lcheck(x, &juiblex_level))
115 #define Is_asmo_level(x)    (Lcheck(x, &asmodeus_level))
116 #define Is_baal_level(x)    (Lcheck(x, &baalzebub_level))
117 #define Is_wiz1_level(x)    (Lcheck(x, &wiz1_level))
118 #define Is_wiz2_level(x)    (Lcheck(x, &wiz2_level))
119 #define Is_wiz3_level(x)    (Lcheck(x, &wiz3_level))
120 #define Is_sanctum(x)       (Lcheck(x, &sanctum_level))
121 #define Is_portal_level(x)  (Lcheck(x, &portal_level))
122 #define Is_rogue_level(x)   (Lcheck(x, &rogue_level))
123 #define Is_stronghold(x)    (Lcheck(x, &stronghold_level))
124 #define Is_bigroom(x)       (Lcheck(x, &bigroom_level))
125 #define Is_qstart(x)        (Lcheck(x, &qstart_level))
126 #define Is_qlocate(x)       (Lcheck(x, &qlocate_level))
127 #define Is_nemesis(x)       (Lcheck(x, &nemesis_level))
128 #define Is_knox(x)          (Lcheck(x, &knox_level))
129 #define Is_mineend_level(x) (Lcheck(x, &mineend_level))
130 #define Is_sokoend_level(x) (Lcheck(x, &sokoend_level))
131
132 #define In_sokoban(x) ((x)->dnum == sokoban_dnum)
133 #define Inhell In_hell(&u.uz) /* now gehennom */
134 #define In_endgame(x) ((x)->dnum == astral_level.dnum)
135
136 #define within_bounded_area(X, Y, LX, LY, HX, HY) \
137     ((X) >= (LX) && (X) <= (HX) && (Y) >= (LY) && (Y) <= (HY))
138
139 /* monster and object migration codes */
140
141 #define MIGR_NOWHERE (-1) /* failure flag for down_gate() */
142 #define MIGR_RANDOM 0
143 #define MIGR_APPROX_XY 1 /* approximate coordinates */
144 #define MIGR_EXACT_XY 2  /* specific coordinates */
145 #define MIGR_STAIRS_UP 3
146 #define MIGR_STAIRS_DOWN 4
147 #define MIGR_LADDER_UP 5
148 #define MIGR_LADDER_DOWN 6
149 #define MIGR_SSTAIRS 7      /* dungeon branch */
150 #define MIGR_PORTAL 8       /* magic portal */
151 #define MIGR_WITH_HERO 9    /* mon: followers; obj: trap door */
152 #define MIGR_NOBREAK 1024   /* bitmask: don't break on delivery */
153 #define MIGR_NOSCATTER 2048 /* don't scatter on delivery */
154 #define MIGR_TO_SPECIES 4096 /* migrating to species as they are made */ 
155 #define MIGR_LEFTOVERS 8192  /* grab remaining MIGR_TO_SPECIES objects */
156 /* level information (saved via ledger number) */
157
158 struct linfo {
159     unsigned char flags;
160 #define VISITED 0x01      /* hero has visited this level */
161 #define FORGOTTEN 0x02    /* hero will forget this level when reached */
162 #define LFILE_EXISTS 0x04 /* a level file exists for this level */
163         /* Note:  VISITED and LFILE_EXISTS are currently almost always
164          * set at the same time.  However they _mean_ different things.
165          */
166 #ifdef MFLOPPY
167 #define FROMPERM 1 /* for ramdisk use */
168 #define TOPERM 2   /* for ramdisk use */
169 #define ACTIVE 1
170 #define SWAPPED 2
171     int where;
172     long time;
173     long size;
174 #endif /* MFLOPPY */
175 };
176
177 /* types and structures for dungeon map recording
178  *
179  * It is designed to eliminate the need for an external notes file for some
180  * mundane dungeon elements.  "Where was the last altar I passed?" etc...
181  * Presumably the character can remember this sort of thing even if, months
182  * later in real time picking up an old save game, I can't.
183  *
184  * To be consistent, one can assume that this map is in the player's mind and
185  * has no physical correspondence (eliminating illiteracy/blind/hands/hands
186  * free concerns).  Therefore, this map is not exhaustive nor detailed ("some
187  * fountains").  This makes it also subject to player conditions (amnesia).
188  */
189
190 /* Because clearly Nethack needs more ways to specify alignment */
191 #define Amask2msa(x) ((x) == 4 ? 3 : (x) &AM_MASK)
192 #define Msa2amask(x) ((x) == 3 ? 4 : (x))
193 #define MSA_NONE 0 /* unaligned or multiple alignments */
194 #define MSA_LAWFUL 1
195 #define MSA_NEUTRAL 2
196 #define MSA_CHAOTIC 3
197
198 /* what the player knows about a single dungeon level */
199 /* initialized in mklev() */
200 typedef struct mapseen {
201     struct mapseen *next; /* next map in the chain */
202     branch *br;           /* knows about branch via taking it in goto_level */
203     d_level lev;          /* corresponding dungeon level */
204     struct mapseen_feat {
205         /* feature knowledge that must be calculated from levl array */
206         Bitfield(nfount, 2);
207         Bitfield(nsink, 2);
208         Bitfield(naltar, 2);
209         Bitfield(nthrone, 2);
210
211         Bitfield(ngrave, 2);
212         Bitfield(ntree, 2);
213         Bitfield(water, 2);
214         Bitfield(lava, 2);
215
216         Bitfield(ice, 2);
217         /* calculated from rooms array */
218         Bitfield(nshop, 2);
219         Bitfield(ntemple, 2);
220         /* altar alignment; MSA_NONE if there is more than one and
221            they aren't all the same */
222         Bitfield(msalign, 2);
223
224         Bitfield(shoptype, 5);
225     } feat;
226     struct mapseen_flags {
227         Bitfield(unreachable, 1); /* can't get back to this level */
228         Bitfield(forgot, 1);      /* player has forgotten about this level */
229         Bitfield(knownbones, 1);  /* player aware of bones */
230         Bitfield(oracle, 1);
231         Bitfield(sokosolved, 1);
232         Bitfield(bigroom, 1);
233         Bitfield(castle, 1);
234         Bitfield(castletune, 1); /* add tune hint to castle annotation */
235
236         Bitfield(valley, 1);
237         Bitfield(msanctum, 1);
238         Bitfield(ludios, 1);
239         Bitfield(roguelevel, 1);
240         /* quest annotations: quest_summons is for main dungeon level
241            with entry portal and is reset once quest has been finished;
242            questing is for quest home (level 1) */
243         Bitfield(quest_summons, 1); /* heard summons from leader */
244         Bitfield(questing, 1); /* quest leader has unlocked quest stairs */
245     } flags;
246     /* custom naming */
247     char *custom;
248     unsigned custom_lth;
249     struct mapseen_rooms {
250         Bitfield(seen, 1);
251         Bitfield(untended, 1);         /* flag for shop without shk */
252     } msrooms[(MAXNROFROOMS + 1) * 2]; /* same size as rooms[] */
253     /* dead heroes; might not have graves or ghosts */
254     struct cemetery *final_resting_place; /* same as level.bonesinfo */
255 } mapseen;
256
257 #endif /* DUNGEON_H */