1 /* NetHack 3.6 sp_lev.h $NHDT-Date: 1432512780 2015/05/25 00:13:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.14 $ */
2 /* Copyright (c) 1989 by Jean-Christophe Collet */
3 /* NetHack may be freely redistributed. See license for details. */
13 #define W_ANY (W_NORTH | W_SOUTH | W_EAST | W_WEST)
20 #define NOTELEPORT 0x00000001L
21 #define HARDFLOOR 0x00000002L
22 #define NOMMAP 0x00000004L
23 #define SHORTSIGHTED 0x00000008L
24 #define ARBOREAL 0x00000010L
25 #define MAZELEVEL 0x00000020L
26 #define PREMAPPED 0x00000040L /* premapped level & sokoban rules */
27 #define SHROUD 0x00000080L
28 #define GRAVEYARD 0x00000100L
29 #define ICEDPOOLS 0x00000200L /* for ice locations: ICED_POOL vs ICED_MOAT \
31 #define SOLIDIFY 0x00000400L /* outer areas are nondiggable & nonpasswall */
32 #define CORRMAZE 0x00000800L /* for maze levels only */
33 #define CHECK_INACCESSIBLES 0x00001000L /* check for inaccessible areas and
34 generate ways to escape from them */
36 /* different level layout initializers */
37 #define LVLINIT_NONE 0
38 #define LVLINIT_SOLIDFILL 1
39 #define LVLINIT_MAZEGRID 2
40 #define LVLINIT_MINES 3
41 #define LVLINIT_ROGUE 4
43 /* max. layers of object containment */
44 #define MAX_CONTAINMENT 10
46 /* max. # of random registers */
47 #define MAX_REGISTERS 10
49 /* max. nested depth of subrooms */
50 #define MAX_NESTED_ROOMS 5
52 /* max. # of opcodes per special level */
53 #define SPCODER_MAX_RUNTIME 65536
55 /* Opcodes for creating the level
56 * If you change these, also change opcodestr[] in util/lev_main.c
119 SPO_VAR_INIT, /* variable_name data */
140 /* MONSTER and OBJECT can take a variable number of parameters,
141 * they also pop different # of values from the stack. So,
142 * first we pop a value that tells what the _next_ value will
146 #define SP_M_V_PEACEFUL 0
147 #define SP_M_V_ALIGN 1
148 #define SP_M_V_ASLEEP 2
149 #define SP_M_V_APPEAR 3
150 #define SP_M_V_NAME 4
152 #define SP_M_V_FEMALE 5
153 #define SP_M_V_INVIS 6
154 #define SP_M_V_CANCELLED 7
155 #define SP_M_V_REVIVED 8
156 #define SP_M_V_AVENGE 9
157 #define SP_M_V_FLEEING 10
158 #define SP_M_V_BLINDED 11
159 #define SP_M_V_PARALYZED 12
160 #define SP_M_V_STUNNED 13
161 #define SP_M_V_CONFUSED 14
162 #define SP_M_V_SEENTRAPS 15
164 #define SP_M_V_END 16 /* end of variable parameters */
168 #define SP_O_V_CURSE 1
169 #define SP_O_V_CORPSENM 2
170 #define SP_O_V_NAME 3
171 #define SP_O_V_QUAN 4
172 #define SP_O_V_BURIED 5
174 #define SP_O_V_ERODED 7
175 #define SP_O_V_LOCKED 8
176 #define SP_O_V_TRAPPED 9
177 #define SP_O_V_RECHARGED 10
178 #define SP_O_V_INVIS 11
179 #define SP_O_V_GREASED 12
180 #define SP_O_V_BROKEN 13
181 #define SP_O_V_COORD 14
182 #define SP_O_V_END 15 /* end of variable parameters */
184 /* When creating objects, we need to know whether
185 * it's a container and/or contents.
187 #define SP_OBJ_CONTENT 0x1
188 #define SP_OBJ_CONTAINER 0x2
190 /* SPO_FILTER types */
191 #define SPOFILTER_PERCENT 0
192 #define SPOFILTER_SELECTION 1
193 #define SPOFILTER_MAPCHAR 2
195 /* gradient filter types */
196 #define SEL_GRADIENT_RADIAL 0
197 #define SEL_GRADIENT_SQUARE 1
200 #define SPOVAR_NULL 0x00
201 #define SPOVAR_INT 0x01 /* l */
202 #define SPOVAR_STRING 0x02 /* str */
203 #define SPOVAR_VARIABLE 0x03 /* str (contains the variable name) */
204 #define SPOVAR_COORD \
205 0x04 /* coordinate, encoded in l; use SP_COORD_X() and SP_COORD_Y() */
206 #define SPOVAR_REGION 0x05 /* region, encoded in l; use SP_REGION_X1() etc \
208 #define SPOVAR_MAPCHAR 0x06 /* map char, in l */
209 #define SPOVAR_MONST \
210 0x07 /* monster class & specific monster, encoded in l; use SP_MONST_... \
213 0x08 /* object class & specific object type, encoded in l; use \
215 #define SPOVAR_SEL 0x09 /* selection. char[COLNO][ROWNO] in str */
216 #define SPOVAR_ARRAY 0x40 /* used in splev_var & lc_vardefs, not in opvar */
218 #define SP_COORD_IS_RANDOM 0x01000000
219 /* Humidity flags for get_location() and friends, used with
220 * SP_COORD_PACK_RANDOM() */
225 #define ANY_LOC 0x10 /* even outside the level */
226 #define NO_LOC_WARN 0x20 /* no complaints and set x & y to -1, if no loc */
228 #define SP_COORD_X(l) (l & 0xff)
229 #define SP_COORD_Y(l) ((l >> 16) & 0xff)
230 #define SP_COORD_PACK(x, y) (((x) &0xff) + (((y) &0xff) << 16))
231 #define SP_COORD_PACK_RANDOM(f) (SP_COORD_IS_RANDOM | (f))
233 #define SP_REGION_X1(l) (l & 0xff)
234 #define SP_REGION_Y1(l) ((l >> 8) & 0xff)
235 #define SP_REGION_X2(l) ((l >> 16) & 0xff)
236 #define SP_REGION_Y2(l) ((l >> 24) & 0xff)
237 #define SP_REGION_PACK(x1, y1, x2, y2) \
238 (((x1) &0xff) + (((y1) &0xff) << 8) + (((x2) &0xff) << 16) \
239 + (((y2) &0xff) << 24))
241 #define SP_MONST_CLASS(l) (l & 0xff)
242 #define SP_MONST_PM(l) ((l >> 8) & 0xffff)
243 #define SP_MONST_PACK(m, c) (((m) << 8) + ((char) (c)))
245 #define SP_OBJ_CLASS(l) (l & 0xff)
246 #define SP_OBJ_TYP(l) ((l >> 8) & 0xffff)
247 #define SP_OBJ_PACK(o, c) (((o) << 8) + ((char) (c)))
249 #define SP_MAPCHAR_TYP(l) (l & 0xff)
250 #define SP_MAPCHAR_LIT(l) ((l >> 8) & 0xff)
251 #define SP_MAPCHAR_PACK(typ, lit) (((lit) << 8) + ((char) (typ)))
254 xchar spovartyp; /* one of SPOVAR_foo */
262 struct splev_var *next;
264 xchar svtyp; /* SPOVAR_foo */
267 struct opvar **arrayvalues;
275 struct opvar **stackdata;
279 struct sp_frame *next;
280 struct splevstack *stack;
281 struct splev_var *variables;
286 struct splevstack *stack;
287 struct sp_frame *frame;
290 struct mkroom *croom;
291 struct mkroom *tmproomlist[MAX_NESTED_ROOMS + 1];
292 boolean failed_room[MAX_NESTED_ROOMS + 1];
296 boolean check_inaccessibles;
298 int opcode; /* current opcode */
299 struct opvar *opdat; /* current push data (req. opcode == SPO_PUSH) */
302 /* special level coder CPU flags */
303 #define SP_CPUFLAG_LT 1
304 #define SP_CPUFLAG_GT 2
305 #define SP_CPUFLAG_EQ 4
306 #define SP_CPUFLAG_ZERO 8
309 * Structures manipulated by the special levels loader & compiler
312 #define packed_coord long
328 typedef union str_or_len {
334 xchar init_style; /* one of LVLINIT_foo */
337 boolean init_present, padding;
339 boolean smoothed, joined;
345 xchar wall, pos, secret, mask;
354 Str_or_Len name, appear_as;
358 xchar x, y, class, appear;
359 schar peaceful, asleep;
360 short female, invis, cancelled, revived, avenge, fleeing, blinded,
361 paralyzed, stunned, confused;
371 xchar x, y, class, containment;
376 short eroded, locked, trapped, recharged, invis, greased, broken;
387 xchar x1, y1, x2, y2;
388 xchar rtype, rlit, rirreg;
397 xchar x1, y1, x2, y2;
398 xchar fromter, toter, tolit;
401 /* values for rtype are defined in dungeon.h */
404 xchar x1, y1, x2, y2;
407 xchar x1, y1, x2, y2;
409 boolean in_islev, del_islev;
410 xchar rtype, padding;
422 typedef struct _room {
426 xchar xalign, yalign;
427 xchar rtype, chance, rlit, filled, joined;
433 schar halign, valign;
449 xchar x, y, direction, count, lit;
453 /* only used by lev_comp */
454 struct lc_funcdefs_parm {
457 struct lc_funcdefs_parm *next;
461 struct lc_funcdefs *next;
466 struct lc_funcdefs_parm *params;
471 struct lc_vardefs *next;
473 long var_type; /* SPOVAR_foo */
478 struct lc_breakdef *next;
479 struct opvar *breakpoint;
484 * Quick! Avert your eyes while you still have a chance!
487 /* compiling lev_comp rather than nethack */
494 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, \
496 #define VA_DECL(typ1, var1) \
497 (var1, VA_ARGS) typ1 var1; \
498 char *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8, *arg9, \
499 *arg10, *arg11, *arg12, *arg13, *arg14; \
501 #define VA_DECL2(typ1, var1, typ2, var2) \
502 (var1, var2, VA_ARGS) typ1 var1; \
504 char *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8, *arg9, \
505 *arg10, *arg11, *arg12, *arg13, *arg14; \
507 /* unlike in the core, lev_comp's VA_SHIFT is completely safe,
508 because callers always pass all these arguments */
510 (arg1 = arg2, arg2 = arg3, arg3 = arg4, arg4 = arg5, arg5 = arg6, \
511 arg6 = arg7, arg7 = arg8, arg8 = arg9, arg9 = arg10, arg10 = arg11, \
512 arg11 = arg12, arg12 = arg13, arg13 = arg14, arg14 = 0)
513 /* standard NULL may be either (void *)0 or plain 0, both of
514 which would need to be explicitly cast to (char *) here */
516 #define VA_PASS1(a1) \
517 (Va) a1, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, \
518 (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
519 #define VA_PASS2(a1, a2) \
520 (Va) a1, (Va) a2, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, \
521 (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
522 #define VA_PASS3(a1, a2, a3) \
523 (Va) a1, (Va) a2, (Va) a3, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, \
524 (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
525 #define VA_PASS4(a1, a2, a3, a4) \
526 (Va) a1, (Va) a2, (Va) a3, (Va) a4, (Va) 0, (Va) 0, (Va) 0, (Va) 0, \
527 (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
528 #define VA_PASS5(a1, a2, a3, a4, a5) \
529 (Va) a1, (Va) a2, (Va) a3, (Va) a4, (Va) a5, (Va) 0, (Va) 0, (Va) 0, \
530 (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
531 #define VA_PASS7(a1, a2, a3, a4, a5, a6, a7) \
532 (Va) a1, (Va) a2, (Va) a3, (Va) a4, (Va) a5, (Va) a6, (Va) a7, (Va) 0, \
533 (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
534 #define VA_PASS8(a1, a2, a3, a4, a5, a6, a7, a8) \
535 (Va) a1, (Va) a2, (Va) a3, (Va) a4, (Va) a5, (Va) a6, (Va) a7, (Va) a8, \
536 (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
537 #define VA_PASS9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
538 (Va) a1, (Va) a2, (Va) a3, (Va) a4, (Va) a5, (Va) a6, (Va) a7, (Va) a8, \
539 (Va) a9, (Va) 0, (Va) 0, (Va) 0, (Va) 0, (Va) 0
540 #define VA_PASS14(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, \
542 (Va) a1, (Va) a2, (Va) a3, (Va) a4, (Va) a5, (Va) a6, (Va) a7, (Va) a8, \
543 (Va) a9, (Va) a10, (Va) a11, (Va) a12, (Va) a13, (Va) a14
544 #else /*!USE_OLDARGS*/
545 /* USE_STDARG and USE_VARARGS don't need to pass dummy arguments
547 #define VA_PASS1(a1) a1
548 #define VA_PASS2(a1, a2) a1, a2
549 #define VA_PASS3(a1, a2, a3) a1, a2, a3
550 #define VA_PASS4(a1, a2, a3, a4) a1, a2, a3, a4
551 #define VA_PASS5(a1, a2, a3, a4, a5) a1, a2, a3, a4, a5
552 #define VA_PASS7(a1, a2, a3, a4, a5, a6, a7) a1, a2, a3, a4, a5, a6, a7
553 #define VA_PASS8(a1, a2, a3, a4, a5, a6, a7, a8) \
554 a1, a2, a3, a4, a5, a6, a7, a8
555 #define VA_PASS9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
556 a1, a2, a3, a4, a5, a6, a7, a8, a9
557 #define VA_PASS14(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, \
559 a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14
560 #endif /*?USE_OLDARGS*/
561 /* You were warned to avert your eyes.... */
564 #endif /* SP_LEV_H */