Finish splitting wallification into two

This commit is contained in:
Pasi Kallinen
2016-01-05 07:42:28 +02:00
parent 366043f714
commit ece4407c41
+14 -15
View File
@@ -123,13 +123,9 @@ int wall_there, dx, dy;
return spine; return spine;
} }
/* /* Remove walls totally surrounded by stone */
* Wall cleanup. This function has two purposes: (1) remove walls that
* are totally surrounded by stone - they are redundant. (2) correct
* the types so that they extend and connect to each other.
*/
void void
wallification(x1, y1, x2, y2) wall_cleanup(x1, y1, x2, y2)
int x1, y1, x2, y2; int x1, y1, x2, y2;
{ {
uchar type; uchar type;
@@ -138,9 +134,9 @@ int x1, y1, x2, y2;
/* sanity check on incoming variables */ /* sanity check on incoming variables */
if (x1 < 0 || x2 >= COLNO || x1 > x2 || y1 < 0 || y2 >= ROWNO || y1 > y2) if (x1 < 0 || x2 >= COLNO || x1 > x2 || y1 < 0 || y2 >= ROWNO || y1 > y2)
panic("wallification: bad bounds (%d,%d) to (%d,%d)", x1, y1, x2, y2); panic("wall_cleanup: bad bounds (%d,%d) to (%d,%d)", x1, y1, x2, y2);
/* Step 1: change walls surrounded by rock to rock. */ /* change walls surrounded by rock to rock. */
for (x = x1; x <= x2; x++) for (x = x1; x <= x2; x++)
for (y = y1; y <= y2; y++) { for (y = y1; y <= y2; y++) {
lev = &levl[x][y]; lev = &levl[x][y];
@@ -153,10 +149,9 @@ int x1, y1, x2, y2;
lev->typ = STONE; lev->typ = STONE;
} }
} }
fix_wall_spines(x1,y1,x2,y2);
} }
/* Correct wall types so they extend and connect to each other */
void void
fix_wall_spines(x1, y1, x2, y2) fix_wall_spines(x1, y1, x2, y2)
int x1, y1, x2, y2; int x1, y1, x2, y2;
@@ -181,11 +176,7 @@ int x1, y1, x2, y2;
if (x1<0 || x2>=COLNO || x1>x2 || y1<0 || y2>=ROWNO || y1>y2) if (x1<0 || x2>=COLNO || x1>x2 || y1<0 || y2>=ROWNO || y1>y2)
panic("wall_extends: bad bounds (%d,%d) to (%d,%d)",x1,y1,x2,y2); panic("wall_extends: bad bounds (%d,%d) to (%d,%d)",x1,y1,x2,y2);
/* /* set the correct wall type. */
* Step 2: set the correct wall type. We can't combine steps
* 1 and 2 into a single sweep because we depend on knowing if
* the surrounding positions are stone.
*/
for (x = x1; x <= x2; x++) for (x = x1; x <= x2; x++)
for (y = y1; y <= y2; y++) { for (y = y1; y <= y2; y++) {
lev = &levl[x][y]; lev = &levl[x][y];
@@ -217,6 +208,14 @@ int x1, y1, x2, y2;
} }
} }
void
wallification(x1, y1, x2, y2)
int x1, y1, x2, y2;
{
wall_cleanup(x1,y1,x2,y2);
fix_wall_spines(x1,y1,x2,y2);
}
STATIC_OVL boolean STATIC_OVL boolean
okay(x, y, dir) okay(x, y, dir)
int x, y; int x, y;