diff --git a/bigstuff.cpp b/bigstuff.cpp index edfced81..630e59ca 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -292,21 +292,19 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special if(!polarb50(c)) return NULL; } + 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) alt->fieldval = hybrid::get_where(centerover).second; alt->alt = alt; - #if MAXMDIM >= 4 - if(reg3::in_rule()) { - reg3::link_structures(h, alt, firststate); - if(alt->fiftyval == -1) return nullptr; /* unlinked */ + if(!currentmap->link_alt(h, alt, firststate, bf.spin)) { + return nullptr; } - #endif h->alt = alt; alt->cdata = (cdata*) h; - currentmap->link_alt(bf); for(int d=rad; d>=0; d--) { currentmap->generateAlts(cx[d]->master); diff --git a/cell.cpp b/cell.cpp index 906c0995..cd61fb31 100644 --- a/cell.cpp +++ b/cell.cpp @@ -20,7 +20,7 @@ struct hrmap { virtual vector& allcells(); virtual void verify() { } virtual void on_dim_change() { } - virtual void link_alt(const cellwalker& hs) { } + virtual bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) { return true; } virtual void generateAlts(heptagon *h, int levs = default_levs(), bool link_cdata = true); heptagon *may_create_step(heptagon *h, int direction) { if(h->move(direction)) return h->move(direction); diff --git a/reg3.cpp b/reg3.cpp index b842ff6d..f3998c77 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -1518,10 +1518,10 @@ EX namespace reg3 { map reducers; - void link_alt(const cellwalker& hs) override { - auto h = hs.at->master; + bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override { altdist(h) = 0; - if(h->alt->s != hsOrigin) reducers[h] = hs.spin; + if(firststate != hsOrigin) reducers[h] = dir; + return true; } void generateAlts(heptagon* h, int levs, bool link_cdata) override { @@ -2075,6 +2075,8 @@ EX namespace reg3 { int aid = cell_id.at(c); return quotient_map->get_move_seq(quotient_map->acells[aid], i); } + + virtual bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override; }; struct hrmap_h3_rule_alt : hrmap { @@ -2091,25 +2093,25 @@ EX hrmap *new_alt_map(heptagon *o) { return new hrmap_h3_rule_alt(o); } -EX void link_structures(heptagon *h, heptagon *alt, hstate firststate) { - auto cm = (hrmap_h3_rule*) currentmap; +bool hrmap_h3_rule::link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) { alt->fieldval = h->fieldval; if(geometry == gSpace535) alt->fieldval = 0; if(firststate == hsOrigin) { - alt->fiftyval = cm->root[alt->fieldval]; - return; + alt->fiftyval = root[alt->fieldval]; + return true; } - vector& choices = cm->possible_states[alt->fieldval]; + vector& choices = possible_states[alt->fieldval]; vector choices2; for(auto c: choices) { bool ok = true; for(int d=0; d<12; d++) if(h->cmove(d)->distance < h->distance) - if(cm->children[S7*c+d] == -1) + if(children[S7*c+d] == -1) ok = false; if(ok) choices2.push_back(c); } alt->fiftyval = hrand_elt(choices2, -1); + return alt->fiftyval != -1; } EX bool reg3_rule_available = true;