1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-22 21:23:18 +00:00

PIU now works in the underlying map -- underlying geometry only is too fragile

This commit is contained in:
Zeno Rogue 2019-11-28 23:09:04 +01:00
parent 30329df05c
commit d63b14da5c
8 changed files with 19 additions and 31 deletions

View File

@ -132,7 +132,7 @@ EX bool grailWasFound(cell *c) {
}
void hrmap::generateAlts(heptagon *h, int levs, bool link_cdata) {
if(hybri) { hybrid::in_underlying_map([&] { generateAlts(h, levs, link_cdata); }); }
if(hybri) { PIU ( generateAlts(h, levs, link_cdata) ); }
if(!h->alt) return;
preventbarriers(h->c7);
if(h->c7) forCellEx(c2, h->c7) preventbarriers(c2);
@ -187,9 +187,7 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special
if(hybri) {
if(hybrid::over_sphere()) return NULL;
c = hybrid::get_where(c).first;
heptagon *res;
hybrid::in_underlying_map([&] { res = createAlternateMap(c, rad, firststate, special); });
return res;
return PIU ( createAlternateMap(c, rad, firststate, special) );
}
// check for direction

View File

@ -439,9 +439,7 @@ EX int celldist(cell *c) {
if(hybri) {
auto w = hybrid::get_where(c);
if(sl2) w.second = 0;
int d;
hybrid::in_underlying_map([&] { d = celldist(w.first) + abs(w.second); });
return d;
return PIU ( celldist(w.first) + abs(w.second) );
}
if(nil && !quotient) return DISTANCE_UNKNOWN;
if(euclid) return celldistance(currentmap->gamestart(), c);
@ -472,7 +470,7 @@ EX int celldistAlt(cell *c) {
auto w = hybrid::get_where(c);
int d = c->master->alt && c->master->alt->alt ? c->master->alt->alt->fieldval : 0;
d = sl2 ? 0 : abs(w.second - d);
hybrid::in_underlying_map([&] { d += celldistAlt(w.first); });
PIU ( d += celldistAlt(w.first) );
return d;
}
#if CAP_BT
@ -738,7 +736,7 @@ cdata *getHeptagonCdata_legacy(heptagon *h) {
cdata *getHeptagonCdata(heptagon *h) {
if(hybri) { cdata *x; hybrid::in_underlying_map([&] { x = getHeptagonCdata(h); }); return x; }
if(hybri) return PIU ( getHeptagonCdata(h) );
if(geometry == gNormal && BITRUNCATED) return getHeptagonCdata_legacy(h);
if(h->cdata) return h->cdata;
@ -980,9 +978,7 @@ EX int celldistance(cell *c1, cell *c2) {
if(prod) {
auto w1 = hybrid::get_where(c1), w2 = hybrid::get_where(c2);
int d;
hybrid::in_underlying_map([&] { d = celldistance(w1.first, w2.first) + abs(w1.second - w2.second); });
return d;
return PIU ( celldistance(w1.first, w2.first) + abs(w1.second - w2.second) );
}
#if CAP_FIELD

View File

@ -796,10 +796,8 @@ EX void set_floor(const transmatrix& spin, hpcshape& sh) {
EX int shvid(cell *c) {
if(hybri) {
int d;
cell *c1 = hybrid::get_where(c).first;
hybrid::in_underlying_map([&] { d = shvid(c1); });
return d;
return PIU( shvid(c1) );
}
else if(GOLDBERG)
return gp::get_plainshape_id(c);

View File

@ -245,7 +245,7 @@ void virtualRebase(cell*& base, T& at, const U& check) {
auto w = hybrid::get_where(base);
auto d = product_decompose(check(at)).first;
at = mscale(at, -d);
hybrid::in_underlying_map([&] { virtualRebase(w.first, at, check); });
PIU( virtualRebase(w.first, at, check) );
if(d > cgi.plevel / 2) { w.second++; d -= cgi.plevel; }
if(d < -cgi.plevel / 2) { w.second--; d += cgi.plevel; }
at = mscale(at, +d);

View File

@ -2590,7 +2590,7 @@ EX void setdist(cell *c, int d, cell *from) {
auto wc = hybrid::get_where(c).first;
auto wf = from ? hybrid::get_where(from).first : NULL;
if(c->land && !wc->land) wc->land = c->land;
hybrid::in_underlying_map([&] { setdist(wc, d, wf); });
PIU ( setdist(wc, d, wf) );
}
if(buggyGeneration) {

View File

@ -1102,16 +1102,16 @@ EX namespace hybrid {
}
}
EX void in_underlying_map(const reaction_t& f) {
if(!hybri) f();
else hmap()->in_underlying(f);
}
EX hrmap* get_umap() { return ((hrmap_hybrid*)currentmap)->underlying_map; }
#if HDR
template<class T> auto in_underlying_geometry(const T& f) -> decltype(f()) {
if(!hybri) return f();
dynamicval<eGeometry> g(geometry, underlying);
dynamicval<eGeometry> gag(actual_geometry, geometry);
dynamicval<geometry_information*> gc(cgip, underlying_cgip);
dynamicval<hrmap*> gpm(pmap, currentmap);
dynamicval<hrmap*> gm(currentmap, get_umap());
return f();
}
@ -1128,7 +1128,7 @@ EX namespace hybrid {
}
else {
ld tf, he, alpha;
in_underlying_map([&] {
in_underlying_geometry([&] {
hyperpoint h1 = get_corner_position(c, i);
hyperpoint h2 = get_corner_position(c, i+1);
hyperpoint hm = mid(h1, h2);
@ -1723,7 +1723,7 @@ EX namespace rots {
cell *co = hybrid::get_where(centerover).first;
hybrid::in_underlying_map([&] {
hybrid::in_underlying_geometry([&] {
cgi.require_shapes();
dynamicval<int> pcc(corner_centering, cornermode ? 1 : 2);
dynamicval<bool> pf(playerfound, true);

View File

@ -368,9 +368,7 @@ EX int fieldval_uniq(cell *c) {
if(experimental) return 0;
else if(hybri) {
auto c1 = hybrid::get_where(c).first;
int res;
hybrid::in_underlying_map([&] { res = fieldval_uniq(c1); });
return res;
return PIU ( fieldval_uniq(c1) );
}
else if(sphere) {
if(archimedean) return c->master->fiftyval;
@ -403,9 +401,7 @@ EX int fieldval_uniq(cell *c) {
EX int fieldval_uniq_rand(cell *c, int randval) {
if(hybri) {
auto c1 = hybrid::get_where(c).first;
int res;
hybrid::in_underlying_map([&] { res = fieldval_uniq_rand(c1, randval); });
return res;
return PIU ( fieldval_uniq_rand(c1, randval) );
}
if(sphere || euclid || NONSTDVAR)
// we do not care in these cases

View File

@ -251,7 +251,7 @@ EX void initgame() {
if(cwt.at->land == laCrossroads2) {
cell *c = cwt.at;
if(hybri) { c = hybrid::get_where(c).first; hybrid::in_underlying_map([&] { c->cmove(0); }); }
if(hybri) { c = hybrid::get_where(c).first; PIU( c->cmove(0) ); }
c->landparam = 12;
c->cmove(0)->landparam = 44;
c->cmove(0)->land = laCrossroads2;