made the equidistant lands generate something without crashing in all geometries

This commit is contained in:
Zeno Rogue 2017-10-30 19:12:33 +01:00
parent 142e39ec4d
commit ccbe7feb96
5 changed files with 44 additions and 5 deletions

View File

@ -662,6 +662,16 @@ int towerval(cell *c, cellfunction* cf) {
/* other geometries */
void setLandWeird(cell *c) {
if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean) {
int d = celldist(c) - (getDistLimit() - 2);
if(d <= 0)
c->land = laCrossroads4;
else
c->land = specialland, c->landparam = d;
}
}
void setLandQuotient(cell *c) {
int fv = zebra40(c);
if(fv/4 == 4 || fv/4 == 6 || fv/4 == 5 || fv/4 == 10) fv ^= 2;
@ -669,6 +679,13 @@ void setLandQuotient(cell *c) {
if(fv%4==0 || fv%4 == 2) setland(c, laWarpSea);
if(specialland == laElementalWall)
setland(c, eLand(laEFire + (fv%4)));
if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean) {
int d = celldist(c) - 1;
if(d <= 0)
c->land = laCrossroads4;
else
c->land = specialland, c->landparam = d;
}
}
void setLandSphere(cell *c) {
@ -700,6 +717,13 @@ void setLandSphere(cell *c) {
if(specialland == laCrossroads3 && c->type != 6 && c->master->fiftyval == 1)
c->wall = waBigTree;
}
if(specialland == laIvoryTower || specialland == laEndorian || specialland == laDungeon || specialland == laOcean) {
int d = celldist(c);
if(d <= 0)
c->land = laCrossroads4;
else
c->land = specialland, c->landparam = d;
}
}
eLand euland[65536];
@ -880,7 +904,7 @@ void buildBigStuff(cell *c, cell *from) {
}
if(generatingEquidistant) deepOcean = false;
if(weirdhyperbolic && c->land == laOcean) deepOcean = true;
if(weirdhyperbolic && c->land == laOcean) deepOcean = c->landparam >= 30;
// buildgreatwalls

View File

@ -2679,6 +2679,9 @@ namespace prairie {
else if(sphere) {
c->LHU.fi.rval = celldistance(c, cwt.c) + 8 - (nontruncated ? 2 : 3);
}
else if(weirdhyperbolic) {
c->LHU.fi.rval = max(celldist(c), 15);
}
else {
if(!from) {
for(int i=0; i<size(currfp.matrices); i++)
@ -3348,6 +3351,12 @@ namespace halloween {
namespace dungeon {
void towerError(cell *c) {
// only care in the standard geometry -- weird ones are intentionally left buggy
if(!weirdhyperbolic && !sphere && !quotient)
raiseBuggyGeneration(c, "ivory tower/dungeon generation error");
}
void buildIvoryTower(cell *c) {
/* if(int(c->landparam) % 5 == 0)
c->wall = waCamelot;
@ -3397,8 +3406,8 @@ namespace dungeon {
rdepths[i] = c2 && c3 && c4 && (c2->landflags == 3 || c3->landflags == 3 || c4->landflags == 3);
c2 = chosenDown(c2, 1, 0); // if(!c2) break;
c3 = chosenDown(c3, -1, 0);
if(!c2) { raiseBuggyGeneration(c, "ivory c2"); return; }
if(!c3) { raiseBuggyGeneration(c, "ivory c3"); return; }
if(!c2) { towerError(c); return; }
if(!c3) { towerError(c); return; }
}
}
@ -3452,8 +3461,8 @@ namespace dungeon {
switchcount++;
c2 = chosenDown(c2, 1, 0); // if(!c2) break;
c3 = chosenDown(c3, -1, 0);
if(!c2) { raiseBuggyGeneration(c, "ivory c2"); return 0; }
if(!c3) { raiseBuggyGeneration(c, "ivory c3"); return 0; }
if(!c2) { towerError(c); return 0; }
if(!c3) { towerError(c); return 0; }
}
}

View File

@ -2148,6 +2148,10 @@ transmatrix applyDowndir(cell *c, cellfunction *cf) {
}
void drawTowerFloor(const transmatrix& V, cell *c, int col, cellfunction *cf = coastvalEdge) {
if(weirdhyperbolic || sphere) {
int ct6 = ctof(c);
qfloor(c, V, PLAINFLOOR, col); return;
}
int j = -1;
if(euclid) j = 10;

View File

@ -1891,6 +1891,7 @@ bool openplains(cell *c);
void buildBigStuff(cell *c, cell *from);
void setLandQuotient(cell *c);
void setLandSphere(cell *c);
void setLandWeird(cell *c);
void moreBigStuff(cell *c);
void setLandEuclid(cell *c);
bool checkInTree(cell *c, int maxv);

View File

@ -2078,6 +2078,7 @@ void setdist(cell *c, int d, cell *from) {
if(sphere || torus) setLandSphere(c);
else if(euclid) setLandEuclid(c);
if(weirdhyperbolic) setLandWeird(c);
if(quotient) { setland(c, specialland); setLandQuotient(c); }
// if(chaosmode) setland(c, getCLand(c));