From 3972e5a6bbb466f2d63bfa899144ab8f11b03db0 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 31 Jul 2021 12:48:52 +0200 Subject: [PATCH] altmap:: generate_random_path used --- bigstuff.cpp | 50 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/bigstuff.cpp b/bigstuff.cpp index c608a0d6..fb779a42 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -257,65 +257,41 @@ EX heptagon *create_altmap(cell *c, int rad, hstate firststate, int special IS(0 if(!weirdhyperbolic && !(checkBarriersFront(bb) && checkBarriersBack(bb))) { return NULL; } + + cellwalker bf(c, gdir); bf += rev; + auto p = generate_random_path(bf, rad, false, false); - // if we always go to the opposite tile on a {even,x} tiling, - // it will be too easy - int flip = 0; - if(WDIM == 2 && S7 % 2 == 0) flip = hrand(2) ? 1 : -1; - - // okay, let's go then! - cellwalker bf(c, gdir); - std::vector cx(rad+1); - for(int i=0; i= 4 - // in 3D honeycombs we vary the direction, but never for three successive i's - if(WDIM == 3 && firststate == hsOrigin && (i%3)) - bf.spin = hrandom_adjacent(bf); - #endif - } - cx[rad] = bf.at; - heptagon *h = bf.at->master; + heptagon *h = p.last.at->master; if(h->alt) { printf("Error: creatingAlternateMap while one already exists\n"); return NULL; } - if(special == waPalace) { - - // type 7 is ensured - cell *c = bf.at; - - if(cdist50(c) != 0) return NULL; - if(!polarb50(c)) return NULL; + if(special == waPalace) { + cell *c = p.last.at; + if(!ctof(c) || cdist50(c) != 0 || !polarb50(c)) return nullptr; } - bf += rev; - heptagon *alt = init_heptagon(h->type); allmaps.push_back(newAltMap(alt)); -//printf("new alt {%p}\n", hr::voidp(alt)); alt->s = firststate; - if(hybri) hybrid::altmap_heights[alt] = hybrid::get_where(centerover).second; - alt->alt = alt; - if(!currentmap->link_alt(h, alt, firststate, bf.spin)) { + if(!currentmap->link_alt(h, alt, firststate, p.last.spin)) { return nullptr; } + if(hybri) hybrid::altmap_heights[alt] = hybrid::get_where(centerover).second; + alt->alt = alt; h->alt = alt; alt->cdata = (cdata*) h; for(int d=rad; d>=0; d--) { - currentmap->extend_altmap(cx[d]->master); - preventbarriers(cx[d]); + currentmap->extend_altmap(p.path[d]->master); + preventbarriers(p.path[d]); } if(special == waPalace) { - cell *c = bf.at; + cell *c = p.last.at; princess::generating = true; c->land = laPalace;