less ugly mapdims
replaced the mapdims array with a struct with properly identified members also reduced the calclight postfilter to actually used map areas
This commit is contained in:
+34
-6
@@ -447,6 +447,39 @@ bool worldbordercheck(int x1, int x2, int y1, int y2, int z1, int z2) // check
|
||||
return true;
|
||||
}
|
||||
|
||||
void calcmapdims()
|
||||
{
|
||||
mapdims.x1 = mapdims.y1 = ssize;
|
||||
mapdims.x2 = mapdims.y2 = 0;
|
||||
mapdims.minfloor = 127; mapdims.maxceil = -128; // flow initialised those two with "0", but i'd guess, that was by mistake
|
||||
sqr *s = world;
|
||||
for(int y = 0; y < ssize; y++) for(int x = 0; x < ssize; x++)
|
||||
{
|
||||
if(!SOLID(s))
|
||||
{
|
||||
if(x < mapdims.x1) mapdims.x1 = x;
|
||||
if(x > mapdims.x2) mapdims.x2 = x;
|
||||
if(y < mapdims.y1) mapdims.y1 = y;
|
||||
mapdims.y2 = y;
|
||||
if(s->floor < mapdims.minfloor) mapdims.minfloor = s->floor; // for some reason, flow excluded cubes with floor == -128 here - let's try without that...
|
||||
if(s->ceil > mapdims.maxceil) mapdims.maxceil = s->ceil;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
if(mapdims.x2 < mapdims.x1 || mapdims.y2 < mapdims.y1)
|
||||
{ // map is completely solid -> default to empty map values
|
||||
mapdims.x1 = mapdims.y1 = 2;
|
||||
mapdims.x2 = mapdims.y2 = ssize - 3;
|
||||
mapdims.minfloor = 0;
|
||||
mapdims.maxceil = 16;
|
||||
}
|
||||
if(mapdims.x1 < 2 || mapdims.y1 < 2 || mapdims.x2 > ssize - 3 || mapdims.y2 > ssize - 3) fatal("calcmapdims(): border violation");
|
||||
mapdims.xspan = mapdims.x2 - mapdims.x1 + 1;
|
||||
mapdims.yspan = mapdims.y2 - mapdims.y1 + 1;
|
||||
mapdims.xm = mapdims.x1 + mapdims.xspan / 2.0f;
|
||||
mapdims.ym = mapdims.y1 + mapdims.yspan / 2.0f;
|
||||
}
|
||||
|
||||
bool empty_world(int factor, bool force) // main empty world creation routine, if passed factor -1 will enlarge old world by 1, factor -2 will shrink old world by 1
|
||||
{
|
||||
if(!force && noteditmode("empty world")) return false;
|
||||
@@ -509,6 +542,7 @@ bool empty_world(int factor, bool force) // main empty world creation routine
|
||||
hdr.headersize = sizeof(header);
|
||||
hdr.sfactor = sfactor;
|
||||
|
||||
calcmapdims();
|
||||
calclight();
|
||||
resetmap(!copy);
|
||||
if(clearmap)
|
||||
@@ -522,12 +556,6 @@ bool empty_world(int factor, bool force) // main empty world creation routine
|
||||
popscontext();
|
||||
setvar("fullbright", 1);
|
||||
fullbrightlight();
|
||||
|
||||
mapdims[0] = mapdims[1] = 0;
|
||||
mapdims[2] = mapdims[3] = ssize;
|
||||
mapdims[4] = mapdims[5] = ssize;
|
||||
mapdims[6] = 0;
|
||||
mapdims[7] = 16;
|
||||
}
|
||||
if(!copy)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user