• R/O
  • SSH
  • HTTPS

jsporkhack: Commit


Commit MetaInfo

Revision33 (tree)
Time2009-09-23 01:17:17
Authordplusplus

Log Message

本家#473
RANDLINE now takes an optional thickness value.

Change Summary

Incremental Difference

--- JSporkHack/trunk/include/sp_lev.h (revision 32)
+++ JSporkHack/trunk/include/sp_lev.h (revision 33)
@@ -74,7 +74,8 @@
7474 #define SPO_REPLACETERRAIN 35 /* replaceterrain */
7575 #define SPO_EXIT 36
7676 #define SPO_ENDROOM 37
77-#define MAX_SP_OPCODES 38
77+#define SPO_RANDLINE 38 /* randline */
78+#define MAX_SP_OPCODES 39
7879
7980
8081 /* special level coder CPU flags */
@@ -88,6 +89,13 @@
8889 */
8990
9091 typedef struct {
92+ xchar x1,y1,x2,y2;
93+ xchar fg, lit;
94+ int roughness;
95+ xchar thick;
96+} randline;
97+
98+typedef struct {
9199 int cmp_what;
92100 int cmp_val;
93101 } opcmp;
--- JSporkHack/trunk/src/sp_lev.c (revision 32)
+++ JSporkHack/trunk/src/sp_lev.c (revision 33)
@@ -1582,10 +1582,28 @@
15821582 }
15831583 }
15841584
1585+
15851586 void
1586-line_midpoint_core(x1,y1,x2,y2,rough, ter,lit, rec)
1587- schar x1,y1,x2,y2,rough,ter,lit,rec;
1587+put_terr_spot(x,y,ter,lit,thick)
1588+ schar x,y,ter,lit,thick;
15881589 {
1590+ int dx, dy;
1591+
1592+ if (thick < 1) thick = 1;
1593+ else if (thick > 10) thick = 10;
1594+
1595+ for (dx = x-(thick/2); dx < x+((thick+1)/2); dx++)
1596+ for (dy = y-(thick/2); dy < y+((thick+1)/2); dy++)
1597+ if (!(dx >= COLNO-1 || dx <= 0 || dy <= 0 || dy >= ROWNO-1)) {
1598+ levl[dx][dy].typ = ter;
1599+ levl[dx][dy].lit = lit;
1600+ }
1601+}
1602+
1603+void
1604+line_midpoint_core(x1,y1,x2,y2,rough, ter,lit,thick, rec)
1605+ schar x1,y1,x2,y2,rough,ter,lit,thick,rec;
1606+{
15891607 int mx, my;
15901608 int dx, dy;
15911609
@@ -1594,10 +1612,7 @@
15941612 }
15951613
15961614 if ((x2 == x1) && (y2 == y1)) {
1597- if (!(x1 >= COLNO-1 || x1 <= 0 || y1 <= 0 || y1 >= ROWNO-1)) {
1598- levl[x1][y1].typ = ter;
1599- levl[x1][y1].lit = lit;
1600- }
1615+ put_terr_spot(x1,y1,ter,lit,thick);
16011616 return;
16021617 }
16031618
@@ -1616,17 +1631,14 @@
16161631 } while ((mx >= COLNO-1 || mx <= 0 || my <= 0 || my >= ROWNO-1));
16171632 }
16181633
1619- if (!(mx >= COLNO-1 || mx <= 0 || my <= 0 || my >= ROWNO-1)) {
1620- levl[mx][my].typ = ter;
1621- levl[mx][my].lit = lit;
1622- }
1634+ put_terr_spot(mx,my,ter,lit,thick);
16231635
16241636 rough = (rough * 2) / 3;
16251637
16261638 rec--;
16271639
1628- line_midpoint_core(x1,y1,mx,my, rough,ter,lit, rec);
1629- line_midpoint_core(mx,my,x2,y2, rough,ter,lit, rec);
1640+ line_midpoint_core(x1,y1,mx,my, rough,ter,lit,thick, rec);
1641+ line_midpoint_core(mx,my,x2,y2, rough,ter,lit,thick, rec);
16301642 }
16311643
16321644 void
@@ -1634,7 +1646,7 @@
16341646 randline *rndline;
16351647 struct mkroom *croom;
16361648 {
1637- schar x1,y1,x2,y2;
1649+ schar x1,y1,x2,y2,thick;
16381650
16391651 x1 = rndline->x1; y1 = rndline->y1;
16401652 get_location(&x1, &y1, DRY|WET, croom);
@@ -1642,7 +1654,9 @@
16421654 x2 = rndline->x2; y2 = rndline->y2;
16431655 get_location(&x2, &y2, DRY|WET, croom);
16441656
1645- line_midpoint_core(x1,y1,x2,y2,rndline->roughness, rndline->fg, rndline->lit, 12);
1657+ thick = rndline->thick;
1658+
1659+ line_midpoint_core(x1,y1,x2,y2,rndline->roughness, rndline->fg, rndline->lit, thick, 12);
16461660 }
16471661
16481662
--- JSporkHack/trunk/util/lev_comp.y (revision 32)
+++ JSporkHack/trunk/util/lev_comp.y (revision 33)
@@ -1323,7 +1323,7 @@
13231323 }
13241324 ;
13251325
1326-randline_detail : RANDLINE_ID ':' lineends ',' CHAR ',' light_state ',' INTEGER
1326+randline_detail : RANDLINE_ID ':' lineends ',' CHAR ',' light_state ',' INTEGER opt_int
13271327 {
13281328 randline* tmprandline = New(randline);
13291329
@@ -1337,9 +1337,20 @@
13371337 }
13381338 tmprandline->lit = $7;
13391339 tmprandline->roughness = $9;
1340+ tmprandline->thick = $<i>10;
13401341 add_opcode(&splev, SPO_RANDLINE, tmprandline);
13411342 }
13421343
1344+opt_int : /* empty */
1345+ {
1346+ $<i>$ = 0;
1347+ }
1348+ | ',' INTEGER
1349+ {
1350+ $<i>$ = $2;
1351+ }
1352+ ;
1353+
13431354 spill_detail : SPILL_ID ':' coordinate ',' CHAR ',' DIRECTION ',' INTEGER ',' light_state
13441355 {
13451356 spill* tmpspill = New(spill);
Show on old repository browser