mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 01:00:25 +00:00
major rewrite: unified the common parts of heptagon and cell via struct connection<T> and struct walker<T>
This commit is contained in:
parent
a5a3cf1c87
commit
682f804576
@ -529,7 +529,7 @@ void improveItemScores() {
|
||||
improve_score(42, itMutant);
|
||||
improve_score(43, itFulgurite);
|
||||
|
||||
if(!isHaunted(cwt.c->land)) improve_score(46, itLotus);
|
||||
if(!isHaunted(cwt.at->land)) improve_score(46, itLotus);
|
||||
improve_score(47, itMutant2);
|
||||
improve_score(48, itWindstone);
|
||||
|
||||
|
318
barriers.cpp
318
barriers.cpp
@ -6,20 +6,20 @@ namespace hr {
|
||||
|
||||
bool checkBarriersFront(cellwalker bb, int q, bool cross) {
|
||||
|
||||
if(!ctof(bb.c))
|
||||
if(!ctof(bb.at))
|
||||
return false;
|
||||
|
||||
if(bb.c->mpdist < BARLEV) return false;
|
||||
if(bb.c->mpdist == BUGLEV) return false;
|
||||
if(bb.c->bardir != NODIR) return false;
|
||||
if(bb.at->mpdist < BARLEV) return false;
|
||||
if(bb.at->mpdist == BUGLEV) return false;
|
||||
if(bb.at->bardir != NODIR) return false;
|
||||
if(bb.spin == (nonbitrunc ? 3 : 0)) {q--; if(!q) return true; }
|
||||
|
||||
if(!cross) for(int i=0; i<7; i++) {
|
||||
cellwalker bb2 = bb + i + wstep;
|
||||
if(bb2.c->bardir != NODIR) return false;
|
||||
if(bb2.at->bardir != NODIR) return false;
|
||||
if(!nonbitrunc) {
|
||||
bb2 = bb2 + 4 + wstep;
|
||||
if(bb2.c->bardir != NODIR) return false;
|
||||
if(bb2.at->bardir != NODIR) return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,22 +37,22 @@ void preventbarriers(cell *c) {
|
||||
}
|
||||
|
||||
bool checkBarriersBack(cellwalker bb, int q, bool cross) {
|
||||
// printf("back, %p, s%d\n", bb.c, bb.spin);
|
||||
// printf("back, %p, s%d\n", bb.at, bb.spin);
|
||||
|
||||
// if(mark) { printf("mpdist = %d [%d] bardir = %d spin=%d q=%d cross=%d\n", bb.c->mpdist, BARLEV, bb.c->bardir, bb.spin, q, cross); }
|
||||
// if(mark) { printf("mpdist = %d [%d] bardir = %d spin=%d q=%d cross=%d\n", bb.at->mpdist, BARLEV, bb.at->bardir, bb.spin, q, cross); }
|
||||
|
||||
if(bb.c->mpdist < BARLEV) return false;
|
||||
if(bb.c->mpdist == BUGLEV) return false;
|
||||
if(bb.c->bardir != NODIR) return false;
|
||||
if(bb.at->mpdist < BARLEV) return false;
|
||||
if(bb.at->mpdist == BUGLEV) return false;
|
||||
if(bb.at->bardir != NODIR) return false;
|
||||
|
||||
// if(bb.spin == 0 && bb.c->mpdist == INFD) return true;
|
||||
// if(bb.spin == 0 && bb.at->mpdist == INFD) return true;
|
||||
|
||||
if(!cross) for(int i=0; i<7; i++) {
|
||||
cellwalker bb2 = bb + i + wstep;
|
||||
if(bb2.c->bardir != NODIR) return false;
|
||||
if(bb2.at->bardir != NODIR) return false;
|
||||
if(!nonbitrunc) {
|
||||
bb2 = bb2 + 4 + wstep;
|
||||
if(bb2.c->bardir != NODIR) return false;
|
||||
if(bb2.at->bardir != NODIR) return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,22 +66,22 @@ bool warped_version(eLand l1, eLand l2) {
|
||||
}
|
||||
|
||||
bool checkBarriersNowall(cellwalker bb, int q, int dir, eLand l1=laNone, eLand l2=laNone) {
|
||||
if(bb.c->mpdist < BARLEV && l1 == l2) return false;
|
||||
if(bb.c->bardir != NODIR && l1 == l2) 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(bb.at->mpdist < BARLEV && l1 == l2) return false;
|
||||
if(bb.at->bardir != NODIR && l1 == l2) return false;
|
||||
// if(bb.at->move(dir) && bb.at->move(dir)->bardir != NODIR && l1 == laNone) return false;
|
||||
// if(bb.at->move(dir) && bb.at->move(dir)->mpdist < BARLEV && l1 == laNone) return false;
|
||||
|
||||
if(l1 != l2) {
|
||||
bb.c->bardir = bb.spin; bb.c->barright = l2; bb.c->barleft = NOWALLSEP;
|
||||
setland(bb.c, l1);
|
||||
bb.at->bardir = bb.spin; bb.at->barright = l2; bb.at->barleft = NOWALLSEP;
|
||||
setland(bb.at, l1);
|
||||
}
|
||||
if(q > 20) return true;
|
||||
|
||||
if(l1 == laNone) for(int i=0; i<bb.c->type; i++) {
|
||||
cell *c1 = bb.c->mov[i];
|
||||
if(l1 == laNone) for(int i=0; i<bb.at->type; i++) {
|
||||
cell *c1 = bb.at->move(i);
|
||||
if(!c1) continue;
|
||||
for(int j=0; j<c1->type; j++) {
|
||||
cell *c2 = c1->mov[j];
|
||||
cell *c2 = c1->move(j);
|
||||
if(!c2) continue;
|
||||
if(c2 && c2->bardir == NOBARRIERS)
|
||||
return false;
|
||||
@ -170,47 +170,47 @@ void extendBarrierFront(cell *c) {
|
||||
int ht = c->landparam;
|
||||
extendcheck(c);
|
||||
|
||||
cellwalker bb(c, c->bardir); setbarrier(bb.c);
|
||||
cellwalker bb(c, c->bardir); setbarrier(bb.at);
|
||||
bb += wstep;
|
||||
|
||||
if(!nonbitrunc) {
|
||||
bb.c->barleft = c->barleft;
|
||||
bb.c->barright = c->barright;
|
||||
setbarrier(bb.c);
|
||||
if(!mirrorwall(bb.c))
|
||||
bb.c->landparam = (ht-4);
|
||||
bb.at->barleft = c->barleft;
|
||||
bb.at->barright = c->barright;
|
||||
setbarrier(bb.at);
|
||||
if(!mirrorwall(bb.at))
|
||||
bb.at->landparam = (ht-4);
|
||||
//printf("[A heat %d]\n", ht-4);
|
||||
|
||||
setland((bb + 2 + wstep).c, c->barleft);
|
||||
setland((bb + 4 + wstep).c, c->barright);
|
||||
setland((bb + 2).cpeek(), c->barleft);
|
||||
setland((bb + 4).cpeek(), c->barright);
|
||||
|
||||
bb = bb + 3 + wstep;
|
||||
bb.c->barleft = c->barright;
|
||||
bb.c->barright = c->barleft;
|
||||
setbarrier(bb.c);
|
||||
if(!mirrorwall(bb.c))
|
||||
bb.c->landparam = (ht-4)^2;
|
||||
bb.at->barleft = c->barright;
|
||||
bb.at->barright = c->barleft;
|
||||
setbarrier(bb.at);
|
||||
if(!mirrorwall(bb.at))
|
||||
bb.at->landparam = (ht-4)^2;
|
||||
//printf("[B heat %d]\n", (ht-4)^2);
|
||||
|
||||
bb = bb + 3 + wstep;
|
||||
|
||||
bb.c->barleft = c->barleft;
|
||||
bb.c->barright = c->barright;
|
||||
if(!mirrorwall(bb.c))
|
||||
bb.c->landparam = ht ^ 2;
|
||||
bb.at->barleft = c->barleft;
|
||||
bb.at->barright = c->barright;
|
||||
if(!mirrorwall(bb.at))
|
||||
bb.at->landparam = ht ^ 2;
|
||||
}
|
||||
|
||||
//printf("[C heat %d]\n", (ht)^2);
|
||||
bb.c->bardir = bb.spin;
|
||||
bb.c->barleft = c->barright;
|
||||
bb.c->barright = c->barleft;
|
||||
bb.at->bardir = bb.spin;
|
||||
bb.at->barleft = c->barright;
|
||||
bb.at->barright = c->barleft;
|
||||
// printf("#1\n");
|
||||
extendcheck(bb.c);
|
||||
extendBarrier(bb.c);
|
||||
extendcheck(bb.at);
|
||||
extendBarrier(bb.at);
|
||||
|
||||
for(int a=-3; a<=3; a++) if(a) {
|
||||
bb.c = c; bb.spin = c->bardir; bb += (nonbitrunc?-a:a); bb += wstep;
|
||||
setland(bb.c, a > 0 ? c->barright : c->barleft);
|
||||
bb.at = c; bb.spin = c->bardir; bb += (nonbitrunc?-a:a); bb += wstep;
|
||||
setland(bb.at, a > 0 ? c->barright : c->barleft);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,30 +220,30 @@ void extendBarrierBack(cell *c) {
|
||||
int ht = c->landparam;
|
||||
extendcheck(c);
|
||||
|
||||
cellwalker bb(c, c->bardir); setbarrier(bb.c);
|
||||
cellwalker bb(c, c->bardir); setbarrier(bb.at);
|
||||
bb = bb + 3 + wstep + (nonbitrunc?5:4);
|
||||
setland(bb.c, nonbitrunc ? c->barleft : c->barright);
|
||||
setland(bb.at, nonbitrunc ? c->barleft : c->barright);
|
||||
bb = bb + wstep + 3;
|
||||
bb.c->bardir = bb.spin;
|
||||
bb.c->barleft = c->barright;
|
||||
bb.c->barright = c->barleft;
|
||||
if(!mirrorwall(bb.c))
|
||||
bb.c->landparam = ht ^ 11;
|
||||
extendcheck(bb.c);
|
||||
bb.at->bardir = bb.spin;
|
||||
bb.at->barleft = c->barright;
|
||||
bb.at->barright = c->barleft;
|
||||
if(!mirrorwall(bb.at))
|
||||
bb.at->landparam = ht ^ 11;
|
||||
extendcheck(bb.at);
|
||||
//printf("[D heat %d]\n", (ht^11));
|
||||
|
||||
// needed for CR2 to work
|
||||
if(!nonbitrunc) {
|
||||
auto bb2 = bb + wstep;
|
||||
bb2.c->barleft = c->barright;
|
||||
bb2.c->barright = c->barleft;
|
||||
if(!mirrorwall(bb2.c))
|
||||
bb2.c->landparam = (ht^11)-4;
|
||||
bb2.at->barleft = c->barright;
|
||||
bb2.at->barright = c->barleft;
|
||||
if(!mirrorwall(bb2.at))
|
||||
bb2.at->landparam = (ht^11)-4;
|
||||
}
|
||||
//printf("[E heat %d]\n", (ht^11));
|
||||
|
||||
// printf("#2\n");
|
||||
extendBarrier(bb.c);
|
||||
extendBarrier(bb.at);
|
||||
}
|
||||
|
||||
void extendNowall(cell *c) {
|
||||
@ -255,14 +255,14 @@ void extendNowall(cell *c) {
|
||||
|
||||
if(warpv) {
|
||||
cw += wstep;
|
||||
setland(cw.c, c->barright);
|
||||
setland(cw.at, c->barright);
|
||||
}
|
||||
else if(S3 == 4) {
|
||||
auto cw2 = cw + wstep;
|
||||
setland(cw2.c, c->barright);
|
||||
cw2.c->barleft = NOWALLSEP_USED;
|
||||
cw2.c->barright = c->land;
|
||||
cw2.c->bardir = cw2.spin;
|
||||
setland(cw2.at, c->barright);
|
||||
cw2.at->barleft = NOWALLSEP_USED;
|
||||
cw2.at->barright = c->land;
|
||||
cw2.at->bardir = cw2.spin;
|
||||
}
|
||||
|
||||
for(int i=-1; i<2; i+=2) {
|
||||
@ -277,26 +277,26 @@ void extendNowall(cell *c) {
|
||||
cw0 = cw + (i>0?3:4) + wstep - (i>0?3:4);
|
||||
//cw0 = cw + (3*i) + wstep - (3*i);
|
||||
}
|
||||
if(cw0.c->barleft != NOWALLSEP_USED) {
|
||||
cw0.c->barleft = NOWALLSEP;
|
||||
if(cw0.at->barleft != NOWALLSEP_USED) {
|
||||
cw0.at->barleft = NOWALLSEP;
|
||||
if(S3 == 4 && nonbitrunc) {
|
||||
cw0.c->barright = c->barright;
|
||||
cw0.c->bardir = cw0.spin;
|
||||
setland(cw0.c, c->land);
|
||||
cw0.at->barright = c->barright;
|
||||
cw0.at->bardir = cw0.spin;
|
||||
setland(cw0.at, c->land);
|
||||
}
|
||||
else {
|
||||
setland(cw0.c, c->barright);
|
||||
cw0.c->barright = c->land;
|
||||
setland(cw0.at, c->barright);
|
||||
cw0.at->barright = c->land;
|
||||
if(c->barright == laNone) {
|
||||
printf("barright\n");
|
||||
}// NONEDEBUG
|
||||
setland(cw0.c, c->barright);
|
||||
setland(cw0.at, c->barright);
|
||||
if(warpv) cw0 += i;
|
||||
cw0.c->bardir = cw0.spin;
|
||||
cw0.at->bardir = cw0.spin;
|
||||
if(warpv) cw0 -= i;
|
||||
}
|
||||
extendcheck(cw0.c);
|
||||
extendBarrier(cw0.c);
|
||||
extendcheck(cw0.at);
|
||||
extendBarrier(cw0.at);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,19 +312,19 @@ void extendCR5(cell *c) {
|
||||
for(int u=0; u<2; u++) {
|
||||
// if(gotit) break;
|
||||
cw = cw + 2 + wstep + 2 + wstep + 5;
|
||||
if(cw.c->bardir == NODIR) {
|
||||
cw.c->landparam = 40;
|
||||
cw.c->bardir = cw.spin;
|
||||
cw.c->barright = laCrossroads5;
|
||||
if(cw.at->bardir == NODIR) {
|
||||
cw.at->landparam = 40;
|
||||
cw.at->bardir = cw.spin;
|
||||
cw.at->barright = laCrossroads5;
|
||||
eLand nland = forbidden;
|
||||
for(int i=0; i<10 && (nland == forbidden || nland == forbidden2); i++)
|
||||
nland = getNewLand(laCrossroads5);
|
||||
cw.c->barleft = forbidden2 = nland;
|
||||
cw.at->barleft = forbidden2 = nland;
|
||||
landcount[nland]++;
|
||||
extendBarrier(cw.c);
|
||||
extendBarrier(cw.at);
|
||||
gotit = true;
|
||||
}
|
||||
else forbidden2 = cw.c->barleft;
|
||||
else forbidden2 = cw.at->barleft;
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ void extendBarrier(cell *c) {
|
||||
if(firstmirror && c->barleft == laMirror && hrand(100) < 60) {
|
||||
cellwalker cw(c, c->bardir);
|
||||
if(!nonbitrunc) cw += wstep;
|
||||
if(cw.c->land != laMirrorWall)
|
||||
if(cw.at->land != laMirrorWall)
|
||||
if(buildBarrier6(cw, 1)) return;
|
||||
}
|
||||
|
||||
@ -390,9 +390,9 @@ void extendBarrier(cell *c) {
|
||||
cellwalker cw(c, c->bardir);
|
||||
if(nonbitrunc) {
|
||||
cw += wstep;
|
||||
if(isbar4(cw.c)) {
|
||||
if(isbar4(cw.at)) {
|
||||
cw = cw + wstep + 3 + wstep - 1 + wstep;
|
||||
bool b = buildBarrier4(cw.c, cw.spin, 2, oppositeElement(c->barleft, c->barright), c->barright);
|
||||
bool b = buildBarrier4(cw.at, cw.spin, 2, oppositeElement(c->barleft, c->barright), c->barright);
|
||||
if(b) return;
|
||||
}
|
||||
else {
|
||||
@ -402,10 +402,10 @@ void extendBarrier(cell *c) {
|
||||
}
|
||||
else {
|
||||
cw = cw + 3 + wstep;
|
||||
cell *cp = (cw + 4 + wstep).c;
|
||||
cell *cp = (cw + 4 + wstep).at;
|
||||
if(!isbar4(cp)) {
|
||||
cw = cw + 2 + wstep;
|
||||
bool b = buildBarrier4(cw.c, cw.spin, 2, oppositeElement(c->barleft, c->barright), c->barright);
|
||||
bool b = buildBarrier4(cw.at, cw.spin, 2, oppositeElement(c->barleft, c->barright), c->barright);
|
||||
if(b) return;
|
||||
}
|
||||
else {
|
||||
@ -445,7 +445,7 @@ void buildBarrier(cell *c, int d, eLand l) {
|
||||
}
|
||||
|
||||
bool buildBarrier6(cellwalker cw, int type) {
|
||||
limitgen("build6 %p/%d (%d)\n", cw.c, cw.spin, type);
|
||||
limitgen("build6 %p/%d (%d)\n", cw.at, cw.spin, type);
|
||||
|
||||
cellwalker b[4];
|
||||
|
||||
@ -463,18 +463,18 @@ bool buildBarrier6(cellwalker cw, int type) {
|
||||
b[2] = cw - 2 + wstep - 3;
|
||||
b[3] = cw - 3 + wstep + 2 + wstep - 3;
|
||||
|
||||
if(type == 1 && b[3].c->land != laMirrorWall) return false;
|
||||
if(type == 2 && (b[1] + wstep).c->land != laMirrorWall) return false;
|
||||
// if(type == 2 && b[2].c->land != laMirrorWall) return false;
|
||||
if(type == 1 && b[3].at->land != laMirrorWall) return false;
|
||||
if(type == 2 && (b[1] + wstep).at->land != laMirrorWall) return false;
|
||||
// if(type == 2 && b[2].at->land != laMirrorWall) return false;
|
||||
}
|
||||
|
||||
if(false) {
|
||||
for(int z=0; z<4; z++) {
|
||||
printf("%p/%d\n", b[z].c, b[z].spin);
|
||||
b[z].c->wall = waStrandedBoat; b[z].c->land = laAlchemist;
|
||||
b[z].c->mondir = b[z].spin;
|
||||
b[z].c->mpdist = 7;
|
||||
b[z].c->item = eItem(1+z);
|
||||
printf("%p/%d\n", b[z].at, b[z].spin);
|
||||
b[z].at->wall = waStrandedBoat; b[z].at->land = laAlchemist;
|
||||
b[z].at->mondir = b[z].spin;
|
||||
b[z].at->mpdist = 7;
|
||||
b[z].at->item = eItem(1+z);
|
||||
buggyGeneration = true;
|
||||
}
|
||||
return true;
|
||||
@ -490,66 +490,66 @@ bool buildBarrier6(cellwalker cw, int type) {
|
||||
}
|
||||
|
||||
for(int d=0; d<4; d++) {
|
||||
b[d].c->bardir = b[d].spin;
|
||||
b[d].at->bardir = b[d].spin;
|
||||
|
||||
if(nonbitrunc) {
|
||||
b[0].c->barleft = laMirrored, b[0].c->barright = laMirrored2;
|
||||
b[1].c->barleft = laMirror, b[1].c->barright = laMirrored;
|
||||
b[2].c->barleft = laMirrored2, b[2].c->barright = laMirrored;
|
||||
b[3].c->barleft = laMirrored, b[3].c->barright = laMirror;
|
||||
b[0].at->barleft = laMirrored, b[0].at->barright = laMirrored2;
|
||||
b[1].at->barleft = laMirror, b[1].at->barright = laMirrored;
|
||||
b[2].at->barleft = laMirrored2, b[2].at->barright = laMirrored;
|
||||
b[3].at->barleft = laMirrored, b[3].at->barright = laMirror;
|
||||
}
|
||||
else {
|
||||
b[0].c->barleft = laMirror, b[0].c->barright = laMirrored;
|
||||
b[1].c->barleft = laMirrored, b[1].c->barright = laMirror;
|
||||
b[2].c->barleft = laMirrored, b[2].c->barright = laMirrored2;
|
||||
b[3].c->barleft = laMirrored2, b[3].c->barright = laMirrored;
|
||||
b[0].at->barleft = laMirror, b[0].at->barright = laMirrored;
|
||||
b[1].at->barleft = laMirrored, b[1].at->barright = laMirror;
|
||||
b[2].at->barleft = laMirrored, b[2].at->barright = laMirrored2;
|
||||
b[3].at->barleft = laMirrored2, b[3].at->barright = laMirrored;
|
||||
}
|
||||
|
||||
(nonbitrunc?extendBarrierFront:extendBarrierBack)(b[d].c);
|
||||
(nonbitrunc?extendBarrierFront:extendBarrierBack)(b[d].at);
|
||||
}
|
||||
|
||||
if(nonbitrunc && false) {
|
||||
for(int z=0; z<4; z++)
|
||||
b[z].c->item = eItem(1+z+4*type);
|
||||
b[z].at->item = eItem(1+z+4*type);
|
||||
for(int a=0; a<4; a++)
|
||||
extendBarrierBack((b[a]+wstep).c);
|
||||
extendBarrierBack((b[a]+wstep).at);
|
||||
}
|
||||
|
||||
if(!nonbitrunc) {
|
||||
setland((cw+1+wstep).c, laMirrorWall);
|
||||
setland((cw+2+wstep).c, laMirrored);
|
||||
setland((cw+3+wstep).c, laMirrorWall2);
|
||||
setland((cw+4+wstep).c, laMirrorWall2);
|
||||
setland((cw+5+wstep).c, laMirrored);
|
||||
setland((cw+0+wstep).c, laMirrorWall);
|
||||
setland((b[0]+2+wstep).c, laMirrored);
|
||||
setland((b[3]+6+wstep).c, laMirrored2);
|
||||
setland((b[3]+5+wstep).c, laMirrored2);
|
||||
setland((b[1]-1+wstep).c, laMirrored);
|
||||
setland((b[2]-2+wstep).c, laMirrored);
|
||||
setland((b[1]-2+wstep).c, laMirrored);
|
||||
setland((b[0]-2+wstep).c, laMirror);
|
||||
cw.c->land = laMirrorWall;
|
||||
cw.c->wall = waMirrorWall;
|
||||
cw.c->landparam = 1;
|
||||
setland((cw+1).cpeek(), laMirrorWall);
|
||||
setland((cw+2).cpeek(), laMirrored);
|
||||
setland((cw+3).cpeek(), laMirrorWall2);
|
||||
setland((cw+4).cpeek(), laMirrorWall2);
|
||||
setland((cw+5).cpeek(), laMirrored);
|
||||
setland((cw+0).cpeek(), laMirrorWall);
|
||||
setland((b[0]+2).cpeek(), laMirrored);
|
||||
setland((b[3]+6).cpeek(), laMirrored2);
|
||||
setland((b[3]+5).cpeek(), laMirrored2);
|
||||
setland((b[1]-1).cpeek(), laMirrored);
|
||||
setland((b[2]-2).cpeek(), laMirrored);
|
||||
setland((b[1]-2).cpeek(), laMirrored);
|
||||
setland((b[0]-2).cpeek(), laMirror);
|
||||
cw.at->land = laMirrorWall;
|
||||
cw.at->wall = waMirrorWall;
|
||||
cw.at->landparam = 1;
|
||||
}
|
||||
else {
|
||||
setland(cw.c, laMirrorWall2);
|
||||
setland((cw+0+wstep).c, laMirrorWall2);
|
||||
setland((cw+1+wstep).c, laMirrored);
|
||||
setland((cw+2+wstep).c, laMirrored);
|
||||
setland((cw+3+wstep).c, laMirrorWall);
|
||||
setland((cw+4+wstep).c, laMirrored);
|
||||
setland((cw+5+wstep).c, laMirrorWall2);
|
||||
setland((cw+6+wstep).c, laMirrored2);
|
||||
setland(cw.at, laMirrorWall2);
|
||||
setland((cw+0).cpeek(), laMirrorWall2);
|
||||
setland((cw+1).cpeek(), laMirrored);
|
||||
setland((cw+2).cpeek(), laMirrored);
|
||||
setland((cw+3).cpeek(), laMirrorWall);
|
||||
setland((cw+4).cpeek(), laMirrored);
|
||||
setland((cw+5).cpeek(), laMirrorWall2);
|
||||
setland((cw+6).cpeek(), laMirrored2);
|
||||
|
||||
setland((b[1]+wstep).c, laMirrorWall);
|
||||
setland((b[1]+1+wstep).c, laMirror);
|
||||
setland((b[1]+2+wstep).c, laMirrorWall);
|
||||
setland((b[1]+6+wstep).c, laMirrored);
|
||||
setland((b[1]).cpeek(), laMirrorWall);
|
||||
setland((b[1]+1).cpeek(), laMirror);
|
||||
setland((b[1]+2).cpeek(), laMirrorWall);
|
||||
setland((b[1]+6).cpeek(), laMirrored);
|
||||
|
||||
setland((b[0] + wstep - 2 + wstep).c, laMirrored);
|
||||
setland((b[3] + wstep - 2 + wstep).c, laMirrored);
|
||||
setland((b[0] + wstep - 2).cpeek(), laMirrored);
|
||||
setland((b[3] + wstep - 2).cpeek(), laMirrored);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -589,29 +589,29 @@ bool buildBarrier4(cell *c, int d, int mode, eLand ll, eLand lr) {
|
||||
|
||||
c->bardir = d, c->barleft = ll, c->barright = lr; extendBarrierBack(c);
|
||||
|
||||
c= b2.c; d=b2.spin;
|
||||
c= b2.at; d=b2.spin;
|
||||
c->bardir = d, c->barleft = xl, c->barright = xr; extendBarrierBack(c);
|
||||
|
||||
c= b3.c; d=b3.spin;
|
||||
c= b3.at; d=b3.spin;
|
||||
c->bardir = d, c->barleft = xl, c->barright = lr; extendBarrierFront(c);
|
||||
|
||||
c= b4.c; d=b4.spin;
|
||||
c= b4.at; d=b4.spin;
|
||||
c->bardir = d, c->barleft = ll, c->barright = xr; extendBarrierFront(c);
|
||||
|
||||
if(!nonbitrunc) for(int a=-3; a<=3; a++) if(a) {
|
||||
setland((b1+a+wstep).c, a > 0 ? lr : ll);
|
||||
setland((b2+a+wstep).c, a > 0 ? xr : xl);
|
||||
setland((b3+a+wstep).c, a > 0 ? lr : xl);
|
||||
setland((b4+a+wstep).c, a > 0 ? xr : ll);
|
||||
setland((b1+a).cpeek(), a > 0 ? lr : ll);
|
||||
setland((b2+a).cpeek(), a > 0 ? xr : xl);
|
||||
setland((b3+a).cpeek(), a > 0 ? lr : xl);
|
||||
setland((b4+a).cpeek(), a > 0 ? xr : ll);
|
||||
}
|
||||
|
||||
if(nonbitrunc) setbarrier(b1.c), setbarrier(b2.c), setbarrier(b3.c), setbarrier(b4.c);
|
||||
if(nonbitrunc) setbarrier(b1.at), setbarrier(b2.at), setbarrier(b3.at), setbarrier(b4.at);
|
||||
|
||||
if(!nonbitrunc) {
|
||||
cell *cp;
|
||||
cp = (b1+wstep).c;
|
||||
cp = (b1+wstep).at;
|
||||
cp->barleft = ll; cp->barright = lr; setbarrier(cp);
|
||||
cp = (b2+wstep).c;
|
||||
cp = (b2+wstep).at;
|
||||
cp->barleft = xl; cp->barright = xr; setbarrier(cp);
|
||||
}
|
||||
|
||||
@ -628,7 +628,7 @@ void buildBarrierStrong(cell *c, int d, bool oldleft, eLand newland) {
|
||||
|
||||
if(oldleft) c->barleft = oldland, c->barright = newland;
|
||||
else c->barleft = newland, c->barright = oldland;
|
||||
extendcheck(bb.c);
|
||||
extendcheck(bb.at);
|
||||
}
|
||||
|
||||
void buildBarrierStrong(cell *c, int d, bool oldleft) {
|
||||
@ -642,8 +642,8 @@ void buildCrossroads2(cell *c) {
|
||||
if(!c) return;
|
||||
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && !c->mov[i]->landparam && c->mov[i]->mpdist < c->mpdist)
|
||||
buildCrossroads2(c->mov[i]);
|
||||
if(c->move(i) && !c->move(i)->landparam && c->move(i)->mpdist < c->mpdist)
|
||||
buildCrossroads2(c->move(i));
|
||||
|
||||
if(hasbardir(c))
|
||||
extendBarrier(c);
|
||||
@ -656,7 +656,7 @@ void buildCrossroads2(cell *c) {
|
||||
if(c2 && c2->landparam && (c2->land == laCrossroads2 || c2->land == laBarrier)) {
|
||||
for(int j=0; j<c2->type; j++) {
|
||||
createMov(c2, j);
|
||||
cell *c3 = c2->mov[j];
|
||||
cell *c3 = c2->move(j);
|
||||
if(c3 && c3->landparam && (c3->land == laCrossroads2 || c3->land == laBarrier)) {
|
||||
int h2 = c2->landparam;
|
||||
int h3 = c3->landparam;
|
||||
@ -670,7 +670,7 @@ void buildCrossroads2(cell *c) {
|
||||
|
||||
for(int d=0; d<c2->type; d++)
|
||||
if(emeraldtable[h2][d] == h3) {
|
||||
int nh = emeraldtable[h2][(42+d + c->spn(i) - j) % c2->type];
|
||||
int nh = emeraldtable[h2][(42+d + c->c.spin(i) - j) % c2->type];
|
||||
if(c->landparam>0 && c->landparam != nh) {
|
||||
printf("CONFLICT\n");
|
||||
raiseBuggyGeneration(c, "CONFLICT");
|
||||
@ -694,7 +694,7 @@ void buildCrossroads2(cell *c) {
|
||||
|
||||
if(c->landparam) {
|
||||
// for(int i=0; i<c->type; i++) {
|
||||
// cell *c2 = c->mov[i];
|
||||
// cell *c2 = c->move(i);
|
||||
// buildCrossroads2(c2);
|
||||
// }
|
||||
}
|
||||
@ -715,10 +715,10 @@ void buildCrossroads2(cell *c) {
|
||||
}
|
||||
if(h/4 == 8 || h/4 == 10)
|
||||
for(int i=0; i<c->type; i++) {
|
||||
if(c->mov[i] && c->mov[i]->landparam == h-4) {
|
||||
if(c->move(i) && c->move(i)->landparam == h-4) {
|
||||
bool oldleft = true;
|
||||
for(int j=1; j<=3; j++)
|
||||
if(c->mov[(i+j)%7] && c->mov[(i+j)%7]->mpdist < c->mpdist)
|
||||
if(c->modmove(i+j) && c->modmove(i+j)->mpdist < c->mpdist)
|
||||
oldleft = false;
|
||||
|
||||
c->landparam = h;
|
||||
@ -749,8 +749,8 @@ bool buildBarrierNowall(cell *c, eLand l2, int forced_dir) {
|
||||
int d = forced_dir != NODIR ? forced_dir : (S3>3 && nonbitrunc && !gp::on) ? (2+(i&1)) : ds[i];
|
||||
/* if(warpv && gp::on) {
|
||||
d = hrand(c->type); */
|
||||
if(warpv && c->mov[d] && c->mov[d]->mpdist < c->mpdist) continue;
|
||||
if(gp::on && a4 && c->mov[d] && c->mov[d]->mpdist <= c->mpdist) continue;
|
||||
if(warpv && c->move(d) && c->move(d)->mpdist < c->mpdist) continue;
|
||||
if(gp::on && a4 && c->move(d) && c->move(d)->mpdist <= c->mpdist) continue;
|
||||
/* }
|
||||
else
|
||||
d = (S3>3 && !warpv) ? (2+(i&1)) : dtab[i]; */
|
||||
|
142
bigstuff.cpp
142
bigstuff.cpp
@ -106,7 +106,7 @@ bool grailWasFound(cell *c) {
|
||||
void generateAlts(heptagon *h, int levs, bool link_cdata) {
|
||||
if(!h->alt) return;
|
||||
preventbarriers(h->c7);
|
||||
for(int i=0; i<S7; i++) preventbarriers(h->c7->mov[i]);
|
||||
for(int i=0; i<S7; i++) preventbarriers(h->c7->move(i));
|
||||
if(gp::on)
|
||||
for(int i=0; i<S7; i++) preventbarriers(createStep(h, i)->c7);
|
||||
for(int i=0; i<S7; i++)
|
||||
@ -116,7 +116,7 @@ void generateAlts(heptagon *h, int levs, bool link_cdata) {
|
||||
else {
|
||||
for(int j=0; j<S7; j++) for(int i=0; i<S7; i++) {
|
||||
createStep(h, i);
|
||||
if(h->move[i]->alt == h->alt->move[j]) {
|
||||
if(h->move(i)->alt == h->alt->move(j)) {
|
||||
relspin = (i-j+S7) % S7;
|
||||
break;
|
||||
}
|
||||
@ -124,9 +124,9 @@ void generateAlts(heptagon *h, int levs, bool link_cdata) {
|
||||
if(relspin == -4 && geometry != gFieldQuotient) {
|
||||
if(h->alt != h->alt->alt) {
|
||||
printf("relspin {%p:%p}\n", h->alt, h->alt->alt);
|
||||
{for(int i=0; i<S7; i++) printf("%p ", h->alt->move[i]);} printf(" ALT\n");
|
||||
{for(int i=0; i<S7; i++) printf("%p ", h->move[i]);} printf(" REAL\n");
|
||||
{for(int i=0; i<S7; i++) printf("%p ", h->move[i]->alt);} printf(" REAL ALT\n");
|
||||
{for(int i=0; i<S7; i++) printf("%p ", h->alt->move(i));} printf(" ALT\n");
|
||||
{for(int i=0; i<S7; i++) printf("%p ", h->move(i));} printf(" REAL\n");
|
||||
{for(int i=0; i<S7; i++) printf("%p ", h->move(i)->alt);} printf(" REAL ALT\n");
|
||||
}
|
||||
relspin = 3;
|
||||
} }
|
||||
@ -134,7 +134,7 @@ void generateAlts(heptagon *h, int levs, bool link_cdata) {
|
||||
//printf("{%d~%d}\n", h->distance, h->alt->distance);
|
||||
for(int i=0; i<S7; i++) {
|
||||
int ir = (S7+i-relspin)%S7;
|
||||
heptagon *hm = h->alt->move[ir];
|
||||
heptagon *hm = h->alt->move(ir);
|
||||
heptagon *ho = createStep(h, i);
|
||||
// printf("[%p:%d ~ %p:%d] %p ~ %p\n",
|
||||
// h, i, h->alt, ir,
|
||||
@ -157,7 +157,7 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) {
|
||||
// check for direction
|
||||
int gdir = -1;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
if(c->mov[i] && c->mov[i]->mpdist < c->mpdist) gdir = i;
|
||||
if(c->move(i) && c->move(i)->mpdist < c->mpdist) gdir = i;
|
||||
}
|
||||
if(gdir < 0) return NULL;
|
||||
|
||||
@ -182,11 +182,11 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) {
|
||||
cellwalker bf(c, gdir);
|
||||
std::vector<cell *> cx(rad+1);
|
||||
for(int i=0; i<rad; i++) {
|
||||
cx[i] = bf.c;
|
||||
cx[i] = bf.at;
|
||||
bf += revstep;
|
||||
}
|
||||
cx[rad] = bf.c;
|
||||
heptagon *h = bf.c->master;
|
||||
cx[rad] = bf.at;
|
||||
heptagon *h = bf.at->master;
|
||||
|
||||
if(h->alt) {
|
||||
printf("Error: creatingAlternateMap while one already exists\n");
|
||||
@ -196,7 +196,7 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) {
|
||||
if(special == waPalace) {
|
||||
|
||||
// type 7 is ensured
|
||||
cell *c = bf.c;
|
||||
cell *c = bf.at;
|
||||
|
||||
if(cdist50(c) != 0) return NULL;
|
||||
if(polarb50(c) != 1) return NULL;
|
||||
@ -208,7 +208,7 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) {
|
||||
alt->s = firststate;
|
||||
alt->emeraldval = 0;
|
||||
alt->zebraval = 0;
|
||||
for(int i=0; i<MAX_EDGE; i++) alt->move[i] = NULL;
|
||||
for(int i=0; i<MAX_EDGE; i++) alt->move(i) = NULL;
|
||||
alt->distance = 0;
|
||||
alt->c7 = NULL;
|
||||
alt->alt = alt;
|
||||
@ -222,7 +222,7 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) {
|
||||
|
||||
if(special == waPalace) {
|
||||
|
||||
cell *c = bf.c;
|
||||
cell *c = bf.at;
|
||||
|
||||
princess::generating = true;
|
||||
c->land = laPalace;
|
||||
@ -233,7 +233,7 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) {
|
||||
princess::newInfo(c);
|
||||
princess::forceMouse = false;
|
||||
|
||||
if(princess::gotoPrincess && cheater) princess::gotoPrincess=false, cwt.c = c;
|
||||
if(princess::gotoPrincess && cheater) princess::gotoPrincess=false, cwt.at = c;
|
||||
}
|
||||
|
||||
return alt;
|
||||
@ -284,7 +284,7 @@ void generateTreasureIsland(cell *c) {
|
||||
}
|
||||
if(!qc) {
|
||||
printf("NO QC\n"); c->wall = waSea;
|
||||
for(int i=0; i<c->type; i++) printf("%d ", celldistAlt(c->mov[i]));
|
||||
for(int i=0; i<c->type; i++) printf("%d ", celldistAlt(c->move(i)));
|
||||
printf("vs %d\n", celldistAlt(c));
|
||||
return;
|
||||
}
|
||||
@ -317,42 +317,42 @@ bool generatingEquidistant = false;
|
||||
cell *buildAnotherEquidistant(cell *c, int radius) {
|
||||
int gdir = -1;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
if(c->mov[i] && c->mov[i]->mpdist < c->mpdist) gdir = i;
|
||||
if(c->move(i) && c->move(i)->mpdist < c->mpdist) gdir = i;
|
||||
}
|
||||
if(gdir == -1) return NULL;
|
||||
|
||||
cellwalker cw(c, (gdir+3) % c->type);
|
||||
vector<cell*> coastpath;
|
||||
|
||||
while(isize(coastpath) < radius || (cw.c->type != 7 && !weirdhyperbolic)) {
|
||||
while(isize(coastpath) < radius || (cw.at->type != 7 && !weirdhyperbolic)) {
|
||||
// this leads to bugs for some reason!
|
||||
if(cw.c->land == laCrossroads2) {
|
||||
if(cw.at->land == laCrossroads2) {
|
||||
#ifdef AUTOPLAY
|
||||
if(doAutoplay) printf("avoiding the Crossroads II\n"); // todo
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
if(cw.c->bardir != NODIR) return NULL;
|
||||
if(cw.c->landparam && cw.c->landparam < radius) return NULL;
|
||||
if(cw.at->bardir != NODIR) return NULL;
|
||||
if(cw.at->landparam && cw.at->landparam < radius) return NULL;
|
||||
|
||||
/* forCellEx(c2, cw.c) if(c2->bardir != NODIR) {
|
||||
/* forCellEx(c2, cw.at) if(c2->bardir != NODIR) {
|
||||
generatingEquidistant = false;
|
||||
return;
|
||||
} */
|
||||
coastpath.push_back(cw.c);
|
||||
if(cw.c->land == laNone && cw.c->mpdist <= 7) {
|
||||
raiseBuggyGeneration(cw.c, "landNone 1");
|
||||
coastpath.push_back(cw.at);
|
||||
if(cw.at->land == laNone && cw.at->mpdist <= 7) {
|
||||
raiseBuggyGeneration(cw.at, "landNone 1");
|
||||
for(int i=0; i<isize(coastpath); i++) coastpath[i]->item = itPirate;
|
||||
return NULL;
|
||||
}
|
||||
cw = cw + wstep + 3;
|
||||
if(ctof(cw.c) && hrand(2) == 0) cw++;
|
||||
if(ctof(cw.at) && hrand(2) == 0) cw++;
|
||||
}
|
||||
coastpath.push_back(cw.c);
|
||||
coastpath.push_back(cw.at);
|
||||
// printf("setdists\n");
|
||||
for(int i=1; i<isize(coastpath) - 1; i++) {
|
||||
if(coastpath[i-1]->land == laNone) {
|
||||
raiseBuggyGeneration(cwt.c, "landNone 3");
|
||||
raiseBuggyGeneration(cwt.at, "landNone 3");
|
||||
int mpd[10];
|
||||
for(int i=0; i<10; i++) mpd[i] = coastpath[i]->mpdist;
|
||||
{for(int i=0; i<10; i++) printf("%d ", mpd[i]);} printf("\n");
|
||||
@ -449,7 +449,7 @@ bool checkInTree(cell *c, int maxv) {
|
||||
if(!maxv) return false;
|
||||
if(c->landflags) return true;
|
||||
for(int t=0; t<c->type; t++)
|
||||
if(c->mov[t] && c->mov[t]->landparam < c->landparam && checkInTree(c->mov[t], maxv-1))
|
||||
if(c->move(t) && c->move(t)->landparam < c->landparam && checkInTree(c->move(t), maxv-1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -467,8 +467,8 @@ void buildEquidistant(cell *c) {
|
||||
if(!b) {
|
||||
printf("land missing at %p\n", c);
|
||||
describeCell(c);
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i])
|
||||
describeCell(c->mov[i]);
|
||||
for(int i=0; i<c->type; i++) if(c->move(i))
|
||||
describeCell(c->move(i));
|
||||
// buggycells.push_back(c);
|
||||
}
|
||||
if(b == laHauntedBorder) b = laGraveyard;
|
||||
@ -492,18 +492,18 @@ void buildEquidistant(cell *c) {
|
||||
int qcv = 0;
|
||||
int sid = 0;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(coastval(c->mov[i], b) == mcv)
|
||||
if(coastval(c->move(i), b) == mcv)
|
||||
qcv++, sid = i;
|
||||
|
||||
// if(generatingEquidistant) printf("qcv=%d mcv=%d\n", qcv, mcv);
|
||||
if(qcv >= 2) c->landparam = mcv+1; // (mcv == UNKNOWN ? UNKNOWN : mcv+1);
|
||||
else {
|
||||
// if(qcv != 1) { printf("qcv = %d\n", qcv); exit(1); }
|
||||
cell *c2 = c->mov[sid];
|
||||
int bsid = c->spn(sid);
|
||||
cell *c2 = c->move(sid);
|
||||
int bsid = c->c.spin(sid);
|
||||
for(int j=0; j<7; j++) {
|
||||
int q = (bsid+j+42) % c2->type;
|
||||
cell *c3 = c2->mov[q];
|
||||
cell *c3 = c2->move(q);
|
||||
if(coastval(c3, b) < mcv) {
|
||||
cell *c4 = createMovR(c2, bsid+1);
|
||||
if(c4->land == laNone && c2->mpdist <= BARLEV) setdist(c4, BARLEV, c2);
|
||||
@ -512,7 +512,7 @@ void buildEquidistant(cell *c) {
|
||||
break;
|
||||
}
|
||||
q = (bsid-j+MODFIXER) % c2->type;
|
||||
c3 = c2->mov[q];
|
||||
c3 = c2->move(q);
|
||||
if(coastval(c3, b) < mcv) {
|
||||
cell *c4 = createMovR(c2, bsid-1);
|
||||
if(c4->land == laNone && c2->mpdist <= BARLEV) setdist(c4, BARLEV, c2);
|
||||
@ -542,8 +542,8 @@ void buildEquidistant(cell *c) {
|
||||
if(c->landparam == 1 && ctof(c)) {
|
||||
for(int i=0; i<S7; i++) {
|
||||
int i1 = (i+1) % S7;
|
||||
if(c->mov[i] && c->mov[i]->land != laEndorian && c->mov[i]->land != laNone)
|
||||
if(c->mov[i1] && c->mov[i1]->land != laEndorian && c->mov[i1]->land != laNone) {
|
||||
if(c->move(i) && c->move(i)->land != laEndorian && c->move(i)->land != laNone)
|
||||
if(c->move(i1) && c->move(i1)->land != laEndorian && c->move(i1)->land != laNone) {
|
||||
c->landflags = 2;
|
||||
c->wall = waTrunk;
|
||||
}
|
||||
@ -555,18 +555,18 @@ void buildEquidistant(cell *c) {
|
||||
int i2 = (i+2) % S6;
|
||||
int i4 = (i+4) % S6;
|
||||
int i5 = (i+5) % S6;
|
||||
if(c->mov[i] && c->mov[i]->land == laBarrier && c->mov[i]->type == 7)
|
||||
if(c->mov[i1] && c->mov[i1]->land != laBarrier)
|
||||
if(c->mov[i2] && c->mov[i2]->land != laBarrier)
|
||||
if(c->mov[i4] && c->mov[i4]->land != laBarrier)
|
||||
if(c->mov[i5] && c->mov[i5]->land != laBarrier) {
|
||||
if(c->move(i) && c->move(i)->land == laBarrier && c->move(i)->type == 7)
|
||||
if(c->move(i1) && c->move(i1)->land != laBarrier)
|
||||
if(c->move(i2) && c->move(i2)->land != laBarrier)
|
||||
if(c->move(i4) && c->move(i4)->land != laBarrier)
|
||||
if(c->move(i5) && c->move(i5)->land != laBarrier) {
|
||||
c->landflags = 2;
|
||||
c->wall = waTrunk;
|
||||
}
|
||||
|
||||
if(c->mov[i] && c->mov[i]->land != laEndorian && c->mov[i]->land != laNone && c->mov[i]->type == 7)
|
||||
if(c->mov[i1] && c->mov[i1]->land != laEndorian && c->mov[i1]->land != laNone)
|
||||
if(c->mov[i5] && c->mov[i5]->land != laEndorian && c->mov[i5]->land != laNone) {
|
||||
if(c->move(i) && c->move(i)->land != laEndorian && c->move(i)->land != laNone && c->move(i)->type == 7)
|
||||
if(c->move(i1) && c->move(i1)->land != laEndorian && c->move(i1)->land != laNone)
|
||||
if(c->move(i5) && c->move(i5)->land != laEndorian && c->move(i5)->land != laNone) {
|
||||
c->landflags = 3;
|
||||
c->wall = waTrunk;
|
||||
}
|
||||
@ -574,19 +574,19 @@ void buildEquidistant(cell *c) {
|
||||
}
|
||||
else if(c->landparam > 1) {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2 && c2->landparam < c->landparam && c2->landflags) {
|
||||
bool ok = false;
|
||||
if(c2->landflags == 3)
|
||||
ok = true;
|
||||
else if(c2->landflags == 2) {
|
||||
ok = c->mov[(i+1)%c->type]->landparam != c->landparam-1
|
||||
&& c->mov[(i+c->type-1)%c->type]->landparam != c->landparam-1;
|
||||
ok = c->modmove(i+1)->landparam != c->landparam-1
|
||||
&& c->modmove(i-1)->landparam != c->landparam-1;
|
||||
}
|
||||
else for(int j=0; j<c2->type; j++) {
|
||||
cell *c3 = c2->mov[j];
|
||||
cell *c3 = c2->move(j);
|
||||
if(c3 && c3->landparam < c2->landparam && c3->landflags)
|
||||
if(c->spn(i) == (j+3)%c2->type || c->spn(i) == (j+c2->type-3)%c2->type)
|
||||
if(c->c.spin(i) == (j+3)%c2->type || c->c.spin(i) == (j+c2->type-3)%c2->type)
|
||||
ok = true;
|
||||
}
|
||||
if(ok) {
|
||||
@ -595,7 +595,7 @@ void buildEquidistant(cell *c) {
|
||||
}
|
||||
}
|
||||
if(c2 && c2->landparam < c->landparam && c2->landflags == 1 && ctof(c)) {
|
||||
cell *c3 = c->mov[(i+1)%7];
|
||||
cell *c3 = c->modmove(i+1);
|
||||
if(c3 && c3->landparam < c->landparam && c3->landflags == 1) {
|
||||
c->wall = waTrunk;
|
||||
c->landflags = 2;
|
||||
@ -630,8 +630,8 @@ cell *randomDown(cell *c) {
|
||||
cell *tab[MAX_EDGE];
|
||||
int q=0;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && coastval(c->mov[i], laIvoryTower) < coastval(c, laIvoryTower))
|
||||
tab[q++] = c->mov[i];
|
||||
if(c->move(i) && coastval(c->move(i), laIvoryTower) < coastval(c, laIvoryTower))
|
||||
tab[q++] = c->move(i);
|
||||
if(!q) return NULL;
|
||||
if(q==1) return tab[0];
|
||||
return tab[hrand(q)];
|
||||
@ -645,13 +645,13 @@ typedef int cellfunction(cell*);
|
||||
cell *chosenDown(cell *c, int which, int bonus, cellfunction* cf) {
|
||||
int d = (*cf)(c)-1;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
if(!c->mov[i]) createMov(c, i);
|
||||
if(c->mov[i]->mpdist > BARLEV && cf == coastvalEdge) setdist(c->mov[i], BARLEV, c);
|
||||
if(!c->move(i)) createMov(c, i);
|
||||
if(c->move(i)->mpdist > BARLEV && cf == coastvalEdge) setdist(c->move(i), BARLEV, c);
|
||||
|
||||
if((*cf)(c->mov[i]) == d) {
|
||||
if((*cf)(c->move(i)) == d) {
|
||||
int i2 = (i+which+S42)%c->type;
|
||||
createMov(c, i2);
|
||||
if((*cf)(c->mov[i2]) == d)
|
||||
if((*cf)(c->move(i2)) == d)
|
||||
return createMovR(c, i2+bonus);
|
||||
else return createMovR(c, i+bonus);
|
||||
}
|
||||
@ -664,7 +664,7 @@ int edgeDepth(cell *c) {
|
||||
if(c->land == laIvoryTower || c->land == laEndorian || c->land == laDungeon)
|
||||
return coastvalEdge(c);
|
||||
else if(c->land != laBarrier) {
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i] && c->mov[i]->land == laBarrier)
|
||||
for(int i=0; i<c->type; i++) if(c->move(i) && c->move(i)->land == laBarrier)
|
||||
return -20+c->cpdist;
|
||||
}
|
||||
return 0;
|
||||
@ -697,7 +697,7 @@ int towerval(cell *c, cellfunction* cf) {
|
||||
int under = 0;
|
||||
int cfc = (*cf)(c);
|
||||
for(int i=0; i<c->type; i++) {
|
||||
if(c->mov[i] && (*cf)(c->mov[i]) < cfc)
|
||||
if(c->move(i) && (*cf)(c->move(i)) < cfc)
|
||||
under++;
|
||||
}
|
||||
return (c->type-6) + 2*(cp1->type-6) + 4*under;
|
||||
@ -945,7 +945,7 @@ bool quickfind(eLand l) {
|
||||
int wallchance(cell *c, bool deepOcean) {
|
||||
eLand l = c->land;
|
||||
return
|
||||
showoff ? (cwt.c->mpdist > 7 ? 0 : 10000) :
|
||||
showoff ? (cwt.at->mpdist > 7 ? 0 : 10000) :
|
||||
inmirror(c) ? 0 :
|
||||
isGravityLand(l) ? 0 :
|
||||
generatingEquidistant ? 0 :
|
||||
@ -992,7 +992,7 @@ void buildBigStuff(cell *c, cell *from) {
|
||||
if(c->land == laOcean) {
|
||||
if(!from) deepOcean = true;
|
||||
else for(int i=0; i<from->type; i++) {
|
||||
cell *c2 = from->mov[i];
|
||||
cell *c2 = from->move(i);
|
||||
if(c2 && c2->land == laOcean && c2->landparam > 30) {
|
||||
deepOcean = true;
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ void buildBigStuff(cell *c, cell *from) {
|
||||
if(c->land == laGraveyard) {
|
||||
if(!from) deepOcean = true;
|
||||
else for(int i=0; i<from->type; i++) {
|
||||
cell *c2 = from->mov[i];
|
||||
cell *c2 = from->move(i);
|
||||
if(c2 && c2->landparam > HAUNTED_RADIUS+5)
|
||||
deepOcean = true;
|
||||
if(c2) forCellEx(c3, c2) if(c3 && c3->land == laGraveyard && c3->landparam > HAUNTED_RADIUS+5)
|
||||
@ -1018,7 +1018,7 @@ void buildBigStuff(cell *c, cell *from) {
|
||||
// buildgreatwalls
|
||||
|
||||
if(celldist(c) < 3 && !gp::on) {
|
||||
if(top_land && c == cwt.c->master->move[3]->c7) {
|
||||
if(top_land && c == cwt.at->master->move(3)->c7) {
|
||||
buildBarrierStrong(c, 6, true, top_land);
|
||||
}
|
||||
}
|
||||
@ -1217,7 +1217,7 @@ void moreBigStuff(cell *c) {
|
||||
if(d == 10) {
|
||||
if(weirdhyperbolic ? hrand(100) < 50 : pseudohept(c)) buildCamelotWall(c);
|
||||
else {
|
||||
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move[i]);
|
||||
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move(i));
|
||||
int q = 0;
|
||||
if(weirdhyperbolic) {
|
||||
for(int t=0; t<c->type; t++) createMov(c, t);
|
||||
@ -1228,7 +1228,7 @@ void moreBigStuff(cell *c) {
|
||||
else {
|
||||
for(int t=0; t<c->type; t++) {
|
||||
createMov(c, t);
|
||||
if(celldistAltRelative(c->mov[t]) == 10 && !pseudohept(c->mov[t])) q++;
|
||||
if(celldistAltRelative(c->move(t)) == 10 && !pseudohept(c->move(t))) q++;
|
||||
}
|
||||
}
|
||||
if(q == 1) buildCamelotWall(c);
|
||||
@ -1245,7 +1245,7 @@ void moreBigStuff(cell *c) {
|
||||
c2->wall = waTower, c2->wparam = 1;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<c->type; i++) if(celldistAltRelative(c->mov[i]) < d)
|
||||
for(int i=0; i<c->type; i++) if(celldistAltRelative(c->move(i)) < d)
|
||||
c->mondir = i;
|
||||
}
|
||||
}
|
||||
@ -1260,9 +1260,9 @@ void moreBigStuff(cell *c) {
|
||||
// roughly as many knights as table cells
|
||||
if(hrand(nonbitrunc ? 2618 : 1720) < 1000)
|
||||
c->monst = moKnight;
|
||||
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move[i]);
|
||||
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move(i));
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && celldistAltRelative(c->mov[i]) < d)
|
||||
if(c->move(i) && celldistAltRelative(c->move(i)) < d)
|
||||
c->mondir = (i+3) % 6;
|
||||
}
|
||||
if(tactic::on && d >= 2 && d <= 8 && hrand(1000) < 10)
|
||||
@ -1279,7 +1279,7 @@ void moreBigStuff(cell *c) {
|
||||
|
||||
if(chaosmode && c->land == laTemple) {
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(pseudohept(c) && c->mov[i] && c->mov[i]->land != laTemple)
|
||||
if(pseudohept(c) && c->move(i) && c->move(i)->land != laTemple)
|
||||
c->wall = waColumn;
|
||||
}
|
||||
|
||||
@ -1298,11 +1298,11 @@ void moreBigStuff(cell *c) {
|
||||
else if(pseudohept(c))
|
||||
c->wall = waColumn;
|
||||
else {
|
||||
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move[i]);
|
||||
if(!eubinary) for(int i=0; i<S7; i++) generateAlts(c->master->move(i));
|
||||
int q = 0;
|
||||
for(int t=0; t<c->type; t++) {
|
||||
createMov(c, t);
|
||||
if(celldistAlt(c->mov[t]) % TEMPLE_EACH == 0 && !ishept(c->mov[t])) q++;
|
||||
if(celldistAlt(c->move(t)) % TEMPLE_EACH == 0 && !ishept(c->move(t))) q++;
|
||||
}
|
||||
if(q == 2) c->wall = waColumn;
|
||||
}
|
||||
|
@ -63,15 +63,15 @@ namespace binary {
|
||||
}
|
||||
#endif
|
||||
// printf("}\n");
|
||||
if(h->move[d] && h->move[d] != h1) {
|
||||
if(h->move(d) && h->move(d) != h1) {
|
||||
printf("already connected to something else (1)\n");
|
||||
breakhere();
|
||||
}
|
||||
if(h1->move[d1] && h1->move[d1] != h) {
|
||||
if(h1->move(d1) && h1->move(d1) != h) {
|
||||
printf("already connected to something else (2)\n");
|
||||
breakhere();
|
||||
}
|
||||
connectHeptagons(h, d, h1, d1);
|
||||
h->c.connect(d, h1, d1, false);
|
||||
rec--;
|
||||
return h1;
|
||||
}
|
||||
@ -176,7 +176,7 @@ namespace binary {
|
||||
}
|
||||
|
||||
void draw() {
|
||||
draw_rec(viewctr.h->c7, 63, cview());
|
||||
draw_rec(viewctr.at->c7, 63, cview());
|
||||
}
|
||||
|
||||
transmatrix relative_matrix(heptagon *h2, heptagon *h1) {
|
||||
|
@ -70,7 +70,7 @@ void drawBlizzards() {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
int& qty = bc.qty[i];
|
||||
qty = 0;
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
auto bc2 = getbcell(c2);
|
||||
if(!bc2) continue;
|
||||
@ -106,7 +106,7 @@ void drawBlizzards() {
|
||||
bc.outid = 0;
|
||||
|
||||
for(int d=0; d<c->type; d++) for(int k=0; k<bc.qty[d]; k++) {
|
||||
auto& bc2 = *getbcell(c->mov[d]);
|
||||
auto& bc2 = *getbcell(c->move(d));
|
||||
auto& sball = *bc.outorder[bc.outid++];
|
||||
auto& sball2 = *bc2.inorder[bc2.inid++];
|
||||
sball.next = &sball2;
|
||||
|
283
cell.cpp
283
cell.cpp
@ -25,18 +25,11 @@ cell *newCell(int type, heptagon *master) {
|
||||
cell *c = new cell;
|
||||
c->type = type;
|
||||
c->master = master;
|
||||
for(int i=0; i<MAX_EDGE; i++) c->mov[i] = NULL;
|
||||
for(int i=0; i<MAX_EDGE; i++) c->move(i) = NULL;
|
||||
initcell(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
void merge(cell *c, int d, cell *c2, int d2, bool mirrored = false) {
|
||||
c->mov[d] = c2;
|
||||
tsetspin(c->spintable, d, d2 + (mirrored?8:0));
|
||||
c2->mov[d2] = c;
|
||||
tsetspin(c2->spintable, d2, d + (mirrored?8:0));
|
||||
}
|
||||
|
||||
struct cdata {
|
||||
int val[4];
|
||||
int bits;
|
||||
@ -68,8 +61,7 @@ hrmap_hyperbolic::hrmap_hyperbolic() {
|
||||
h.fieldval = 0;
|
||||
h.rval0 = h.rval1 = 0;
|
||||
h.cdata = NULL;
|
||||
for(int i=0; i<MAX_EDGE; i++) h.move[i] = NULL;
|
||||
h.spintable = 0;
|
||||
h.c.clear();
|
||||
h.alt = NULL;
|
||||
h.distance = 0;
|
||||
isnonbitrunc = nonbitrunc;
|
||||
@ -119,9 +111,8 @@ struct hrmap_spherical : hrmap {
|
||||
h.rval0 = h.rval1 = 0;
|
||||
h.alt = NULL;
|
||||
h.cdata = NULL;
|
||||
h.spintable = 0;
|
||||
h.c.clear();
|
||||
h.fieldval = i;
|
||||
for(int i=0; i<S7; i++) h.move[i] = NULL;
|
||||
if(!irr::on) h.c7 = newCell(S7, &h);
|
||||
}
|
||||
if(S7 == 5)
|
||||
@ -133,60 +124,60 @@ struct hrmap_spherical : hrmap {
|
||||
for(int i=0; i<3; i++) {
|
||||
int i1 = (i+1)%3;
|
||||
int i2 = (i+2)%3;
|
||||
dodecahedron[i]->move[0] = dodecahedron[i1];
|
||||
dodecahedron[i]->setspin(0, 1);
|
||||
dodecahedron[i]->move[1] = dodecahedron[i2];
|
||||
dodecahedron[i]->setspin(1, 0);
|
||||
dodecahedron[i]->move[2] = dodecahedron[i1];
|
||||
dodecahedron[i]->setspin(2, 3+8);
|
||||
dodecahedron[i]->move[3] = dodecahedron[i2];
|
||||
dodecahedron[i]->setspin(3, 2+8);
|
||||
dodecahedron[i]->move(0) = dodecahedron[i1];
|
||||
dodecahedron[i]->c.setspin(0, 1, false);
|
||||
dodecahedron[i]->move(1) = dodecahedron[i2];
|
||||
dodecahedron[i]->c.setspin(1, 0, false);
|
||||
dodecahedron[i]->move(2) = dodecahedron[i1];
|
||||
dodecahedron[i]->c.setspin(2, 3, true);
|
||||
dodecahedron[i]->move(3) = dodecahedron[i2];
|
||||
dodecahedron[i]->c.setspin(3, 2, true);
|
||||
}
|
||||
}
|
||||
else for(int i=0; i<S7; i++) {
|
||||
dodecahedron[0]->move[i] = dodecahedron[i+1];
|
||||
dodecahedron[0]->setspin(i, 0);
|
||||
dodecahedron[i+1]->move[0] = dodecahedron[0];
|
||||
dodecahedron[i+1]->setspin(0, i);
|
||||
dodecahedron[0]->move(i) = dodecahedron[i+1];
|
||||
dodecahedron[0]->c.setspin(i, 0, false);
|
||||
dodecahedron[i+1]->move(0) = dodecahedron[0];
|
||||
dodecahedron[i+1]->c.setspin(0, i, false);
|
||||
|
||||
dodecahedron[i+1]->move[1] = dodecahedron[(i+S7-1)%S7+1];
|
||||
dodecahedron[i+1]->setspin(1, S7-1);
|
||||
dodecahedron[i+1]->move[S7-1] = dodecahedron[(i+1)%S7+1];
|
||||
dodecahedron[i+1]->setspin(S7-1, 1);
|
||||
dodecahedron[i+1]->move(1) = dodecahedron[(i+S7-1)%S7+1];
|
||||
dodecahedron[i+1]->c.setspin(1, S7-1, false);
|
||||
dodecahedron[i+1]->move(S7-1) = dodecahedron[(i+1)%S7+1];
|
||||
dodecahedron[i+1]->c.setspin(S7-1, 1, false);
|
||||
|
||||
if(S7 == 5 && elliptic) {
|
||||
dodecahedron[i+1]->move[2] = dodecahedron[(i+2)%S7+1];
|
||||
dodecahedron[i+1]->setspin(2, 3 + 8);
|
||||
dodecahedron[i+1]->move[3] = dodecahedron[(i+3)%S7+1];
|
||||
dodecahedron[i+1]->setspin(3, 2 + 8);
|
||||
dodecahedron[i+1]->move(2) = dodecahedron[(i+2)%S7+1];
|
||||
dodecahedron[i+1]->c.setspin(2, 3, true);
|
||||
dodecahedron[i+1]->move(3) = dodecahedron[(i+3)%S7+1];
|
||||
dodecahedron[i+1]->c.setspin(3, 2, true);
|
||||
}
|
||||
|
||||
else if(S7 == 5) {
|
||||
dodecahedron[6]->move[i] = dodecahedron[7+i];
|
||||
dodecahedron[6]->setspin(i, 0);
|
||||
dodecahedron[7+i]->move[0] = dodecahedron[6];
|
||||
dodecahedron[7+i]->setspin(0, i);
|
||||
dodecahedron[6]->move(i) = dodecahedron[7+i];
|
||||
dodecahedron[6]->c.setspin(i, 0, false);
|
||||
dodecahedron[7+i]->move(0) = dodecahedron[6];
|
||||
dodecahedron[7+i]->c.setspin(0, i, false);
|
||||
|
||||
dodecahedron[i+7]->move[1] = dodecahedron[(i+4)%5+7];
|
||||
dodecahedron[i+7]->setspin(1, 4);
|
||||
dodecahedron[i+7]->move[4] = dodecahedron[(i+1)%5+7];
|
||||
dodecahedron[i+7]->setspin(4, 1);
|
||||
dodecahedron[i+7]->move(1) = dodecahedron[(i+4)%5+7];
|
||||
dodecahedron[i+7]->c.setspin(1, 4, false);
|
||||
dodecahedron[i+7]->move(4) = dodecahedron[(i+1)%5+7];
|
||||
dodecahedron[i+7]->c.setspin(4, 1, false);
|
||||
|
||||
dodecahedron[i+1]->move[2] = dodecahedron[7+(10-i)%5];
|
||||
dodecahedron[i+1]->setspin(2, 2);
|
||||
dodecahedron[7+(10-i)%5]->move[2] = dodecahedron[1+i];
|
||||
dodecahedron[7+(10-i)%5]->setspin(2, 2);
|
||||
dodecahedron[i+1]->move(2) = dodecahedron[7+(10-i)%5];
|
||||
dodecahedron[i+1]->c.setspin(2, 2, false);
|
||||
dodecahedron[7+(10-i)%5]->move(2) = dodecahedron[1+i];
|
||||
dodecahedron[7+(10-i)%5]->c.setspin(2, 2, false);
|
||||
|
||||
dodecahedron[i+1]->move[3] = dodecahedron[7+(9-i)%5];
|
||||
dodecahedron[i+1]->setspin(3, 3);
|
||||
dodecahedron[7+(9-i)%5]->move[3] = dodecahedron[i+1];
|
||||
dodecahedron[7+(9-i)%5]->setspin(3, 3);
|
||||
dodecahedron[i+1]->move(3) = dodecahedron[7+(9-i)%5];
|
||||
dodecahedron[i+1]->c.setspin(3, 3, false);
|
||||
dodecahedron[7+(9-i)%5]->move(3) = dodecahedron[i+1];
|
||||
dodecahedron[7+(9-i)%5]->c.setspin(3, 3, false);
|
||||
}
|
||||
if(S7 == 4) {
|
||||
dodecahedron[5]->move[3-i] = dodecahedron[i+1];
|
||||
dodecahedron[5]->setspin(3-i, 2);
|
||||
dodecahedron[i+1]->move[2] = dodecahedron[5];
|
||||
dodecahedron[i+1]->setspin(2, 3-i);
|
||||
dodecahedron[5]->move(3-i) = dodecahedron[i+1];
|
||||
dodecahedron[5]->c.setspin(3-i, 2, false);
|
||||
dodecahedron[i+1]->move(2) = dodecahedron[5];
|
||||
dodecahedron[i+1]->c.setspin(2, 3-i, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +201,7 @@ struct hrmap_spherical : hrmap {
|
||||
for(int i=0; i<spherecells(); i++) for(int k=0; k<S7; k++) {
|
||||
heptspin hs(dodecahedron[i], k, false);
|
||||
heptspin hs2 = hs + wstep + (S7-1) + wstep + (S7-1) + wstep + (S7-1);
|
||||
if(hs2.h != hs.h) printf("error %d,%d\n", i, k);
|
||||
if(hs2.at != hs.at) printf("error %d,%d\n", i, k);
|
||||
}
|
||||
for(int i=0; i<spherecells(); i++) verifycells(dodecahedron[i]);
|
||||
}
|
||||
@ -420,15 +411,15 @@ struct hrmap_torus : hrmap {
|
||||
int iv = id_to_vec(i);
|
||||
build_euclidean_moves(all[i], iv, [&] (int delta, int d, int d2) {
|
||||
auto im = vec_to_id_mirror(iv + delta);
|
||||
all[i]->mov[d] = all[im.first];
|
||||
tsetspin(all[i]->spintable, d, im.second);
|
||||
all[i]->move(d) = all[im.first];
|
||||
all[i]->c.setspin(d, im.second, false);
|
||||
});
|
||||
}
|
||||
for(cell *c: all) for(int d=0; d<c->type; d++) {
|
||||
cell *c2 = c->mov[d];
|
||||
cell *c2 = c->move(d);
|
||||
for(int d2=0; d2<c2->type; d2++)
|
||||
if(c2->mov[d2] == c)
|
||||
tsetspin(c->spintable, d, d2 + (8 * c->spin(d)));
|
||||
if(c2->move(d2) == c)
|
||||
c->c.setspin(d, d2, c->c.spin(d));
|
||||
}
|
||||
celllister cl(gamestart(), 100, 100000000, NULL);
|
||||
dists.resize(q);
|
||||
@ -510,7 +501,7 @@ cellwalker vec_to_cellwalker(int vec) {
|
||||
}
|
||||
|
||||
int cellwalker_to_vec(cellwalker cw) {
|
||||
int id = decodeId(cw.c->master);
|
||||
int id = decodeId(cw.at->master);
|
||||
if(!torus) return id;
|
||||
return torusconfig::id_to_vec(id, cw.mirrored);
|
||||
}
|
||||
@ -564,9 +555,9 @@ namespace quotientspace {
|
||||
|
||||
code get(heptspin hs) {
|
||||
code res;
|
||||
res.c[0] = cod(hs.h);
|
||||
res.c[0] = cod(hs.at);
|
||||
for(int i=1; i<=S7; i++) {
|
||||
res.c[i] = cod((hs + wstep).h);
|
||||
res.c[i] = cod((hs + wstep).at);
|
||||
hs += 1;
|
||||
}
|
||||
return res;
|
||||
@ -612,7 +603,7 @@ struct hrmap_quotient : hrmap {
|
||||
}
|
||||
|
||||
case gZebraQuotient: {
|
||||
heptspin hs; hs.h = base.origin; hs.spin = 0;
|
||||
heptspin hs(base.origin);
|
||||
reachable.clear();
|
||||
bfsq.clear();
|
||||
add(hs);
|
||||
@ -745,8 +736,8 @@ struct hrmap_quotient : hrmap {
|
||||
int co = connections[i*S7+j];
|
||||
bool swapped = co & symmask;
|
||||
co &= ~symmask;
|
||||
h->move[rv(j)] = allh[co/S7];
|
||||
h->setspin(rv(j), rv(co%S7) + (swapped ? 8 : 0));
|
||||
h->move(rv(j)) = allh[co/S7];
|
||||
h->c.setspin(rv(j), rv(co%S7), swapped);
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,81 +778,27 @@ struct hrmap_quotient : hrmap {
|
||||
|
||||
// --- general ---
|
||||
|
||||
cell *createMov(cell *c, int d);
|
||||
|
||||
cellwalker& operator += (cellwalker& cw, int spin) {
|
||||
cw.spin = (cw.spin+(MIRR(cw)?-spin:spin) + MODFIXER) % cw.c->type;
|
||||
return cw;
|
||||
}
|
||||
|
||||
cellwalker& operator += (cellwalker& cw, wstep_t) {
|
||||
createMov(cw.c, cw.spin);
|
||||
int nspin = cw.c->spn(cw.spin);
|
||||
if(cw.c->mirror(cw.spin)) cw.mirrored = !cw.mirrored;
|
||||
cw.c = cw.c->mov[cw.spin];
|
||||
cw.spin = nspin;
|
||||
return cw;
|
||||
}
|
||||
|
||||
cellwalker& operator -= (cellwalker& cw, int i) { return cw += (-i); }
|
||||
|
||||
cellwalker& operator += (cellwalker& cw, wmirror_t) {
|
||||
cw.mirrored = !cw.mirrored;
|
||||
return cw;
|
||||
}
|
||||
|
||||
cellwalker& operator ++ (cellwalker& h, int) { return h += 1; }
|
||||
cellwalker& operator -- (cellwalker& h, int) { return h -= 1; }
|
||||
|
||||
bool cwstepcreates(cellwalker& cw) {
|
||||
return cw.c->mov[cw.spin] == NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
cell *cwpeek(cellwalker cw, int dir) {
|
||||
return (cw+dir+wstep).c;.
|
||||
// return createMov(cw.c, (cw.spin+MODFIXER+(MIRR(cw)?-dir:dir)) % cw.c->type);
|
||||
} */
|
||||
|
||||
void cwmirrorat(cellwalker& cw, int d) {
|
||||
cw.spin = (d+d - cw.spin + MODFIXER) % cw.c->type;
|
||||
cw.mirrored = !cw.mirrored;
|
||||
}
|
||||
|
||||
static const struct rev_t { rev_t() {} } rev;
|
||||
|
||||
cellwalker& operator += (cellwalker& cw, rev_t) {
|
||||
cw += cw.c->type/2 + ((cw.c->type&1)?hrand(2):0);
|
||||
return cw;
|
||||
}
|
||||
|
||||
static const struct revstep_t { revstep_t() {}} revstep;
|
||||
|
||||
cellwalker& operator += (cellwalker& cw, revstep_t) {
|
||||
cw += rev; cw += wstep; return cw;
|
||||
}
|
||||
|
||||
// very similar to createMove in heptagon.cpp
|
||||
cell *createMov(cell *c, int d) {
|
||||
if(d<0 || d>= c->type) {
|
||||
printf("ERROR createmov\n");
|
||||
}
|
||||
|
||||
if(masterless && !c->mov[d]) {
|
||||
if(masterless && !c->move(d)) {
|
||||
int id = decodeId(c->master);
|
||||
for(int dx=-1; dx<=1; dx++)
|
||||
for(int dy=-1; dy<=1; dy++)
|
||||
euclideanAtCreate(id + pair_to_vec(dx, dy));
|
||||
if(!c->mov[d]) { printf("fail!\n"); }
|
||||
if(!c->move(d)) { printf("fail!\n"); }
|
||||
}
|
||||
|
||||
if(c->mov[d]) return c->mov[d];
|
||||
if(c->move(d)) return c->move(d);
|
||||
else if(irr::on) {
|
||||
irr::link_cell(c, d);
|
||||
}
|
||||
else if(nonbitrunc && gp::on) {
|
||||
gp::extend_map(c, d);
|
||||
if(!c->mov[d]) {
|
||||
if(!c->move(d)) {
|
||||
printf("extend failed to create for %p/%d\n", c, d);
|
||||
exit(1);
|
||||
}
|
||||
@ -869,13 +806,13 @@ cell *createMov(cell *c, int d) {
|
||||
else if(nonbitrunc && syntetic) {
|
||||
if(synt::id_of(c->master) <= synt::N * 2) {
|
||||
heptspin hs = heptspin(c->master, d) + wstep + 2 + wstep + 1;
|
||||
merge(c,d,hs.h->c7,hs.spin,false);
|
||||
c->c.connect(d, hs.at->c7, hs.spin, hs.mirrored);
|
||||
}
|
||||
else merge(c, d, c, d, false);
|
||||
else c->c.connect(d, c, d, false);
|
||||
}
|
||||
else if(nonbitrunc || syntetic) {
|
||||
heptagon *h2 = createStep(c->master, d);
|
||||
merge(c,d,h2->c7,c->master->spin(d),false);
|
||||
c->c.connect(d, h2->c7,c->master->c.spin(d),false);
|
||||
}
|
||||
else if(c == c->master->c7) {
|
||||
|
||||
@ -888,7 +825,7 @@ cell *createMov(cell *c, int d) {
|
||||
|
||||
for(int u=0; u<S6; u+=2) {
|
||||
if(hs.mirrored && geometry == gSmallElliptic) hs+=1;
|
||||
merge(hs.h->c7, hs.spin, n, u, hs.mirrored);
|
||||
hs.at->c7->c.connect(hs.spin, n, u, hs.mirrored);
|
||||
if(hs.mirrored && geometry == gSmallElliptic) hs+=-1;
|
||||
hs = hs + alt3 + wstep - alt4;
|
||||
}
|
||||
@ -899,9 +836,9 @@ cell *createMov(cell *c, int d) {
|
||||
else {
|
||||
cellwalker cw(c, d, false);
|
||||
cellwalker cw2 = cw - 1 + wstep - 1 + wstep - 1;
|
||||
merge(c, d, cw2.c, cw2.spin, cw2.mirrored);
|
||||
c->c.connect(d, cw2);
|
||||
}
|
||||
return c->mov[d];
|
||||
return c->move(d);
|
||||
}
|
||||
|
||||
cell *createMovR(cell *c, int d) {
|
||||
@ -911,14 +848,14 @@ cell *createMovR(cell *c, int d) {
|
||||
|
||||
cell *getMovR(cell *c, int d) {
|
||||
d %= MODFIXER; d += MODFIXER; d %= c->type;
|
||||
return c->mov[d];
|
||||
return c->move(d);
|
||||
}
|
||||
|
||||
void eumerge(cell* c1, cell *c2, int s1, int s2) {
|
||||
if(!c2) return;
|
||||
c1->mov[s1] = c2; tsetspin(c1->spintable, s1, s2);
|
||||
c2->mov[s2] = c1; tsetspin(c2->spintable, s2, s1);
|
||||
}
|
||||
c1->move(s1) = c2; c1->c.setspin(s1, s2, false);
|
||||
c2->move(s2) = c1; c2->c.setspin(s2, s1, false);
|
||||
}
|
||||
|
||||
// map<pair<eucoord, eucoord>, cell*> euclidean;
|
||||
|
||||
@ -959,15 +896,15 @@ void initcells() {
|
||||
void clearcell(cell *c) {
|
||||
if(!c) return;
|
||||
DEBMEM ( printf("c%d %p\n", c->type, c); )
|
||||
for(int t=0; t<c->type; t++) if(c->mov[t]) {
|
||||
DEBMEM ( printf("mov %p [%p] S%d\n", c->mov[t], c->mov[t]->mov[c->spn(t)], c->spn(t)); )
|
||||
if(c->mov[t]->mov[c->spn(t)] != NULL &&
|
||||
c->mov[t]->mov[c->spn(t)] != c) {
|
||||
printf("type = %d %d -> %d\n", c->type, t, c->spn(t));
|
||||
for(int t=0; t<c->type; t++) if(c->move(t)) {
|
||||
DEBMEM ( printf("mov %p [%p] S%d\n", c->move(t), c->move(t)->move(c->c.spin(t)), c->c.spin(t)); )
|
||||
if(c->move(t)->move(c->c.spin(t)) != NULL &&
|
||||
c->move(t)->move(c->c.spin(t)) != c) {
|
||||
printf("type = %d %d -> %d\n", c->type, t, c->c.spin(t));
|
||||
printf("cell error\n");
|
||||
exit(1);
|
||||
}
|
||||
c->mov[t]->mov[c->spn(t)] = NULL;
|
||||
c->move(t)->move(c->c.spin(t)) = NULL;
|
||||
}
|
||||
DEBMEM ( printf("DEL %p\n", c); )
|
||||
delete c;
|
||||
@ -977,7 +914,7 @@ heptagon deletion_marker;
|
||||
|
||||
template<class T> void subcell(cell *c, const T& t) {
|
||||
if(gp::on) {
|
||||
forCellEx(c2, c) if(c2->mov[0] == c && c2 != c2->master->c7) {
|
||||
forCellEx(c2, c) if(c2->move(0) == c && c2 != c2->master->c7) {
|
||||
subcell(c2, t);
|
||||
}
|
||||
}
|
||||
@ -1025,19 +962,19 @@ void clearfrom(heptagon *at) {
|
||||
}
|
||||
int edges = S7;
|
||||
if(binarytiling) edges = at->c7->type;
|
||||
for(int i=0; i<edges; i++) if(at->move[i]) {
|
||||
if(at->move[i]->alt != &deletion_marker)
|
||||
q.push(at->move[i]);
|
||||
unlink_cdata(at->move[i]);
|
||||
at->move[i]->alt = &deletion_marker;
|
||||
DEBMEM ( printf("!mov %p [%p]\n", at->move[i], at->move[i]->move[at->spin(i)]); )
|
||||
if(at->move[i]->move[at->spin(i)] != NULL &&
|
||||
at->move[i]->move[at->spin(i)] != at) {
|
||||
for(int i=0; i<edges; i++) if(at->move(i)) {
|
||||
if(at->move(i)->alt != &deletion_marker)
|
||||
q.push(at->move(i));
|
||||
unlink_cdata(at->move(i));
|
||||
at->move(i)->alt = &deletion_marker;
|
||||
DEBMEM ( printf("!mov %p [%p]\n", at->move(i), at->move(i)->move[at->c.spin(i)]); )
|
||||
if(at->move(i)->move(at->c.spin(i)) != NULL &&
|
||||
at->move(i)->move(at->c.spin(i)) != at) {
|
||||
printf("hept error\n");
|
||||
exit(1);
|
||||
}
|
||||
at->move[i]->move[at->spin(i)] = NULL;
|
||||
at->move[i] = NULL;
|
||||
at->move(i)->move(at->c.spin(i)) = NULL;
|
||||
at->move(i) = NULL;
|
||||
}
|
||||
clearHexes(at);
|
||||
delete at;
|
||||
@ -1048,11 +985,11 @@ void clearfrom(heptagon *at) {
|
||||
void verifycell(cell *c) {
|
||||
int t = c->type;
|
||||
for(int i=0; i<t; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2) {
|
||||
if(!stdeuclid && !nonbitrunc && c == c->master->c7) verifycell(c2);
|
||||
if(c2->mov[c->spn(i)] && c2->mov[c->spn(i)] != c) {
|
||||
printf("cell error %p:%d [%d] %p:%d [%d]\n", c, i, c->type, c2, c->spn(i), c2->type);
|
||||
if(c2->move(c->c.spin(i)) && c2->move(c->c.spin(i)) != c) {
|
||||
printf("cell error %p:%d [%d] %p:%d [%d]\n", c, i, c->type, c2, c->c.spin(i), c2->type);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -1061,12 +998,12 @@ void verifycell(cell *c) {
|
||||
|
||||
void verifycells(heptagon *at) {
|
||||
if(gp::on || irr::on || syntetic) return;
|
||||
for(int i=0; i<S7; i++) if(at->move[i] && at->move[i]->move[at->spin(i)] && at->move[i]->move[at->spin(i)] != at) {
|
||||
printf("hexmix error %p [%d s=%d] %p %p\n", at, i, at->spin(i), at->move[i], at->move[i]->move[at->spin(i)]);
|
||||
for(int i=0; i<S7; i++) if(at->move(i) && at->move(i)->move(at->c.spin(i)) && at->move(i)->move(at->c.spin(i)) != at) {
|
||||
printf("hexmix error %p [%d s=%d] %p %p\n", at, i, at->c.spin(i), at->move(i), at->move(i)->move(at->c.spin(i)));
|
||||
}
|
||||
if(!sphere && !quotient)
|
||||
for(int i=0; i<S7; i++) if(at->move[i] && at->spin(i) == 0 && at->s != hsOrigin)
|
||||
verifycells(at->move[i]);
|
||||
for(int i=0; i<S7; i++) if(at->move(i) && at->c.spin(i) == 0 && at->s != hsOrigin)
|
||||
verifycells(at->move(i));
|
||||
verifycell(at->c7);
|
||||
}
|
||||
|
||||
@ -1154,7 +1091,7 @@ int celldistAlt(cell *c) {
|
||||
}
|
||||
|
||||
int dirfromto(cell *cfrom, cell *cto) {
|
||||
for(int i=0; i<cfrom->type; i++) if(cfrom->mov[i] == cto) return i;
|
||||
for(int i=0; i<cfrom->type; i++) if(cfrom->move(i) == cto) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1315,10 +1252,10 @@ cdata *getHeptagonCdata(heptagon *h) {
|
||||
return h->cdata = new cdata(orig_cdata);
|
||||
}
|
||||
|
||||
cdata mydata = *getHeptagonCdata(h->move[0]);
|
||||
cdata mydata = *getHeptagonCdata(h->move(0));
|
||||
|
||||
for(int di=3; di<5; di++) {
|
||||
heptspin hs; hs.h = h; hs.spin = di;
|
||||
heptspin hs; hs.at = h; hs.spin = di;
|
||||
int signum = +1;
|
||||
while(true) {
|
||||
heptspin hstab[15];
|
||||
@ -1338,19 +1275,19 @@ cdata *getHeptagonCdata(heptagon *h) {
|
||||
hstab[i] += ((i&1) ? 4 : 3);
|
||||
}
|
||||
|
||||
if(hstab[3].h->distance < hstab[7].h->distance) {
|
||||
if(hstab[3].at->distance < hstab[7].at->distance) {
|
||||
hs = hstab[3]; continue;
|
||||
}
|
||||
|
||||
if(hstab[11].h->distance < hstab[7].h->distance) {
|
||||
if(hstab[11].at->distance < hstab[7].at->distance) {
|
||||
hs = hstab[11]; continue;
|
||||
}
|
||||
|
||||
int jj = 7;
|
||||
for(int k=3; k<12; k++) if(hstab[k].h->distance < hstab[jj].h->distance) jj = k;
|
||||
for(int k=3; k<12; k++) if(hstab[k].at->distance < hstab[jj].at->distance) jj = k;
|
||||
|
||||
int ties = 0, tiespos = 0;
|
||||
for(int k=3; k<12; k++) if(hstab[k].h->distance == hstab[jj].h->distance)
|
||||
for(int k=3; k<12; k++) if(hstab[k].at->distance == hstab[jj].at->distance)
|
||||
ties++, tiespos += (k-jj);
|
||||
|
||||
// printf("ties=%d tiespos=%d jj=%d\n", ties, tiespos, jj);
|
||||
@ -1362,18 +1299,18 @@ cdata *getHeptagonCdata(heptagon *h) {
|
||||
break;
|
||||
}
|
||||
hs = hs + 3 + wstep;
|
||||
setHeptagonRval(hs.h);
|
||||
setHeptagonRval(hs.at);
|
||||
|
||||
affect(mydata, hs.spin ? hs.h->rval0 : hs.h->rval1, signum);
|
||||
affect(mydata, hs.spin ? hs.at->rval0 : hs.at->rval1, signum);
|
||||
|
||||
/* if(!(spins[hs.h] & hs.spin)) {
|
||||
spins[hs.h] |= (1<<hs.spin);
|
||||
/* if(!(spins[hs.at] & hs.spin)) {
|
||||
spins[hs.at] |= (1<<hs.spin);
|
||||
int t = 0;
|
||||
for(int k=0; k<7; k++) if(spins[hs.h] & (1<<k)) t++;
|
||||
for(int k=0; k<7; k++) if(spins[hs.at] & (1<<k)) t++;
|
||||
static bool wast[256];
|
||||
if(!wast[spins[hs.h]]) {
|
||||
printf("%p %4x\n", hs.h, spins[hs.h]);
|
||||
wast[spins[hs.h]] = true;
|
||||
if(!wast[spins[hs.at]]) {
|
||||
printf("%p %4x\n", hs.at, spins[hs.at]);
|
||||
wast[spins[hs.at]] = true;
|
||||
}
|
||||
} */
|
||||
}
|
||||
@ -1466,7 +1403,7 @@ int getBits(cell *c) {
|
||||
cell *heptatdir(cell *c, int d) {
|
||||
if(d&1) {
|
||||
cell *c2 = createMov(c, d);
|
||||
int s = c->spin(d);
|
||||
int s = c->c.spin(d);
|
||||
s += 3; s %= 6;
|
||||
return createMov(c2, s);
|
||||
}
|
||||
@ -1478,7 +1415,7 @@ int heptdistance(heptagon *h1, heptagon *h2) {
|
||||
int d = 0;
|
||||
while(true) {
|
||||
if(h1 == h2) return d;
|
||||
for(int i=0; i<S7; i++) if(h1->move[i] == h2) return d + 1;
|
||||
for(int i=0; i<S7; i++) if(h1->move(i) == h2) return d + 1;
|
||||
int d1 = h1->distance, d2 = h2->distance;
|
||||
if(d1 >= d2) d++, h1 = createStep(h1, binarytiling ? 5 : 0);
|
||||
if(d2 > d1) d++, h2 = createStep(h2, binarytiling ? 5 : 0);
|
||||
|
266
complex.cpp
266
complex.cpp
@ -98,8 +98,8 @@ namespace whirlwind {
|
||||
cell *at = whirlline[isize(whirlline)-1];
|
||||
cell *prev = whirlline[isize(whirlline)-2];
|
||||
for(int i=0; i<at->type; i++)
|
||||
if(at->mov[i] && (euclid || at->mov[i]->master->alt) && celldistAlt(at->mov[i]) == d && at->mov[i] != prev) {
|
||||
whirlline.push_back(at->mov[i]);
|
||||
if(at->move(i) && (euclid || at->move(i)->master->alt) && celldistAlt(at->move(i)) == d && at->move(i) != prev) {
|
||||
whirlline.push_back(at->move(i));
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
@ -111,18 +111,18 @@ namespace whirlwind {
|
||||
vector<cell*> whirlline;
|
||||
whirlline.push_back(c);
|
||||
cell *prev = c;
|
||||
cell *c2 = c->mov[dfrom[0]];
|
||||
cell *c2 = c->move(dfrom[0]);
|
||||
while(true) {
|
||||
// printf("c = %p dist = %d\n", c2, c2->mpdist);
|
||||
if(c == c2) break;
|
||||
calcdirs(c2);
|
||||
if(qdirs == 0) break;
|
||||
cell *cc2 = c2;
|
||||
if(qdirs == 1) whirlline.push_back(c2), c2 = c2->mov[dfrom[0]];
|
||||
else if(c2->mov[dto[0]] == prev)
|
||||
c2 = c2->mov[dfrom[1]];
|
||||
if(qdirs == 1) whirlline.push_back(c2), c2 = c2->move(dfrom[0]);
|
||||
else if(c2->move(dto[0]) == prev)
|
||||
c2 = c2->move(dfrom[1]);
|
||||
else
|
||||
c2 = c2->mov[dfrom[0]];
|
||||
c2 = c2->move(dfrom[0]);
|
||||
prev = cc2;
|
||||
}
|
||||
int z = isize(whirlline);
|
||||
@ -160,7 +160,7 @@ namespace whirlwind {
|
||||
for(int i=0; i<2; i++) {
|
||||
calcdirs(c);
|
||||
if(qdirs != 1) return NULL;
|
||||
cell *c2 = c->mov[dfrom[0]];
|
||||
cell *c2 = c->move(dfrom[0]);
|
||||
if(!passable(c, c2, P_JUMP1)) return NULL;
|
||||
if(player && i == 0 && !passable(c, c2, P_ISPLAYER)) return NULL;
|
||||
c = c2;
|
||||
@ -174,7 +174,7 @@ namespace whirlwind {
|
||||
for(int i=0; i<2; i++) {
|
||||
calcdirs(c);
|
||||
if(qdirs != 1) return NULL;
|
||||
c = c->mov[dto[0]];
|
||||
c = c->move(dto[0]);
|
||||
}
|
||||
calcdirs(c);
|
||||
if(qdirs != 1) return NULL;
|
||||
@ -302,7 +302,7 @@ namespace elec {
|
||||
}
|
||||
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
if(c2->listindex == from) continue;
|
||||
eCharge ct = getCharge(c2);
|
||||
@ -362,7 +362,7 @@ namespace elec {
|
||||
if(here == ecCharged) chargecells.push_back(c);
|
||||
cl.add(c);
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2) listChargedCells(c2, cl, here);
|
||||
}
|
||||
}
|
||||
@ -416,7 +416,7 @@ namespace elec {
|
||||
if(c->ligon) return;
|
||||
c->ligon = true;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
eCharge ch = getCharge(c2);
|
||||
if(conduct(what, ch))
|
||||
@ -573,7 +573,7 @@ namespace princess {
|
||||
}
|
||||
|
||||
void bringBack() {
|
||||
if(bringBackAt(cwt.c->mov[cwt.spin])) return;
|
||||
if(bringBackAt(cwt.peek())) return;
|
||||
for(int i=1; i<isize(dcal); i++)
|
||||
if(bringBackAt(dcal[i])) return;
|
||||
}
|
||||
@ -763,7 +763,7 @@ namespace clearing {
|
||||
if(!quotient) {
|
||||
generateAlts(c->master);
|
||||
for(int i=0; i<S7; i++)
|
||||
generateAlts(c->master->move[i]);
|
||||
generateAlts(c->master->move(i));
|
||||
}
|
||||
int d = celldistAlt(c);
|
||||
|
||||
@ -788,7 +788,7 @@ namespace clearing {
|
||||
|
||||
int quseful = 0, tuseful = 0, tuseful2 = 0;
|
||||
for(int i=1; i<S6; i+=2) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(celldistAlt(c2) == d) {
|
||||
bool useful = false;
|
||||
for(int j=1; j<S6; j++) {
|
||||
@ -877,8 +877,8 @@ namespace clearing {
|
||||
int d = plantdir(c);
|
||||
steps++;
|
||||
onpath.push_back(c); pdir.push_back(d);
|
||||
// printf("c [%4d] %p -> %p\n", celldistAlt(c), c, c->mov[d]);
|
||||
c = c->mov[d];
|
||||
// printf("c [%4d] %p -> %p\n", celldistAlt(c), c, c->move(d));
|
||||
c = c->move(d);
|
||||
}
|
||||
else {
|
||||
bd.dist--;
|
||||
@ -892,7 +892,7 @@ namespace clearing {
|
||||
return;
|
||||
}
|
||||
rpath.push_back(bd.root);
|
||||
// printf("r [%4d] %p -> %p\n", celldistAlt(bd.root), bd.root, bd.root->mov[plantdir(bd.root)]);
|
||||
// printf("r [%4d] %p -> %p\n", celldistAlt(bd.root), bd.root, bd.root->move(plantdir(bd.root)));
|
||||
bd.root = createMov(bd.root, plantdir(bd.root));
|
||||
}
|
||||
}
|
||||
@ -931,14 +931,14 @@ namespace whirlpool {
|
||||
int d2;
|
||||
while(true) {
|
||||
if(i == c->type) return NULL;
|
||||
if(c->mov[i] && (d2 = celldistAlt(c->mov[i])) != d)
|
||||
if(c->move(i) && (d2 = celldistAlt(c->move(i))) != d)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
if(i == c->type) return NULL;
|
||||
if(d>d2) next = -next;
|
||||
for(int j=1; j<c->type; j++) {
|
||||
cell *c2 = c->mov[(i+MODFIXER+next*j) % c->type];
|
||||
cell *c2 = c->modmove(i+next*j);
|
||||
if(celldistAlt(c2) == d) return c2;
|
||||
}
|
||||
return NULL;
|
||||
@ -949,10 +949,10 @@ namespace whirlpool {
|
||||
cell *at = whirlline[isize(whirlline)-1];
|
||||
cell *prev = whirlline[isize(whirlline)-2];
|
||||
for(int i=0; i<at->type; i++)
|
||||
if(at->mov[i] && (eubinary || at->mov[i]->master->alt) && celldistAlt(at->mov[i]) == d && at->mov[i] != prev) {
|
||||
if(at->mov[i] == whirlline[0]) return; // loops in weird geometries?
|
||||
if(at->mov[i] == whirlline[isize(whirlline)/2]) return; // even weirder geometry?
|
||||
whirlline.push_back(at->mov[i]);
|
||||
if(at->move(i) && (eubinary || at->move(i)->master->alt) && celldistAlt(at->move(i)) == d && at->move(i) != prev) {
|
||||
if(at->move(i) == whirlline[0]) return; // loops in weird geometries?
|
||||
if(at->move(i) == whirlline[isize(whirlline)/2]) return; // even weirder geometry?
|
||||
whirlline.push_back(at->move(i));
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
@ -1054,10 +1054,6 @@ namespace whirlpool {
|
||||
}
|
||||
}
|
||||
|
||||
bool operator == (const cellwalker& c1, const cellwalker& c2) {
|
||||
return c1.c == c2.c && c1.spin == c2.spin && c1.mirrored == c2.mirrored;
|
||||
}
|
||||
|
||||
namespace mirror {
|
||||
|
||||
vector<pair<int, cellwalker>> mirrors;
|
||||
@ -1081,20 +1077,20 @@ namespace mirror {
|
||||
void destroyKilled() {
|
||||
int j = 0;
|
||||
for(int i=0; i<isize(mirrors); i++)
|
||||
if(mirrors[i].second.c->monst == moMimic)
|
||||
if(mirrors[i].second.at->monst == moMimic)
|
||||
mirrors[j++] = mirrors[i];
|
||||
mirrors.resize(j);
|
||||
}
|
||||
|
||||
void unlist() {
|
||||
for(auto& m: mirrors)
|
||||
if(m.second.c->monst == moMimic)
|
||||
m.second.c->monst = moNone;
|
||||
if(m.second.at->monst == moMimic)
|
||||
m.second.at->monst = moNone;
|
||||
}
|
||||
|
||||
void list() {
|
||||
for(auto& m: mirrors)
|
||||
m.second.c->monst = moMimic;
|
||||
m.second.at->monst = moMimic;
|
||||
}
|
||||
|
||||
void destroyAll() {
|
||||
@ -1107,7 +1103,7 @@ namespace mirror {
|
||||
cw = reflect(cw);
|
||||
if(cpid == LIGHTNING)
|
||||
castLightningBolt(cw);
|
||||
else if(cellMirrorable(cw.c)) {
|
||||
else if(cellMirrorable(cw.at)) {
|
||||
for(auto& m: mirrors)
|
||||
if(m == make_pair(cpid,cw))
|
||||
return;
|
||||
@ -1117,11 +1113,11 @@ namespace mirror {
|
||||
|
||||
void createMirrors(cellwalker cw, int cpid) {
|
||||
cw.mirrored = !cw.mirrored;
|
||||
cell *c = cw.c;
|
||||
cell *c = cw.at;
|
||||
|
||||
for(int i=0; i<cw.c->type; i++) {
|
||||
for(int i=0; i<cw.at->type; i++) {
|
||||
auto cws = cw + wstep;
|
||||
if(cws.c->type == c->type)
|
||||
if(cws.at->type == c->type)
|
||||
createMirror(cws+i, cpid);
|
||||
cw += 1;
|
||||
}
|
||||
@ -1129,13 +1125,13 @@ namespace mirror {
|
||||
|
||||
void createMirages(cellwalker cw, int cpid) {
|
||||
if(nonbitrunc) {
|
||||
for(int i=0; i<cw.c->type; i++)
|
||||
for(int i=0; i<cw.at->type; i++)
|
||||
createMirror(cw + i + wstep + 3 + wstep + 5 + wstep + 3 - i, cpid);
|
||||
return;
|
||||
}
|
||||
for(int i=0; i<S6; i++) {
|
||||
auto cw0 = cw + i + wstep;
|
||||
if(!ctof(cw0.c)) {
|
||||
if(!ctof(cw0.at)) {
|
||||
createMirror(cw0 + 2 + wstep - (2+i), cpid);
|
||||
createMirror(cw0 - 2 + wstep + (2-i), cpid);
|
||||
}
|
||||
@ -1143,22 +1139,22 @@ namespace mirror {
|
||||
}
|
||||
|
||||
void createHere(cellwalker cw, int cpid) {
|
||||
if(!cw.c) return;
|
||||
if(cw.c->wall == waCloud)
|
||||
if(!cw.at) return;
|
||||
if(cw.at->wall == waCloud)
|
||||
createMirages(cw, cpid);
|
||||
if(cw.c->wall == waMirror)
|
||||
if(cw.at->wall == waMirror)
|
||||
createMirrors(cw, cpid);
|
||||
}
|
||||
|
||||
void breakMirror(cellwalker cw, int pid) {
|
||||
if(!cw.c) return;
|
||||
cell *c = cw.c;
|
||||
if(!cw.at) return;
|
||||
cell *c = cw.at;
|
||||
if(c->wall == waMirror || c->wall == waCloud) {
|
||||
drawParticles(c, winf[c->wall].color, 16);
|
||||
playSound(c, "pickup-mirror", 50);
|
||||
if(pid >= 0 && (cw.c->land == laMirror || cw.c->land == laMirrorOld)) {
|
||||
if(pid >= 0 && (cw.at->land == laMirror || cw.at->land == laMirrorOld)) {
|
||||
dynamicval<int> d(multi::cpid, pid);
|
||||
gainShard(cw.c, c->wall == waMirror ? "The mirror shatters!" : "The cloud turns into a bunch of images!");
|
||||
gainShard(cw.at, c->wall == waMirror ? "The mirror shatters!" : "The cloud turns into a bunch of images!");
|
||||
}
|
||||
c->wall = waNone;
|
||||
}
|
||||
@ -1166,9 +1162,9 @@ namespace mirror {
|
||||
|
||||
bool isKilledByMirror(cell *c) {
|
||||
for(auto& m: mirrors) {
|
||||
cell *c1 = (m.second + wstep).c;
|
||||
if(inmirror(c1)) c1 = reflect(cellwalker(c1, 0, false)).c;
|
||||
if(c1 == c && canAttack(m.second.c, moMimic, c, c->monst, 0))
|
||||
cell *c1 = (m.second + wstep).at;
|
||||
if(inmirror(c1)) c1 = reflect(cellwalker(c1, 0, false)).at;
|
||||
if(c1 == c && canAttack(m.second.at, moMimic, c, c->monst, 0))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1183,11 +1179,11 @@ namespace mirror {
|
||||
auto& m = mirrors[i];
|
||||
bool survive = true;
|
||||
if(m.first == multi::cpid) {
|
||||
cell *c = m.second.c;
|
||||
cell *c = m.second.at;
|
||||
if(!m.second.mirrored) nummirage++;
|
||||
auto cw2 = m.second + wstep;
|
||||
if(inmirror(cw2)) cw2 = reflect(cw2);
|
||||
cell *c2 = cw2.c;
|
||||
cell *c2 = cw2.at;
|
||||
if(c2->monst) {
|
||||
c->monst = moMimic;
|
||||
eMonster m2 = c2->monst;
|
||||
@ -1262,7 +1258,7 @@ namespace mirror {
|
||||
|
||||
int icount = 0, isum = 0;
|
||||
for(int i=0; i<6; i+=2) {
|
||||
if(createMov(c, i)->bardir == c->spin(i))
|
||||
if(createMov(c, i)->bardir == c->c.spin(i))
|
||||
icount++, isum+=i;
|
||||
}
|
||||
if(icount != 1) return -1;
|
||||
@ -1275,7 +1271,7 @@ namespace mirror {
|
||||
if(v[i]) cw -= v[i];
|
||||
else {
|
||||
cw += wstep;
|
||||
if(cw.c->land == laMirrorWall || cw.c->land == laMirror) goout = true;
|
||||
if(cw.at->land == laMirrorWall || cw.at->land == laMirror) goout = true;
|
||||
}
|
||||
}
|
||||
return make_pair(goout, cw);
|
||||
@ -1293,10 +1289,10 @@ namespace mirror {
|
||||
stepcount++; if(stepcount > 10000) {
|
||||
return cw;
|
||||
}
|
||||
cell *c0 = (cw+wstep).c;
|
||||
cell *c0 = (cw+wstep).at;
|
||||
int go = 0;
|
||||
if(!inmirror(c0)) go = 2;
|
||||
else if(depth(c0) && depth(c0) < depth(cw.c)) go = 1;
|
||||
else if(depth(c0) && depth(c0) < depth(cw.at)) go = 1;
|
||||
if(go) {
|
||||
v.push_back(0);
|
||||
cw += wstep;
|
||||
@ -1307,16 +1303,16 @@ namespace mirror {
|
||||
cw += 1;
|
||||
}
|
||||
}
|
||||
if(cw.c->land == laMirrorWall || cw.c->land == laMirrorWall2) {
|
||||
if(cw.c->type == 7) {
|
||||
while(cw.spin != cw.c->bardir) {
|
||||
if(cw.at->land == laMirrorWall || cw.at->land == laMirrorWall2) {
|
||||
if(cw.at->type == 7) {
|
||||
while(cw.spin != cw.at->bardir) {
|
||||
cw += 1;
|
||||
v.push_back(1);
|
||||
stepcount++; if(stepcount > 10000) { printf("failhep\n"); return cw; }
|
||||
}
|
||||
if(nonbitrunc && (cw+wstep).c == cwcopy.c)
|
||||
if(nonbitrunc && (cw+wstep).at == cwcopy.at)
|
||||
v.pop_back();
|
||||
if(nonbitrunc && (cw+3+wstep).c->land == laMirrored && (cw+2+wstep).c->land == laMirrorWall) {
|
||||
if(nonbitrunc && (cw+3+wstep).at->land == laMirrored && (cw+2+wstep).at->land == laMirrorWall) {
|
||||
cw += wmirror;
|
||||
auto p = traceback(v, cw);
|
||||
if(p.first) return p.second;
|
||||
@ -1329,13 +1325,13 @@ namespace mirror {
|
||||
}
|
||||
}
|
||||
else {
|
||||
while((cw+wstep).c->type != 7) {
|
||||
while((cw+wstep).at->type != 7) {
|
||||
cw ++;
|
||||
v.push_back(1);
|
||||
}
|
||||
int icount = 0;
|
||||
for(int i=0; i<3; i++) {
|
||||
if((cw+wstep).c->bardir == cw.c->spin(cw.spin))
|
||||
if((cw+wstep).at->bardir == cw.at->c.spin(cw.spin))
|
||||
icount++;
|
||||
cw += 2;
|
||||
}
|
||||
@ -1351,7 +1347,7 @@ namespace mirror {
|
||||
printf("icount >= 2 but failed\n");
|
||||
return cw;
|
||||
}
|
||||
while((cw+wstep).c->bardir != cw.c->spin(cw.spin)) {
|
||||
while((cw+wstep).at->bardir != cw.at->c.spin(cw.spin)) {
|
||||
stepcount++; if(stepcount > 10000) { printf("fail2\n"); return cw; }
|
||||
cw += 2;
|
||||
v.push_back(1);
|
||||
@ -1376,24 +1372,24 @@ namespace mirror {
|
||||
}
|
||||
|
||||
cellwalker reflect(const cellwalker& cw) {
|
||||
if(!cw.c) return cw;
|
||||
if((cw.c->landparam & 255) == 0) {
|
||||
if(!cw.at) return cw;
|
||||
if((cw.at->landparam & 255) == 0) {
|
||||
bool cando = false;
|
||||
forCellEx(c2, cw.c) if(c2->landparam & 255) cando = true;
|
||||
if(cando) buildEquidistant(cw.c);
|
||||
forCellEx(c2, cw.at) if(c2->landparam & 255) cando = true;
|
||||
if(cando) buildEquidistant(cw.at);
|
||||
}
|
||||
if((cw.c->landparam & 255) == 0) return cw;
|
||||
int cid = (cw.c->landparam >> 8) & CACHEMASK;
|
||||
if(cache[cid].first != cw.c) {
|
||||
if((cw.at->landparam & 255) == 0) return cw;
|
||||
int cid = (cw.at->landparam >> 8) & CACHEMASK;
|
||||
if(cache[cid].first != cw.at) {
|
||||
cid = nextcache++;
|
||||
nextcache &= CACHEMASK;
|
||||
cw.c->landparam &= ~ (CACHEMASK << 8);
|
||||
cw.c->landparam |= (cid << 8);
|
||||
cache[cid].first = cw.c;
|
||||
cellwalker cw0(cw.c, 0, false);
|
||||
cw.at->landparam &= ~ (CACHEMASK << 8);
|
||||
cw.at->landparam |= (cid << 8);
|
||||
cache[cid].first = cw.at;
|
||||
cellwalker cw0(cw.at, 0, false);
|
||||
cache[cid].second = reflect0(cw0);
|
||||
int tries = 64;
|
||||
while(inmirror(cache[cid].second.c) && tries--)
|
||||
while(inmirror(cache[cid].second.at) && tries--)
|
||||
cache[cid].second = reflect0(cache[cid].second);
|
||||
}
|
||||
cellwalker res = cache[cid].second + cw.spin;
|
||||
@ -1479,7 +1475,7 @@ namespace hive {
|
||||
b.dist[k] = BUGINF;
|
||||
bool havebug = false, haveother = false;
|
||||
for(int dir=0; dir<c->type; dir++) {
|
||||
cell *c2 = c->mov[dir];
|
||||
cell *c2 = c->move(dir);
|
||||
if(c2 && isBugEnemy(c2,k) && canAttack(c,eMonster(moBug0+k),c2,c2->monst, AF_TOUGH | AF_NOSHIELD | AF_GETPLAYER)) {
|
||||
if(isBug(c2)) havebug = true;
|
||||
else haveother = true;
|
||||
@ -1492,13 +1488,13 @@ namespace hive {
|
||||
// also all nearby cells are inserted to the buginfo structure
|
||||
if(isize(buginfo) < 30000) {
|
||||
for(int dir=0; dir<c->type; dir++) {
|
||||
cell *c2 = c->mov[dir];
|
||||
cell *c2 = c->move(dir);
|
||||
if(c2) {
|
||||
// if(isBug(c)) bugcellq.push_back(c2); => does not help...
|
||||
for(int t=0; t<c2->type; t++)
|
||||
if(c2->mov[t] && isBug(c2->mov[t]))
|
||||
if(c2->move(t) && isBug(c2->move(t)))
|
||||
bugcellq.push_back(c2),
|
||||
bugcellq.push_back(c2->mov[t]);
|
||||
bugcellq.push_back(c2->move(t));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@ -1507,12 +1503,12 @@ namespace hive {
|
||||
if(c->land == laHive && c->landparam > 1 && c->wall != waWaxWall) {
|
||||
c->landparam --;
|
||||
for(int dir=0; dir<c->type; dir++) {
|
||||
cell *c2 = c->mov[dir];
|
||||
cell *c2 = c->move(dir);
|
||||
if(c2) {
|
||||
for(int t=0; t<c2->type; t++)
|
||||
if(c2->mov[t])
|
||||
if(c2->move(t))
|
||||
bugcellq.push_back(c2),
|
||||
bugcellq.push_back(c2->mov[t]);
|
||||
bugcellq.push_back(c2->move(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1528,7 +1524,7 @@ namespace hive {
|
||||
last_d = d;
|
||||
int goodmoves = 0;
|
||||
for(int dir=0; dir<c->type; dir++) {
|
||||
cell *c2 = c->mov[dir];
|
||||
cell *c2 = c->move(dir);
|
||||
if(!c2) continue;
|
||||
if(c2->listindex < 0 || c2->listindex >= isize(buginfo)) continue;
|
||||
if(!passable(c, c2, P_MONSTER)) continue;
|
||||
@ -1604,7 +1600,7 @@ namespace hive {
|
||||
if(againstRose(c, NULL)) bqual = -40;
|
||||
|
||||
for(int dir=0; dir<c->type; dir++) {
|
||||
cell *c2 = c->mov[dir];
|
||||
cell *c2 = c->move(dir);
|
||||
int qual = -10;
|
||||
if(!c2) continue;
|
||||
else if(againstRose(c, c2)) qual = -50;
|
||||
@ -1625,7 +1621,7 @@ namespace hive {
|
||||
|
||||
if(!q) { if(c->land == laHive) c->landparam += 3; continue; }
|
||||
int d = gmoves[hrand(q)];
|
||||
cell *c2 = c->mov[d];
|
||||
cell *c2 = c->move(d);
|
||||
if(c2->monst || isPlayerOn(c2)) {
|
||||
eMonster killed = c2->monst;
|
||||
if(isPlayerOn(c2)) killed = moPlayer;
|
||||
@ -1709,7 +1705,7 @@ namespace hive {
|
||||
|
||||
int gdir = -1;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
if(c->mov[i] && c->mov[i]->mpdist < c->mpdist) gdir = i;
|
||||
if(c->move(i) && c->move(i)->mpdist < c->mpdist) gdir = i;
|
||||
}
|
||||
if(!gdir) return;
|
||||
cellwalker bf(c, gdir);
|
||||
@ -1720,13 +1716,13 @@ namespace hive {
|
||||
if(getDistLimit() <= 3) radius = 3;
|
||||
|
||||
for(int i=2; i<radius; i++) {
|
||||
if(bf.c->type == 6)
|
||||
if(bf.at->type == 6)
|
||||
bf += 3;
|
||||
else
|
||||
bf += 3 + hrand(2);
|
||||
bf += wstep;
|
||||
}
|
||||
cell *citycenter = bf.c;
|
||||
cell *citycenter = bf.at;
|
||||
buginfo.clear();
|
||||
|
||||
|
||||
@ -1893,7 +1889,7 @@ namespace heat {
|
||||
|
||||
if(shmup::on && (c->land == laCocytus || ct->land == laCocytus))
|
||||
hdiff /= 3;
|
||||
// if(c->mov[j]->cpdist > 7 && !quotient) hdiff += -HEAT(c) / 30;
|
||||
// if(c->move(j)->cpdist > 7 && !quotient) hdiff += -HEAT(c) / 30;
|
||||
hmod += hdiff;
|
||||
}
|
||||
// printf("%d ", vsum);
|
||||
@ -1952,7 +1948,7 @@ namespace heat {
|
||||
if(isFireOrMagma(c)) {
|
||||
if(c->wall == waMagma) c->wparam = 20;
|
||||
|
||||
cell *last = c->mov[c->type-1];
|
||||
cell *last = c->move(c->type-1);
|
||||
|
||||
forCellEx(c2, c) {
|
||||
|
||||
@ -2114,8 +2110,8 @@ void livecaves() {
|
||||
hv -= 1000;
|
||||
if(isPlayerOn(c) && markOrb(itOrbDigging))
|
||||
hv -= 1000;
|
||||
for(int j=0; j<c->type; j++) if(c->mov[j]) {
|
||||
cell *c2 = c->mov[j];
|
||||
for(int j=0; j<c->type; j++) if(c->move(j)) {
|
||||
cell *c2 = c->move(j);
|
||||
if(c2->wall == waNone || c2->wall == waStrandedBoat)
|
||||
hv -= (c2->land == laLivefjord ? 1 : 100);
|
||||
if(c2->wall == waTempFloor || c2->wall == waTempBridge || c2->wall == waTempBridgeBlocked)
|
||||
@ -2142,8 +2138,8 @@ void livecaves() {
|
||||
if(c2->wall == waBarrier) {
|
||||
bool landbar = false;
|
||||
for(int k=0; k<c2->type; k++)
|
||||
if(c2->mov[k]) {
|
||||
cell *c3 = c2->mov[k];
|
||||
if(c2->move(k)) {
|
||||
cell *c3 = c2->move(k);
|
||||
if(!isSealand(c3->land))
|
||||
landbar = true;
|
||||
}
|
||||
@ -2256,7 +2252,7 @@ namespace tortoise {
|
||||
}
|
||||
|
||||
void updateVals(int delta) {
|
||||
int currbits = getBits(cwt.c);
|
||||
int currbits = getBits(cwt.at);
|
||||
for(int i=0; i<numbits; i++)
|
||||
update(seekval[i], seek() && !(peace::on && !peace::hint) ? getBit(seekbits, i) : .5, delta);
|
||||
for(int i=0; i<numbits; i++)
|
||||
@ -2266,7 +2262,7 @@ namespace tortoise {
|
||||
double getScent(int bits) {
|
||||
double res = 0;
|
||||
for(int i=0; i<numbits; i++)
|
||||
/* if(getBit(bits, i) != getBit(getBits(cwt.c), i))
|
||||
/* if(getBit(bits, i) != getBit(getBits(cwt.at), i))
|
||||
res += (1 - 2*getBit(bits, i)); */
|
||||
res += (2* seekval[i] - 1) * (getBit(bits, i) - currval[i]);
|
||||
|
||||
@ -2298,11 +2294,11 @@ namespace dragon {
|
||||
void pullback(cell *c) {
|
||||
int maxlen = 1000;
|
||||
while(maxlen-->0) {
|
||||
cell *c2 = c->mov[c->mondir];
|
||||
cell *c2 = c->move(c->mondir);
|
||||
mountmove(c, c->mondir, true, c2);
|
||||
c->monst = c2->monst;
|
||||
c->hitpoints = c2->hitpoints;
|
||||
animateMovement(c2, c, LAYER_BIG, c->spin(c->mondir));
|
||||
animateMovement(c2, c, LAYER_BIG, c->c.spin(c->mondir));
|
||||
c->stuntime = 2;
|
||||
if(c2->mondir == NODIR) { c->mondir = NODIR; c2->monst = moNone; return; }
|
||||
c = c2;
|
||||
@ -2318,8 +2314,8 @@ namespace dragon {
|
||||
if(maxlen--<0) return c;
|
||||
if(c->monst == moDragonHead) return c;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && isDragon(c->mov[i]->monst) && c->mov[i]->mondir == c->spn(i)) {
|
||||
c = c->mov[i]; goto findhead;
|
||||
if(c->move(i) && isDragon(c->move(i)->monst) && c->move(i)->mondir == c->c.spin(i)) {
|
||||
c = c->move(i); goto findhead;
|
||||
}
|
||||
if(cmode & sm::MAP) return c;
|
||||
if(!conformal::includeHistory) {
|
||||
@ -2347,7 +2343,7 @@ namespace dragon {
|
||||
if(head == c) i = j;
|
||||
j++;
|
||||
if(head->mondir == NODIR) break;
|
||||
head = head->mov[head->mondir];
|
||||
head = head->move(head->mondir);
|
||||
}
|
||||
if(i == 0) return 'h';
|
||||
if(i == 1) return 'l';
|
||||
@ -2384,7 +2380,7 @@ namespace dragon {
|
||||
}
|
||||
}
|
||||
if(c->mondir == NODIR) break;
|
||||
c = c->mov[c->mondir];
|
||||
c = c->move(c->mondir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2398,7 +2394,7 @@ namespace dragon {
|
||||
}
|
||||
total += c->hitpoints;
|
||||
if(c->mondir == NODIR) return total;
|
||||
c = c->mov[c->mondir];
|
||||
c = c->move(c->mondir);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@ -2425,13 +2421,13 @@ namespace dragon {
|
||||
animateMovement(cft, cmt, LAYER_BIG, allcells[i]->mondir);
|
||||
}
|
||||
while(c->mondir != NODIR) {
|
||||
c = c->mov[c->mondir];
|
||||
c = c->move(c->mondir);
|
||||
c->stuntime = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(c->mondir == NODIR) { printf("dragon bug\n"); break; }
|
||||
c = c->mov[c->mondir];
|
||||
c = c->move(c->mondir);
|
||||
if(!c) {
|
||||
if(!conformal::includeHistory) printf("dragon bug #2\n");
|
||||
break;
|
||||
@ -2456,7 +2452,7 @@ namespace dragon {
|
||||
pullfront(head, dt);
|
||||
}
|
||||
else {
|
||||
cell *c2 = df->mov[df->mondir];
|
||||
cell *c2 = df->move(df->mondir);
|
||||
if(!c2) return false;
|
||||
int id = neighborId(dt, c2);
|
||||
if(id == -1) return false;
|
||||
@ -2483,7 +2479,7 @@ namespace sword {
|
||||
if(s<0) s += S84;
|
||||
s *= t;
|
||||
s /= S84;
|
||||
return c->mov[s];
|
||||
return c->move(s);
|
||||
}
|
||||
|
||||
eItem orbof(bool rev) { return rev ? itOrbSword2 : itOrbSword; }
|
||||
@ -2514,7 +2510,7 @@ namespace sword {
|
||||
int s1 = neighborId(c1, c2);
|
||||
int s2 = neighborId(c2, c1);
|
||||
if(s1 < 0 || s2 < 0) return angle;
|
||||
if(c1->mirror(s1))
|
||||
if(c1->c.mirror(s1))
|
||||
return ((s2*S42/c2->type - angle + s1*S42/c1->type) + S21) % S42;
|
||||
else
|
||||
return ((s2*S42/c2->type - s1*S42/c1->type) + S21 + angle) % S42;
|
||||
@ -2538,7 +2534,7 @@ namespace kraken {
|
||||
|
||||
cell *head(cell *c) {
|
||||
if(c->monst == moKrakenH) return c;
|
||||
if(c->monst == moKrakenT) return c->mov[c->mondir];
|
||||
if(c->monst == moKrakenT) return c->move(c->mondir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2550,14 +2546,14 @@ namespace kraken {
|
||||
kills[moKrakenH]++;
|
||||
if(checkOrb(who, itOrbStone)) c->wall = waNone;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i]->monst == moKrakenT) {
|
||||
if(c->move(i)->monst == moKrakenT) {
|
||||
drawParticles(c, minf[moKrakenT].color, 16);
|
||||
c->mov[i]->monst = moNone;
|
||||
c->move(i)->monst = moNone;
|
||||
if(checkOrb(who, itOrbStone)) {
|
||||
if(isWatery(c->mov[i]))
|
||||
c->mov[i]->wall = waNone;
|
||||
if(isWatery(c->move(i)))
|
||||
c->move(i)->wall = waNone;
|
||||
else
|
||||
c->mov[i]->wall = waPetrified, c->mov[i]->wparam = moKrakenT;
|
||||
c->move(i)->wall = waPetrified, c->move(i)->wparam = moKrakenT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2565,15 +2561,15 @@ namespace kraken {
|
||||
int totalhp(cell *c) {
|
||||
int total = 0;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i]->monst == moKrakenT)
|
||||
total += c->mov[i]->hitpoints;
|
||||
if(c->move(i)->monst == moKrakenT)
|
||||
total += c->move(i)->hitpoints;
|
||||
return total;
|
||||
}
|
||||
|
||||
void trymove(cell *c);
|
||||
|
||||
void sleep(cell *c) {
|
||||
if(c->monst == moKrakenT) c = c->mov[c->mondir];
|
||||
if(c->monst == moKrakenT) c = c->move(c->mondir);
|
||||
c->stuntime = 1;
|
||||
forCellEx(c2, c) c2->stuntime = 1;
|
||||
}
|
||||
@ -2618,12 +2614,12 @@ namespace kraken {
|
||||
// c is the tentacle which will be the head after the move
|
||||
void trymove(cell *c) {
|
||||
if(kraken_pseudohept(c)) return;
|
||||
cell *c2 = c->mov[c->mondir];
|
||||
cell *c2 = c->move(c->mondir);
|
||||
if(!isWatery(c)) return;
|
||||
if(againstCurrent(c, c2)) return;
|
||||
forCellIdEx(c3, i, c) {
|
||||
if(c3->monst && c3 != c2 && !(c3->mondir >= 0 && c3->mondir < c3->type &&
|
||||
c3->mov[c3->mondir] == c2))
|
||||
c3->move(c3->mondir) == c2))
|
||||
return;
|
||||
if(isPlayerOn(c3)) return;
|
||||
if(sword::at(c3)) return;
|
||||
@ -2639,10 +2635,10 @@ namespace kraken {
|
||||
vector<pair<cell*, cell*> > acells;
|
||||
acells.push_back(make_pair(c2, c));
|
||||
forCellIdEx(c3, i, c) {
|
||||
c3->monst = moKrakenT, c3->mondir = c->spn(i), onpath(c3, 0);
|
||||
int i0 = (i+c->spn(c->mondir)-c->mondir+96+c->type/2) % c2->type;
|
||||
c3->monst = moKrakenT, c3->mondir = c->c.spin(i), onpath(c3, 0);
|
||||
int i0 = (i+c->c.spin(c->mondir)-c->mondir+96+c->type/2) % c2->type;
|
||||
c3->hitpoints = hpcount[i0];
|
||||
acells.push_back(make_pair(c2->mov[i0], c3));
|
||||
acells.push_back(make_pair(c2->move(i0), c3));
|
||||
if(c3->wall == waBoat) {
|
||||
addMessage(XLAT("%The1 destroys %the2!", moKrakenH, waBoat));
|
||||
c3->wall = waSea;
|
||||
@ -2706,7 +2702,7 @@ namespace prairie {
|
||||
c->LHU.fi.rval = (y&15);
|
||||
}
|
||||
else if(sphere) {
|
||||
c->LHU.fi.rval = celldistance(c, cwt.c) + 8 - (nonbitrunc ? 2 : 3);
|
||||
c->LHU.fi.rval = celldistance(c, cwt.at) + 8 - (nonbitrunc ? 2 : 3);
|
||||
}
|
||||
else if(weirdhyperbolic) {
|
||||
c->LHU.fi.rval = max(celldist(c), 15);
|
||||
@ -2930,11 +2926,11 @@ namespace prairie {
|
||||
}
|
||||
|
||||
void treasures() {
|
||||
if(enter && !isriver(cwt.c)) enter = NULL;
|
||||
else if(!enter && isriver(cwt.c)) enter = cwt.c;
|
||||
if(enter && !isriver(cwt.at)) enter = NULL;
|
||||
else if(!enter && isriver(cwt.at)) enter = cwt.at;
|
||||
if(isize(tchoices)) {
|
||||
if(lasttreasure && lasttreasure->item == itGreenGrass) {
|
||||
if(celldistance(lasttreasure, cwt.c) >= (nonbitrunc ? 7 : 10)) {
|
||||
if(celldistance(lasttreasure, cwt.at) >= (nonbitrunc ? 7 : 10)) {
|
||||
lasttreasure->item = itNone;
|
||||
forCellEx(c2, lasttreasure) if(c2->item == itGreenGrass) c2->item = itNone;
|
||||
}
|
||||
@ -2991,7 +2987,7 @@ namespace ca {
|
||||
#endif
|
||||
|
||||
void simulate() {
|
||||
if(cwt.c->land != laCA) return;
|
||||
if(cwt.at->land != laCA) return;
|
||||
vector<cell*>& allcells = currentmap->allcells();
|
||||
int dcs = isize(allcells);
|
||||
std::vector<bool> willlive(dcs);
|
||||
@ -3065,7 +3061,7 @@ namespace windmap {
|
||||
}
|
||||
|
||||
int getId(cellwalker cw) {
|
||||
auto i = fieldpattern::fieldval_uniq(cw.c);
|
||||
auto i = fieldpattern::fieldval_uniq(cw.at);
|
||||
auto &id = getid[i];
|
||||
if(id == 0) { samples.push_back(cw); id = isize(samples); }
|
||||
return id-1;
|
||||
@ -3099,12 +3095,12 @@ namespace windmap {
|
||||
auto &v = neighbors.back();
|
||||
if(gp::on || irr::on)
|
||||
for(int l=0; l<S7; l++) {
|
||||
heptspin hs(cw.c->master, cw.spin);
|
||||
heptspin hs(cw.at->master, cw.spin);
|
||||
hs = hs + l + wstep;
|
||||
v.push_back(getId(cellwalker(hs.h->c7, hs.spin)));
|
||||
v.push_back(getId(cellwalker(hs.at->c7, hs.spin)));
|
||||
}
|
||||
else
|
||||
for(int l=0; l<cw.c->type; l++) v.push_back(getId(cw+l+wstep));
|
||||
for(int l=0; l<cw.at->type; l++) v.push_back(getId(cw+l+wstep));
|
||||
}
|
||||
|
||||
int N = isize(samples);
|
||||
@ -3119,7 +3115,7 @@ namespace windmap {
|
||||
if(precomp && hyperbolic && isize(currfp.matrices)) {
|
||||
int randval = hrand(isize(currfp.matrices));
|
||||
for(int i=0; i<N; i++)
|
||||
windcodes[i] = precomp[getid[fieldpattern::fieldval_uniq_rand(samples[i].c, randval)]-1];
|
||||
windcodes[i] = precomp[getid[fieldpattern::fieldval_uniq_rand(samples[i].at, randval)]-1];
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3490,8 +3486,8 @@ namespace dungeon {
|
||||
else {
|
||||
cell *c4 = c2;
|
||||
if(c2 != c3 && !isNeighbor(c2, c3)) {
|
||||
for(int i=0; i<c2->type; i++) if(c2->mov[i] && isNeighbor(c2->mov[i], c3))
|
||||
c4 = c2->mov[i];
|
||||
for(int i=0; i<c2->type; i++) if(c2->move(i) && isNeighbor(c2->move(i), c3))
|
||||
c4 = c2->move(i);
|
||||
}
|
||||
rdepths[i] = c2 && c3 && c4 && (c2->landflags == 3 || c3->landflags == 3 || c4->landflags == 3);
|
||||
c2 = chosenDown(c2, 1, 0); // if(!c2) break;
|
||||
@ -3543,8 +3539,8 @@ namespace dungeon {
|
||||
else {
|
||||
cell *c4 = c2;
|
||||
if(c2 != c3 && !isNeighbor(c2, c3)) {
|
||||
for(int i=0; i<c2->type; i++) if(c2->mov[i] && isNeighbor(c2->mov[i], c3))
|
||||
c4 = c2->mov[i];
|
||||
for(int i=0; i<c2->type; i++) if(c2->move(i) && isNeighbor(c2->move(i), c3))
|
||||
c4 = c2->move(i);
|
||||
}
|
||||
rdepths[i] = c2 && c3 && c4 && (c2->landflags == 3 || c3->landflags == 3 || c4->landflags == 3);
|
||||
if((c2&&c2->landflags == 1) || (c3&&c3->landflags == 1) || (c4&&c4->landflags == 1))
|
||||
|
@ -303,13 +303,13 @@ namespace conformal {
|
||||
}
|
||||
|
||||
void create() {
|
||||
if(celldist(cwt.c) == 0) {
|
||||
if(celldist(cwt.at) == 0) {
|
||||
addMessage("Must go a distance from the starting point");
|
||||
return;
|
||||
}
|
||||
|
||||
on = true;
|
||||
cell *c = cwt.c;
|
||||
cell *c = cwt.at;
|
||||
|
||||
while(true) {
|
||||
shmup::monster *m = new shmup::monster;
|
||||
@ -318,8 +318,8 @@ namespace conformal {
|
||||
v.push_back(m);
|
||||
if(c == currentmap->gamestart()) break;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(celldist(c->mov[i]) < celldist(c)) {
|
||||
c = c->mov[i];
|
||||
if(celldist(c->move(i)) < celldist(c)) {
|
||||
c = c->move(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -373,7 +373,7 @@ namespace conformal {
|
||||
if(ph<0) ph = 0;
|
||||
if(ph >= siz-1) ph = siz-2;
|
||||
|
||||
viewctr.h = v[ph]->base->master;
|
||||
viewctr.at = v[ph]->base->master;
|
||||
viewctr.spin = 0;
|
||||
|
||||
View = inverse(master_relative(v[ph]->base) * v[ph]->at);
|
||||
@ -385,7 +385,7 @@ namespace conformal {
|
||||
|
||||
View = spin(M_PI/180 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View;
|
||||
playermoved = false;
|
||||
centerover.c = v[ph]->base;
|
||||
centerover.at = v[ph]->base;
|
||||
compute_graphical_distance();
|
||||
}
|
||||
|
||||
@ -528,7 +528,7 @@ namespace conformal {
|
||||
xpos += bwidth;
|
||||
}
|
||||
|
||||
last_base = viewctr.h->c7;
|
||||
last_base = viewctr.at->c7;
|
||||
last_relative = inverse(ggmatrix(last_base)) * C0;
|
||||
}
|
||||
}
|
||||
@ -900,7 +900,7 @@ namespace conformal {
|
||||
|
||||
void renderAutoband() {
|
||||
#if CAP_SDL
|
||||
if(!cwt.c || celldist(cwt.c) <= 7) return;
|
||||
if(!cwt.at || celldist(cwt.at) <= 7) return;
|
||||
if(!autoband) return;
|
||||
eModel spm = pmodel;
|
||||
bool ih = includeHistory;
|
||||
|
46
control.cpp
46
control.cpp
@ -55,7 +55,7 @@ bool mouseout2() {
|
||||
|
||||
movedir vectodir(const hyperpoint& P) {
|
||||
|
||||
transmatrix U = ggmatrix(cwt.c);
|
||||
transmatrix U = ggmatrix(cwt.at);
|
||||
|
||||
hyperpoint H = sphereflip * tC0(U);
|
||||
transmatrix Centered = sphereflip * rgpushxto0(H);
|
||||
@ -64,22 +64,22 @@ movedir vectodir(const hyperpoint& P) {
|
||||
|
||||
ld dirdist[MAX_EDGE];
|
||||
|
||||
for(int i=0; i<cwt.c->type; i++) {
|
||||
for(int i=0; i<cwt.at->type; i++) {
|
||||
transmatrix T;
|
||||
if(compute_relamatrix(cwt.c->mov[fixdir(cwt.spin + i, cwt.c)], cwt.c, i, T)) {
|
||||
if(compute_relamatrix(cwt.at->modmove(cwt.spin + i), cwt.at, i, T)) {
|
||||
dirdist[i] = intval(U * T * C0, Centered * P);
|
||||
}
|
||||
//xspinpush0(-i * 2 * M_PI /cwt.c->type, .5), P);
|
||||
//xspinpush0(-i * 2 * M_PI /cwt.at->type, .5), P);
|
||||
}
|
||||
|
||||
movedir res;
|
||||
res.d = -1;
|
||||
|
||||
for(int i=0; i<cwt.c->type; i++) {
|
||||
for(int i=0; i<cwt.at->type; i++) {
|
||||
if(dirdist[i] < binv) {
|
||||
binv = dirdist[i];
|
||||
res.d = i;
|
||||
res.subdir = dirdist[(i+1)%cwt.c->type] < dirdist[(i+cwt.c->type-1)%cwt.c->type] ? 1 : -1;
|
||||
res.subdir = dirdist[(i+1)%cwt.at->type] < dirdist[(i+cwt.at->type-1)%cwt.at->type] ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,37 +104,37 @@ void movepckeydir(int d) {
|
||||
void calcMousedest() {
|
||||
if(mouseout()) return;
|
||||
if(vid.revcontrol == true) { mouseh[0] = -mouseh[0]; mouseh[1] = -mouseh[1]; }
|
||||
ld mousedist = intval(mouseh, tC0(ggmatrix(cwt.c)));
|
||||
ld mousedist = intval(mouseh, tC0(ggmatrix(cwt.at)));
|
||||
mousedest.d = -1;
|
||||
|
||||
cellwalker bcwt = cwt;
|
||||
|
||||
ld dists[MAX_EDGE];
|
||||
|
||||
transmatrix U = ggmatrix(cwt.c);
|
||||
transmatrix U = ggmatrix(cwt.at);
|
||||
|
||||
for(int i=0; i<cwt.c->type; i++) {
|
||||
for(int i=0; i<cwt.at->type; i++) {
|
||||
transmatrix T;
|
||||
if(compute_relamatrix(cwt.c->mov[i], cwt.c, i, T))
|
||||
if(compute_relamatrix(cwt.at->move(i), cwt.at, i, T))
|
||||
dists[i] = intval(mouseh, U * T * C0);
|
||||
else
|
||||
dists[i] = HUGE_VAL;
|
||||
}
|
||||
// confusingGeometry() ? ggmatrix(cwt.c) * calc_relative_matrix(cwt.c->mov[i], cwt.c, i) : shmup::ggmatrix(cwt.c->mov[i])));
|
||||
// confusingGeometry() ? ggmatrix(cwt.at) * calc_relative_matrix(cwt.at->move(i), cwt.at, i) : shmup::ggmatrix(cwt.at->move(i))));
|
||||
|
||||
/* printf("curcell = %Lf\n", mousedist);
|
||||
for(int i=0; i<cwt.c->type; i++)
|
||||
for(int i=0; i<cwt.at->type; i++)
|
||||
printf("d%d = %Lf\n", i, dists[i]); */
|
||||
|
||||
for(int i=0; i<cwt.c->type; i++) if(dists[i] < mousedist) {
|
||||
for(int i=0; i<cwt.at->type; i++) if(dists[i] < mousedist) {
|
||||
mousedist = dists[i];
|
||||
mousedest.d = fixdir(i - cwt.spin, cwt.c);
|
||||
mousedest.d = fixdir(i - cwt.spin, cwt.at);
|
||||
|
||||
mousedest.subdir =
|
||||
dists[(i+1)%cwt.c->type] < dists[(i+cwt.c->type-1)%cwt.c->type] ? 1 : -1;
|
||||
dists[(i+1)%cwt.at->type] < dists[(i+cwt.at->type-1)%cwt.at->type] ? 1 : -1;
|
||||
|
||||
if(cwt.mirrored)
|
||||
mousedest.d = fixdir(-mousedest.d, cwt.c),
|
||||
mousedest.d = fixdir(-mousedest.d, cwt.at),
|
||||
mousedest.subdir = -mousedest.subdir;
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ void handlePanning(int sym, int uni) {
|
||||
}
|
||||
|
||||
if(sym == SDLK_PAGEUP || sym == SDLK_PAGEDOWN)
|
||||
if(isGravityLand(cwt.c->land)) playermoved = false;
|
||||
if(isGravityLand(cwt.at->land)) playermoved = false;
|
||||
|
||||
if(sym == PSEUDOKEY_WHEELUP) {
|
||||
ld jx = (mousex - vid.xcenter - .0) / vid.radius / 10;
|
||||
@ -357,7 +357,7 @@ void handleKeyNormal(int sym, int uni) {
|
||||
// vid.yshift = 1 - vid.yshift;
|
||||
// vid.drawmousecircle = true;
|
||||
}
|
||||
if(sym == 'm' && canmove && (centerover == cwt ? mouseover : centerover.c))
|
||||
if(sym == 'm' && canmove && (centerover == cwt ? mouseover : centerover.at))
|
||||
performMarkCommand(mouseover);
|
||||
}
|
||||
|
||||
@ -367,10 +367,10 @@ void handleKeyNormal(int sym, int uni) {
|
||||
movepcto(MD_DROP, 1);
|
||||
if(sym == 't' && uni != 'T' && uni != 'T'-64 && canmove) {
|
||||
if(playermoved && items[itStrongWind]) {
|
||||
cell *c = whirlwind::jumpDestination(cwt.c);
|
||||
if(c) centerover.c = c;
|
||||
cell *c = whirlwind::jumpDestination(cwt.at);
|
||||
if(c) centerover.at = c;
|
||||
}
|
||||
targetRangedOrb(centerover.c, roKeyboard);
|
||||
targetRangedOrb(centerover.at, roKeyboard);
|
||||
sym = 0; uni = 0;
|
||||
}
|
||||
}
|
||||
@ -503,8 +503,8 @@ void mainloopiter() {
|
||||
if(!shmup::on && (multi::alwaysuse || multi::players > 1) && normal)
|
||||
timetowait = 0, multi::handleMulti(ticks - lastt);
|
||||
|
||||
if(vid.sspeed >= 5 && gmatrix.count(cwt.c) && !elliptic) {
|
||||
cwtV = gmatrix[cwt.c] * ddspin(cwt.c, cwt.spin);
|
||||
if(vid.sspeed >= 5 && gmatrix.count(cwt.at) && !elliptic) {
|
||||
cwtV = gmatrix[cwt.at] * ddspin(cwt.at, cwt.spin);
|
||||
if(cwt.mirrored) playerV = playerV * Mirror;
|
||||
}
|
||||
|
||||
|
32
debug.cpp
32
debug.cpp
@ -65,12 +65,12 @@ eItem randomTreasure2(int cv) {
|
||||
if(itemclass(i) != IC_TREASURE) continue;
|
||||
int q = 2*items[i];
|
||||
if(a == lt) q -= (2*cv-1);
|
||||
if(a == itEmerald && bearsCamelot(cwt.c->land)) q -= 8;
|
||||
if(a == itElixir && isCrossroads(cwt.c->land)) q -= 7;
|
||||
if(a == itIvory && isCrossroads(cwt.c->land)) q -= 6;
|
||||
if(a == itPalace && isCrossroads(cwt.c->land)) q -= 5;
|
||||
if(a == itIvory && cwt.c->land == laJungle) q -= 5;
|
||||
if(a == itIvory && cwt.c->land == laPalace) q -= 5;
|
||||
if(a == itEmerald && bearsCamelot(cwt.at->land)) q -= 8;
|
||||
if(a == itElixir && isCrossroads(cwt.at->land)) q -= 7;
|
||||
if(a == itIvory && isCrossroads(cwt.at->land)) q -= 6;
|
||||
if(a == itPalace && isCrossroads(cwt.at->land)) q -= 5;
|
||||
if(a == itIvory && cwt.at->land == laJungle) q -= 5;
|
||||
if(a == itIvory && cwt.at->land == laPalace) q -= 5;
|
||||
if(q < bq) bq = q, cq = 0;
|
||||
if(q == bq) { cq++; if(hrand(cq) == 0) best = i; }
|
||||
}
|
||||
@ -128,10 +128,10 @@ bool applyCheat(char u, cell *c = NULL) {
|
||||
}
|
||||
if(u == 'O') {
|
||||
cheater++; addMessage(XLAT("Orbs summoned!"));
|
||||
for(int i=0; i<cwt.c->type; i++)
|
||||
if(passable(cwt.c->mov[i], NULL, 0)) {
|
||||
for(int i=0; i<cwt.at->type; i++)
|
||||
if(passable(cwt.at->move(i), NULL, 0)) {
|
||||
eItem it = nextOrb();
|
||||
cwt.c->mov[i]->item = it;
|
||||
cwt.at->move(i)->item = it;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -165,7 +165,7 @@ bool applyCheat(char u, cell *c = NULL) {
|
||||
return true;
|
||||
}
|
||||
if(u == 'A'-64) {
|
||||
mapeditor::drawcell = mouseover ? mouseover : cwt.c;
|
||||
mapeditor::drawcell = mouseover ? mouseover : cwt.at;
|
||||
pushScreen(mapeditor::showDrawEditor);
|
||||
return true;
|
||||
}
|
||||
@ -192,7 +192,7 @@ bool applyCheat(char u, cell *c = NULL) {
|
||||
}
|
||||
if(u == 'Z') {
|
||||
if (flipplayer) {
|
||||
cwt += cwt.c->type/2;
|
||||
cwt += cwt.at->type/2;
|
||||
flipplayer = false;
|
||||
}
|
||||
cwt++;
|
||||
@ -227,7 +227,7 @@ bool applyCheat(char u, cell *c = NULL) {
|
||||
cheater++; addMessage(XLAT("Collected the keys!"));
|
||||
}
|
||||
if(u == 'Y'-64) {
|
||||
yendor::collected(cwt.c);
|
||||
yendor::collected(cwt.at);
|
||||
cheater++;
|
||||
}
|
||||
if(u == 'P') {
|
||||
@ -240,7 +240,7 @@ bool applyCheat(char u, cell *c = NULL) {
|
||||
}
|
||||
if(u == 'S') {
|
||||
canmove = true;
|
||||
cheatMoveTo(cwt.c->land);
|
||||
cheatMoveTo(cwt.at->land);
|
||||
items[itOrbSafety] += 3;
|
||||
cheater++; addMessage(XLAT("Activated Orb of Safety!"));
|
||||
return true;
|
||||
@ -265,7 +265,7 @@ bool applyCheat(char u, cell *c = NULL) {
|
||||
if(u == 'L'-64) {
|
||||
cell *c = mouseover;
|
||||
describeCell(c);
|
||||
printf("Neighbors:"); for(int i=0; i<c->type; i++) printf("%p ", c->mov[i]);
|
||||
printf("Neighbors:"); for(int i=0; i<c->type; i++) printf("%p ", c->move(i));
|
||||
printf("Barrier: dir=%d left=%d right=%d\n",
|
||||
c->bardir, c->barleft, c->barright);
|
||||
return true;
|
||||
@ -399,7 +399,7 @@ void showCheatMenu() {
|
||||
}
|
||||
|
||||
void modalDebug(cell *c) {
|
||||
viewctr.h = c->master;
|
||||
viewctr.at = c->master;
|
||||
if(noGUI) {
|
||||
fprintf(stderr, "fatal: modalDebug called on %p without GUI\n", c);
|
||||
exit(1);
|
||||
@ -537,7 +537,7 @@ int read_cheat_args() {
|
||||
else if(argis("-gencells")) {
|
||||
PHASEFROM(2); shift(); start_game();
|
||||
printf("Generating %d cells...\n", argi());
|
||||
celllister cl(cwt.c, 50, argi(), NULL);
|
||||
celllister cl(cwt.at, 50, argi(), NULL);
|
||||
printf("Cells generated: %d\n", isize(cl.lst));
|
||||
for(int i=0; i<isize(cl.lst); i++)
|
||||
setdist(cl.lst[i], 7, NULL);
|
||||
|
@ -635,19 +635,19 @@ void viewmat() {
|
||||
int id = 0;
|
||||
if(gp::on) {
|
||||
gp::just_matrices = true;
|
||||
gp::draw_li = gp::get_local_info(cwt.c);
|
||||
gp::draw_li = gp::get_local_info(cwt.at);
|
||||
if(gp::draw_li.last_dir == -1) gp::draw_li.total_dir = 0;
|
||||
gp::draw_li.total_dir = fix6(gp::draw_li.total_dir);
|
||||
gp::get_plainshape_id(cwt.c);
|
||||
gp::get_plainshape_id(cwt.at);
|
||||
gp::just_matrices = false;
|
||||
}
|
||||
// if(gp::on && !gp::usedml.count(cwt.c)) return;
|
||||
// for(auto& v: (pseudohept(cwt.c) ? hept_matrices : hex_matrices).v) {
|
||||
// for(auto& v: (gp::on ? gp::usedml[cwt.c] : pseudohept(cwt.c) ? hept_matrices : hex_matrices).v) {
|
||||
// if(gp::on && !gp::usedml.count(cwt.at)) return;
|
||||
// for(auto& v: (pseudohept(cwt.at) ? hept_matrices : hex_matrices).v) {
|
||||
// for(auto& v: (gp::on ? gp::usedml[cwt.c] : pseudohept(cwt.at) ? hept_matrices : hex_matrices).v) {
|
||||
// hyperpoint h1 = gmatrix[cwt.c] * v.second[0] * hpxyz(1,0,0);
|
||||
id = irr::cellindex[cwt.c];
|
||||
for(auto& v: irr::usedml[id].v) {
|
||||
// for(auto& v: (gp::on ? gp::usedml[cwt.c] : pseudohept(cwt.c) ? hept_matrices : hex_matrices).v) {
|
||||
// for(auto& v: (gp::on ? gp::usedml[cwt.c] : pseudohept(cwt.at) ? hept_matrices : hex_matrices).v) {
|
||||
|
||||
hyperpoint h1 = gmatrix[cwt.c] * v.second[0] * hpxyz(1,0,0);
|
||||
hyperpoint h2 = gmatrix[cwt.c] * v.second[0] * hpxyz(0,1,0);
|
||||
|
@ -516,7 +516,7 @@ void showEuclideanMenu() {
|
||||
|
||||
void runGeometryExperiments() {
|
||||
if(!geometry)
|
||||
specialland = getLandForList(cwt.c);
|
||||
specialland = getLandForList(cwt.at);
|
||||
pushScreen(showEuclideanMenu);
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,7 @@ transmatrix spinmatrix[MAX_S84];
|
||||
ld hexshift;
|
||||
|
||||
const transmatrix& getspinmatrix(int id) {
|
||||
while(id>=S84) id -= S84;
|
||||
while(id<0) id += S84;
|
||||
id = (id + MODFIXER) % S84;
|
||||
return spinmatrix[id];
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ transmatrix master_relative(cell *c, bool get_inverse) {
|
||||
}
|
||||
}
|
||||
else if(!nonbitrunc && !euclid) {
|
||||
for(int d=0; d<S7; d++) if(c->master->c7->mov[d] == c)
|
||||
for(int d=0; d<S7; d++) if(c->master->c7->move(d) == c)
|
||||
return (get_inverse?invhexmove:hexmove)[d];
|
||||
return Id;
|
||||
}
|
||||
@ -96,7 +96,7 @@ transmatrix calc_relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hin
|
||||
t = eumovedir(2+i/2) * eumovedir(2+(i+1)/2) * t;
|
||||
else
|
||||
t = eumovedir(2+i/2) * t;
|
||||
if(c2->mirror(i)) mirrors++;
|
||||
if(c2->c.mirror(i)) mirrors++;
|
||||
c2 = c3;
|
||||
goto approach;
|
||||
}
|
||||
@ -122,16 +122,16 @@ transmatrix calc_relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hin
|
||||
if(quotient & qSMALL) {
|
||||
transmatrix T;
|
||||
ld bestdist = 1e9;
|
||||
for(int d=0; d<S7; d++) if(h2->move[d]) {
|
||||
int sp = h2->spin(d);
|
||||
for(int d=0; d<S7; d++) if(h2->move(d)) {
|
||||
int sp = h2->c.spin(d);
|
||||
transmatrix S = heptmove[sp] * spin(2*M_PI*d/S7);
|
||||
if(h2->move[d] == h1) {
|
||||
if(h2->move(d) == h1) {
|
||||
transmatrix T1 = gm * S * where;
|
||||
auto curdist = hdist(tC0(T1), point_hint);
|
||||
if(curdist < bestdist) T = T1, bestdist = curdist;
|
||||
}
|
||||
for(int e=0; e<S7; e++) if(h2->move[d]->move[e] == h1) {
|
||||
int sp2 = h2->move[d]->spin(e);
|
||||
for(int e=0; e<S7; e++) if(h2->move(d)->move(e) == h1) {
|
||||
int sp2 = h2->move(d)->c.spin(e);
|
||||
transmatrix T1 = gm * heptmove[sp2] * spin(2*M_PI*e/S7) * S * where;
|
||||
auto curdist = hdist(tC0(T1), point_hint);
|
||||
if(curdist < bestdist) T = T1, bestdist = curdist;
|
||||
@ -139,28 +139,28 @@ transmatrix calc_relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hin
|
||||
}
|
||||
if(bestdist < 1e8) return T;
|
||||
}
|
||||
for(int d=0; d<S7; d++) if(h2->move[d] == h1) {
|
||||
int sp = h2->spin(d);
|
||||
for(int d=0; d<S7; d++) if(h2->move(d) == h1) {
|
||||
int sp = h2->c.spin(d);
|
||||
return gm * heptmove[sp] * spin(2*M_PI*d/S7) * where;
|
||||
}
|
||||
if(geometry == gFieldQuotient) {
|
||||
int bestdist = 1000, bestd = 0;
|
||||
for(int d=0; d<S7; d++) {
|
||||
int dist = celldistance(h2->move[d]->c7, c1);
|
||||
int dist = celldistance(h2->move(d)->c7, c1);
|
||||
if(dist < bestdist) bestdist = dist, bestd = d;
|
||||
}
|
||||
int sp = h2->spin(bestd);
|
||||
int sp = h2->c.spin(bestd);
|
||||
where = heptmove[sp] * spin(2*M_PI*bestd/S7) * where;
|
||||
h2 = h2->move[bestd];
|
||||
h2 = h2->move(bestd);
|
||||
}
|
||||
else if(h1->distance < h2->distance) {
|
||||
int sp = h2->spin(0);
|
||||
h2 = h2->move[0];
|
||||
int sp = h2->c.spin(0);
|
||||
h2 = h2->move(0);
|
||||
where = heptmove[sp] * where;
|
||||
}
|
||||
else {
|
||||
int sp = h1->spin(0);
|
||||
h1 = h1->move[0];
|
||||
int sp = h1->c.spin(0);
|
||||
h1 = h1->move(0);
|
||||
gm = gm * invheptmove[sp];
|
||||
}
|
||||
}
|
||||
@ -180,14 +180,14 @@ transmatrix calc_relative_matrix(cell *c2, cell *c1, const hyperpoint& point_hin
|
||||
transmatrix &ggmatrix(cell *c) {
|
||||
transmatrix& t = gmatrix[c];
|
||||
if(t[2][2] == 0) {
|
||||
if(torus && centerover.c)
|
||||
t = calc_relative_matrix(c, centerover.c, C0);
|
||||
if(torus && centerover.at)
|
||||
t = calc_relative_matrix(c, centerover.at, C0);
|
||||
else if(euclid) {
|
||||
if(!centerover.c) centerover = cwt;
|
||||
if(!centerover.at) centerover = cwt;
|
||||
t = View * eumove(cell_to_vec(c) - cellwalker_to_vec(centerover));
|
||||
}
|
||||
else
|
||||
t = actualV(viewctr, cview()) * calc_relative_matrix(c, viewctr.h->c7, C0);
|
||||
t = actualV(viewctr, cview()) * calc_relative_matrix(c, viewctr.at->c7, C0);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
@ -200,21 +200,21 @@ transmatrix calc_relative_matrix_help(cell *c, heptagon *h1) {
|
||||
auto li = gp::get_local_info(c);
|
||||
where = gp::Tf[li.last_dir][li.relative.first&31][li.relative.second&31][fix6(li.total_dir)];
|
||||
}
|
||||
else if(!nonbitrunc) for(int d=0; d<S7; d++) if(h2->c7->mov[d] == c)
|
||||
else if(!nonbitrunc) for(int d=0; d<S7; d++) if(h2->c7->move(d) == c)
|
||||
where = hexmove[d];
|
||||
// always add to last!
|
||||
while(h1 != h2) {
|
||||
for(int d=0; d<S7; d++) if(h1->move[d] == h2) printf("(adj) ");
|
||||
for(int d=0; d<S7; d++) if(h1->move(d) == h2) printf("(adj) ");
|
||||
if(h1->distance < h2->distance) {
|
||||
int sp = h2->spin(0);
|
||||
int sp = h2->c.spin(0);
|
||||
printf("A%d ", sp);
|
||||
h2 = h2->move[0];
|
||||
h2 = h2->move(0);
|
||||
where = heptmove[sp] * where;
|
||||
}
|
||||
else {
|
||||
int sp = h1->spin(0);
|
||||
int sp = h1->c.spin(0);
|
||||
printf("B%d ", sp);
|
||||
h1 = h1->move[0];
|
||||
h1 = h1->move(0);
|
||||
gm = gm * invheptmove[sp];
|
||||
}
|
||||
}
|
||||
@ -262,16 +262,14 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
|
||||
transmatrix bestV;
|
||||
|
||||
for(int d=0; d<S7; d++) {
|
||||
heptspin hs;
|
||||
hs.h = h;
|
||||
hs.spin = d;
|
||||
heptspin hs(h, d, false);
|
||||
heptspin hs2 = hs + wstep;
|
||||
transmatrix V2 = spin(-hs2.spin*2*M_PI/S7) * invheptmove[d];
|
||||
double newz = check(V2 * at) [2];
|
||||
if(newz < currz) {
|
||||
currz = newz;
|
||||
bestV = V2;
|
||||
newbase = hs2.h->c7;
|
||||
newbase = hs2.at->c7;
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +280,7 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
|
||||
else {
|
||||
if(tohex && !nonbitrunc) for(int d=0; d<S7; d++) {
|
||||
cell *c = createMov(base, d);
|
||||
transmatrix V2 = spin(-base->spn(d)*2*M_PI/S6) * invhexmove[d];
|
||||
transmatrix V2 = spin(-base->c.spin(d)*2*M_PI/S6) * invhexmove[d];
|
||||
double newz = check(V2 *at) [2];
|
||||
if(newz < currz) {
|
||||
currz = newz;
|
||||
@ -310,14 +308,14 @@ void virtualRebase(cell*& base, hyperpoint& h, bool tohex) {
|
||||
}
|
||||
|
||||
double cellgfxdist(cell *c, int i) {
|
||||
if(gp::on || irr::on) return hdist0(tC0(calc_relative_matrix(c->mov[i], c, i)));
|
||||
if(gp::on || irr::on) return hdist0(tC0(calc_relative_matrix(c->move(i), c, i)));
|
||||
return nonbitrunc ? tessf * gp::scale : (c->type == 6 && (i&1)) ? hexhexdist : crossf;
|
||||
}
|
||||
|
||||
transmatrix cellrelmatrix(cell *c, int i) {
|
||||
if(gp::on) return calc_relative_matrix(c->mov[i], c, i);
|
||||
if(gp::on) return calc_relative_matrix(c->move(i), c, i);
|
||||
double d = cellgfxdist(c, i);
|
||||
return ddspin(c, i) * xpush(d) * iddspin(c->mov[i], c->spin(i), euclid ? 0 : S42);
|
||||
return ddspin(c, i) * xpush(d) * iddspin(c->move(i), c->c.spin(i), euclid ? 0 : S42);
|
||||
}
|
||||
|
||||
double randd() { return (rand() + .5) / (RAND_MAX + 1.); }
|
||||
@ -375,9 +373,9 @@ hyperpoint get_corner_position(cell *c, int cid, ld cf) {
|
||||
hyperpoint hypercorner(cell *c, gp::local_info& li, int i) {
|
||||
cellwalker cw(c, i);
|
||||
cw += wstep;
|
||||
transmatrix cwm = calc_relative_matrix(cw.c, c, i);
|
||||
transmatrix cwm = calc_relative_matrix(cw.at, c, i);
|
||||
if(elliptic && cwm[2][2] < 0) cwm = centralsym * cwm;
|
||||
return cwm * gp::get_corner_position(cw.c, (cw+2).spin);
|
||||
return cwm * gp::get_corner_position(cw.at, (cw+2).spin);
|
||||
}
|
||||
|
||||
hyperpoint midcorner(cell *c, int i, ld v) {
|
||||
@ -407,7 +405,7 @@ hyperpoint nearcorner(cell *c, int i) {
|
||||
if(gp::on) {
|
||||
cellwalker cw(c, i);
|
||||
cw += wstep;
|
||||
transmatrix cwm = calc_relative_matrix(cw.c, c, i);
|
||||
transmatrix cwm = calc_relative_matrix(cw.at, c, i);
|
||||
if(elliptic && cwm[2][2] < 0) cwm = centralsym * cwm;
|
||||
return cwm * C0;
|
||||
}
|
||||
@ -447,9 +445,9 @@ hyperpoint farcorner(cell *c, int i, int which) {
|
||||
cellwalker cw(c, i);
|
||||
int hint = cw.spin;
|
||||
cw += wstep;
|
||||
transmatrix cwm = calc_relative_matrix(cw.c, c, hint);
|
||||
transmatrix cwm = calc_relative_matrix(cw.at, c, hint);
|
||||
// hyperpoint nfar = cwm*C0;
|
||||
auto li1 = gp::get_local_info(cw.c);
|
||||
auto li1 = gp::get_local_info(cw.at);
|
||||
if(which == 0)
|
||||
return cwm * get_corner_position(li1, (cw+2).spin);
|
||||
if(which == 1)
|
||||
|
46
goldberg.cpp
46
goldberg.cpp
@ -84,8 +84,8 @@ namespace hr { namespace gp {
|
||||
else {
|
||||
vector<int> dirs;
|
||||
while(c != c->master->c7) {
|
||||
dirs.push_back(c->spin(0));
|
||||
c = c->mov[0];
|
||||
dirs.push_back(c->c.spin(0));
|
||||
c = c->move(0);
|
||||
}
|
||||
li.first_dir = dirs[0];
|
||||
li.last_dir = dirs.back();
|
||||
@ -125,7 +125,7 @@ namespace hr { namespace gp {
|
||||
goldberg_mapping_t goldberg_map[32][32];
|
||||
void clear_mapping() {
|
||||
for(int y=0; y<32; y++) for(int x=0; x<32; x++) {
|
||||
goldberg_map[y][x].cw.c = NULL;
|
||||
goldberg_map[y][x].cw.at = NULL;
|
||||
goldberg_map[y][x].rdir = -1;
|
||||
goldberg_map[y][x].mindir = 0;
|
||||
}
|
||||
@ -147,18 +147,14 @@ namespace hr { namespace gp {
|
||||
static char bufs[16][32];
|
||||
static int bufid;
|
||||
bufid++; bufid %= 16;
|
||||
snprintf(bufs[bufid], 32, "[%p/%2d:%d:%d]", cw.c, cw.c?cw.c->type:-1, cw.spin, cw.mirrored);
|
||||
snprintf(bufs[bufid], 32, "[%p/%2d:%d:%d]", cw.at, cw.at?cw.at->type:-1, cw.spin, cw.mirrored);
|
||||
return bufs[bufid];
|
||||
}
|
||||
|
||||
int spawn;
|
||||
|
||||
bool operator != (cellwalker cw1, cellwalker cw2) {
|
||||
return cw1.c != cw2.c || cw1.spin != cw2.spin || cw1.mirrored != cw2.mirrored;
|
||||
}
|
||||
|
||||
cell*& peek(cellwalker cw) {
|
||||
return cw.c->mov[cw.spin];
|
||||
return cw.at->move(cw.spin);
|
||||
}
|
||||
|
||||
cellwalker get_localwalk(const goldberg_mapping_t& wc, int dir) {
|
||||
@ -179,7 +175,7 @@ namespace hr { namespace gp {
|
||||
int dir1 = fixg6(dir+SG3);
|
||||
cellwalker wcw = get_localwalk(wc, dir);
|
||||
auto& wc1= get_mapping(at1);
|
||||
if(wc1.cw.c) {
|
||||
if(wc1.cw.at) {
|
||||
if(peek(wcw)) {
|
||||
auto wcw1 = get_localwalk(wc1, dir1);
|
||||
if(wcw + wstep != wcw1) {
|
||||
@ -203,15 +199,15 @@ namespace hr { namespace gp {
|
||||
auto& wc1 = get_mapping(at + eudir(dir));
|
||||
WHD( Xprintf(" md:%02d s:%d", wc.mindir, wc.cw.spin); )
|
||||
WHD( Xprintf(" connection %s/%d %s=%s ~ %s/%d ", disp(at), dir, dcw(wc.cw+dir), dcw(wcw), disp(at+eudir(dir)), dir1); )
|
||||
if(!wc1.cw.c) {
|
||||
if(!wc1.cw.at) {
|
||||
wc1.start = wc.start;
|
||||
if(peek(wcw)) {
|
||||
WHD( Xprintf("(pulled) "); )
|
||||
set_localwalk(wc1, dir1, wcw + wstep);
|
||||
}
|
||||
else {
|
||||
peek(wcw) = newCell(SG6, wc.cw.c->master);
|
||||
tsetspin(wcw.c->spintable, wcw.spin, 0);
|
||||
peek(wcw) = newCell(SG6, wc.cw.at->master);
|
||||
wcw.at->c.setspin(wcw.spin, 0, false);
|
||||
set_localwalk(wc1, dir1, wcw + wstep);
|
||||
spawn++;
|
||||
WHD( Xprintf("(created) "); )
|
||||
@ -229,8 +225,8 @@ namespace hr { namespace gp {
|
||||
}
|
||||
else {
|
||||
WHD(Xprintf("ok\n"); )
|
||||
peek(wcw) = wcw1.c;
|
||||
tsetspin(wcw.c->spintable, wcw.spin, wcw1.spin + (wcw.mirrored != wcw1.mirrored ? 8 : 0));
|
||||
peek(wcw) = wcw1.at;
|
||||
wcw.at->c.setspin(wcw.spin, wcw1.spin, wcw.mirrored != wcw1.mirrored);
|
||||
if(wcw+wstep != wcw1) {
|
||||
Xprintf("assertion failed\n");
|
||||
exit(1);
|
||||
@ -245,7 +241,7 @@ namespace hr { namespace gp {
|
||||
|
||||
goldberg_mapping_t& set_heptspin(loc at, heptspin hs) {
|
||||
auto& ac0 = get_mapping(at);
|
||||
ac0.cw = cellwalker(hs.h->c7, hs.spin, hs.mirrored);
|
||||
ac0.cw = cellwalker(hs.at->c7, hs.spin, hs.mirrored);
|
||||
ac0.start = at;
|
||||
WHD( Xprintf("%s : %s\n", disp(at), dcw(ac0.cw)); )
|
||||
return ac0;
|
||||
@ -255,15 +251,15 @@ namespace hr { namespace gp {
|
||||
WHD( Xprintf("EXTEND %p %d\n", c, d); )
|
||||
if(c->master->c7 != c) {
|
||||
while(c->master->c7 != c) {
|
||||
WHD( Xprintf("%p direction 0 corresponds to %p direction %d\n", c, c->mov[0], c->spin(0)); )
|
||||
d = c->spin(0);
|
||||
c = c->mov[0];
|
||||
WHD( Xprintf("%p direction 0 corresponds to %p direction %d\n", c, c->move(0), c->c.spin(0)); )
|
||||
d = c->c.spin(0);
|
||||
c = c->move(0);
|
||||
}
|
||||
// c move 0 equals c' move spin(0)
|
||||
extend_map(c, d);
|
||||
extend_map(c, fixdir(d-1, c));
|
||||
extend_map(c, fixdir(d+1, c));
|
||||
if(S3 == 4 && !c->mov[d])
|
||||
if(S3 == 4 && !c->move(d))
|
||||
for(int i=0; i<S7; i++)
|
||||
for(int j=0; j<S7; j++)
|
||||
extend_map(createStep(c->master, i)->c7, j);
|
||||
@ -419,7 +415,7 @@ namespace hr { namespace gp {
|
||||
case 1: {
|
||||
auto at2 = at + eudir(dx+1);
|
||||
auto& wc2 = get_mapping(at2);
|
||||
if(wc2.cw.c) { at = at1; continue; }
|
||||
if(wc2.cw.at) { at = at1; continue; }
|
||||
wc.rdir = (dx+1) % 6;
|
||||
conn(at, (dx+1) % 6);
|
||||
conn(at1, (dx+2) % 6);
|
||||
@ -440,7 +436,7 @@ namespace hr { namespace gp {
|
||||
case 1:
|
||||
auto at2 = at + eudir(dx+1);
|
||||
auto& wc2 = get_mapping(at2);
|
||||
if(wc2.cw.c) {
|
||||
if(wc2.cw.at) {
|
||||
auto at3 = at1 + eudir(wc1.rdir);
|
||||
auto& wc3 = get_mapping(at3);
|
||||
auto at4 = at3 + eudir(wc3.rdir);
|
||||
@ -462,7 +458,7 @@ namespace hr { namespace gp {
|
||||
int bdist = 100;
|
||||
for(int d=0; d<4; d++) {
|
||||
auto &wcm = get_mapping(at2 + eudir(d));
|
||||
if(wcm.cw.c && length(wcm.start - at2) < bdist)
|
||||
if(wcm.cw.at && length(wcm.start - at2) < bdist)
|
||||
bdist = length(wcm.start - at2), bdir = d;
|
||||
}
|
||||
if(bdir != -1) conn(at2 + eudir(bdir), bdir ^ 2);
|
||||
@ -883,7 +879,7 @@ namespace hr { namespace gp {
|
||||
else if(irr::on)
|
||||
return irr::get_masters(c);
|
||||
else
|
||||
return make_array(c->mov[0]->master, c->mov[2]->master, c->mov[4]->master);
|
||||
return make_array(c->move(0)->master, c->move(2)->master, c->move(4)->master);
|
||||
}
|
||||
|
||||
int compute_dist(cell *c, int master_function(cell*)) {
|
||||
@ -902,7 +898,7 @@ namespace hr { namespace gp {
|
||||
if(S3 == 4) {
|
||||
heptspin hs(cm->master, i);
|
||||
hs += wstep; hs+=-1; hs += wstep;
|
||||
auto d2 = master_function(hs.h->c7);
|
||||
auto d2 = master_function(hs.at->c7);
|
||||
return solve_quad(dmain, d0, d1, d2, at);
|
||||
}
|
||||
|
||||
|
176
graph.cpp
176
graph.cpp
@ -135,7 +135,7 @@ void drawShield(const transmatrix& V, eItem it) {
|
||||
int col = iinf[it].color;
|
||||
if(it == itOrbShield && items[itOrbTime] && !orbused[it])
|
||||
col = (col & 0xFEFEFE) / 2;
|
||||
if(sphere && cwt.c->land == laHalloween && !wmblack && !wmascii)
|
||||
if(sphere && cwt.at->land == laHalloween && !wmblack && !wmascii)
|
||||
col = 0;
|
||||
double d = it == itOrbShield ? hexf : hexf - .1;
|
||||
int mt = sphere ? 7 : 5;
|
||||
@ -240,7 +240,7 @@ int displaydir(cell *c, int d) {
|
||||
auto& vs = irr::cells[id];
|
||||
if(d < 0 || d >= c->type) return 0;
|
||||
auto& p = vs.jpoints[vs.neid[d]];
|
||||
return -int(atan2(p[1], p[0]) * S84 / 2 / M_PI + MODFIXER + .5);
|
||||
return -int(atan2(p[1], p[0]) * S84 / 2 / M_PI + .5);
|
||||
}
|
||||
else if(binarytiling) {
|
||||
if(d == NODIR) return 0;
|
||||
@ -310,7 +310,7 @@ void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
|
||||
if(a == ang && items[itOrbSword]) continue;
|
||||
if(nonbitrunc && !gp::on && !irr::on && a%3 != ang%3) continue;
|
||||
if((a+S21)%S42 == ang && items[itOrbSword2]) continue;
|
||||
bool longer = sword::pos(cwt.c, a-1) != sword::pos(cwt.c, a+1);
|
||||
bool longer = sword::pos(cwt.at, a-1) != sword::pos(cwt.at, a+1);
|
||||
int col = darkena(0xC0C0C0, 0, 0xFF);
|
||||
queueline(Vnow*ddi0(dda, nonbitrunc ? 0.6 * gp::scale : longer ? 0.36 : 0.4), Vnow*ddi0(dda, nonbitrunc ? 0.7 * gp::scale : longer ? 0.44 : 0.42), col, 1);
|
||||
}
|
||||
@ -562,8 +562,8 @@ void otherbodyparts(const transmatrix& V, int col, eMonster who, double footphas
|
||||
|
||||
bool drawstar(cell *c) {
|
||||
for(int t=0; t<c->type; t++)
|
||||
if(c->mov[t] && c->mov[t]->wall != waSulphur && c->mov[t]->wall != waSulphurC &&
|
||||
c->mov[t]->wall != waBarrier)
|
||||
if(c->move(t) && c->move(t)->wall != waSulphur && c->move(t)->wall != waSulphurC &&
|
||||
c->move(t)->wall != waBarrier)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -1801,7 +1801,7 @@ int cellcolor(cell *c) {
|
||||
int taildist(cell *c) {
|
||||
int s = 0;
|
||||
while(s < 1000 && c->mondir != NODIR && isWorm(c->monst)) {
|
||||
s++; c = c->mov[c->mondir];
|
||||
s++; c = c->move(c->mondir);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -1850,11 +1850,11 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
int d = c->mondir;
|
||||
if(d == NODIR)
|
||||
forCellIdEx(c2, i, c)
|
||||
if(among(c2->monst, moHexSnakeTail, moHexSnake) && c2->mondir == c->spin(i))
|
||||
if(among(c2->monst, moHexSnakeTail, moHexSnake) && c2->mondir == c->c.spin(i))
|
||||
d = i;
|
||||
if(d == NODIR) { d = hrand(c->type); createMov(c, d); }
|
||||
int c1 = nestcolors[pattern_threecolor(c)];
|
||||
int c2 = nestcolors[pattern_threecolor(c->mov[d])];
|
||||
int c2 = nestcolors[pattern_threecolor(c->move(d))];
|
||||
col = (c1 + c2); // sum works because they are dark and should be brightened
|
||||
}
|
||||
|
||||
@ -1865,9 +1865,9 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
|
||||
if(mmmon) {
|
||||
ld length;
|
||||
// cell *c2 = c->mov[c->mondir];
|
||||
// cell *c2 = c->move(c->mondir);
|
||||
if(nospinb)
|
||||
chainAnimation(c, Vb, c->mov[c->mondir], c->mondir, 0, Vparam, length);
|
||||
chainAnimation(c, Vb, c->move(c->mondir), c->mondir, 0, Vparam, length);
|
||||
else {
|
||||
Vb = Vb * ddspin(c, c->mondir);
|
||||
length = cellgfxdist(c, c->mondir);
|
||||
@ -1968,8 +1968,8 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
else if(m == moDragonTail) {
|
||||
cell *c2 = NULL;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && isDragon(c->mov[i]->monst) && c->mov[i]->mondir == c->spn(i))
|
||||
c2 = c->mov[i];
|
||||
if(c->move(i) && isDragon(c->move(i)->monst) && c->move(i)->mondir == c->c.spin(i))
|
||||
c2 = c->move(i);
|
||||
int nd = neighborId(c, c2);
|
||||
char part = dragon::bodypart(c, dragon::findhead(c));
|
||||
if(part == 't') {
|
||||
@ -1990,7 +1990,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
ld length;
|
||||
chainAnimation(c, Vb, c2, nd, 0, Vparam, length);
|
||||
Vb = Vb * pispin;
|
||||
double ang = chainAngle(c, Vb, c->mov[c->mondir], (displaydir(c, c->mondir) - displaydir(c, nd)) * M_PI / S42, Vparam);
|
||||
double ang = chainAngle(c, Vb, c->move(c->mondir), (displaydir(c, c->mondir) - displaydir(c, nd)) * M_PI / S42, Vparam);
|
||||
ang /= 2;
|
||||
Vb = Vb * spin(M_PI-ang);
|
||||
}
|
||||
@ -2016,8 +2016,8 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
bool hexsnake = c->monst == moHexSnake || c->monst == moHexSnakeTail;
|
||||
cell *c2 = NULL;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && isWorm(c->mov[i]->monst) && c->mov[i]->mondir == c->spn(i))
|
||||
c2 = c->mov[i];
|
||||
if(c->move(i) && isWorm(c->move(i)->monst) && c->move(i)->mondir == c->c.spin(i))
|
||||
c2 = c->move(i);
|
||||
int nd = neighborId(c, c2);
|
||||
if(nospinb) {
|
||||
ld length;
|
||||
@ -2045,17 +2045,17 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
copies = 2;
|
||||
if(xdir == -1) copies = 6, xdir = 0;
|
||||
}
|
||||
for(auto& m: mirror::mirrors) if(c == m.second.c)
|
||||
for(auto& m: mirror::mirrors) if(c == m.second.at)
|
||||
for(int d=0; d<copies; d++) {
|
||||
multi::cpid = m.first;
|
||||
auto cw = m.second;
|
||||
if(d&1) cwmirrorat(cw, xdir);
|
||||
if(d&1) cw = cw.mirrorat(xdir);
|
||||
if(d>=2) cw += 2;
|
||||
if(d>=4) cw += 2;
|
||||
transmatrix Vs = Vparam;
|
||||
bool mirr = cw.mirrored;
|
||||
Vs = Vs * ddspin(c, cw.spin-cwt.spin, stdeuclid ? 0 : S42);
|
||||
nospins = applyAnimation(cwt.c, Vs, footphase, LAYER_SMALL);
|
||||
nospins = applyAnimation(cwt.at, Vs, footphase, LAYER_SMALL);
|
||||
if(!nospins) Vs = Vs * ddspin(c, cwt.spin);
|
||||
if(mirr) Vs = Vs * Mirror;
|
||||
if(inmirrorcount&1) mirr = !mirr;
|
||||
@ -2092,8 +2092,8 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
if(!nospins) {
|
||||
int d = 0;
|
||||
double bheat = -999;
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i] && HEAT(c->mov[i]) > bheat) {
|
||||
bheat = HEAT(c->mov[i]);
|
||||
for(int i=0; i<c->type; i++) if(c->move(i) && HEAT(c->move(i)) > bheat) {
|
||||
bheat = HEAT(c->move(i));
|
||||
d = i;
|
||||
}
|
||||
Vs = Vs * ddspin(c, d);
|
||||
@ -2105,12 +2105,12 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
|
||||
if(c->hitpoints == 0) col = 0x404040;
|
||||
if(nospinb) {
|
||||
ld length;
|
||||
chainAnimation(c, Vb, c->mov[c->mondir], c->mondir, 0, Vparam, length);
|
||||
chainAnimation(c, Vb, c->move(c->mondir), c->mondir, 0, Vparam, length);
|
||||
Vb = Vb * pispin;
|
||||
Vb = Vb * xpush(tentacle_length - cellgfxdist(c, c->mondir));
|
||||
}
|
||||
else if(gp::on || irr::on) {
|
||||
transmatrix T = calc_relative_matrix(c->mov[c->mondir], c, c->mondir);
|
||||
transmatrix T = calc_relative_matrix(c->move(c->mondir), c, c->mondir);
|
||||
Vb = Vb * T * rspintox(tC0(inverse(T))) * xpush(tentacle_length);
|
||||
}
|
||||
else {
|
||||
@ -2356,7 +2356,7 @@ void drawaura() {
|
||||
bool bugsNearby(cell *c, int dist = 2) {
|
||||
if(!(havewhat&HF_BUG)) return false;
|
||||
if(isBug(c)) return true;
|
||||
if(dist) for(int t=0; t<c->type; t++) if(c->mov[t] && bugsNearby(c->mov[t], dist-1)) return true;
|
||||
if(dist) for(int t=0; t<c->type; t++) if(c->move(t) && bugsNearby(c->move(t), dist-1)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2384,7 +2384,7 @@ const char* minetexts[8] = {
|
||||
int countMinesAround(cell *c) {
|
||||
int mines = 0;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && c->mov[i]->wall == waMineMine)
|
||||
if(c->move(i) && c->move(i)->wall == waMineMine)
|
||||
mines++;
|
||||
return mines;
|
||||
}
|
||||
@ -2552,7 +2552,7 @@ void viewBuggyCells(cell *c, transmatrix V) {
|
||||
|
||||
for(int i=0; i<isize(buggycells); i++) {
|
||||
cell *c1 = buggycells[i];
|
||||
cell *cf = cwt.c;
|
||||
cell *cf = cwt.at;
|
||||
|
||||
while(cf != c1) {
|
||||
cf = pathTowards(cf, c1);
|
||||
@ -2573,7 +2573,7 @@ void drawMovementArrows(cell *c, transmatrix V) {
|
||||
movedir md = vectodir(spin(-d * M_PI/4) * tC0(pushone()));
|
||||
int u = md.d;
|
||||
cellwalker xc = cwt + u + wstep;
|
||||
if(xc.c == c) {
|
||||
if(xc.at == c) {
|
||||
transmatrix fixrot = sphereflip * rgpushxto0(sphereflip * tC0(V));
|
||||
// make it more transparent
|
||||
int col = getcs().uicolor;
|
||||
@ -2639,7 +2639,7 @@ void setcolors(cell *c, int& wcol, int &fcol) {
|
||||
int mafcol = (kraken_pseudohept(c) ? 64 : 8);
|
||||
/* bool nearshore = false;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i]->wall != waSea && c->mov[i]->wall != waBoat)
|
||||
if(c->move(i)->wall != waSea && c->move(i)->wall != waBoat)
|
||||
nearshore = true;
|
||||
if(nearshore) mafcol += 30; */
|
||||
fcol = fcol + mafcol * (4+sin(ticks / 500. + ((eubinary||c->master->alt) ? celldistAlt(c) : 0)*1.5))/5;
|
||||
@ -2962,7 +2962,7 @@ void setcolors(cell *c, int& wcol, int &fcol) {
|
||||
}
|
||||
if(isHaunted(c->land)) {
|
||||
int itcolor = 0;
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i] && c->mov[i]->item)
|
||||
for(int i=0; i<c->type; i++) if(c->move(i) && c->move(i)->item)
|
||||
itcolor = 1;
|
||||
if(c->item) itcolor |= 2;
|
||||
fcol = 0x609F60 + 0x202020 * itcolor;
|
||||
@ -3176,8 +3176,8 @@ bool placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, int col) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(qfi.fshape == &shBigTriangle && pseudohept(c->mov[i])) return false;
|
||||
if(qfi.fshape == &shTriheptaFloor && !pseudohept(c) && !pseudohept(c->mov[i])) return false;
|
||||
if(qfi.fshape == &shBigTriangle && pseudohept(c->move(i))) return false;
|
||||
if(qfi.fshape == &shTriheptaFloor && !pseudohept(c) && !pseudohept(c->move(i))) return false;
|
||||
|
||||
int prio;
|
||||
/* if(mirr) prio = PPR_GLASS - 2;
|
||||
@ -3392,7 +3392,7 @@ void draw_wall(cell *c, const transmatrix& V, int wcol, int& zcol, int ct6, int
|
||||
|
||||
if(c->wall == waClosedGate) {
|
||||
int hdir = 0;
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i]->wall == waClosedGate)
|
||||
for(int i=0; i<c->type; i++) if(c->move(i)->wall == waClosedGate)
|
||||
hdir = i;
|
||||
transmatrix V2 = mscale(V, wmspatial?geom3::WALL:1) * ddspin(c, hdir, S42);
|
||||
queuepolyat(V2, shPalaceGate, darkena(wcol, 0, 0xFF), wmspatial?PPR_WALL3A:PPR_WALL);
|
||||
@ -3565,8 +3565,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
int cmc = (cw.mirrored == mirrored) ? 2 : 1;
|
||||
inmirrorcount += cmc;
|
||||
if(cw.mirrored != mirrored) V = V * Mirror;
|
||||
if(cw.spin) V = V * spin(2*M_PI*cw.spin/cw.c->type);
|
||||
drawcell(cw.c, V, 0, cw.mirrored);
|
||||
if(cw.spin) V = V * spin(2*M_PI*cw.spin/cw.at->type);
|
||||
drawcell(cw.at, V, 0, cw.mirrored);
|
||||
inmirrorcount -= cmc;
|
||||
return;
|
||||
}
|
||||
@ -3621,7 +3621,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
}
|
||||
|
||||
if(viewdists && !behindsphere(V)) {
|
||||
int cd = (cwt.c == currentmap->gamestart() && numplayers() == 1) ? celldist(c) : celldistance(c, cwt.c);
|
||||
int cd = (cwt.at == currentmap->gamestart() && numplayers() == 1) ? celldist(c) : celldistance(c, cwt.at);
|
||||
string label = its(cd);
|
||||
// string label = its(fieldpattern::getriverdistleft(c)) + its(fieldpattern::getriverdistright(c));
|
||||
int dc = distcolors[cd&7];
|
||||
@ -3726,7 +3726,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
int tim = ticks - lightat;
|
||||
if(tim > 1000) tim = 800;
|
||||
if(elec::havecharge && tim > 400) tim = 400;
|
||||
for(int t=0; t<c->type; t++) if(c->mov[t] && c->mov[t]->ligon) {
|
||||
for(int t=0; t<c->type; t++) if(c->move(t) && c->move(t)->ligon) {
|
||||
int hdir = displaydir(c, t);
|
||||
int lcol = darkena(gradient(iinf[itOrbLightning].color, 0, 0, tim, 1100), 0, 0xFF);
|
||||
queueline(V*ddi0(ticks, hexf/2), V*ddi0(hdir, crossf), lcol, 2 + vid.linequality);
|
||||
@ -3814,19 +3814,19 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
bool onleft = c->type == 7;
|
||||
if(c->type == 7 && c->barleft == laMirror)
|
||||
onleft = !onleft;
|
||||
if(c->type == 6 && c->mov[d]->barleft == laMirror)
|
||||
if(c->type == 6 && d != -1 && c->move(d)->barleft == laMirror)
|
||||
onleft = !onleft;
|
||||
if(nonbitrunc) onleft = !onleft;
|
||||
|
||||
if(d == -1) {
|
||||
for(d=0; d<6; d++)
|
||||
if(c->mov[d] && c->mov[(1+d)%6] && c->mov[d]->land == laMirrorWall && c->mov[(1+d)%6]->land == laMirrorWall)
|
||||
for(d=0; d<c->type; d++)
|
||||
if(c->move(d) && c->modmove(d+1) && c->move(d)->land == laMirrorWall && c->modmove(d+1)->land == laMirrorWall)
|
||||
break;
|
||||
qfi.spin = ddspin(c, d, 0);
|
||||
transmatrix V2 = V * qfi.spin;
|
||||
if(!wmblack) for(int d=0; d<6; d++) {
|
||||
transmatrix V2 = V * qfi.spin;
|
||||
if(!wmblack) for(int d=0; d<c->type; d++) {
|
||||
inmirrorcount+=d;
|
||||
queuepolyat(V2 * spin(d*M_PI/3), shHalfFloor[2], darkena(fcol, fd, 0xFF), PPR_FLOORa);
|
||||
queuepolyat(V2 * spin(d*M_PI/S3), shHalfFloor[2], darkena(fcol, fd, 0xFF), PPR_FLOORa);
|
||||
inmirrorcount-=d;
|
||||
}
|
||||
if(wmspatial) {
|
||||
@ -3860,7 +3860,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
else if(c->land == laWineyard && cellHalfvine(c)) {
|
||||
|
||||
int i =-1;
|
||||
for(int t=0;t<6; t++) if(c->mov[t] && c->mov[t]->wall == c->wall)
|
||||
for(int t=0;t<6; t++) if(c->move(t) && c->move(t)->wall == c->wall)
|
||||
i = t;
|
||||
|
||||
qfi.spin = ddspin(c, i, S14);
|
||||
@ -4104,8 +4104,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
int bridgedir = -1;
|
||||
if(c->type == 6) {
|
||||
for(int i=1; i<c->type; i+=2)
|
||||
if(pseudohept(c->mov[(i+5)%6]) && c->mov[(i+5)%6]->land == laMercuryRiver)
|
||||
if(pseudohept(c->mov[(i+1)%6]) && c->mov[(i+1)%6]->land == laMercuryRiver)
|
||||
if(pseudohept(c->modmove(i-1)) && c->modmove(i-1)->land == laMercuryRiver)
|
||||
if(pseudohept(c->modmove(i+1)) && c->modmove(i+1)->land == laMercuryRiver)
|
||||
bridgedir = i;
|
||||
}
|
||||
if(bridgedir == -1)
|
||||
@ -4114,7 +4114,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
transmatrix bspin = ddspin(c, bridgedir);
|
||||
set_floor(bspin, shMercuryBridge[0]);
|
||||
// only needed in one direction
|
||||
if(c < c->mov[bridgedir]) {
|
||||
if(c < c->move(bridgedir)) {
|
||||
bspin = Vf * bspin;
|
||||
queuepoly(bspin, shMercuryBridge[1], darkena(fcol, fd+1, 0xFF));
|
||||
if(wmspatial) {
|
||||
@ -4554,7 +4554,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
setcolors(c2, wcol2, fcol2);
|
||||
int col = (highwall(c2) || c->wall == waTower) ? wcol2 : fcol2;
|
||||
col = gradient(0, col, 0, spherity(V), 1);
|
||||
int j = c->spin(i);
|
||||
int j = c->c.spin(i);
|
||||
if(ticks % 500 < -250) {
|
||||
V2 = V2 * ddspin(c2, j);
|
||||
j = 0;
|
||||
@ -4627,7 +4627,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
|
||||
if(cellHalfvine(c)) {
|
||||
int i =-1;
|
||||
for(int t=0;t<6; t++) if(c->mov[t] && c->mov[t]->wall == c->wall)
|
||||
for(int t=0;t<6; t++) if(c->move(t) && c->move(t)->wall == c->wall)
|
||||
i = t;
|
||||
|
||||
Vboat = &(Vboat0 = *Vboat * ddspin(c, i) * xpush(-.13));
|
||||
@ -4657,7 +4657,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
if(ad == 1 || ad == 2) {
|
||||
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(airdist(c2) < airdist(c)) {
|
||||
calcAirdir(c2); // printf("airdir = %d\n", airdir);
|
||||
transmatrix V0 = ddspin(c, i, S42);
|
||||
@ -4740,12 +4740,12 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
ld yx = log(2) / 2;
|
||||
ld yy = yx;
|
||||
ld xx = 1 / sqrt(2)/2;
|
||||
queueline(V * get_horopoint(-yy, xx), V * get_horopoint(yy, 2*xx), gridcolor(c, c->mov[binary::bd_right]), prec);
|
||||
queueline(V * get_horopoint(-yy, xx), V * get_horopoint(yy, 2*xx), gridcolor(c, c->move(binary::bd_right)), prec);
|
||||
auto horizontal = [&] (ld y, ld x1, ld x2, int steps, int dir) {
|
||||
if(vid.linequality > 0) steps <<= vid.linequality;
|
||||
if(vid.linequality < 0) steps >>= -vid.linequality;
|
||||
for(int i=0; i<=steps; i++) curvepoint(V * get_horopoint(y, x1 + (x2-x1) * i / steps));
|
||||
queuecurve(gridcolor(c, c->mov[dir]), 0, PPR_LINE);
|
||||
queuecurve(gridcolor(c, c->move(dir)), 0, PPR_LINE);
|
||||
lastptd().u.poly.linewidth = linewidthat(V * get_horopoint(y, (x1+x2)/2), vid.linewidth, 0);
|
||||
};
|
||||
horizontal(yy, 2*xx, xx, 4, binary::bd_up_right);
|
||||
@ -4756,14 +4756,14 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
if(pseudohept(c)) for(int t=0; t<c->type; t++)
|
||||
queueline(V * get_warp_corner(c, t%c->type),
|
||||
V * get_warp_corner(c, (t+1)%c->type),
|
||||
gridcolor(c, c->mov[t]), prec);
|
||||
gridcolor(c, c->move(t)), prec);
|
||||
}
|
||||
else {
|
||||
for(int t=0; t<c->type; t++)
|
||||
if(c->mov[t] && c->mov[t] < c)
|
||||
if(c->move(t) && c->move(t) < c)
|
||||
queueline(V * get_corner_position(c, t),
|
||||
V * get_corner_position(c, (t+1)%c->type),
|
||||
gridcolor(c, c->mov[t]), prec);
|
||||
gridcolor(c, c->move(t)), prec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4779,34 +4779,34 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
|
||||
}
|
||||
}
|
||||
|
||||
else if(isGravityLand(cwt.c->land)) {
|
||||
if(cwt.c->land == laDungeon) rev = true;
|
||||
else if(isGravityLand(cwt.at->land)) {
|
||||
if(cwt.at->land == laDungeon) rev = true;
|
||||
if(conformal::do_rotate >= 1)
|
||||
if(!straightDownSeek || edgeDepth(c) < edgeDepth(straightDownSeek)) {
|
||||
usethis = true;
|
||||
spd = cwt.c->landparam / 10.;
|
||||
spd = cwt.at->landparam / 10.;
|
||||
}
|
||||
}
|
||||
|
||||
else if(c->master->alt && cwt.c->master->alt &&
|
||||
(cwt.c->land == laMountain ||
|
||||
else if(c->master->alt && cwt.at->master->alt &&
|
||||
(cwt.at->land == laMountain ||
|
||||
(conformal::do_rotate >= 2 &&
|
||||
(cwt.c->land == laTemple || cwt.c->land == laWhirlpool ||
|
||||
(cheater && (cwt.c->land == laClearing || cwt.c->land == laCaribbean ||
|
||||
cwt.c->land == laCamelot || cwt.c->land == laPalace)))
|
||||
(cwt.at->land == laTemple || cwt.at->land == laWhirlpool ||
|
||||
(cheater && (cwt.at->land == laClearing || cwt.at->land == laCaribbean ||
|
||||
cwt.at->land == laCamelot || cwt.at->land == laPalace)))
|
||||
))
|
||||
&& c->land == cwt.c->land && c->master->alt->alt == cwt.c->master->alt->alt) {
|
||||
&& c->land == cwt.at->land && c->master->alt->alt == cwt.at->master->alt->alt) {
|
||||
if(!straightDownSeek || !straightDownSeek->master->alt || celldistAlt(c) < celldistAlt(straightDownSeek)) {
|
||||
usethis = true;
|
||||
spd = .5;
|
||||
if(cwt.c->land == laMountain) rev = true;
|
||||
if(cwt.at->land == laMountain) rev = true;
|
||||
}
|
||||
}
|
||||
|
||||
else if(conformal::do_rotate >= 2 && cwt.c->land == laOcean && cwt.c->landparam < 25) {
|
||||
else if(conformal::do_rotate >= 2 && cwt.at->land == laOcean && cwt.at->landparam < 25) {
|
||||
if(!straightDownSeek || coastval(c, laOcean) < coastval(straightDownSeek, laOcean)) {
|
||||
usethis = true;
|
||||
spd = cwt.c->landparam / 10;
|
||||
spd = cwt.at->landparam / 10;
|
||||
}
|
||||
|
||||
}
|
||||
@ -4967,7 +4967,7 @@ void drawMarkers() {
|
||||
}
|
||||
hyperpoint H = tC0(ggmatrix(keycell));
|
||||
queuechr(H, 2*vid.fsize, 'X', 0x10101 * int(128 + 100 * sin(ticks / 150.)));
|
||||
queuestr(H, vid.fsize, its(celldistance(cwt.c, yi[yii].key())), 0x10101 * int(128 - 100 * sin(ticks / 150.)));
|
||||
queuestr(H, vid.fsize, its(celldistance(cwt.at, yi[yii].key())), 0x10101 * int(128 - 100 * sin(ticks / 150.)));
|
||||
addauraspecial(H, iinf[itOrbYendor].color, 0);
|
||||
}
|
||||
}
|
||||
@ -4983,7 +4983,7 @@ void drawMarkers() {
|
||||
|
||||
#if CAP_SDLJOY
|
||||
if(joydir.d >= 0)
|
||||
queuecircleat(cwt.c->mov[(joydir.d+cwt.spin) % cwt.c->type], .78 - .02 * sin(ticks/199.0),
|
||||
queuecircleat(cwt.at->modmove(joydir.d+cwt.spin), .78 - .02 * sin(ticks/199.0),
|
||||
darkena(0x00FF00, 0, 0xFF));
|
||||
#endif
|
||||
|
||||
@ -4991,8 +4991,8 @@ void drawMarkers() {
|
||||
#if CAP_MODEL
|
||||
m = netgen::mode == 0;
|
||||
#endif
|
||||
if(centerover.c && !playermoved && m && !conformal::on)
|
||||
queuecircleat(centerover.c, .70 - .06 * sin(ticks/200.0),
|
||||
if(centerover.at && !playermoved && m && !conformal::on)
|
||||
queuecircleat(centerover.at, .70 - .06 * sin(ticks/200.0),
|
||||
darkena(int(175 + 25 * sin(ticks / 200.0)), 0, 0xFF));
|
||||
|
||||
if(multi::players > 1 || multi::alwaysuse) for(int i=0; i<numplayers(); i++) {
|
||||
@ -5006,15 +5006,15 @@ void drawMarkers() {
|
||||
|
||||
if((vid.axes == 4 || (vid.axes == 1 && !mousing)) && !shmup::on) {
|
||||
if(multi::players == 1) {
|
||||
forCellIdAll(c2, d, cwt.c) IG(c2) drawMovementArrows(c2, confusingGeometry() ? Gm(cwt.c) * calc_relative_matrix(c2, cwt.c, d) : Gm(c2));
|
||||
forCellIdAll(c2, d, cwt.at) IG(c2) drawMovementArrows(c2, confusingGeometry() ? Gm(cwt.at) * calc_relative_matrix(c2, cwt.at, d) : Gm(c2));
|
||||
}
|
||||
else if(multi::players > 1) for(int p=0; p<multi::players; p++) {
|
||||
if(multi::playerActive(p) && (vid.axes == 4 || !drawstaratvec(multi::mdx[p], multi::mdy[p])))
|
||||
forCellIdAll(c2, d, multi::player[p].c) IG(c2) {
|
||||
forCellIdAll(c2, d, multi::player[p].at) IG(c2) {
|
||||
multi::cpid = p;
|
||||
dynamicval<transmatrix> ttm(cwtV, multi::whereis[p]);
|
||||
dynamicval<cellwalker> tcw(cwt, multi::player[p]);
|
||||
drawMovementArrows(c2, confusingGeometry() ? Gm(cwt.c) * calc_relative_matrix(c2, cwt.c, d) : Gm(c2));
|
||||
drawMovementArrows(c2, confusingGeometry() ? Gm(cwt.at) * calc_relative_matrix(c2, cwt.at, d) : Gm(c2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5187,7 +5187,7 @@ void drawthemap() {
|
||||
compute_graphical_distance();
|
||||
|
||||
centdist = 1e20;
|
||||
if(!stdeuclid) centerover.c = NULL;
|
||||
if(!stdeuclid) centerover.at = NULL;
|
||||
|
||||
for(int i=0; i<multi::players; i++) {
|
||||
multi::ccdist[i] = 1e20; multi::ccat[i] = NULL;
|
||||
@ -5279,7 +5279,7 @@ void drawthemap() {
|
||||
items[itWarning] -= 2;
|
||||
if(cw.spin != cwt.spin) mirror::act(-mousedest.d, mirror::SPINSINGLE);
|
||||
cwt = cw; flipplayer = f;
|
||||
lmouseover = mousedest.d >= 0 ? cwt.c->mov[(cwt.spin + mousedest.d) % cwt.c->type] : cwt.c;
|
||||
lmouseover = mousedest.d >= 0 ? cwt.at->modmove(cwt.spin + mousedest.d) : cwt.at;
|
||||
}
|
||||
#endif
|
||||
profile_stop(0);
|
||||
@ -5654,7 +5654,7 @@ void drawscreen() {
|
||||
SDL_FillRect(s, NULL, backcolor);
|
||||
#endif
|
||||
|
||||
// displaynum(vx,100, 0, 24, 0xc0c0c0, celldist(cwt.c), ":");
|
||||
// displaynum(vx,100, 0, 24, 0xc0c0c0, celldist(cwt.at), ":");
|
||||
|
||||
lgetcstat = getcstat;
|
||||
getcstat = 0; inslider = false;
|
||||
@ -5667,8 +5667,8 @@ void drawscreen() {
|
||||
screens.back()();
|
||||
|
||||
#if !ISMOBILE
|
||||
int col = linf[cwt.c->land].color;
|
||||
if(cwt.c->land == laRedRock) col = 0xC00000;
|
||||
int col = linf[cwt.at->land].color;
|
||||
if(cwt.at->land == laRedRock) col = 0xC00000;
|
||||
if(!nohelp)
|
||||
displayfr(vid.xres/2, vid.fsize, 2, vid.fsize, mouseovers, col, 8);
|
||||
#endif
|
||||
@ -5687,10 +5687,10 @@ void drawscreen() {
|
||||
mines[p] = 0;
|
||||
cell *c = playerpos(p);
|
||||
if(!c) continue;
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i]) {
|
||||
if(c->mov[i]->land == laMinefield)
|
||||
for(int i=0; i<c->type; i++) if(c->move(i)) {
|
||||
if(c->move(i)->land == laMinefield)
|
||||
minefieldNearby = true;
|
||||
if(c->mov[i]->wall == waMineMine) {
|
||||
if(c->move(i)->wall == waMineMine) {
|
||||
bool ep = false;
|
||||
if(!ep) mines[p]++, tmines++;
|
||||
}
|
||||
@ -5710,7 +5710,7 @@ void drawscreen() {
|
||||
vid.fsize,
|
||||
XLAT(minetexts[mines[p]]), minecolors[mines[p]], 8);
|
||||
|
||||
if(minefieldNearby && !shmup::on && cwt.c->land != laMinefield && cwt.c->mov[cwt.spin]->land != laMinefield) {
|
||||
if(minefieldNearby && !shmup::on && cwt.at->land != laMinefield && cwt.peek()->land != laMinefield) {
|
||||
displayfr(vid.xres/2, vid.ycenter - vid.radius * 3/4 - vid.fsize*3/2, 2,
|
||||
vid.fsize,
|
||||
XLAT("WARNING: you are entering a minefield!"),
|
||||
@ -5741,7 +5741,7 @@ void restartGraph() {
|
||||
centerover = vec_to_cellwalker(0);
|
||||
}
|
||||
else {
|
||||
viewctr.h = currentmap->getOrigin();
|
||||
viewctr.at = currentmap->getOrigin();
|
||||
viewctr.spin = 0;
|
||||
viewctr.mirrored = false;
|
||||
}
|
||||
@ -5757,7 +5757,7 @@ void clearAnimations() {
|
||||
|
||||
auto graphcm = addHook(clearmemory, 0, [] () {
|
||||
DEBB(DF_INIT, (debugfile,"clear graph memory\n"));
|
||||
mouseover = centerover.c = lmouseover = NULL;
|
||||
mouseover = centerover.at = lmouseover = NULL;
|
||||
gmatrix.clear(); gmatrix0.clear();
|
||||
clearAnimations();
|
||||
});
|
||||
@ -5776,7 +5776,7 @@ map<cell*, animation> animations[ANIMLAYERS];
|
||||
unordered_map<cell*, transmatrix> gmatrix, gmatrix0;
|
||||
|
||||
int revhint(cell *c, int hint) {
|
||||
if(hint >= 0 && hint < c->type) return c->spin(hint);
|
||||
if(hint >= 0 && hint < c->type) return c->c.spin(hint);
|
||||
else return hint;
|
||||
}
|
||||
|
||||
@ -5862,16 +5862,16 @@ void animateReplacement(cell *a, cell *b, int layer, int direction_hinta, int di
|
||||
void drawBug(const cellwalker& cw, int col) {
|
||||
#if CAP_POLY
|
||||
initquickqueue();
|
||||
transmatrix V = ggmatrix(cw.c);
|
||||
if(cw.spin) V = V * ddspin(cw.c, cw.spin, S42);
|
||||
transmatrix V = ggmatrix(cw.at);
|
||||
if(cw.spin) V = V * ddspin(cw.at, cw.spin, S42);
|
||||
queuepoly(V, shBugBody, col);
|
||||
quickqueue();
|
||||
#endif
|
||||
}
|
||||
|
||||
cell *viewcenter() {
|
||||
if(stdeuclid) return centerover.c;
|
||||
else return viewctr.h->c7;
|
||||
if(stdeuclid) return centerover.at;
|
||||
else return viewctr.at->c7;
|
||||
}
|
||||
|
||||
bool inscreenrange(cell *c) {
|
||||
|
10
help.cpp
10
help.cpp
@ -195,8 +195,8 @@ void describeOrb(string& help, const orbinfo& oi) {
|
||||
if(inv::on) return;
|
||||
eOrbLandRelation olr = getOLR(oi.orb, getPrizeLand());
|
||||
eItem tr = treasureType(oi.l);
|
||||
eItem tt = treasureTypeUnlock(cwt.c->land, oi.orb);
|
||||
help += "\n\n" + XLAT(olrDescriptions[olr], cwt.c->land, tr, tt);
|
||||
eItem tt = treasureTypeUnlock(cwt.at->land, oi.orb);
|
||||
help += "\n\n" + XLAT(olrDescriptions[olr], cwt.at->land, tr, tt);
|
||||
int t = items[tr] * landMultiplier(oi.l);
|
||||
if(t >= 25)
|
||||
if(olr == olrPrize25 || olr == olrPrize3 || olr == olrGuest || olr == olrMonster || olr == olrAlways) {
|
||||
@ -381,7 +381,7 @@ string generateHelpForItem(eItem it) {
|
||||
help += XLAT("\n\nOrb unlocked: %1", oi.orb);
|
||||
describeOrb(help, oi);
|
||||
}
|
||||
else if(oi.l == cwt.c->land || inv::on) {
|
||||
else if(oi.l == cwt.at->land || inv::on) {
|
||||
help += XLAT("\n\nSecondary orb: %1", oi.orb);
|
||||
describeOrb(help, oi);
|
||||
}
|
||||
@ -759,7 +759,7 @@ hookset<void(cell*)> *hooks_mouseover;
|
||||
void describeMouseover() {
|
||||
DEBB(DF_GRAPH, (debugfile,"describeMouseover\n"));
|
||||
|
||||
cell *c = mousing ? mouseover : playermoved ? NULL : centerover.c;
|
||||
cell *c = mousing ? mouseover : playermoved ? NULL : centerover.at;
|
||||
string& out = mouseovers;
|
||||
if(!c || instat || getcstat != '-') { }
|
||||
else if(c->wall != waInvisibleFloor) {
|
||||
@ -796,7 +796,7 @@ void describeMouseover() {
|
||||
int wm = windmap::at(c);
|
||||
windtotal += (signed char) (wm-lastval);
|
||||
lastval = wm;
|
||||
if(c == cwt.c) windtotal = 0;
|
||||
if(c == cwt.at) windtotal = 0;
|
||||
out += " [" + its(windtotal) + "]";
|
||||
}
|
||||
|
||||
|
153
heptagon.cpp
153
heptagon.cpp
@ -70,10 +70,8 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
heptagon *h = new heptagon;
|
||||
h->alt = NULL;
|
||||
h->s = s;
|
||||
for(int i=0; i<MAX_EDGE; i++) h->move[i] = NULL;
|
||||
h->spintable = 0;
|
||||
h->move[pard] = parent; tsetspin(h->spintable, pard, d);
|
||||
parent->move[d] = h; tsetspin(parent->spintable, d, pard);
|
||||
h->c.clear();
|
||||
h->c.connect(pard, parent, d, false);
|
||||
h->cdata = NULL;
|
||||
if(binarytiling || syntetic) return h;
|
||||
if(parent->c7) {
|
||||
@ -90,7 +88,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
else if(parent->s == hsOrigin)
|
||||
h->fiftyval = firstfiftyval(d);
|
||||
else
|
||||
h->fiftyval = nextfiftyval(parent->fiftyval, parent->move[0]->fiftyval, d);
|
||||
h->fiftyval = nextfiftyval(parent->fiftyval, parent->move(0)->fiftyval, d);
|
||||
}
|
||||
else {
|
||||
h->c7 = NULL;
|
||||
@ -105,52 +103,52 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
if(fixdistance != COMPUTE) h->distance = fixdistance;
|
||||
else if(S3 == 4 && !nonbitrunc) {
|
||||
h->distance = parent->distance + 2;
|
||||
if(h->spin(0) == 2 || (h->spin(0) == 3 && S7 <= 5))
|
||||
h->distance = min<short>(h->distance, createStep(h->move[0], 0)->distance + 3);
|
||||
if(h->spin(0) == 2 && h->move[0]) {
|
||||
int d = h->spin(0);
|
||||
if(h->c.spin(0) == 2 || (h->c.spin(0) == 3 && S7 <= 5))
|
||||
h->distance = min<short>(h->distance, createStep(h->move(0), 0)->distance + 3);
|
||||
if(h->c.spin(0) == 2 && h->move(0)) {
|
||||
int d = h->c.spin(0);
|
||||
int d1 = (d+S7-1)%S7;
|
||||
heptagon* h1 = createStep(h->move[0], d1);
|
||||
if(h1->distance <= h->move[0]->distance)
|
||||
h->distance = h->move[0]->distance+1;
|
||||
heptagon* h1 = createStep(h->move(0), d1);
|
||||
if(h1->distance <= h->move(0)->distance)
|
||||
h->distance = h->move(0)->distance+1;
|
||||
}
|
||||
if((h->s == hsB && h->move[0]->s == hsB) || h->move[0]->s == hsA) {
|
||||
int d = h->spin(0);
|
||||
heptagon* h1 = createStep(h->move[0], (d+1)%S7);
|
||||
if(h1->distance <= h->move[0]->distance)
|
||||
h->distance = h->move[0]->distance+1;
|
||||
if((h->s == hsB && h->move(0)->s == hsB) || h->move(0)->s == hsA) {
|
||||
int d = h->c.spin(0);
|
||||
heptagon* h1 = createStep(h->move(0), (d+1)%S7);
|
||||
if(h1->distance <= h->move(0)->distance)
|
||||
h->distance = h->move(0)->distance+1;
|
||||
}
|
||||
if(h->spin(0) == S7-1 && h->move[0]->distance != 0)
|
||||
if(h->c.spin(0) == S7-1 && h->move(0)->distance != 0)
|
||||
h->distance = min(
|
||||
h->move[0]->move[0]->distance + 2,
|
||||
h->move(0)->move(0)->distance + 2,
|
||||
createStep(h, S7-1)->distance + 1
|
||||
);
|
||||
}
|
||||
else if(parent->s == hsOrigin) h->distance = parent->distance + gp::dist_2();
|
||||
else if(S3 == 4 && gp::on && h->spin(0) == S7-2 && h->move[0]->spin(0) >= S7-2 && h->move[0]->move[0]->s != hsOrigin) {
|
||||
else if(S3 == 4 && gp::on && h->c.spin(0) == S7-2 && h->move(0)->c.spin(0) >= S7-2 && h->move(0)->move(0)->s != hsOrigin) {
|
||||
heptspin hs(h, 0);
|
||||
hs += wstep;
|
||||
int d1 = hs.h->distance;
|
||||
int d1 = hs.at->distance;
|
||||
hs += 1; hs += wstep;
|
||||
int dm = hs.h->distance;
|
||||
int dm = hs.at->distance;
|
||||
hs += -1; hs += wstep;
|
||||
int d0 = hs.h->distance;
|
||||
int d0 = hs.at->distance;
|
||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(-1,1)));
|
||||
}
|
||||
else if(S3 == 4 && gp::on && h->spin(0) == S7-1 && among(h->move[0]->spin(0), S7-2, S7-3) && h->move[0]->move[0]->s != hsOrigin) {
|
||||
else if(S3 == 4 && gp::on && h->c.spin(0) == S7-1 && among(h->move(0)->c.spin(0), S7-2, S7-3) && h->move(0)->move(0)->s != hsOrigin) {
|
||||
heptspin hs(h, 0);
|
||||
hs += wstep;
|
||||
int d0 = hs.h->distance;
|
||||
int d0 = hs.at->distance;
|
||||
hs += 1; hs += wstep;
|
||||
int dm = hs.h->distance;
|
||||
int dm = hs.at->distance;
|
||||
hs += 1; hs += wstep;
|
||||
int d1 = hs.h->distance;
|
||||
int d1 = hs.at->distance;
|
||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
||||
}
|
||||
else if(S3 == 4 && gp::on && h->spin(0) >= 2 && h->spin(0) <= S7-2) {
|
||||
else if(S3 == 4 && gp::on && h->c.spin(0) >= 2 && h->c.spin(0) <= S7-2) {
|
||||
h->distance = parent->distance + gp::dist_2();
|
||||
}
|
||||
else if(h->spin(0) == S7-2) {
|
||||
else if(h->c.spin(0) == S7-2) {
|
||||
if(!gp::on)
|
||||
h->distance = parent->distance + gp::dist_1();
|
||||
else {
|
||||
@ -160,9 +158,9 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
||||
}
|
||||
}
|
||||
else if(h->spin(0) == S7-3 && h->move[0]->s == hsB) {
|
||||
else if(h->c.spin(0) == S7-3 && h->move(0)->s == hsB) {
|
||||
if(!gp::on) {
|
||||
h->distance = createStep(h->move[0], (h->spin(0)+2)%S7)->distance + gp::dist_3();
|
||||
h->distance = createStep(h->move(0), (h->c.spin(0)+2)%S7)->distance + gp::dist_3();
|
||||
}
|
||||
else {
|
||||
int d0 = parent->distance;
|
||||
@ -171,7 +169,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
||||
}
|
||||
}
|
||||
else if(h->spin(0) == S7-1 && S3 == 4 && gp::on) {
|
||||
else if(h->c.spin(0) == S7-1 && S3 == 4 && gp::on) {
|
||||
h->distance = parent->distance + gp::dist_1();
|
||||
}
|
||||
else h->distance = parent->distance + gp::dist_2();
|
||||
@ -194,25 +192,13 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
return h;
|
||||
}
|
||||
|
||||
void connectHeptagons(heptagon *h1, int d1, heptagon *h2, int d2) {
|
||||
h1->move[d1] = h2;
|
||||
h1->setspin(d1, d2);
|
||||
h2->move[d2] = h1;
|
||||
h2->setspin(d2, d1);
|
||||
}
|
||||
|
||||
int recsteps;
|
||||
|
||||
void addSpin(heptagon *h, int d, heptagon *from, int rot, int spin) {
|
||||
rot = fixrot(h, rot);
|
||||
createStep(from, rot);
|
||||
int fr = fixrot(from, from->spin(rot) + spin);
|
||||
connectHeptagons(h, d, from->move[rot], fr);
|
||||
/* h->move[d] = from->move[rot];
|
||||
h->setspin(d, fr);
|
||||
h->move[d]->move[fr] = h;
|
||||
h->move[d]->setspin(fr, d); */
|
||||
//generateEmeraldval(h->move[d]); generateEmeraldval(h);
|
||||
rot = h->c.fix(rot);
|
||||
auto h1 = createStep(from, rot);
|
||||
int fr = h1->c.fix(from->c.spin(rot) + spin);
|
||||
h->c.connect(d, from->move(rot), fr, false);
|
||||
}
|
||||
|
||||
extern int hrand(int);
|
||||
@ -220,38 +206,15 @@ extern int hrand(int);
|
||||
// a structure used to walk on the heptagonal tesselation
|
||||
// (remembers not only the heptagon, but also direction)
|
||||
|
||||
int fixrot(heptagon *h, int a) {
|
||||
if(syntetic) return synt::fix(h, a);
|
||||
return (a+MODFIXER) % S7;
|
||||
}
|
||||
|
||||
heptspin& operator += (heptspin& hs, int spin) {
|
||||
hs.spin = fixrot(hs.h, hs.spin + (MIRR(hs)?-spin:spin));
|
||||
return hs;
|
||||
}
|
||||
|
||||
heptspin operator + (const heptspin& hs, wstep_t) {
|
||||
createStep(hs.h, hs.spin);
|
||||
heptspin res;
|
||||
res.h = hs.h->move[hs.spin];
|
||||
res.mirrored = hs.mirrored ^ hs.h->mirror(hs.spin);
|
||||
res.spin = hs.h->spin(hs.spin);
|
||||
return res;
|
||||
}
|
||||
|
||||
heptspin operator + (heptspin h, int spin) { return h += spin; }
|
||||
heptspin operator - (heptspin h, int spin) { return h += -spin; }
|
||||
heptspin& operator += (heptspin& h, wstep_t) { h = h + wstep; return h; }
|
||||
|
||||
heptagon *createStep(heptagon *h, int d) {
|
||||
d = fixrot(h, d);
|
||||
if(!h->move[d] && binarytiling)
|
||||
d = h->c.fix(d);
|
||||
if(!h->move(d) && binarytiling)
|
||||
return binary::createStep(h, d);
|
||||
if(!h->move[d] && syntetic) {
|
||||
if(!h->move(d) && syntetic) {
|
||||
synt::create_adjacent(h, d);
|
||||
return h->move[d];
|
||||
return h->move(d);
|
||||
}
|
||||
if(!h->move[0] && h->s != hsOrigin && !binarytiling) {
|
||||
if(!h->move(0) && h->s != hsOrigin && !binarytiling) {
|
||||
// cheating:
|
||||
int pard=0;
|
||||
if(S3 == 3)
|
||||
@ -262,61 +225,55 @@ heptagon *createStep(heptagon *h, int d) {
|
||||
pard = 3;
|
||||
buildHeptagon(h, 0, h->distance < -10000 ? hsOrigin : hsA, pard);
|
||||
}
|
||||
if(h->move[d]) return h->move[d];
|
||||
if(h->move(d)) return h->move(d);
|
||||
if(h->s == hsOrigin) {
|
||||
buildHeptagon(h, d, hsA);
|
||||
}
|
||||
else if(S3 == 4) {
|
||||
if(d == 1) {
|
||||
heptspin hs;
|
||||
hs.h = h;
|
||||
hs.spin = 0;
|
||||
hs.mirrored = false;
|
||||
heptspin hs(h, 0, false);
|
||||
hs = hs + wstep - 1 + wstep - 1 + wstep - 1;
|
||||
connectHeptagons(h, d, hs.h, hs.spin);
|
||||
h->c.connect(d, hs);
|
||||
}
|
||||
else if(h->s == hsB && d == S7-1) {
|
||||
heptspin hs;
|
||||
hs.h = h;
|
||||
hs.spin = 0;
|
||||
hs.mirrored = false;
|
||||
heptspin hs(h, 0, false);
|
||||
hs = hs + wstep + 1 + wstep + 1 + wstep + 1;
|
||||
connectHeptagons(h, d, hs.h, hs.spin);
|
||||
h->c.connect(d, hs);
|
||||
}
|
||||
else
|
||||
buildHeptagon(h, d, transition(h->s, d));
|
||||
}
|
||||
else if(d == 1) {
|
||||
addSpin(h, d, h->move[0], h->spin(0)-1, -1);
|
||||
addSpin(h, d, h->move(0), h->c.spin(0)-1, -1);
|
||||
}
|
||||
else if(d == S7-1) {
|
||||
addSpin(h, d, h->move[0], h->spin(0)+1, +1);
|
||||
addSpin(h, d, h->move(0), h->c.spin(0)+1, +1);
|
||||
}
|
||||
else if(d == 2) {
|
||||
createStep(h->move[0], h->spin(0)-1);
|
||||
addSpin(h, d, h->move[0]->modmove(h->spin(0)-1), S7-2 + h->move[0]->gspin(h->spin(0)-1), -1);
|
||||
createStep(h->move(0), h->c.spin(0)-1);
|
||||
addSpin(h, d, h->move(0)->modmove(h->c.spin(0)-1), S7-2 + h->move(0)->c.modspin(h->c.spin(0)-1), -1);
|
||||
}
|
||||
else if(d == S7-2 && h->s == hsB) {
|
||||
createStep(h->move[0], h->spin(0)+1);
|
||||
addSpin(h, d, h->move[0]->modmove(h->spin(0)+1), 2 + h->move[0]->gspin(h->spin(0)+1), +1);
|
||||
createStep(h->move(0), h->c.spin(0)+1);
|
||||
addSpin(h, d, h->move(0)->modmove(h->c.spin(0)+1), 2 + h->move(0)->c.modspin(h->c.spin(0)+1), +1);
|
||||
}
|
||||
else
|
||||
buildHeptagon(h, d, (d == S7-2 || (h->s == hsB && d == S7-3)) ? hsB : hsA);
|
||||
return h->move[d];
|
||||
return h->move(d);
|
||||
}
|
||||
|
||||
// display the coordinates of the heptagon
|
||||
void backtrace(heptagon *pos) {
|
||||
if(pos->s == hsOrigin) return;
|
||||
backtrace(pos->move[0]);
|
||||
printf(" %d", pos->spin(0));
|
||||
backtrace(pos->move(0));
|
||||
printf(" %d", pos->c.spin(0));
|
||||
}
|
||||
|
||||
void hsshow(const heptspin& t) {
|
||||
printf("ORIGIN"); backtrace(t.h); printf(" (spin %d)\n", t.spin);
|
||||
printf("ORIGIN"); backtrace(t.at); printf(" (spin %d)\n", t.spin);
|
||||
}
|
||||
|
||||
// create h->move[d] if not created yet
|
||||
// create h->move(d) if not created yet
|
||||
heptagon *createStep(heptagon *h, int d);
|
||||
|
||||
}
|
||||
|
16
hud.cpp
16
hud.cpp
@ -130,9 +130,9 @@ int glyphflags(int gid) {
|
||||
if(itemclass(i) == IC_NAI) f |= GLYPH_NONUMBER;
|
||||
if(isElementalShard(i)) {
|
||||
f |= GLYPH_LOCAL | GLYPH_INSQUARE;
|
||||
if(i == localshardof(cwt.c->land)) f |= GLYPH_LOCAL2;
|
||||
if(i == localshardof(cwt.at->land)) f |= GLYPH_LOCAL2;
|
||||
}
|
||||
if(i == treasureType(cwt.c->land) || daily::on)
|
||||
if(i == treasureType(cwt.at->land) || daily::on)
|
||||
f |= GLYPH_LOCAL | GLYPH_LOCAL2 | GLYPH_IMPORTANT | GLYPH_INSQUARE;
|
||||
if(i == itHolyGrail) {
|
||||
if(items[i] >= 3 && !inv::on) f |= GLYPH_MARKOVER;
|
||||
@ -151,7 +151,7 @@ int glyphflags(int gid) {
|
||||
else {
|
||||
eMonster m = eMonster(gid-ittypes);
|
||||
if(m == moLesser) f |= GLYPH_IMPORTANT | GLYPH_DEMON | GLYPH_INPORTRAIT | GLYPH_INSQUARE;
|
||||
int isnat = isNative(cwt.c->land, m);
|
||||
int isnat = isNative(cwt.at->land, m);
|
||||
if(isnat) f |= GLYPH_LOCAL | GLYPH_IMPORTANT | GLYPH_INPORTRAIT | GLYPH_INSQUARE;
|
||||
if(isnat == 2) f |= GLYPH_LOCAL2;
|
||||
if(m == monsterToSummon) f |= GLYPH_TARGET;
|
||||
@ -304,11 +304,11 @@ hookset<bool()> *hooks_prestats;
|
||||
void drawMobileArrow(int i) {
|
||||
|
||||
int dir = i;
|
||||
cell *c = cwt.c->mov[i];
|
||||
cell *c = cwt.at->move(i);
|
||||
if(!c) return;
|
||||
|
||||
transmatrix T;
|
||||
if(!compute_relamatrix(c, cwt.c, i, T)) return;
|
||||
if(!compute_relamatrix(c, cwt.at, i, T)) return;
|
||||
|
||||
// int col = getcs().uicolor;
|
||||
// col -= (col & 0xFF) >> 1;
|
||||
@ -326,7 +326,7 @@ void drawMobileArrow(int i) {
|
||||
ld scale = vid.mobilecompasssize * (sphere ? 7 : euclid ? 6 : 5);
|
||||
// m2[0][0] = scale; m2[1][1] = scale; m2[2][2] = 1;
|
||||
|
||||
transmatrix U = ggmatrix(cwt.c);
|
||||
transmatrix U = ggmatrix(cwt.at);
|
||||
hyperpoint H = sphereflip * tC0(U);
|
||||
transmatrix Centered = sphereflip * rgpushxto0(H);
|
||||
|
||||
@ -353,7 +353,7 @@ void drawStats() {
|
||||
vector<cell*>& ac = currentmap->allcells();
|
||||
for(int i=0; i<64; i++) qty[i] = 0;
|
||||
for(int i=0; i<isize(ac); i++) {
|
||||
int d = celldistance(ac[i], cwt.c);
|
||||
int d = celldistance(ac[i], cwt.at);
|
||||
if(d >= 0 && d < 64) qty[d]++;
|
||||
}
|
||||
if(geometry == gNormal && !gp::on)
|
||||
@ -399,7 +399,7 @@ void drawStats() {
|
||||
queuecircle(xmove, yb, rad*SKIPFAC,
|
||||
legalmoves[MAX_EDGE] ? 0xFF0000FF : 0xFF000080
|
||||
);
|
||||
for(int i=0; i<cwt.c->type; i++) drawMobileArrow(i);
|
||||
for(int i=0; i<cwt.at->type; i++) drawMobileArrow(i);
|
||||
if(hypot(mousex-xmove, mousey-yb) <= rad) getcstat = '-';
|
||||
quickqueue();
|
||||
}
|
||||
|
171
hyper.h
171
hyper.h
@ -316,15 +316,97 @@ struct gcell {
|
||||
|
||||
#define fval LHU.fi.fieldval
|
||||
|
||||
#define NODIR 8
|
||||
#define NOBARRIERS 9
|
||||
#define MODFIXER 23520
|
||||
#define NODIR 14
|
||||
#define NOBARRIERS 15
|
||||
#define MODFIXER 10090080
|
||||
|
||||
inline void tsetspin(uint32_t& t, int d, int spin) { t &= ~(15 << (d<<2)); t |= spin << (d<<2); }
|
||||
inline int tspin(uint32_t& t, int d) { return (t >> (d<<2)) & 7; }
|
||||
inline bool tmirror(uint32_t& t, int d) { return (t >> ((d<<2)+3)) & 1; }
|
||||
template<class T> struct walker;
|
||||
|
||||
int fixrot(struct heptagon *h, int a);
|
||||
template<class T> struct connection_table {
|
||||
uint32_t spintable;
|
||||
// neighbors; move[0] always goes towards origin, and then we go clockwise
|
||||
T* move_table[8];
|
||||
T* full() { T* x; return (T*)((char*)this - ((char*)(&(x->c)) - (char*)x)); }
|
||||
void setspin(int d, int spin, bool mirror) { spintable &= ~(15 << (d<<2)); spintable |= spin << (d<<2); spintable |= mirror << ((d<<2)+3); }
|
||||
// we are spin(i)-th neighbor of move[i]
|
||||
int spin(int d) { return (spintable >> (d<<2)) & 7; }
|
||||
bool mirror(int d) { return (spintable >> ((d<<2)+3)) & 1; }
|
||||
int fix(int d) { return (d + MODFIXER) % full()->degree(); }
|
||||
T*& modmove(int i) { return move(fix(i)); }
|
||||
T*& move(int i) { return move_table[i]; }
|
||||
unsigned char modspin(int i) { return spin(fix(i)); }
|
||||
void clear() {
|
||||
spintable = 0;
|
||||
for(int i=0; i<8; i++) move_table[i] = NULL;
|
||||
}
|
||||
void connect(int d0, T* c1, int d1, bool m) {
|
||||
move(d0) = c1;
|
||||
c1->move(d1) = full();
|
||||
setspin(d0, d1, m);
|
||||
c1->c.setspin(d1, d0, m);
|
||||
}
|
||||
void connect(int d0, walker<T> hs) {
|
||||
connect(d0, hs.at, hs.spin, hs.mirrored);
|
||||
}
|
||||
};
|
||||
|
||||
static const struct wstep_t { wstep_t() {} } wstep;
|
||||
static const struct wmirror_t { wmirror_t() {}} wmirror;
|
||||
static const struct rev_t { rev_t() {} } rev;
|
||||
static const struct revstep_t { revstep_t() {}} revstep;
|
||||
|
||||
int hrand(int x);
|
||||
|
||||
template<class T> struct walker {
|
||||
T *at;
|
||||
int spin;
|
||||
bool mirrored;
|
||||
walker<T> (T *at = NULL, int s = 0, bool m = false) : at(at), spin(s), mirrored(m) { }
|
||||
walker<T>& operator += (int i) {
|
||||
spin = at->c.fix(spin+(mirrored?-i:i));
|
||||
return (*this);
|
||||
}
|
||||
walker<T>& operator -= (int i) {
|
||||
spin = at->c.fix(spin-(mirrored?-i:i));
|
||||
return (*this);
|
||||
}
|
||||
walker<T>& operator += (wmirror_t) {
|
||||
mirrored = !mirrored;
|
||||
return (*this);
|
||||
}
|
||||
walker<T>& operator += (wstep_t) {
|
||||
at->cmove(spin);
|
||||
int nspin = at->c.spin(spin);
|
||||
if(at->c.mirror(spin)) mirrored = !mirrored;
|
||||
at = at->move(spin);
|
||||
spin = nspin;
|
||||
return (*this);
|
||||
}
|
||||
walker<T>& operator += (rev_t) {
|
||||
int d = at->degree();
|
||||
return (*this) += d/2 + ((d&1)?hrand(2):0);
|
||||
}
|
||||
walker<T>& operator += (revstep_t) {
|
||||
(*this) += rev; return (*this) += wstep;
|
||||
}
|
||||
bool operator != (const walker<T>& x) const {
|
||||
return at != x.at || spin != x.spin || mirrored != x.mirrored;
|
||||
}
|
||||
bool operator == (const walker<T>& x) const {
|
||||
return at == x.at && spin == x.spin && mirrored == x.mirrored;
|
||||
}
|
||||
|
||||
|
||||
|
||||
walker<T>& operator ++ (int) { return (*this) += 1; }
|
||||
walker<T>& operator -- (int) { return (*this) -= 1; }
|
||||
template<class U> walker operator + (U t) const { walker<T> w = *this; w += t; return w; }
|
||||
template<class U> walker operator - (U t) const { walker<T> w = *this; w += (-t); return w; }
|
||||
T*& peek() { return at->move(spin); }
|
||||
T* cpeek() { return at->cmove(spin); }
|
||||
bool creates() { return !peek(); }
|
||||
walker<T> mirrorat(int d) { return walker<T> (at, at->c.fix(d+d - spin), !mirrored); }
|
||||
};
|
||||
|
||||
inline int fix42(int a) { return (a+MODFIXER)% S42; }
|
||||
|
||||
@ -333,18 +415,13 @@ struct cell;
|
||||
// automaton state
|
||||
enum hstate { hsOrigin, hsA, hsB, hsError, hsA0, hsA1, hsB0, hsB1, hsC };
|
||||
|
||||
struct cell *createMov(struct cell *c, int d);
|
||||
struct heptagon *createStep(struct heptagon *c, int d);
|
||||
|
||||
struct heptagon {
|
||||
// automaton state
|
||||
hstate s : 6;
|
||||
unsigned int dm4: 2;
|
||||
// we are spin[i]-th neighbor of move[i]
|
||||
uint32_t spintable;
|
||||
int spin(int d) { return tspin(spintable, d); }
|
||||
bool mirror(int d) { return tmirror(spintable, d); }
|
||||
void setspin(int d, int sp) { tsetspin(spintable, d, sp); }
|
||||
// neighbors; move[0] always goes towards origin,
|
||||
// and then we go clockwise
|
||||
heptagon* move[MAX_EDGE];
|
||||
// distance from the origin
|
||||
short distance;
|
||||
// emerald/wineyard generator
|
||||
@ -362,46 +439,38 @@ struct heptagon {
|
||||
cell *c7;
|
||||
// associated generator of alternate structure, for Camelot and horocycles
|
||||
heptagon *alt;
|
||||
// connection table
|
||||
connection_table<heptagon> c;
|
||||
heptagon*& move(int d) { return c.move(d); }
|
||||
heptagon*& modmove(int d) { return c.modmove(d); }
|
||||
// functions
|
||||
heptagon*& modmove(int i) { return move[fixrot(this, i)]; }
|
||||
unsigned char gspin(int i) { return spin(fixrot(this, i)); }
|
||||
heptagon () { heptacount++; }
|
||||
~heptagon () { heptacount--; }
|
||||
};
|
||||
|
||||
struct heptspin {
|
||||
heptagon *h;
|
||||
int spin;
|
||||
bool mirrored;
|
||||
heptspin() { mirrored = false; }
|
||||
heptspin(heptagon *h, int s = 0, bool m = false) : h(h), spin(s), mirrored(m) { }
|
||||
heptagon *cmove(int d) { return createStep(this, d); }
|
||||
inline int degree();
|
||||
};
|
||||
|
||||
struct cell : gcell {
|
||||
char type; // 6 for hexagons, 7 for heptagons
|
||||
int degree() { return type; }
|
||||
|
||||
// wall parameter, used for remaining power of Bonfires and Thumpers
|
||||
char wparam;
|
||||
|
||||
int listindex;
|
||||
|
||||
uint32_t spintable;
|
||||
int spin(int d) { return tspin(spintable, d); }
|
||||
int spn(int d) { return tspin(spintable, d); }
|
||||
bool mirror(int d) { return tmirror(spintable, d); }
|
||||
|
||||
heptagon *master;
|
||||
cell *mov[MAX_EDGE]; // meaning very similar to heptagon::move
|
||||
|
||||
connection_table<cell> c;
|
||||
cell*& move(int d) { return c.move(d); }
|
||||
cell*& modmove(int d) { return c.modmove(d); }
|
||||
cell* cmove(int d) { return createMov(this, d); }
|
||||
};
|
||||
|
||||
// similar to heptspin from heptagon.cpp
|
||||
struct cellwalker {
|
||||
cell *c;
|
||||
int spin;
|
||||
bool mirrored;
|
||||
cellwalker(cell *c, int spin, bool m=false) : c(c), spin(spin), mirrored(m) { }
|
||||
cellwalker() { mirrored = false; }
|
||||
};
|
||||
int heptagon::degree() { if(syntetic) return c7->type; else return S7; }
|
||||
|
||||
using heptspin = walker<heptagon>;
|
||||
using cellwalker = walker<cell>;
|
||||
|
||||
#define BUGCOLORS 3
|
||||
|
||||
@ -520,7 +589,7 @@ eItem treasureType(eLand l);
|
||||
void buildBarrier(cell *c, int d, eLand l = laNone);
|
||||
void extendBarrier(cell *c);
|
||||
bool buildBarrier4(cell *c, int d, int mode, eLand ll, eLand lr);
|
||||
bool buildBarrier6(struct cellwalker cw, int type);
|
||||
bool buildBarrier6(cellwalker cw, int type);
|
||||
bool makeEmpty(cell *c);
|
||||
bool isCrossroads(eLand l);
|
||||
enum orbAction { roMouse, roKeyboard, roCheck, roMouseForce, roMultiCheck, roMultiGo };
|
||||
@ -537,7 +606,7 @@ void checkOnYendorPath();
|
||||
void killThePlayerAt(eMonster m, cell *c, flagtype flags);
|
||||
bool notDippingFor(eItem i);
|
||||
bool collectItem(cell *c2, bool telekinesis = false);
|
||||
void castLightningBolt(struct cellwalker lig);
|
||||
void castLightningBolt(cellwalker lig);
|
||||
bool movepcto(int d, int subdir = 1, bool checkonly = false);
|
||||
void stabbingAttack(cell *mf, cell *mt, eMonster who, int bonuskill = 0);
|
||||
bool earthMove(cell *from, int dir);
|
||||
@ -1322,7 +1391,7 @@ bool withRose(cell *cfrom, cell *cto);
|
||||
|
||||
#define fakecellloop(ct) for(cell *ct = (cell*)1; ct; ct=NULL)
|
||||
|
||||
#define forCellIdAll(ct, i, cf) fakecellloop(ct) for(int i=0; i<(cf)->type && (ct=(cf)->mov[i],true); i++)
|
||||
#define forCellIdAll(ct, i, cf) fakecellloop(ct) for(int i=0; i<(cf)->type && (ct=(cf)->move(i),true); i++)
|
||||
#define forCellIdCM(ct, i, cf) fakecellloop(ct) for(int i=0; i<(cf)->type && (ct=createMov((cf),i),true); i++)
|
||||
#define forCellIdEx(ct, i, cf) forCellIdAll(ct,i,cf) if(ct)
|
||||
|
||||
@ -2755,11 +2824,6 @@ extern int startseed;
|
||||
extern transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE];
|
||||
extern transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
|
||||
|
||||
static const struct wstep_t { wstep_t() {} } wstep;
|
||||
static const struct wmirror_t { wmirror_t() {}} wmirror;
|
||||
|
||||
heptspin operator + (const heptspin& hs, wstep_t);
|
||||
|
||||
// heptspin hsstep(const heptspin &hs, int spin);
|
||||
|
||||
extern void fixmatrix(transmatrix&);
|
||||
@ -3711,25 +3775,12 @@ void queuestr(int x, int y, int shift, int size, string str, int col, int frame
|
||||
|
||||
ld frac(ld x);
|
||||
|
||||
cellwalker& operator += (cellwalker& cw, wstep_t);
|
||||
cellwalker& operator += (cellwalker& cw, int spin);
|
||||
|
||||
template <class T> cellwalker operator + (cellwalker h, T t) { return h += t; }
|
||||
template <class T> cellwalker operator - (cellwalker h, T t) { return h += (-t); }
|
||||
|
||||
bool cwstepcreates(cellwalker& cw);
|
||||
extern int poly_outline;
|
||||
|
||||
extern hpcshape shDisk, shTriangle, shHeptaMarker, shSnowball, shDiskT, shDiskS, shDiskSq, shDiskM;
|
||||
|
||||
extern std::mt19937 hrngen;
|
||||
|
||||
heptspin& operator += (heptspin& hs, int spin);
|
||||
heptspin operator + (const heptspin& hs, wstep_t);
|
||||
heptspin operator + (heptspin h, int spin);
|
||||
heptspin operator - (heptspin h, int spin);
|
||||
heptspin& operator += (heptspin& h, wstep_t);
|
||||
|
||||
bool anglestraight(cell *c, int d1, int d2);
|
||||
|
||||
hyperpoint randomPointIn(int t);
|
||||
|
50
hypgraph.cpp
50
hypgraph.cpp
@ -504,15 +504,15 @@ ld master_to_c7_angle() {
|
||||
|
||||
transmatrix actualV(const heptspin& hs, const transmatrix& V) {
|
||||
if(irr::on)
|
||||
return V * spin(M_PI + 2 * M_PI / S7 * (hs.spin + irr::periodmap[hs.h].base.spin));
|
||||
if(syntetic) return V * spin(-synt::triangles[synt::id_of(hs.h)][hs.spin].first);
|
||||
return V * spin(M_PI + 2 * M_PI / S7 * (hs.spin + irr::periodmap[hs.at].base.spin));
|
||||
if(syntetic) return V * spin(-synt::triangles[synt::id_of(hs.at)][hs.spin].first);
|
||||
if(binarytiling) return V;
|
||||
return (hs.spin || nonbitrunc) ? V * spin(hs.spin*2*M_PI/S7 + master_to_c7_angle()) : V;
|
||||
}
|
||||
|
||||
transmatrix applyspin(const heptspin& hs, const transmatrix& V) {
|
||||
if(binarytiling) return V;
|
||||
if(syntetic) return V * spin(synt::triangles[synt::id_of(hs.h)][hs.spin].first);
|
||||
if(syntetic) return V * spin(synt::triangles[synt::id_of(hs.at)][hs.spin].first);
|
||||
return hs.spin ? V * spin(hs.spin*2*M_PI/S7) : V;
|
||||
}
|
||||
|
||||
@ -529,9 +529,9 @@ void drawrec(cell *c, const transmatrix& V) {
|
||||
if(dodrawcell(c))
|
||||
drawcell(c, V, 0, false);
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
if(c2->mov[0] != c) continue;
|
||||
if(c2->move(0) != c) continue;
|
||||
if(c2 == c2->master->c7) continue;
|
||||
transmatrix V1 = V * ddspin(c, i) * xpush(crossf) * iddspin(c2, 0) * spin(M_PI);
|
||||
drawrec(c2, V1);
|
||||
@ -553,9 +553,9 @@ void drawrec(cell *c, const transmatrix& V) {
|
||||
drawcell(c, V1, 0, false);
|
||||
}
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
if(c2->mov[0] != c) continue;
|
||||
if(c2->move(0) != c) continue;
|
||||
if(c2 == c2->master->c7) continue;
|
||||
drawrec(c2, V, at + eudir(dir+i), dir + i + SG3, maindir);
|
||||
}
|
||||
@ -568,9 +568,9 @@ void drawrec(cell *c, const transmatrix& V) {
|
||||
if(dodrawcell(c))
|
||||
drawcell(c, V, 0, false);
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
if(c2->mov[0] != c) continue;
|
||||
if(c2->move(0) != c) continue;
|
||||
if(c2 == c2->master->c7) continue;
|
||||
draw_li.last_dir = i;
|
||||
drawrec(c2, V, gp::loc(1,0), SG3, i);
|
||||
@ -580,9 +580,9 @@ void drawrec(cell *c, const transmatrix& V) {
|
||||
|
||||
void drawrec(const heptspin& hs, hstate s, const transmatrix& V) {
|
||||
|
||||
// calc_relative_matrix(cwt.c, hs.h);
|
||||
// calc_relative_matrix(cwt.c, hs.at);
|
||||
|
||||
cell *c = hs.h->c7;
|
||||
cell *c = hs.at->c7;
|
||||
|
||||
transmatrix V10;
|
||||
const transmatrix& V1 = hs.mirrored ? (V10 = V * Mirror) : V;
|
||||
@ -594,9 +594,9 @@ void drawrec(const heptspin& hs, hstate s, const transmatrix& V) {
|
||||
}
|
||||
|
||||
else if(irr::on) {
|
||||
auto& hi = irr::periodmap[hs.h];
|
||||
auto& hi = irr::periodmap[hs.at];
|
||||
transmatrix V0 = actualV(hs, V1);
|
||||
auto& vc = irr::cells_of_heptagon[hi.base.h];
|
||||
auto& vc = irr::cells_of_heptagon[hi.base.at];
|
||||
for(int i=0; i<isize(vc); i++)
|
||||
if(dodrawcell(hi.subcells[i]) && in_qrange(V0 * irr::cells[vc[i]].pusher))
|
||||
draw = true,
|
||||
@ -610,12 +610,12 @@ void drawrec(const heptspin& hs, hstate s, const transmatrix& V) {
|
||||
}
|
||||
|
||||
if(!nonbitrunc) for(int d=0; d<S7; d++) {
|
||||
int ds = fixrot(hs.h, hs.spin + d);
|
||||
int ds = hs.at->c.fix(hs.spin + d);
|
||||
// createMov(c, ds);
|
||||
if(c->mov[ds] && c->spn(ds) == 0 && dodrawcell(c->mov[ds])) {
|
||||
if(c->move(ds) && c->c.spin(ds) == 0 && dodrawcell(c->move(ds))) {
|
||||
transmatrix V2 = V1 * hexmove[d];
|
||||
if(in_qrange(V2))
|
||||
drawcell(c->mov[ds], V2, 0, hs.mirrored ^ c->mirror(ds));
|
||||
drawcell(c->move(ds), V2, 0, hs.mirrored ^ c->c.mirror(ds));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -692,7 +692,7 @@ ld matrixnorm(const transmatrix& Mat) {
|
||||
void drawEuclidean() {
|
||||
DEBB(DF_GRAPH, (debugfile,"drawEuclidean\n"));
|
||||
sphereflip = Id;
|
||||
if(!centerover.c) centerover = cwt;
|
||||
if(!centerover.at) centerover = cwt;
|
||||
// printf("centerover = %p player = %p [%d,%d]-[%d,%d]\n", lcenterover, cwt.c,
|
||||
// mindx, mindy, maxdx, maxdy);
|
||||
int pvec = cellwalker_to_vec(centerover);
|
||||
@ -713,7 +713,7 @@ void drawEuclidean() {
|
||||
cellwalker cw = vec_to_cellwalker(pvec + euclid_getvec(dx, dy));
|
||||
transmatrix Mat = eumove(dx,dy);
|
||||
|
||||
if(!cw.c) continue;
|
||||
if(!cw.at) continue;
|
||||
|
||||
Mat = View0 * Mat;
|
||||
|
||||
@ -738,8 +738,8 @@ void drawEuclidean() {
|
||||
if(dy > maxdy) maxdy = dy;
|
||||
}
|
||||
if(cx >= -cellrad && cy >= -cellrad && cx < vid.xres+cellrad && cy < vid.yres+cellrad)
|
||||
if(dodrawcell(cw.c)) {
|
||||
drawcell(cw.c, cw.mirrored ? Mat * Mirror : Mat, cw.spin, cw.mirrored);
|
||||
if(dodrawcell(cw.at)) {
|
||||
drawcell(cw.at, cw.mirrored ? Mat * Mirror : Mat, cw.spin, cw.mirrored);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -806,16 +806,16 @@ void optimizeview() {
|
||||
|
||||
if(binarytiling || syntetic) {
|
||||
turn = -1, best = View[2][2];
|
||||
for(int i=0; i<viewctr.h->c7->type; i++) {
|
||||
heptagon *h2 = createStep(viewctr.h, i);
|
||||
transmatrix T = (binarytiling) ? binary::relative_matrix(h2, viewctr.h) : synt::relative_matrix(h2, viewctr.h);
|
||||
for(int i=0; i<viewctr.at->c7->type; i++) {
|
||||
heptagon *h2 = createStep(viewctr.at, i);
|
||||
transmatrix T = (binarytiling) ? binary::relative_matrix(h2, viewctr.at) : synt::relative_matrix(h2, viewctr.at);
|
||||
hyperpoint H = View * tC0(T);
|
||||
if(H[2] < best) best = H[2], turn = i, TB = T;
|
||||
}
|
||||
if(turn >= 0) {
|
||||
View = View * TB;
|
||||
fixmatrix(View);
|
||||
viewctr.h = createStep(viewctr.h, turn);
|
||||
viewctr.at = createStep(viewctr.at, turn);
|
||||
}
|
||||
}
|
||||
|
||||
@ -866,7 +866,7 @@ void resetview() {
|
||||
View = Id;
|
||||
// EUCLIDEAN
|
||||
if(!stdeuclid)
|
||||
viewctr.h = cwt.c->master,
|
||||
viewctr.at = cwt.at->master,
|
||||
viewctr.spin = cwt.spin;
|
||||
else centerover = cwt;
|
||||
cwtV = Id;
|
||||
|
12
init.cpp
12
init.cpp
@ -82,7 +82,7 @@ string buildScoreDescription() {
|
||||
s += XLAT("HyperRogue for Android");
|
||||
s += " ( " VER "), http://www.roguetemple.com/z/hyper/\n";
|
||||
s += XLAT("Date: %1 time: %2 s ", buf, getgametime_s());
|
||||
s += XLAT("distance: %1\n", its(celldist(cwt.c)));
|
||||
s += XLAT("distance: %1\n", its(celldist(cwt.at)));
|
||||
// s += buf2;
|
||||
if(cheater) s += XLAT("Cheats: ") + its(cheater) + "\n";
|
||||
s += XLAT("Score: ") + its(gold());
|
||||
@ -149,7 +149,7 @@ void handleclick(MOBPAR_FORMAL) {
|
||||
|
||||
else if(statkeys && getcstat == 't') {
|
||||
if(playermoved && items[itStrongWind]) {
|
||||
cell *c = whirlwind::jumpDestination(cwt.c);
|
||||
cell *c = whirlwind::jumpDestination(cwt.at);
|
||||
if(c) centerover.c = c, centerover.spin = 0;
|
||||
}
|
||||
targetRangedOrb(centerover.c, roKeyboard);
|
||||
@ -172,7 +172,7 @@ void handleclick(MOBPAR_FORMAL) {
|
||||
ors::reset();
|
||||
centerpc(INF);
|
||||
View = Id;
|
||||
viewctr.h = cwt.c->master;
|
||||
viewctr.h = cwt.at->master;
|
||||
}
|
||||
andmode = 11;
|
||||
}
|
||||
@ -207,7 +207,7 @@ void handleclick(MOBPAR_FORMAL) {
|
||||
if(!playerfound) {
|
||||
centerpc(INF);
|
||||
View = Id;
|
||||
viewctr.h = cwt.c->master;
|
||||
viewctr.h = cwt.at->master;
|
||||
}
|
||||
playermoved = true;
|
||||
}
|
||||
@ -273,7 +273,7 @@ void mobile_draw(MOBPAR_FORMAL) {
|
||||
int dy = mousey - yb;
|
||||
int h = hypot(dx, dy);
|
||||
if(h < rad) {
|
||||
if(h < rad*SKIPFAC) { lmouseover = cwt.c; mousedest.d = -1; }
|
||||
if(h < rad*SKIPFAC) { lmouseover = cwt.at; mousedest.d = -1; }
|
||||
else {
|
||||
double d = vid.revcontrol ? -1 : 1;
|
||||
mouseh = hpxy(dx * d / rad, dy * d / rad);
|
||||
@ -282,7 +282,7 @@ void mobile_draw(MOBPAR_FORMAL) {
|
||||
}
|
||||
}
|
||||
if(andmode == 0 && !useRangedOrb && gtouched && lclicked) {
|
||||
lmouseover = mousedest.d >= 0 ? cwt.c->mov[(cwt.spin + mousedest.d) % cwt.c->type] : cwt.c;
|
||||
lmouseover = mousedest.d >= 0 ? cwt.at->modmove(cwt.spin + mousedest.d) : cwt.at;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ namespace hr { namespace inv {
|
||||
if(it == itOrbSword || it == itOrbSword2) {
|
||||
for(int i=0; i<numplayers(); i++)
|
||||
if(multi::playerActive(i)) {
|
||||
cwt.c = playerpos(i);
|
||||
cwt.at = playerpos(i);
|
||||
multi::cpid = i;
|
||||
swordAttackStatic(it == itOrbSword2);
|
||||
}
|
||||
@ -576,7 +576,7 @@ namespace hr { namespace inv {
|
||||
addMessage(XLAT("You mirror %the1.", orb));
|
||||
if(mirroring) {
|
||||
bool next = false;
|
||||
forCellEx(c2, cwt.c) if(c2->wall == waMirror || c2->wall == waCloud || c2->wall == waMirrorWall)
|
||||
forCellEx(c2, cwt.at) if(c2->wall == waMirror || c2->wall == waCloud || c2->wall == waMirrorWall)
|
||||
next = true;
|
||||
if(!next) {
|
||||
addMessage(XLAT("You need to stand next to a magic mirror or cloud to use %the1.", itOrbMirror));
|
||||
@ -598,20 +598,20 @@ namespace hr { namespace inv {
|
||||
}
|
||||
else mirroring = false;
|
||||
}
|
||||
else if((isHaunted(cwt.c->land) || cwt.c->land == laDungeon) && orb == itOrbSafety) {
|
||||
else if((isHaunted(cwt.at->land) || cwt.at->land == laDungeon) && orb == itOrbSafety) {
|
||||
addMessage(XLAT("This would only move you deeper into the trap!"));
|
||||
}
|
||||
else {
|
||||
eItem it = cwt.c->item;
|
||||
cwt.c->item = orbmap[uni];
|
||||
eItem it = cwt.at->item;
|
||||
cwt.at->item = orbmap[uni];
|
||||
inv::activating = true;
|
||||
collectItem(cwt.c, true);
|
||||
collectItem(cwt.at, true);
|
||||
inv::activating = false;
|
||||
addMessage(XLAT("You activate %the1.", orbmap[uni]));
|
||||
if(!cwt.c->item) usedup[orbmap[uni]]++;
|
||||
if(!cwt.at->item) usedup[orbmap[uni]]++;
|
||||
if(getOLR(it, getPrizeLand()) == olrForbidden)
|
||||
usedForbidden = true;
|
||||
cwt.c->item = it;
|
||||
cwt.at->item = it;
|
||||
evokeOrb(orbmap[uni]);
|
||||
checkmove();
|
||||
popScreenAll();
|
||||
|
@ -490,7 +490,7 @@ bool step(int delta) {
|
||||
ld dists[8];
|
||||
for(int i=0; i<S7; i++) {
|
||||
dists[i] = hdist(s.p, spin(hexshift - i * ALPHA) * xpush(-hcrossf) * C0);
|
||||
// calc_relative_matrix(s.owner->mov[i], s.owner, s.p) * C0);
|
||||
// calc_relative_matrix(s.owner->move(i), s.owner, s.p) * C0);
|
||||
// spin(2 * M_PI * i / S7) * xpush(hcrossf) * C0);
|
||||
if(dists[i] < dist)
|
||||
d = i, dist = dists[i];
|
||||
@ -537,7 +537,7 @@ bool draw_cell_schematics(cell *c, transmatrix V) {
|
||||
|
||||
queueline(V * p.p, V * C0, 0xFF0000FF);
|
||||
if(p.patterndir != -1)
|
||||
queueline(V * p.p, V * calc_relative_matrix(c->master->move[p.patterndir]->c7, c, p.p) * C0, 0x00FF00FF);
|
||||
queueline(V * p.p, V * calc_relative_matrix(c->master->move(p.patterndir)->c7, c, p.p) * C0, 0x00FF00FF);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -553,10 +553,10 @@ struct heptinfo {
|
||||
map<heptagon*, heptinfo> periodmap;
|
||||
|
||||
void link_to_base(heptagon *h, heptspin base) {
|
||||
// printf("linking %p to %p/%d\n", h, base.h, base.spin);
|
||||
// printf("linking %p to %p/%d\n", h, base.at, base.spin);
|
||||
auto &hi = periodmap[h];
|
||||
hi.base = base;
|
||||
for(int k: cells_of_heptagon[base.h]) {
|
||||
for(int k: cells_of_heptagon[base.at]) {
|
||||
cell *c = newCell(isize(cells[k].vertices), h);
|
||||
hi.subcells.push_back(c);
|
||||
cellindex[c] = k;
|
||||
@ -567,7 +567,7 @@ void link_to_base(heptagon *h, heptspin base) {
|
||||
void clear_links(heptagon *h) {
|
||||
auto& hi = periodmap[h];
|
||||
for(cell *c: hi.subcells) {
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i]) c->mov[i]->mov[c->spin(i)] = NULL;
|
||||
for(int i=0; i<c->type; i++) if(c->move(i)) c->move(i)->move(c->c.spin(i)) = NULL;
|
||||
cellindex.erase(c);
|
||||
delete c;
|
||||
}
|
||||
@ -582,14 +582,14 @@ void link_start(heptagon *h) {
|
||||
void link_next(heptagon *parent, int d) {
|
||||
if(!periodmap.count(parent))
|
||||
link_to_base(parent, heptspin(cells[0].owner->master, 0));
|
||||
// printf("linking next: %p direction %d [s%d]\n", parent, d, parent->spin(d));
|
||||
auto *h = parent->move[d];
|
||||
heptspin hs = periodmap[parent].base + d + wstep - parent->spin(d);
|
||||
// printf("linking next: %p direction %d [s%d]\n", parent, d, parent->c.spin(d));
|
||||
auto *h = parent->move(d);
|
||||
heptspin hs = periodmap[parent].base + d + wstep - parent->c.spin(d);
|
||||
link_to_base(h, hs);
|
||||
}
|
||||
|
||||
void may_link_next(heptagon *parent, int d) {
|
||||
if(!periodmap.count(parent->move[d]))
|
||||
if(!periodmap.count(parent->move(d)))
|
||||
link_next(parent, d);
|
||||
}
|
||||
|
||||
@ -610,26 +610,23 @@ void link_cell(cell *c, int d) {
|
||||
else {
|
||||
int dirs = 0;
|
||||
int os = periodmap[c->master].base.spin;
|
||||
for(int d=0; d<S7; d++) if(sc2.owner->master == sc.owner->master->move[(os+d)%S7]) {
|
||||
for(int d=0; d<S7; d++) if(sc2.owner->master == sc.owner->master->modmove(os+d)) {
|
||||
heptspin hss(c->master, d);
|
||||
hss += wstep;
|
||||
master2 = hss.h;
|
||||
// printf("master2 is %p; base = %p; should be = %p\n", master2, periodmap[master2].base.h, sc2.owner->master);
|
||||
master2 = hss.at;
|
||||
// printf("master2 is %p; base = %p; should be = %p\n", master2, periodmap[master2].base.at, sc2.owner->master);
|
||||
dirs++;
|
||||
}
|
||||
if(dirs != 1) { printf("dirs error\n"); exit(1); }
|
||||
}
|
||||
|
||||
cell *c2 = periodmap[master2].subcells[sc2.localindex];
|
||||
c->mov[d] = c2;
|
||||
tsetspin(c->spintable, d, sc.spin[d]);
|
||||
c2->mov[sc.spin[d]] = c;
|
||||
tsetspin(c2->spintable, sc.spin[d], d);
|
||||
c->c.connect(d, c2, sc.spin[d], false);
|
||||
}
|
||||
|
||||
int hdist(heptagon *h1, heptagon *h2) {
|
||||
if(h1 == h2) return 0;
|
||||
for(int i=0; i<S7; i++) if(h1->move[i] == h2) return 1;
|
||||
for(int i=0; i<S7; i++) if(h1->move(i) == h2) return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -669,7 +666,7 @@ void compute_distances(heptagon *h, bool alts) {
|
||||
vector<heptagon*> hs;
|
||||
hs.push_back(h);
|
||||
for(int i=0; i<S7; i++) if(dm4(createStep(h, i)) == cdm)
|
||||
hs.push_back(h->move[i]);
|
||||
hs.push_back(h->move(i));
|
||||
|
||||
vector<vector<int>*> to_clear;
|
||||
|
||||
@ -724,10 +721,10 @@ void compute_horocycle(heptagon *alt) {
|
||||
for(auto h: hs[i]) {
|
||||
generateAlts(h);
|
||||
for(int j=0; j<S7; j++) {
|
||||
if(h->move[j]->alt->alt != master->alt->alt) continue;
|
||||
region.insert(h->move[j]);
|
||||
if(h->move[j]->alt->distance < h->alt->distance)
|
||||
hs[i+1].insert(h->move[j]);
|
||||
if(h->move(j)->alt->alt != master->alt->alt) continue;
|
||||
region.insert(h->move(j));
|
||||
if(h->move(j)->alt->distance < h->alt->distance)
|
||||
hs[i+1].insert(h->move(j));
|
||||
}
|
||||
}
|
||||
if(hs[i+1].empty()) { printf("error: hs[%d] not found\n", i+1); exit(1); }
|
||||
@ -748,7 +745,7 @@ void compute_horocycle(heptagon *alt) {
|
||||
}
|
||||
int delta = NODISTANCE;
|
||||
for(int i=0; i<S7; i++) {
|
||||
heptagon *h = master->move[i];
|
||||
heptagon *h = master->move(i);
|
||||
if(h->alt->alt != master->alt->alt) continue;
|
||||
heptinfo& hi = periodmap[h];
|
||||
if(!isize(hi.celldists[1])) continue;
|
||||
@ -770,7 +767,7 @@ void compute_horocycle(heptagon *alt) {
|
||||
|
||||
for(int i=0; i<LOOKUP/2; i++) {
|
||||
for(auto h: hs[i]) for(int j=-1; j<S7; j++) {
|
||||
heptinfo& hi = periodmap[j == -1 ? h : h->move[j]];
|
||||
heptinfo& hi = periodmap[j == -1 ? h : h->move(j)];
|
||||
hi.celldists[1].resize(isize(hi.subcells));
|
||||
for(int c=0; c<isize(hi.subcells); c++)
|
||||
hi.celldists[1][c] = delta + xdist[hi.subcells[c]];
|
||||
@ -785,16 +782,16 @@ int celldist(cell *c, bool alts) {
|
||||
auto &hi = periodmap[master];
|
||||
/* if(alts && master->alt->alt->s != hsOrigin && isize(hi.celldists[alts]) == 0) {
|
||||
int doalts = 0;
|
||||
for(int i=0; i<S7; i++) if(master->move[i]->alt == master->alt->move[0]) {
|
||||
for(int i=0; i<S7; i++) if(master->move(i)->alt == master->alt->move[0]) {
|
||||
doalts = 1;
|
||||
if(periodmap[master->move[i]].celldists[true].empty()) {
|
||||
if(periodmap[master->move(i)].celldists[true].empty()) {
|
||||
compute_horocycle(master);
|
||||
doalts = 2;
|
||||
}
|
||||
}
|
||||
if(doalts == 0) {
|
||||
generateAlts(master);
|
||||
for(int i=0; i<S7; i++) if(master->move[i]->alt == master->alt->move[0] && periodmap[master->move[i]].celldists[true].empty())
|
||||
for(int i=0; i<S7; i++) if(master->move(i)->alt == master->alt->move[0] && periodmap[master->move(i)].celldists[true].empty())
|
||||
compute_horocycle(master);
|
||||
}
|
||||
} */
|
||||
@ -1072,7 +1069,7 @@ array<heptagon*, 3> get_masters(cell *c) {
|
||||
int d = cells[cellindex[c]].patterndir;
|
||||
heptspin s = periodmap[c->master].base;
|
||||
heptspin s0 = heptspin(c->master, 0) + (d - s.spin);
|
||||
return make_array(s0.h, (s0 + wstep).h, (s0 + 1 + wstep).h);
|
||||
return make_array(s0.at, (s0 + wstep).at, (s0 + 1 + wstep).at);
|
||||
}
|
||||
|
||||
auto hook =
|
||||
|
108
landgen.cpp
108
landgen.cpp
@ -145,7 +145,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
else prairie::generateBeast(c);
|
||||
}
|
||||
else if(!prairie::nearriver(c) && c->LHU.fi.flowerdist > 7) {
|
||||
if(hrand(9000) < items[itGreenGrass] - (prairie::isriver(cwt.c) ? 40 : 0))
|
||||
if(hrand(9000) < items[itGreenGrass] - (prairie::isriver(cwt.at) ? 40 : 0))
|
||||
c->monst = moGadfly;
|
||||
else buildPrizeMirror(c, 1000);
|
||||
}
|
||||
@ -277,17 +277,17 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
else {
|
||||
int q = 0, s = 0;
|
||||
if(!ishept(c)) for(int i=0; i<c->type; i++)
|
||||
if(cdist50(c->mov[i]) == 3 && polarb50(c->mov[i]) == 1 && !ishept(c->mov[i]))
|
||||
if(cdist50(c->move(i)) == 3 && polarb50(c->move(i)) == 1 && !ishept(c->move(i)))
|
||||
q++, s += i;
|
||||
if(q == 1 && c->mov[s]->land == laPalace) {
|
||||
if(q == 1 && c->move(s)->land == laPalace) {
|
||||
switch(princess::generating ? 0 : hrand(2)) {
|
||||
case 0:
|
||||
c->wall = waClosedGate;
|
||||
c->mov[s]->wall = waClosedGate;
|
||||
c->move(s)->wall = waClosedGate;
|
||||
break;
|
||||
case 1:
|
||||
c->wall = waOpenGate;
|
||||
c->mov[s]->wall = waOpenGate;
|
||||
c->move(s)->wall = waOpenGate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c->wall = waTrapdoor;
|
||||
|
||||
if(cdist50(c) == 0 && yendor::path) {
|
||||
cell *c2 = c->mov[hrand(c->type)];
|
||||
cell *c2 = c->move(hrand(c->type));
|
||||
if(c2->wall == waNone) c2->wall = waTrapdoor;
|
||||
}
|
||||
|
||||
@ -330,9 +330,9 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cellwalker cw(c, i);
|
||||
cw = cw + wstep + 4 + wstep + 2 + wstep + 4 + wstep + (2 + hrand(3)) + wstep;
|
||||
if(!c2) c2 = cw.c;
|
||||
else if(celldist(cw.c) > celldist(c2)) c2 = cw.c;
|
||||
cw.c->monst = moMouse;
|
||||
if(!c2) c2 = cw.at;
|
||||
else if(celldist(cw.at) > celldist(c2)) c2 = cw.at;
|
||||
cw.at->monst = moMouse;
|
||||
}
|
||||
c2->wall = waOpenPlate;
|
||||
}
|
||||
@ -429,7 +429,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
if(hrand(nonbitrunc?400:1000) < PT(100 + 2 * (kills[moMiner] + kills[moLancer] + kills[moFlailer]), 200) && notDippingFor(itEmerald)) {
|
||||
// do not destroy walls!
|
||||
bool ok = true;
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i]->wall == waCavewall) ok = false;
|
||||
for(int i=0; i<c->type; i++) if(c->move(i)->wall == waCavewall) ok = false;
|
||||
if(ok) c->item = itEmerald;
|
||||
}
|
||||
if(hrand(8000) < 50 + 10 * (items[itEmerald] + yendor::hardness())) {
|
||||
@ -511,12 +511,12 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
// seal entrances to the Land of Power.
|
||||
if(d == 7 && ctof(c)) {
|
||||
bool onwall = false;
|
||||
for(int i=0; i<7; i++) if(c->mov[i] && c->mov[i]->land == laBarrier)
|
||||
for(int i=0; i<7; i++) if(c->move(i) && c->move(i)->land == laBarrier)
|
||||
onwall = true;
|
||||
if(!onwall) for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
cell *c3 = c2->mov[(c->spn(i) + 3) % c2->type];
|
||||
cell *c3 = c2->modmove(c->c.spin(i) + 3);
|
||||
if(c3->land != laPower && c3->land != laBarrier)
|
||||
if(c2->wall != waFire && c2->wall != waGlass) {
|
||||
if(isFire(c)) c->monst = moWitchWinter;
|
||||
@ -727,7 +727,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c2->wall = waIcewall;
|
||||
for(int j=0; j<c2->type; j++) if(hrand(100) < 20) {
|
||||
cell *c3 = createMov(c2, j);
|
||||
setdist(c->mov[i], d+2, c);
|
||||
setdist(c->move(i), d+2, c);
|
||||
if(c3->wall == waBarrier || c3->land != laIce) continue;
|
||||
c3->wall = waIcewall;
|
||||
}
|
||||
@ -770,7 +770,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
// 40 is the usual rate of dragon generation
|
||||
int dchance = 40;
|
||||
// but it grows to 400 if no Dragons in sight, to make it faster
|
||||
if(cwt.c->land == laDragon && !(havewhat&HF_DRAGON))
|
||||
if(cwt.at->land == laDragon && !(havewhat&HF_DRAGON))
|
||||
dchance = 400;
|
||||
// also, don't generate additional Dragons for newbies
|
||||
else if((havewhat&HF_DRAGON) && items[itDragon] < 10)
|
||||
@ -780,7 +780,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
havewhat |= HF_DRAGON;
|
||||
// printf("dragon generated with dchance = %d\n", dchance);
|
||||
vector<int> possi;
|
||||
for(int t=0; t<c->type; t++) if(c->mov[t]->mpdist > c->mpdist) possi.push_back(t);
|
||||
for(int t=0; t<c->type; t++) if(c->move(t)->mpdist > c->mpdist) possi.push_back(t);
|
||||
if(isize(possi)) {
|
||||
int i = possi[hrand(isize(possi))];
|
||||
int dragonlength = 6 + items[itDragon] / 2;
|
||||
@ -794,8 +794,8 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
preventbarriers(c2);
|
||||
c2->mondir = i;
|
||||
createMov(c2, i);
|
||||
int j = c2->spn(i);
|
||||
cell *c3 = c2->mov[i];
|
||||
int j = c2->c.spin(i);
|
||||
cell *c3 = c2->move(i);
|
||||
if(c3->monst || c3->bardir != NODIR || c3->wall || c3->mpdist <= 7) break;
|
||||
c2 = c3;
|
||||
c2->monst = moDragonTail;
|
||||
@ -891,10 +891,10 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
if(hrand(16000) < (items[itSilver] + yendor::hardness())) {
|
||||
c->monst = moEarthElemental;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
earthFloor(c2);
|
||||
}
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i]->mpdist < c->mpdist) c->mondir = i;
|
||||
for(int i=0; i<c->type; i++) if(c->move(i)->mpdist < c->mpdist) c->mondir = i;
|
||||
chasmifyEarth(c); c->wall = waDeadfloor2;
|
||||
}
|
||||
else if(hrand(8000) < 60 + 8 * (items[itSilver] + yendor::hardness())) {
|
||||
@ -967,8 +967,8 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
cell* cc[5];
|
||||
cc[2] = c;
|
||||
cellwalker cw2 = cw;
|
||||
cw += wstep; cc[3] = cw.c; cw += revstep; cc[4] = cw.c;
|
||||
cw2 += revstep; cc[1] = cw2.c; cw2 += revstep; cc[0] = cw2.c;
|
||||
cw += wstep; cc[3] = cw.at; cw += revstep; cc[4] = cw.at;
|
||||
cw2 += revstep; cc[1] = cw2.at; cw2 += revstep; cc[0] = cw2.at;
|
||||
bool ok = true;
|
||||
for(int i=0; i<5; i++) {
|
||||
if(cc[i]->land != laNone && cc[i]->land != laTerracotta) ok = false;
|
||||
@ -1031,8 +1031,8 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c->landparam = items[itMutant] + 5 + hrand(11);
|
||||
c->wall = waNone;
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && (c->mov[i]->wall == waBigTree || c->mov[i]->wall == waSmallTree))
|
||||
c->mov[i]->wall = waNone;
|
||||
if(c->move(i) && (c->move(i)->wall == waBigTree || c->move(i)->wall == waSmallTree))
|
||||
c->move(i)->wall = waNone;
|
||||
}
|
||||
else if(hrand(15000) < 20 + (2 * items[itMutant] + yendor::hardness()) && !safety) {
|
||||
// for the Yendor Challenge, use only Mutants
|
||||
@ -1160,7 +1160,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
bool sand = false;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
createMov(c, i);
|
||||
tie(x,y) = cell_to_pair(c->mov[i]);
|
||||
tie(x,y) = cell_to_pair(c->move(i));
|
||||
if((x+1)%3 == 0 && (y)%3 == 0) sand = true;
|
||||
}
|
||||
if(sand && hrand(100) < 20)
|
||||
@ -1217,7 +1217,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
}
|
||||
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && c->mov[i]->land != laStorms && c->mov[i]->land != laNone)
|
||||
if(c->move(i) && c->move(i)->land != laStorms && c->move(i)->land != laNone)
|
||||
c->wall = waNone;
|
||||
}
|
||||
if(d == BARLEV && randstorm) {
|
||||
@ -1298,8 +1298,8 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
|
||||
for(int j=0; j<2; j++) {
|
||||
int i = hrand(c->type);
|
||||
if(c->mov[i] && c->mov[i]->land == laRlyeh)
|
||||
c->mov[i]->wall = waNone;
|
||||
if(c->move(i) && c->move(i)->land == laRlyeh)
|
||||
c->move(i)->wall = waNone;
|
||||
}
|
||||
}
|
||||
if(pseudohept(c) && hrand(2)) c->wall = waColumn;
|
||||
@ -1314,10 +1314,10 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c->monst = hrand(3) ? ((hrand(40) < items[itStatue]-25) ? moCultistLeader : moCultist) : moPyroCultist;
|
||||
else if(hrand(8000) < 5 + items[itStatue] + yendor::hardness() && c->type == 6 && !(yendor::on && (yendor::clev().flags & YF_NEAR_TENT)) && celldist(c)>=3) {
|
||||
for(int t=0; t<c->type; t++) {
|
||||
if(c->mov[t] && c->mov[t]->monst == moNone && (c->wall == waNone || c->wall == waColumn))
|
||||
c->mov[t]->wall = ishept(c->mov[t]) ? waColumn : waNone;
|
||||
if(c->mov[t]->wall == waColumn)
|
||||
c->mov[t]->item = itNone;
|
||||
if(c->move(t) && c->move(t)->monst == moNone && (c->wall == waNone || c->wall == waColumn))
|
||||
c->move(t)->wall = ishept(c->move(t)) ? waColumn : waNone;
|
||||
if(c->move(t)->wall == waColumn)
|
||||
c->move(t)->item = itNone;
|
||||
}
|
||||
if(buildIvy(c, 0, 3) && !peace::on) c->item = itStatue;
|
||||
}
|
||||
@ -1410,7 +1410,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
hive::createBugArmy(c);
|
||||
if(hrand(2000) < 100 && !c->wall && !c->item && !c->monst) {
|
||||
int nww = 0;
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i] && c->mov[i]->wall == waWaxWall)
|
||||
for(int i=0; i<c->type; i++) if(c->move(i) && c->move(i)->wall == waWaxWall)
|
||||
nww++;
|
||||
if(nww == 0) {
|
||||
c->wall = waWaxWall;
|
||||
@ -1449,7 +1449,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
forCellIdEx(c2, i, c) {
|
||||
c2->monst = moKrakenT;
|
||||
c2->hitpoints = 1;
|
||||
c2->mondir = c->spn(i);
|
||||
c2->mondir = c->c.spin(i);
|
||||
}
|
||||
if(!peace::on) playSound(c, "seen-kraken");
|
||||
}
|
||||
@ -1493,7 +1493,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
if(d == 8 && !eubinary) {
|
||||
int mindist = 9;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if((eubinary || c2->master->alt) && celldistAlt(c2) < mindist)
|
||||
mindist = celldistAlt(c2);
|
||||
}
|
||||
@ -1502,7 +1502,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
if(d == 7 && c->wall == waSea) {
|
||||
bool coast = false;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(passable(c2, c, 0) && c2->wall != waBoat) coast = true;
|
||||
}
|
||||
if(coast && hrand(10) < 5) {
|
||||
@ -1580,8 +1580,8 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
|
||||
for(int j=0; j<2; j++) {
|
||||
int i = hrand(c->type);
|
||||
if(c->mov[i] && c->mov[i]->land == laDesert)
|
||||
c->mov[i]->wall = waNone;
|
||||
if(c->move(i) && c->move(i)->land == laDesert)
|
||||
c->move(i)->wall = waNone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1615,12 +1615,12 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
int i = hrand(S7);
|
||||
buildRedWall(createMovR(c, i), 33);
|
||||
if(hrand(2) == 0)
|
||||
buildRedWall(createMovR(createMovR(c, i), c->spn(i)+(hrand(2)?2:4)), 20);
|
||||
buildRedWall(createMovR(createMovR(c, i), c->c.spin(i)+(hrand(2)?2:4)), 20);
|
||||
i = (i + 3 + hrand(2)) % S7;
|
||||
if(hrand(6) < 4)
|
||||
buildRedWall(createMovR(c, i), 33);
|
||||
if(hrand(2) == 0)
|
||||
buildRedWall(createMovR(createMovR(c, i), c->spn(i)+(hrand(2)?2:4)), 20);
|
||||
buildRedWall(createMovR(createMovR(c, i), c->c.spin(i)+(hrand(2)?2:4)), 20);
|
||||
}
|
||||
}
|
||||
if(d == 7 && c->wall == waNone)
|
||||
@ -1628,7 +1628,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
ONEMPTY {
|
||||
if(hrand((doCross && celldist(c) <= 5) ?450:16000) < 30+items[itRedGem]+yendor::hardness() && !pseudohept(c) && !c->monst && !c->wall && !(nonbitrunc && S3==4)) {
|
||||
int i = -1;
|
||||
for(int t=0; t<c->type; t++) if(c->mov[t]->mpdist > c->mpdist && !pseudohept(c->mov[t]))
|
||||
for(int t=0; t<c->type; t++) if(c->move(t)->mpdist > c->mpdist && !pseudohept(c->move(t)))
|
||||
i = t;
|
||||
if(i != -1 && !peace::on)
|
||||
generateSnake(c, i, 1);
|
||||
@ -1643,7 +1643,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
ONEMPTY {
|
||||
if(hrand(30000) < 30+items[itSnake]+yendor::hardness() && !c->monst && !c->wall && !peace::on) {
|
||||
vector<int> gooddir;
|
||||
for(int t=0; t<c->type; t++) if(c->mov[t]->mpdist > c->mpdist)
|
||||
for(int t=0; t<c->type; t++) if(c->move(t)->mpdist > c->mpdist)
|
||||
gooddir.push_back(t);
|
||||
if(isize(gooddir))
|
||||
generateSnake(c, gooddir[hrand(isize(gooddir))], 2);
|
||||
@ -1670,7 +1670,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c->wall = waSmallTree;
|
||||
int q = 0;
|
||||
if(!nonbitrunc && !chaosmode && !weirdhyperbolic) for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && !isWarped(c->mov[i]->land) && c->mov[i]->land != laCrossroads4)
|
||||
if(c->move(i) && !isWarped(c->move(i)->land) && c->move(i)->land != laCrossroads4)
|
||||
q++;
|
||||
if(q == 1) c->wall = waWarpGate;
|
||||
}
|
||||
@ -1679,7 +1679,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c->wall = waSea;
|
||||
int q = 0;
|
||||
if(!nonbitrunc && !chaosmode) for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && !isWarped(c->mov[i]->land)) q++;
|
||||
if(c->move(i) && !isWarped(c->move(i)->land)) q++;
|
||||
if(q == 1) c->wall = waWarpGate;
|
||||
}
|
||||
}
|
||||
@ -1743,10 +1743,10 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
if(d == 8 && c->land == laRose && hrand(2000) < 100 && !c->wall && !c->item && !c->monst) {
|
||||
int nww = 0;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2 && c2->wall == waRose) nww++;
|
||||
if(!chaosmode) for(int j=0; j<c2->type; j++) {
|
||||
cell *c3 = c2->mov[j];
|
||||
cell *c3 = c2->move(j);
|
||||
// note: c3->land is required for Android --
|
||||
// not strictly equivalent since another land there might be not yet generated
|
||||
if(c3 && c3->land != laRose && c3->land) nww++;
|
||||
@ -1760,7 +1760,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
}
|
||||
ONEMPTY {
|
||||
if(hrand(2000) < PT(25 + min(kills[moFalsePrincess] + kills[moRoseBeauty] + kills[moRoseLady], 200), 100) && notDippingFor(itRose)) {
|
||||
for(int t=0; t<c->type; t++) if(c->mov[t] && c->mov[t]->wall == waRose)
|
||||
for(int t=0; t<c->type; t++) if(c->move(t) && c->move(t)->wall == waRose)
|
||||
c->item = itRose;
|
||||
}
|
||||
else {
|
||||
@ -1791,9 +1791,9 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
cellwalker ci(c, i);
|
||||
cellwalker cw0 = ci + wstep + revstep;
|
||||
cellwalker cw1 = ci + bonus + wstep + revstep;
|
||||
if(cw0.c->mpdist > 7)
|
||||
if(cw1.c->mpdist > 7)
|
||||
next.emplace_back(cw0.c, cw1.c);
|
||||
if(cw0.at->mpdist > 7)
|
||||
if(cw1.at->mpdist > 7)
|
||||
next.emplace_back(cw0.at, cw1.at);
|
||||
}
|
||||
if(isize(next)) {
|
||||
c->item = itHunting;
|
||||
@ -2004,7 +2004,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c->wall = hrand(2) ? waMirror : waCloud;
|
||||
else if(ishept(c) && hrand(5000) < 10 * PRIZEMUL)
|
||||
placePrizeOrb(c);
|
||||
else if(hrand(cwt.c->land == laMirror ? 600 : 2400) < 8 + items[itShard] + yendor::hardness()) {
|
||||
else if(hrand(cwt.at->land == laMirror ? 600 : 2400) < 8 + items[itShard] + yendor::hardness()) {
|
||||
if(items[itShard] >= 5 && hrand(120) <= 20)
|
||||
c->monst = moMirrorSpirit;
|
||||
else
|
||||
@ -2035,7 +2035,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
// preset the movement direction
|
||||
// this will make the dog go in the direction of the center,
|
||||
// if the player is unreachable/invisible
|
||||
for(int d=0; d<c->type; d++) if(c->mov[d] == from) {
|
||||
for(int d=0; d<c->type; d++) if(c->move(d) == from) {
|
||||
c->mondir = (d+3) % c->type;
|
||||
}
|
||||
chasmify(c);
|
||||
@ -2357,7 +2357,7 @@ void repairLandgen(cell *c) {
|
||||
|
||||
if(cellHalfvine(c)) {
|
||||
int i = -1;
|
||||
for(int k=0; k<c->type; k++) if(c->mov[k] && c->mov[k]->wall == c->wall)
|
||||
for(int k=0; k<c->type; k++) if(c->move(k) && c->move(k)->wall == c->wall)
|
||||
i = 0;
|
||||
if(i == -1) c->wall = waNone;
|
||||
}
|
||||
@ -2434,7 +2434,7 @@ void setdist(cell *c, int d, cell *from) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(d == BARLEV && !euclid && c != cwt.c)
|
||||
if(d == BARLEV && !euclid && c != cwt.at)
|
||||
buildBigStuff(c, from);
|
||||
|
||||
if(buggyGeneration) return;
|
||||
|
@ -395,7 +395,7 @@ bool inmirror(cell *c) {
|
||||
}
|
||||
|
||||
bool inmirror(const cellwalker& cw) {
|
||||
return inmirror(cw.c->land);
|
||||
return inmirror(cw.at->land);
|
||||
}
|
||||
|
||||
eLand oppositeElement(eLand l, eLand l2) {
|
||||
@ -1009,7 +1009,7 @@ eLand getLandForList(cell *c) {
|
||||
if(l == laMercuryRiver) return laTerracotta;
|
||||
if(l == laBarrier) return laCrossroads;
|
||||
if(l == laOceanWall) return laOcean;
|
||||
if(l == laPalace && princess::dist(cwt.c) < OUT_OF_PRISON)
|
||||
if(l == laPalace && princess::dist(cwt.at) < OUT_OF_PRISON)
|
||||
l = laPrincessQuest;
|
||||
// princess?
|
||||
return l;
|
||||
|
@ -132,15 +132,15 @@ namespace mapstream {
|
||||
save(fgeomextras[current_extra].current_prime_id);
|
||||
}
|
||||
}
|
||||
addToQueue((bounded || euclid) ? currentmap->gamestart() : cwt.c->master->c7);
|
||||
addToQueue((bounded || euclid) ? currentmap->gamestart() : cwt.at->master->c7);
|
||||
for(int i=0; i<isize(cellbyid); i++) {
|
||||
cell *c = cellbyid[i];
|
||||
if(i) {
|
||||
for(int j=0; j<c->type; j++) if(c->mov[j] && cellids.count(c->mov[j]) &&
|
||||
cellids[c->mov[j]] < i) {
|
||||
int32_t i = cellids[c->mov[j]];
|
||||
for(int j=0; j<c->type; j++) if(c->move(j) && cellids.count(c->move(j)) &&
|
||||
cellids[c->move(j)] < i) {
|
||||
int32_t i = cellids[c->move(j)];
|
||||
save(i);
|
||||
saveChar(c->spn(j));
|
||||
saveChar(c->c.spin(j));
|
||||
saveChar(j);
|
||||
break;
|
||||
}
|
||||
@ -157,13 +157,13 @@ namespace mapstream {
|
||||
save(c->wparam); save(c->landparam);
|
||||
saveChar(c->stuntime); saveChar(c->hitpoints);
|
||||
for(int j=0; j<c->type; j++) {
|
||||
cell *c2 = c->mov[j];
|
||||
cell *c2 = c->move(j);
|
||||
if(c2 && c2->land != laNone) addToQueue(c2);
|
||||
}
|
||||
}
|
||||
printf("cells saved = %d\n", isize(cellbyid));
|
||||
int32_t n = -1; save(n);
|
||||
int32_t id = cellids.count(cwt.c) ? cellids[cwt.c] : -1;
|
||||
int32_t id = cellids.count(cwt.at) ? cellids[cwt.at] : -1;
|
||||
save(id);
|
||||
|
||||
for(int i=0; i<USERSHAPEGROUPS; i++) for(int j=0; j<USERSHAPEIDS; j++) {
|
||||
@ -251,7 +251,7 @@ namespace mapstream {
|
||||
// printf("%p:%d,%d -> %p\n", c2, relspin[parent], dir, c);
|
||||
|
||||
// spinval becomes xspinval
|
||||
rspin = (c2->spn(dir) - loadChar() + MODFIXER) % c->type;
|
||||
rspin = (c2->c.spin(dir) - loadChar() + MODFIXER) % c->type;
|
||||
}
|
||||
|
||||
cellbyid.push_back(c);
|
||||
@ -284,8 +284,8 @@ namespace mapstream {
|
||||
|
||||
int32_t whereami = loadInt();
|
||||
if(whereami >= 0 && whereami < isize(cellbyid))
|
||||
cwt.c = cellbyid[whereami];
|
||||
else cwt.c = currentmap->gamestart();
|
||||
cwt.at = cellbyid[whereami];
|
||||
else cwt.at = currentmap->gamestart();
|
||||
|
||||
for(int i=0; i<isize(cellbyid); i++) {
|
||||
cell *c = cellbyid[i];
|
||||
@ -516,14 +516,14 @@ namespace mapeditor {
|
||||
}
|
||||
|
||||
int drawcellShapeGroup() {
|
||||
if(drawcell == cwt.c && drawplayer) return 0;
|
||||
if(drawcell == cwt.at && drawplayer) return 0;
|
||||
if(drawcell->monst) return 1;
|
||||
if(drawcell->item) return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
int drawcellShapeID() {
|
||||
if(drawcell == cwt.c && drawplayer) return vid.cs.charid;
|
||||
if(drawcell == cwt.at && drawplayer) return vid.cs.charid;
|
||||
if(drawcell->monst) return drawcell->monst;
|
||||
if(drawcell->item) return drawcell->item;
|
||||
return patterns::getpatterninfo0(drawcell).id;
|
||||
@ -535,7 +535,7 @@ namespace mapeditor {
|
||||
}
|
||||
|
||||
void editCell(const pair<cellwalker, cellwalker>& where) {
|
||||
cell *c = where.first.c;
|
||||
cell *c = where.first.at;
|
||||
int cdir = where.first.spin;
|
||||
saveUndo(c);
|
||||
switch(painttype) {
|
||||
@ -545,8 +545,8 @@ namespace mapeditor {
|
||||
c->stuntime = 0;
|
||||
c->mondir = cdir;
|
||||
|
||||
if((isWorm(c) || isIvy(c) || isMutantIvy(c)) && c->mov[cdir] &&
|
||||
!isWorm(c->mov[cdir]) && !isIvy(c->mov[cdir]))
|
||||
if((isWorm(c) || isIvy(c) || isMutantIvy(c)) && c->move(cdir) &&
|
||||
!isWorm(c->move(cdir)) && !isIvy(c->move(cdir)))
|
||||
c->mondir = NODIR;
|
||||
|
||||
if(c->monst == moMimic) {
|
||||
@ -603,7 +603,7 @@ namespace mapeditor {
|
||||
c->landparam = paintwhat >> 8;
|
||||
break;
|
||||
case 4:
|
||||
cell *copywhat = where.second.c;
|
||||
cell *copywhat = where.second.at;
|
||||
c->wall = copywhat->wall;
|
||||
c->item = copywhat->item;
|
||||
c->land = copywhat->land;
|
||||
@ -631,13 +631,13 @@ namespace mapeditor {
|
||||
if(crad > radius) break;
|
||||
}
|
||||
auto sd = spill_list[i];
|
||||
for(int i=0; i<sd.first.c->type; i++) {
|
||||
for(int i=0; i<sd.first.at->type; i++) {
|
||||
auto sd2 = sd;
|
||||
sd2.first = sd2.first + i + wstep;
|
||||
if(!cl.add(sd2.first.c)) continue;
|
||||
if(sd2.second.c) {
|
||||
if(!cl.add(sd2.first.at)) continue;
|
||||
if(sd2.second.at) {
|
||||
sd2.second = sd2.second + i + wstep;
|
||||
if(sd2.second.c->land == laNone) continue;
|
||||
if(sd2.second.at->land == laNone) continue;
|
||||
}
|
||||
spill_list.push_back(sd2);
|
||||
}
|
||||
@ -671,12 +671,12 @@ namespace mapeditor {
|
||||
void editAt(cellwalker where, manual_celllister& cl) {
|
||||
|
||||
if(painttype == 4 && radius) {
|
||||
if(where.c->type != copysource.c->type) return;
|
||||
if(where.at->type != copysource.at->type) return;
|
||||
if(where.spin<0) where.spin=0;
|
||||
if(!nonbitrunc && !ctof(mouseover) && ((where.spin&1) != (copysource.spin&1)))
|
||||
where += 1;
|
||||
}
|
||||
if(painttype != 4) copysource.c = NULL;
|
||||
if(painttype != 4) copysource.at = NULL;
|
||||
list_spill(where, copysource, cl);
|
||||
|
||||
for(auto& st: spill_list)
|
||||
@ -691,7 +691,7 @@ namespace mapeditor {
|
||||
return;
|
||||
}
|
||||
|
||||
cl.add(where.c);
|
||||
cl.add(where.at);
|
||||
|
||||
int at = 0;
|
||||
while(at < isize(cl.lst)) {
|
||||
@ -701,7 +701,7 @@ namespace mapeditor {
|
||||
forCellEx(c3, c2) cl.add(c3);
|
||||
}
|
||||
|
||||
auto si = patterns::getpatterninfo0(where.c);
|
||||
auto si = patterns::getpatterninfo0(where.at);
|
||||
int cdir = where.spin;
|
||||
if(cdir >= 0) cdir = cdir - si.dir;
|
||||
|
||||
@ -862,7 +862,7 @@ namespace mapeditor {
|
||||
else if(uni == ' ') {
|
||||
popScreen();
|
||||
pushScreen(showDrawEditor);
|
||||
initdraw(mouseover ? mouseover : cwt.c);
|
||||
initdraw(mouseover ? mouseover : cwt.at);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1541,7 +1541,7 @@ namespace mapeditor {
|
||||
applyToShape(sg, i, uni, mh);
|
||||
|
||||
if(uni == 'e' || (uni == '-' && mousekey == 'e')) {
|
||||
initdraw(mouseover ? mouseover : cwt.c);
|
||||
initdraw(mouseover ? mouseover : cwt.at);
|
||||
}
|
||||
if(uni == 'l') { dslayer++; dslayer %= USERLAYERS; }
|
||||
if(uni == 'L') { dslayer--; if(dslayer < 0) dslayer += USERLAYERS; }
|
||||
@ -1600,7 +1600,7 @@ namespace mapeditor {
|
||||
if(mapeditor::painttype == 4)
|
||||
mapeditor::painttype = 0, mapeditor::paintwhat = 0,
|
||||
mapeditor::paintwhat_str = "clear monster";
|
||||
mapeditor::copysource.c = NULL;
|
||||
mapeditor::copysource.at = NULL;
|
||||
mapeditor::undo.clear();
|
||||
if(!cheater) patterns::displaycodes = false;
|
||||
if(!cheater) patterns::whichShape = 0;
|
||||
@ -1608,7 +1608,7 @@ namespace mapeditor {
|
||||
}) +
|
||||
addHook(hooks_removecells, 0, [] () {
|
||||
modelcell.clear();
|
||||
set_if_removed(mapeditor::copysource.c, NULL);
|
||||
set_if_removed(mapeditor::copysource.at, NULL);
|
||||
});;;
|
||||
#endif
|
||||
|
||||
|
@ -65,7 +65,7 @@ void showOverview() {
|
||||
|
||||
int vf = min((vid.yres-64-vid.fsize*2) / nlm, vid.xres/40);
|
||||
|
||||
eLand curland = getLandForList(cwt.c);
|
||||
eLand curland = getLandForList(cwt.at);
|
||||
|
||||
getcstat = '0';
|
||||
|
||||
@ -103,7 +103,7 @@ void showOverview() {
|
||||
getcstat = 3000+waMirror;
|
||||
if(getcstat == 3000+waMirror)
|
||||
mouseovers = XLAT(
|
||||
olrDescriptions[getOLR(io, cwt.c->land)], cwt.c->land, it, treasureTypeUnlock(curland, io));
|
||||
olrDescriptions[getOLR(io, cwt.at->land)], cwt.at->land, it, treasureTypeUnlock(curland, io));
|
||||
}
|
||||
else if(io) {
|
||||
if(lv >= 25) col = 0xFFD500;
|
||||
@ -376,7 +376,7 @@ void showDisplayMode() {
|
||||
#if CAP_EDIT
|
||||
else if(xuni == 'g') {
|
||||
pushScreen(mapeditor::showDrawEditor);
|
||||
mapeditor::initdraw(cwt.c);
|
||||
mapeditor::initdraw(cwt.at);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -735,7 +735,7 @@ void showStartMenu() {
|
||||
config.tstate = config.tstate_max = tsActive;
|
||||
config.perform_mapping();
|
||||
config.finish_mapping();
|
||||
mapeditor::initdraw(cwt.c);
|
||||
mapeditor::initdraw(cwt.at);
|
||||
pushScreen(showMenu);
|
||||
pushScreen(mapeditor::showDrawEditor);
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ int buildIvy(cell *c, int children, int minleaf) {
|
||||
int leafchild = 0;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
createMov(c, i);
|
||||
if(passable(c->mov[i], c, 0) && c->mov[i]->land == c->land) {
|
||||
if(passable(c->move(i), c, 0) && c->move(i)->land == c->land) {
|
||||
if(children && !child)
|
||||
child = c->mov[i], leafchild = buildIvy(c->mov[i], children-1, 5);
|
||||
child = c->move(i), leafchild = buildIvy(c->move(i), children-1, 5);
|
||||
else
|
||||
c->mov[i]->monst = (leaf++ || peace::on) ? moIvyWait : moIvyHead,
|
||||
c->mov[i]->mondir = c->spn(i);
|
||||
c->move(i)->monst = (leaf++ || peace::on) ? moIvyWait : moIvyHead,
|
||||
c->move(i)->mondir = c->c.spin(i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ void chasmify(cell *c) {
|
||||
c->wall = waChasm; c->item = itNone;
|
||||
int q = 0;
|
||||
cell *c2[10];
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i] && c->mov[i]->mpdist > c->mpdist && cellUnstable(c->mov[i]))
|
||||
c2[q++] = c->mov[i];
|
||||
for(int i=0; i<c->type; i++) if(c->move(i) && c->move(i)->mpdist > c->mpdist && cellUnstable(c->move(i)))
|
||||
c2[q++] = c->move(i);
|
||||
if(q) {
|
||||
cell *c3 = c2[hrand(q)];
|
||||
c3->wall = waChasmD;
|
||||
@ -56,7 +56,7 @@ void chasmifyEarth(cell *c) {
|
||||
int d2[10];
|
||||
for(int i=2; i<=c->type-2; i++) {
|
||||
int j = (i+c->mondir)%c->type;
|
||||
cell *c2 = c->mov[j];
|
||||
cell *c2 = c->move(j);
|
||||
if(c2 && c2->mpdist > c->mpdist && (
|
||||
c2->wall == waDeadfloor || c2->wall == waDeadwall ||
|
||||
c2->wall == waDeadfloor2))
|
||||
@ -65,13 +65,13 @@ void chasmifyEarth(cell *c) {
|
||||
if(!q) printf("no further move!\n");
|
||||
if(q) {
|
||||
int d = d2[hrand(q)];
|
||||
cell *c3 = c->mov[d];
|
||||
cell *c3 = c->move(d);
|
||||
c3->wall = waEarthD;
|
||||
for(int i=0; i<c3->type; i++) {
|
||||
cell *c4 = createMov(c3, i);
|
||||
earthFloor(c4);
|
||||
}
|
||||
c3->mondir = c->spn(d);
|
||||
c3->mondir = c->c.spin(d);
|
||||
}
|
||||
earthWall(c); c->item = itNone;
|
||||
}
|
||||
@ -81,20 +81,20 @@ void chasmifyElemental(cell *c) {
|
||||
int d2[10];
|
||||
for(int i=2; i<=c->type-2; i++) {
|
||||
int j = (i+c->mondir)%c->type;
|
||||
cell *c2 = c->mov[j];
|
||||
cell *c2 = c->move(j);
|
||||
if(c2 && c2->mpdist > c->mpdist && c2->land == c->land)
|
||||
d2[q++] = j;
|
||||
}
|
||||
if(q) {
|
||||
int d = d2[hrand(q)];
|
||||
cell *c3 = c->mov[d];
|
||||
cell *c3 = c->move(d);
|
||||
if(!c3->monst) {
|
||||
c3->wall = waElementalD;
|
||||
for(int i=0; i<c3->type; i++) {
|
||||
cell *c4 = createMov(c3, i);
|
||||
if(c4->wall != waBarrier) c4->wall = waNone;
|
||||
}
|
||||
c3->mondir = c->spn(d);
|
||||
c3->mondir = c->c.spin(d);
|
||||
}
|
||||
}
|
||||
c->wall = getElementalWall(c->land);
|
||||
@ -188,10 +188,10 @@ int reptilemax() {
|
||||
bool wchance(int a, int of, int reduction = 0) {
|
||||
of *= 10;
|
||||
a += yendor::hardness() + 1;
|
||||
if(isCrossroads(cwt.c->land))
|
||||
if(isCrossroads(cwt.at->land))
|
||||
a+= items[itHyperstone] * 10;
|
||||
|
||||
//if(cwt.c->land == laWhirlwind && !nowhirl) a += items[itWindstone] * 3;
|
||||
//if(cwt.at->land == laWhirlwind && !nowhirl) a += items[itWindstone] * 3;
|
||||
|
||||
for(int i=0; i<ittypes; i++) if(itemclass(eItem(i)) == IC_TREASURE)
|
||||
a = max(a, (items[i]-R10) / 10);
|
||||
@ -213,7 +213,7 @@ void wanderingZebra(cell *start) {
|
||||
int q = 0;
|
||||
cell *ctab[8];
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c3 = c->mov[i];
|
||||
cell *c3 = c->move(i);
|
||||
if(c3 && c3 != c2 && c3->land == laZebra && c3->wall == waNone)
|
||||
ctab[q++] = c3;
|
||||
}
|
||||
@ -247,7 +247,7 @@ bool canReachPlayer(cell *cf, eMonster m) {
|
||||
for(int i=0; i<isize(cl.lst) && i < 10000; i++) {
|
||||
cell *c = cl.lst[i];
|
||||
for(int j=0; j<c->type; j++) {
|
||||
cell *c2 = c->mov[j];
|
||||
cell *c2 = c->move(j);
|
||||
if(!c2) continue;
|
||||
if(cl.listed(c2)) continue;
|
||||
if(!passable_for(m, c2, c, P_MONSTER | P_ONPLAYER | P_CHAIN)) continue;
|
||||
@ -306,14 +306,14 @@ void wandering() {
|
||||
pathdata pd(moYeti);
|
||||
int seepcount = getSeepcount();
|
||||
int ghostcount = getGhostcount();
|
||||
if(cwt.c->land == laCA) ghostcount = 0;
|
||||
if(cwt.at->land == laCA) ghostcount = 0;
|
||||
bool genturn = hrand(100) < 30;
|
||||
|
||||
if(bounded && specialland == laClearing)
|
||||
clearing::new_root();
|
||||
|
||||
if(cwt.c->land == laZebra && cwt.c->wall == waNone && wchance(items[itZebra], 20))
|
||||
wanderingZebra(cwt.c);
|
||||
if(cwt.at->land == laZebra && cwt.at->wall == waNone && wchance(items[itZebra], 20))
|
||||
wanderingZebra(cwt.at);
|
||||
|
||||
bool smallbounded_generation = smallbounded || (bounded && specialland == laClearing);
|
||||
|
||||
@ -429,7 +429,7 @@ void wandering() {
|
||||
playSeenSound(c);
|
||||
continue;
|
||||
}
|
||||
if(c->land == laOcean && (items[itCoast] > 50 || (cwt.c->landparam < 25 && c->landparam < 25)) && wchance(items[itCoast], 25) && canReachPlayer(c, moEagle)) {
|
||||
if(c->land == laOcean && (items[itCoast] > 50 || (cwt.at->landparam < 25 && c->landparam < 25)) && wchance(items[itCoast], 25) && canReachPlayer(c, moEagle)) {
|
||||
c->monst = moAlbatross;
|
||||
playSeenSound(c);
|
||||
continue;
|
||||
@ -457,9 +457,9 @@ void wandering() {
|
||||
c2->monst = moKrakenH;
|
||||
playSeenSound(c2);
|
||||
for(int i=0; i<c2->type; i++) {
|
||||
c2->mov[i]->monst = moKrakenT;
|
||||
c2->mov[i]->hitpoints = 1;
|
||||
c2->mov[i]->mondir = c2->spn(i);
|
||||
c2->move(i)->monst = moKrakenT;
|
||||
c2->move(i)->hitpoints = 1;
|
||||
c2->move(i)->mondir = c2->c.spin(i);
|
||||
}
|
||||
goto found;
|
||||
}
|
||||
@ -513,7 +513,7 @@ void wandering() {
|
||||
else if(items[itBull] >= 50 && isize(butterflies) && wchance(items[itBull]-49, 25))
|
||||
c->monst = moGadfly;
|
||||
|
||||
else if(c->land == laPrairie && cwt.c->LHU.fi.flowerdist > 3 && wchance(items[itGreenGrass], prairie::isriver(cwt.c) ? 150 : 40))
|
||||
else if(c->land == laPrairie && cwt.at->LHU.fi.flowerdist > 3 && wchance(items[itGreenGrass], prairie::isriver(cwt.at) ? 150 : 40))
|
||||
c->monst = moGadfly;
|
||||
|
||||
else if(c->land == laHive && wchance(hive::hivehard(), 25))
|
||||
@ -676,7 +676,7 @@ void wandering() {
|
||||
void generateSnake(cell *c, int i, int color) {
|
||||
c->monst = moHexSnake;
|
||||
c->hitpoints = color;
|
||||
int cpair = (1<<pattern_threecolor(c)) | (1<<pattern_threecolor(c->mov[i]));
|
||||
int cpair = (1<<pattern_threecolor(c)) | (1<<pattern_threecolor(c->move(i)));
|
||||
preventbarriers(c);
|
||||
int len = nonbitrunc ? 2 : ROCKSNAKELENGTH;
|
||||
cell *c2 = c;
|
||||
@ -686,17 +686,17 @@ void generateSnake(cell *c, int i, int color) {
|
||||
preventbarriers(c2);
|
||||
c2->mondir = i;
|
||||
createMov(c2, i);
|
||||
int j = c2->spn(i);
|
||||
cell *c3 = c2->mov[i];
|
||||
int j = c2->c.spin(i);
|
||||
cell *c3 = c2->move(i);
|
||||
if(c3->monst || c3->bardir != NODIR || c3->wall) break;
|
||||
c2 = c3;
|
||||
c2->monst = moHexSnakeTail; c2->hitpoints = color;
|
||||
i = (j + (c2->type%4 == 0 ? c2->type/2 : (len%2 ? 2 : c2->type - 2))) % c2->type;
|
||||
createMov(c2, i);
|
||||
if(!inpair(c2->mov[i], cpair)) {
|
||||
if(!inpair(c2->move(i), cpair)) {
|
||||
vector<int> goodsteps;
|
||||
{for(int i=0; i<c2->type; i++)
|
||||
if(inpair(c2->mov[i], cpair))
|
||||
if(inpair(c2->move(i), cpair))
|
||||
goodsteps.push_back(i);}
|
||||
if(!isize(goodsteps)) break;
|
||||
i = goodsteps[hrand(isize(goodsteps))];
|
||||
|
10
netgen.cpp
10
netgen.cpp
@ -116,7 +116,7 @@ namespace hr { namespace netgen {
|
||||
for(int j=0; j<CELLS; j++) {
|
||||
cell *c1 = dcal[i];
|
||||
cell *c2 = dcal[j];
|
||||
for(int k=0; k<c1->type; k++) if(c1->mov[k] == c2)
|
||||
for(int k=0; k<c1->type; k++) if(c1->move(k) == c2)
|
||||
nei[i][k] = j;
|
||||
}
|
||||
}
|
||||
@ -675,8 +675,8 @@ namespace hr { namespace netgen {
|
||||
}
|
||||
if(!created) {
|
||||
View = Id;
|
||||
if(centerover.c) viewctr.h = centerover.c->master;
|
||||
else viewctr.h = cwt.c->master;
|
||||
if(centerover.at) viewctr.at = centerover.at->master;
|
||||
else viewctr.at = cwt.at->master;
|
||||
playermoved = false;
|
||||
dataFromHR();
|
||||
designNet();
|
||||
@ -691,8 +691,8 @@ namespace hr { namespace netgen {
|
||||
}
|
||||
if(uni == 's') {
|
||||
View = Id;
|
||||
if(centerover.c) viewctr.h = centerover.c->master;
|
||||
else viewctr.h = cwt.c->master;
|
||||
if(centerover.at) viewctr.at = centerover.at->master;
|
||||
else viewctr.at = cwt.at->master;
|
||||
playermoved = false;
|
||||
}
|
||||
else if(uni == 'c') {
|
||||
|
@ -378,7 +378,7 @@ bool buildPrizeMirror(cell *c, int freq) {
|
||||
return true;
|
||||
}
|
||||
|
||||
eLand getPrizeLand(cell *c = cwt.c) {
|
||||
eLand getPrizeLand(cell *c = cwt.at) {
|
||||
eLand l = c->land;
|
||||
if(isElemental(l)) l = laElementalWall;
|
||||
if(l == laPalace && princess::dist(c) < OUT_OF_PRISON)
|
||||
|
162
orbs.cpp
162
orbs.cpp
@ -70,7 +70,7 @@ void empathyMove(cell *c, cell *cto, int dir) {
|
||||
bool reduceOrbPower(eItem it, int cap) {
|
||||
if(items[it] && (lastorbused[it] || (it == itOrbShield && items[it]>3) || !markOrb(itOrbTime))) {
|
||||
items[it] -= multi::activePlayers();
|
||||
if(isHaunted(cwt.c->land)) survivalist = false;
|
||||
if(isHaunted(cwt.at->land)) survivalist = false;
|
||||
if(items[it] < 0) items[it] = 0;
|
||||
if(items[it] > cap && timerghost) items[it] = cap;
|
||||
if(items[it] == 0 && it == itOrbLove)
|
||||
@ -93,7 +93,7 @@ void reduceOrbPowers() {
|
||||
for(int i=0; i<ittypes; i++)
|
||||
lastorbused[i] = orbused[i], orbused[i] = false;
|
||||
if(items[itOrbShield]) orbused[itOrbShield] = lastorbused[itOrbShield];
|
||||
reduceOrbPower(itOrbTime, cwt.c->land == laCaribbean ? 777 : 150);
|
||||
reduceOrbPower(itOrbTime, cwt.at->land == laCaribbean ? 777 : 150);
|
||||
if(invismove && !invisfish) markOrb(itOrbInvis);
|
||||
reduceOrbPower(itOrbLightning, 777);
|
||||
reduceOrbPower(itOrbSpeed, 67);
|
||||
@ -147,17 +147,17 @@ void reduceOrbPowers() {
|
||||
reduceOrbPower(itOrbSide1, 120);
|
||||
reduceOrbPower(itOrbSide2, 120);
|
||||
reduceOrbPower(itOrbSide3, 120);
|
||||
if(cwt.c->land != laWildWest)
|
||||
if(cwt.at->land != laWildWest)
|
||||
reduceOrbPower(itRevolver, 6);
|
||||
whirlwind::calcdirs(cwt.c);
|
||||
whirlwind::calcdirs(cwt.at);
|
||||
items[itStrongWind] = !items[itOrbAether] && whirlwind::qdirs == 1;
|
||||
items[itWarning] = 0;
|
||||
}
|
||||
|
||||
void flashAlchemist(cell *c) {
|
||||
if(isAlch(c)) {
|
||||
if(isAlch(cwt.c))
|
||||
c->wall = cwt.c->wall;
|
||||
if(isAlch(cwt.at))
|
||||
c->wall = cwt.at->wall;
|
||||
else
|
||||
c->wall = eWall(c->wall ^ waFloorB ^ waFloorA);
|
||||
}
|
||||
@ -205,8 +205,8 @@ void flashCell(cell *c, eMonster killer, flagtype flags) {
|
||||
if(c->wall == waOpenGate || c->wall == waClosedGate) {
|
||||
eWall w = c->wall;
|
||||
c->wall = waNone;
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i] && c->mov[i]->wall == w)
|
||||
flashCell(c->mov[i], killer, flags);
|
||||
for(int i=0; i<c->type; i++) if(c->move(i) && c->move(i)->wall == w)
|
||||
flashCell(c->move(i), killer, flags);
|
||||
}
|
||||
if(c->wall == waRed1) c->wall = waNone;
|
||||
else if(c->wall == waRed2) c->wall = waRed1;
|
||||
@ -230,7 +230,7 @@ void activateFlashFrom(cell *cf, eMonster who, flagtype flags) {
|
||||
if(c == cf) continue;
|
||||
for(int t=0; t<c->type; t++)
|
||||
for(int u=0; u<cf->type; u++)
|
||||
if(c->mov[t] == cf->mov[u] && c->mov[t] != NULL) {
|
||||
if(c->move(t) == cf->move(u) && c->move(t) != NULL) {
|
||||
flashCell(c, who, flags);
|
||||
goto nexti;
|
||||
}
|
||||
@ -242,7 +242,7 @@ bool distanceBound(cell *c1, cell *c2, int d) {
|
||||
if(!c1 || !c2) return false;
|
||||
if(d == 0) return c1 == c2;
|
||||
for(int i=0; i<c2->type; i++)
|
||||
if(distanceBound(c1, c2->mov[i], d-1)) return true;
|
||||
if(distanceBound(c1, c2->move(i), d-1)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -253,14 +253,14 @@ void checkFreedom(cell *cf) {
|
||||
cell *c = cl.lst[i];
|
||||
if(c->cpdist >= 5) return;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
// todo leader
|
||||
if(cl.listed(c2)) continue;
|
||||
if(!passable(c2, c, P_ISPLAYER | P_MIRROR | P_LEADER)) continue;
|
||||
if(c2->wall == waArrowTrap && c2->wparam == 2) continue;
|
||||
bool monsterhere = false;
|
||||
for(int j=0; j<c2->type; j++) {
|
||||
cell *c3 = c2->mov[j];
|
||||
cell *c3 = c2->move(j);
|
||||
if(c3 && c3->monst && !isFriendly(c3))
|
||||
monsterhere = true;
|
||||
}
|
||||
@ -286,7 +286,7 @@ void activateFlash() {
|
||||
drawFlash(playerpos(i));
|
||||
|
||||
addMessage(XLAT("You activate the Flash spell!"));
|
||||
playSound(cwt.c, "storm");
|
||||
playSound(cwt.at, "storm");
|
||||
drainOrb(itOrbFlash);
|
||||
for(int i=0; i<isize(dcal); i++) {
|
||||
cell *c = dcal[i];
|
||||
@ -307,22 +307,22 @@ bool reflectingBarrierAt(cellwalker& c, int d) {
|
||||
if(d >= 3) return true;
|
||||
if(d <= -3) return true;
|
||||
d = c.spin + d + 42;
|
||||
d%=c.c->type;
|
||||
if(!c.c->mov[d]) return true;
|
||||
d%=c.at->type;
|
||||
if(!c.at->move(d)) return true;
|
||||
|
||||
return reflectingBarrierAt(c.c->mov[d]);
|
||||
return reflectingBarrierAt(c.at->move(d));
|
||||
// WAS:
|
||||
// if(c.c->mov[d]->wall == waBarrier) return true;
|
||||
// if(c.at->move(d)->wall == waBarrier) return true;
|
||||
// THEN:
|
||||
// if(c.c->mov[d]->land == laBarrier || c.c->mov[d]->land == laOceanWall ||
|
||||
// c.c->mov[d]->land == laHauntedWall ||
|
||||
// c.c->mov[d]->land == laElementalWall) ;
|
||||
// if(c.at->move(d)->land == laBarrier || c.at->move(d)->land == laOceanWall ||
|
||||
// c.at->move(d)->land == laHauntedWall ||
|
||||
// c.at->move(d)->land == laElementalWall) ;
|
||||
// return false;
|
||||
}
|
||||
|
||||
void killAdjacentSharks(cell *c) {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2) continue;
|
||||
if(isShark(c2->monst)) {
|
||||
c2->ligon = true;
|
||||
@ -348,14 +348,14 @@ void castLightningBolt(cellwalker lig) {
|
||||
counter--; if(counter < 0) break;
|
||||
// printf("at: %p i=%d d=%d\n", lig.c, i, lig.spin);
|
||||
|
||||
killAdjacentSharks(lig.c);
|
||||
killAdjacentSharks(lig.at);
|
||||
|
||||
if(lig.c->mov[lig.spin] == NULL) break;
|
||||
if(lig.peek() == NULL) break;
|
||||
|
||||
lig += wstep;
|
||||
if(inmirror(lig)) lig = mirror::reflect(lig);
|
||||
|
||||
cell *c = lig.c;
|
||||
cell *c = lig.at;
|
||||
|
||||
eWall ow = c->wall;
|
||||
|
||||
@ -404,15 +404,15 @@ void castLightningBolt(cellwalker lig) {
|
||||
if(c->wall == waCharged && first) {
|
||||
for(int i=0; i<c->type; i++)
|
||||
// do not do strange things in horocyclic spires
|
||||
if(c->mov[i] && c->mov[i]->wall != waCharged) {
|
||||
if(c->move(i) && c->move(i)->wall != waCharged) {
|
||||
cellwalker lig2(c, i);
|
||||
castLightningBolt(lig2);
|
||||
}
|
||||
brk = true;
|
||||
}
|
||||
|
||||
if(c->wall == waBoat && c != cwt.c) c->wall = waSea, spin = true;
|
||||
if(c->wall == waStrandedBoat && c !=cwt.c) c->wall = waNone, spin = true;
|
||||
if(c->wall == waBoat && c != cwt.at) c->wall = waSea, spin = true;
|
||||
if(c->wall == waStrandedBoat && c !=cwt.at) c->wall = waNone, spin = true;
|
||||
|
||||
if((c->wall == waNone || c->wall == waSea) && c->land == laLivefjord)
|
||||
c->wall = eWall(c->wall ^ waSea ^ waNone);
|
||||
@ -430,7 +430,7 @@ void castLightningBolt(cellwalker lig) {
|
||||
if(c->wall == waDock) makeflame(c, 5, false);
|
||||
if(c->wall == waCTree) makeflame(c, 12, false);
|
||||
if(c->wall == waRose) makeflame(c, 60, false);
|
||||
if(cellHalfvine(c) && c->mov[lig.spin] && c->wall == c->mov[lig.spin]->wall) {
|
||||
if(cellHalfvine(c) && c->wall == lig.peek()->wall) {
|
||||
destroyHalfvine(c, waPartialFire, 4);
|
||||
brk = true;
|
||||
}
|
||||
@ -438,8 +438,8 @@ void castLightningBolt(cellwalker lig) {
|
||||
if(c->wall != ow && ow)
|
||||
drawParticles(c, winf[ow].color, 16);
|
||||
|
||||
if(c == cwt.c) {bnc++; if(bnc > 10) break; }
|
||||
if(spin) lig += hrand(lig.c->type);
|
||||
if(c == cwt.at) {bnc++; if(bnc > 10) break; }
|
||||
if(spin) lig += hrand(lig.at->type);
|
||||
|
||||
if(brk) break;
|
||||
|
||||
@ -456,12 +456,12 @@ void castLightningBolt(cellwalker lig) {
|
||||
else
|
||||
lig += rev;
|
||||
|
||||
if(lig.c->wall == waCloud) {
|
||||
lig.c->wall = waNone;
|
||||
if(lig.at->wall == waCloud) {
|
||||
lig.at->wall = waNone;
|
||||
mirror::createMirages(lig, mirror::LIGHTNING);
|
||||
}
|
||||
if(lig.c->wall == waMirror) {
|
||||
lig.c->wall = waNone;
|
||||
if(lig.at->wall == waMirror) {
|
||||
lig.at->wall = waNone;
|
||||
mirror::createMirrors(lig, mirror::LIGHTNING);
|
||||
}
|
||||
}
|
||||
@ -488,7 +488,7 @@ void activateLightning() {
|
||||
elec::afterOrb = false;
|
||||
|
||||
achievement_count("LIGHTNING", tkills(), tk);
|
||||
playSound(cwt.c, "storm");
|
||||
playSound(cwt.at, "storm");
|
||||
}
|
||||
|
||||
// roCheck: return orb type if successful, 0 otherwise
|
||||
@ -525,7 +525,7 @@ int teleportAction() {
|
||||
void teleportTo(cell *dest) {
|
||||
playSound(dest, "other-teleport");
|
||||
if(dest->monst) {
|
||||
cwt.c->monst = dest->monst;
|
||||
cwt.at->monst = dest->monst;
|
||||
dest->monst = moNone;
|
||||
}
|
||||
|
||||
@ -534,8 +534,8 @@ void teleportTo(cell *dest) {
|
||||
if(b) {
|
||||
killFriendlyIvy();
|
||||
drainOrb(itOrbTeleport);
|
||||
movecost(cwt.c, dest, 3);
|
||||
playerMoveEffects(cwt.c, dest);
|
||||
movecost(cwt.at, dest, 3);
|
||||
playerMoveEffects(cwt.at, dest);
|
||||
afterplayermoved();
|
||||
bfs();
|
||||
}
|
||||
@ -545,10 +545,10 @@ void teleportTo(cell *dest) {
|
||||
addMessage(XLAT("You teleport to a new location!"));
|
||||
|
||||
killFriendlyIvy();
|
||||
cell *from = cwt.c;
|
||||
cell *from = cwt.at;
|
||||
movecost(from, dest, 1);
|
||||
playerMoveEffects(cwt.c, dest);
|
||||
cwt.c = dest; cwt.spin = hrand(dest->type); flipplayer = !!(hrand(2));
|
||||
playerMoveEffects(cwt.at, dest);
|
||||
cwt.at = dest; cwt.spin = hrand(dest->type); flipplayer = !!(hrand(2));
|
||||
drainOrb(itOrbTeleport);
|
||||
|
||||
mirror::destroyAll();
|
||||
@ -568,7 +568,7 @@ void teleportTo(cell *dest) {
|
||||
|
||||
void jumpTo(cell *dest, eItem byWhat, int bonuskill, eMonster dashmon) {
|
||||
if(byWhat != itStrongWind) playSound(dest, "orb-frog");
|
||||
cell *from = cwt.c;
|
||||
cell *from = cwt.at;
|
||||
|
||||
if(byWhat == itOrbFrog) {
|
||||
useupOrb(itOrbFrog, 5);
|
||||
@ -589,9 +589,9 @@ void jumpTo(cell *dest, eItem byWhat, int bonuskill, eMonster dashmon) {
|
||||
|
||||
killFriendlyIvy();
|
||||
|
||||
cell *c1 = cwt.c;
|
||||
animateMovement(cwt.c, dest, LAYER_SMALL, NOHINT);
|
||||
cwt.c = dest;
|
||||
cell *c1 = cwt.at;
|
||||
animateMovement(cwt.at, dest, LAYER_SMALL, NOHINT);
|
||||
cwt.at = dest;
|
||||
forCellIdEx(c2, i, dest) if(c2->cpdist < dest->cpdist) {
|
||||
cwt.spin = i;
|
||||
flipplayer = true;
|
||||
@ -601,13 +601,13 @@ void jumpTo(cell *dest, eItem byWhat, int bonuskill, eMonster dashmon) {
|
||||
sword::reset();
|
||||
stabbingAttack(c1, dest, moPlayer, bonuskill);
|
||||
playerMoveEffects(c1, dest);
|
||||
if(cwt.c->item != itOrbYendor && cwt.c->item != itHolyGrail)
|
||||
collectItem(cwt.c, true);
|
||||
if(cwt.at->item != itOrbYendor && cwt.at->item != itHolyGrail)
|
||||
collectItem(cwt.at, true);
|
||||
|
||||
mirror::destroyAll();
|
||||
|
||||
for(int i=9; i>=0; i--)
|
||||
setdist(cwt.c, i, NULL);
|
||||
setdist(cwt.at, i, NULL);
|
||||
|
||||
movecost(from, dest, 2);
|
||||
|
||||
@ -643,10 +643,10 @@ void telekinesis(cell *dest) {
|
||||
|
||||
auto cost = spacedrain(dest);
|
||||
|
||||
if(dest->land == laAlchemist && isAlchAny(dest) && isAlchAny(cwt.c))
|
||||
dest->wall = cwt.c->wall;
|
||||
if(dest->land == laAlchemist && isAlchAny(dest) && isAlchAny(cwt.at))
|
||||
dest->wall = cwt.at->wall;
|
||||
|
||||
if(dest->land == laPower && cwt.c->land != laPower && dest->item != itOrbFire && dest->item != itOrbLife) {
|
||||
if(dest->land == laPower && cwt.at->land != laPower && dest->item != itOrbFire && dest->item != itOrbLife) {
|
||||
if(itemclass(dest->item) != IC_ORB)
|
||||
items[dest->item] ++;
|
||||
else
|
||||
@ -660,8 +660,8 @@ void telekinesis(cell *dest) {
|
||||
addMessage(XLAT("Your power is drained by %the1!", dest->wall));
|
||||
}
|
||||
|
||||
moveItem(dest, cwt.c, true);
|
||||
collectItem(cwt.c, true);
|
||||
moveItem(dest, cwt.at, true);
|
||||
collectItem(cwt.at, true);
|
||||
useupOrb(itOrbSpace, cost.first);
|
||||
if(cost.second)
|
||||
markOrb(itOrbMagnetism);
|
||||
@ -967,8 +967,8 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
return itNone;
|
||||
}
|
||||
|
||||
if(rosedist(cwt.c) == 1) {
|
||||
int r = rosemap[cwt.c];
|
||||
if(rosedist(cwt.at) == 1) {
|
||||
int r = rosemap[cwt.at];
|
||||
int r2 = rosemap[c];
|
||||
if(r2 <= r) {
|
||||
if(a == roKeyboard || a == roMouseForce )
|
||||
@ -984,7 +984,7 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
|
||||
// (-1) distance
|
||||
|
||||
if(c == cwt.c || isNeighbor(cwt.c, c)) {
|
||||
if(c == cwt.at || isNeighbor(cwt.at, c)) {
|
||||
if(!isWeakCheck(a))
|
||||
addMessage(XLAT("You cannot target that close!"));
|
||||
return itNone;
|
||||
@ -996,7 +996,7 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
}
|
||||
|
||||
// (0-) strong wind
|
||||
if(items[itStrongWind] && c->cpdist == 2 && cwt.c == whirlwind::jumpFromWhereTo(c, true) && !monstersnearO(a, c, NULL, moPlayer, NULL, cwt.c)) {
|
||||
if(items[itStrongWind] && c->cpdist == 2 && cwt.at == whirlwind::jumpFromWhereTo(c, true) && !monstersnearO(a, c, NULL, moPlayer, NULL, cwt.at)) {
|
||||
if(!isCheck(a)) jumpTo(c, itStrongWind);
|
||||
return itStrongWind;
|
||||
}
|
||||
@ -1013,7 +1013,7 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
}
|
||||
|
||||
// (0) telekinesis
|
||||
if(c->item && !itemHiddenFromSight(c) && !cwt.c->item && items[itOrbSpace] >= fixpower(spacedrain(c).first) && !cantGetGrimoire(c, !isCheck(a))
|
||||
if(c->item && !itemHiddenFromSight(c) && !cwt.at->item && items[itOrbSpace] >= fixpower(spacedrain(c).first) && !cantGetGrimoire(c, !isCheck(a))
|
||||
&& c->item != itBarrow) {
|
||||
if(!isCheck(a)) telekinesis(c);
|
||||
return itOrbSpace;
|
||||
@ -1023,11 +1023,11 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
bool nowhereToBlow = false;
|
||||
if(items[itOrbAir] && isBlowableMonster(c->monst)) {
|
||||
int d = 0;
|
||||
for(; d<c->type; d++) if(c->mov[d] && c->mov[d]->cpdist < c->cpdist) break;
|
||||
for(; d<c->type; d++) if(c->move(d) && c->move(d)->cpdist < c->cpdist) break;
|
||||
if(d<c->type) for(int e=d; e<d+c->type; e++) {
|
||||
nowhereToBlow = true;
|
||||
int di = e % c->type;
|
||||
cell *c2 = c->mov[di];
|
||||
cell *c2 = c->move(di);
|
||||
if(c2 && c2->cpdist > c->cpdist && passable(c2, c, P_BLOW)) {
|
||||
if(!isCheck(a)) blowoff(c, c2, di);
|
||||
return itOrbAir;
|
||||
@ -1045,12 +1045,12 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
|
||||
if(c->monst) {
|
||||
if(!canAttack(c, c->monst, cf, moFriendlyIvy, 0)) continue;
|
||||
if(monstersnear(cwt.c, c, moPlayer, NULL, cwt.c)) continue;
|
||||
if(monstersnear(cwt.at, c, moPlayer, NULL, cwt.at)) continue;
|
||||
}
|
||||
else {
|
||||
if(!passable(c, cf, P_ISPLAYER | P_MONSTER)) continue;
|
||||
if(strictlyAgainstGravity(c, cf, false, MF_IVY)) continue;
|
||||
if(monstersnear(cwt.c, NULL, moPlayer, c, cwt.c)) continue;
|
||||
if(monstersnear(cwt.at, NULL, moPlayer, c, cwt.at)) continue;
|
||||
}
|
||||
dirs[qsides] = d;
|
||||
sides[qsides++] = cf;
|
||||
@ -1072,8 +1072,8 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
int i = items[itOrbAether];
|
||||
if(i) items[itOrbAether] = i-1;
|
||||
cell *c2 = NULL, *c3 = NULL;
|
||||
for(int i=0; i<cwt.c->type; i++) {
|
||||
cell *cc = cwt.c->mov[i];
|
||||
for(int i=0; i<cwt.at->type; i++) {
|
||||
cell *cc = cwt.at->move(i);
|
||||
if(isNeighbor(cc, c)) c3 = c2, c2 = cc;
|
||||
}
|
||||
jumpthru = c2;
|
||||
@ -1081,10 +1081,10 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
if(jumpstate == 10 && c2) jumpstate = 11;
|
||||
if(jumpstate == 11 && c2->monst) jumpstate = 12;
|
||||
if(jumpstate == 12 && !c3) jumpstate = 13;
|
||||
if(jumpstate == 13 && passable(c2, cwt.c, P_ISPLAYER | P_JUMP1 | P_MONSTER)) jumpstate = 14;
|
||||
if(jumpstate == 13 && passable(c2, cwt.at, P_ISPLAYER | P_JUMP1 | P_MONSTER)) jumpstate = 14;
|
||||
if(jumpstate == 14 && passable(c, c2, P_ISPLAYER | P_JUMP2)) jumpstate = 15;
|
||||
if(jumpstate == 15 && canAttack(cwt.c, moPlayer, c2, c2->monst, 0)) jumpstate = 16;
|
||||
if(jumpstate == 16 && !monstersnearO(a, c, c2, moPlayer, NULL, cwt.c)) jumpstate = 17;
|
||||
if(jumpstate == 15 && canAttack(cwt.at, moPlayer, c2, c2->monst, 0)) jumpstate = 16;
|
||||
if(jumpstate == 16 && !monstersnearO(a, c, c2, moPlayer, NULL, cwt.at)) jumpstate = 17;
|
||||
items[itOrbAether] = i;
|
||||
|
||||
if(jumpstate == 17) {
|
||||
@ -1103,11 +1103,11 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
jumpstate = 1;
|
||||
int i = items[itOrbAether];
|
||||
if(i) items[itOrbAether] = i-1;
|
||||
for(int i=0; i<cwt.c->type; i++) {
|
||||
cell *c2 = cwt.c->mov[i];
|
||||
for(int i=0; i<cwt.at->type; i++) {
|
||||
cell *c2 = cwt.at->move(i);
|
||||
if(isNeighbor(c2, c)) {
|
||||
jumpthru = c2;
|
||||
if(passable(c2, cwt.c, P_ISPLAYER | P_JUMP1)) {
|
||||
if(passable(c2, cwt.at, P_ISPLAYER | P_JUMP1)) {
|
||||
jumpstate = 2;
|
||||
if(passable(c, c2, P_ISPLAYER | P_JUMP2)) {
|
||||
jumpstate = 3;
|
||||
@ -1117,7 +1117,7 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
}
|
||||
}
|
||||
items[itOrbAether] = i;
|
||||
if(jumpstate == 3 && !monstersnearO(a, c, NULL, moPlayer, NULL, cwt.c)) {
|
||||
if(jumpstate == 3 && !monstersnearO(a, c, NULL, moPlayer, NULL, cwt.at)) {
|
||||
jumpstate = 4;
|
||||
if(!isCheck(a)) jumpTo(c, itOrbFrog);
|
||||
return itOrbFrog;
|
||||
@ -1129,11 +1129,11 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
jumpstate = 21;
|
||||
int i = items[itOrbAether];
|
||||
if(i) items[itOrbAether] = i-1;
|
||||
for(int i=0; i<cwt.c->type; i++) {
|
||||
cell *c2 = cwt.c->mov[i];
|
||||
if(isNeighbor(c2, c) && !nonAdjacent(cwt.c, c2) && !nonAdjacent(c2, c)) {
|
||||
for(int i=0; i<cwt.at->type; i++) {
|
||||
cell *c2 = cwt.at->move(i);
|
||||
if(isNeighbor(c2, c) && !nonAdjacent(cwt.at, c2) && !nonAdjacent(c2, c)) {
|
||||
jumpthru = c2;
|
||||
if(passable(c, cwt.c, P_ISPLAYER | P_PHASE)) {
|
||||
if(passable(c, cwt.at, P_ISPLAYER | P_PHASE)) {
|
||||
jumpstate = 22;
|
||||
if(c2->monst || isWall(c2)) {
|
||||
jumpstate = 23;
|
||||
@ -1143,7 +1143,7 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
}
|
||||
}
|
||||
items[itOrbAether] = i;
|
||||
if(jumpstate == 23 && !monstersnearO(a, c, NULL, moPlayer, NULL, cwt.c)) {
|
||||
if(jumpstate == 23 && !monstersnearO(a, c, NULL, moPlayer, NULL, cwt.at)) {
|
||||
jumpstate = 24;
|
||||
if(!isCheck(a)) jumpTo(c, itOrbPhasing);
|
||||
}
|
||||
@ -1152,7 +1152,7 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
}
|
||||
|
||||
// (1) switch with an illusion
|
||||
if(items[itOrbTeleport] && c->monst == moIllusion && !cwt.c->monst && teleportAction() == 1) {
|
||||
if(items[itOrbTeleport] && c->monst == moIllusion && !cwt.at->monst && teleportAction() == 1) {
|
||||
if(!isCheck(a)) teleportTo(c);
|
||||
return itOrbTeleport;
|
||||
}
|
||||
@ -1181,10 +1181,10 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
}
|
||||
|
||||
// (4a) colt
|
||||
if(!shmup::on && items[itRevolver] && c->monst && canAttack(cwt.c, moPlayer, c, c->monst, AF_GUN)) {
|
||||
if(!shmup::on && items[itRevolver] && c->monst && canAttack(cwt.at, moPlayer, c, c->monst, AF_GUN)) {
|
||||
bool inrange = false;
|
||||
for(cell *c1: gun_targets(cwt.c)) if(c1 == c) inrange = true;
|
||||
if(inrange && !monstersnearO(a, cwt.c, c, moPlayer, NULL, cwt.c)) {
|
||||
for(cell *c1: gun_targets(cwt.at)) if(c1 == c) inrange = true;
|
||||
if(inrange && !monstersnearO(a, cwt.at, c, moPlayer, NULL, cwt.at)) {
|
||||
if(!isCheck(a)) gun_attack(c);
|
||||
return itRevolver;
|
||||
}
|
||||
@ -1259,7 +1259,7 @@ eItem targetRangedOrb(cell *c, orbAction a) {
|
||||
else if(items[itOrbSpace] && saved_tortoise_on(c))
|
||||
addMessage(XLAT("No, that would be heartless!"));
|
||||
else if(c->item && items[itOrbSpace] && !itemHiddenFromSight(c)) {
|
||||
if(cwt.c->item)
|
||||
if(cwt.at->item)
|
||||
addMessage(XLAT("Cannot use %the1 here!", itOrbSpace));
|
||||
addMessage(XLAT("Not enough power for telekinesis!"));
|
||||
}
|
||||
|
96
pattern2.cpp
96
pattern2.cpp
@ -38,7 +38,7 @@ bool ishept(cell *c) {
|
||||
bool ishex1(cell *c) {
|
||||
// EUCLIDEAN
|
||||
if(euclid) return eupattern(c) == 1;
|
||||
else if(gp::on) return c->master->c7 != c && !pseudohept(c->mov[0]);
|
||||
else if(gp::on) return c->master->c7 != c && !pseudohept(c->move(0));
|
||||
else return c->type != S6;
|
||||
}
|
||||
|
||||
@ -285,7 +285,7 @@ int zebra40(cell *c) {
|
||||
else if(sphere) return 0;
|
||||
else if(euclid) return eupattern(c);
|
||||
else if(S3 == 4 && S7 == 6) {
|
||||
return 8 + ((c->master->zebraval / 10 + c->spin(0))%2) * 2;
|
||||
return 8 + ((c->master->zebraval / 10 + c->c.spin(0))%2) * 2;
|
||||
}
|
||||
else {
|
||||
int ii[3], z;
|
||||
@ -328,7 +328,7 @@ namespace fieldpattern {
|
||||
|
||||
pair<int, bool> fieldval(cell *c) {
|
||||
if(ctof(c)) return make_pair(c->master->fieldval, false);
|
||||
else return make_pair(btspin(c->master->fieldval, c->spin(0)), true);
|
||||
else return make_pair(btspin(c->master->fieldval, c->c.spin(0)), true);
|
||||
}
|
||||
|
||||
int fieldval_uniq(cell *c) {
|
||||
@ -348,7 +348,7 @@ int fieldval_uniq(cell *c) {
|
||||
else {
|
||||
int z = 0;
|
||||
for(int u=0; u<S6; u+=2)
|
||||
z = max(z, btspin(createMov(c, u)->master->fieldval, c->spin(u)));
|
||||
z = max(z, btspin(createMov(c, u)->master->fieldval, c->c.spin(u)));
|
||||
return -1-z;
|
||||
}
|
||||
}
|
||||
@ -361,7 +361,7 @@ int fieldval_uniq_rand(cell *c, int randval) {
|
||||
else {
|
||||
int z = 0;
|
||||
for(int u=0; u<6; u+=2)
|
||||
z = max(z, btspin(currfp.gmul(createMov(c, u)->master->fieldval, randval), c->spin(u)));
|
||||
z = max(z, btspin(currfp.gmul(createMov(c, u)->master->fieldval, randval), c->c.spin(u)));
|
||||
return -1-z;
|
||||
}
|
||||
}
|
||||
@ -436,14 +436,14 @@ int getHemisphere(cell *c, int which) {
|
||||
|
||||
cellwalker cw(currentmap->gamestart(), 0);
|
||||
int ct = 1;
|
||||
visit(cw.c, ct);
|
||||
visit(cw.at, ct);
|
||||
do {
|
||||
cw = cw + wstep;
|
||||
visit(cw.c, -ct);
|
||||
visit(cw.at, -ct);
|
||||
cw = cw + (2*ct) + wstep + ct;
|
||||
ct = -ct;
|
||||
}
|
||||
while(cw.c != currentmap->gamestart());
|
||||
while(cw.at != currentmap->gamestart());
|
||||
for(int i=0; i<isize(q); i++)
|
||||
forCellCM(c2, q[i])
|
||||
if(pseudohept(q[i]) || pseudohept(c2))
|
||||
@ -461,8 +461,8 @@ int getHemisphere(cell *c, int which) {
|
||||
auto corner = gp::corners * gp::loctoh_ort(li.relative);
|
||||
ld scored =
|
||||
corner[0] * getHemisphere(c->master->c7, which)
|
||||
+ corner[1] * getHemisphere(c->master->move[li.last_dir]->c7, which)
|
||||
+ corner[2] * getHemisphere(c->master->move[fix7(1+li.last_dir)]->c7, which);
|
||||
+ corner[1] * getHemisphere(c->master->move(li.last_dir)->c7, which)
|
||||
+ corner[2] * getHemisphere(c->master->modmove(li.last_dir+1)->c7, which);
|
||||
int score = int(scored + 10.5) - 10;
|
||||
ld error = scored - score;
|
||||
if(score == 0 && error > .001) score++;
|
||||
@ -477,7 +477,7 @@ int getHemisphere(cell *c, int which) {
|
||||
}
|
||||
else {
|
||||
for(int i=0; i<6; i+=2)
|
||||
score += getHemisphere(c->mov[i], which) * (c->mirror(i) ? -1 : 1);
|
||||
score += getHemisphere(c->move(i), which) * (c->c.mirror(i) ? -1 : 1);
|
||||
return score/3;
|
||||
}
|
||||
}
|
||||
@ -491,7 +491,7 @@ namespace patterns {
|
||||
si.id = (d < siblings[d]) ? 0 : 1;
|
||||
if(sub & SPF_ROT) si.id = 0;
|
||||
for(int i=0; i<S7; i++) {
|
||||
int di = c->master->move[i]->fieldval;
|
||||
int di = c->master->move(i)->fieldval;
|
||||
if(di == siblings[d]) si.dir = i;
|
||||
}
|
||||
si.reflect = false;
|
||||
@ -499,21 +499,21 @@ namespace patterns {
|
||||
else {
|
||||
int ids = 0, tids = 0, td = 0;
|
||||
for(int i=0; i<S3; i++) {
|
||||
int d = c->mov[i*2]->master->fieldval;
|
||||
int d = c->move(2*i)->master->fieldval;
|
||||
ids |= (1<<d); tids += d;
|
||||
}
|
||||
for(int i=0; i<S3; i++) {
|
||||
int d = c->mov[i*2]->master->fieldval;
|
||||
int d = c->move(2*i)->master->fieldval;
|
||||
if(ids & (1<<siblings[d])) td += d;
|
||||
}
|
||||
if(td) {
|
||||
si.id = 4;
|
||||
for(int i=0; i<S3; i++) {
|
||||
int d = c->mov[i*2]->master->fieldval;
|
||||
int d = c->move(2*i)->master->fieldval;
|
||||
if(!(ids & (1<<siblings[d]))) si.dir = 2*i;
|
||||
}
|
||||
/* if(!(sub & SPF_ROT)) {
|
||||
int d0 = c->mov[(si.dir+2)%c->type]->master->fieldval;
|
||||
int d0 = c->modmove(si.dir+2)->master->fieldval;
|
||||
if(d0 < siblings[d0]) si.id += 8;
|
||||
} */
|
||||
si.reflect = false;
|
||||
@ -522,8 +522,8 @@ namespace patterns {
|
||||
si.id = 8;
|
||||
si.dir = 0; // whatever
|
||||
patterninfo si2;
|
||||
valSibling(c->mov[0], si2, sub, pat);
|
||||
int di = si2.dir - c->spin(0);
|
||||
valSibling(c->move(0), si2, sub, pat);
|
||||
int di = si2.dir - c->c.spin(0);
|
||||
di %= S7;
|
||||
if(di<0) di += S7;
|
||||
if(pat == PAT_SIBLING) si.reflect = di > S7/2;
|
||||
@ -577,8 +577,8 @@ namespace patterns {
|
||||
printf("\n"); */
|
||||
}
|
||||
else {
|
||||
si.id = ((c->master->emeraldval & 1) ^ ((c->master->emeraldval & 2)>>1) ^ (c->spin(0)&1)) ? 8 : 4;
|
||||
si.dir = ((c->mov[0]->master->emeraldval + c->spin(0)) & 1) ? 2 : 0;
|
||||
si.id = ((c->master->emeraldval & 1) ^ ((c->master->emeraldval & 2)>>1) ^ (c->c.spin(0)&1)) ? 8 : 4;
|
||||
si.dir = ((c->move(0)->master->emeraldval + c->c.spin(0)) & 1) ? 2 : 0;
|
||||
if(createMov(c, si.dir)->master->emeraldval & 4)
|
||||
si.dir += 4;
|
||||
|
||||
@ -638,7 +638,7 @@ namespace patterns {
|
||||
si.id += 16, si.symmetries = 4;
|
||||
}
|
||||
else {
|
||||
int sp = c->spin(0);
|
||||
int sp = c->c.spin(0);
|
||||
if(gp::on) {
|
||||
sp = gp::last_dir(c);
|
||||
sp ^= int(ishex2(c));
|
||||
@ -649,11 +649,11 @@ namespace patterns {
|
||||
if(gp::on) {
|
||||
auto li = gp::get_local_info(c);
|
||||
val38(c->master->c7, si0, 0, PAT_COLORING);
|
||||
val38(c->master->move[li.last_dir]->c7, si1, 0, PAT_COLORING);
|
||||
val38(c->master->move(li.last_dir)->c7, si1, 0, PAT_COLORING);
|
||||
}
|
||||
else {
|
||||
val38(c->mov[0], si0, 0, PAT_COLORING);
|
||||
val38(c->mov[2], si1, 0, PAT_COLORING);
|
||||
val38(c->move(0), si0, 0, PAT_COLORING);
|
||||
val38(c->move(2), si1, 0, PAT_COLORING);
|
||||
}
|
||||
if((si0.id+1) % 3 == (si1.id) % 3)
|
||||
si.id = 8;
|
||||
@ -680,7 +680,7 @@ namespace patterns {
|
||||
cell *c2 = createMov(c, i);
|
||||
int id2 = 4;
|
||||
if(!pseudohept(c2)) {
|
||||
int sp2 = c2->spin(0);
|
||||
int sp2 = c2->c.spin(0);
|
||||
if(gp::on) {
|
||||
sp2 = gp::last_dir(c2);
|
||||
sp2 ^= int(ishex2(c2));
|
||||
@ -741,9 +741,9 @@ namespace patterns {
|
||||
return;
|
||||
}
|
||||
int qhex = 0;
|
||||
for(int v=0; v<c->type; v++) if(c->mov[v] && !isWarped(c->mov[v])) {
|
||||
for(int v=0; v<c->type; v++) if(c->move(v) && !isWarped(c->move(v))) {
|
||||
u += 2;
|
||||
if(!ishept(c->mov[v])) qhex++;
|
||||
if(!ishept(c->move(v))) qhex++;
|
||||
}
|
||||
if(u == 8 && qhex == 2) u = 12;
|
||||
else if(u == 2 && qhex == 1) u = 8;
|
||||
@ -903,7 +903,7 @@ namespace patterns {
|
||||
else if(t4 >= 1 && t4 < 4) tcdir = si.id+12;
|
||||
else if(t4 >= 7 && t4 < 10) tcdir = si.id-24;
|
||||
|
||||
for(int i=0; i<c->type; i++) if(c->mov[i] && zebra40(c->mov[i]) == tcdir)
|
||||
for(int i=0; i<c->type; i++) if(c->move(i) && zebra40(c->move(i)) == tcdir)
|
||||
si.dir = i;
|
||||
|
||||
applySym0123(si.id, sub);
|
||||
@ -929,7 +929,7 @@ namespace patterns {
|
||||
if(!euclid) {
|
||||
int tcdir = 0, tbest = (si.id&3);
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2) {
|
||||
int t2 = emeraldval(c2);
|
||||
if((si.id&3) == (t2&3) && t2 > tbest)
|
||||
@ -1134,11 +1134,11 @@ int pattern_threecolor(cell *c) {
|
||||
if(ctof(c))
|
||||
return 0;
|
||||
else for(int i=0; i<3; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2->master->fiftyval == 0)
|
||||
return 1 + (c->spin(i)&1);
|
||||
return 1 + (c->c.spin(i)&1);
|
||||
if(c2->master->fiftyval == 5)
|
||||
return 2 - (c->spin(i)&1);
|
||||
return 2 - (c->c.spin(i)&1);
|
||||
}
|
||||
}
|
||||
if(stdhyperbolic && nonbitrunc) {
|
||||
@ -1927,7 +1927,7 @@ namespace linepatterns {
|
||||
|
||||
case patNormal: {
|
||||
for(int t=0; t<c->type; t++)
|
||||
if(c->mov[t] && c->mov[t] < c)
|
||||
if(c->move(t) && c->move(t) < c)
|
||||
queueline(V * get_corner_position(c, t),
|
||||
V * get_corner_position(c, (t+1)%c->type),
|
||||
col, 1 + vid.linequality);
|
||||
@ -1949,7 +1949,7 @@ namespace linepatterns {
|
||||
|
||||
case patTriRings:
|
||||
forCellIdEx(c2, i, c) {
|
||||
if(S3 == 4) c2 = (cellwalker(c, i) + wstep + 1 + wstep).c;
|
||||
if(S3 == 4) c2 = (cellwalker(c, i) + wstep + 1).cpeek();
|
||||
if(c2 > c) if(gmatrix.count(c2) && celldist(c) == celldist(c2))
|
||||
queuelinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
}
|
||||
@ -1987,7 +1987,7 @@ namespace linepatterns {
|
||||
|
||||
case patBigTriangles: {
|
||||
if(is_master(c) && !euclid) for(int i=0; i<S7; i++)
|
||||
if(c->master->move[i] && c->master->move[i] < c->master) {
|
||||
if(c->master->move(i) && c->master->move(i) < c->master) {
|
||||
queuelinef(tC0(V), V*xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
@ -1995,7 +1995,7 @@ namespace linepatterns {
|
||||
|
||||
case patBigRings: {
|
||||
if(is_master(c) && !euclid) for(int i=0; i<S7; i++)
|
||||
if(c->master->move[i] && c->master->move[i] < c->master && c->master->move[i]->dm4 == c->master->dm4)
|
||||
if(c->master->move(i) && c->master->move(i) < c->master && c->master->move(i)->dm4 == c->master->dm4)
|
||||
queuelinef(tC0(V), V*xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), tessf), col, 2 + vid.linequality);
|
||||
// V*xspinpush0((nonbitrunc?M_PI:0) -2*M_PI*i/S7
|
||||
break;
|
||||
@ -2003,7 +2003,7 @@ namespace linepatterns {
|
||||
|
||||
case patTree:
|
||||
if(is_master(c)) {
|
||||
cell *c2 = c->master->move[binarytiling ? 5 : 0]->c7;
|
||||
cell *c2 = c->master->move(binarytiling ? 5 : 0)->c7;
|
||||
if(gmatrix.count(c2)) queuelinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
}
|
||||
break;
|
||||
@ -2021,8 +2021,8 @@ namespace linepatterns {
|
||||
case patAltTree:
|
||||
if(is_master(c) && !euclid && c->master->alt) {
|
||||
for(int i=0; i<S7; i++)
|
||||
if(c->master->move[i] && c->master->move[i]->alt == c->master->alt->move[0]) {
|
||||
cell *c2 = c->master->move[i]->c7;
|
||||
if(c->master->move(i) && c->master->move(i)->alt == c->master->alt->move(0)) {
|
||||
cell *c2 = c->master->move(i)->c7;
|
||||
if(gmatrix.count(c2)) queuelinef(tC0(V), gmatrix[c2]*C0, col, 2 + vid.linequality);
|
||||
}
|
||||
}
|
||||
@ -2030,8 +2030,8 @@ namespace linepatterns {
|
||||
|
||||
case patVine: {
|
||||
if(gp::on) {
|
||||
if(c->master->c7 != c) if(gmatrix.count(c->mov[0]))
|
||||
queuelinef(tC0(V), gmatrix[c->mov[0]]*C0,
|
||||
if(c->master->c7 != c) if(gmatrix.count(c->move(0)))
|
||||
queuelinef(tC0(V), gmatrix[c->move(0)]*C0,
|
||||
darkena(backcolor ^ 0xFFFFFF, 0, col),
|
||||
2 + vid.linequality);
|
||||
}
|
||||
@ -2045,7 +2045,7 @@ namespace linepatterns {
|
||||
int p = emeraldval(c);
|
||||
double hdist = hdist0(heptmove[0] * heptmove[2] * C0);
|
||||
if(pseudohept(c) && (p/4 == 10 || p/4 == 8))
|
||||
for(int i=0; i<S7; i++) if(c->mov[i] && emeraldval(c->mov[i]) == p-4) {
|
||||
for(int i=0; i<S7; i++) if(c->move(i) && emeraldval(c->move(i)) == p-4) {
|
||||
queuelinef(tC0(V), V*tC0(heptmove[i]), col, 2 + vid.linequality);
|
||||
queuelinef(tC0(V), V*tC0(spin(-i * ALPHA) * xpush(-hdist/2)), col, 2 + vid.linequality);
|
||||
}
|
||||
@ -2055,22 +2055,22 @@ namespace linepatterns {
|
||||
|
||||
case patPower: {
|
||||
if(gp::on) {
|
||||
for(int i=0; i<S7; i++) if(c->mov[i] && c->mov[i]->master != c->master && gmatrix.count(c->mov[i]))
|
||||
queuelinef(tC0(V), gmatrix[c->mov[i]]*C0,
|
||||
for(int i=0; i<S7; i++) if(c->move(i) && c->move(i)->master != c->master && gmatrix.count(c->move(i)))
|
||||
queuelinef(tC0(V), gmatrix[c->move(i)]*C0,
|
||||
col,
|
||||
1 + vid.linequality);
|
||||
}
|
||||
else if(syntetic) {
|
||||
if(!pseudohept(c)) for(int i=0; i<c->type; i++) if(c->mov[i] && c < c->mov[i] && !pseudohept(c->mov[i]) && gmatrix.count(c->mov[i]))
|
||||
queuelinef(tC0(V), gmatrix[c->mov[i]]*C0,
|
||||
if(!pseudohept(c)) for(int i=0; i<c->type; i++) if(c->move(i) && c < c->move(i) && !pseudohept(c->move(i)) && gmatrix.count(c->move(i)))
|
||||
queuelinef(tC0(V), gmatrix[c->move(i)]*C0,
|
||||
col,
|
||||
1 + vid.linequality);
|
||||
}
|
||||
else {
|
||||
int a = emeraldval(c);
|
||||
if(pseudohept(c) && a/4 == 8) for(int i=0; i<7; i++) {
|
||||
heptagon *h1 = c->master->move[(i+1)%7];
|
||||
heptagon *h2 = c->master->move[(i+6)%7];
|
||||
heptagon *h1 = c->master->modmove(i+1);
|
||||
heptagon *h2 = c->master->modmove(i-1);
|
||||
if(!h1 || !h2) continue;
|
||||
if(emeraldval(h1->c7)/4 == 8 && emeraldval(h2->c7)/4 == 8)
|
||||
queuelinef(V * ddspin(c,i,84*5/14) * xpush0(tessf/2),
|
||||
|
102
patterngen.cpp
102
patterngen.cpp
@ -134,8 +134,8 @@ void patternFiftyAt(cell *c) {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cellwalker cw(c, i);
|
||||
cellwalker cw1 = cw + wstep + 4 + wstep;
|
||||
(cw1+3+wstep).c->wall = waFloorA;
|
||||
(cw1+4+wstep).c->wall = waFloorA;
|
||||
(cw1+3+wstep).at->wall = waFloorA;
|
||||
(cw1+4+wstep).at->wall = waFloorA;
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,13 +182,13 @@ void patternFiftyAt(cell *c) {
|
||||
|
||||
for(int i=0; i<c->type; i++) {
|
||||
auto cw = cellwalker(c, sw) + (sgn1 * i) + wstep + (sgn * 4) + wstep;
|
||||
if(cw.spin < 0 || cw.spin >= 7 || cw.c->type != 7) exit(1);
|
||||
if(cw.spin < 0 || cw.spin >= 7 || cw.at->type != 7) exit(1);
|
||||
encode(cw.c, s, 1+i, cw.spin);
|
||||
}
|
||||
|
||||
for(int i=0; i<c->type; i++) {
|
||||
auto cw = cellwalker(c, sw) + (sgn1 * i) + wstep + 3 + wstep + 3 + wstep;
|
||||
if(cw.spin < 0 || cw.spin >= 7 || cw.c->type != 7) exit(1);
|
||||
if(cw.spin < 0 || cw.spin >= 7 || cw.at->type != 7) exit(1);
|
||||
encode(cw.c, s, 8+i, cw.spin);
|
||||
}
|
||||
|
||||
@ -198,31 +198,31 @@ void patternFiftyAt(cell *c) {
|
||||
cellwalker cw(c, s.wc2);
|
||||
cw += (sgn1 * i);
|
||||
cw += wstep;
|
||||
if(style == 0) cw.c->wall = waCamelot;
|
||||
// cw.c->item = itSilver;
|
||||
if(style == 0) cw.at->wall = waCamelot;
|
||||
// cw.at->item = itSilver;
|
||||
cw += (sgn*4); //6
|
||||
cw += wstep; if(style == 0) cw.c->wall = waFloorA;
|
||||
cw += wstep; if(style == 0) cw.at->wall = waFloorA;
|
||||
|
||||
// cw.c->item = itSilver;
|
||||
// cw.at->item = itSilver;
|
||||
cw += (sgn*4); //7
|
||||
cw += wstep; if(style == 0) cw.c->wall = waFloorA;
|
||||
// cw.c->item = itSilver;
|
||||
cw += wstep; if(style == 0) cw.at->wall = waFloorA;
|
||||
// cw.at->item = itSilver;
|
||||
cw += (3); //6
|
||||
cw += wstep; if(style == 0) cw.c->wall = waFloorA;
|
||||
// cw.c->item = itSilver;
|
||||
cw += wstep; if(style == 0) cw.at->wall = waFloorA;
|
||||
// cw.at->item = itSilver;
|
||||
cw += (3); //6
|
||||
cw += wstep; if(style == 0) cw.c->wall = waFloorA;
|
||||
// cw.c->item = itSilver;
|
||||
cw += wstep; if(style == 0) cw.at->wall = waFloorA;
|
||||
// cw.at->item = itSilver;
|
||||
cw += (sgn*3); //7
|
||||
cw += wstep; if(style == 0) cw.c->wall = waCamelot;
|
||||
// cw.c->item = itSilver;
|
||||
cw += wstep; if(style == 0) cw.at->wall = waCamelot;
|
||||
// cw.at->item = itSilver;
|
||||
cw += (sgn*2); //6
|
||||
cw += wstep; // cw.c->item = itGold;
|
||||
cw += wstep; // cw.at->item = itGold;
|
||||
// setdist(cw.c, 8, NULL);
|
||||
state50 s2 = s; s2.polarity1 = !s.polarity1;
|
||||
s2.wc2 = (cw.spin + sgn1 * i + sgn + 42) % 7;
|
||||
progress(cw.c, s2);
|
||||
// printf("heat set %f\n", cw.c->heat);
|
||||
// printf("heat set %f\n", cw.at->heat);
|
||||
}
|
||||
|
||||
int newcol = s.color2;
|
||||
@ -232,25 +232,25 @@ void patternFiftyAt(cell *c) {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cellwalker cw(c, s.wc2);
|
||||
cw += (sgn1 * i);
|
||||
cw += wstep; // cw.c->item = itSilver;
|
||||
// cw.c->item = itDiamond;
|
||||
cw += wstep; // cw.at->item = itSilver;
|
||||
// cw.at->item = itDiamond;
|
||||
cw += (3); // 6
|
||||
cw += wstep; // cw.c->item = itSilver;
|
||||
// cw.c->item = itDiamond;
|
||||
cw += wstep; // cw.at->item = itSilver;
|
||||
// cw.at->item = itDiamond;
|
||||
cw += (sgn*4); // 6
|
||||
cw += wstep; // cw.c->item = itSilver;
|
||||
// cw.c->item = itDiamond;
|
||||
cw += wstep; // cw.at->item = itSilver;
|
||||
// cw.at->item = itDiamond;
|
||||
cw += (sgn*2); // 6
|
||||
cw += wstep; // cw.c->item = itSilver;
|
||||
// cw.c->item = itDiamond;
|
||||
cw += wstep; // cw.at->item = itSilver;
|
||||
// cw.at->item = itDiamond;
|
||||
cw += (3); // 6
|
||||
cw += wstep; // cw.c->item = itSilver;
|
||||
// cw.c->item = itDiamond;
|
||||
cw += wstep; // cw.at->item = itSilver;
|
||||
// cw.at->item = itDiamond;
|
||||
cw += (sgn*3); // 7
|
||||
cw += wstep; // cw.c->item = itSilver;
|
||||
// cw.c->item = itDiamond;
|
||||
cw += wstep; // cw.at->item = itSilver;
|
||||
// cw.at->item = itDiamond;
|
||||
cw += (sgn*4); // 6
|
||||
cw += wstep; // cw.c->item = itSilver;
|
||||
cw += wstep; // cw.at->item = itSilver;
|
||||
// setdist(cw.c, 8, NULL);
|
||||
state50 s2 = s;
|
||||
s2.polarity2 = !s.polarity2;
|
||||
@ -260,7 +260,7 @@ void patternFiftyAt(cell *c) {
|
||||
s2.wc2 = cw.spin;
|
||||
progress(cw.c, s2);
|
||||
while(true) { newcol++; newcol &= 7; if(newcol != s2.color && newcol != s.color) break; }
|
||||
// printf("heat set %f\n", cw.c->heat);
|
||||
// printf("heat set %f\n", cw.at->heat);
|
||||
}
|
||||
|
||||
}
|
||||
@ -309,7 +309,7 @@ void setzebra(cellwalker cwb, int it, int type, string pathcode, int xmods) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cwb.c->tmp = cwb.spin + 16 * type;
|
||||
cwb.at->tmp = cwb.spin + 16 * type;
|
||||
}
|
||||
|
||||
void zebra(cellwalker cwb, int it, int type, string pathcode, int xmods) {
|
||||
@ -325,21 +325,21 @@ void zebra(cellwalker cwb, int it, int type, string pathcode, int xmods) {
|
||||
// printf("%p+%d = 0%s\n", cwb.c, cwb.spin, pathcode.c_str());
|
||||
bool redraw = false;
|
||||
// int qval = Q + 99;
|
||||
// redraw = cwb.c->heat == qval;
|
||||
// cwb.c->heat = qval;
|
||||
// redraw = cwb.at->heat == qval;
|
||||
// cwb.at->heat = qval;
|
||||
eWall w = colorwalls[type];
|
||||
cwb.c->wall = w;
|
||||
cwb.at->wall = w;
|
||||
for(int i=0; i<6; i+=2) {
|
||||
cellwalker cw = cwb;
|
||||
cw += (i);
|
||||
cw.c->heat = 4 + type + 4 * 9;
|
||||
cw += wstep; cw += (3); cw.c->wall = w;
|
||||
cw.at->heat = 4 + type + 4 * 9;
|
||||
cw += wstep; cw += (3); cw.at->wall = w;
|
||||
int i0 = i; if(type&2 && i0) i0 = 6-i0; i0 /= 2;
|
||||
cw.c->heat = 4 + type + 4 * (3+i0);
|
||||
cw += wstep; cw += (3); cw.c->wall = w;
|
||||
cw.c->heat = 4 + type + 4 * i0;
|
||||
cw += wstep; cw += (3); cw.c->wall = w;
|
||||
cw.c->heat = 4 + type + 4 * (6+i0);
|
||||
cw.at->heat = 4 + type + 4 * (3+i0);
|
||||
cw += wstep; cw += (3); cw.at->wall = w;
|
||||
cw.at->heat = 4 + type + 4 * i0;
|
||||
cw += wstep; cw += (3); cw.at->wall = w;
|
||||
cw.at->heat = 4 + type + 4 * (6+i0);
|
||||
cw += wstep; cw += (-3);
|
||||
cw += wstep; cw += (-3);
|
||||
cw += wstep; cw += (-3);
|
||||
@ -354,14 +354,14 @@ void zebra(cellwalker cwb, int it, int type, string pathcode, int xmods) {
|
||||
cw += wstep; cw += (3);
|
||||
cw += wstep; cw += (5);
|
||||
if(xmods < 2) {
|
||||
if(cw.c->item && cw.c->item != (1+i) && redraw && i==0) {
|
||||
if(cw.at->item && cw.at->item != (1+i) && redraw && i==0) {
|
||||
qconflict++;
|
||||
// allconflict += pathcode; allconflict += "-";
|
||||
// cwb.c->item = itPalace;
|
||||
// printf("Conflict at %p\n", cwb.c);
|
||||
// cwb.at->item = itPalace;
|
||||
// printf("Conflict at %p\n", cwb.at);
|
||||
}
|
||||
// cw.c->item = eItem(1 + i);
|
||||
// cw.c->heat = 4 + type + 4 * (i/2);
|
||||
// cw.at->item = eItem(1 + i);
|
||||
// cw.at->heat = 4 + type + 4 * (i/2);
|
||||
}
|
||||
cw += wstep; cw += (1);
|
||||
if(type < 2) {
|
||||
@ -397,7 +397,7 @@ void zebraPattern() {
|
||||
cellwalker cw(cwt);
|
||||
cw += wstep; cw += (1);
|
||||
setzebra(cw, 7, 0, "", -999);
|
||||
// cw.c->
|
||||
// cw.at->
|
||||
// printf("Conflicts: %d\n", qconflict);
|
||||
}
|
||||
|
||||
@ -434,8 +434,8 @@ void buildAutomatonRule(cell *c) {
|
||||
buildAutomatonRule(c->master);
|
||||
else {
|
||||
int ii[3];
|
||||
for(int i=0; i<6; i+=2) if(!c->mov[i] || !c->mov[i]->heat || c->mov[i]->type != 7) return;
|
||||
for(int i=0; i<6; i+=2) ii[i/2] = int(c->mov[i]->heat);
|
||||
for(int i=0; i<6; i+=2) if(!c->move(i) || !c->move(i)->heat || c->move(i)->type != 7) return;
|
||||
for(int i=0; i<6; i+=2) ii[i/2] = int(c->move(i)->heat);
|
||||
int z;
|
||||
for(int r=0; r<2; r++)
|
||||
if(ii[1] < ii[0] || ii[2] < ii[0])
|
||||
|
6
quit.cpp
6
quit.cpp
@ -216,7 +216,7 @@ hint hints[] = {
|
||||
|
||||
{
|
||||
0,
|
||||
[]() { return !canmove && geometry == gNormal && celldist(cwt.c) >= 50; },
|
||||
[]() { return !canmove && geometry == gNormal && celldist(cwt.at) >= 50; },
|
||||
[]() {
|
||||
dialog::addHelp(XLAT(
|
||||
"Did you know that the path you take during the game "
|
||||
@ -244,9 +244,9 @@ hint hints[] = {
|
||||
|
||||
{
|
||||
0,
|
||||
[]() { return !canmove && sizes_known() && celldist(cwt.c) >= 50; },
|
||||
[]() { return !canmove && sizes_known() && celldist(cwt.at) >= 50; },
|
||||
[]() {
|
||||
int c = celldist(cwt.c);
|
||||
int c = celldist(cwt.at);
|
||||
string s = circlesizestr(c);
|
||||
dialog::addHelp(XLAT(
|
||||
"You are %1 cells away from the starting point, or "
|
||||
|
@ -31,18 +31,18 @@ set<cell*> testlist;
|
||||
map<cell*, cell*> parent;
|
||||
|
||||
bool test_uniq(cellwalker cw, int z, int lev, cell *par) {
|
||||
if(testlist.count(cw.c)) return false;
|
||||
testlist.insert(cw.c);
|
||||
if(par) parent[cw.c] = par;
|
||||
if(celldist(cw.c) > 9) return true;
|
||||
if(testlist.count(cw.at)) return false;
|
||||
testlist.insert(cw.at);
|
||||
if(par) parent[cw.at] = par;
|
||||
if(celldist(cw.at) > 9) return true;
|
||||
|
||||
/* if(cw.c->wall == waSea) {
|
||||
/* if(cw.at->wall == waSea) {
|
||||
printf("test_uniq failed\n");
|
||||
cw.c->wall = waEternalFire;
|
||||
cw.at->wall = waEternalFire;
|
||||
}
|
||||
cw.c->wall = waSea; */
|
||||
cw.at->wall = waSea; */
|
||||
if(lev) for(int y=0; y<4; y++) if(y != z)
|
||||
if(!test_uniq(trace(cw, gens[y]), y^2, lev-1, cw.c))
|
||||
if(!test_uniq(trace(cw, gens[y]), y^2, lev-1, cw.at))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -51,12 +51,8 @@ bool test_uniq(cellwalker cw, int z, int lev, cell *par) {
|
||||
template<class T> void recursively(cell *c, cell *c1, const T& t) {
|
||||
t(c);
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i] && c->spin(i) == 0 && c->mov[i] != c1)
|
||||
recursively(c->mov[i], c, t);
|
||||
}
|
||||
|
||||
bool operator != (cellwalker c1, cellwalker c2) {
|
||||
return c1.c != c2.c || c1.spin != c2.spin;
|
||||
if(c->move(i) && c->c.spin(i) == 0 && c->move(i) != c1)
|
||||
recursively(c->move(i), c, t);
|
||||
}
|
||||
|
||||
vector<cell*> allcells;
|
||||
@ -91,7 +87,7 @@ void debugpath(vector<int>& way, cwpath& pinv) {
|
||||
|
||||
printf("way:"); for(int i: way) {
|
||||
cellwalker cw2 = trace(cw, pinv);
|
||||
printf(" [%d]", lastd = celldist(cw2.c));
|
||||
printf(" [%d]", lastd = celldist(cw2.at));
|
||||
printf(" %d", i);
|
||||
last_cw = cw;
|
||||
cw = trace(cw, gens[i]);
|
||||
@ -99,7 +95,7 @@ void debugpath(vector<int>& way, cwpath& pinv) {
|
||||
|
||||
cellwalker cw2 = trace(cw, pinv);
|
||||
int curd;
|
||||
printf(" [%d]", curd = celldist(cw2.c));
|
||||
printf(" [%d]", curd = celldist(cw2.at));
|
||||
printf("\n");
|
||||
|
||||
if(lastd == 10 && curd == 2) {
|
||||
@ -120,7 +116,7 @@ void recursive_paint(cwpath& pinv, vector<int>& way, int noway) {
|
||||
cellwalker cw = cwt;
|
||||
for(int i: way) cw = trace(cw, gens[i]);
|
||||
cw = trace(cw, pinv);
|
||||
cell *c = cw.c;
|
||||
cell *c = cw.at;
|
||||
|
||||
/* if(cidd == 1 && way == vector<int>{1,2,3})
|
||||
c->item = itPirate; */
|
||||
@ -177,7 +173,7 @@ cwpath path_to(cell *c, int dir = 0) {
|
||||
cwpath p;
|
||||
cellwalker cw(c, dir);
|
||||
while(cw != cwt) {
|
||||
if(celldist((cw+wstep).c) < celldist(cw.c))
|
||||
if(celldist((cw+wstep).at) < celldist(cw.at))
|
||||
p.push_back(0), cw += wstep;
|
||||
else {
|
||||
if(p.size() && p.back()) p.back()++;
|
||||
@ -211,7 +207,7 @@ int notry = 0;
|
||||
void bantar() {
|
||||
if(!on) return;
|
||||
cwt = cellwalker(currentmap->gamestart(), 0);
|
||||
viewctr = heptspin(cwt.c->master, 0);
|
||||
viewctr = heptspin(cwt.at->master, 0);
|
||||
infos.clear();
|
||||
|
||||
vector<bantar_config> genchoices;
|
||||
@ -219,7 +215,7 @@ void bantar() {
|
||||
int lnotry = notry;
|
||||
|
||||
{
|
||||
celllister clgen(cwt.c, 4, 1000000, NULL);
|
||||
celllister clgen(cwt.at, 4, 1000000, NULL);
|
||||
for(cell *c1: clgen.lst) if(c1->type == S7)
|
||||
for(cell *c2: clgen.lst) if(c2->type == S7)
|
||||
genchoices.emplace_back(c1, c2);
|
||||
@ -263,8 +259,8 @@ void bantar() {
|
||||
|
||||
for(int i=0; i<4; i++) bttargets[i] = trace(cwt, gens[i]);
|
||||
|
||||
celllister cl(cwt.c, 8+more, 1000000, NULL);
|
||||
// recursively(cwt.c, NULL, [] (cell *c) { allcells.push_back(c); } );
|
||||
celllister cl(cwt.at, 8+more, 1000000, NULL);
|
||||
// recursively(cwt.at, NULL, [] (cell *c) { allcells.push_back(c); } );
|
||||
for(cell* c: cl.lst) bantar_note(c);
|
||||
|
||||
for(cell *c: cl.lst) if(infos.count(c) && infos[c].gid == 0)
|
||||
@ -285,7 +281,7 @@ int curpart;
|
||||
} */
|
||||
|
||||
heptspin cth(cellwalker cw) {
|
||||
return heptspin(cw.c->master, cw.spin, cw.mirrored);
|
||||
return heptspin(cw.at->master, cw.spin, cw.mirrored);
|
||||
}
|
||||
|
||||
ld alphaof(hyperpoint h) {
|
||||
@ -334,7 +330,7 @@ void bantar_frame() {
|
||||
|
||||
View = Id;
|
||||
|
||||
transmatrix tView = actualV(cth(xcw), Id) * calc_relative_matrix(cwt.c, xcw.c, NOHINT) * inverse(actualV(cth(cwt), Id));
|
||||
transmatrix tView = actualV(cth(xcw), Id) * calc_relative_matrix(cwt.at, xcw.at, NOHINT) * inverse(actualV(cth(cwt), Id));
|
||||
|
||||
if(tphase < 2) part = 0;
|
||||
else if(tphase == 2)
|
||||
@ -369,7 +365,7 @@ void bantar_frame() {
|
||||
cci.second.c->monst = moNone,
|
||||
cci.second.c->land = laNone;
|
||||
|
||||
mapeditor::drawplayer = cwt.c->wparam == i;
|
||||
mapeditor::drawplayer = cwt.at->wparam == i;
|
||||
|
||||
switch(tphase) {
|
||||
case 0:
|
||||
@ -459,8 +455,8 @@ bool bantar_stats() {
|
||||
|
||||
double x = hexvdist;
|
||||
for(auto gm: gmatrix) for(cell *c: {gm.first})
|
||||
if(euclid || !pseudohept(c)) for(int t=0; t<c->type; t++) if(infos.count(c) && infos.count(c->mov[t]) && c->mov[t] && infos[c].gid != infos[c->mov[t]].gid)
|
||||
if(euclid ? c->mov[t]<c : (((t^1)&1) || c->mov[t] < c))
|
||||
if(euclid || !pseudohept(c)) for(int t=0; t<c->type; t++) if(infos.count(c) && infos.count(c->move(t)) && c->move(t) && infos[c].gid != infos[c->move(t)].gid)
|
||||
if(euclid ? c->move(t)<c : (((t^1)&1) || c->move(t) < c))
|
||||
queueline(gm.second * ddspin(c,t,-S7) * xpush(x) * C0,
|
||||
gm.second * ddspin(c,t,+S7) * xpush(x) * C0,
|
||||
0xFF0000FF, 1);
|
||||
|
@ -286,7 +286,7 @@ void analyze() {
|
||||
int gaussian = 0;
|
||||
|
||||
double mydistance(cell *c1, cell *c2) {
|
||||
if(gaussian == 2) return hdist(tC0(ggmatrix(c1)), tC0(shmup::ggmatrix(c2)));
|
||||
if(gaussian == 2) return hdist(tC0(ggmatrix(c1)), tC0(ggmatrix(c2)));
|
||||
else return celldistance(c1, c2);
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ struct cellcrawler {
|
||||
vector<cellcrawlerdata> data;
|
||||
|
||||
void store(const cellwalker& o, int from, int spin, manual_celllister& cl) {
|
||||
if(!cl.add(o.c)) return;
|
||||
if(!cl.add(o.at)) return;
|
||||
data.emplace_back(o, from, spin);
|
||||
}
|
||||
|
||||
@ -312,14 +312,14 @@ struct cellcrawler {
|
||||
store(start, 0, 0, cl);
|
||||
for(int i=0; i<isize(data); i++) {
|
||||
cellwalker cw0 = data[i].orig;
|
||||
for(int j=0; j<cw0.c->type; j++) {
|
||||
for(int j=0; j<cw0.at->type; j++) {
|
||||
cellwalker cw = cw0 + j + wstep;
|
||||
if(!getNeuron(cw.c)) continue;
|
||||
if(!getNeuron(cw.at)) continue;
|
||||
store(cw, i, j, cl);
|
||||
}
|
||||
}
|
||||
if(gaussian) for(cellcrawlerdata& s: data)
|
||||
s.dist = mydistance(s.orig.c, start.c);
|
||||
s.dist = mydistance(s.orig.at, start.at);
|
||||
}
|
||||
|
||||
void sprawl(const cellwalker& start) {
|
||||
@ -328,9 +328,9 @@ struct cellcrawler {
|
||||
for(int i=1; i<isize(data); i++) {
|
||||
cellcrawlerdata& s = data[i];
|
||||
s.target = data[s.from].target;
|
||||
if(!s.target.c) continue;
|
||||
if(!s.target.at) continue;
|
||||
s.target += s.spin;
|
||||
if(cwstepcreates(s.target)) s.target.c = NULL;
|
||||
if(!s.target.peek()) s.target.at = NULL;
|
||||
else s.target += wstep;
|
||||
}
|
||||
}
|
||||
@ -383,7 +383,7 @@ void buildcellcrawler(cell *c, cellcrawler& cr, int dir) {
|
||||
if(iter % dispersion_each == 0) {
|
||||
d.emplace_back(N);
|
||||
auto& dispvec = d.back();
|
||||
for(int i=0; i<N; i++) dispvec[i] = curtemp[neuronId(*getNeuron(cr.data[i].orig.c))] / vmax;
|
||||
for(int i=0; i<N; i++) dispvec[i] = curtemp[neuronId(*getNeuron(cr.data[i].orig.at))] / vmax;
|
||||
if(isize(d) == dispersion_count) break;
|
||||
}
|
||||
double df = dispersion_precision * (iter+1);
|
||||
@ -426,7 +426,7 @@ pair<int, int> get_cellcrawler_id(cell *c) {
|
||||
}
|
||||
else {
|
||||
id = c->type == S7;
|
||||
// if(id == 0) ld = c->spin(0);
|
||||
// if(id == 0) ld = c->c.spin(0);
|
||||
}
|
||||
/* if(geometry == gZebraQuotient) {
|
||||
id = 8*id + ld;
|
||||
@ -440,10 +440,10 @@ pair<int, int> get_cellcrawler_id(cell *c) {
|
||||
|
||||
bool verify_crawler(cellcrawler& cc, cellwalker cw) {
|
||||
cc.sprawl(cw);
|
||||
for(auto& d: cc.data) if(celldistance(cw.c, d.target.c) != d.dist)
|
||||
for(auto& d: cc.data) if(celldistance(cw.at, d.target.at) != d.dist)
|
||||
return false;
|
||||
vector<int> cellcounter(cells, 0);
|
||||
for(auto& d: cc.data) cellcounter[d.target.c->landparam]++;
|
||||
for(auto& d: cc.data) cellcounter[d.target.at->landparam]++;
|
||||
for(int i=0; i<cells; i++) if(cellcounter[i] != 1) return false;
|
||||
return true;
|
||||
}
|
||||
@ -546,7 +546,7 @@ void step() {
|
||||
auto it = gaussian ? fake.begin() : s.dispersion[dispid].begin();
|
||||
|
||||
for(auto& sd: s.data) {
|
||||
neuron *n2 = getNeuron(sd.target.c);
|
||||
neuron *n2 = getNeuron(sd.target.at);
|
||||
if(!n2) continue;
|
||||
double nu = learning_factor;
|
||||
|
||||
@ -599,7 +599,7 @@ int showsample(int id) {
|
||||
auto& v = vdata.back();
|
||||
v.name = data[id].name;
|
||||
v.cp = dftcolor;
|
||||
createViz(i, bids.size() ? net[bids[id]].where : cwt.c, Id);
|
||||
createViz(i, bids.size() ? net[bids[id]].where : cwt.at, Id);
|
||||
v.m->store();
|
||||
return i;
|
||||
}
|
||||
@ -642,13 +642,13 @@ void sominit(int initto) {
|
||||
vector<cell*> allcells;
|
||||
|
||||
if(krad) {
|
||||
celllister cl(cwt.c, krad, 1000000, NULL);
|
||||
celllister cl(cwt.at, krad, 1000000, NULL);
|
||||
allcells = cl.lst;
|
||||
}
|
||||
else allcells = currentmap->allcells();
|
||||
|
||||
if(isize(allcells) > kohrestrict) {
|
||||
sort(allcells.begin(), allcells.end(), [] (cell *c1, cell *c2) { return hdist0(tC0(ggmatrix(c1))) < hdist0(tC0(shmup::ggmatrix(c2))); });
|
||||
sort(allcells.begin(), allcells.end(), [] (cell *c1, cell *c2) { return hdist0(tC0(ggmatrix(c1))) < hdist0(tC0(ggmatrix(c2))); });
|
||||
allcells.resize(kohrestrict);
|
||||
}
|
||||
|
||||
@ -675,7 +675,7 @@ void sominit(int initto) {
|
||||
auto &vd = vdata.back();
|
||||
vd.name = data[s].name;
|
||||
vd.cp = dftcolor;
|
||||
createViz(vdid, cwt.c, Id);
|
||||
createViz(vdid, cwt.at, Id);
|
||||
storeall(vdid);
|
||||
}
|
||||
|
||||
@ -786,9 +786,9 @@ namespace levelline {
|
||||
neuron *n1 = getNeuron(c1);
|
||||
if(!n1) continue;
|
||||
for(int i=0; i<c1->type; i++) {
|
||||
cell *c2 = c1->mov[i];
|
||||
cell *c2 = c1->move(i);
|
||||
if(!c2) continue;
|
||||
cell *c3 = c1->mov[i ? i-1 : c1->type-1];
|
||||
cell *c3 = c1->modmove(i-1);
|
||||
if(!c3) continue;
|
||||
|
||||
if(!gmatrix.count(c2)) continue;
|
||||
|
@ -44,13 +44,13 @@ void rvvideo(const string &fname) {
|
||||
drawthemap();
|
||||
centerpc(100); optimizeview();
|
||||
fixmatrix(View);
|
||||
bfs(); setdist(cwt.c, 7 - getDistLimit() - genrange_bonus, NULL);
|
||||
bfs(); setdist(cwt.at, 7 - getDistLimit() - genrange_bonus, NULL);
|
||||
vertexdata& vd = vdata[id];
|
||||
for(int e=0; e<isize(vd.edges); e++) {
|
||||
int id2 = vd.edges[e].first;
|
||||
if(vdata[id2].name == seq[next]) {
|
||||
id = id2; next++;
|
||||
cwt.c = shmup::pc[0]->base = vdata[id2].m->base;
|
||||
cwt.at = shmup::pc[0]->base = vdata[id2].m->base;
|
||||
if(next == isize(seq)) goto found;
|
||||
}
|
||||
}
|
||||
|
40
rogueviz.cpp
40
rogueviz.cpp
@ -167,7 +167,7 @@ hyperpoint where(int i, cell *base) {
|
||||
}
|
||||
else {
|
||||
// notimpl(); // actually probably that's a buug
|
||||
return inverse(ggmatrix(currentmap->gamestart())) * (shmup::ggmatrix(m->base) * tC0(m->at));
|
||||
return inverse(ggmatrix(currentmap->gamestart())) * (ggmatrix(m->base) * tC0(m->at));
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ namespace spiral {
|
||||
|
||||
transmatrix h = at(d);
|
||||
|
||||
createViz(i, cwt.c, h);
|
||||
createViz(i, cwt.at, h);
|
||||
vd.name = its(i+1);
|
||||
virtualRebase(vd.m, true);
|
||||
|
||||
@ -282,7 +282,7 @@ namespace collatz {
|
||||
collatz2 = add_edgetype("2");
|
||||
vdata.resize(1);
|
||||
vertexdata& vd = vdata[0];
|
||||
createViz(0, cwt.c, xpush(cshift));
|
||||
createViz(0, cwt.at, xpush(cshift));
|
||||
virtualRebase(vd.m, true);
|
||||
vd.cp = perturb(dftcolor);
|
||||
vd.data = 0;
|
||||
@ -469,7 +469,7 @@ namespace tree {
|
||||
vd.m = new shmup::monster;
|
||||
vd.m->pid = i;
|
||||
vd.data = lv.parent;
|
||||
createViz(i, cwt.c, h);
|
||||
createViz(i, cwt.at, h);
|
||||
vd.cp = dftcolor;
|
||||
|
||||
if(tol[i].parent >= 0)
|
||||
@ -518,11 +518,11 @@ namespace sag {
|
||||
bool snake_enabled;
|
||||
|
||||
void setsnake(cellwalker& cw, int i) {
|
||||
lpbak[i] = cw.c->landparam;
|
||||
wpbak[i] = cw.c->wparam;
|
||||
cw.c->landparam = i; cw.c->wparam = INSNAKE;
|
||||
// cw.c->monst = moWormtail; cw.c->mondir = cw.spin;
|
||||
snakecells[i] = cw.c;
|
||||
lpbak[i] = cw.at->landparam;
|
||||
wpbak[i] = cw.at->wparam;
|
||||
cw.at->landparam = i; cw.at->wparam = INSNAKE;
|
||||
// cw.at->monst = moWormtail; cw.at->mondir = cw.spin;
|
||||
snakecells[i] = cw.at;
|
||||
}
|
||||
|
||||
void snakeswitch() {
|
||||
@ -577,9 +577,9 @@ namespace sag {
|
||||
for(int i=2; i<=numsnake; i++) {
|
||||
if(i == numsnake && sphere) break;
|
||||
cw += wstep;
|
||||
snakefirst[i-1] = cw.c->landparam;
|
||||
while(cw.c->wparam == INSNAKE) {
|
||||
snakelast[i-1] = cw.c->landparam;
|
||||
snakefirst[i-1] = cw.at->landparam;
|
||||
while(cw.at->wparam == INSNAKE) {
|
||||
snakelast[i-1] = cw.at->landparam;
|
||||
cw = cw + wstep + 1 + wstep;
|
||||
}
|
||||
if(i == numsnake) break;
|
||||
@ -605,7 +605,7 @@ namespace sag {
|
||||
}
|
||||
/* cell *c = snakecells[id];
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2 && c2->wparam == INSNAKE && snakenode[c2->landparam] >= 0)
|
||||
cost += 100;
|
||||
} */
|
||||
@ -662,7 +662,7 @@ namespace sag {
|
||||
int it = s<2 ? (s+1) : s-2;
|
||||
for(int ii=0; ii<it; ii++) {
|
||||
int d = hrand(c->type);
|
||||
c = c->mov[d];
|
||||
c = c->move(d);
|
||||
if(!c) goto aiter;
|
||||
if(c->wparam != INSNAKE) goto aiter;
|
||||
}
|
||||
@ -1185,12 +1185,12 @@ bool drawVertex(const transmatrix &V, cell *c, shmup::monster *m) {
|
||||
}
|
||||
else {
|
||||
|
||||
cell *center = multidraw ? c : euclid ? cwt.c : viewctr.h->c7;
|
||||
cell *center = multidraw ? c : euclid ? cwt.at : viewctr.at->c7;
|
||||
|
||||
if(!multidraw && ei->orig && ei->orig != center && celldistance(ei->orig, center) > 3)
|
||||
ei->orig = NULL;
|
||||
if(!ei->orig) {
|
||||
ei->orig = center; // cwt.c;
|
||||
ei->orig = center; // cwt.at;
|
||||
ei->prec.clear();
|
||||
|
||||
transmatrix T = inverse(ggmatrix(ei->orig));
|
||||
@ -1783,9 +1783,9 @@ void showMenu() {
|
||||
else if(uni == 'b') backcolor ^= 0xFFFFFF, bordcolor ^= 0xFFFFFF, forecolor ^= 0xFFFFFF;
|
||||
else if(uni == 'g') pushScreen(configure_edge_display);
|
||||
else if(uni == 'z') {
|
||||
for(int i=0; i<isize(named)-1; i++) if(named[i] == cwt.c)
|
||||
for(int i=0; i<isize(named)-1; i++) if(named[i] == cwt.at)
|
||||
swap(named[i], named[i+1]);
|
||||
if(!isize(named) || named[isize(named)-1] != cwt.c) named.push_back(cwt.c);
|
||||
if(!isize(named) || named[isize(named)-1] != cwt.at) named.push_back(cwt.at);
|
||||
printf("named = %d\n", isize(named));
|
||||
popScreen();
|
||||
}
|
||||
@ -1819,7 +1819,7 @@ template<class T> function<void(presmode)> roguevizslide(char c, const T& t) {
|
||||
slidecommand = "toggle the player";
|
||||
if(mode == 4)
|
||||
mapeditor::drawplayer = !mapeditor::drawplayer;
|
||||
centerover.c = NULL; pd_from = NULL;
|
||||
centerover.at = NULL; pd_from = NULL;
|
||||
};
|
||||
}
|
||||
|
||||
@ -2003,7 +2003,7 @@ slide rvslides[] = {
|
||||
if(mode == 4) {
|
||||
if(!banachtarski::on) {
|
||||
bool b = mapeditor::drawplayer;
|
||||
specialland = cwt.c->land;
|
||||
specialland = cwt.at->land;
|
||||
push_game();
|
||||
banachtarski::init_bantar();
|
||||
airmap.clear();
|
||||
|
8
rug.cpp
8
rug.cpp
@ -578,7 +578,7 @@ void buildRug() {
|
||||
return;
|
||||
}
|
||||
|
||||
celllister cl(centerover.c ? centerover.c : cwt.c, get_sightrange(), vertex_limit, NULL);
|
||||
celllister cl(centerover.at ? centerover.at : cwt.at, get_sightrange(), vertex_limit, NULL);
|
||||
|
||||
map<cell*, rugpoint *> vptr;
|
||||
|
||||
@ -589,15 +589,15 @@ void buildRug() {
|
||||
cell *c = p.first;
|
||||
rugpoint *v = p.second;
|
||||
for(int j=0; j<c->type; j++) try {
|
||||
cell *c2 = c->mov[j];
|
||||
cell *c2 = c->move(j);
|
||||
rugpoint *w = vptr.at(c2);
|
||||
// if(v<w) addEdge(v, w);
|
||||
|
||||
cell *c3 = c->mov[(j+1) % c->type];
|
||||
cell *c3 = c->modmove(j+1);
|
||||
rugpoint *w2 = vptr.at(c3);
|
||||
|
||||
if(a4) {
|
||||
cell *c4 = (cellwalker(c,j) + wstep - 1 + wstep).c;
|
||||
cell *c4 = (cellwalker(c,j) + wstep - 1).cpeek();
|
||||
cell *cm = c; comp(cm, c); comp(cm, c2); comp(cm, c3); comp(cm, c4);
|
||||
if(cm == c || cm == c4)
|
||||
addTriangle(v, w, w2);
|
||||
|
44
savemem.cpp
44
savemem.cpp
@ -32,8 +32,8 @@ void slow_delete_cell(cell *c) {
|
||||
while(c->mpdist < BARLEV)
|
||||
degrade(c);
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i])
|
||||
c->mov[i]->mov[c->spn(i)] = NULL;
|
||||
if(c->move(i))
|
||||
c->move(i)->move(c->c.spin(i)) = NULL;
|
||||
removed_cells.push_back(c);
|
||||
delete c;
|
||||
}
|
||||
@ -42,20 +42,20 @@ void delete_heptagon(heptagon *h2) {
|
||||
cell *c = h2->c7;
|
||||
if(!nonbitrunc) {
|
||||
for(int i=0; i<c->type; i++)
|
||||
if(c->mov[i])
|
||||
slow_delete_cell(c->mov[i]);
|
||||
if(c->move(i))
|
||||
slow_delete_cell(c->move(i));
|
||||
}
|
||||
slow_delete_cell(c);
|
||||
for(int i=0; i<S7; i++)
|
||||
if(h2->move[i])
|
||||
h2->move[i]->move[h2->spin(i)] = NULL;
|
||||
if(h2->move(i))
|
||||
h2->move(i)->move(h2->c.spin(i)) = NULL;
|
||||
delete h2;
|
||||
}
|
||||
|
||||
void recursive_delete(heptagon *h, int i) {
|
||||
heptagon *h2 = h->move[i];
|
||||
heptagon *h2 = h->move(i);
|
||||
{ for(int i=1; i<S7; i++)
|
||||
if(h2->move[i] && h2->move[i]->move[0] == h2)
|
||||
if(h2->move(i) && h2->move(i)->move(0) == h2)
|
||||
recursive_delete(h2, i); }
|
||||
if(h2->alt && h2->alt->alt == h2->alt) {
|
||||
DEBSM(printf("destroying alternate map %p\n", h2->alt);)
|
||||
@ -74,7 +74,7 @@ void recursive_delete(heptagon *h, int i) {
|
||||
h2->alt->cdata = NULL;
|
||||
}
|
||||
delete_heptagon(h2);
|
||||
h->move[i] = NULL;
|
||||
h->move(i) = NULL;
|
||||
}
|
||||
|
||||
bool unsafeLand(cell *c) {
|
||||
@ -86,11 +86,11 @@ bool unsafeLand(cell *c) {
|
||||
void save_memory() {
|
||||
if(quotient || !hyperbolic) return;
|
||||
if(!memory_saving_mode) return;
|
||||
if(unsafeLand(cwt.c)) return;
|
||||
int d = celldist(cwt.c);
|
||||
if(unsafeLand(cwt.at)) return;
|
||||
int d = celldist(cwt.at);
|
||||
if(d < LIM+10) return;
|
||||
|
||||
heptagon *at = cwt.c->master;
|
||||
heptagon *at = cwt.at->master;
|
||||
heptagon *orig = currentmap->gamestart()->master;
|
||||
|
||||
if(recallCell) {
|
||||
@ -100,13 +100,13 @@ void save_memory() {
|
||||
while(at != at2) {
|
||||
t++; if(t > 10000) return;
|
||||
if(celldist(at->c7) > celldist(at2->c7))
|
||||
at = at->move[0];
|
||||
at = at->move(0);
|
||||
else
|
||||
at2 = at2->move[0];
|
||||
at2 = at2->move(0);
|
||||
}
|
||||
}
|
||||
|
||||
while(celldist(at->c7) > d-LIM) at = at->move[0];
|
||||
while(celldist(at->c7) > d-LIM) at = at->move(0);
|
||||
|
||||
// go back to such a point X that all the heptagons adjacent to the current 'at'
|
||||
// are the children of X. This X becomes the new 'at'
|
||||
@ -115,8 +115,8 @@ void save_memory() {
|
||||
int hcount = 0;
|
||||
allh[hcount++] = at;
|
||||
for(int j=0; j<S7; j++)
|
||||
if(allh[0]->move[j])
|
||||
allh[hcount++] = at->move[j];
|
||||
if(allh[0]->move(j))
|
||||
allh[hcount++] = at->move(j);
|
||||
|
||||
int deuniq_steps = 0;
|
||||
|
||||
@ -125,10 +125,10 @@ void save_memory() {
|
||||
if(allh[i] == allh[0])
|
||||
allh[i] = allh[hcount-1], hcount--;
|
||||
else if(celldist(allh[i]->c7) > celldist(allh[0]->c7))
|
||||
allh[i] = allh[i]->move[0];
|
||||
allh[i] = allh[i]->move(0);
|
||||
else {
|
||||
if(allh[0] == orig) return;
|
||||
allh[0] = allh[0]->move[0];
|
||||
allh[0] = allh[0]->move(0);
|
||||
i = 1;
|
||||
deuniq_steps++;
|
||||
if(deuniq_steps == 10) return;
|
||||
@ -141,15 +141,15 @@ void save_memory() {
|
||||
if(last_cleared && celldist(at->c7) < celldist(last_cleared->c7))
|
||||
return;
|
||||
|
||||
DEBSM(printf("celldist = %d, %d\n", celldist(cwt.c), celldist(at->c7));)
|
||||
DEBSM(printf("celldist = %d, %d\n", celldist(cwt.at), celldist(at->c7));)
|
||||
|
||||
heptagon *at1 = at;
|
||||
while(at != last_cleared && at != orig) {
|
||||
heptagon *atn = at;
|
||||
at = at->move[0];
|
||||
at = at->move(0);
|
||||
|
||||
for(int i=1; i<S7; i++)
|
||||
if(at->move[i] && at->move[i] != atn)
|
||||
if(at->move(i) && at->move(i) != atn)
|
||||
recursive_delete(at, i);
|
||||
}
|
||||
|
||||
|
80
shmup.cpp
80
shmup.cpp
@ -40,11 +40,11 @@ namespace multi {
|
||||
|
||||
void recall() {
|
||||
for(int i=0; i<numplayers(); i++) {
|
||||
int idir = (3 * i) % cwt.c->type;
|
||||
cell *c2 = cwt.c->mov[idir];
|
||||
int idir = (3 * i) % cwt.at->type;
|
||||
cell *c2 = cwt.at->move(idir);
|
||||
makeEmpty(c2);
|
||||
if(!passable(c2, NULL, P_ISPLAYER)) c2 = cwt.c;
|
||||
multi::player[i].c = c2;
|
||||
if(!passable(c2, NULL, P_ISPLAYER)) c2 = cwt.at;
|
||||
multi::player[i].at = c2;
|
||||
multi::player[i].spin = 0;
|
||||
|
||||
multi::flipped[i] = true;
|
||||
@ -699,7 +699,7 @@ void handleInput(int delta) {
|
||||
|
||||
|
||||
void leaveGame(int i) {
|
||||
multi::player[i].c = NULL;
|
||||
multi::player[i].at = NULL;
|
||||
multi::deaths[i]++;
|
||||
revive_queue.push_back(i);
|
||||
checklastmove();
|
||||
@ -707,7 +707,7 @@ void handleInput(int delta) {
|
||||
|
||||
bool playerActive(int p) {
|
||||
if(multi::players == 1 || shmup::on) return true;
|
||||
return player[p].c;
|
||||
return player[p].at;
|
||||
}
|
||||
|
||||
int activePlayers() {
|
||||
@ -718,13 +718,13 @@ void handleInput(int delta) {
|
||||
|
||||
cell *multiPlayerTarget(int i) {
|
||||
cellwalker cwti = multi::player[i];
|
||||
if(!cwti.c) return NULL;
|
||||
if(!cwti.at) return NULL;
|
||||
int dir = multi::whereto[i].d;
|
||||
if(dir == MD_UNDECIDED) return NULL;
|
||||
if(dir == MD_USE_ORB) return multi::whereto[i].tgt;
|
||||
if(dir >= 0)
|
||||
cwti = cwti + dir + wstep;
|
||||
return cwti.c;
|
||||
return cwti.at;
|
||||
}
|
||||
|
||||
void checklastmove() {
|
||||
@ -802,7 +802,7 @@ void handleInput(int delta) {
|
||||
if(multi::actionspressed[b+pcFace])
|
||||
multi::whereto[i].d = MD_UNDECIDED;
|
||||
|
||||
cwt.c = multi::player[i].c;
|
||||
cwt.at = multi::player[i].at;
|
||||
if(multi::ccat[i] && !multi::combo[i] && targetRangedOrb(multi::ccat[i], roMultiCheck)) {
|
||||
multi::whereto[i].d = MD_USE_ORB;
|
||||
multi::whereto[i].tgt = multi::ccat[i];
|
||||
@ -838,7 +838,7 @@ void handleInput(int delta) {
|
||||
needinput = true;
|
||||
|
||||
for(int i=0; i<numplayers(); i++) if(playerActive(i)) {
|
||||
origpos[i] = player[i].c;
|
||||
origpos[i] = player[i].at;
|
||||
origtarget[i] = multiPlayerTarget(i);
|
||||
}
|
||||
|
||||
@ -848,7 +848,7 @@ void handleInput(int delta) {
|
||||
addMessage("Two players cannot move/attack the same location!");
|
||||
return;
|
||||
}
|
||||
/* if(multiPlayerTarget(i) == multi::player[j].c) {
|
||||
/* if(multiPlayerTarget(i) == multi::player[j].at) {
|
||||
addMessage("Cannot move into the current location of another player!");
|
||||
return;
|
||||
}
|
||||
@ -946,7 +946,7 @@ cell *findbaseAround(hyperpoint p, cell *around) {
|
||||
cell *best = around;
|
||||
double d0 = intval(p, ggmatrix(around) * C0);
|
||||
for(int i=0; i<around->type; i++) {
|
||||
cell *c2 = around->mov[i];
|
||||
cell *c2 = around->move(i);
|
||||
if(c2) {
|
||||
double d1 = intval(p, ggmatrix(c2) * C0);
|
||||
if(d1 < d0) { best = c2; d0 = d1; }
|
||||
@ -1123,7 +1123,7 @@ bool playerfire[MAXPLAYER];
|
||||
|
||||
void awakenMimics(monster *m, cell *c2) {
|
||||
for(auto& mi: mirror::mirrors) {
|
||||
cell *c = mi.second.c;
|
||||
cell *c = mi.second.at;
|
||||
|
||||
transmatrix mirrortrans = Id;
|
||||
if(mi.second.mirrored) mirrortrans[0][0] = -1;
|
||||
@ -1214,7 +1214,7 @@ void oceanCurrents(transmatrix& nat, monster *m, int delta) {
|
||||
cell *c = m->base;
|
||||
if(c->land == laWhirlpool) {
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2 || !gmatrix.count(c2)) continue;
|
||||
|
||||
double spd = 0;
|
||||
@ -1244,7 +1244,7 @@ bool airCurrents(transmatrix& nat, monster *m, int delta) {
|
||||
if(c->land == laWhirlwind) {
|
||||
whirlwind::calcdirs(c);
|
||||
for(int i=0; i<whirlwind::qdirs; i++) {
|
||||
cell *c2 = c->mov[whirlwind::dto[i]];
|
||||
cell *c2 = c->move(whirlwind::dto[i]);
|
||||
if(!c2 || !gmatrix.count(c2)) continue;
|
||||
|
||||
double spd = SCALE * delta / 900.;
|
||||
@ -1293,12 +1293,12 @@ void roseCurrents(transmatrix& nat, monster *m, int delta) {
|
||||
int qty = 0;
|
||||
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2 && rosedist(c2) == 2) qty++;
|
||||
}
|
||||
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(!c2 || !gmatrix.count(c2)) continue;
|
||||
if(rosedist(c2) != 2) continue;
|
||||
|
||||
@ -1480,13 +1480,13 @@ void movePlayer(monster *m, int delta) {
|
||||
#endif
|
||||
|
||||
if(actionspressed[b+pcOrbPower] && !lactionpressed[b+pcOrbPower] && mouseover) {
|
||||
cwt.c = m->base;
|
||||
cwt.at = m->base;
|
||||
targetRangedOrb(mouseover, roKeyboard);
|
||||
}
|
||||
|
||||
#if !ISMOBILE
|
||||
if(haveRangedOrb()) {
|
||||
cwt.c = m->base;
|
||||
cwt.at = m->base;
|
||||
if(actionspressed[b+pcOrbKey] && !lactionpressed[b+pcOrbKey])
|
||||
keyresult[cpid] = targetRangedOrbKey(roKeyboard);
|
||||
else
|
||||
@ -1608,7 +1608,7 @@ void movePlayer(monster *m, int delta) {
|
||||
else if(c2->wall == waBigStatue && canPushStatueOn(m->base) && !nonAdjacent(c2, m->base)) {
|
||||
visibleFor(300);
|
||||
c2->wall = m->base->wall;
|
||||
if(cellUnstable(cwt.c))
|
||||
if(cellUnstable(cwt.at))
|
||||
m->base->wall = waChasm;
|
||||
else {
|
||||
m->base->wall = waBigStatue;
|
||||
@ -1645,13 +1645,13 @@ void movePlayer(monster *m, int delta) {
|
||||
visibleFor(300);
|
||||
cellwalker push(c2, dirfromto(c2, m->base));
|
||||
push = push + 3 * (-subdir) + wstep;
|
||||
if(!canPushThumperOn(push.c, c2, m->base) && c2->type == 7) {
|
||||
if(!canPushThumperOn(push.at, c2, m->base) && c2->type == 7) {
|
||||
push = push + wstep - subdir + wstep;
|
||||
}
|
||||
if(!canPushThumperOn(push.c, c2, m->base)) {
|
||||
if(!canPushThumperOn(push.at, c2, m->base)) {
|
||||
go = false;
|
||||
}
|
||||
else pushThumper(c2, push.c);
|
||||
else pushThumper(c2, push.at);
|
||||
popmonsters();
|
||||
}
|
||||
else if(c2->wall == waRose && !nonAdjacent(m->base, c2)) {
|
||||
@ -1689,7 +1689,7 @@ void movePlayer(monster *m, int delta) {
|
||||
if(d >= 0 && earthMove(m->base, d)) markOrb(itOrbDigging);
|
||||
}
|
||||
|
||||
cwt.c = c2; afterplayermoved();
|
||||
cwt.at = c2; afterplayermoved();
|
||||
if(c2->item && c2->land == laAlchemist) c2->wall = m->base->wall;
|
||||
if(m->base->wall == waRoundTable)
|
||||
roundTableMessage(c2);
|
||||
@ -1817,7 +1817,7 @@ void movePlayer(monster *m, int delta) {
|
||||
if(items[itOrbFlash]) {
|
||||
pushmonsters();
|
||||
killMonster(m->base, moNone);
|
||||
cwt.c = m->base;
|
||||
cwt.at = m->base;
|
||||
activateFlash();
|
||||
popmonsters();
|
||||
return;
|
||||
@ -1826,7 +1826,7 @@ void movePlayer(monster *m, int delta) {
|
||||
if(items[itOrbLightning]) {
|
||||
pushmonsters();
|
||||
killMonster(m->base, moLightningBolt);
|
||||
cwt.c = m->base;
|
||||
cwt.at = m->base;
|
||||
activateLightning();
|
||||
popmonsters();
|
||||
return;
|
||||
@ -1959,8 +1959,8 @@ void destroyMimics() {
|
||||
|
||||
void teleported() {
|
||||
monster *m = pc[cpid];
|
||||
m->base = cwt.c;
|
||||
m->at = rgpushxto0(inverse(gmatrix[cwt.c]) * mouseh) * spin(rand() % 1000 * M_PI / 2000);
|
||||
m->base = cwt.at;
|
||||
m->at = rgpushxto0(inverse(gmatrix[cwt.at]) * mouseh) * spin(rand() % 1000 * M_PI / 2000);
|
||||
m->findpat();
|
||||
destroyMimics();
|
||||
}
|
||||
@ -2135,7 +2135,7 @@ void moveBullet(monster *m, int delta) {
|
||||
|
||||
// destroy stray bullets
|
||||
if(!doall) for(int i=0; i<m->base->type; i++)
|
||||
if(!m->base->mov[i] || !gmatrix.count(m->base->mov[i]))
|
||||
if(!m->base->move(i) || !gmatrix.count(m->base->move(i)))
|
||||
m->dead = true;
|
||||
|
||||
// items[itOrbWinter] = 100; items[itOrbLife] = 100;
|
||||
@ -2422,7 +2422,7 @@ void moveMonster(monster *m, int delta) {
|
||||
else if(m->type == moWolf && !peace::on) {
|
||||
cell *cnext = c;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2 && gmatrix.count(c2) && (c2->land == laVolcano || (isIcyLand(c2) && HEAT(c2) > HEAT(c))) && passable(c2, c, 0))
|
||||
cnext = c2;
|
||||
}
|
||||
@ -2471,7 +2471,7 @@ void moveMonster(monster *m, int delta) {
|
||||
goal = gmatrix[c];
|
||||
cell *cnext = c;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
cell *c2 = c->move(i);
|
||||
if(c2 && gmatrix.count(c2) && c2->pathdist < c->pathdist &&
|
||||
passable_for(m->type, c2, c, P_CHAIN | P_ONPLAYER))
|
||||
cnext = c2;
|
||||
@ -2661,7 +2661,7 @@ void moveMonster(monster *m, int delta) {
|
||||
|
||||
if(c2 != m->base && m->type == moNecromancer && !c2->monst) {
|
||||
for(int i=0; i<m->base->type; i++) {
|
||||
cell *c3 = m->base->mov[i];
|
||||
cell *c3 = m->base->move(i);
|
||||
if(dirfromto(c3, c2) != -1 && c3->wall == waFreshGrave && gmatrix.count(c3)) {
|
||||
bool monstersNear = false;
|
||||
for(monster *m2: nonvirtual) {
|
||||
@ -2943,8 +2943,8 @@ void turn(int delta) {
|
||||
int d = c->pathdist;
|
||||
if(d == PINFD-1) continue;
|
||||
for(int i=0; i<c->type; i++) {
|
||||
cell *c2 = c->mov[i];
|
||||
// printf("i=%d cd=%d\n", i, c->mov[i]->cpdist);
|
||||
cell *c2 = c->move(i);
|
||||
// printf("i=%d cd=%d\n", i, c->move(i)->cpdist);
|
||||
if(c2 && c2->pathdist == PINFD && gmatrix.count(c2) &&
|
||||
(passable_for(eMonster(t), c, c2, P_CHAIN | P_ONPLAYER) || c->wall == waThumperOn)) {
|
||||
onpath(c2, d+1);
|
||||
@ -2967,7 +2967,7 @@ void turn(int delta) {
|
||||
|
||||
bool tick = curtime >= nextmove;
|
||||
keepLightning = ticks <= lightat + 1000;
|
||||
cwt.c = pc[0]->base;
|
||||
cwt.at = pc[0]->base;
|
||||
bfs(); moverefresh(tick);
|
||||
countLocalTreasure();
|
||||
pushmonsters();
|
||||
@ -3091,13 +3091,13 @@ void turn(int delta) {
|
||||
|
||||
void recall() {
|
||||
for(int i=0; i<players; i++) {
|
||||
pc[i]->base = cwt.c;
|
||||
pc[i]->base = cwt.at;
|
||||
if(players == 1)
|
||||
pc[i]->at = Id;
|
||||
else
|
||||
pc[i]->at = spin(2*M_PI*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id;
|
||||
/* ggmatrix(cwt.c);
|
||||
display(gmatrix[cwt.c]);
|
||||
/* ggmatrix(cwt.at);
|
||||
display(gmatrix[cwt.at]);
|
||||
pc[i]->findpat(); */
|
||||
}
|
||||
destroyMimics();
|
||||
@ -3115,7 +3115,7 @@ void init() {
|
||||
pc[i]->at = Id;
|
||||
else
|
||||
pc[i]->at = spin(2*M_PI*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id;
|
||||
pc[i]->base = cwt.c;
|
||||
pc[i]->base = cwt.at;
|
||||
pc[i]->inBoat = (firstland == laCaribbean || firstland == laOcean || firstland == laLivefjord ||
|
||||
firstland == laWhirlpool);
|
||||
pc[i]->store();
|
||||
@ -3322,7 +3322,7 @@ transmatrix master_relative(cell *c, bool get_inverse) {
|
||||
}
|
||||
}
|
||||
else if(!nonbitrunc && !euclid) {
|
||||
for(int d=0; d<S7; d++) if(c->master->c7->mov[d] == c)
|
||||
for(int d=0; d<S7; d++) if(c->master->c7->move(d) == c)
|
||||
return (get_inverse?invhexmove:hexmove)[d];
|
||||
return Id;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ string musfname[landtypes];
|
||||
int musicvolume = 60, effvolume = 60;
|
||||
|
||||
eLand getCurrentLandForMusic() {
|
||||
eLand id = cwt.c->land;
|
||||
eLand id = cwt.at->land;
|
||||
if(isHaunted(id)) id = laHaunted;
|
||||
if(id == laWarpSea) id = laWarpCoast;
|
||||
return id;
|
||||
|
@ -756,7 +756,7 @@ void show_surfaces() {
|
||||
if(coverage_style == 2) {
|
||||
if(rug::rugged) rug::close();
|
||||
}
|
||||
coverage_matrix = inverse(ggmatrix(coverage_center = cwt.c));
|
||||
coverage_matrix = inverse(ggmatrix(coverage_center = cwt.at));
|
||||
}
|
||||
else if(rug::handlekeys(sym, uni)) ;
|
||||
else if(doexiton(sym, uni)) popScreen();
|
||||
|
142
syntetic.cpp
142
syntetic.cpp
@ -257,9 +257,9 @@ void initialize(heptagon *h) {
|
||||
};
|
||||
|
||||
void verify_distance_delta(heptagon *h, int d, int delta) {
|
||||
if(!h->move[d]) return;
|
||||
if(h->move[d]->distance != h->distance + delta) {
|
||||
SDEBUG( printf("ERROR: delta %p.%d (%d/%d)\n", h, d, h->move[d]->distance, h->distance + delta); )
|
||||
if(!h->move(d)) return;
|
||||
if(h->move(d)->distance != h->distance + delta) {
|
||||
SDEBUG( printf("ERROR: delta %p.%d (%d/%d)\n", h, d, h->move(d)->distance, h->distance + delta); )
|
||||
// exit(1);
|
||||
}
|
||||
}
|
||||
@ -276,11 +276,11 @@ void debug(heptagon *h) {
|
||||
verify_distance_delta(h, first-1, 0);
|
||||
verify_distance_delta(h, isize(p)-1, 0);
|
||||
for(int d=first; d<isize(p)-1; d++) verify_distance_delta(h, d, 1);
|
||||
for(int d=0; d<isize(p); d++) if(h->move[d]) {
|
||||
for(int d=0; d<isize(p); d++) if(h->move(d)) {
|
||||
auto& p = adjacent[id_of(h)];
|
||||
auto uv = p[(parent_index_of(h) + d) % isize(p)];
|
||||
if(neighbors_of(h->move[d]) != isize(adjacent[uv.first])) {
|
||||
SDEBUG( printf("neighbors mismatch at %p/%d->%p: is %d expected %d\n", h, d, h->move[d], neighbors_of(h->move[d]), isize(adjacent[uv.first])); )
|
||||
if(neighbors_of(h->move(d)) != isize(adjacent[uv.first])) {
|
||||
SDEBUG( printf("neighbors mismatch at %p/%d->%p: is %d expected %d\n", h, d, h->move(d), neighbors_of(h->move(d)), isize(adjacent[uv.first])); )
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -303,24 +303,24 @@ heptagon *build_child(heptagon *parent, int d, int id, int pindex) {
|
||||
|
||||
void connectHeptagons(heptagon *h, int i, heptspin hs) {
|
||||
indenter ind;
|
||||
SDEBUG( printf("%p.%d/%d ~ %p.%d/%d (state=%d,id=%d,pindex=%d,distance=%d)\n", h, i, neighbors_of(h), hs.h, hs.spin, neighbors_of(hs.h),
|
||||
hs.h->s, id_of(hs.h), parent_index_of(hs.h), hs.h->distance); )
|
||||
if(h->move[i] == hs.h && h->spin(i) == hs.spin) {
|
||||
SDEBUG( printf("%p.%d/%d ~ %p.%d/%d (state=%d,id=%d,pindex=%d,distance=%d)\n", h, i, neighbors_of(h), hs.at, hs.spin, neighbors_of(hs.at),
|
||||
hs.at->s, id_of(hs.at), parent_index_of(hs.at), hs.at->distance); )
|
||||
if(h->move(i) == hs.at && h->c.spin(i) == hs.spin) {
|
||||
SDEBUG( printf("WARNING: already connected\n"); )
|
||||
return;
|
||||
}
|
||||
if(h->move[i]) {
|
||||
SDEBUG( printf("ERROR: already connected left to: %p not %p\n", h->move[i], hs.h); )
|
||||
if(h->move(i)) {
|
||||
SDEBUG( printf("ERROR: already connected left to: %p not %p\n", h->move(i), hs.at); )
|
||||
exit(1);
|
||||
}
|
||||
if(hs.h->move[hs.spin]) {
|
||||
SDEBUG( printf("ERROR: already connected right to: %p not %p\n", hs.h->move[hs.spin], h); )
|
||||
if(hs.peek()) {
|
||||
SDEBUG( printf("ERROR: already connected right to: %p not %p\n", hs.peek(), h); )
|
||||
exit(1);
|
||||
// exit(1);
|
||||
}
|
||||
hr::connectHeptagons(h, i, hs.h, hs.spin);
|
||||
h->c.connect(i, hs);
|
||||
debug(h);
|
||||
debug(hs.h);
|
||||
debug(hs.at);
|
||||
}
|
||||
|
||||
int prune(heptagon*& h) {
|
||||
@ -329,12 +329,12 @@ int prune(heptagon*& h) {
|
||||
auto h0 = h;
|
||||
SDEBUG( printf("pruning: %p\n", h0); )
|
||||
for(int i=0; i<n; i++)
|
||||
if(h0->move[i]) {
|
||||
if(h0->spin(i) == 0)
|
||||
result += prune(h0->move[i]);
|
||||
if(h0->move(i)) {
|
||||
if(h0->c.spin(i) == 0)
|
||||
result += prune(h0->move(i));
|
||||
else {
|
||||
h0->move[i]->move[h0->spin(i)] = NULL;
|
||||
h0->move[i] = NULL;
|
||||
h0->move(i)->move(h0->c.spin(i)) = NULL;
|
||||
h0->move(i) = NULL;
|
||||
}
|
||||
}
|
||||
delete h0->c7;
|
||||
@ -348,11 +348,11 @@ void contract(heptagon *h) {
|
||||
SDEBUG( printf("handling contraction (0) at %p\n", h); )
|
||||
heptspin right = heptspin(h, right_sibling_of(h)) + wstep + 1;
|
||||
heptspin left = heptspin(h, parents_of(h)) + wstep - 1;
|
||||
connectHeptagons(right.h, right.spin, left);
|
||||
right.h->s++;
|
||||
right_sibling_of(left.h)--;
|
||||
contract(right.h);
|
||||
contract(left.h);
|
||||
connectHeptagons(right.at, right.spin, left);
|
||||
right.at->s++;
|
||||
right_sibling_of(left.at)--;
|
||||
contract(right.at);
|
||||
contract(left.at);
|
||||
break;
|
||||
}
|
||||
case -1: {
|
||||
@ -361,46 +361,46 @@ void contract(heptagon *h) {
|
||||
heptspin hs0(h, neighbors_of(h)-1);
|
||||
heptspin hs = hs0;
|
||||
hs = hs + 1 + wstep + 1;
|
||||
while(hs.spin == neighbors_of(hs.h) - 1) {
|
||||
SDEBUG( printf("hsr at %p.%d/%d (%d parents)\n", hs.h, hs.spin, neighbors_of(hs.h), parents_of(hs.h)); )
|
||||
while(hs.spin == neighbors_of(hs.at) - 1) {
|
||||
SDEBUG( printf("hsr at %p.%d/%d (%d parents)\n", hs.at, hs.spin, neighbors_of(hs.at), parents_of(hs.at)); )
|
||||
hs = hs + wstep + 1;
|
||||
}
|
||||
SDEBUG( printf("hsr at %p.%d/%d (%d parents)\n", hs.h, hs.spin, neighbors_of(hs.h), parents_of(hs.h)); )
|
||||
SDEBUG( printf("hsr at %p.%d/%d (%d parents)\n", hs.at, hs.spin, neighbors_of(hs.at), parents_of(hs.at)); )
|
||||
heptspin correct = hs + wstep;
|
||||
SDEBUG( printf("correct is: %p.%d/%d (%d parents)\n", correct.h, correct.spin, neighbors_of(correct.h), parents_of(correct.h)); )
|
||||
SDEBUG( printf("correct is: %p.%d/%d (%d parents)\n", correct.at, correct.spin, neighbors_of(correct.at), parents_of(correct.at)); )
|
||||
heptspin hsl = hs0;
|
||||
correct = correct+1; correct.h->s++;
|
||||
connectHeptagons(hsl.h, hsl.spin, correct);
|
||||
correct = correct+1; correct.at->s++;
|
||||
connectHeptagons(hsl.at, hsl.spin, correct);
|
||||
hsl = hsl - 1 + wstep - 1;
|
||||
while(true) {
|
||||
SDEBUG( printf("hsl at %p.%d/%d (%d parents)\n", hsl.h, hsl.spin, neighbors_of(hsl.h), parents_of(hsl.h)); )
|
||||
if(hsl.spin == parents_of(hsl.h)) {
|
||||
SDEBUG( printf("hsl at %p.%d/%d (%d parents)\n", hsl.at, hsl.spin, neighbors_of(hsl.at), parents_of(hsl.at)); )
|
||||
if(hsl.spin == parents_of(hsl.at)) {
|
||||
SDEBUG(printf("go left\n"))
|
||||
hsl = hsl + wstep - 1;
|
||||
}
|
||||
else if(hsl.h->move[hsl.spin] && hsl.h->move[hsl.spin] != correct.h) {
|
||||
else if(hsl.peek() && hsl.peek() != correct.at) {
|
||||
SDEBUG(printf("prune\n");)
|
||||
if(neighbors_of(hsl.h->move[hsl.spin]) != neighbors_of(correct.h)) {
|
||||
if(neighbors_of(hsl.peek()) != neighbors_of(correct.at)) {
|
||||
SDEBUG(printf("neighbors mismatch while pruning %d -> %d\n",
|
||||
neighbors_of(hsl.h->move[hsl.spin]),
|
||||
neighbors_of(correct.h)
|
||||
neighbors_of(hsl.peek()),
|
||||
neighbors_of(correct.at)
|
||||
);)
|
||||
exit(1);
|
||||
}
|
||||
prune(hsl.h->move[hsl.spin]);
|
||||
prune(hsl.peek());
|
||||
}
|
||||
else if(hsl.h->move[hsl.spin] == NULL) {
|
||||
correct = correct+1; correct.h->s++;
|
||||
else if(hsl.peek() == NULL) {
|
||||
correct = correct+1; correct.at->s++;
|
||||
SDEBUG( printf("connect\n") )
|
||||
connectHeptagons(hsl.h, hsl.spin, correct);
|
||||
connectHeptagons(hsl.at, hsl.spin, correct);
|
||||
}
|
||||
else if(hsl.spin == parents_of(hsl.h)+1) {
|
||||
else if(hsl.spin == parents_of(hsl.at)+1) {
|
||||
SDEBUG( printf("single child so go left\n") )
|
||||
hsl = hsl - 1 + wstep - 1;
|
||||
}
|
||||
else { SDEBUG( printf("ready\n"); ) break; }
|
||||
}
|
||||
contract(correct.h);
|
||||
contract(correct.at);
|
||||
break;
|
||||
}
|
||||
case -2: {
|
||||
@ -409,7 +409,7 @@ void contract(heptagon *h) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!sphere) for(int i=0; i<neighbors_of(h); i++) if(!h->move[i]) {
|
||||
if(!sphere) for(int i=0; i<neighbors_of(h); i++) if(!h->move(i)) {
|
||||
auto uv = adjacent[id_of(h)][(parent_index_of(h) + i) % neighbors_of(h)];
|
||||
if(isize(adjacent[uv.first]) < 6) {
|
||||
SDEBUG( printf("prebuilding weak neighbor\n") )
|
||||
@ -432,8 +432,8 @@ void create_adjacent(heptagon *h, int d) {
|
||||
for(int i=0; i<nei; i++)
|
||||
build_child(h, i, p[i].first, p[i].second);
|
||||
for(int i=0; i<nei; i++) {
|
||||
heptagon *h1 = h->move[i];
|
||||
heptagon *h2 = h->move[(i+nei-1)%nei];
|
||||
heptagon *h1 = h->move(i);
|
||||
heptagon *h2 = h->move((i+nei-1)%nei);
|
||||
connectHeptagons(h1, 1, heptspin(h2, isize(adjacent[id_of(h2)])-1));
|
||||
}
|
||||
}
|
||||
@ -453,62 +453,62 @@ void create_adjacent(heptagon *h, int d) {
|
||||
else {
|
||||
build_siblings(h, 10);
|
||||
build_siblings(h, -10);
|
||||
if(h->move[d]) return;
|
||||
if(h->move(d)) return;
|
||||
heptspin hs(h, d);
|
||||
// make sure no contractions on the left
|
||||
heptspin hsl(h, d);
|
||||
int steps = 0;
|
||||
while(hsl.spin == parents_of(hsl.h) + 1 && steps < 100) {
|
||||
while(hsl.spin == parents_of(hsl.at) + 1 && steps < 100) {
|
||||
hsl = hsl - 1 + wstep - 1;
|
||||
steps++;
|
||||
}
|
||||
if(steps == 100) {
|
||||
SDEBUG( printf("generating top\n"); )
|
||||
auto uv = adjacent[id_of(hs.h)][(parent_index_of(hs.h) + hs.spin) % neighbors_of(hs.h)];
|
||||
heptagon *newchild = build_child(hs.h, hs.spin, uv.first, uv.second);
|
||||
auto uv = adjacent[id_of(hs.at)][(parent_index_of(hs.at) + hs.spin) % neighbors_of(hs.at)];
|
||||
heptagon *newchild = build_child(hs.at, hs.spin, uv.first, uv.second);
|
||||
hs = hs - 1 + wstep - 1;
|
||||
while(hs.h != h) {
|
||||
while(hs.at != h) {
|
||||
newchild->s++;
|
||||
connectHeptagons(hs.h, hs.spin, heptspin(newchild, newchild->s-1));
|
||||
connectHeptagons(hs.at, hs.spin, heptspin(newchild, newchild->s-1));
|
||||
hs = hs - 1 + wstep - 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// while trying to generate the last child, go right
|
||||
while(true) {
|
||||
if(h->move[d]) {
|
||||
if(h->move(d)) {
|
||||
SDEBUG( printf("solved itself\n"); )
|
||||
return;
|
||||
}
|
||||
SDEBUG( printf("going right at %p.%d/%d parents = %d\n", hs.h, hs.spin, neighbors_of(hs.h), parents_of(hs.h)); )
|
||||
SDEBUG( printf("going right at %p.%d/%d parents = %d\n", hs.at, hs.spin, neighbors_of(hs.at), parents_of(hs.at)); )
|
||||
// rightmost child
|
||||
if(hs.spin == right_sibling_of(hs.h) - 1)
|
||||
if(hs.spin == right_sibling_of(hs.at) - 1)
|
||||
hs = hs + 1 + wstep + 1;
|
||||
else if(children_of(hs.h) <= 0) {
|
||||
else if(children_of(hs.at) <= 0) {
|
||||
SDEBUG( printf("unexpected situation\n"); )
|
||||
return;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
auto uv = adjacent[id_of(hs.h)][(parent_index_of(hs.h) + hs.spin) % neighbors_of(hs.h)];
|
||||
heptagon *newchild = build_child(hs.h, hs.spin, uv.first, uv.second);
|
||||
auto uv = adjacent[id_of(hs.at)][(parent_index_of(hs.at) + hs.spin) % neighbors_of(hs.at)];
|
||||
heptagon *newchild = build_child(hs.at, hs.spin, uv.first, uv.second);
|
||||
bool add_parent = false;
|
||||
while(true) {
|
||||
SDEBUG( printf("going left at %p.%d/%d parents = %d\n", hs.h, hs.spin, neighbors_of(hs.h), parents_of(hs.h)); )
|
||||
SDEBUG( printf("going left at %p.%d/%d parents = %d\n", hs.at, hs.spin, neighbors_of(hs.at), parents_of(hs.at)); )
|
||||
// add parent
|
||||
if(hs.spin > parents_of(hs.h) && add_parent) {
|
||||
if(hs.spin > parents_of(hs.at) && add_parent) {
|
||||
SDEBUG( printf("add parent\n"); )
|
||||
newchild->s++;
|
||||
connectHeptagons(hs.h, hs.spin, heptspin(newchild, newchild->s-1));
|
||||
connectHeptagons(hs.at, hs.spin, heptspin(newchild, newchild->s-1));
|
||||
add_parent = false;
|
||||
}
|
||||
// childless
|
||||
if(children_of(hs.h) <= 0) {
|
||||
if(children_of(hs.at) <= 0) {
|
||||
SDEBUG( printf("unexpected situation v2\n"); )
|
||||
return;
|
||||
}
|
||||
// lefmost child
|
||||
else if(hs.spin == parents_of(hs.h)+1) {
|
||||
else if(hs.spin == parents_of(hs.at)+1) {
|
||||
SDEBUG( printf("(leftmost child)\n"); )
|
||||
hs = hs - 1 + wstep - 1;
|
||||
add_parent = true;
|
||||
@ -537,9 +537,9 @@ transmatrix adjcell_matrix(heptagon *h, int d) {
|
||||
int id = id_of(h);
|
||||
auto& t1 = triangles[id][(pindex + d)%S];
|
||||
|
||||
heptagon *h2 = h->move[d];
|
||||
heptagon *h2 = h->move(d);
|
||||
|
||||
int d2 = h->spin(d);
|
||||
int d2 = h->c.spin(d);
|
||||
int id2 = id_of(h2);
|
||||
int pindex2 = parent_index_of(h2);
|
||||
auto& t2 = triangles[id2][(pindex2 + d2) % neighbors_of(h2)];
|
||||
@ -551,7 +551,7 @@ transmatrix adjcell_matrix(heptagon *h, int d) {
|
||||
|
||||
void draw() {
|
||||
visited.clear();
|
||||
enqueue(viewctr.h, cview());
|
||||
enqueue(viewctr.at, cview());
|
||||
int idx = 0;
|
||||
|
||||
while(!drawqueue.empty()) {
|
||||
@ -568,8 +568,8 @@ void draw() {
|
||||
}
|
||||
|
||||
for(int i=0; i<S; i++) {
|
||||
if(nonbitrunc && id >= 2*N && h->move[i] && id_of(h->move[i]) >= 2*N) continue;
|
||||
enqueue(h->move[i], V * adjcell_matrix(h, i));
|
||||
if(nonbitrunc && id >= 2*N && h->move(i) && id_of(h->move(i)) >= 2*N) continue;
|
||||
enqueue(h->move(i), V * adjcell_matrix(h, i));
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
@ -580,16 +580,16 @@ transmatrix relative_matrix(heptagon *h2, heptagon *h1) {
|
||||
return inverse(gmatrix0[h1->c7]) * gmatrix0[h2->c7];
|
||||
transmatrix gm = Id, where = Id;
|
||||
while(h1 != h2) {
|
||||
for(int i=0; i<neighbors_of(h1); i++) if(h1->move[i] == h2) {
|
||||
for(int i=0; i<neighbors_of(h1); i++) if(h1->move(i) == h2) {
|
||||
return gm * adjcell_matrix(h1, i) * where;
|
||||
}
|
||||
else if(h1->distance > h2->distance) {
|
||||
gm = gm * adjcell_matrix(h1, 0);
|
||||
h1 = h1->move[0];
|
||||
h1 = h1->move(0);
|
||||
}
|
||||
else {
|
||||
where = inverse(adjcell_matrix(h2, 0)) * where;
|
||||
h2 = h2->move[0];
|
||||
h2 = h2->move(0);
|
||||
}
|
||||
}
|
||||
return gm * where;
|
||||
|
50
system.cpp
50
system.cpp
@ -120,25 +120,25 @@ void initgame() {
|
||||
if((isGravityLand(firstland) && !isCyclic(firstland)) || (firstland == laOcean && !safety && !yendor::on))
|
||||
firstland = weirdhyperbolic ? laCrossroads4 : laCrossroads;
|
||||
|
||||
cwt.c = currentmap->gamestart(); cwt.spin = 0; cwt.mirrored = false;
|
||||
cwt.c->land = firstland;
|
||||
cwt.at = currentmap->gamestart(); cwt.spin = 0; cwt.mirrored = false;
|
||||
cwt.at->land = firstland;
|
||||
|
||||
chaosAchieved = false;
|
||||
|
||||
if(firstland == laElementalWall) cwt.c->land = randomElementalLand();
|
||||
if(firstland == laElementalWall) cwt.at->land = randomElementalLand();
|
||||
|
||||
createMov(cwt.c, 0);
|
||||
createMov(cwt.at, 0);
|
||||
|
||||
setdist(cwt.c, BARLEV, NULL);
|
||||
setdist(cwt.at, BARLEV, NULL);
|
||||
|
||||
if((tactic::on || yendor::on || peace::on) && isCyclic(firstland)) {
|
||||
anthraxBonus = items[itHolyGrail];
|
||||
cwt.c->mov[0]->land = firstland;
|
||||
if(firstland == laWhirlpool) cwt.c->mov[0]->wall = waSea;
|
||||
cwt.at->move(0)->land = firstland;
|
||||
if(firstland == laWhirlpool) cwt.at->move(0)->wall = waSea;
|
||||
|
||||
setdist(cwt.c->mov[0], BARLEV-1, cwt.c);
|
||||
setdist(cwt.at->move(0), BARLEV-1, cwt.at);
|
||||
if(!sphere && !euclid) {
|
||||
heptagon *h = createAlternateMap(cwt.c, 2, hsA);
|
||||
heptagon *h = createAlternateMap(cwt.at, 2, hsA);
|
||||
if(!h) printf("FAIL\n");
|
||||
}
|
||||
}
|
||||
@ -172,10 +172,10 @@ void initgame() {
|
||||
princess::generating = false;
|
||||
}
|
||||
|
||||
if(cwt.c->land == laCrossroads2) {
|
||||
cwt.c->landparam = 12;
|
||||
createMov(cwt.c, 0)->landparam = 44;
|
||||
createMov(cwt.c, 0)->land = laCrossroads2;
|
||||
if(cwt.at->land == laCrossroads2) {
|
||||
cwt.at->landparam = 12;
|
||||
createMov(cwt.at, 0)->landparam = 44;
|
||||
createMov(cwt.at, 0)->land = laCrossroads2;
|
||||
}
|
||||
|
||||
for(int i=0; i<numplayers(); i++) sword::angle[i] = 11;
|
||||
@ -193,10 +193,10 @@ void initgame() {
|
||||
#endif
|
||||
|
||||
// extern int sightrange; sightrange = 9;
|
||||
// cwt.c->land = laHell; items[itHell] = 10;
|
||||
// cwt.at->land = laHell; items[itHell] = 10;
|
||||
for(int i=BARLEV; i>=7 - getDistLimit() - genrange_bonus; i--) {
|
||||
if(tactic::trailer && cwt.c->land != laClearing) safety = trailer_safety;
|
||||
setdist(cwt.c, i, NULL);
|
||||
if(tactic::trailer && cwt.at->land != laClearing) safety = trailer_safety;
|
||||
setdist(cwt.at, i, NULL);
|
||||
if(tactic::trailer) safety = false;
|
||||
|
||||
currentmap->verify();
|
||||
@ -218,14 +218,14 @@ void initgame() {
|
||||
|
||||
|
||||
if(multi::players > 1 && !shmup::on) for(int i=0; i<numplayers(); i++) {
|
||||
int idir = (3 * i) % cwt.c->type;
|
||||
multi::player[i].c = cwt.c->mov[idir];
|
||||
int idir = (3 * i) % cwt.at->type;
|
||||
multi::player[i].at = cwt.at->move(idir);
|
||||
// special case -- otherwise they land on a wall
|
||||
if(firstland == laCrossroads2 && i == 1)
|
||||
multi::player[1].c = cwt.c;
|
||||
multi::player[1].at = cwt.at;
|
||||
if(firstland == laCrossroads2 && i == 6)
|
||||
multi::player[6].c = createMov(createMov(cwt.c, 0), 3);
|
||||
setdist(cwt.c->mov[idir], 7 - getDistLimit() - genrange_bonus, cwt.c);
|
||||
multi::player[6].at = createMov(createMov(cwt.at, 0), 3);
|
||||
setdist(cwt.at->move(idir), 7 - getDistLimit() - genrange_bonus, cwt.at);
|
||||
multi::player[i].spin = 0;
|
||||
multi::flipped[i] = true;
|
||||
multi::whereto[i].d = MD_UNDECIDED;
|
||||
@ -248,7 +248,7 @@ void initgame() {
|
||||
}
|
||||
else {
|
||||
for(int i=0; i<numplayers(); i++)
|
||||
makeEmpty(cwt.c);
|
||||
makeEmpty(cwt.at);
|
||||
}
|
||||
|
||||
princess::squeaked = false;
|
||||
@ -438,7 +438,7 @@ void applyBoxes() {
|
||||
applyBoxNum(cheater, "number of cheats");
|
||||
|
||||
fakebox[boxid] = true;
|
||||
if(saving) applyBoxSave(items[itOrbSafety] ? safetyland : cwt.c->land, "");
|
||||
if(saving) applyBoxSave(items[itOrbSafety] ? safetyland : cwt.at->land, "");
|
||||
else if(loading) firstland = safetyland = eLand(applyBoxLoad());
|
||||
else lostin = eLand(savebox[boxid++]);
|
||||
|
||||
@ -865,7 +865,7 @@ void saveStats(bool emergency = false) {
|
||||
fprintf(f, "Number of cells explored, by distance from the player:\n");
|
||||
{for(int i=0; i<10; i++) fprintf(f, " %d", explore[i]);} fprintf(f, "\n");
|
||||
if(kills[0]) fprintf(f, "walls melted: %d\n", kills[0]);
|
||||
fprintf(f, "cells travelled: %d\n", celldist(cwt.c));
|
||||
fprintf(f, "cells travelled: %d\n", celldist(cwt.at));
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
@ -1122,7 +1122,7 @@ void stop_game() {
|
||||
void push_game() {
|
||||
gamestack::push();
|
||||
pd_from = NULL;
|
||||
centerover.c = NULL;
|
||||
centerover.at = NULL;
|
||||
game_active = false;
|
||||
}
|
||||
|
||||
|
12
textures.cpp
12
textures.cpp
@ -846,7 +846,7 @@ bool texture_config::save() {
|
||||
targetgeometry = geometry;
|
||||
target_nonbitru = nonbitrunc;
|
||||
|
||||
cell *ctr = euclid ? centerover.c : viewctr.h->c7;
|
||||
cell *ctr = euclid ? centerover.at : viewctr.at->c7;
|
||||
si_save = patterns::getpatterninfo0(ctr);
|
||||
|
||||
for(auto s: texturesavers) if(s->dosave())
|
||||
@ -892,11 +892,11 @@ bool texture_config::load() {
|
||||
celllister cl(currentmap->gamestart(), 20, 10000, NULL);
|
||||
bool found = false;
|
||||
for(cell *c: cl.lst) if(euclid || ctof(c)) {
|
||||
cell *ctr = euclid ? centerover.c : viewctr.h->c7;
|
||||
cell *ctr = euclid ? centerover.at : viewctr.at->c7;
|
||||
auto si_here = patterns::getpatterninfo0(c);
|
||||
if(si_here.id == si_save.id && si_here.reflect == si_save.reflect && si_here.dir == si_save.dir) {
|
||||
if(euclid) centerover.c = ctr;
|
||||
else viewctr.h = ctr->master;
|
||||
if(euclid) centerover.at = ctr;
|
||||
else viewctr.at = ctr->master;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@ -1174,7 +1174,7 @@ void showMenu() {
|
||||
|
||||
#if CAP_EDIT
|
||||
else if(uni == 'e' && config.tstate == tsActive) {
|
||||
mapeditor::initdraw(cwt.c);
|
||||
mapeditor::initdraw(cwt.at);
|
||||
pushScreen(mapeditor::showDrawEditor);
|
||||
}
|
||||
|
||||
@ -1184,7 +1184,7 @@ void showMenu() {
|
||||
config.tstate = config.tstate_max = tsActive;
|
||||
config.perform_mapping();
|
||||
config.finish_mapping();
|
||||
mapeditor::initdraw(cwt.c);
|
||||
mapeditor::initdraw(cwt.at);
|
||||
pushScreen(mapeditor::showDrawEditor);
|
||||
}
|
||||
}
|
||||
|
24
tour.cpp
24
tour.cpp
@ -136,7 +136,7 @@ bool handleKeyTour(int sym, int uni) {
|
||||
|
||||
if(sym == '2') {
|
||||
dynamicval<eGeometry> g(geometry, gEuclid);
|
||||
if(cwt.c->land != laCanvas && !land_validity(cwt.c->land).quality_level) {
|
||||
if(cwt.at->land != laCanvas && !land_validity(cwt.at->land).quality_level) {
|
||||
addMessage(XLAT("This land has no Euclidean version."));
|
||||
return true;
|
||||
}
|
||||
@ -144,7 +144,7 @@ bool handleKeyTour(int sym, int uni) {
|
||||
|
||||
if(sym == '1') {
|
||||
dynamicval<eGeometry> g(geometry, gSphere);
|
||||
if(cwt.c->land != laCanvas && !land_validity(cwt.c->land).quality_level) {
|
||||
if(cwt.at->land != laCanvas && !land_validity(cwt.at->land).quality_level) {
|
||||
addMessage(XLAT("This land has no spherical version."));
|
||||
return true;
|
||||
}
|
||||
@ -160,7 +160,7 @@ bool handleKeyTour(int sym, int uni) {
|
||||
if(sym == '1') targetgeometry = gSphere, vid.alpha = 1, vid.scale = .5;
|
||||
if(sym == '2') targetgeometry = gEuclid, vid.alpha = 1, vid.scale = .5;
|
||||
|
||||
firstland = specialland = cwt.c->land;
|
||||
firstland = specialland = cwt.at->land;
|
||||
push_game();
|
||||
switch_game_mode(sym == '3' ? rg::bitrunc : rg::geometry);
|
||||
start_game();
|
||||
@ -171,8 +171,8 @@ bool handleKeyTour(int sym, int uni) {
|
||||
if(sym == '2') x = XLAT("Euclidean version of %the1. ", s0 + "'" + slides[currentslide].name + "'");
|
||||
}
|
||||
else {
|
||||
if(sym == '1') x = XLAT("Spherical version of %the1. ", cwt.c->land);
|
||||
if(sym == '2') x = XLAT("Euclidean version of %the1. ", cwt.c->land);
|
||||
if(sym == '1') x = XLAT("Spherical version of %the1. ", cwt.at->land);
|
||||
if(sym == '2') x = XLAT("Euclidean version of %the1. ", cwt.at->land);
|
||||
}
|
||||
if(mousing)
|
||||
addMessage(x + XLAT("Click again to go back to your game."));
|
||||
@ -383,9 +383,9 @@ slide default_slides[] = {
|
||||
[] (presmode mode) {
|
||||
slidecommand = "gain Ice Diamonds";
|
||||
if(mode == 4)
|
||||
forCellEx(c2, cwt.c)
|
||||
forCellEx(c2, cwt.at)
|
||||
forCellEx(c3, c2)
|
||||
if(c3->wall == waNone && c3->item == itNone && c3->monst == moNone && c3 != cwt.c)
|
||||
if(c3->wall == waNone && c3->item == itNone && c3->monst == moNone && c3 != cwt.at)
|
||||
c3->item = itDiamond;
|
||||
SHOWLAND( l == laIce );
|
||||
}
|
||||
@ -456,8 +456,8 @@ slide default_slides[] = {
|
||||
[] (presmode mode) {
|
||||
setCanvas(mode, 'F');
|
||||
if(mode == 5) {
|
||||
cwt.c->mov[0]->monst = moRunDog;
|
||||
cwt.c->mov[1]->monst = moGoblin;
|
||||
cwt.at->move(0)->monst = moRunDog;
|
||||
cwt.at->move(1)->monst = moGoblin;
|
||||
}
|
||||
SHOWLAND( l == laCanvas );
|
||||
}
|
||||
@ -582,7 +582,7 @@ slide default_slides[] = {
|
||||
if(mode == 1)
|
||||
pmodel = mdHalfplane;
|
||||
if(mode == 2)
|
||||
conformal::rotation = cwt.c->land == laDungeon ? 0 : 2;
|
||||
conformal::rotation = cwt.at->land == laDungeon ? 0 : 2;
|
||||
if(mode == 3) pmodel = mdDisk, conformal::rotation = 0;
|
||||
}
|
||||
},
|
||||
@ -664,7 +664,7 @@ slide default_slides[] = {
|
||||
[] (presmode mode) {
|
||||
slidecommand = "create a baby tortoise";
|
||||
if(mode == 4) {
|
||||
cell *c = cwt.c->mov[0];
|
||||
cell *c = cwt.at->move(0);
|
||||
c->item = itBabyTortoise;
|
||||
tortoise::babymap[c] = getBits(c) ^ tortoise::getRandomBits();
|
||||
}
|
||||
@ -762,7 +762,7 @@ slide default_slides[] = {
|
||||
"focus on a particular challenge.",
|
||||
[] (presmode mode) {
|
||||
if(mode == 1) {
|
||||
firstland = cwt.c->land;
|
||||
firstland = cwt.at->land;
|
||||
push_game();
|
||||
switch_game_mode(rg::shmup);
|
||||
start_game();
|
||||
|
24
yendor.cpp
24
yendor.cpp
@ -185,16 +185,16 @@ namespace yendor {
|
||||
bool in_endorian = false;
|
||||
cellwalker lig(yendor, hrand(yendor->type));
|
||||
for(int i=0; i<YDIST-1; i++) {
|
||||
if(lig.c->land == laEndorian)
|
||||
if(lig.at->land == laEndorian)
|
||||
in_endorian = true;
|
||||
else if(!isTechnicalLand(lig.c->land))
|
||||
else if(!isTechnicalLand(lig.at->land))
|
||||
in_endorian = false;
|
||||
nyi.path[i] = lig.c;
|
||||
nyi.path[i] = lig.at;
|
||||
|
||||
lig += wstep;
|
||||
if(inmirror(lig)) lig = mirror::reflect(lig);
|
||||
lig += 3;
|
||||
if(lig.c->type == 7) {
|
||||
if(lig.at->type == 7) {
|
||||
if(in_endorian && endorian_change && i >= YDIST - 20) {
|
||||
// make the last leg a bit more difficult
|
||||
lig += (hrand(2)*3-1);
|
||||
@ -204,7 +204,7 @@ namespace yendor {
|
||||
lig += hrand(2);
|
||||
}
|
||||
}
|
||||
nyi.path[YDIST-1] = lig.c;
|
||||
nyi.path[YDIST-1] = lig.at;
|
||||
}
|
||||
|
||||
generating = true;
|
||||
@ -242,7 +242,7 @@ namespace yendor {
|
||||
for(int b=10; b>=5; b--) setdist(key, b, nyi.path[YDIST-2]);
|
||||
|
||||
for(int i=-1; i<key->type; i++) {
|
||||
cell *c2 = i >= 0 ? key->mov[i] : key;
|
||||
cell *c2 = i >= 0 ? key->move(i) : key;
|
||||
checkTide(c2);
|
||||
c2->monst = moNone; c2->item = itNone;
|
||||
if(!passable(c2, NULL, P_MIRROR | P_MONSTER)) {
|
||||
@ -264,7 +264,7 @@ namespace yendor {
|
||||
if(c2->land == laLivefjord) {
|
||||
c2->wall = waSea;
|
||||
for(int i=0; i<c2->type; i++)
|
||||
c2->mov[i]->wall = waSea;
|
||||
c2->move(i)->wall = waSea;
|
||||
}
|
||||
if(isGravityLand(c2->land) && key->land == c2->land &&
|
||||
c2->landparam < key->landparam && c2->wall != waTrunk)
|
||||
@ -337,7 +337,7 @@ namespace yendor {
|
||||
}
|
||||
|
||||
if(phase == 2) {
|
||||
cell *c2 = cwt.c->mov[0];
|
||||
cell *c2 = cwt.at->move(0);
|
||||
c2->land = firstland;
|
||||
if(firstland == laRlyeh) c2->wall = waNone;
|
||||
yendor::check(c2);
|
||||
@ -371,11 +371,11 @@ namespace yendor {
|
||||
}
|
||||
|
||||
if(phase == 3) {
|
||||
cell *c2 = cwt.c->mov[0];
|
||||
cell *c2 = cwt.at->move(0);
|
||||
makeEmpty(c2);
|
||||
c2->item = itOrbYendor;
|
||||
nexttostart = laNone;
|
||||
if(clev().flags & YF_RECALL) recallCell = cwt.c;
|
||||
if(clev().flags & YF_RECALL) recallCell = cwt.at;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1032,12 +1032,12 @@ namespace peace {
|
||||
tobuild = 0;
|
||||
if(!on) return;
|
||||
if(otherpuzzles) { items[itGreenStone] = 500; return; }
|
||||
cell *c2 = cwt.c->mov[0];
|
||||
cell *c2 = cwt.at->move(0);
|
||||
makeEmpty(c2);
|
||||
c2->item = itOrbYendor;
|
||||
|
||||
path.clear();
|
||||
path.push_back(cwt.c);
|
||||
path.push_back(cwt.at);
|
||||
path.push_back(c2);
|
||||
extend();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user