mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-17 11:30:09 +00:00
Merge remote work
This commit is contained in:
commit
039e56edfe
26
bigstuff.cpp
26
bigstuff.cpp
@ -105,6 +105,8 @@ void generateAlts(heptagon *h, int levs, bool link_cdata) {
|
|||||||
if(!h->alt) return;
|
if(!h->alt) return;
|
||||||
preventbarriers(h->c7);
|
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->mov[i]);
|
||||||
|
if(whirl::whirl)
|
||||||
|
for(int i=0; i<S7; i++) preventbarriers(createStep(h, i)->c7);
|
||||||
for(int i=0; i<S7; i++)
|
for(int i=0; i<S7; i++)
|
||||||
createStep(h->alt, i)->alt = h->alt->alt;
|
createStep(h->alt, i)->alt = h->alt->alt;
|
||||||
int relspin = -4; // for horocycles it must go the other way
|
int relspin = -4; // for horocycles it must go the other way
|
||||||
@ -953,6 +955,13 @@ bool mouse_reachability_test(cell *c) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool horo_ok() {
|
||||||
|
if(!hyperbolic) return false;
|
||||||
|
if(!whirl::whirl) return true;
|
||||||
|
if(whirl::param.second) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void buildBigStuff(cell *c, cell *from) {
|
void buildBigStuff(cell *c, cell *from) {
|
||||||
if(sphere || quotient) return;
|
if(sphere || quotient) return;
|
||||||
bool deepOcean = false;
|
bool deepOcean = false;
|
||||||
@ -1050,7 +1059,7 @@ void buildBigStuff(cell *c, cell *from) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((!chaosmode) && bearsCamelot(c->land) && ctof(c) &&
|
if((!chaosmode) && bearsCamelot(c->land) && ctof(c) &&
|
||||||
(quickfind(laCamelot) || peace::on || (hrand(I2000) < 200 && !whirl::whirl &&
|
(quickfind(laCamelot) || peace::on || (hrand(I2000) < 200 && horo_ok() &&
|
||||||
items[itEmerald] >= U5 && !tactic::on))) {
|
items[itEmerald] >= U5 && !tactic::on))) {
|
||||||
int rtr = newRoundTableRadius();
|
int rtr = newRoundTableRadius();
|
||||||
heptagon *alt = createAlternateMap(c, rtr+14, hsOrigin);
|
heptagon *alt = createAlternateMap(c, rtr+14, hsOrigin);
|
||||||
@ -1071,7 +1080,7 @@ void buildBigStuff(cell *c, cell *from) {
|
|||||||
createAlternateMap(c, 2, hsA);
|
createAlternateMap(c, 2, hsA);
|
||||||
|
|
||||||
if(c->land == laJungle && ctof(c) &&
|
if(c->land == laJungle && ctof(c) &&
|
||||||
(quickfind(laMountain) || (hrand(I2000) < 100 && !whirl::whirl &&
|
(quickfind(laMountain) || (hrand(I2000) < 100 && horo_ok() &&
|
||||||
!randomPatternsMode && !tactic::on && !yendor::on && landUnlocked(laMountain))))
|
!randomPatternsMode && !tactic::on && !yendor::on && landUnlocked(laMountain))))
|
||||||
createAlternateMap(c, 2, hsA);
|
createAlternateMap(c, 2, hsA);
|
||||||
|
|
||||||
@ -1084,20 +1093,20 @@ void buildBigStuff(cell *c, cell *from) {
|
|||||||
if(h) clearing::bpdata[h].root = NULL;
|
if(h) clearing::bpdata[h].root = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c->land == laStorms && ctof(c) && hrand(2000) < 1000 && !whirl::whirl && !randomPatternsMode) {
|
if(c->land == laStorms && ctof(c) && hrand(2000) < 1000 && horo_ok() && !randomPatternsMode) {
|
||||||
heptagon *h = createAlternateMap(c, 2, hsA);
|
heptagon *h = createAlternateMap(c, 2, hsA);
|
||||||
if(h) h->alt->emeraldval = hrand(2);
|
if(h) h->alt->emeraldval = hrand(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c->land == laOcean && ctof(c) && deepOcean && !generatingEquidistant && !peace::on && !whirl::whirl &&
|
if(c->land == laOcean && ctof(c) && deepOcean && !generatingEquidistant && !peace::on && horo_ok() &&
|
||||||
(quickfind(laWhirlpool) || (
|
(quickfind(laWhirlpool) || (
|
||||||
hrand(2000) < (nonbitrunc ? 500 : 1000) && !tactic::on && !yendor::on)))
|
hrand(2000) < (nonbitrunc ? 500 : 1000) && !tactic::on && !yendor::on)))
|
||||||
createAlternateMap(c, 2, hsA);
|
createAlternateMap(c, 2, hsA);
|
||||||
|
|
||||||
if(c->land == laCaribbean && !whirl::whirl && ctof(c))
|
if(c->land == laCaribbean && horo_ok() && ctof(c))
|
||||||
createAlternateMap(c, 2, hsA);
|
createAlternateMap(c, 2, hsA);
|
||||||
|
|
||||||
if(c->land == laPalace && ctof(c) && !princess::generating && !shmup::on && multi::players == 1 && !whirl::whirl &&
|
if(c->land == laPalace && ctof(c) && !princess::generating && !shmup::on && multi::players == 1 && horo_ok() &&
|
||||||
(princess::forceMouse ? mouse_reachability_test(from) :
|
(princess::forceMouse ? mouse_reachability_test(from) :
|
||||||
(hrand(2000) < (peace::on ? 100 : 20))) &&
|
(hrand(2000) < (peace::on ? 100 : 20))) &&
|
||||||
!c->master->alt &&
|
!c->master->alt &&
|
||||||
@ -1253,7 +1262,10 @@ void moreBigStuff(cell *c) {
|
|||||||
c->land = laTemple, c->wall = waNone, c->monst = moNone, c->item = itNone;
|
c->land = laTemple, c->wall = waNone, c->monst = moNone, c->item = itNone;
|
||||||
}
|
}
|
||||||
if(d % TEMPLE_EACH==0) {
|
if(d % TEMPLE_EACH==0) {
|
||||||
if((weirdhyperbolic && nonbitrunc) ? hrand(100) < 50 : pseudohept(c))
|
if(weirdhyperbolic && nonbitrunc) {
|
||||||
|
if(hrand(100) < 50) c->wall = waColumn;
|
||||||
|
}
|
||||||
|
else if(pseudohept(c))
|
||||||
c->wall = waColumn;
|
c->wall = waColumn;
|
||||||
else {
|
else {
|
||||||
if(!euclid) for(int i=0; i<S7; i++) generateAlts(c->master->move[i]);
|
if(!euclid) for(int i=0; i<S7; i++) generateAlts(c->master->move[i]);
|
||||||
|
19
cell.cpp
19
cell.cpp
@ -983,6 +983,7 @@ int celldist(cell *c) {
|
|||||||
}
|
}
|
||||||
if(sphere) return celldistance(c, currentmap->gamestart());
|
if(sphere) return celldistance(c, currentmap->gamestart());
|
||||||
if(ctof(c)) return c->master->distance;
|
if(ctof(c)) return c->master->distance;
|
||||||
|
if(whirl::whirl) return whirl::compute_dist(c, celldist);
|
||||||
int dx[MAX_S3];
|
int dx[MAX_S3];
|
||||||
for(int u=0; u<S3; u++)
|
for(int u=0; u<S3; u++)
|
||||||
dx[u] = createMov(c, u+u)->master->distance;
|
dx[u] = createMov(c, u+u)->master->distance;
|
||||||
@ -1009,6 +1010,7 @@ int celldistAlt(cell *c) {
|
|||||||
}
|
}
|
||||||
if(!c->master->alt) return 0;
|
if(!c->master->alt) return 0;
|
||||||
if(ctof(c)) return c->master->alt->distance;
|
if(ctof(c)) return c->master->alt->distance;
|
||||||
|
if(whirl::whirl) return whirl::compute_dist(c, celldistAlt);
|
||||||
int dx[MAX_S3]; dx[0] = 0;
|
int dx[MAX_S3]; dx[0] = 0;
|
||||||
for(int u=0; u<S3; u++) if(createMov(c, u+u)->master->alt == NULL)
|
for(int u=0; u<S3; u++) if(createMov(c, u+u)->master->alt == NULL)
|
||||||
return ALTDIST_UNKNOWN;
|
return ALTDIST_UNKNOWN;
|
||||||
@ -1342,6 +1344,23 @@ cell *heptatdir(cell *c, int d) {
|
|||||||
else return createMov(c, d);
|
else return createMov(c, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int heptdistance(heptagon *h1, heptagon *h2) {
|
||||||
|
// very rough distance
|
||||||
|
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;
|
||||||
|
int d1 = h1->distance, d2 = h2->distance;
|
||||||
|
if(d1 >= d2) d++, h1 = h1->move[0];
|
||||||
|
if(d2 >= d1) d++, h2 = h2->move[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int heptdistance(cell *c1, cell *c2) {
|
||||||
|
if(!hyperbolic || quotient) return celldistance(c1, c2);
|
||||||
|
else return heptdistance(c1->master, c2->master);
|
||||||
|
}
|
||||||
|
|
||||||
int celldistance(cell *c1, cell *c2) {
|
int celldistance(cell *c1, cell *c2) {
|
||||||
int d = 0;
|
int d = 0;
|
||||||
|
|
||||||
|
@ -321,7 +321,10 @@ void debugScreen() {
|
|||||||
dialog::addSelItem("cpdist", its(mouseover->cpdist), 0);
|
dialog::addSelItem("cpdist", its(mouseover->cpdist), 0);
|
||||||
dialog::addSelItem("celldist", its(celldist(mouseover)), 0);
|
dialog::addSelItem("celldist", its(celldist(mouseover)), 0);
|
||||||
dialog::addSelItem("pathdist", its(mouseover->pathdist), 0);
|
dialog::addSelItem("pathdist", its(mouseover->pathdist), 0);
|
||||||
|
dialog::addSelItem("celldistAlt", mouseover->master->alt ? its(celldistAlt(mouseover)) : "--", 0);
|
||||||
dialog::addSelItem("temporary", its(mouseover->aitmp), 0);
|
dialog::addSelItem("temporary", its(mouseover->aitmp), 0);
|
||||||
|
if(whirl::whirl)
|
||||||
|
dialog::addSelItem("whirl", whirl::disp(whirl::get_local_info(mouseover).relative), 0);
|
||||||
dialog::addBreak(50);
|
dialog::addBreak(50);
|
||||||
dialog::addSelItem("monster", dnameof2(mouseover->monst, mouseover->mondir), 0);
|
dialog::addSelItem("monster", dnameof2(mouseover->monst, mouseover->mondir), 0);
|
||||||
dialog::addSelItem("stuntime/hitpoints", its(mouseover->stuntime)+"/"+its(mouseover->hitpoints), 0);
|
dialog::addSelItem("stuntime/hitpoints", its(mouseover->stuntime)+"/"+its(mouseover->hitpoints), 0);
|
||||||
|
@ -5925,6 +5925,8 @@ cell *viewcenter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool inscreenrange(cell *c) {
|
bool inscreenrange(cell *c) {
|
||||||
return celldistance(viewcenter(), c) <= (euclid ? get_sightrange() : nonbitrunc ? 9 : 13);
|
if(sphere) return true;
|
||||||
|
if(euclid) return celldistance(viewcenter(), c) <= get_sightrange();
|
||||||
|
return heptdistance(viewcenter(), c) <= 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
|||||||
if(pard == 0) {
|
if(pard == 0) {
|
||||||
h->dm4 = parent->dm4+1;
|
h->dm4 = parent->dm4+1;
|
||||||
if(fixdistance != COMPUTE) h->distance = fixdistance;
|
if(fixdistance != COMPUTE) h->distance = fixdistance;
|
||||||
|
else if(whirl::whirl) h->distance = parent->distance + whirl::param.first;
|
||||||
else if(nonbitrunc) h->distance = parent->distance + 1;
|
else if(nonbitrunc) h->distance = parent->distance + 1;
|
||||||
else if(parent->s == hsOrigin) h->distance = parent->distance + 2;
|
else if(parent->s == hsOrigin) h->distance = parent->distance + 2;
|
||||||
else if(S3 == 4) {
|
else if(S3 == 4) {
|
||||||
@ -128,7 +129,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
|||||||
else h->distance = parent->distance + 2;
|
else h->distance = parent->distance + 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
h->distance = parent->distance - (nonbitrunc?1:2);
|
h->distance = parent->distance - (whirl::whirl?whirl::param.first:nonbitrunc?1:2);
|
||||||
if(S3 == 4 && S7 == 5) {
|
if(S3 == 4 && S7 == 5) {
|
||||||
if(h->s == hsOrigin) {
|
if(h->s == hsOrigin) {
|
||||||
printf("had to cheat!\n");
|
printf("had to cheat!\n");
|
||||||
|
3
hyper.h
3
hyper.h
@ -2714,6 +2714,7 @@ inline hyperpoint tC0(const transmatrix &T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
transmatrix actualV(const heptspin& hs, const transmatrix& V);
|
transmatrix actualV(const heptspin& hs, const transmatrix& V);
|
||||||
|
transmatrix applyspin(const heptspin& hs, const transmatrix& V);
|
||||||
transmatrix cview();
|
transmatrix cview();
|
||||||
|
|
||||||
extern string bitruncnames[2];
|
extern string bitruncnames[2];
|
||||||
@ -2981,6 +2982,8 @@ namespace whirl {
|
|||||||
|
|
||||||
local_info get_local_info(cell *c);
|
local_info get_local_info(cell *c);
|
||||||
const char *disp(loc at);
|
const char *disp(loc at);
|
||||||
|
|
||||||
|
int compute_dist(cell *c, int master_function(cell*));
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_sightrange();
|
int get_sightrange();
|
||||||
|
@ -456,6 +456,10 @@ transmatrix actualV(const heptspin& hs, const transmatrix& V) {
|
|||||||
return (hs.spin || nonbitrunc) ? V * spin(hs.spin*2*M_PI/S7 + (nonbitrunc ? M_PI:0) + whirl::alpha) : V;
|
return (hs.spin || nonbitrunc) ? V * spin(hs.spin*2*M_PI/S7 + (nonbitrunc ? M_PI:0) + whirl::alpha) : V;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transmatrix applyspin(const heptspin& hs, const transmatrix& V) {
|
||||||
|
return (hs.spin || nonbitrunc) ? V * spin(hs.spin*2*M_PI/S7) : V;
|
||||||
|
}
|
||||||
|
|
||||||
namespace whirl {
|
namespace whirl {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
13
pattern2.cpp
13
pattern2.cpp
@ -960,6 +960,17 @@ int pattern_threecolor(cell *c) {
|
|||||||
}
|
}
|
||||||
if(S7 == 4 && S3 == 3) {
|
if(S7 == 4 && S3 == 3) {
|
||||||
int codesN[6] = {0,1,2,1,2,0};
|
int codesN[6] = {0,1,2,1,2,0};
|
||||||
|
if(whirl::whirl) {
|
||||||
|
auto li = whirl::get_local_info(c);
|
||||||
|
int sp = (MODFIXER + li.relative.first + 2 * li.relative.second) % 3;
|
||||||
|
if(sp != 0) {
|
||||||
|
if(li.last_dir & 1)
|
||||||
|
sp = 3 - sp;
|
||||||
|
if(among(c->master->fiftyval, 1, 3, 5))
|
||||||
|
sp = 3 - sp;
|
||||||
|
}
|
||||||
|
return sp;
|
||||||
|
}
|
||||||
if(nonbitrunc)
|
if(nonbitrunc)
|
||||||
return codesN[c->master->fiftyval];
|
return codesN[c->master->fiftyval];
|
||||||
if(ctof(c))
|
if(ctof(c))
|
||||||
@ -1252,7 +1263,7 @@ namespace patterns {
|
|||||||
if(nonbitrunc && S3 == 4)
|
if(nonbitrunc && S3 == 4)
|
||||||
dialog::addBoolItem(XLAT("chessboard"), (whichPattern == PAT_CHESS), PAT_CHESS);
|
dialog::addBoolItem(XLAT("chessboard"), (whichPattern == PAT_CHESS), PAT_CHESS);
|
||||||
|
|
||||||
if(a38 || a46 || euclid || S3 == 4)
|
if(a38 || a46 || euclid || S3 == 4 || S7 == 4)
|
||||||
dialog::addBoolItem(XLAT("coloring"), (whichPattern == PAT_COLORING), PAT_COLORING);
|
dialog::addBoolItem(XLAT("coloring"), (whichPattern == PAT_COLORING), PAT_COLORING);
|
||||||
|
|
||||||
if(sphere)
|
if(sphere)
|
||||||
|
11
polygons.cpp
11
polygons.cpp
@ -607,7 +607,16 @@ void drawpolyline(polytodraw& p) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
glLineWidth(linewidthat(tC0(pp.V), pp.minwidth));
|
glLineWidth(linewidthat(tC0(pp.V), pp.minwidth));
|
||||||
gldraw(3, Id, glcoords, 0, size(glcoords), p.col, pp.outline, poly_flags, pp.tinf);
|
if(pp.tinf && pp.offset) {
|
||||||
|
vector<glvertex> tv;
|
||||||
|
for(int i=0; i<pp.cnt; i++)
|
||||||
|
tv.push_back(pp.tinf->tvertices[pp.offset+i]);
|
||||||
|
swap(pp.tinf->tvertices, tv);
|
||||||
|
gldraw(3, Id, glcoords, 0, size(glcoords), p.col, pp.outline, poly_flags, pp.tinf);
|
||||||
|
swap(pp.tinf->tvertices, tv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gldraw(3, Id, glcoords, 0, size(glcoords), p.col, pp.outline, poly_flags, pp.tinf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
10
shmup.cpp
10
shmup.cpp
@ -3378,8 +3378,8 @@ transmatrix &ggmatrix(cell *c) {
|
|||||||
else if(euclid) {
|
else if(euclid) {
|
||||||
t = gmatrix[centerover.c] * eumove(cell_to_vec(c) - cellwalker_to_vec(centerover));
|
t = gmatrix[centerover.c] * eumove(cell_to_vec(c) - cellwalker_to_vec(centerover));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
t = actualV(viewctr, cview()) * calc_relative_matrix(c, viewctr.h);
|
t = applyspin(viewctr, cview()) * calc_relative_matrix(c, viewctr.h);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@ -3388,7 +3388,11 @@ transmatrix calc_relative_matrix_help(cell *c, heptagon *h1) {
|
|||||||
transmatrix gm = Id;
|
transmatrix gm = Id;
|
||||||
heptagon *h2 = c->master;
|
heptagon *h2 = c->master;
|
||||||
transmatrix where = Id;
|
transmatrix where = Id;
|
||||||
if(!nonbitrunc) for(int d=0; d<S7; d++) if(h2->c7->mov[d] == c)
|
if(whirl::whirl && c != c->master->c7) {
|
||||||
|
auto li = whirl::get_local_info(c);
|
||||||
|
where = whirl::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)
|
||||||
where = hexmove[d];
|
where = hexmove[d];
|
||||||
// always add to last!
|
// always add to last!
|
||||||
while(h1 != h2) {
|
while(h1 != h2) {
|
||||||
|
@ -351,6 +351,8 @@ bool texture_config::apply(cell *c, const transmatrix &V, int col) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastptd().u.poly.tinf = &mi;
|
lastptd().u.poly.tinf = &mi;
|
||||||
|
if(whirl::whirl)
|
||||||
|
lastptd().u.poly.flags = POLY_INVERSE;
|
||||||
if(grid_color) {
|
if(grid_color) {
|
||||||
queuepolyat(V, shFullFloor[ctof(c)], 0, PPR_FLOOR);
|
queuepolyat(V, shFullFloor[ctof(c)], 0, PPR_FLOOR);
|
||||||
lastptd().u.poly.outline = grid_color;
|
lastptd().u.poly.outline = grid_color;
|
||||||
@ -1171,8 +1173,11 @@ void showMenu() {
|
|||||||
else if(uni == 't' && config.tstate == tsActive)
|
else if(uni == 't' && config.tstate == tsActive)
|
||||||
config.tstate = tsOff;
|
config.tstate = tsOff;
|
||||||
|
|
||||||
else if(uni == 'T' && config.tstate == tsAdjusting)
|
else if(uni == 'T' && config.tstate == tsAdjusting) {
|
||||||
config.tstate = tsOff;
|
config.tstate = tsOff;
|
||||||
|
if(config.tstate == tsActive)
|
||||||
|
config.tstate = tsOff;
|
||||||
|
}
|
||||||
|
|
||||||
else if(uni == 'T' && config.tstate == tsActive)
|
else if(uni == 'T' && config.tstate == tsActive)
|
||||||
config.tstate = tsAdjusting;
|
config.tstate = tsAdjusting;
|
||||||
|
41
whirl.cpp
41
whirl.cpp
@ -295,8 +295,6 @@ namespace whirl {
|
|||||||
hpxyz(0, 0, 0) // center, not a corner
|
hpxyz(0, 0, 0) // center, not a corner
|
||||||
};
|
};
|
||||||
|
|
||||||
int bak_sp;
|
|
||||||
|
|
||||||
hyperpoint atz(const transmatrix& T, const transmatrix& corners, loc at, int cornerid = 6, ld cf = 3) {
|
hyperpoint atz(const transmatrix& T, const transmatrix& corners, loc at, int cornerid = 6, ld cf = 3) {
|
||||||
int sp = 0;
|
int sp = 0;
|
||||||
again:
|
again:
|
||||||
@ -307,7 +305,7 @@ namespace whirl {
|
|||||||
sp++;
|
sp++;
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
if(sp>3) sp -= 6; bak_sp = sp;
|
if(sp>3) sp -= 6;
|
||||||
|
|
||||||
return normalize(spin(2*M_PI*sp/S7) * T * corner);
|
return normalize(spin(2*M_PI*sp/S7) * T * corner);
|
||||||
}
|
}
|
||||||
@ -490,5 +488,42 @@ namespace whirl {
|
|||||||
param = loc(config_x, config_y);
|
param = loc(config_x, config_y);
|
||||||
pushScreen(whirl::show);
|
pushScreen(whirl::show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int compute_dist(cell *c, int master_function(cell*)) {
|
||||||
|
auto li = get_local_info(c);
|
||||||
|
|
||||||
|
cell *cm = c->master->c7;
|
||||||
|
|
||||||
|
int i = li.last_dir;
|
||||||
|
auto at = li.relative;
|
||||||
|
|
||||||
|
while(at.first < 0 || at.second < 0) {
|
||||||
|
at = at * eudir(1);
|
||||||
|
i = fixdir(i-1, cm);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dmain = master_function(cm);
|
||||||
|
auto d0 = master_function(createStep(cm->master, i)->c7);
|
||||||
|
auto d1 = master_function(createStep(cm->master, fixdir(i+1, cm))->c7);
|
||||||
|
|
||||||
|
int w = param.first;
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
if(dmain < d0 && dmain < d1)
|
||||||
|
return dmain + at.first + at.second;
|
||||||
|
if(dmain > d0 && dmain > d1)
|
||||||
|
return dmain - at.first - at.second;
|
||||||
|
if(dmain == d0 && dmain == d1)
|
||||||
|
return dmain;
|
||||||
|
// main ~ (0,0)
|
||||||
|
// d0 ~ (w,0)
|
||||||
|
// d1 ~ (0,w)
|
||||||
|
tie(dmain, d0, d1) = make_tuple(d0, d1, dmain);
|
||||||
|
// (0,0) -> (0,w)
|
||||||
|
// (w,0) -> (0,0)
|
||||||
|
// (0,w) -> (w,0)
|
||||||
|
at = loc(at.second, w - at.first - at.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user