Source:NetHack 3.0.0/lev comp.c

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to lev_comp.c from the source code of NetHack 3.0.0. To link to a particular line, write [[NetHack 3.0.0/lev_comp.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

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.    
2.    # line 1 "lev_comp.y"
3.     
4.    /*	SCCS Id: @(#)lev_comp.c	3.0	89/07/02
5.    /*	Copyright (c) 1989 by Jean-Christophe Collet */
6.    /* NetHack may be freely redistributed.  See license for details. */
7.    
8.    /*
9.     * This file contains the Level Compiler code
10.    * It may handle special mazes & special room-levels
11.    */
12.   
13.   /* block some unused #defines to avoid overloading some cpp's */
14.   #define MONDATA_H
15.   #include "hack.h"
16.   #include "sp_lev.h"
17.   #include <fcntl.h>
18.   
19.   #ifdef AMIGA
20.   char *fgets();
21.   # define    alloc   malloc
22.   # undef     fopen
23.   # undef     printf
24.   # undef     Printf
25.   # define    Printf  printf
26.   # define    memset(addr,val,len)    setmem(addr,len,val)
27.   #endif
28.   
29.   #ifdef MSDOS
30.   # undef exit
31.   #endif
32.   
33.   #define MAX_REGISTERS	10
34.   #define ERR		(-1)
35.   
36.   struct reg {
37.   	int x1, y1;
38.   	int x2, y2;
39.   }		current_region;
40.   
41.   struct coord {
42.   	int x;
43.   	int y;
44.   }		current_coord;
45.   
46.   struct {
47.   	char *name;
48.   	short type;
49.   } trap_types[TRAPNUM-1] = {
50.   	"monster",	MONST_TRAP,
51.   	"statue",	STATUE_TRAP,
52.   	"bear",		BEAR_TRAP,
53.   	"arrow",	ARROW_TRAP,
54.   	"dart",		DART_TRAP,
55.   	"trapdoor",	TRAPDOOR,
56.   	"teleport",	TELEP_TRAP,
57.   	"pit",		PIT,
58.   	"sleeping gas",	SLP_GAS_TRAP,
59.   	"magic",	MGTRP,
60.   	"board",	SQBRD,
61.   	"web",		WEB,
62.   	"spiked pit",	SPIKED_PIT,
63.   	"level teleport",LEVEL_TELEP,
64.   #ifdef SPELLS
65.   	"anti magic",	ANTI_MAGIC,
66.   #endif
67.   	"rust",		RUST_TRAP
68.   #ifdef POLYSELF
69.   	, "polymorph",	POLY_TRAP
70.   #endif
71.   #ifdef ARMY
72.   	, "land mine",	LANDMINE
73.   #endif
74.     };
75.   
76.   struct {
77.   	char *name;
78.   	int type;
79.   } room_types[SHOPBASE-1] = {
80.   	/* for historical reasons, room types are not contiguous numbers */
81.   	/* (type 1 is skipped) */
82.   	"ordinary",	OROOM,
83.   #ifdef THRONES
84.   	"throne",	COURT,
85.   #endif
86.   	"swamp",	SWAMP,
87.   	"vault",	VAULT,
88.   	"beehive",	BEEHIVE,
89.   	"morgue",	MORGUE,
90.   #ifdef ARMY
91.   	"barracks",	BARRACKS,
92.   #endif
93.   	"zoo",		ZOO,
94.   	"temple",	TEMPLE,
95.   	"shop",		SHOPBASE,
96.   };
97.   
98.   short db_dirs[4] = {
99.   	DB_NORTH,
100.  	DB_EAST,
101.  	DB_SOUTH,
102.  	DB_WEST
103.  };
104.  
105.  #ifdef ALTARS
106.  static altar *tmpaltar[256];
107.  #endif /* ALTARS /**/
108.  static lad *tmplad[256];
109.  static dig *tmpdig[256];
110.  static char *tmpmap[ROWNO];
111.  static region *tmpreg[16];
112.  static door *tmpdoor[256];
113.  static trap *tmptrap[256];
114.  static monster *tmpmonst[256];
115.  static object *tmpobj[256];
116.  static drawbridge *tmpdb[256];
117.  static walk *tmpwalk[256];
118.  static mazepart *tmppart[10];
119.  static room *tmproom[MAXNROFROOMS];
120.  static specialmaze maze;
121.  
122.  static char olist[MAX_REGISTERS], mlist[MAX_REGISTERS];
123.  static struct coord plist[MAX_REGISTERS];
124.  static int n_olist = 0, n_mlist = 0, n_plist = 0;
125.  
126.  unsigned int nreg = 0, ndoor = 0, ntrap = 0, nmons = 0, nobj = 0;
127.  unsigned int ndb = 0, nwalk = 0, npart = 0, ndig = 0, nlad = 0;
128.  #ifdef ALTARS
129.  unsigned int naltar = 0;
130.  #endif /* ALTARS /*/
131.  
132.  unsigned int max_x_map, max_y_map;
133.  
134.  extern int fatal_error;
135.  extern char* fname;
136.  
137.  boolean check_monster_char(), check_object_char();
138.  void scan_map(), store_part(), write_maze();
139.  
140.  
141.  # line 140 "lev_comp.y"
142.  typedef union 
143.  {
144.  	int	i;
145.  	char*	map;
146.  } YYSTYPE;
147.  # define CHAR 257
148.  # define INTEGER 258
149.  # define MAZE_ID 259
150.  # define LEVEL_ID 260
151.  # define GEOMETRY_ID 261
152.  # define OBJECT_ID 262
153.  # define MONSTER_ID 263
154.  # define TRAP_ID 264
155.  # define DOOR_ID 265
156.  # define DRAWBRIDGE_ID 266
157.  # define MAZEWALK_ID 267
158.  # define REGION_ID 268
159.  # define RANDOM_OBJECTS_ID 269
160.  # define RANDOM_MONSTERS_ID 270
161.  # define RANDOM_PLACES_ID 271
162.  # define ALTAR_ID 272
163.  # define LADDER_ID 273
164.  # define NON_DIGGABLE_ID 274
165.  # define ROOM_ID 275
166.  # define DOOR_STATE 276
167.  # define LIGHT_STATE 277
168.  # define DIRECTION 278
169.  # define RANDOM_TYPE 279
170.  # define O_REGISTER 280
171.  # define M_REGISTER 281
172.  # define P_REGISTER 282
173.  # define A_REGISTER 283
174.  # define ALIGNMENT 284
175.  # define LEFT_OR_RIGHT 285
176.  # define CENTER 286
177.  # define TOP_OR_BOT 287
178.  # define ALTAR_TYPE 288
179.  # define UP_OR_DOWN 289
180.  # define STRING 290
181.  # define MAP_ID 291
182.  #define yyclearin yychar = -1
183.  #define yyerrok yyerrflag = 0
184.  extern int yychar;
185.  extern short yyerrflag;
186.  #ifndef YYMAXDEPTH
187.  #define YYMAXDEPTH 150
188.  #endif
189.  YYSTYPE yylval, yyval;
190.  # define YYERRCODE 256
191.  
192.  # line 617 "lev_comp.y"
193.  
194.  
195.  /* 
196.   * Find the type of a room in the table, knowing its name.
197.   */
198.  
199.  int
200.  get_room_type(s)
201.  char *s;
202.  {
203.  	register int i;
204.  	
205.  	for(i=0; i < SHOPBASE -1; i++)
206.  	    if (!strcmp(s, room_types[i].name))
207.  		return room_types[i].type;
208.  	return ERR;
209.  }
210.  
211.  /* 
212.   * Find the type of a trap in the table, knowing its name.
213.   */
214.  
215.  int
216.  get_trap_type(s)
217.  char *s;
218.  {
219.  	register int i;
220.  	
221.  	for(i=0; i < TRAPNUM - 1; i++)
222.  	    if(!strcmp(s,trap_types[i].name))
223.  		return(trap_types[i].type);
224.  	return ERR;
225.  }
226.  
227.  /* 
228.   * Find the index of a monster in the table, knowing its name.
229.   */
230.  
231.  int
232.  get_monster_id(s, c)
233.  char *s;
234.  char c;
235.  {
236.  	register int i;
237.  	
238.  	for(i=0; mons[i].mname[0]; i++)
239.  	    if(!strncmp(s, mons[i].mname, strlen(mons[i].mname))
240.  	       && c == mons[i].mlet)
241.  		return i;
242.  	return ERR;
243.  }
244.  
245.  /* 
246.   * Find the index of an object in the table, knowing its name.
247.   */
248.  
249.  int
250.  get_object_id(s, c)
251.  char *s;
252.  char c;
253.  {
254.  	register int i;
255.  	
256.  	for(i=0; i<=NROFOBJECTS;i++)
257.  	    if(objects[i].oc_name &&
258.  	       !strncmp(s, objects[i].oc_name, strlen(objects[i].oc_name))
259.  	       && c == objects[i].oc_olet)
260.  		return i;
261.  	return ERR;
262.  }
263.  
264.  /* 
265.   * Is the character 'c' a valid monster class ?
266.   */
267.  
268.  boolean
269.  check_monster_char(c)
270.  char c;
271.  {
272.  	register int i;
273.  	
274.  	for(i=0; mons[i].mname[0]; i++)
275.  	    if( c ==  mons[i].mlet)
276.  		return 1;
277.  	return(0);
278.  }
279.  
280.  /* 
281.   * Is the character 'c' a valid object class ?
282.   */
283.  
284.  boolean
285.  check_object_char(c)
286.  char c;
287.  {
288.  	register int i;
289.  	
290.  	for(i=0; i<=NROFOBJECTS;i++)
291.  	    if( c == objects[i].oc_olet)
292.  		return 1;
293.  	return 0;
294.  }
295.  
296.  /* 
297.   * Yep! LEX gives us the map in a raw mode.
298.   * Just analyze it here.
299.   */
300.  
301.  void scan_map(map)
302.  char *map;
303.  {
304.  	register int i, len;
305.  	register char *s1, *s2;
306.  	int max_len = 0;
307.  	int max_hig = 0;
308.  	
309.  	/* First : find the max width of the map */
310.  
311.  	s1 = map;
312.  	while (s1 && *s1) {
313.  		s2 = index(s1, '\n');
314.  		if (s2) {
315.  			if (s2-s1 > max_len)
316.  			    max_len = s2-s1;
317.  			s1 = s2 + 1;
318.  		} else {
319.  			if (strlen(s1) > max_len)
320.  			    max_len = strlen(s1);
321.  			s1 = (char *) 0;
322.  		}
323.  	}
324.  
325.  	/* Then parse it now */
326.  
327.  	while (map && *map) {
328.  		tmpmap[max_hig] = (char *) alloc(max_len);
329.  		s1 = index(map, '\n');
330.  		if (s1) {
331.  			len = s1 - map;
332.  			s1++;
333.  		} else {
334.  			len = strlen(map);
335.  			s1 = map + len;
336.  		}
337.  		for(i=0; i<len; i++)
338.  		    switch(map[i]) {
339.  			  case '-' : tmpmap[max_hig][i] = HWALL; break;
340.  			  case '|' : tmpmap[max_hig][i] = VWALL; break;
341.  			  case '+' : tmpmap[max_hig][i] = DOOR; break;
342.  			  case 'S' : tmpmap[max_hig][i] = SDOOR; break;
343.  			  case '{' : 
344.  #ifdef FOUNTAINS
345.  			      tmpmap[max_hig][i] = FOUNTAIN;
346.  #else
347.  			      tmpmap[max_hig][i] = ROOM;
348.  			      yywarning("Fountains are not allowed in this version!  Ignoring...");
349.  #endif
350.  			      break;
351.  			  case '\\' : 
352.  #ifdef THRONES
353.  			      tmpmap[max_hig][i] = THRONE;
354.  #else
355.  			      tmpmap[max_hig][i] = ROOM;
356.  			      yywarning("Thrones are not allowed in this version!  Ignoring...");
357.  #endif
358.  			      break;
359.  			  case 'K' : 
360.  #ifdef SINKS
361.  			      tmpmap[max_hig][i] = SINK;
362.  #else
363.  			      tmpmap[max_hig][i] = ROOM;
364.  			      yywarning("Sinks are not allowed in this version!  Ignoring...");
365.  #endif
366.  			      break;
367.  			  case '}' : tmpmap[max_hig][i] = MOAT; break;
368.  			  case '#' : tmpmap[max_hig][i] = CORR; break;
369.  			  default  : tmpmap[max_hig][i] = ROOM; break;
370.  		    }
371.  		while(i < max_len)
372.  		    tmpmap[max_hig][i++] = ROOM;
373.  		map = s1;
374.  		max_hig++;
375.  	}
376.  
377.  	/* Memorize boundaries */
378.  
379.  	max_x_map = max_len - 1;
380.  	max_y_map = max_hig - 1;
381.  
382.  	/* Store the map into the mazepart structure */
383.  
384.  	tmppart[npart]->xsize = max_len;
385.  	tmppart[npart]->ysize = max_hig;
386.  	tmppart[npart]->map = (char **) alloc(max_hig*sizeof(char *));
387.  	for(i = 0; i< max_hig; i++)
388.  	    tmppart[npart]->map[i] = tmpmap[i];
389.  }
390.  
391.  /* 
392.   * Here we want to store the maze part we just got.
393.   */
394.  
395.  void
396.  store_part()
397.  {
398.  	register int i;
399.  
400.  	/* Ok, We got the whole part, now we store it. */
401.  	
402.  	/* The Regions */
403.  
404.  	if(tmppart[npart]->nreg = nreg) {
405.  		tmppart[npart]->regions = (region**)alloc(sizeof(region*) * nreg);
406.  		for(i=0;i<nreg;i++)
407.  		    tmppart[npart]->regions[i] = tmpreg[i];
408.  	}
409.  	nreg = 0;
410.  
411.  	/* the doors */
412.  
413.  	if(tmppart[npart]->ndoor = ndoor) {
414.  		tmppart[npart]->doors = (door **)alloc(sizeof(door *) * ndoor);
415.  		for(i=0;i<ndoor;i++)
416.  		    tmppart[npart]->doors[i] = tmpdoor[i];
417.  	}
418.  	ndoor = 0;
419.  
420.  	/* the traps */
421.  
422.  	if(tmppart[npart]->ntraps = ntrap) {
423.  		tmppart[npart]->traps = (trap **)alloc(sizeof(trap*) * ntrap);
424.  		for(i=0;i<ntrap;i++)
425.  		    tmppart[npart]->traps[i] = tmptrap[i];
426.  	}
427.  	ntrap = 0;
428.  
429.  	/* the monsters */
430.  
431.  	if(tmppart[npart]->nmonster = nmons) {
432.  		tmppart[npart]->monsters = (monster**)alloc(sizeof(monster*)*nmons);
433.  		for(i=0;i<nmons;i++)
434.  		    tmppart[npart]->monsters[i] = tmpmonst[i];
435.  	}
436.  	nmons = 0;
437.  
438.  	/* the objects */
439.  
440.  	if(tmppart[npart]->nobjects = nobj) {
441.  		tmppart[npart]->objects = (object**)alloc(sizeof(object*)*nobj);
442.  		for(i=0;i<nobj;i++)
443.  		    tmppart[npart]->objects[i] = tmpobj[i];
444.  	}
445.  	nobj = 0;
446.  
447.  	/* the drawbridges */
448.  
449.  	if(tmppart[npart]->ndrawbridge = ndb) {
450.  		tmppart[npart]->drawbridges = (drawbridge**)alloc(sizeof(drawbridge*)*ndb);
451.  		for(i=0;i<ndb;i++)
452.  		    tmppart[npart]->drawbridges[i] = tmpdb[i];
453.  	}
454.  	ndb = 0;
455.  
456.  	/* The walkmaze directives */
457.  
458.  	if(tmppart[npart]->nwalk = nwalk) {
459.  		tmppart[npart]->walks = (walk**)alloc(sizeof(walk*)*nwalk);
460.  		for(i=0;i<nwalk;i++)
461.  		    tmppart[npart]->walks[i] = tmpwalk[i];
462.  	}
463.  	nwalk = 0;
464.  
465.  	/* The non_diggable directives */
466.  
467.  	if(tmppart[npart]->ndig = ndig) {
468.  		tmppart[npart]->digs = (dig **) alloc(sizeof(dig*) * ndig);
469.  		for(i=0;i<ndig;i++)
470.  		    tmppart[npart]->digs[i] = tmpdig[i];
471.  	}
472.  	ndig = 0;
473.  
474.  	/* The ladders */
475.  
476.  	if(tmppart[npart]->nlad = nlad) {
477.  		tmppart[npart]->lads = (lad **) alloc(sizeof(lad*) * nlad);
478.  		for(i=0;i<nlad;i++)
479.  		    tmppart[npart]->lads[i] = tmplad[i];
480.  	}
481.  	nlad = 0;
482.  #ifdef ALTARS
483.  	/* The altars */
484.  
485.  	if(tmppart[npart]->naltar = naltar) {
486.  		tmppart[npart]->altars = (altar**)alloc(sizeof(altar*) * naltar);
487.  		for(i=0;i<naltar;i++)
488.  		    tmppart[npart]->altars[i] = tmpaltar[i];
489.  	}
490.  	naltar = 0;
491.  #endif /* ALTARS /**/
492.  	npart++;
493.  	n_plist = n_mlist = n_olist = 0;
494.  }
495.  
496.  /* 
497.   * Here we write the structure of the maze in the specified file (fd).
498.   * Also, we have to free the memory allocated via alloc()
499.   */
500.  
501.  void
502.  write_maze(fd, maze)
503.  int fd;
504.  specialmaze *maze;
505.  {
506.  	char c;
507.  	short i,j;
508.  	mazepart *pt;
509.  
510.  	c = 2;
511.  	(void) write(fd, &c, 1);	/* Header for special mazes */
512.  	(void) write(fd, &(maze->numpart), 1);	/* Number of parts */
513.  	for(i=0;i<maze->numpart;i++) {
514.  	    pt = maze->parts[i];
515.  
516.  	    /* First, write the map */
517.  
518.  	    (void) write(fd, &(pt->halign), 1);
519.  	    (void) write(fd, &(pt->valign), 1);
520.  	    (void) write(fd, &(pt->xsize), 1);
521.  	    (void) write(fd, &(pt->ysize), 1);
522.  	    for(j=0;j<pt->ysize;j++) {
523.  		    (void) write(fd, pt->map[j], pt->xsize);
524.  		    free(pt->map[j]);
525.  	    }
526.  	    free(pt->map);
527.  
528.  	    /* The random registers */
529.  	    (void) write(fd, &(pt->nrobjects), 1);
530.  	    if(pt->nrobjects) {
531.  		    (void) write(fd, pt->robjects, pt->nrobjects);
532.  		    free(pt->robjects);
533.  	    }
534.  	    (void) write(fd, &(pt->nloc), 1);
535.  	    if(pt->nloc) {
536.  		(void) write(fd,pt->rloc_x, pt->nloc);
537.  		(void) write(fd,pt->rloc_y, pt->nloc);
538.  		free(pt->rloc_x);
539.  		free(pt->rloc_y);
540.  	    }
541.  	    (void) write(fd,&(pt->nrmonst), 1);
542.  	    if(pt->nrmonst) {
543.  		    (void) write(fd, pt->rmonst, pt->nrmonst);
544.  		    free(pt->rmonst);
545.  	    }
546.  
547.  	    /* subrooms */
548.  	    (void) write(fd, &(pt->nreg), 1);
549.  	    for(j=0;j<pt->nreg;j++) {
550.  		    (void) write(fd,(genericptr_t) pt->regions[j], sizeof(region));
551.  		    free(pt->regions[j]);
552.  	    }
553.  	    if(pt->nreg > 0)
554.  		free(pt->regions);
555.  
556.  	    /* the doors */
557.  	    (void) write(fd,&(pt->ndoor),1);
558.  	    for(j=0;j<pt->ndoor;j++) {
559.  		    (void) write(fd,(genericptr_t) pt->doors[j], sizeof(door));
560.  		    free(pt->doors[j]);
561.  	    }
562.  	    if (pt->ndoor > 0)
563.  		free(pt->doors);
564.  
565.  	    /* The traps */
566.  	    (void) write(fd,&(pt->ntraps), 1);
567.  	    for(j=0;j<pt->ntraps;j++) {
568.  		    (void) write(fd,(genericptr_t) pt->traps[j], sizeof(trap));
569.  		    free(pt->traps[j]);
570.  	    }
571.  	    if (pt->ntraps)
572.  		free(pt->traps);
573.  
574.  	    /* The monsters */
575.  	    (void) write(fd, &(pt->nmonster), 1);
576.  	    for(j=0;j<pt->nmonster;j++) {
577.  		    (void) write(fd,(genericptr_t) pt->monsters[j], sizeof(monster));
578.  		    free(pt->monsters[j]);
579.  	    }
580.  	    if (pt->nmonster > 0)
581.  		free(pt->monsters);
582.  
583.  	    /* The objects */
584.  	    (void) write(fd, &(pt->nobjects), 1);
585.  	    for(j=0;j<pt->nobjects;j++) {
586.  		    (void) write(fd,(genericptr_t) pt->objects[j], sizeof(object));
587.  		    free(pt->objects[j]);
588.  	    }
589.  	    if(pt->nobjects > 0)
590.  		free(pt->objects);
591.  
592.  	    /* The drawbridges */
593.  	    (void) write(fd, &(pt->ndrawbridge),1);
594.  	    for(j=0;j<pt->ndrawbridge;j++) {
595.  		    (void) write(fd,(genericptr_t) pt->drawbridges[j], sizeof(drawbridge));
596.  		    free(pt->drawbridges[j]);
597.  	    }
598.  	    if(pt->ndrawbridge > 0)
599.  		free(pt->drawbridges);
600.  
601.  	    /* The mazewalk directives */
602.  	    (void) write(fd, &(pt->nwalk), 1);
603.  	    for(j=0; j<pt->nwalk; j++) {
604.  		    (void) write(fd,(genericptr_t) pt->walks[j], sizeof(walk));
605.  		    free(pt->walks[j]);
606.  	    }
607.  	    if (pt->nwalk > 0)
608.  		free(pt->walks);
609.  
610.  	    /* The non_diggable directives */
611.  	    (void) write(fd, &(pt->ndig), 1);
612.  	    for(j=0;j<pt->ndig;j++) {
613.  		    (void) write(fd,(genericptr_t) pt->digs[j], sizeof(dig));
614.  		    free(pt->digs[j]);
615.  	    }
616.  	    if (pt->ndig > 0)
617.  		free(pt->digs);
618.  
619.  	    /* The ladders */
620.  	    (void) write(fd, &(pt->nlad), 1);
621.  	    for(j=0;j<pt->nlad;j++) {
622.  		    (void) write(fd,(genericptr_t) pt->lads[j], sizeof(lad));
623.  		    free(pt->lads[j]);
624.  	    }
625.  	    if (pt->nlad > 0)
626.  		free(pt->lads);
627.  #ifdef ALTARS
628.  	    /* The altars */
629.  	    (void) write(fd, &(pt->naltar), 1);
630.  	    for(j=0;j<pt->naltar;j++) {
631.  		    (void) write(fd,(genericptr_t) pt->altars[j], sizeof(altar));
632.  		    free(pt->altars[j]);
633.  	    }
634.  	    if (pt->naltar > 0)
635.  		free(pt->altars);
636.  #endif /* ALTARS /**/
637.  	    free(pt);
638.  	}
639.  }
640.  short yyexca[] ={
641.  -1, 1,
642.  	0, -1,
643.  	-2, 0,
644.  	};
645.  # define YYNPROD 86
646.  # define YYLAST 251
647.  short yyact[]={
648.  
649.   164, 130, 126,  91,  16,  19, 168, 146,  69,  72,
650.   145,  19,  19,  19,  19, 167,  75,  74,  26,  27,
651.   143, 137,  12, 138, 144, 141,  65,  87, 134,   6,
652.    88,  78, 173,  80,  40,  39,  42,  41,  43,  46,
653.    44, 170, 169, 155,  45,  47,  48, 147,  83,  85,
654.    22,  24,  23, 135, 131, 127, 116, 105,  72,  65,
655.    18,  92,  71,  86, 171, 153,  67,  93, 151, 149,
656.   157,  64, 114, 110, 108,  97,  62,  61,  60,  59,
657.    58,  57,  56,  55,  54,  53,  51,  50,  49,  17,
658.    13, 172, 165, 156, 154, 152, 150, 148, 139, 122,
659.   119, 118, 117, 115, 113, 112, 111, 109, 107, 106,
660.   104, 103,  52, 174, 158,  69,  77,  90,  68,  98,
661.     9,  99, 100, 101,   3, 142,  82,   7,  94,  14,
662.    84,  79, 166, 140, 162, 136,  89,  81, 102,  76,
663.    38,  37,  36,  35,  34,  33,  32,  31,  30,  29,
664.    28,  70,  66,  63,  21,  73,  25,  11,  20,  15,
665.    10,   8,   4,   2,   1, 128, 124,   5, 125, 123,
666.   129, 121,  68, 132, 133, 120,   0,   0,   0,   0,
667.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
668.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
669.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
670.   159,   0, 160,   0,   0, 163, 161,   0,   0,   0,
671.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
672.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
673.     0,   0,   0,   0,   0,   0,   0,  95,   0,   0,
674.    96 };
675.  short yypact[]={
676.  
677.  -230,-1000,-230,-1000,-1000,-239,  32,-1000,-239,-1000,
678.  -1000,-287,  31,-285,-1000,-219,-1000,-267,-1000,-1000,
679.  -228,-1000,  30,  29,  28,  68,-1000,-1000,-1000,-1000,
680.  -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,  27,
681.    26,  25,  24,  23,  22,  21,  20,  19,  18,-198,
682.    75,-199,-270,-248,-231,-249,-276, -32,  79, -32,
683.   -32, -32,  79,  67,-1000,-1000,  66,-1000,-1000,-201,
684.    65,-1000,-1000,-1000,-1000,-1000,  64,-1000,-1000,-1000,
685.   -17,  63,-1000,-1000,-1000, -18,  62,-1000,-1000,  61,
686.  -1000,-1000,  60,-1000,-1000,-1000, -19,  59,-202,  58,
687.    57,  56,-1000,-198,  75,  55,-199,-277,-203,-278,
688.  -204, -32, -32,-250,-205,-256,  54,-259,-268,-282,
689.  -1000,-1000,-211,-1000,  53,-1000,-1000, -24,  52,-1000,
690.  -1000, -25,-1000,-1000,  51, -28,  50,-1000,-1000,-215,
691.    49,-1000,-1000,-1000, -21,-1000,-1000,  73, -32,-1000,
692.   -32,-1000,-249,-1000,-279,  48,-273,-216,-1000,-1000,
693.  -1000,-1000,-1000,-1000,-1000,-217,-1000,-1000,-1000, -29,
694.    47,-1000,-226,  72,-1000 };
695.  short yypgo[]={
696.  
697.     0,  60, 167, 166, 165, 164, 163, 124, 162, 161,
698.   120, 160, 159, 158, 157, 156, 155, 154, 153, 152,
699.   151,  71,  62,  66, 150, 149, 148, 147, 146, 145,
700.   144, 143, 142, 141, 140, 139,  61, 137,  63, 136,
701.    75, 135, 134, 133, 132, 131, 130,  67, 128, 125 };
702.  short yyr1[]={
703.  
704.     0,   5,   5,   6,   6,   7,   8,   2,   9,   9,
705.    10,  11,  14,  15,  15,  16,  16,  12,  12,  17,
706.    17,  17,  18,  18,  20,  20,  19,  19,  13,  13,
707.    24,  24,  24,  24,  24,  24,  24,  24,  24,  24,
708.    25,  26,  27,  28,  29,  32,  33,  34,  30,  31,
709.    35,  35,  35,  37,  37,  37,   3,   3,   4,   4,
710.    39,  39,  42,  42,  36,  36,  36,  38,  38,  41,
711.    41,  43,  43,  43,  44,  44,  48,  46,  45,  49,
712.    23,  22,  21,   1,  47,  40 };
713.  short yyr2[]={
714.  
715.     0,   0,   1,   1,   2,   1,   2,   3,   1,   2,
716.     3,   2,   5,   1,   1,   1,   1,   0,   2,   3,
717.     3,   3,   1,   3,   1,   3,   1,   3,   0,   2,
718.     1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
719.     7,   7,   5,   5,   7,   5,   5,   3,   7,   7,
720.     1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
721.     1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
722.     1,   1,   1,   1,   1,   1,   4,   4,   4,   4,
723.     1,   1,   1,   1,   5,   9 };
724.  short yychk[]={
725.  
726.  -1000,  -5,  -6,  -7,  -8,  -2, 259,  -7,  -9, -10,
727.   -11, -14, 261,  58, -10, -12, 291,  58,  -1, 290,
728.   -13, -17, 269, 271, 270, -15, 285, 286, -24, -25,
729.   -26, -27, -28, -29, -30, -31, -32, -33, -34, 263,
730.   262, 265, 264, 266, 268, 272, 267, 273, 274,  58,
731.    58,  58,  44,  58,  58,  58,  58,  58,  58,  58,
732.    58,  58,  58, -18, -21, 257, -19, -23, -47,  40,
733.   -20, -22, 257, -16, 287, 286, -35, -22, 279, -45,
734.   281, -37, -21, 279, -46, 280, -38, 276, 279, -39,
735.    -1, 279, -36, -47, -48, 279, 282, -40,  40, -36,
736.   -36, -36, -40,  44,  44, 258,  44,  44,  91,  44,
737.    91,  44,  44,  44,  91,  44, 258,  44,  44,  44,
738.   -21, -23,  44, -22,  -3,  -1, 279, 258,  -4,  -1,
739.   279, 258, -36, -36, 278, 258, -41, 277, 279,  44,
740.   -43, 284, -49, 279, 283, 278, 289, 258,  44,  93,
741.    44,  93,  44,  93,  44, 258,  44,  91,  41, -36,
742.   -36, -38, -42,  -1, 279,  44, -44, 288, 279, 258,
743.   258,  93,  44, 258,  41 };
744.  short yydef[]={
745.  
746.     1,  -2,   2,   3,   5,   0,   0,   4,   6,   8,
747.    17,   0,   0,   0,   9,  28,  11,   0,   7,  83,
748.    10,  18,   0,   0,   0,   0,  13,  14,  29,  30,
749.    31,  32,  33,  34,  35,  36,  37,  38,  39,   0,
750.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
751.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
752.     0,   0,   0,  19,  22,  82,  20,  26,  80,   0,
753.    21,  24,  81,  12,  15,  16,   0,  50,  51,  52,
754.     0,   0,  53,  54,  55,   0,   0,  67,  68,   0,
755.    60,  61,   0,  64,  65,  66,   0,   0,   0,   0,
756.     0,   0,  47,   0,   0,   0,   0,   0,   0,   0,
757.     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
758.    23,  27,   0,  25,   0,  56,  57,   0,   0,  58,
759.    59,   0,  42,  43,   0,   0,   0,  69,  70,   0,
760.     0,  71,  72,  73,   0,  45,  46,   0,   0,  78,
761.     0,  77,   0,  76,   0,   0,   0,   0,  84,  40,
762.    41,  44,  48,  62,  63,   0,  49,  74,  75,   0,
763.     0,  79,   0,   0,  85 };
764.  #ifndef lint
765.  static char yaccpar_sccsid[] = "@(#)yaccpar	4.1	(Berkeley)	2/11/83";
766.  #endif not lint
767.  
768.  #
769.  # define YYFLAG -1000
770.  # define YYERROR goto yyerrlab
771.  # define YYACCEPT return(0)
772.  # define YYABORT return(1)
773.  
774.  /*	parser for yacc output	*/
775.  
776.  #ifdef YYDEBUG
777.  int yydebug = 0; /* 1 for debugging */
778.  #endif
779.  YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
780.  int yychar = -1; /* current input token number */
781.  int yynerrs = 0;  /* number of errors */
782.  short yyerrflag = 0;  /* error recovery flag */
783.  
784.  yyparse() {
785.  
786.  	short yys[YYMAXDEPTH];
787.  	short yyj, yym;
788.  	register YYSTYPE *yypvt;
789.  	register short yystate, *yyps, yyn;
790.  	register YYSTYPE *yypv;
791.  	register short *yyxi;
792.  
793.  	yystate = 0;
794.  	yychar = -1;
795.  	yynerrs = 0;
796.  	yyerrflag = 0;
797.  	yyps= &yys[-1];
798.  	yypv= &yyv[-1];
799.  
800.   yystack:    /* put a state and value onto the stack */
801.  
802.  #ifdef YYDEBUG
803.  	if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
804.  #endif
805.  		if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
806.  		*yyps = yystate;
807.  		++yypv;
808.  		*yypv = yyval;
809.  
810.   yynewstate:
811.  
812.  	yyn = yypact[yystate];
813.  
814.  	if( yyn<= YYFLAG ) goto yydefault; /* simple state */
815.  
816.  	if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
817.  	if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
818.  
819.  	if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
820.  		yychar = -1;
821.  		yyval = yylval;
822.  		yystate = yyn;
823.  		if( yyerrflag > 0 ) --yyerrflag;
824.  		goto yystack;
825.  		}
826.  
827.   yydefault:
828.  	/* default state action */
829.  
830.  	if( (yyn=yydef[yystate]) == -2 ) {
831.  		if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
832.  		/* look through exception table */
833.  
834.  		for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
835.  
836.  		while( *(yyxi+=2) >= 0 ){
837.  			if( *yyxi == yychar ) break;
838.  			}
839.  		if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
840.  		}
841.  
842.  	if( yyn == 0 ){ /* error */
843.  		/* error ... attempt to resume parsing */
844.  
845.  		switch( yyerrflag ){
846.  
847.  		case 0:   /* brand new error */
848.  
849.  			yyerror( "syntax error" );
850.  		yyerrlab:
851.  			++yynerrs;
852.  
853.  		case 1:
854.  		case 2: /* incompletely recovered error ... try again */
855.  
856.  			yyerrflag = 3;
857.  
858.  			/* find a state where "error" is a legal shift action */
859.  
860.  			while ( yyps >= yys ) {
861.  			   yyn = yypact[*yyps] + YYERRCODE;
862.  			   if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
863.  			      yystate = yyact[yyn];  /* simulate a shift of "error" */
864.  			      goto yystack;
865.  			      }
866.  			   yyn = yypact[*yyps];
867.  
868.  			   /* the current yyps has no shift onn "error", pop stack */
869.  
870.  #ifdef YYDEBUG
871.  			   if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
872.  #endif
873.  			   --yyps;
874.  			   --yypv;
875.  			   }
876.  
877.  			/* there is no state on the stack with an error shift ... abort */
878.  
879.  	yyabort:
880.  			return(1);
881.  
882.  
883.  		case 3:  /* no shift yet; clobber input char */
884.  
885.  #ifdef YYDEBUG
886.  			if( yydebug ) printf( "error recovery discards char %d\n", yychar );
887.  #endif
888.  
889.  			if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
890.  			yychar = -1;
891.  			goto yynewstate;   /* try again in the same state */
892.  
893.  			}
894.  
895.  		}
896.  
897.  	/* reduction by production yyn */
898.  
899.  #ifdef YYDEBUG
900.  		if( yydebug ) printf("reduce %d\n",yyn);
901.  #endif
902.  		yyps -= yyr2[yyn];
903.  		yypvt = yypv;
904.  		yypv -= yyr2[yyn];
905.  		yyval = yypv[1];
906.  		yym=yyn;
907.  			/* consult goto table to find next state */
908.  		yyn = yyr1[yyn];
909.  		yyj = yypgo[yyn] + *yyps + 1;
910.  		if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
911.  		switch(yym){
912.  			
913.  case 6:
914.  # line 170 "lev_comp.y"
915.  {
916.  			  int fout, i;
917.  
918.  			  if (fatal_error > 0)
919.  				  fprintf(stderr,"%s : %d errors detected. No output created!\n", fname, fatal_error);
920.  			  else {
921.  				  fout = open(yypvt[-1].map, O_WRONLY | O_CREAT
922.  #ifdef MSDOS
923.  					      | O_BINARY
924.  #endif /* MSDOS */
925.  					      , 0644);
926.  				  if (fout < 0) {
927.  					  yyerror("Can't open output file!!");
928.  					  exit(1);
929.  				  }
930.  				  maze.numpart = npart;
931.  				  maze.parts = (mazepart**) alloc(sizeof(mazepart*)*npart);
932.  				  for(i=0;i<npart;i++)
933.  				      maze.parts[i] = tmppart[i];
934.  				  write_maze(fout, &maze);
935.  				  (void) close(fout);
936.  				  npart = 0;
937.  			  }
938.  		  } break;
939.  case 7:
940.  # line 196 "lev_comp.y"
941.  {
942.  			  yyval.map = yypvt[-0].map;
943.  		  } break;
944.  case 10:
945.  # line 204 "lev_comp.y"
946.  {
947.  			store_part();
948.  		  } break;
949.  case 11:
950.  # line 209 "lev_comp.y"
951.  {
952.  			tmppart[npart] = (mazepart *) alloc(sizeof(mazepart));
953.  			tmppart[npart]->halign = yypvt[-1].i % 10;
954.  			tmppart[npart]->valign = yypvt[-1].i / 10;
955.  			tmppart[npart]->nrobjects = 0;
956.  			tmppart[npart]->nloc = 0;
957.  			tmppart[npart]->nrmonst = 0;
958.  			scan_map(yypvt[-0].map);
959.  		  } break;
960.  case 12:
961.  # line 220 "lev_comp.y"
962.  {
963.  			  yyval.i = yypvt[-2].i + ( yypvt[-0].i * 10 );
964.  		  } break;
965.  case 19:
966.  # line 234 "lev_comp.y"
967.  {
968.  			  if (tmppart[npart]->nrobjects)
969.  			      yyerror("Object registers already initialized!");
970.  			  else {
971.  				  tmppart[npart]->robjects = (char *) alloc(n_olist);
972.  				  memcpy(tmppart[npart]->robjects, olist, n_olist);
973.  				  tmppart[npart]->nrobjects = n_olist;
974.  			  }
975.  		  } break;
976.  case 20:
977.  # line 244 "lev_comp.y"
978.  {
979.  			  if (tmppart[npart]->nloc)
980.  			      yyerror("Location registers already initialized!");
981.  			  else {
982.  				  register int i;
983.  				  tmppart[npart]->rloc_x = (char *) alloc(n_plist);
984.  				  tmppart[npart]->rloc_y = (char *) alloc(n_plist);
985.  				  for(i=0;i<n_plist;i++) {
986.  					  tmppart[npart]->rloc_x[i] = plist[i].x;
987.  					  tmppart[npart]->rloc_y[i] = plist[i].y;
988.  				  }
989.  				  tmppart[npart]->nloc = n_plist;
990.  			  }
991.  		  } break;
992.  case 21:
993.  # line 259 "lev_comp.y"
994.  {
995.  			  if (tmppart[npart]->nrmonst)
996.  			      yyerror("Monster registers already initialized!");
997.  			  else {
998.  				  tmppart[npart]->rmonst = (char *) alloc(n_mlist);
999.  				  memcpy(tmppart[npart]->rmonst, mlist, n_mlist);
1000. 				  tmppart[npart]->nrmonst = n_mlist;
1001. 			  }
1002. 		  } break;
1003. case 22:
1004. # line 270 "lev_comp.y"
1005. {
1006. 			  if (n_olist < MAX_REGISTERS)
1007. 			      olist[n_olist++] = yypvt[-0].i;
1008. 			  else
1009. 			      yyerror("Object list too long!");
1010. 		  } break;
1011. case 23:
1012. # line 277 "lev_comp.y"
1013. {
1014. 			  if (n_olist < MAX_REGISTERS)
1015. 			      olist[n_olist++] = yypvt[-0].i;
1016. 			  else
1017. 			      yyerror("Object list too long!");
1018. 		  } break;
1019. case 24:
1020. # line 285 "lev_comp.y"
1021. {
1022. 			  if (n_mlist < MAX_REGISTERS)
1023. 			      mlist[n_mlist++] = yypvt[-0].i;
1024. 			  else
1025. 			      yyerror("Monster list too long!");
1026. 		  } break;
1027. case 25:
1028. # line 292 "lev_comp.y"
1029. {
1030. 			  if (n_mlist < MAX_REGISTERS)
1031. 			      mlist[n_mlist++] = yypvt[-0].i;
1032. 			  else
1033. 			      yyerror("Monster list too long!");
1034. 		  } break;
1035. case 26:
1036. # line 300 "lev_comp.y"
1037. {
1038. 			  if (n_plist < MAX_REGISTERS)
1039. 			      plist[n_plist++] = current_coord;
1040. 			  else
1041. 			      yyerror("Location list too long!");
1042. 		  } break;
1043. case 27:
1044. # line 307 "lev_comp.y"
1045. {
1046. 			  if (n_plist < MAX_REGISTERS)
1047. 			      plist[n_plist++] = current_coord;
1048. 			  else
1049. 			      yyerror("Location list too long!");
1050. 		  } break;
1051. case 40:
1052. # line 329 "lev_comp.y"
1053. {
1054. 			  int token;
1055. 
1056. 			  tmpmonst[nmons] = (monster *) alloc(sizeof(monster));
1057. 			  tmpmonst[nmons]->x = current_coord.x;
1058. 			  tmpmonst[nmons]->y = current_coord.y;
1059. 			  tmpmonst[nmons]->class = yypvt[-4].i;
1060. 			  if (!yypvt[-2].map)
1061. 			      tmpmonst[nmons]->id = -1;
1062. 			  else {
1063. 				  token = get_monster_id(yypvt[-2].map, (char) yypvt[-4].i);  
1064. 				  if (token == ERR) {
1065. 				      yywarning("Illegal monster name!  Making random monster.");
1066. 				      tmpmonst[nmons]->id = -1;
1067. 				  } else
1068. 				      tmpmonst[nmons]->id = token;
1069. 			  }
1070. 			  nmons++;
1071. 		  } break;
1072. case 41:
1073. # line 350 "lev_comp.y"
1074. {
1075. 			  int token;
1076. 
1077. 			  tmpobj[nobj] = (object *) alloc(sizeof(object));
1078. 			  tmpobj[nobj]->x = current_coord.x;
1079. 			  tmpobj[nobj]->y = current_coord.y;
1080. 			  tmpobj[nobj]->class = yypvt[-4].i;
1081. 			  if (!yypvt[-2].map)
1082. 			      tmpobj[nobj]->id = -1;
1083. 			  else {
1084. 				  token = get_object_id(yypvt[-2].map, (char) yypvt[-4].i);
1085. 				  if (token == ERR) {
1086. 				      yywarning("Illegal object name!  Making random object.");
1087. 				      tmpobj[nobj]->id = -1;
1088. 				  } else
1089. 				      tmpobj[nobj]->id = token;
1090. 			  }
1091. 			  nobj++;
1092. 		  } break;
1093. case 42:
1094. # line 371 "lev_comp.y"
1095. {
1096. 			tmpdoor[ndoor] = (door *) alloc(sizeof(door));
1097. 			tmpdoor[ndoor]->x = current_coord.x;
1098. 			tmpdoor[ndoor]->y = current_coord.y;
1099. 			tmpdoor[ndoor]->mask = yypvt[-2].i;
1100. 			ndoor++;
1101. 		  } break;
1102. case 43:
1103. # line 380 "lev_comp.y"
1104. {
1105. 			tmptrap[ntrap] = (trap *) alloc(sizeof(trap));
1106. 			tmptrap[ntrap]->x = current_coord.x;
1107. 			tmptrap[ntrap]->y = current_coord.y;
1108. 			tmptrap[ntrap]->type = yypvt[-2].i;
1109. 			ntrap++;
1110. 		  } break;
1111. case 44:
1112. # line 389 "lev_comp.y"
1113. {
1114. 			tmpdb[ndb] = (drawbridge *) alloc(sizeof(drawbridge));
1115. 			tmpdb[ndb]->x = current_coord.x;
1116. 			tmpdb[ndb]->y = current_coord.y;
1117. 			tmpdb[ndb]->dir = db_dirs[yypvt[-2].i];
1118. 			if ( yypvt[-0].i == D_ISOPEN )
1119. 			  tmpdb[ndb]->open = 1;
1120. 			else if ( yypvt[-0].i == D_CLOSED )
1121. 			  tmpdb[ndb]->open = 0;
1122. 			else
1123. 			  yyerror("A drawbridge can only be open or closed!");
1124. 			ndb++;
1125. 		   } break;
1126. case 45:
1127. # line 404 "lev_comp.y"
1128. {
1129. 			tmpwalk[nwalk] = (walk *) alloc(sizeof(walk));
1130. 			tmpwalk[nwalk]->x = current_coord.x;
1131. 			tmpwalk[nwalk]->y = current_coord.y;
1132. 			tmpwalk[nwalk]->dir = yypvt[-0].i;
1133. 			nwalk++;
1134. 		  } break;
1135. case 46:
1136. # line 413 "lev_comp.y"
1137. {
1138. 			tmplad[nlad] = (lad *) alloc(sizeof(lad));
1139. 			tmplad[nlad]->x = current_coord.x;
1140. 			tmplad[nlad]->y = current_coord.y;
1141. 			tmplad[nlad]->up = yypvt[-0].i;
1142. 			nlad++;
1143. 		  } break;
1144. case 47:
1145. # line 422 "lev_comp.y"
1146. {
1147. 			tmpdig[ndig] = (dig *) alloc(sizeof(dig));
1148. 			tmpdig[ndig]->x1 = current_region.x1;
1149. 			tmpdig[ndig]->y1 = current_region.y1;
1150. 			tmpdig[ndig]->x2 = current_region.x2;
1151. 			tmpdig[ndig]->y2 = current_region.y2;
1152. 			ndig++;
1153. 		  } break;
1154. case 48:
1155. # line 432 "lev_comp.y"
1156. {
1157. 			tmpreg[nreg] = (region *) alloc(sizeof(region));
1158. 			tmpreg[nreg]->x1 = current_region.x1;
1159. 			tmpreg[nreg]->y1 = current_region.y1;
1160. 			tmpreg[nreg]->x2 = current_region.x2;
1161. 			tmpreg[nreg]->y2 = current_region.y2;
1162. 			tmpreg[nreg]->rlit = yypvt[-2].i;
1163. 			tmpreg[nreg]->rtype = yypvt[-0].i;
1164. 			nreg++;
1165. 		  } break;
1166. case 49:
1167. # line 444 "lev_comp.y"
1168. {
1169. #ifndef ALTARS
1170. 			yywarning("Altars are not allowed in this version!  Ignoring...");
1171. #else
1172. 			tmpaltar[naltar] = (altar *) alloc(sizeof(altar));
1173. 			tmpaltar[naltar]->x = current_coord.x;
1174. 			tmpaltar[naltar]->y = current_coord.y;
1175. 			tmpaltar[naltar]->align = yypvt[-2].i;
1176. 			tmpaltar[naltar]->shrine = yypvt[-0].i;
1177. 			naltar++;
1178. #endif /* ALTARS */
1179. 		  } break;
1180. case 51:
1181. # line 459 "lev_comp.y"
1182. {
1183. 			  yyval.i = - MAX_REGISTERS - 1;
1184. 		  } break;
1185. case 54:
1186. # line 466 "lev_comp.y"
1187. {
1188. 			  yyval.i = - MAX_REGISTERS - 1;
1189. 		  } break;
1190. case 57:
1191. # line 473 "lev_comp.y"
1192. {
1193. 			  yyval.map = (char *) 0;
1194. 		  } break;
1195. case 59:
1196. # line 479 "lev_comp.y"
1197. {
1198. 			  yyval.map = (char *) 0;
1199. 		  } break;
1200. case 60:
1201. # line 484 "lev_comp.y"
1202. {
1203. 		  	int token = get_trap_type(yypvt[-0].map);
1204. 			if (token == ERR)
1205. 				yyerror("unknown trap type!");
1206. 			yyval.i = token;
1207. 		  } break;
1208. case 62:
1209. # line 493 "lev_comp.y"
1210. {
1211. 			int token = get_room_type(yypvt[-0].map);
1212. 			if (token == ERR) {
1213. 				yywarning("Unknown room type!  Making ordinary room...");
1214. 				yyval.i = OROOM;
1215. 			} else
1216. 				yyval.i = token;
1217. 		  } break;
1218. case 66:
1219. # line 506 "lev_comp.y"
1220. {
1221. 			  current_coord.x = current_coord.y = -MAX_REGISTERS-1;
1222. 		  } break;
1223. case 73:
1224. # line 519 "lev_comp.y"
1225. {
1226. 			  yyval.i = - MAX_REGISTERS - 1;
1227. 		  } break;
1228. case 76:
1229. # line 527 "lev_comp.y"
1230. {
1231. 			if ( yypvt[-1].i >= MAX_REGISTERS ) {
1232. 				yyerror("Register Index overflow!");
1233. 			} else {
1234. 				current_coord.x = current_coord.y = - yypvt[-1].i - 1;
1235. 			}
1236. 		  } break;
1237. case 77:
1238. # line 536 "lev_comp.y"
1239. {
1240. 			if ( yypvt[-1].i >= MAX_REGISTERS ) {
1241. 				yyerror("Register Index overflow!");
1242. 			} else {
1243. 				yyval.i = - yypvt[-1].i - 1;
1244. 			}
1245. 		  } break;
1246. case 78:
1247. # line 545 "lev_comp.y"
1248. {
1249. 			if ( yypvt[-1].i >= MAX_REGISTERS ) {
1250. 				yyerror("Register Index overflow!");
1251. 			} else {
1252. 				yyval.i = - yypvt[-1].i - 1;
1253. 			}
1254. 		  } break;
1255. case 79:
1256. # line 554 "lev_comp.y"
1257. {
1258. 			if ( yypvt[-1].i >= 3 ) {
1259. 				yyerror("Register Index overflow!");
1260. 			} else {
1261. 				yyval.i = - yypvt[-1].i - 1;
1262. 			}
1263. 		  } break;
1264. case 81:
1265. # line 565 "lev_comp.y"
1266. {
1267. 			if (check_monster_char(yypvt[-0].i))
1268. 				yyval.i = yypvt[-0].i ;
1269. 			else {
1270. 				yyerror("unknown monster class!");
1271. 				yyval.i = ERR;
1272. 			}
1273. 		  } break;
1274. case 82:
1275. # line 575 "lev_comp.y"
1276. {
1277. 			char c;
1278. 
1279. 			c = yypvt[-0].i;
1280. #ifndef SPELLS
1281. 			if ( c == '+') {
1282. 				c = '?';
1283. 				yywarning("Spellbooks are not allowed in this version! (converted into scroll)");
1284. 			}
1285. #endif
1286. 			if (check_object_char(c))
1287. 				yyval.i = c;
1288. 			else {
1289. 				yyerror("Unknown char class!");
1290. 				yyval.i = ERR;
1291. 			}
1292. 		  } break;
1293. case 84:
1294. # line 595 "lev_comp.y"
1295. {
1296. 		        if (yypvt[-3].i < 0 || yypvt[-3].i > max_x_map ||
1297. 			    yypvt[-1].i < 0 || yypvt[-1].i > max_y_map)
1298. 			    yyerror("Coordinates out of map range!");
1299. 			current_coord.x = yypvt[-3].i;
1300. 			current_coord.y = yypvt[-1].i;
1301. 		  } break;
1302. case 85:
1303. # line 604 "lev_comp.y"
1304. {
1305. 		        if (yypvt[-7].i < 0 || yypvt[-7].i > max_x_map ||
1306. 			    yypvt[-5].i < 0 || yypvt[-5].i > max_y_map ||
1307. 			    yypvt[-3].i < 0 || yypvt[-3].i > max_x_map ||
1308. 			    yypvt[-1].i < 0 || yypvt[-1].i > max_y_map)
1309. 			    yyerror("Region out of map range!");
1310. 			current_region.x1 = yypvt[-7].i;
1311. 			current_region.y1 = yypvt[-5].i;
1312. 			current_region.x2 = yypvt[-3].i;
1313. 			current_region.y2 = yypvt[-1].i;
1314. 		  } break; 
1315. 		}
1316. 		goto yystack;  /* stack new state and value */
1317. 
1318. 	}