本家#478
Don't define special levels with MAZE anymore; just use LEVEL, and add "mazeleve
l" to level FLAGS.
LEVEL also takes now an optional parameter, just like MAZE used to, which is a f
ill character
used to fill the level with a grid, so you can use MAZEWALK on it.
@@ -24,11 +24,8 @@ | ||
24 | 24 | #define ARBOREAL 16 |
25 | 25 | #define NOFLIPX 32 |
26 | 26 | #define NOFLIPY 64 |
27 | +#define MAZELEVEL 128 | |
27 | 28 | |
28 | - /* special level types */ | |
29 | -#define SP_LEV_ROOMS 1 | |
30 | -#define SP_LEV_MAZE 2 | |
31 | - | |
32 | 29 | /* max. # of random registers */ |
33 | 30 | #define MAX_REGISTERS 10 |
34 | 31 |
@@ -115,7 +112,6 @@ | ||
115 | 112 | boolean smoothed, joined; |
116 | 113 | xchar lit, walled; |
117 | 114 | long flags; |
118 | - char levtyp; /* SP_LEV_xxx */ | |
119 | 115 | schar filling; |
120 | 116 | long n_opcodes; |
121 | 117 | } lev_init; |
@@ -2687,7 +2687,7 @@ | ||
2687 | 2687 | |
2688 | 2688 | (void) memset((genericptr_t)&SpLev_Map[0][0], 0, sizeof SpLev_Map); |
2689 | 2689 | |
2690 | - level.flags.is_maze_lev = lvl->init_lev.levtyp == SP_LEV_MAZE; | |
2690 | + level.flags.is_maze_lev = 0; | |
2691 | 2691 | |
2692 | 2692 | if (lvl->init_lev.init_present) { |
2693 | 2693 | if (lvl->init_lev.lit < 0) lvl->init_lev.lit = rn2(2); |
@@ -2719,6 +2719,7 @@ | ||
2719 | 2719 | if (lvl->init_lev.flags & ARBOREAL) level.flags.arboreal = 1; |
2720 | 2720 | if (lvl->init_lev.flags & NOFLIPX) allow_flips &= ~1; |
2721 | 2721 | if (lvl->init_lev.flags & NOFLIPY) allow_flips &= ~2; |
2722 | + if (lvl->init_lev.flags & MAZELEVEL) level.flags.is_maze_lev = 1; | |
2722 | 2723 | |
2723 | 2724 | while (n_opcode < lvl->init_lev.n_opcodes && !exit_script) { |
2724 | 2725 | int opcode = lvl->opcodes[n_opcode].opcode; |
@@ -160,26 +160,25 @@ | ||
160 | 160 | } |
161 | 161 | ; |
162 | 162 | |
163 | -level_def : MAZE_ID ':' string ',' filling | |
163 | +level_def : LEVEL_ID ':' string opt_filling | |
164 | 164 | { |
165 | - splev.init_lev.filling = (schar) $5; | |
166 | - splev.init_lev.levtyp = SP_LEV_MAZE; | |
167 | 165 | if (index($3, '.')) |
168 | 166 | yyerror("Invalid dot ('.') in level name."); |
169 | 167 | if ((int) strlen($3) > 8) |
170 | 168 | yyerror("Level names limited to 8 characters."); |
169 | + n_plist = n_mlist = n_olist = 0; | |
171 | 170 | $$ = $3; |
172 | - n_plist = n_mlist = n_olist = 0; | |
173 | 171 | } |
174 | - | LEVEL_ID ':' string | |
172 | + ; | |
173 | + | |
174 | +opt_filling : /* nothing */ | |
175 | 175 | { |
176 | - splev.init_lev.levtyp = SP_LEV_ROOMS; | |
177 | - if (index($3, '.')) | |
178 | - yyerror("Invalid dot ('.') in level name."); | |
179 | - if ((int) strlen($3) > 8) | |
180 | - yyerror("Level names limited to 8 characters."); | |
181 | - $$ = $3; | |
176 | + /* really, nothing */ | |
182 | 177 | } |
178 | + | ',' filling | |
179 | + { | |
180 | + splev.init_lev.filling = (schar) $2; | |
181 | + } | |
183 | 182 | ; |
184 | 183 | |
185 | 184 | lev_init : /* nothing */ |
@@ -213,6 +213,7 @@ | ||
213 | 213 | noflipx { yylval.i=NOFLIPX; return FLAG_TYPE; } |
214 | 214 | noflipy { yylval.i=NOFLIPY; return FLAG_TYPE; } |
215 | 215 | noflip { yylval.i=(NOFLIPX + NOFLIPY); return FLAG_TYPE; } |
216 | +mazelevel { yylval.i=MAZELEVEL; return FLAG_TYPE; } | |
216 | 217 | \[\ *[0-9]+\%\ *\] { yylval.i = atoi(yytext + 1); return PERCENT; } |
217 | 218 | [0-9]+\% { yylval.i = atoi(yytext); return SPERCENT; } |
218 | 219 | [+\-]?[0-9]+ { yylval.i=atoi(yytext); return INTEGER; } |