some rearranging, and NOWALL barriers now work in weirdhyperbolic

This commit is contained in:
Zeno Rogue 2017-10-29 14:21:42 +01:00
parent f4d134a692
commit 00d61aae1c
2 changed files with 65 additions and 40 deletions

View File

@ -1,12 +1,8 @@
// This file implements routines related to barriers (Great Walls and similar).
bool buildBarrierNowall(cell *c, eLand l2, bool force = false);
bool checkBarriersFront(cellwalker bb, int q, bool cross) {
bool checkBarriersBack(cellwalker bb, int q=5, bool cross = false);
bool checkBarriersFront(cellwalker bb, int q=5, bool cross = false) {
if(bb.c->type == 6)
if(!ctof(bb.c))
return false;
if(bb.c->mpdist < BARLEV) return false;
@ -65,12 +61,11 @@ bool checkBarriersBack(cellwalker bb, int q, bool cross) {
return checkBarriersFront(bb, q);
}
const eLand NOWALLSEP = laNone;
const eLand NOWALLSEP_USED = laWhirlpool;
bool checkBarriersNowall(cellwalker bb, int q, int dir, eLand l1=laNone, eLand l2=laNone) {
if(bb.c->mpdist < BARLEV && l1 == laNone) return false;
if(bb.c->bardir != NODIR && l1 == laNone) return false;
// if(bb.c->mov[dir] && bb.c->mov[dir]->bardir != NODIR && l1 == laNone) return false;
// if(bb.c->mov[dir] && bb.c->mov[dir]->mpdist < BARLEV && l1 == laNone) return false;
if(l1 != laNone) {
bb.c->bardir = bb.spin; bb.c->barright = l2; bb.c->barleft = NOWALLSEP;
@ -92,7 +87,12 @@ bool checkBarriersNowall(cellwalker bb, int q, int dir, eLand l1=laNone, eLand l
}
}
if(purehepta) {
if(purehepta && S3==4) {
cwspin(bb, dir);
cwstep(bb);
cwspin(bb, dir);
}
else if(purehepta) {
cwspin(bb, 3*dir);
cwstep(bb);
cwspin(bb, -3*dir);
@ -116,7 +116,7 @@ eWall getElementalWall(eLand l) {
void setbarrier(cell *c) {
if(isSealand(c->barleft) && isSealand(c->barright)) {
bool setbar = c->type == 7;
bool setbar = ctof(c);
if(c->barleft == laKraken || c->barright == laKraken)
if(c->barleft != laWarpSea && c->barright != laWarpSea)
setbar = !setbar;
@ -260,8 +260,22 @@ void extendNowall(cell *c) {
setland(cw.c, c->barright);
}
if(purehepta && S3 == 4) {
cwstep(cw);
setland(cw.c, c->barright);
cw.c->barleft = NOWALLSEP_USED;
cw.c->barright = c->land;
cw.c->bardir = cw.spin;
cwstep(cw);
}
for(int i=-1; i<2; i+=2) {
if(purehepta) {
if(purehepta && S3==4) {
cwspin(cw, i);
cwstep(cw);
cwspin(cw, i);
}
else if(purehepta) {
cwspin(cw, 3*i);
cwstep(cw);
cwspin(cw, -3*i);
@ -270,21 +284,33 @@ void extendNowall(cell *c) {
cwspin(cw, 2*i);
cwstep(cw);
}
setland(cw.c, c->barright);
if(cw.c->barleft != NOWALLSEP_USED) {
cw.c->barleft = NOWALLSEP;
cw.c->barright = c->land;
if(c->barright == laNone) {
printf("barright\n");
}// NONEDEBUG
setland(cw.c, c->barright);
if(!purehepta) cwspin(cw, i);
cw.c->bardir = cw.spin;
if(!purehepta) cwspin(cw, -i);
if(S3 == 4 && purehepta) {
cw.c->barright = c->barright;
cw.c->bardir = cw.spin;
setland(cw.c, c->land);
}
else {
setland(cw.c, c->barright);
cw.c->barright = c->land;
if(c->barright == laNone) {
printf("barright\n");
}// NONEDEBUG
setland(cw.c, c->barright);
if(!purehepta) cwspin(cw, i);
cw.c->bardir = cw.spin;
if(!purehepta) cwspin(cw, -i);
}
extendcheck(cw.c);
extendBarrier(cw.c);
}
if(purehepta) {
if(purehepta && S3==4) {
cwspin(cw, -i);
cwstep(cw);
cwspin(cw, -i);
}
else if(purehepta) {
cwspin(cw, 3*i);
cwstep(cw);
cwspin(cw, -3*i);
@ -754,7 +780,7 @@ bool buildBarrierNowall(cell *c, eLand l2, bool force) {
}
for(int i=0; i<3; i++) {
int d = dtab[i];
int d = (S3>3 && purehepta) ? (2+(i&1)) : dtab[i];
if(force) d=1;
cellwalker cw(c, d);

View File

@ -4,8 +4,6 @@
// * 'setland' routines for other geometries
// * the buildBigStuff function which calls equidistant/(horo)cycle/barrier generators.
#define UNKNOWN 65535
// horocycles
int newRoundTableRadius() {
@ -176,7 +174,7 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) {
}
heptagon *alt = new heptagon;
allmaps.push_back(new hrmap_alternate(alt));
allmaps.push_back(newAltMap(alt));
//printf("new alt {%p}\n", alt);
alt->s = firststate;
alt->emeraldval = 0;
@ -282,7 +280,6 @@ void generateTreasureIsland(cell *c) {
// equidistants
#define HAUNTED_RADIUS (purehepta?5:7)
extern bool generatingEquidistant;
bool generatingEquidistant = false;
@ -317,7 +314,7 @@ cell *buildAnotherEquidistant(cell *c, int radius) {
return NULL;
}
cwstep(cw); cwspin(cw, 3);
if(cw.c->type == 7 && hrand(2) == 0) cwspin(cw, 1);
if(ctof(cw.c) && hrand(2) == 0) cwspin(cw, 1);
}
coastpath.push_back(cw.c);
// printf("setdists\n");
@ -354,8 +351,8 @@ cell *buildAnotherEquidistant(cell *c, int radius) {
// prevent gravity anomalies
if(c2->land != c->land) return NULL;
// else if(c->type == 7 && hrand(10000) < 20 && !isCrossroads(c->land) && gold() >= 200)
if(c2->type == 7 && gold() >= R200 && hrand(10) < 2 && buildBarrierNowall(c2, laCrossroads4, true)) {
// else if(ctof(c) && hrand(10000) < 20 && !isCrossroads(c->land) && gold() >= 200)
if(ctof(c2) && gold() >= R200 && hrand(10) < 2 && buildBarrierNowall(c2, laCrossroads4, true)) {
nowall = true;
// raiseBuggyGeneration(c2, "check");
// return;
@ -557,7 +554,7 @@ void buildEquidistant(cell *c) {
c->landflags = 1;
}
}
if(c2 && c2->landparam < c->landparam && c2->landflags == 1 && c->type == 7) {
if(c2 && c2->landparam < c->landparam && c2->landflags == 1 && ctof(c)) {
cell *c3 = c->mov[(i+1)%7];
if(c3 && c3->landparam < c->landparam && c3->landflags == 1) {
c->wall = waTrunk;
@ -882,24 +879,24 @@ void buildBigStuff(cell *c, cell *from) {
// buildgreatwalls
if(weirdhyperbolic) ; // barriers not implemented yet in weird hyperbolic
if(celldist(c) < 3) ;
else if(chaosmode) {
if(c->type == 7 && hrand(10000) < 9000 && c->land && !inmirror(c) && buildBarrierNowall(c, getNewLand(c->land)))
if(ctof(c) && hrand(10000) < 9000 && c->land && !inmirror(c) && buildBarrierNowall(c, getNewLand(c->land)))
{}
else if(c->type == 7 && c->land == laMirror && hrand(10000) < 2000) {
else if(ctof(c) && c->land == laMirror && hrand(10000) < 2000 && !weirdhyperbolic) {
int bd = 2 + hrand(2) * 3;
buildBarrier(c, bd, laMirrored);
}
}
else if(c->type == 7 && isWarped(c->land) && hrand(10000) < 3000 && c->land &&
else if(ctof(c) && isWarped(c->land) && hrand(10000) < 3000 && c->land &&
buildBarrierNowall(c, eLand(c->land ^ laWarpSea ^ laWarpCoast))) ;
else if(c->type == 7 && c->land == laCrossroads4 && hrand(10000) < 7000 && c->land &&
else if(ctof(c) && c->land == laCrossroads4 && hrand(10000) < 7000 && c->land &&
buildBarrierNowall(c, getNewLand(laCrossroads4))) ;
else if(c->type == 7 && hrand(I10000) < 20 && !generatingEquidistant && !yendor::on && !tactic::on && !isCrossroads(c->land) && gold() >= R200 &&
else if(ctof(c) && hrand(I10000) < 20 && !generatingEquidistant && !yendor::on && !tactic::on && !isCrossroads(c->land) && gold() >= R200 &&
!inmirror(c) && !isSealand(c->land) && !isHaunted(c->land) && !isGravityLand(c->land) &&
(c->land != laRlyeh || rlyehComplete()) &&
c->land != laTortoise && c->land != laPrairie && c->land &&
@ -909,21 +906,23 @@ void buildBigStuff(cell *c, cell *from) {
buildBarrierNowall(c, laCrossroads4) ;
}
else if(weirdhyperbolic) ; // non-Nowall barriers not implemented yet in weird hyperbolic
else if(c->land == laCrossroads2 && !purehepta)
buildCrossroads2(c);
else if(c->land == laPrairie && c->LHU.fi.walldist == 0) {
for(int bd=0; bd<7; bd++) {
int fval2 = createStep(c->master, bd)->fieldval;
int wd = currfp.gmul(fval2, currfp.inverses[c->fval-1]);
if(currfp.distwall[wd] == 0) {
int wd = currfp_gmul(fval2, currfp_inverses(c->fval-1));
if(currfp_distwall(wd) == 0) {
buildBarrier(c, bd);
break;
}
}
}
else if(c->type == 7 && c->land && hrand(I10000) < (
else if(ctof(c) && c->land && hrand(I10000) < (
showoff ? (cwt.c->mpdist > 7 ? 0 : 10000) :
inmirror(c) ? 0 :
isGravityLand(c->land) ? 0 :