rewrite calculation of map geometry bounding box

and rename client-side struct "mapdims" to clmapdims (to avoid confusion
with server-side data)
This commit is contained in:
ac-stef
2016-08-26 14:08:55 +02:00
parent 48e2ce3863
commit e1ce0979d0
13 changed files with 223 additions and 105 deletions
+3 -36
View File
@@ -620,41 +620,6 @@ 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(OUTBORD(x, y)) conoutf("non-solid cube in world border found: x %d, y %d", x, y); // will also go fatal() below
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 < MINBORD || mapdims.y1 < MINBORD || mapdims.x2 >= ssize - MINBORD || mapdims.y2 >= ssize - MINBORD)
fatal("calcmapdims(): world border violation (x:%d..%d, y:%d..%d)", mapdims.x1, mapdims.x2, mapdims.y1, mapdims.y2);
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;
@@ -719,7 +684,9 @@ bool empty_world(int factor, bool force) // main empty world creation routine
hdr.headersize = sizeof(header);
hdr.sfactor = sfactor;
calcmapdims();
servsqr *servworld = createservworld(world, cubicsize);
calcmapdims(clmapdims, servworld, ssize);
delete[] servworld;
calclight();
resetmap(!copy);
if(clearmap)