From f40072511ba92d87f5f7eae777353267531abbd9 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 18 Aug 2019 15:32:46 +0200 Subject: [PATCH] product:: big stuff --- barriers.cpp | 3 ++- bigstuff.cpp | 32 ++++++++++++++++++++++++++++---- cell.cpp | 4 ++++ landgen.cpp | 8 ++++++++ nonisotropic.cpp | 1 - pattern2.cpp | 2 ++ 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/barriers.cpp b/barriers.cpp index de412e5f..a47cf6e6 100644 --- a/barriers.cpp +++ b/barriers.cpp @@ -31,12 +31,13 @@ EX bool checkBarriersFront(cellwalker bb, int q IS(5), bool cross IS(false)) { return checkBarriersBack(bb, q); } +/** return true if the cell c is not allowed to generate barriers because of other large things already existing nearby. */ EX bool hasbardir(cell *c) { return c->bardir != NODIR && c->bardir != NOBARRIERS; } -/** return true if the cell c is not allowed to generate barriers because of other large things already existing nearby. */ EX void preventbarriers(cell *c) { + if(prod) c = product::get_where(c).first; if(c && c->bardir == NODIR) c->bardir = NOBARRIERS; } diff --git a/bigstuff.cpp b/bigstuff.cpp index e39e9128..4d0acc31 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -132,6 +132,7 @@ EX bool grailWasFound(cell *c) { } void hrmap::generateAlts(heptagon *h, int levs, bool link_cdata) { + if(prod) { product::in_underlying_map([&] { generateAlts(h, levs, link_cdata); }); } if(!h->alt) return; preventbarriers(h->c7); if(h->c7) forCellEx(c2, h->c7) preventbarriers(c2); @@ -182,6 +183,13 @@ void hrmap::generateAlts(heptagon *h, int levs, bool link_cdata) { EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special IS(0)) { + if(prod) { + c = product::get_where(c).first; + heptagon *res; + product::in_underlying_map([&] { res = createAlternateMap(c, rad, firststate, special); }); + return res; + } + // check for direction int gdir = -1; for(int i=0; itype; i++) { @@ -969,6 +977,16 @@ EX void setLandSol(cell *c) { } } +EX void setLandProduct(cell *c) { + auto wc = product::get_where(c).first; + c->barleft = wc->barleft; + c->barright = wc->barright; + c->bardir = wc->bardir; + if(wc->land) setland(c, wc->land); + if(among(wc->wall, waBarrier, waMercury) || wc->land == laElementalWall) + c->wall = wc->wall; + } + EX void setLandNil(cell *c) { setland(c, specialland); @@ -1257,9 +1275,9 @@ EX int wallchance(cell *c, bool deepOcean) { 50; } -EX bool horo_ok() { - // do the horocycles work in the current geometry? - return hyperbolic && !binarytiling && !archimedean && !penrose && !experimental; +/** should we generate the horocycles in the current geometry? */ +EX bool horo_ok() { + return hyperbolic && !binarytiling && !archimedean && !penrose && !experimental && !prod; } EX bool gp_wall_test() { @@ -1317,7 +1335,9 @@ EX void buildBigStuff(cell *c, cell *from) { // buildgreatwalls - if(geometry == gNormal && celldist(c) < 3 && !GOLDBERG) { + if(prod) ; /* Great Walls generated via the underlying geometry */ + + else if(geometry == gNormal && celldist(c) < 3 && !GOLDBERG) { if(top_land && c == cwt.at->master->move(3)->c7) { buildBarrierStrong(c, 6, true, top_land); } @@ -1645,6 +1665,10 @@ EX void moreBigStuff(cell *c) { else if(geometry == gKiteDart3) { if(kite::getshape(c->master) == kite::pKite) c->wall = waColumn; } + else if(prod) { + auto d = product::get_where(c); + if(d.first->wall == waColumn || (d.second&1)) c->wall = waColumn; + } else if(WDIM == 3) { if(c->master->zebraval != 1) c->wall = waColumn; } diff --git a/cell.cpp b/cell.cpp index 5c0be1a4..592bab8a 100644 --- a/cell.cpp +++ b/cell.cpp @@ -448,6 +448,7 @@ EX int compdist(int dx[]) { EX int celldist(cell *c) { if(experimental) return 0; + if(prod) { auto w = product::get_where(c); return PIU(celldist(w.first)) + abs(w.second); } if(fulltorus && WDIM == 2) return torusmap()->dists[decodeId(c->master)]; if(nil) return DISTANCE_UNKNOWN; @@ -478,6 +479,7 @@ static const int ALTDIST_ERROR = 90000; EX int celldistAlt(cell *c) { if(experimental) return 0; + if(prod) { auto w = product::get_where(c); return PIU(celldistAlt(w.first)) + abs(w.second); } if(masterless) { if(fulltorus) return celldist(c); if(euwrap) return cylinder_alt(c); @@ -981,6 +983,8 @@ EX cell *random_in_distance(cell *c, int d) { } EX int celldistance(cell *c1, cell *c2) { + + if(prod) { auto w1 = product::get_where(c1), w2 = product::get_where(c2); return PIU(celldistance(w1.first, w2.first) + abs(w1.second - w2.second)); } if((masterless) && (euclid6 || (euclid4 && PURE))) { if(!euwrap) diff --git a/landgen.cpp b/landgen.cpp index 40ab7ad8..698c4c6b 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -2549,6 +2549,13 @@ EX void setdist(cell *c, int d, cell *from) { } if(d <= 10 - getDistLimit()) lastexplore = shmup::on ? shmup::curtime : turncount; + + if(prod) { + auto wc = product::get_where(c).first; + auto wf = from ? product::get_where(from).first : NULL; + if(c->land && !wc->land) wc->land = c->land; + product::in_underlying_map([&] { setdist(wc, d, wf); }); + } if(buggyGeneration) { if(d < BARLEV) for(int i=0; itype; i++) { @@ -2612,6 +2619,7 @@ EX void setdist(cell *c, int d, cell *from) { #if MAXMDIM == 4 else if(euclid && WDIM == 3) euclid3::set_land(c); #endif + else if(prod) setLandProduct(c); else if(sphere || fulltorus) setLandSphere(c); else if(euclid) setLandEuclid(c); else if(quotient) { setland(c, specialland); setLandQuotient(c); } diff --git a/nonisotropic.cpp b/nonisotropic.cpp index d3cc7742..c850f3be 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -554,7 +554,6 @@ EX namespace product { geometry = gProduct; ginf[gProduct] = ginf[underlying]; ginf[gProduct].cclass = gcProduct; - ginf[gProduct].flags |= qEXPERIMENTAL; pmodel = mdPerspective; } diff --git a/pattern2.cpp b/pattern2.cpp index c7d0c905..2271c645 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -372,6 +372,7 @@ EX pair fieldval(cell *c) { EX int fieldval_uniq(cell *c) { if(experimental) return 0; + else if(prod) { auto c1 = product::get_where(c).first; return PIU(fieldval_uniq(c1)); } else if(sphere) { if(archimedean) return c->master->fiftyval; #if CAP_IRR @@ -1362,6 +1363,7 @@ EX bool pseudohept(cell *c) { #if CAP_IRR if(IRREGULAR) return irr::pseudohept(c); #endif + if(prod) { auto d = product::get_where(c); return (d.second & 1) && PIU(pseudohept(d.first)); } #if CAP_BT if(nil) return c->master->zebraval & c->master->emeraldval & c->master->fieldval & 1; if(sol) return (c->master->emeraldval % 3 == 2) && (c->master->zebraval % 3 == 2) && (c->master->distance % 2);