• R/O
  • SSH
  • HTTPS

jsporkhack: コミット


コミットメタ情報

リビジョン42 (tree)
日時2013-02-17 08:17:48
作者dplusplus

ログメッセージ

本家#482
Consolidate all map initializers under INIT_MAP.

Instead of giving fill char (or random) in LEVEL (ex-MAZE), you now use
INIT_MAP:solidfill,' '
INIT_MAP:mazegrid,'-'
INIT_MAP:mines,'.',' ',true,true,unlit,true
The mines-style can also take one extra mapchar, for "backfilling",
if walled and joined are true:
INIT_MAP:mines,'.',' ',true,true,unlit,true,'L'

変更サマリ

差分

--- JSporkHack/trunk/include/sp_lev.h (revision 41)
+++ JSporkHack/trunk/include/sp_lev.h (revision 42)
@@ -26,6 +26,13 @@
2626 #define NOFLIPY 64
2727 #define MAZELEVEL 128
2828
29+/* different level layout initializers */
30+#define LVLINIT_NONE 0
31+#define LVLINIT_SOLIDFILL 1
32+#define LVLINIT_MAZEGRID 2
33+#define LVLINIT_MINES 3
34+
35+
2936 /* max. # of random registers */
3037 #define MAX_REGISTERS 10
3138
@@ -107,7 +114,7 @@
107114 } Str_or_Len;
108115
109116 typedef struct {
110- boolean init_present, padding;
117+ xchar init_style; /* one of LVLINIT_foo */
111118 char fg, bg;
112119 boolean smoothed, joined;
113120 xchar lit, walled;
--- JSporkHack/trunk/src/sp_lev.c (revision 41)
+++ JSporkHack/trunk/src/sp_lev.c (revision 42)
@@ -2715,21 +2715,35 @@
27152715
27162716 level.flags.is_maze_lev = 0;
27172717
2718- if (lvl->init_lev.init_present) {
2718+ switch (lvl->init_lev.init_style) {
2719+ default: impossible("Unrecognized level init style."); break;
2720+ case LVLINIT_NONE: break;
2721+ case LVLINIT_SOLIDFILL:
2722+ lvlfill_solid(lvl->init_lev.filling);
2723+ xstart = 1;
2724+ ystart = 0;
2725+ xsize = COLNO-1;
2726+ ysize = ROWNO;
2727+ break;
2728+ case LVLINIT_MAZEGRID:
2729+ lvlfill_maze_grid(2,0, x_maze_max,y_maze_max, HWALL);
2730+ xstart = 1;
2731+ ystart = 0;
2732+ xsize = COLNO-1;
2733+ ysize = ROWNO;
2734+ break;
2735+ case LVLINIT_MINES:
27192736 if (lvl->init_lev.lit < 0) lvl->init_lev.lit = rn2(2);
2737+ if (lvl->init_lev.filling > -1) lvlfill_solid(lvl->init_lev.filling);
27202738 mkmap(&(lvl->init_lev));
2721- } else {
2722- if (lvl->init_lev.filling == -1)
2723- lvlfill_maze_grid(2,0, x_maze_max,y_maze_max, HWALL);
2724- else
2725- lvlfill_solid(lvl->init_lev.filling);
2726- /* ensure the whole level is marked as mapped area */
27272739 xstart = 1;
27282740 ystart = 0;
27292741 xsize = COLNO-1;
27302742 ysize = ROWNO;
2743+ break;
27312744 }
27322745
2746+
27332747 if (lvl->init_lev.flags & NOTELEPORT) level.flags.noteleport = 1;
27342748 if (lvl->init_lev.flags & HARDFLOOR) level.flags.hardfloor = 1;
27352749 if (lvl->init_lev.flags & NOMMAP) level.flags.nommap = 1;
@@ -3219,12 +3233,13 @@
32193233 panic("reading special level with ysize too large");
32203234 }
32213235
3222- if(lvl->init_lev.init_present && xsize <= 1 && ysize <= 1) {
3236+ if (xsize <= 1 && ysize <= 1) {
32233237 xstart = 1;
32243238 ystart = 0;
32253239 xsize = COLNO-1;
32263240 ysize = ROWNO;
32273241 } else {
3242+
32283243 /* Load the map */
32293244 for(y = ystart; y < ystart+ysize; y++)
32303245 for(x = xstart; x < xstart+xsize; x++) {
@@ -3238,6 +3253,7 @@
32383253 levl[x][y].roomno = 0;
32393254 levl[x][y].edge = 0;
32403255
3256+
32413257 /*
32423258 * Set secret doors to closed (why not trapped too?). Set
32433259 * the horizontal bit.
@@ -3261,8 +3277,9 @@
32613277 else if(levl[x][y].typ == CROSSWALL)
32623278 has_bounds = TRUE;
32633279 }
3264- if (lvl->init_lev.init_present && lvl->init_lev.joined)
3280+ if (lvl->init_lev.joined)
32653281 remove_rooms(xstart, ystart, xstart+xsize, ystart+ysize);
3282+
32663283 }
32673284
32683285 if (!tmpmazepart->keep_region) {
--- JSporkHack/trunk/src/mkmap.c (revision 41)
+++ JSporkHack/trunk/src/mkmap.c (revision 42)
@@ -507,7 +507,7 @@
507507 * doesn't _have_ to be stone, say, for hell. so if the player
508508 * defined a maze filler originally, go ahead and backfill the
509509 * background in with that filler - DSR */
510- if (walled && join) {
510+ if (walled && join && (init_lev->filling > -1)) {
511511 level.flags.is_maze_lev = FALSE;
512512 level.flags.is_cavernous_lev = TRUE;
513513 backfill(bg_typ,init_lev->filling);
--- JSporkHack/trunk/util/lev_comp.y (revision 41)
+++ JSporkHack/trunk/util/lev_comp.y (revision 42)
@@ -106,6 +106,7 @@
106106
107107
108108 %token <i> CHAR INTEGER BOOLEAN PERCENT SPERCENT
109+%token <i> MAZE_GRID_ID SOLID_FILL_ID MINES_ID
109110 %token <i> MESSAGE_ID MAZE_ID LEVEL_ID LEV_INIT_ID GEOMETRY_ID NOMAP_ID
110111 %token <i> OBJECT_ID COBJECT_ID MONSTER_ID TRAP_ID DOOR_ID DRAWBRIDGE_ID
111112 %token <i> MAZEWALK_ID WALLIFY_ID REGION_ID FILLING
@@ -123,7 +124,7 @@
123124 %token <i> ',' ':' '(' ')' '[' ']' '{' '}'
124125 %token <map> STRING MAP_ID
125126 %type <i> h_justif v_justif trap_name room_type door_state light_state
126-%type <i> alignment altar_type a_register roomfill filling door_pos
127+%type <i> alignment altar_type a_register roomfill door_pos
127128 %type <i> door_wall walled secret amount chance opt_boolean
128129 %type <i> engraving_type flags flag_list prefilled lev_region lev_init
129130 %type <i> monster monster_c m_register object object_c o_register
@@ -147,7 +148,7 @@
147148 "%s : %d errors detected. No output created!\n",
148149 fname, fatal_error);
149150 } else {
150- splev.init_lev.init_present = (boolean) $3;
151+ splev.init_lev.init_style = (xchar) $3;
151152 splev.init_lev.flags = (long) $2;
152153 if (check_subrooms(&splev)) {
153154 if (!write_level_file($1, &splev)) {
@@ -160,7 +161,7 @@
160161 }
161162 ;
162163
163-level_def : LEVEL_ID ':' string opt_filling
164+level_def : LEVEL_ID ':' string
164165 {
165166 if (index($3, '.'))
166167 yyerror("Invalid dot ('.') in level name.");
@@ -171,41 +172,65 @@
171172 }
172173 ;
173174
174-opt_filling : /* nothing */
175+lev_init : /* nothing */
175176 {
176- /* really, nothing */
177+ $$ = LVLINIT_NONE;
177178 }
178- | ',' filling
179+ | LEV_INIT_ID ':' SOLID_FILL_ID ',' CHAR
179180 {
180- splev.init_lev.filling = (schar) $2;
181+ splev.init_lev.filling = what_map_char((char) $5);
182+ if (splev.init_lev.filling == INVALID_TYPE)
183+ yyerror("INIT_MAP: Invalid fill char type.");
184+ $$ = LVLINIT_SOLIDFILL;
181185 max_x_map = COLNO-1;
182186 max_y_map = ROWNO;
183187 }
184- ;
185-
186-lev_init : /* nothing */
188+ | LEV_INIT_ID ':' MAZE_GRID_ID ',' CHAR
187189 {
188- $$ = 0;
190+ splev.init_lev.filling = what_map_char((char) $5);
191+ if (splev.init_lev.filling == INVALID_TYPE)
192+ yyerror("INIT_MAP: Invalid fill char type.");
193+ $$ = LVLINIT_MAZEGRID;
194+ max_x_map = COLNO-1;
195+ max_y_map = ROWNO;
189196 }
190- | LEV_INIT_ID ':' CHAR ',' CHAR ',' BOOLEAN ',' BOOLEAN ',' light_state ',' walled
197+ | LEV_INIT_ID ':' MINES_ID ',' CHAR ',' CHAR ',' BOOLEAN ',' BOOLEAN ',' light_state ',' walled opt_fillchar
191198 {
192- splev.init_lev.fg = what_map_char((char) $3);
199+ splev.init_lev.fg = what_map_char((char) $5);
193200 if (splev.init_lev.fg == INVALID_TYPE)
194201 yyerror("INIT_MAP: Invalid foreground type.");
195- splev.init_lev.bg = what_map_char((char) $5);
202+ splev.init_lev.bg = what_map_char((char) $7);
196203 if (splev.init_lev.bg == INVALID_TYPE)
197204 yyerror("INIT_MAP: Invalid background type.");
198- splev.init_lev.smoothed = $7;
199- splev.init_lev.joined = $9;
205+ splev.init_lev.smoothed = $9;
206+ splev.init_lev.joined = $11;
200207 if (splev.init_lev.joined &&
201208 splev.init_lev.fg != CORR && splev.init_lev.fg != ROOM)
202209 yyerror("INIT_MAP: Invalid foreground type for joined map.");
203- splev.init_lev.lit = $11;
204- splev.init_lev.walled = $13;
205- $$ = 1;
210+ splev.init_lev.lit = $13;
211+ splev.init_lev.walled = $15;
212+
213+ splev.init_lev.filling = $<i>16;
214+ if (splev.init_lev.filling == INVALID_TYPE)
215+ yyerror("INIT_MAP: Invalid fill char type.");
216+
217+ $$ = LVLINIT_MINES;
218+ max_x_map = COLNO-1;
219+ max_y_map = ROWNO;
206220 }
207221 ;
208222
223+opt_fillchar : /* nothing */
224+ {
225+ $<i>$ = -1;
226+ }
227+ | ',' CHAR
228+ {
229+ $<i>$ = what_map_char((char) $2);
230+ }
231+ ;
232+
233+
209234 walled : BOOLEAN
210235 | RANDOM_TYPE
211236 ;
@@ -594,16 +619,6 @@
594619 | RANDOM_TYPE
595620 ;
596621
597-filling : CHAR
598- {
599- $$ = get_floor_type((char)$1);
600- }
601- | RANDOM_TYPE
602- {
603- $$ = -1;
604- }
605- ;
606-
607622 map_definition : NOMAP_ID
608623 {
609624 mazepart *tmppart = New(mazepart);
--- JSporkHack/trunk/util/lev_comp.l (revision 41)
+++ JSporkHack/trunk/util/lev_comp.l (revision 42)
@@ -105,6 +105,9 @@
105105 NOMAP return NOMAP_ID;
106106 LEVEL return LEVEL_ID;
107107 INIT_MAP return LEV_INIT_ID;
108+mazegrid return MAZE_GRID_ID;
109+solidfill return SOLID_FILL_ID;
110+mines return MINES_ID;
108111 FLAGS return FLAGS_ID;
109112 GEOMETRY return GEOMETRY_ID;
110113 ^MAP\r?\n { BEGIN(MAPC); line_number++; }
旧リポジトリブラウザで表示