diff --git a/Makefile b/Makefile index c63d9cd37..2412fdbad 100644 --- a/Makefile +++ b/Makefile @@ -82,9 +82,9 @@ endif ifeq (${TOOLCHAIN},clang) CXXFLAGS_STD = -std=c++11 CXXFLAGS_EARLY += -march=native -fPIC - CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic + CXXFLAGS_EARLY += -W -Wall -Wextra -Wsuggest-override -Werror -pedantic CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option - CXXFLAGS_EARLY += -Wno-invalid-offsetof -Wno-overloaded-virtual + CXXFLAGS_EARLY += -Wno-invalid-offsetof endif ifeq (${TOOLCHAIN},gcc) diff --git a/arbitrile.cpp b/arbitrile.cpp index 8d434d091..84dff294b 100644 --- a/arbitrile.cpp +++ b/arbitrile.cpp @@ -706,7 +706,7 @@ struct hrmap_arbi : hrmap { void verify() override { } transmatrix adj(heptagon *h, int dl) override { - return get_adj(current_or_slided(), id_of(h), dl, h->c.move(dl) ? h->c.spin(dl) : -1); + return get_adj(current_or_slided(), id_of(h), dl, h->c().move(dl) ? h->c().spin(dl) : -1); } heptagon *create_step(heptagon *h, int d) override { @@ -737,7 +737,7 @@ struct hrmap_arbi : hrmap { transmatrix T = v[i].second; heptagon *h2 = v[i].first; if(eqmatrix(T, goal)) { - h->c.connect(d, h2, e, m); + h->c().connect(d, h2, e, m); return h2; } for(int i=0; itype; i++) { @@ -754,7 +754,7 @@ struct hrmap_arbi : hrmap { h1->zebraval = xt; h1->c7 = newCell(h1->type, h1); h1->emeraldval = h->emeraldval ^ m; - h->c.connect(d, h1, e, m); + h->c().connect(d, h1, e, m); return h1; } @@ -789,7 +789,7 @@ struct hrmap_arbi : hrmap { println(hlog, "err = ", err); max_err = err; } - h->c.connect(d, p2.first, oth%p2.first->type, m); + h->c().connect(d, p2.first, oth%p2.first->type, m); return p2.first; } } @@ -800,14 +800,14 @@ struct hrmap_arbi : hrmap { h1->zebraval = xt; h1->c7 = newCell(h1->type, h1); h1->emeraldval = h->emeraldval ^ m; - h->c.connect(d, h1, e, m); + h->c().connect(d, h1, e, m); arbi_matrix[h1] = make_pair(alt, T); altmap[alt].emplace_back(h1, T); return h1; } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { return relative_matrix_recursive(h2, h1); } diff --git a/archimedean.cpp b/archimedean.cpp index 0ca7bf27c..448b4ced4 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -554,7 +554,7 @@ struct hrmap_archimedean : hrmap { heptspin hs(origin, 0); heptagon *hnew = build_child(hs, current.get_adj(hs)); for(int s=1; s<2*current.N; s++) - origin->c.connect(s, hnew, s, false); + origin->c().connect(s, hnew, s, false); } else if(current.real_faces == 0) { may_create_step(origin, 0); @@ -562,20 +562,20 @@ struct hrmap_archimedean : hrmap { may_create_step(origin, 1); heptagon *o1 = origin->move(1); for(int s=1; s<2*current.N; s+=2) - o0->c.connect(s, o1, 2*current.N-s, false); + o0->c().connect(s, o1, 2*current.N-s, false); for(int s=2; s<2*current.N; s+=2) { heptspin hs(o0, s); heptagon *hnew = build_child(hs, current.get_adj(hs)); // no need to specify archimedean_gmatrix and altmap - hnew->c.connect(1, heptspin(o1, 2*current.N-s)); + hnew->c().connect(1, heptspin(o1, 2*current.N-s)); } - o1->c.connect(1, o0, 2*current.N-1, false); + o1->c().connect(1, o0, 2*current.N-1, false); } else if(origin->degree() == 2) { may_create_step(origin, 0); may_create_step(origin, 1); - origin->move(0)->c.connect(1, origin->move(1), 2*current.N-1, false); - origin->move(1)->c.connect(1, origin->move(0), 2*current.N-1, false); + origin->move(0)->c().connect(1, origin->move(1), 2*current.N-1, false); + origin->move(1)->c().connect(1, origin->move(0), 2*current.N-1, false); } cgi.base_distlimit = 0; @@ -706,7 +706,7 @@ struct hrmap_archimedean : hrmap { return calc_relative_matrix(c->cmove(dir), c, C0); } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { if(use_gmatrix && gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7)) return inverse_shift(gmatrix0[h1->c7], gmatrix0[h2->c7]); transmatrix gm = Id, where = Id; @@ -749,19 +749,19 @@ struct hrmap_archimedean : hrmap { if(PURE) { if(arcm::id_of(c->master) < arcm::current.N * 2) { heptspin hs = heptspin(c->master, d) + wstep + 2 + wstep + 1; - c->c.connect(d, hs.at->c7, hs.spin, hs.mirrored); + c->c().connect(d, hs.at->c7, hs.spin, hs.mirrored); } - else c->c.connect(d, c, d, false); + else c->c().connect(d, c, d, false); } else if(DUAL) { if(arcm::id_of(c->master) >= arcm::current.N * 2) { heptagon *h2 = createStep(c->master, d*2); - int d1 = c->master->c.spin(d*2); - c->c.connect(d, h2->c7, d1/2, false); + int d1 = c->master->c().spin(d*2); + c->c().connect(d, h2->c7, d1/2, false); } else { printf("bad connection\n"); - c->c.connect(d,c,d,false); + c->c().connect(d,c,d,false); } } else hrmap::find_cell_connection(c, d); @@ -848,16 +848,16 @@ void connect_digons_too(heptspin h1, heptspin h2) { h1--, h2++; heptagon *hnew = build_child(h1, current.get_adj(h1)); // no need to specify archimedean_gmatrix and altmap - hnew->c.connect(1, h2); + hnew->c().connect(1, h2); h1--, h2++; DEBB(DF_GEOM, (format("OL2 %p.%d ~ %p.%d\n", hr::voidp(h1.at), h1.spin, hr::voidp(h2.at), h2.spin))); - h1.at->c.connect(h1.spin, h2); + h1.at->c().connect(h1.spin, h2); } } void connectHeptagons(heptspin hi, heptspin hs) { DEBB(DF_GEOM, (format("OLD %p.%d ~ %p.%d\n", hr::voidp(hi.at), hi.spin, hr::voidp(hs.at), hs.spin))); - if(hi.at->move(hi.spin) == hs.at && hi.at->c.spin(hi.spin) == hs.spin) { + if(hi.at->move(hi.spin) == hs.at && hi.at->c().spin(hi.spin) == hs.spin) { DEBB(DF_GEOM, (format("WARNING: already connected\n"))); return; } @@ -869,7 +869,7 @@ void connectHeptagons(heptspin hi, heptspin hs) { DEBB(DF_GEOM, (format("ERROR: already connected right\n"))); throw hr_archimedean_error("Archimedean error: already connected right"); } - hi.at->c.connect(hi.spin, hs); + hi.at->c().connect(hi.spin, hs); auto p = current.get_adj(hi); if(current.tilegroup[p.first] != current.tilegroup[id_of(hs.at)]) { @@ -915,7 +915,7 @@ transmatrix archimedean_tiling::adjcell_matrix(heptagon *h, int d) { heptagon *h2 = h->move(d); - int d2 = h->c.spin(d); + int d2 = h->c().spin(d); auto& t2 = get_triangle(h2, d2); return spin(-t1.first) * xpush(t1.second) * spin(M_PI + t2.first); diff --git a/asonov.cpp b/asonov.cpp index 3ecd0787c..c37cbb765 100644 --- a/asonov.cpp +++ b/asonov.cpp @@ -191,13 +191,13 @@ struct hrmap_asonov : hrmap { auto p = coords[parent]; auto q = p.addmove(d); auto child = get_at(q); - parent->c.connect(d, child, (d + 6) % 12, false); + parent->c().connect(d, child, (d + 6) % 12, false); return child; } transmatrix adj(heptagon *h, int i) override { return adjmatrix(i); } - virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { for(int a=0; amove(a)) return adjmatrix(a); return coord_to_matrix(coords[h2], coords[h1]); } diff --git a/attack.cpp b/attack.cpp index 52d298618..3aac79f81 100644 --- a/attack.cpp +++ b/attack.cpp @@ -225,7 +225,7 @@ EX void killIvy(cell *c, eMonster who) { if(checkOrb(who, itOrbStone)) petrify(c, waPetrified, c->monst); c->monst = moIvyDead; // NEWYEARFIX for(int i=0; itype; i++) if(c->move(i)) - if(isIvy(c->move(i)) && c->move(i)->mondir == c->c.spin(i)) + if(isIvy(c->move(i)) && c->move(i)->mondir == c->c().spin(i)) killIvy(c->move(i), who), kills[moIvyDead]++; } @@ -414,7 +414,7 @@ EX void killMutantIvy(cell *c, eMonster who) { changes.ccell(c); removeIvy(c); for(int i=0; itype; i++) - if(c->move(i)->mondir == c->c.spin(i) && (isMutantIvy(c->move(i)) || c->move(i)->monst == moFriendlyIvy)) + if(c->move(i)->mondir == c->c().spin(i) && (isMutantIvy(c->move(i)) || c->move(i)->monst == moFriendlyIvy)) kills[c->move(i)->monst]++, killMutantIvy(c->move(i), who); if(c->land == laClearing) clearing::imput(c); } @@ -774,7 +774,7 @@ EX void killMonster(cell *c, eMonster who, flagtype deathflags IS(0)) { cell *c2 = proper(c, c->mondir) ? c->move(c->mondir) : nullptr; if(!c2) c2 = c; /* should not happen */ for(int i=0; itype; i++) - if(c2->move(i)->monst == moIvyWait && c2->move(i)->mondir == c2->c.spin(i)) + if(c2->move(i)->monst == moIvyWait && c2->move(i)->mondir == c2->c().spin(i)) qty++; if(c2->monst == moIvyRoot || qty) { c->monst = moIvyNext; @@ -1028,7 +1028,7 @@ EX void pushMonster(const movei& mi) { moveMonster(mi); if(mi.t->monst) { mi.t->mondir = id; - other->mondir = mi.t->c.spin(id); + other->mondir = mi.t->c().spin(id); } } } diff --git a/barriers.cpp b/barriers.cpp index ec8dcb4b4..f92e1b4f7 100644 --- a/barriers.cpp +++ b/barriers.cpp @@ -681,7 +681,7 @@ EX void buildCrossroads2(cell *c) { for(int d=0; dtype; d++) if(emeraldtable[h2][d] == h3) { - int nh = emeraldtable[h2][(42+d + c->c.spin(i) - j) % c2->type]; + int nh = emeraldtable[h2][(42+d + c->c().spin(i) - j) % c2->type]; if(c->landparam>0 && c->landparam != nh) { printf("CONFLICT\n"); raiseBuggyGeneration(c, "CONFLICT"); diff --git a/bigstuff.cpp b/bigstuff.cpp index edfced81e..48e9a1973 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -622,7 +622,7 @@ EX void buildEquidistant(cell *c) { else { // if(qcv != 1) { printf("qcv = %d\n", qcv); exit(1); } cell *c2 = c->move(sid); - int bsid = c->c.spin(sid); + int bsid = c->c().spin(sid); for(int j=0; jtype; j++) { int q = gmod(bsid+j, c2->type); cell *c3 = c2->move(q); @@ -677,7 +677,7 @@ EX void buildEquidistant(cell *c) { } else if(WDIM == 3 && c->landparam % skip != 1 && c->move(up) && c->move(up)->landflags) c->landflags = 1; - else if(WDIM == 3 && c->landparam % skip == 1 && c->move(up) && c->move(up)->c.spin(up) == (c->c.spin(up)) && c->move(up)->move(up)->landflags) + else if(WDIM == 3 && c->landparam % skip == 1 && c->move(up) && c->move(up)->c().spin(up) == (c->c().spin(up)) && c->move(up)->move(up)->landflags) c->landflags = 1; if(c->landflags) c->wall = (WDIM == 3 ? waTrunk3 : waTrunk); } @@ -792,7 +792,7 @@ EX void buildEquidistant(cell *c) { else for(int j=0; jtype; j++) { cell *c3 = c2->move(j); if(c3 && c3->landparam < c2->landparam && c3->landflags) - if(c->c.spin(i) == (j+3)%c2->type || c->c.spin(i) == (j+c2->type-3)%c2->type) + if(c->c().spin(i) == (j+3)%c2->type || c->c().spin(i) == (j+c2->type-3)%c2->type) ok = true; } if(ok) { @@ -1895,7 +1895,7 @@ EX void gen_temple(cell *c) { if(c->master->zebraval % 5 != 1) c->wall = waColumn; } else if(geometry == gHoroTris || geometry == gHoroRec) { - if(c->c.spin(bt::updir()) != 0) c->wall = waColumn; + if(c->c().spin(bt::updir()) != 0) c->wall = waColumn; } else if(geometry == gKiteDart3) { if(kite::getshape(c->master) == kite::pKite) c->wall = waColumn; diff --git a/binary-tiling.cpp b/binary-tiling.cpp index 17107ccdc..6f55d8f97 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -90,14 +90,14 @@ EX namespace bt { printf("already connected to something else (2)\n"); breakhere(); } - h->c.connect(d, h1, d1, false); + h->c().connect(d, h1, d1, false); rec--; return h1; } EX heptagon *pathc(heptagon *h, int d, int d1, std::vector> p) { h->cmove(S7-1); - int z = h->c.spin(S7-1); + int z = h->c().spin(S7-1); return path(h, d, d1, p[z]); } @@ -316,28 +316,28 @@ EX namespace bt { return build3(parent, 8, nextdir(4), -1); case 4: parent->cmove(8); - if(parent->c.spin(8) & 1) - return path(h, 4, 5, {8, parent->c.spin(8) ^ 1}); + if(parent->c().spin(8) & 1) + return path(h, 4, 5, {8, parent->c().spin(8) ^ 1}); else - return path(h, 4, 5, {8, 4, parent->c.spin(8) ^ 1}); + return path(h, 4, 5, {8, 4, parent->c().spin(8) ^ 1}); case 5: parent->cmove(8); - if(!(parent->c.spin(8) & 1)) - return path(h, 5, 4, {8, parent->c.spin(8) ^ 1}); + if(!(parent->c().spin(8) & 1)) + return path(h, 5, 4, {8, parent->c().spin(8) ^ 1}); else - return path(h, 5, 4, {8, 5, parent->c.spin(8) ^ 1}); + return path(h, 5, 4, {8, 5, parent->c().spin(8) ^ 1}); case 6: parent->cmove(8); - if(parent->c.spin(8) & 2) - return path(h, 6, 7, {8, parent->c.spin(8) ^ 2}); + if(parent->c().spin(8) & 2) + return path(h, 6, 7, {8, parent->c().spin(8) ^ 2}); else - return path(h, 6, 7, {8, 6, parent->c.spin(8) ^ 2}); + return path(h, 6, 7, {8, 6, parent->c().spin(8) ^ 2}); case 7: parent->cmove(8); - if(!(parent->c.spin(8) & 2)) - return path(h, 7, 6, {8, parent->c.spin(8) ^ 2}); + if(!(parent->c().spin(8) & 2)) + return path(h, 7, 6, {8, parent->c().spin(8) ^ 2}); else - return path(h, 7, 6, {8, 7, parent->c.spin(8) ^ 2}); + return path(h, 7, 6, {8, 7, parent->c().spin(8) ^ 2}); default: throw hr_exception("wrong dir"); } @@ -350,22 +350,22 @@ EX namespace bt { return build3(parent, 6, nextdir(2), -1); case 2: parent->cmove(6); - if(parent->c.spin(6) == 0) + if(parent->c().spin(6) == 0) return path(h, 2, 4, {6, 1}); else return path(h, 2, 4, {6, 3, 0}); case 4: parent->cmove(6); - if(parent->c.spin(6) == 0) + if(parent->c().spin(6) == 0) return path(h, 4, 2, {6, 5, 1}); else return path(h, 4, 2, {6, 0}); case 3: parent->cmove(6); - return path(h, 3, 5, {6, 4, parent->c.spin(6)}); + return path(h, 3, 5, {6, 4, parent->c().spin(6)}); case 5: parent->cmove(6); - return path(h, 5, 3, {6, 2, parent->c.spin(6)}); + return path(h, 5, 3, {6, 2, parent->c().spin(6)}); default: throw hr_exception("wrong dir"); } @@ -378,7 +378,7 @@ EX namespace bt { return build3(parent, 7, nextdir(3), -1); case 4: case 5: case 6: { parent->cmove(7); - int s = parent->c.spin(7); + int s = parent->c().spin(7); if(s == 0) return path(h, d, d, {7, d-3}); else if(s == d-3) return path(h, d, d, {7, 0}); else return path(h, d, d, {7, d, 9-d-s}); @@ -415,7 +415,7 @@ EX namespace bt { return pathc(h, 11, 7, {{13,1}, {13,2}, {13,0}}); case 12: { h->cmove(13); - int z = h->c.spin(13); + int z = h->c().spin(13); return path(h, 12, (z+1)%3+3, {13, z+6}); } default: @@ -453,7 +453,7 @@ EX namespace bt { else throw hr_exception("wrong dir"); } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { if(gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7)) return inverse_shift(gmatrix0[h1->c7], gmatrix0[h2->c7]); transmatrix gm = Id, where = Id; @@ -503,11 +503,11 @@ EX namespace bt { return cgi.direct_tmatrix[dir]; else { h->cmove(dir); - return cgi.inverse_tmatrix[h->c.spin(dir)]; + return cgi.inverse_tmatrix[h->c().spin(dir)]; } } - const transmatrix iadj(heptagon *h, int dir) { heptagon *h1 = h->cmove(dir); return adj(h1, h->c.spin(dir)); } + const transmatrix iadj(heptagon *h, int dir) { heptagon *h1 = h->cmove(dir); return adj(h1, h->c().spin(dir)); } void virtualRebase(heptagon*& base, transmatrix& at) override { @@ -845,15 +845,15 @@ EX bool pseudohept(cell *c) { if(WDIM == 2) return c->type & c->master->distance & 1; else if(geometry == gHoroRec) - return c->c.spin(S7-1) == 0 && (c->master->distance & 1) && c->cmove(S7-1)->c.spin(S7-1) == 0; + return c->c().spin(S7-1) == 0 && (c->master->distance & 1) && c->cmove(S7-1)->c().spin(S7-1) == 0; else if(geometry == gHoroTris) - return c->c.spin(S7-1) == 0 && (c->master->distance & 1); + return c->c().spin(S7-1) == 0 && (c->master->distance & 1); else return (c->master->zebraval == 1) && (c->master->distance & 1); } EX pair gpvalue(heptagon *h) { - int d = h->c.spin(S7-1); + int d = h->c().spin(S7-1); if(d == 0) return make_pair(gp::loc(0,0), gp::loc(-1,0)); else return make_pair(gp::eudir((d-1)*2), gp::loc(1,0)); } @@ -908,7 +908,7 @@ EX int celldistance3_rec(heptagon *c1, heptagon *c2) { int steps = equalize(c1, c2); vector dx; while(c1 != c2) { - dx.push_back(c1->c.spin(S7-1) - c2->c.spin(S7-1)); + dx.push_back(c1->c().spin(S7-1) - c2->c().spin(S7-1)); c1 = c1->cmove(S7-1); c2 = c2->cmove(S7-1); steps += 2; @@ -929,8 +929,8 @@ EX int celldistance3_square(heptagon *c1, heptagon *c2) { int steps = equalize(c1, c2); vector dx, dy; while(c1 != c2) { - dx.push_back((c1->c.spin(S7-1) & 1) - (c2->c.spin(S7-1) & 1)); - dy.push_back((c1->c.spin(S7-1) >> 1) - (c2->c.spin(S7-1) >> 1)); + dx.push_back((c1->c().spin(S7-1) & 1) - (c2->c().spin(S7-1) & 1)); + dy.push_back((c1->c().spin(S7-1) >> 1) - (c2->c().spin(S7-1) >> 1)); c1 = c1->cmove(S7-1); c2 = c2->cmove(S7-1); steps += 2; @@ -954,8 +954,8 @@ EX int celldistance3_hex(heptagon *c1, heptagon *c2) { int steps = equalize(c1, c2); vector d1, d2; while(c1 != c2) { - d1.push_back(c1->c.spin(S7-1)); - d2.push_back(c2->c.spin(S7-1)); + d1.push_back(c1->c().spin(S7-1)); + d2.push_back(c2->c().spin(S7-1)); c1 = c1->cmove(S7-1); c2 = c2->cmove(S7-1); steps += 2; diff --git a/cell.cpp b/cell.cpp index 1c2cd0e11..dfd9793b0 100644 --- a/cell.cpp +++ b/cell.cpp @@ -30,18 +30,23 @@ struct hrmap { printf("create_step called unexpectedly\n"); exit(1); return NULL; } - virtual struct transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) { - printf("relative_matrix called unexpectedly\n"); +private: + virtual transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) { + printf("relative_matrixh called unexpectedly\n"); return Id; } - virtual struct transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) { - return relative_matrix(c2->master, c1->master, hint); + virtual transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) { + return relative_matrixh(c2->master, c1->master, hint); } - virtual struct transmatrix adj(cell *c, int i) { return adj(c->master, i); } - virtual struct transmatrix adj(heptagon *h, int i); - struct transmatrix iadj(cell *c, int i) { cell *c1 = c->cmove(i); return adj(c1, c->c.spin(i)); } +public: + transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) { return relative_matrixh(h2, h1, hint); } + transmatrix relative_matrix(cell *h2, cell *h1, const hyperpoint& hint) { return relative_matrixc(h2, h1, hint); } + + virtual transmatrix adj(cell *c, int i) { return adj(c->master, i); } + virtual transmatrix adj(heptagon *h, int i); + transmatrix iadj(cell *c, int i) { cell *c1 = c->cmove(i); return adj(c1, c->c().spin(i)); } transmatrix iadj(heptagon *h, int d) { - heptagon *h1 = h->cmove(d); return adj(h1, h->c.spin(d)); + heptagon *h1 = h->cmove(d); return adj(h1, h->c().spin(d)); } virtual void draw_all(); virtual void draw_at(cell *at, const shiftmatrix& where); @@ -94,8 +99,8 @@ struct hrmap { **/ struct hrmap_standard : hrmap { void draw_at(cell *at, const shiftmatrix& where) override; - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override; - transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) override; + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override; + transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override; heptagon *create_step(heptagon *h, int direction) override; transmatrix adj(cell *c, int d) override; transmatrix adj(heptagon *h, int d) override; @@ -218,7 +223,7 @@ hrmap_hyperbolic::hrmap_hyperbolic() { origin = hyperbolic_origin(); } void hrmap::find_cell_connection(cell *c, int d) { heptagon *h2 = createStep(c->master, d); - c->c.connect(d, h2->c7,c->master->c.spin(d), c->master->c.mirror(d)); + c->c().connect(d, h2->c7,c->master->c().spin(d), c->master->c().mirror(d)); hybrid::link(); } @@ -252,7 +257,7 @@ void hrmap_standard::find_cell_connection(cell *c, int d) { for(int u=0; uc7->c.connect(hs.spin, n, u, hs.mirrored); + hs.at->c7->c().connect(hs.spin, n, u, hs.mirrored); if(hs.mirrored && (S7%2 == 0)) hs--; hs = hs + alt3 + wstep - alt4; } @@ -264,7 +269,7 @@ void hrmap_standard::find_cell_connection(cell *c, int d) { else { cellwalker cw(c, d, false); cellwalker cw2 = cw - 1 + wstep - 1 + wstep - 1; - c->c.connect(d, cw2); + c->c().connect(d, cw2); hybrid::link(); } } @@ -280,8 +285,8 @@ EX cell *createMov(cell *c, int d) { EX void eumerge(cell* c1, int s1, cell *c2, int s2, bool mirror) { if(!c2) return; - c1->move(s1) = c2; c1->c.setspin(s1, s2, mirror); - c2->move(s2) = c1; c2->c.setspin(s2, s1, mirror); + c1->move(s1) = c2; c1->c().setspin(s1, s2, mirror); + c2->move(s2) = c1; c2->c().setspin(s2, s1, mirror); } // map, cell*> euclidean; @@ -335,13 +340,13 @@ EX void clearcell(cell *c) { if(!c) return; DEBB(DF_MEMORY, (format("c%d %p\n", c->type, hr::voidp(c)))); for(int t=0; ttype; t++) if(c->move(t)) { - DEBB(DF_MEMORY, (format("mov %p [%p] S%d\n", hr::voidp(c->move(t)), hr::voidp(c->move(t)->move(c->c.spin(t))), c->c.spin(t)))); - if(c->move(t)->move(c->c.spin(t)) != NULL && - c->move(t)->move(c->c.spin(t)) != c) { - DEBB(DF_MEMORY | DF_ERROR, (format("cell error: type = %d %d -> %d\n", c->type, t, c->c.spin(t)))); + DEBB(DF_MEMORY, (format("mov %p [%p] S%d\n", hr::voidp(c->move(t)), hr::voidp(c->move(t)->move(c->c().spin(t))), c->c().spin(t)))); + if(c->move(t)->move(c->c().spin(t)) != NULL && + c->move(t)->move(c->c().spin(t)) != c) { + DEBB(DF_MEMORY | DF_ERROR, (format("cell error: type = %d %d -> %d\n", c->type, t, c->c().spin(t)))); exit(1); } - c->move(t)->move(c->c.spin(t)) = NULL; + c->move(t)->move(c->c().spin(t)) = NULL; } DEBB(DF_MEMORY, (format("DEL %p\n", hr::voidp(c)))); destroy_cell(c); @@ -414,13 +419,13 @@ EX void clearfrom(heptagon *at) { q.push(at->move(i)); unlink_cdata(at->move(i)); at->move(i)->alt = &deletion_marker; - DEBB(DF_MEMORY, ("!mov ", at->move(i), " [", at->move(i)->move(at->c.spin(i)), "]")); - if(at->move(i)->move(at->c.spin(i)) != NULL && - at->move(i)->move(at->c.spin(i)) != at) { + DEBB(DF_MEMORY, ("!mov ", at->move(i), " [", at->move(i)->move(at->c().spin(i)), "]")); + if(at->move(i)->move(at->c().spin(i)) != NULL && + at->move(i)->move(at->c().spin(i)) != at) { DEBB(DF_MEMORY | DF_ERROR, ("hept error")); exit(1); } - at->move(i)->move(at->c.spin(i)) = NULL; + at->move(i)->move(at->c().spin(i)) = NULL; at->move(i) = NULL; } clearHexes(at); @@ -435,8 +440,8 @@ EX void verifycell(cell *c) { cell *c2 = c->move(i); if(c2) { if(BITRUNCATED && c == c->master->c7) verifycell(c2); - if(c2->move(c->c.spin(i)) && c2->move(c->c.spin(i)) != c) { - printf("cell error %p:%d [%d] %p:%d [%d]\n", hr::voidp(c), i, c->type, hr::voidp(c2), c->c.spin(i), c2->type); + if(c2->move(c->c().spin(i)) && c2->move(c->c().spin(i)) != c) { + printf("cell error %p:%d [%d] %p:%d [%d]\n", hr::voidp(c), i, c->type, hr::voidp(c2), c->c().spin(i), c2->type); exit(1); } } @@ -445,11 +450,11 @@ EX void verifycell(cell *c) { EX void verifycells(heptagon *at) { if(GOLDBERG || IRREGULAR || arcm::in()) return; - for(int i=0; itype; i++) if(at->move(i) && at->move(i)->move(at->c.spin(i)) && at->move(i)->move(at->c.spin(i)) != at) { - printf("hexmix error %p [%d s=%d] %p %p\n", hr::voidp(at), i, at->c.spin(i), hr::voidp(at->move(i)), hr::voidp(at->move(i)->move(at->c.spin(i)))); + for(int i=0; itype; i++) if(at->move(i) && at->move(i)->move(at->c().spin(i)) && at->move(i)->move(at->c().spin(i)) != at) { + printf("hexmix error %p [%d s=%d] %p %p\n", hr::voidp(at), i, at->c().spin(i), hr::voidp(at->move(i)), hr::voidp(at->move(i)->move(at->c().spin(i)))); } if(!sphere && !quotient) - for(int i=0; imove(i) && at->c.spin(i) == 0 && at->s != hsOrigin) + for(int i=0; imove(i) && at->c().spin(i) == 0 && at->s != hsOrigin) verifycells(at->move(i)); verifycell(at->c7); } @@ -1007,7 +1012,7 @@ EX int getBits(cell *c) { EX cell *heptatdir(cell *c, int d) { if(d&1) { cell *c2 = createMov(c, d); - int s = c->c.spin(d); + int s = c->c().spin(d); s += 3; s %= 6; return createMov(c2, s); } diff --git a/complex.cpp b/complex.cpp index 34b0a7b30..2a9593e00 100644 --- a/complex.cpp +++ b/complex.cpp @@ -1524,7 +1524,7 @@ EX namespace mirror { int icount = 0, isum = 0; for(int i=0; i<6; i+=2) { - if(createMov(c, i)->bardir == c->c.spin(i)) + if(createMov(c, i)->bardir == c->c().spin(i)) icount++, isum+=i; } if(icount != 1) return -1; @@ -1597,7 +1597,7 @@ EX namespace mirror { } int icount = 0; for(int i=0; i<3; i++) { - if((cw+wstep).at->bardir == cw.at->c.spin(cw.spin)) + if((cw+wstep).at->bardir == cw.at->c().spin(cw.spin)) icount++; cw += 2; } @@ -1613,7 +1613,7 @@ EX namespace mirror { printf("icount >= 2 but failed\n"); return cw; } - while((cw+wstep).at->bardir != cw.at->c.spin(cw.spin)) { + while((cw+wstep).at->bardir != cw.at->c().spin(cw.spin)) { stepcount++; if(stepcount > 10000) { printf("fail2\n"); return cw; } cw += 2; v.push_back(1); @@ -2622,7 +2622,7 @@ EX namespace dragon { if(maxlen--<0) return c; if(c->monst == moDragonHead) return c; for(int i=0; itype; i++) - if(c->move(i) && isDragon(c->move(i)->monst) && c->move(i)->mondir == c->c.spin(i)) { + if(c->move(i) && isDragon(c->move(i)->monst) && c->move(i)->mondir == c->c().spin(i)) { c = c->move(i); goto findhead; } if(cmode & sm::MAP) return c; @@ -2881,7 +2881,7 @@ EX namespace sword { int sub = (hybri) ? 2 : 0; int t2 = c2->type - sub; int t1 = c1->type - sub; - if(c1->c.mirror(s1)) + if(c1->c().mirror(s1)) d.angle = ((s2*sword_angles/t2 - d.angle + s1*sword_angles/t1) + sword_angles/2) % sword_angles; else d.angle = ((s2*sword_angles/t2 - s1*sword_angles/t1) + sword_angles/2 + d.angle) % sword_angles; @@ -3031,8 +3031,8 @@ EX namespace kraken { vector > acells; acells.push_back(make_pair(c2, c)); forCellIdEx(c3, i, c) { - c3->monst = moKrakenT, c3->mondir = c->c.spin(i), c3->monmirror = c->monmirror ^ c->c.mirror(i), onpath(c3, 0); - int i0 = (i+c->c.spin(c->mondir)-c->mondir+96+c->type/2) % c2->type; + c3->monst = moKrakenT, c3->mondir = c->c().spin(i), c3->monmirror = c->monmirror ^ c->c().mirror(i), onpath(c3, 0); + int i0 = (i+c->c().spin(c->mondir)-c->mondir+96+c->type/2) % c2->type; c3->hitpoints = hpcount[i0]; acells.push_back(make_pair(c2->move(i0), c3)); if(c3->wall == waBoat) { diff --git a/control.cpp b/control.cpp index 3ddf04eeb..99e33932b 100644 --- a/control.cpp +++ b/control.cpp @@ -163,13 +163,13 @@ EX void calcMousedest() { for(int i=0; itype; i++) if(dists[i] < mousedist) { mousedist = dists[i]; - mousedest.d = cwt.at->c.fix(i - cwt.spin); + mousedest.d = cwt.at->c().fix(i - cwt.spin); mousedest.subdir = - dists[cwt.at->c.fix(i+1)] < dists[cwt.at->c.fix(i-1)] ? 1 : -1; + dists[cwt.at->c().fix(i+1)] < dists[cwt.at->c().fix(i-1)] ? 1 : -1; if(cwt.mirrored) - mousedest.d = cwt.at->c.fix(-mousedest.d), + mousedest.d = cwt.at->c().fix(-mousedest.d), mousedest.subdir = -mousedest.subdir; } diff --git a/crystal.cpp b/crystal.cpp index d0d3c01e9..e70a9b783 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -581,7 +581,7 @@ struct hrmap_crystal : hrmap_standard { auto st1 = get_canonical(co1); for(int d1=0; d1c.connect(d, h1, (d1+S7/2) % S7, false); + h->c().connect(d, h1, (d1+S7/2) % S7, false); return h1; } @@ -600,16 +600,16 @@ struct hrmap_crystal : hrmap_standard { auto lw1 = lw+wstep; apply_period(c1); - h->c.connect(d, heptspin(get_heptagon_at(c1, S7), lw1.spin)); + h->c().connect(d, heptspin(get_heptagon_at(c1, S7), lw1.spin)); } else { auto coc = add(add(co, lw, HALFSTEP), lw+1, HALFSTEP); auto hc = get_heptagon_at(coc, 8); apply_period(coc); for(int a=0; a<8; a+=2) { - hc->c.connect(a, heptspin(h, lw.spin)); + hc->c().connect(a, heptspin(h, lw.spin)); if(h->modmove(lw.spin-1)) { - hc->c.connect(a+1, heptspin(h, lw.spin) - 1 + wstep - 1); + hc->c().connect(a+1, heptspin(h, lw.spin) - 1 + wstep - 1); } co = add(co, lw, FULLSTEP); apply_period(co); @@ -643,7 +643,7 @@ struct hrmap_crystal : hrmap_standard { transmatrix U = T * cr.M; - ld go = hdist0(U * tC0(cgi.adjmoves[h->c.spin(d)])); + ld go = hdist0(U * tC0(cgi.adjmoves[h->c().spin(d)])); if(go > 1e-2) continue; for(int s=0; smove(i)) return adj(h1->master, i); @@ -683,7 +683,7 @@ struct hrmap_crystal : hrmap_standard { return xpush(999); } - virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { if(!crystal3()) return hrmap::relative_matrix(h2, h1, hint); return relative_matrix(h2->c7, h1->c7, hint); } @@ -1714,9 +1714,9 @@ void transform_crystal_to_euclid () { for(int i=0; imove(i) = spacemap[co + shifttable[i]], - h->c.setspin(i, (i + 3) % 6, false), + h->c().setspin(i, (i + 3) % 6, false), h->c7->move(i) = h->move(i)->c7, - h->c7->c.setspin(i, (i + 3) % 6, false); + h->c7->c().setspin(i, (i + 3) % 6, false); } clearAnimations(); @@ -1785,9 +1785,9 @@ void transform_euclid_to_crystal () { if(m->heptagon_at.count(co1)) { auto lw1 = lw+wstep; h->move(i) = m->heptagon_at[co1], - h->c.setspin(i, lw1.spin, false), + h->c().setspin(i, lw1.spin, false), h->c7->move(i) = h->move(i)->c7; - h->c7->c.setspin(i, h->c.spin(i), false); + h->c7->c().setspin(i, h->c().spin(i), false); } } } diff --git a/devmods/honeycomb-rule-generator.cpp b/devmods/honeycomb-rule-generator.cpp index 56f219703..8e3a5904b 100644 --- a/devmods/honeycomb-rule-generator.cpp +++ b/devmods/honeycomb-rule-generator.cpp @@ -73,7 +73,7 @@ string find_path(cell *x, cell *y, int steps) { if(y->move(j) && y->move(j)->FV < y->FV) { string ch = find_path(x->move(i), y->move(j), steps-1); if(ch == "?") continue; - return dis(i) + ch + dis(y->c.spin(j)); + return dis(i) + ch + dis(y->c().spin(j)); } return "?"; } @@ -188,7 +188,7 @@ void listnear_exh(cell *c, ext_nei_rules_t& e, int maxdist) { e.dir.push_back(i); e.original.push_back(!dist.count(c1)); if(e.original.back() && di < maxdist) - enqueue(c1, di, ca->c.spin(i)); + enqueue(c1, di, ca->c().spin(i)); } } } @@ -433,7 +433,7 @@ void test_canonical(string fname) { c2 = c1->move(b); if(!c2) continue; if(c2->FV >= c1->FV) continue; - dir = c1->c.spin(b); + dir = c1->c().spin(b); break; } } @@ -449,7 +449,7 @@ void test_canonical(string fname) { println(hlog, "c1 fv = ", c1->FV, " [", a, "]"); if(c2 == nullptr) { println(hlog, "c2 missing"); } else - println(hlog, "c2 fv = ", c2->FV, " [", c2->c.spin(dir), "]"); + println(hlog, "c2 fv = ", c2->FV, " [", c2->c().spin(dir), "]"); println(hlog, c, "->", c1, "->", c2); fflush(stdout); diff --git a/devmods/manual-animation.cpp b/devmods/manual-animation.cpp index e5e14b7cc..78cb60e1c 100644 --- a/devmods/manual-animation.cpp +++ b/devmods/manual-animation.cpp @@ -125,7 +125,7 @@ namespace sn { pair getcoord(heptagon *h); } bignum bdiff(heptagon *h1, heptagon *h2) { if(h1 == h2) return 0; auto p = bdiff(h1->move(3), h2->move(3)); - int d = h1->c.spin(3) - h2->c.spin(3); + int d = h1->c().spin(3) - h2->c().spin(3); println(hlog, "d=", d, " p = ", p.get_str(10000)); return p + p + bignum(d); } diff --git a/dpgen.cpp b/dpgen.cpp index 879c151c4..7671ce47d 100644 --- a/dpgen.cpp +++ b/dpgen.cpp @@ -50,7 +50,7 @@ void solve(cpos at) { if(!ca1) continue; if(ca1->wall != waNone) continue; - int s = (c1->c.spin((d+k)%4) - c0->c.spin(k)) & 3; + int s = (c1->c().spin((d+k)%4) - c0->c().spin(k)) & 3; enqueue(make_tuple(ca0, ca1, s), dist+1, i); } } @@ -264,4 +264,4 @@ auto sbhook = addHook(hooks_args, 100, [] { #endif EX } -} \ No newline at end of file +} diff --git a/environment.cpp b/environment.cpp index f0717bef5..4d4ffc1c6 100644 --- a/environment.cpp +++ b/environment.cpp @@ -220,7 +220,7 @@ EX void computePathdist(eMonster param, bool include_allies IS(true)) { continue; } - onpath(c2, d+1, c->c.spin(i)); + onpath(c2, d+1, c->c().spin(i)); } else if(c2 && c2->wall == waClosedGate && princess) @@ -389,7 +389,7 @@ EX void bfs() { if(!keepLightning) c2->ligon = 0; dcal.push_back(c2); - reachedfrom.push_back(c->c.spin(i)); + reachedfrom.push_back(c->c().spin(i)); checkTide(c2); diff --git a/euclid.cpp b/euclid.cpp index 8f147396f..675b4207c 100644 --- a/euclid.cpp +++ b/euclid.cpp @@ -219,7 +219,7 @@ EX namespace euc { for(int i=0; ic.connect(d1, parent, d, mirr); + h->c().connect(d1, parent, d, mirr); return h; } @@ -260,7 +260,7 @@ EX namespace euc { } } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { if(eu.twisted) { if(h1 == h2) return Id; for(int s=0; smove(s)) return adj(h1, s); @@ -1153,7 +1153,7 @@ EX gp::loc full_coords2(cell *c) { } } if(BITRUNCATED) - return to_loc(ans) * gp::loc(1,1) + (c == c->master->c7 ? gp::loc(0,0) : gp::eudir((c->c.spin(0)+4)%6)); + return to_loc(ans) * gp::loc(1,1) + (c == c->master->c7 ? gp::loc(0,0) : gp::eudir((c->c().spin(0)+4)%6)); if(GOLDBERG) { auto li = gp::get_local_info(c); gp::loc shift(0,0); diff --git a/expansion.cpp b/expansion.cpp index 8d7a8600a..b322a8406 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -458,7 +458,7 @@ EX int parent_id(cell *c, int which, const cellfunction& cf) { int steps = 0; again: if(!which || steps == c->type) return i; - int i2 = c->c.fix(i+which); + int i2 = c->c().fix(i+which); if(cf(c->cmove(i2)) == d) { i = i2; steps++; goto again; } @@ -1038,4 +1038,4 @@ EX int hyperbolic_celldistance(cell *c1, cell *c2) { } } -} \ No newline at end of file +} diff --git a/fake.cpp b/fake.cpp index 253797e9a..8afbb881e 100644 --- a/fake.cpp +++ b/fake.cpp @@ -79,7 +79,7 @@ EX namespace fake { } heptagon *create_step(heptagon *parent, int d) override { - parent->c.connect(d, parent, d, false); + parent->c().connect(d, parent, d, false); return parent; } @@ -179,7 +179,7 @@ EX namespace fake { } } - transmatrix relative_matrix(cell *h2, cell *h1, const hyperpoint& hint) override { + transmatrix relative_matrixc(cell *h2, cell *h1, const hyperpoint& hint) override { if(arcm::in()) return underlying_map->relative_matrix(h2, h1, hint); if(h1 == h2) return Id; @@ -189,7 +189,7 @@ EX namespace fake { return Id; } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { if(arcm::in()) return underlying_map->relative_matrix(h2, h1, hint); return relative_matrix(h2->c7, h1->c7, hint); } diff --git a/floorshapes.cpp b/floorshapes.cpp index 9123c14b0..991872be8 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -389,8 +389,8 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i for(int i=0; ic.fix(ri); - cornerlist.push_back(mid(get_corner_position(c, ri, 3.1), get_corner_position(c, c->c.fix(ri+1), 3.1))); + ri = c->c().fix(ri); + cornerlist.push_back(mid(get_corner_position(c, ri, 3.1), get_corner_position(c, c->c().fix(ri+1), 3.1))); } } } @@ -409,7 +409,7 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i for(int i=0; ic.fix(ri); + ri = c->c().fix(ri); hyperpoint nc = nearcorner(c, ri); cornerlist.push_back(mid_at(hpxy(0,0), nc, .94)); } @@ -701,14 +701,14 @@ void geometry_information::generate_floorshapes() { modelh.c7 = &model; model.type = modelh.type = S7; - auto mmerge1 = [&] (int i, int j) { model.c.setspin(i, j, false); modelh.c.setspin(i, j, false); }; + auto mmerge1 = [&] (int i, int j) { model.c().setspin(i, j, false); modelh.c().setspin(i, j, false); }; auto mmerge = [&] (int i, int j) { mmerge1(i, j); mmerge1(j, i); }; for(int i=0; i(co)], get<1>(co), get<2>(co)); - ms.c.connect(j, &models[get<0>(co)], get<1>(co), get<2>(co)); + mh.c().connect(j, &modelh[get<0>(co)], get<1>(co), get<2>(co)); + ms.c().connect(j, &models[get<0>(co)], get<1>(co), get<2>(co)); } } for(int i=0; ifixd(si.dir))) != (siid+1)%3) printf("threecolor mismatch direction\n"); - sidir = c1->c.fix(si.dir); + sidir = c1->c().fix(si.dir); } else if(geosupport_football() == 2) { siid = !pseudohept(c1); @@ -960,8 +960,8 @@ int hrmap_standard::shvid(cell *c) { for(int i=0; itype; i++) - if(c->move(i) && isWorm(c->move(i)->monst) && c->move(i)->mondir == c->c.spin(i)) + if(c->move(i) && isWorm(c->move(i)->monst) && c->move(i)->mondir == c->c().spin(i)) return c->move(i); return nullptr; } diff --git a/geometry2.cpp b/geometry2.cpp index 49b3f4e05..c4985ce0d 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -77,7 +77,7 @@ transmatrix hrmap_standard::master_relative(cell *c, bool get_inverse) { else if(BITRUNCATED) { if(c == c->master->c7) return Id; - return (get_inverse?cgi.invhexmove:cgi.hexmove)[c->c.spin(0)]; + return (get_inverse?cgi.invhexmove:cgi.hexmove)[c->c().spin(0)]; } else if(WDIM == 3) return Id; @@ -99,12 +99,12 @@ transmatrix hrmap_standard::adj(heptagon *h, int d) { if(inforder::mixed()) { int t0 = h->type; int t1 = h->cmove(d)->type; - int sp = h->c.spin(d); + int sp = h->c().spin(d); return spin(-d * 2 * M_PI / t0) * xpush(spacedist(h->c7, d)) * spin(M_PI + 2*M_PI*sp/t1); } transmatrix T = cgi.heptmove[d]; - if(h->c.mirror(d)) T = T * Mirror; - int sp = h->c.spin(d); + if(h->c().mirror(d)) T = T * Mirror; + int sp = h->c().spin(d); if(sp) T = T * spin(2*M_PI*sp/S7); return T; } @@ -120,11 +120,11 @@ EX transmatrix relative_matrix_via_masters(cell *c2, cell *c1, const hyperpoint& return gm * U * where; } -transmatrix hrmap_standard::relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) { +transmatrix hrmap_standard::relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) { return relative_matrix_via_masters(c2, c1, hint); } -transmatrix hrmap_standard::relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) { +transmatrix hrmap_standard::relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) { transmatrix gm = Id, where = Id; // always add to last! @@ -494,9 +494,9 @@ transmatrix hrmap_standard::adj(cell *c, int i) { } double d = cellgfxdist(c, i); transmatrix T = ddspin(c, i) * xpush(d); - if(c->c.mirror(i)) T = T * Mirror; + if(c->c().mirror(i)) T = T * Mirror; cell *c1 = c->cmove(i); - T = T * iddspin(c1, c->c.spin(i), M_PI); + T = T * iddspin(c1, c->c().spin(i), M_PI); return T; } diff --git a/goldberg.cpp b/goldberg.cpp index 315b383f3..c55a291dd 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -124,7 +124,7 @@ EX namespace gp { else { vector dirs; while(c != c->master->c7) { - dirs.push_back(c->c.spin(0)); + dirs.push_back(c->c().spin(0)); c = c->move(0); } li.first_dir = dirs[0]; @@ -236,7 +236,7 @@ EX namespace gp { } else { peek(wcw) = newCell(SG6, wc.cw.at->master); - wcw.at->c.setspin(wcw.spin, 0, false); + wcw.at->c().setspin(wcw.spin, 0, false); set_localwalk(wc1, dir1, wcw + wstep); if(do_adjm) wc1.adjm = wc.adjm; spawn++; @@ -256,7 +256,7 @@ EX namespace gp { else { DEBB(DF_GP, ("ok")); peek(wcw) = wcw1.at; - wcw.at->c.setspin(wcw.spin, wcw1.spin, wcw.mirrored != wcw1.mirrored); + wcw.at->c().setspin(wcw.spin, wcw1.spin, wcw.mirrored != wcw1.mirrored); if(wcw+wstep != wcw1) { DEBB(DF_GP | DF_ERROR, ("assertion failed")); exit(1); @@ -289,14 +289,14 @@ EX namespace gp { DEBB(DF_GP, ("EXTEND ",c, " ", d)); if(c->master->c7 != c) { while(c->master->c7 != c) { - DEBB(DF_GP, (c, " direction 0 corresponds to ", c->move(0), " direction ", c->c.spin(0)); ) - d = c->c.spin(0); + DEBB(DF_GP, (c, " direction 0 corresponds to ", c->move(0), " direction ", c->c().spin(0)); ) + d = c->c().spin(0); c = c->move(0); } // c move 0 equals c' move spin(0) extend_map(c, d); - extend_map(c, c->c.fix(d-1)); - extend_map(c, c->c.fix(d+1)); + extend_map(c, c->c().fix(d-1)); + extend_map(c, c->c().fix(d+1)); if(S3 == 4 && !c->move(d)) for(int i=0; imaster, i)->c7); - auto d1 = master_function(createStep(cm->master, cm->c.fix(i+1))->c7); + auto d1 = master_function(createStep(cm->master, cm->c().fix(i+1))->c7); if(S3 == 4) { heptspin hs(cm->master, i); @@ -1131,11 +1131,11 @@ EX namespace gp { return c; } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { return in_underlying([&] { return currentmap->relative_matrix(h2, h1, hint); }); } - transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) override { + transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override { c1 = mapping[c1]; c2 = mapping[c2]; return in_underlying([&] { return currentmap->relative_matrix(c2, c1, hint); }); @@ -1184,7 +1184,7 @@ EX namespace gp { cw --; }); cw.at = get_mapped(cw.at, 0); - parent->c.connect(d, cw.at, cw.spin, cw.mirrored); + parent->c().connect(d, cw.at, cw.spin, cw.mirrored); return cw.at; } if(UNTRUNCATED) { @@ -1193,7 +1193,7 @@ EX namespace gp { cw += wstep; }); cw.at = get_mapped(cw.at, cw.spin & 1); - parent->c.connect(d, cw.at, cw.spin / 2, cw.mirrored); + parent->c().connect(d, cw.at, cw.spin / 2, cw.mirrored); return cw.at; } if(WARPED) { @@ -1202,7 +1202,7 @@ EX namespace gp { cellwalker cw(mapping[parent], d); in_underlying([&] { cw += wstep; }); cw.at = get_mapped(cw.at, cw.spin & 1); - parent->c.connect(d, cw.at, cw.spin / 2, cw.mirrored); + parent->c().connect(d, cw.at, cw.spin / 2, cw.mirrored); return cw.at; } else { @@ -1211,7 +1211,7 @@ EX namespace gp { cw += wstep; }); cw.at = get_mapped(cw.at, 2); - parent->c.connect(d, cw.at, cw.spin, cw.mirrored); + parent->c().connect(d, cw.at, cw.spin, cw.mirrored); return cw.at; } } diff --git a/graph.cpp b/graph.cpp index 3b077c89e..95296bfcc 100644 --- a/graph.cpp +++ b/graph.cpp @@ -2581,7 +2581,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col int d = c->mondir; if(d == NODIR) forCellIdEx(c2, i, c) - if(among(c2->monst, moHexSnakeTail, moHexSnake) && c2->mondir == c->c.spin(i)) + if(among(c2->monst, moHexSnakeTail, moHexSnake) && c2->mondir == c->c().spin(i)) d = i; if(d == NODIR) { d = hrand(c->type); createMov(c, d); } int c1 = nestcolors[pattern_threecolor(c)]; @@ -2726,7 +2726,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col else if(m == moDragonTail) { cell *c2 = NULL; for(int i=0; itype; i++) - if(c->move(i) && isDragon(c->move(i)->monst) && c->move(i)->mondir == c->c.spin(i)) + if(c->move(i) && isDragon(c->move(i)->monst) && c->move(i)->mondir == c->c().spin(i)) c2 = c->move(i); int nd = neighborId(c, c2); char part = dragon::bodypart(c, dragon::findhead(c)); @@ -2778,7 +2778,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col bool hexsnake = c->monst == moHexSnake || c->monst == moHexSnakeTail; cell *c2 = NULL; for(int i=0; itype; i++) - if(c->move(i) && isWorm(c->move(i)->monst) && c->move(i)->mondir == c->c.spin(i)) + if(c->move(i) && isWorm(c->move(i)->monst) && c->move(i)->mondir == c->c().spin(i)) c2 = c->move(i); int nd = neighborId(c, c2); if(nospinb) { @@ -5569,7 +5569,7 @@ struct animation { EX array, ANIMLAYERS> animations; EX int revhint(cell *c, int hint) { - if(hint >= 0 && hint < c->type) return c->c.spin(hint); + if(hint >= 0 && hint < c->type) return c->c().spin(hint); else return hint; } @@ -5602,7 +5602,7 @@ EX void animateMovement(const movei& m, int layer) { a.footphase = 0; a.mirrored = false; } - if(m.proper() && m.s->c.mirror(m.d)) + if(m.proper() && m.s->c().mirror(m.d)) a.mirrored = !a.mirrored; } diff --git a/heptagon.cpp b/heptagon.cpp index 87a2ca32f..615a79908 100644 --- a/heptagon.cpp +++ b/heptagon.cpp @@ -72,7 +72,7 @@ EX hstate transition(hstate s, int dir) { EX heptagon *buildHeptagon1(heptagon *h, heptagon *parent, int d, hstate s, int pard IS(0)) { h->alt = NULL; h->s = s; - h->c.connect(pard, parent, d, false); + h->c().connect(pard, parent, d, false); h->cdata = NULL; return h; } @@ -129,10 +129,10 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix if(fixdistance != COMPUTE) h->distance = fixdistance; else if(S3 == 4 && BITRUNCATED) { h->distance = parent->distance + 2; - if(h->c.spin(0) == 2 || (h->c.spin(0) == 3 && S7 <= 5)) + if(h->c().spin(0) == 2 || (h->c().spin(0) == 3 && S7 <= 5)) h->distance = min(h->distance, createStep(h->move(0), 0)->distance + 3); - if(h->c.spin(0) == 2 && h->move(0)) { - int d = h->c.spin(0); + if(h->c().spin(0) == 2 && h->move(0)) { + int d = h->c().spin(0); int d1 = (d+S7-1)%S7; bool missing0 = !h->move(0)->move(d1); if(missing0) { @@ -146,19 +146,19 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix } } if((h->s == hsB && h->move(0)->s == hsB) || h->move(0)->s == hsA) { - int d = h->c.spin(0); + int d = h->c().spin(0); heptagon* h1 = createStep(h->move(0), (d+1)%S7); if(h1->distance <= h->move(0)->distance) h->distance = h->move(0)->distance+1; } - if(h->c.spin(0) == S7-1 && (h->move(0)->s != hsOrigin) && BITRUNCATED) { + if(h->c().spin(0) == S7-1 && (h->move(0)->s != hsOrigin) && BITRUNCATED) { bool missing = !h->move(S7-1); if(missing) { h->distance = parent->distance; if( parent->distance - h->move(0)->move(0)->distance == 1 && - h->c.spin(0) == S7 - 1 && - h->move(0)->c.spin(0) == 2) + h->c().spin(0) == S7 - 1 && + h->move(0)->c().spin(0) == 2) h->distance++; } else { @@ -171,7 +171,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix } else if(parent->s == hsOrigin) h->distance = parent->distance + gp::dist_2(); #if CAP_GP - else if(S3 == 4 && GOLDBERG && h->c.spin(0) == S7-2 && h->move(0)->c.spin(0) >= S7-2 && h->move(0)->move(0)->s != hsOrigin) { + else if(S3 == 4 && GOLDBERG && h->c().spin(0) == S7-2 && h->move(0)->c().spin(0) >= S7-2 && h->move(0)->move(0)->s != hsOrigin) { heptspin hs(h, 0); hs += wstep; int d1 = hs.at->distance; @@ -181,7 +181,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix int d0 = hs.at->distance; h->distance = gp::solve_triangle(dm, d0, d1, gp::param * gp::loc(-1,1)); } - else if(S3 == 4 && GOLDBERG && h->c.spin(0) == S7-1 && among(h->move(0)->c.spin(0), S7-2, S7-3) && h->move(0)->move(0)->s != hsOrigin) { + else if(S3 == 4 && GOLDBERG && h->c().spin(0) == S7-1 && among(h->move(0)->c().spin(0), S7-2, S7-3) && h->move(0)->move(0)->s != hsOrigin) { heptspin hs(h, 0); hs += wstep; int d0 = hs.at->distance; @@ -191,11 +191,11 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix int d1 = hs.at->distance; h->distance = gp::solve_triangle(dm, d0, d1, gp::param * gp::loc(1,1)); } - else if(S3 == 4 && GOLDBERG && h->c.spin(0) >= 2 && h->c.spin(0) <= S7-2) { + else if(S3 == 4 && GOLDBERG && h->c().spin(0) >= 2 && h->c().spin(0) <= S7-2) { h->distance = parent->distance + gp::dist_2(); } #endif - else if(h->c.spin(0) == S7-2) { + else if(h->c().spin(0) == S7-2) { #if CAP_GP if(GOLDBERG) { int d0 = parent->distance; @@ -206,7 +206,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix #endif h->distance = parent->distance + gp::dist_1(); } - else if(h->c.spin(0) == S7-3 && h->move(0)->s == hsB) { + else if(h->c().spin(0) == S7-3 && h->move(0)->s == hsB) { #if CAP_GP if(GOLDBERG) { int d0 = parent->distance; @@ -215,9 +215,9 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix h->distance = gp::solve_triangle(dm, d0, d1, gp::param * gp::loc(1,1)); } else #endif - h->distance = createStep(h->move(0), (h->c.spin(0)+2)%S7)->distance + gp::dist_3(); + h->distance = createStep(h->move(0), (h->c().spin(0)+2)%S7)->distance + gp::dist_3(); } - else if(h->c.spin(0) == S7-1 && S3 == 4 && GOLDBERG) { + else if(h->c().spin(0) == S7-1 && S3 == 4 && GOLDBERG) { h->distance = parent->distance + gp::dist_1(); } else h->distance = parent->distance + gp::dist_2(); @@ -246,10 +246,10 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix int recsteps; void addSpin(heptagon *h, int d, heptagon *from, int rot, int spin) { - rot = h->c.fix(rot); + rot = h->c().fix(rot); auto h1 = createStep(from, rot); - int fr = h1->c.fix(from->c.spin(rot) + spin); - h->c.connect(d, from->move(rot), fr, false); + int fr = h1->c().fix(from->c().spin(rot) + spin); + h->c().connect(d, from->move(rot), fr, false); } extern int hrand(int); @@ -258,7 +258,7 @@ EX hookset hooks_createStep; // create h->move(d) if not created yet heptagon *createStep(heptagon *h, int d) { - d = h->c.fix(d); + d = h->c().fix(d); if(h->move(d)) return h->move(d); callhooks(hooks_createStep, h, d); return currentmap->create_step(h, d); @@ -284,12 +284,12 @@ heptagon *hrmap_standard::create_step(heptagon *h, int d) { if(d == 1) { heptspin hs(h, 0, false); hs = hs + wstep - 1 + wstep - 1 + wstep - 1; - h->c.connect(d, hs); + h->c().connect(d, hs); } else if(h->s == hsB && d == S7-1) { heptspin hs(h, 0, false); hs = hs + wstep + 1 + wstep + 1 + wstep + 1; - h->c.connect(d, hs); + h->c().connect(d, hs); } else buildHeptagon(h, d, transition(h->s, d)); @@ -301,18 +301,18 @@ heptagon *hrmap_standard::create_step(heptagon *h, int d) { // buildHeptagon(h, d, transition(h->s, d)); } else if(d == 1) { - addSpin(h, d, h->move(0), h->c.spin(0)-1, -1); + addSpin(h, d, h->move(0), h->c().spin(0)-1, -1); } else if(d == S7-1) { - addSpin(h, d, h->move(0), h->c.spin(0)+1, +1); + addSpin(h, d, h->move(0), h->c().spin(0)+1, +1); } else if(d == 2) { - createStep(h->move(0), h->c.spin(0)-1); - addSpin(h, d, h->move(0)->modmove(h->c.spin(0)-1), S7-2 + h->move(0)->c.modspin(h->c.spin(0)-1), -1); + createStep(h->move(0), h->c().spin(0)-1); + addSpin(h, d, h->move(0)->modmove(h->c().spin(0)-1), S7-2 + h->move(0)->c().modspin(h->c().spin(0)-1), -1); } else if(d == S7-2 && h->s == hsB) { - createStep(h->move(0), h->c.spin(0)+1); - addSpin(h, d, h->move(0)->modmove(h->c.spin(0)+1), 2 + h->move(0)->c.modspin(h->c.spin(0)+1), +1); + createStep(h->move(0), h->c().spin(0)+1); + addSpin(h, d, h->move(0)->modmove(h->c().spin(0)+1), 2 + h->move(0)->c().modspin(h->c().spin(0)+1), +1); } else buildHeptagon(h, d, (d == S7-2 || (h->s == hsB && d == S7-3)) ? hsB : hsA); @@ -323,7 +323,7 @@ heptagon *hrmap_standard::create_step(heptagon *h, int d) { void backtrace(heptagon *pos) { if(pos->s == hsOrigin) return; backtrace(pos->move(0)); - printf(" %d", pos->c.spin(0)); + printf(" %d", pos->c().spin(0)); } void hsshow(const heptspin& t) { diff --git a/hypgraph.cpp b/hypgraph.cpp index b2ea1538c..fcf718e92 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1662,7 +1662,7 @@ EX bool drawcell_subs(cell *c, const shiftmatrix& V) { } if(BITRUNCATED) forCellIdEx(c1, d, c) { - if(c->c.spin(d) == 0) { + if(c->c().spin(d) == 0) { shiftmatrix V2 = V * currentmap->adj(c, d); if(do_draw(c1, V2)) draw = true, diff --git a/inforder.cpp b/inforder.cpp index a32094d2a..e19886d88 100644 --- a/inforder.cpp +++ b/inforder.cpp @@ -26,7 +26,7 @@ EX namespace inforder { if(mixed()) deg = 7 - deg; auto h1 = init_heptagon(deg); bool par = h->s == hsA && direction == 0; - h->c.connect(direction, h1, par ? 1 + hrand(2) : 0, false); + h->c().connect(direction, h1, par ? 1 + hrand(2) : 0, false); h1->s = hsA; h1->distance = h->distance + (par ? -1 : 1); diff --git a/irregular.cpp b/irregular.cpp index 9ca840056..e8264078e 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -537,7 +537,7 @@ EX void link_to_base(heptagon *h, heptspin base) { EX void clear_links(heptagon *h) { auto& hi = periodmap[h]; for(cell *c: hi.subcells) { - for(int i=0; itype; i++) if(c->move(i)) c->move(i)->move(c->c.spin(i)) = NULL; + for(int i=0; itype; i++) if(c->move(i)) c->move(i)->move(c->c().spin(i)) = NULL; cellindex.erase(c); delete c; } @@ -552,9 +552,9 @@ EX void link_start(heptagon *h) { EX void link_next(heptagon *parent, int d) { if(!periodmap.count(parent)) link_to_base(parent, heptspin(cells[0].owner->master, 0)); - // printf("linking next: %p direction %d [s%d]\n", hr::voidp(parent), d, parent->c.spin(d)); + // printf("linking next: %p direction %d [s%d]\n", hr::voidp(parent), d, parent->c().spin(d)); auto *h = parent->move(d); - heptspin hs = periodmap[parent].base + d + wstep - parent->c.spin(d); + heptspin hs = periodmap[parent].base + d + wstep - parent->c().spin(d); link_to_base(h, hs); } @@ -591,7 +591,7 @@ EX void link_cell(cell *c, int d) { } cell *c2 = periodmap[master2].subcells[sc2.localindex]; - c->c.connect(d, c2, sc.spin[d], false); + c->c().connect(d, c2, sc.spin[d], false); } int hdist(heptagon *h1, heptagon *h2) { diff --git a/kite.cpp b/kite.cpp index 14d1531c2..2094c4336 100644 --- a/kite.cpp +++ b/kite.cpp @@ -168,7 +168,7 @@ struct hrmap_kite : hrmap { heptagon *hspawn(heptagon *of, int our, int their, pshape s) { auto h = newtile(s, of->distance + (our ? 1 : -1)); if(bt::in()) bt::make_binary_lands(of, h); - of->c.connect(our, h, their, false); + of->c().connect(our, h, their, false); return h; } @@ -184,13 +184,13 @@ struct hrmap_kite : hrmap { if(sh == pDart && dir == 1) return hspawn(of, 1, 0, pKite); if(sh == pDart && dir == 2) return hspawn(of, 2, 0, pDart); - if(sh == pDart && dir == 3) of->c.connect(3, of, 3, false); /* illegal */ + if(sh == pDart && dir == 3) of->c().connect(3, of, 3, false); /* illegal */ /* generated by findmore */ - #define RULEFOR(sh0, dir0, z, dir1) if(sh == sh0 && dir == dir0) { heptagon *at = of; if(z true) of->c.connect(dir0, at, dir1, false); } + #define RULEFOR(sh0, dir0, z, dir1) if(sh == sh0 && dir == dir0) { heptagon *at = of; if(z true) of->c().connect(dir0, at, dir1, false); } #define GO(our, shape) (at = at->cmove(our)) && getshape(at) == shape && - #define GOIF(our, shape, their) at->cmove(our) && at->c.spin(our) == their && getshape(at->move(our)) == shape && (at = at->move(our), true) && + #define GOIF(our, shape, their) at->cmove(our) && at->c().spin(our) == their && getshape(at->move(our)) == shape && (at = at->move(our), true) && RULEFOR(pDart, 5, GOIF(0, pDart, 2) GO(4, pKite) GO(3, pDart), 4) RULEFOR(pDart, 5, GOIF(0, pDart, 2) GO(4, pDart) GO(6, pKite) GO(2, pKite), 5) @@ -303,9 +303,9 @@ struct hrmap_kite : hrmap { transmatrix adj(cell *c, int dir) override { if(no_adj) return Id; auto c1 = c->cmove(dir); - auto code = encode(getshape(c->master), dir, getshape(c1->master), c->c.spin(dir)); + auto code = encode(getshape(c->master), dir, getshape(c1->master), c->c().spin(dir)); if(!graphrules.count(code)) { - println(hlog, "rule missing: ", make_tuple(getshape(c->master), dir, getshape(c1->master), c->c.spin(dir))); + println(hlog, "rule missing: ", make_tuple(getshape(c->master), dir, getshape(c1->master), c->c().spin(dir))); throw 0; } return graphrules[code]; @@ -313,7 +313,7 @@ struct hrmap_kite : hrmap { /* works only for dir = 0,1,2,3 */ transmatrix get_tmatrix(heptagon *h2, int dir, bool inverted) { - if(dir == 0) inverted = !inverted, h2->cmove(dir), tie(dir, h2) = make_pair(h2->c.spin(dir), h2->move(dir)); + if(dir == 0) inverted = !inverted, h2->cmove(dir), tie(dir, h2) = make_pair(h2->c().spin(dir), h2->move(dir)); if(inverted) { if(dir == 1) return getshape(h2) == pKite ? ipKite1 : ipDart1; if(dir == 2) return getshape(h2) == pKite ? ipKite2 : ipDart2; @@ -326,7 +326,7 @@ struct hrmap_kite : hrmap { } } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { if(gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7)) return inverse_shift(gmatrix0[h1->c7], gmatrix0[h2->c7]); transmatrix gm = Id, where = Id; @@ -361,7 +361,7 @@ EX hrmap *new_map() { return new hrmap_kite; } hrmap_kite *kite_map() { return (hrmap_kite*) currentmap; } void con(cell *c0, int d0, cell *c1, int d1) { - c0->c.connect(d0, c1, d1, false); + c0->c().connect(d0, c1, d1, false); } EX void find_cell_connection(cell *c, int d) { @@ -374,13 +374,13 @@ EX void find_cell_connection(cell *c, int d) { if(sibling != 8) h = h->cmove(sibling); if(getshape(h) != s1) { printf("bad s1\n"); exit(1); } con(c, d0, h->c7, d1); - // c->c.connect(d0, h->c7, d1, false); + // c->c().connect(d0, h->c7, d1, false); } - if(sh == s1 && d == d1 && sibling == 8 && getshape(h0->cmove(0)) == s0 && h0->c.spin(0) == child) + if(sh == s1 && d == d1 && sibling == 8 && getshape(h0->cmove(0)) == s0 && h0->c().spin(0) == child) con(c, d1, h0->cmove(0)->c7, d0); - // c->c.connect(d1, h0->cmove(0)->c7, d0, false); - if(sh == s1 && d == d1 && sibling != 8 && (h0->cmove(rsibling), h0->c.spin(rsibling) == sibling) && getshape(h0->cmove(rsibling)) == sparent && getshape(h0->cmove(rsibling)->cmove(0)) == s0) - // c->c.connect(d1, h0->cmove(sibling)->cmove(0)->c7, d0, false); + // c->c().connect(d1, h0->cmove(0)->c7, d0, false); + if(sh == s1 && d == d1 && sibling != 8 && (h0->cmove(rsibling), h0->c().spin(rsibling) == sibling) && getshape(h0->cmove(rsibling)) == sparent && getshape(h0->cmove(rsibling)->cmove(0)) == s0) + // c->c().connect(d1, h0->cmove(sibling)->cmove(0)->c7, d0, false); con(c, d1, h0->cmove(rsibling)->cmove(0)->c7, d0); }; @@ -388,9 +388,9 @@ EX void find_cell_connection(cell *c, int d) { int dx = d; dx += 4; heptagon *h1 = h0->cmove(dx); - dx = h0->c.spin(dx); + dx = h0->c().spin(dx); dx -= 4; - // c->c.connect(d, h1->c7, h0->c.spin(4+d)-4, false); + // c->c().connect(d, h1->c7, h0->c().spin(4+d)-4, false); con(c, d, h1->c7, dx); return; } diff --git a/landgen.cpp b/landgen.cpp index ae392a4c9..3dc416556 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -720,7 +720,7 @@ EX void giantLandSwitch(cell *c, int d, cell *from) { if(!onwall) for(int i=0; itype; i++) { cell *c2 = c->move(i); if(!c2) continue; - cell *c3 = c2->modmove(c->c.spin(i) + 3); + cell *c3 = c2->modmove(c->c().spin(i) + 3); if(!c3) continue; if(c3->land != laPower && c3->land != laBarrier) if(c2->wall != waFire && c2->wall != waGlass) { @@ -1018,7 +1018,7 @@ EX void giantLandSwitch(cell *c, int d, cell *from) { preventbarriers(c2); c2->mondir = i; createMov(c2, i); - int j = c2->c.spin(i); + int j = c2->c().spin(i); cell *c3 = c2->move(i); if(c3->monst || c3->bardir != NODIR || c3->wall || c3->mpdist <= 7) break; c2 = c3; @@ -1696,7 +1696,7 @@ EX void giantLandSwitch(cell *c, int d, cell *from) { forCellIdEx(c2, i, c) { c2->monst = moKrakenT; c2->hitpoints = 1; - c2->mondir = c->c.spin(i); + c2->mondir = c->c().spin(i); } if(!peace::on) playSound(c, "seen-kraken"); } diff --git a/locations.cpp b/locations.cpp index 904110fde..e0ca15ac9 100644 --- a/locations.cpp +++ b/locations.cpp @@ -126,42 +126,51 @@ template struct walker; int gmod(int i, int j); -template struct connection_table { - - /** \brief Table of moves. This is the maximum size, but tailored_alloc allocates less. */ - T* move_table[FULL_EDGE + (FULL_EDGE + sizeof(char*) - 1) / sizeof(char*)]; - - unsigned char *spintable() { return (unsigned char*) (&move_table[full()->degree()]); } +template +class connection_table_details { + CRTP *crtp() { + static_assert(std::is_base_of::value, ""); + return static_cast(this); + } + T **move_table() { + static_assert(alignof(CRTP) >= alignof(T*), ""); + return (T **)(crtp() + 1); + } + unsigned char *spin_table() { + return (unsigned char *)(move_table() + crtp()->degree()); + } - /** \brief get the full T from the pointer to this connection table */ - T* full() { return (T*)((char*)this - offsetof(T, c)); } +public: /** \brief for the edge d, set the `spin` and `mirror` attributes */ void setspin(int d, int spin, bool mirror) { - unsigned char& c = spintable() [d]; + unsigned char& c = spin_table()[d]; c = spin; if(mirror) c |= 128; } /** \brief we are spin(i)-th neighbor of move[i] */ - int spin(int d) { return spintable() [d] & 127; } + int spin(int d) { return spin_table()[d] & 127; } /** \brief on non-orientable surfaces, the d-th edge may be mirrored */ - bool mirror(int d) { return spintable() [d] & 128; } + bool mirror(int d) { return spin_table()[d] & 128; } /** \brief 'fix' the edge number d to get the actual index in [0, degree()) */ - int fix(int d) { return gmod(d, full()->degree()); } + int fix(int d) { return gmod(d, crtp()->degree()); } /** \brief T in the direction i */ - T*& move(int i) { return move_table[i]; } + T*& move(int i) { return move_table()[i]; } /** \brief T in the direction i, modulo degree() */ T*& modmove(int i) { return move(fix(i)); } unsigned char modspin(int i) { return spin(fix(i)); } /** \brief initialize the table */ - void fullclear() { - for(int i=0; idegree(); i++) move_table[i] = NULL; + void fullclear() { + for(int i=0; i < crtp()->degree(); i++) { + move_table()[i] = nullptr; + spin_table()[i] = 0; + } } /** \brief connect this in direction d0 to c1 in direction d1, possibly mirrored */ void connect(int d0, T* c1, int d1, bool m) { move(d0) = c1; - c1->move(d1) = full(); + c1->move(d1) = crtp(); setspin(d0, d1, m); - c1->c.setspin(d1, d0, m); + c1->setspin(d1, d0, m); } /* like the other connect, but take the parameters of the other cell from a walker */ void connect(int d0, walker hs) { @@ -169,6 +178,18 @@ template struct connection_table { } }; +template +class trailing_connection_table : private connection_table_details { +public: + friend class connection_table_details; + + connection_table_details& c() { return *this; } + + static size_t tailored_alloc_size(int degree) { + return sizeof(CRTP) + (degree * sizeof(T*)) + degree; + } + }; + /** \brief Allocate a class T with a connection_table, but with only `degree` connections. * * Also set yet unknown connections to NULL. @@ -178,23 +199,17 @@ template struct connection_table { */ template T* tailored_alloc(int degree) { - T* result; -#ifndef NO_TAILORED_ALLOC - int b = offsetof(T, c) + offsetof(connection_table, move_table) + sizeof(T*) * degree + degree; - result = (T*) new char[b]; - new (result) T(); -#else - result = new T; -#endif + size_t num_bytes = T::tailored_alloc_size(degree); + T* result = ::new (::operator new(num_bytes)) T; result->type = degree; - for(int i=0; ic.move_table[i] = NULL; + result->c().fullclear(); return result; } /** \brief Counterpart to hr::tailored_alloc(). */ template void tailored_delete(T* x) { x->~T(); - delete[] ((char*) (x)); + ::operator delete((void*)x); } static const struct wstep_t { wstep_t() {} } wstep; @@ -212,15 +227,15 @@ template struct walker { int spin; /** \brief are we mirrored */ bool mirrored; - walker (T *at = NULL, int s = 0, bool m = false) : at(at), spin(s), mirrored(m) { if(at) s = at->c.fix(s); } + walker (T *at = NULL, int s = 0, bool m = false) : at(at), spin(s), mirrored(m) { if(at) s = at->c().fix(s); } /** \brief spin by i to the left (or right, when mirrored */ walker& operator += (int i) { - spin = at->c.fix(spin+(mirrored?-i:i)); + spin = at->c().fix(spin+(mirrored?-i:i)); return (*this); } /** \brief spin by i to the right (or left, when mirrored */ walker& operator -= (int i) { - spin = at->c.fix(spin-(mirrored?-i:i)); + spin = at->c().fix(spin-(mirrored?-i:i)); return (*this); } /** \brief add wmirror to mirror this walker */ @@ -231,8 +246,8 @@ template struct walker { /** \brief add wstep to make a single step, after which we are facing the T we were originally on */ walker& operator += (wstep_t) { at->cmove(spin); - int nspin = at->c.spin(spin); - if(at->c.mirror(spin)) mirrored = !mirrored; + int nspin = at->c().spin(spin); + if(at->c().mirror(spin)) mirrored = !mirrored; at = at->move(spin); spin = nspin; return (*this); @@ -275,7 +290,7 @@ template struct walker { /** \brief would we create a new T if we stepped forwards? */ bool creates() { return !peek(); } /** \brief mirror this walker with respect to the d-th edge */ - walker mirrorat(int d) { return walker (at, at->c.fix(d+d - spin), !mirrored); } + walker mirrorat(int d) { return walker (at, at->c().fix(d+d - spin), !mirrored); } }; struct cell; @@ -314,7 +329,7 @@ constexpr int iteration_limit = 10000000; * heptagons are unused */ -struct heptagon : cdata_or_heptagon { +struct heptagon : cdata_or_heptagon, trailing_connection_table { /** \brief Automata are used to generate the standard maps. s is the state of this automaton */ hstate s : 6; /** \brief distance modulo 4, in heptagons */ @@ -345,16 +360,14 @@ struct heptagon : cdata_or_heptagon { cell *c7; /** \brief associated generator of alternate structure, for Camelot and horocycles */ heptagon *alt; - /** \brief connection table */ - connection_table c; - // DO NOT add any fields after connection_table! (see tailored_alloc) - heptagon*& move(int d) { return c.move(d); } - heptagon*& modmove(int d) { return c.modmove(d); } + + heptagon*& move(int d) { return c().move(d); } + heptagon*& modmove(int d) { return c().modmove(d); } // functions heptagon () { heptacount++; } ~heptagon () { heptacount--; } heptagon *cmove(int d) { return createStep(this, d); } - heptagon *cmodmove(int d) { return createStep(this, c.fix(d)); } + heptagon *cmodmove(int d) { return createStep(this, c().fix(d)); } inline int degree() { return type; } // prevent accidental copying @@ -362,20 +375,17 @@ struct heptagon : cdata_or_heptagon { heptagon& operator=(const heptagon&) = delete; }; -struct cell : gcell { +struct cell : gcell, trailing_connection_table { char type; ///< our degree int degree() { return type; } int listindex; ///< used by celllister heptagon *master; ///< heptagon who owns us; for 'masterless' tilings it contains coordinates instead - connection_table c; - // DO NOT add any fields after connection_table! (see tailored_alloc) - - cell*& move(int d) { return c.move(d); } - cell*& modmove(int d) { return c.modmove(d); } + cell*& move(int d) { return c().move(d); } + cell*& modmove(int d) { return c().modmove(d); } cell* cmove(int d) { return createMov(this, d); } - cell* cmodmove(int d) { return createMov(this, c.fix(d)); } + cell* cmodmove(int d) { return createMov(this, c().fix(d)); } cell() {} // prevent accidental copying @@ -492,11 +502,11 @@ struct movei { movei(cellwalker cw) : s(cw.at), t(cw.cpeek()), d(cw.spin) {} movei rev() const { return movei(t, s, rev_dir_or(d)); } int dir_or(int x) const { return proper() ? d : x; } - int rev_dir_or(int x) const { return proper() ? s->c.spin(d) : x; } - int rev_dir_mirror() const { return proper() ? s->c.spin(d) : d; } - int rev_dir_force() const { hassert(proper()); return s->c.spin(d); } + int rev_dir_or(int x) const { return proper() ? s->c().spin(d) : x; } + int rev_dir_mirror() const { return proper() ? s->c().spin(d) : d; } + int rev_dir_force() const { hassert(proper()); return s->c().spin(d); } int dir_force() const { hassert(proper()); return d; } - bool mirror() { return s->c.mirror(d); } + bool mirror() { return s->c().mirror(d); } }; #endif diff --git a/mapeditor.cpp b/mapeditor.cpp index 575750849..0d5596143 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -655,7 +655,7 @@ EX namespace mapstream { cellids[c->move(j)] < i) { int32_t i = cellids[c->move(j)]; f.write(i); - f.write_char(c->c.spin(j)); + f.write_char(c->c().spin(j)); f.write_char(j); ok = true; break; @@ -814,7 +814,7 @@ EX namespace mapstream { // printf("%p:%d,%d -> %p\n", c2, relspin[parent], dir, c); // spinval becomes xspinval - rspin = gmod(c2->c.spin(dir) - f.read_char(), c->type - sub); + rspin = gmod(c2->c().spin(dir) - f.read_char(), c->type - sub); if(GDIM == 3 && rspin && !hybri) { println(hlog, "rspin in 3D"); throw hstream_exception(); diff --git a/monstergen.cpp b/monstergen.cpp index 1393ece1e..d95c134ca 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -30,7 +30,7 @@ EX int buildIvy(cell *c, int children, int minleaf) { child = c->move(i), leafchild = buildIvy(c->move(i), children-1, 5); else c->move(i)->monst = (leaf++ || peace::on) ? moIvyWait : moIvyHead, - c->move(i)->mondir = c->c.spin(i), + c->move(i)->mondir = c->c().spin(i), c->move(i)->monmirror = c->monmirror; } } @@ -78,7 +78,7 @@ EX void chasmifyEarth(cell *c) { cell *c4 = createMov(c3, i); earthFloor(c4); } - c3->mondir = c->c.spin(d); + c3->mondir = c->c().spin(d); } earthWall(c); c->item = itNone; } @@ -101,7 +101,7 @@ EX void chasmifyElemental(cell *c) { cell *c4 = createMov(c3, i); if(c4->wall != waBarrier) c4->wall = waNone; } - c3->mondir = c->c.spin(d); + c3->mondir = c->c().spin(d); } } c->wall = getElementalWall(c->land); @@ -531,7 +531,7 @@ EX void wandering() { for(int i=0; itype; i++) { c2->move(i)->monst = moKrakenT; c2->move(i)->hitpoints = 1; - c2->move(i)->mondir = c2->c.spin(i); + c2->move(i)->mondir = c2->c().spin(i); } goto found; } @@ -785,7 +785,7 @@ EX void generateSnake(cell *c, int i, int snakecolor) { preventbarriers(c2); c2->mondir = i; createMov(c2, i); - int j = c2->c.spin(i); + int j = c2->c().spin(i); cell *c3 = c2->move(i); if(c3->monst || c3->bardir != NODIR || c3->wall) break; c2 = c3; diff --git a/monstermove.cpp b/monstermove.cpp index ea3a1bfce..1a126b5a5 100644 --- a/monstermove.cpp +++ b/monstermove.cpp @@ -148,7 +148,7 @@ EX void moveMonster(const movei& mi) { if(ct->monst != moTentacleGhost) ct->mondir = d; if(d >= 0) - ct->monmirror = cf->monmirror ^ ct->c.mirror(d); + ct->monmirror = cf->monmirror ^ ct->c().mirror(d); } ct->hitpoints = cf->hitpoints; ct->stuntime = cf->stuntime; @@ -899,7 +899,7 @@ EX void moveWorm(cell *c) { animateMovement(mi, LAYER_BIG); c->monst = eMonster(moWormtail + id); goal->mondir = mi.rev_dir_or(NODIR); - goal->monmirror = c->monmirror ^ c->c.mirror(dir); + goal->monmirror = c->monmirror ^ c->c().mirror(dir); setdist(goal, 6, nullptr); mountmove(mi, true); @@ -945,7 +945,7 @@ EX void ivynext(cell *c) { if(!proper(c2, c2->mondir)) return; /* incorrect data */ if(!isIvy(c2->monst)) break; - if(c2->c.mirror(c2->mondir)) cw.mirrored = !cw.mirrored; + if(c2->c().mirror(c2->mondir)) cw.mirrored = !cw.mirrored; c2 = c2->move(c2->mondir); } @@ -1364,7 +1364,7 @@ EX void movehex_rest(bool mounted) { for(int u=0; utype; u++) { createMov(c, dirtable[u]); if(inpair(c->move(dirtable[u]), colorpair)) - hexvisit(c, c->move(dirtable[u]), c->c.spin(dirtable[u]), mounted, colorpair); + hexvisit(c, c->move(dirtable[u]), c->c().spin(dirtable[u]), mounted, colorpair); } } if(c->monst == moHexSnake) { @@ -1423,7 +1423,7 @@ EX void movemutant() { if((c2->land == laOvergrown || !pseudohept(c2)) && passable(c2, c, 0)) { if(c2->land == laClearing && !bounded && c2->mpdist > 7) continue; c2->monst = moMutant; - c2->mondir = c->c.spin(j); + c2->mondir = c->c().spin(j); c2->stuntime = mutantphase; animateMovement(mi, LAYER_BIG); } diff --git a/mymake.cpp b/mymake.cpp index 09ff92582..a0eff652f 100644 --- a/mymake.cpp +++ b/mymake.cpp @@ -75,7 +75,7 @@ void set_linux() { void set_mac() { preprocessor = "g++ -E"; - compiler = "g++ -march=native -W -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-invalid-offsetof -c"; + compiler = "g++ -march=native -W -Wall -Wextra -Wsuggest-override -pedantic -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-invalid-offsetof -c"; linker = "g++ -o hyper"; opts = "-DMAC -I/usr/local/include"; libs = " -L/usr/local/lib -framework AppKit -framework OpenGL -lSDL -lSDLMain -lSDL_gfx -lSDL_mixer -lSDL_ttf -lpng -lpthread -lz"; diff --git a/nonisotropic.cpp b/nonisotropic.cpp index a31d75480..2412ce5b5 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -300,7 +300,7 @@ EX namespace sn { auto pf = p.first, ps = p.second; auto rule = [&] (heptagon *c1, heptagon *c2, int d1) { auto g = get_at(c1, c2); - parent->c.connect(d, g, d1, false); + parent->c().connect(d, g, d1, false); return g; }; @@ -422,11 +422,11 @@ EX namespace sn { } transmatrix adj(heptagon *h, int d) override { - h->cmove(d); return adjmatrix(d, h->c.spin(d)); + h->cmove(d); return adjmatrix(d, h->c().spin(d)); } - virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { - for(int i=0; itype; i++) if(h1->move(i) == h2) return adjmatrix(i, h1->c.spin(i)); + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + for(int i=0; itype; i++) if(h1->move(i) == h2) return adjmatrix(i, h1->c().spin(i)); if(gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7)) return inverse_shift(gmatrix0[h1->c7], gmatrix0[h2->c7]); @@ -937,13 +937,13 @@ EX namespace nilv { auto q = p * current_ns().movevectors[d]; for(int a=0; a<3; a++) q[a] = zgmod(q[a], nilperiod[a]); auto child = get_at(q); - parent->c.connect(d, child, (d + S7/2) % S7, false); + parent->c().connect(d, child, (d + S7/2) % S7, false); return child; } transmatrix adj(heptagon *h, int i) override { return adjmatrix(i); } - virtual transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { for(int a=0; amove(a)) return adjmatrix(a); auto p = coords[h1].inverse() * coords[h2]; for(int a=0; a<3; a++) p[a] = szgmod(p[a], nilperiod[a]); @@ -1327,12 +1327,12 @@ EX namespace hybrid { int s = cgi.single_step; int lev = m->where[c].second + (d == c->type-1 ? s : -s); cell *c1 = get_at(m->where[c].first, lev); - c->c.connect(d, c1, c1->type - 3 + c->type - d, false); + c->c().connect(d, c1, c1->type - 3 + c->type - d, false); } else { auto cu = m->where[c].first; auto cu1 = m->in_underlying([&] { return cu->cmove(d); }); - int d1 = cu->c.spin(d); + int d1 = cu->c().spin(d); int s = 0; if(geometry == gRotSpace) { auto cm = (hrmap_hybrid*)currentmap; @@ -1340,7 +1340,7 @@ EX namespace hybrid { s = ((hrmap_hybrid*)currentmap)->get_shift(cellwalker(cu, d)); } cell *c1 = get_at(cu1, m->where[c].second + s); - c->c.connect(d, c1, d1, cu->c.mirror(d)); + c->c().connect(d, c1, d1, cu->c().mirror(d)); } } @@ -1427,8 +1427,8 @@ EX namespace hybrid { for(cell *c: xlink) { bool success_here = ss.count(c); if(!success_here) forCellIdEx(c2, i, c) if(ss.count(c2)) { - ss[c].first = ss[c2].first + c->c.spin(i) + wstep - i; - ss[c].second = ss[c2].second + c->c.spin(i) + wstep - i; + ss[c].first = ss[c2].first + c->c().spin(i) + wstep - i; + ss[c].second = ss[c2].second + c->c().spin(i) + wstep - i; success++; success_here = true; break; @@ -1518,7 +1518,7 @@ EX namespace product { int z0; struct hrmap_product : hybrid::hrmap_hybrid { - transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) override { + transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override { return in_underlying([&] { return calc_relative_matrix(where[c2].first, where[c1].first, hint); }) * mscale(Id, cgi.plevel * szgmod(where[c2].second - where[c1].second, hybrid::csteps)); } @@ -1628,7 +1628,7 @@ EX namespace product { cell *c = cl.lst[i]; cellwalker cwc = cws.at(c); forCellIdEx(c2, j, c) { - cellwalker cwc2 = cwc + j + wstep - c->c.spin(j); + cellwalker cwc2 = cwc + j + wstep - c->c().spin(j); if(!cws.count(c2)) cws[c2] = cwc2; else if(cws[c2] != cwc2) return false; cl.add(c2); @@ -2070,7 +2070,7 @@ EX namespace rots { int id1 = shvid(c1); int id2 = shvid(c2); #endif - int j = c1->c.spin(i); + int j = c1->c().spin(i); int id = id1 + (id2 << 10) + (i << 20) + (j << 26); auto &M = saved_matrices[id]; if(M[3][3]) return M; @@ -2079,7 +2079,7 @@ EX namespace rots { return M = lift_matrix(PIU(currentmap->adj(cw, i))); } - virtual transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) override { + transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override { if(c1 == c2) return Id; if(gmatrix0.count(c2) && gmatrix0.count(c1)) return inverse_shift(gmatrix0[c1], gmatrix0[c2]); @@ -2087,7 +2087,7 @@ EX namespace rots { return Id; // not implemented yet } - virtual transmatrix ray_iadj(cell *c1, int i) override { + transmatrix ray_iadj(cell *c1, int i) override { if(i == c1->type-1) return uzpush(-cgi.plevel) * spin(-2*cgi.plevel); if(i == c1->type-2) return uzpush(+cgi.plevel) * spin(+2*cgi.plevel); cell *c2 = c1->cmove(i); @@ -2098,7 +2098,7 @@ EX namespace rots { int id1 = shvid(c1); int id2 = shvid(c2); #endif - int j = c1->c.spin(i); + int j = c1->c().spin(i); int id = id1 + (id2 << 10) + (i << 20) + (j << 26); auto &M = saved_matrices_ray[id]; if(M[3][3]) return M; diff --git a/passable.cpp b/passable.cpp index 64bb49f68..04d4a37a6 100644 --- a/passable.cpp +++ b/passable.cpp @@ -297,7 +297,7 @@ EX ld calcAirdir(cell *c) { for(int i=0; itype; i++) { cell *c2 = c->move(i); if(c2 && c2->monst == moAirElemental) { - return c->c.spin(i) * 2 * M_PI / c2->type; + return c->c().spin(i) * 2 * M_PI / c2->type; } } for(int i=0; itype; i++) { @@ -308,7 +308,7 @@ EX ld calcAirdir(cell *c) { for(int i=0; itype; i++) { cell *c3 = c2->move(i); if(c3 && c3->monst == moAirElemental) { - return c2->c.spin(i) * 2 * M_PI / c3->type; + return c2->c().spin(i) * 2 * M_PI / c3->type; } } } @@ -384,7 +384,7 @@ bool slimepassable(cell *w, cell *c) { if(cellHalfvine(w)) { int i=0; for(int t=0; ttype; t++) if(w->move(t) && w->move(t)->wall == w->wall) i=t; - int z = i-c->c.spin(u); if(z<0) z=-z; z%=6; + int z = i-c->c().spin(u); if(z<0) z=-z; z%=6; if(z>1) return false; hv=(group == ogroup); } diff --git a/pattern2.cpp b/pattern2.cpp index ae257c6d7..79112ca1c 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -369,7 +369,7 @@ EX int zebra40(cell *c) { } else if(sphere) return 0; else if(S3 == 4 && S7 == 6) { - return 8 + ((c->master->zebraval / 10 + c->c.spin(0))%2) * 2; + return 8 + ((c->master->zebraval / 10 + c->c().spin(0))%2) * 2; } else if(reg3::in()) return 0; else { @@ -416,7 +416,7 @@ EX namespace fieldpattern { EX pair fieldval(cell *c) { if(WDIM == 3) return make_pair(currfp.inverses[int(c->master->fieldval) * currfp.local_group], false); else if(ctof(c)) return make_pair(int(c->master->fieldval), false); - else return make_pair(btspin(c->master->fieldval, c->c.spin(0)), true); + else return make_pair(btspin(c->master->fieldval, c->c().spin(0)), true); } EX int fieldval_uniq(cell *c) { @@ -457,7 +457,7 @@ EX int fieldval_uniq(cell *c) { else { int z = 0; for(int u=0; umaster->fieldval, c->c.spin(u))); + z = max(z, btspin(createMov(c, u)->master->fieldval, c->c().spin(u))); return -1-z; } } @@ -474,7 +474,7 @@ EX int fieldval_uniq_rand(cell *c, int randval) { else { int z = 0; for(int u=0; u<6; u+=2) - z = max(z, btspin(currfp.gmul(createMov(c, u)->master->fieldval, randval), c->c.spin(u))); + z = max(z, btspin(currfp.gmul(createMov(c, u)->master->fieldval, randval), c->c().spin(u))); return -1-z; } } @@ -604,7 +604,7 @@ EX int getHemisphere(cell *c, int which) { #endif else { for(int i=0; i<6; i+=2) - score += getHemisphere(c->move(i), which) * (c->c.mirror(i) ? -1 : 1); + score += getHemisphere(c->move(i), which) * (c->c().mirror(i) ? -1 : 1); return score/3; } } @@ -690,7 +690,7 @@ EX namespace patterns { si.dir = 0; // whatever patterninfo si2; valSibling(c->move(0), si2, sub, pat); - int di = si2.dir - c->c.spin(0); + int di = si2.dir - c->c().spin(0); di %= S7; if(di<0) di += S7; if(pat == PAT_SIBLING) si.reflect = di > S7/2; @@ -742,8 +742,8 @@ EX namespace patterns { printf("\n"); */ } else { - si.id = ((c->master->emeraldval & 1) ^ ((c->master->emeraldval & 2)>>1) ^ (c->c.spin(0)&1)) ? 8 : 4; - si.dir = ((c->move(0)->master->emeraldval + c->c.spin(0)) & 1) ? 2 : 0; + si.id = ((c->master->emeraldval & 1) ^ ((c->master->emeraldval & 2)>>1) ^ (c->c().spin(0)&1)) ? 8 : 4; + si.dir = ((c->move(0)->master->emeraldval + c->c().spin(0)) & 1) ? 2 : 0; if(createMov(c, si.dir)->master->emeraldval & 4) si.dir += 4; @@ -803,7 +803,7 @@ EX namespace patterns { si.id += 16, si.symmetries = 4; } else { - int sp = c->c.spin(0); + int sp = c->c().spin(0); #if CAP_GP if(GOLDBERG) { sp = gp::last_dir(c); @@ -853,7 +853,7 @@ EX namespace patterns { cell *c2 = createMov(c, i); int id2 = 4; if(!pseudohept(c2)) { - int sp2 = c2->c.spin(0); + int sp2 = c2->c().spin(0); if(GOLDBERG) { sp2 = gp::last_dir(c2); sp2 ^= int(ishex2(c2)); @@ -1038,7 +1038,7 @@ EX namespace patterns { else if(c == c->master->c7) si.dir = (zebra40(c)*4) % 6; else - si.dir = (zebra40(c)*4 + 9 - c->c.spin(0)) % 6; + si.dir = (zebra40(c)*4 + 9 - c->c().spin(0)) % 6; } if(sub & SPF_ROT) si.id = 1; if(euc::in(2,6) && !(sub & SPF_EXTRASYM)) { @@ -1064,8 +1064,8 @@ EX namespace patterns { #endif #if CAP_GP else if(GOLDBERG) { - if(c == c->master->c7) si.id += (c->c.fix(si.dir) << 8); - else si.id += (get_code(gp::get_local_info(c)) << 16) | (c->c.fix(si.dir) << 8); + if(c == c->master->c7) si.id += (c->c().fix(si.dir) << 8); + else si.id += (get_code(gp::get_local_info(c)) << 16) | (c->c().fix(si.dir) << 8); } #endif return si; @@ -1406,7 +1406,7 @@ EX int pattern_threecolor(cell *c) { if(euclid) { if(a4 && PURE) return eupattern4(c); if(euc::in(2,6) && !BITRUNCATED) return eupattern(c) % 3; - return c == c->master->c7 ? 0 : (c->c.spin(0)&1) ? 1 : 2; + return c == c->master->c7 ? 0 : (c->c().spin(0)&1) ? 1 : 2; } if(S3 >= OINF) return c->master->distance % 3; if(S7 == 4 && S3 == 3) { @@ -1431,9 +1431,9 @@ EX int pattern_threecolor(cell *c) { else for(int i=0; i<3; i++) { cell *c2 = c->move(i); if(c2->master->fiftyval == 0) - return 1 + (c->c.spin(i)&1); + return 1 + (c->c().spin(i)&1); if(c2->master->fiftyval == 5) - return 2 - (c->c.spin(i)&1); + return 2 - (c->c().spin(i)&1); } } if(stdhyperbolic && PURE) { @@ -1852,7 +1852,7 @@ EX namespace patterns { int y = (c->master->fieldval >> 12) & 4095; ignore(x); if(c->master->distance % 3) return 0; - if(c->c.spin(bt::updir()) != 1) return 0; + if(c->c().spin(bt::updir()) != 1) return 0; // if(c->master->distance % 2 == 0) return 0; if(hrand(100) == 0) return 0; return 0x1000000 | (0xFFFFFF & (0x671349 + y * 0x512369)); @@ -2625,7 +2625,7 @@ EX namespace linepatterns { template bool way(T*c, int i) { T* c2 = c->move(i); if(c == c2) - return i <= c->c.spin(i); + return i <= c->c().spin(i); return c2 > c; } diff --git a/pcmove.cpp b/pcmove.cpp index 304c9f1a9..85624b33d 100644 --- a/pcmove.cpp +++ b/pcmove.cpp @@ -1573,7 +1573,7 @@ EX void sideAttack(cell *mf, int dir, eMonster who, int bonus, eItem orb) { if(who != moPlayer && !items[itOrbEmpathy]) return; for(int k: {-1, 1}) { int dir1 = dir + k*bonus; - dir1 = mf->c.fix(dir1); + dir1 = mf->c().fix(dir1); cell *mt = mf->move(dir1); sideAttackAt(mf, dir1, mt, who, orb, mf); } @@ -1677,4 +1677,4 @@ EX void movecost(cell* from, cell *to, int phase) { } } -} \ No newline at end of file +} diff --git a/quotient.cpp b/quotient.cpp index 4a7428d4e..e5979bfe8 100644 --- a/quotient.cpp +++ b/quotient.cpp @@ -369,7 +369,7 @@ struct hrmap_quotient : hrmap_standard { bool swapped = co & symmask; co &= ~symmask; h->move(rv(j)) = allh[co/S7]; - h->c.setspin(rv(j), rv(co%S7), swapped); + h->c().setspin(rv(j), rv(co%S7), swapped); } } diff --git a/raycaster.cpp b/raycaster.cpp index ae99ae8e5..0cdd70647 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -1682,7 +1682,7 @@ struct raycast_map { shiftmatrix Vf; dd.set_land_floor(Vf); color_t wcol = darkena(dd.wcol, 0, 0xFF); - int dv = get_darkval(c1, c->c.spin(i)); + int dv = get_darkval(c1, c->c().spin(i)); float p = 1 - dv / 16.; wallcolor[u] = glhr::acolor(wcol); for(int a: {0,1,2}) wallcolor[u][a] *= p; @@ -1697,7 +1697,7 @@ struct raycast_map { if(col == 0) wallcolor[u] = glhr::acolor(0); else { - int dv = get_darkval(c1, c->c.spin(i)); + int dv = get_darkval(c1, c->c().spin(i)); float p = 1 - dv / 16.; wallcolor[u] = glhr::acolor(col); for(int a: {0,1,2}) wallcolor[u][a] *= p; diff --git a/reg3.cpp b/reg3.cpp index 46e49f959..d9bdb6460 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -689,7 +689,7 @@ EX namespace reg3 { heptagon *getOrigin() override { return allh[0]; } - transmatrix relative_matrix(cell *h2, cell *h1, const hyperpoint& hint) override; + transmatrix relative_matrixc(cell *h2, cell *h1, const hyperpoint& hint) override; void initialize(int cell_count); vector& allcells() override { return acells; } @@ -879,7 +879,7 @@ EX namespace reg3 { if(hdist(ctr1, ss[id1].face_centers[j]) < 1e-6) { transmatrix T2 = T1 * va.T; if(id == id1 && eqmatrix(T2, Id)) continue; - c->c.connect(i, c1, j, false); + c->c().connect(i, c1, j, false); if(!found) { tmcell.push_back(ss[id].from_cellcenter * T2 * ss[id1].to_cellcenter); auto& ms = move_sequences[local_id[c].first]; @@ -938,7 +938,7 @@ EX namespace reg3 { if(found && !testing_subconnections) break; } if(testing_subconnections && !found) { - c->c.connect(i, c, i, false); + c->c().connect(i, c, i, false); tmcell.push_back(Id); } foundtab.push_back(found); @@ -950,7 +950,7 @@ EX namespace reg3 { if(failures && !testing_subconnections) throw hr_exception("hrmap_closed3 failures"); } - transmatrix hrmap_closed3::relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) { + transmatrix hrmap_closed3::relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) { if(c1 == c2) return Id; int d = hr::celldistance(c2, c1); @@ -988,7 +988,7 @@ EX namespace reg3 { heptagon *h1 = get_heptagon_at(co); for(int d=0; d<8; d++) { int b = encode_coord(crystal::get_coord(h1->cmove(d))); - allh[a]->c.connect(d, allh[b], h1->c.spin(d), false); + allh[a]->c().connect(d, allh[b], h1->c().spin(d), false); tmatrices[a].push_back(crystal::get_adj(h1, d)); } } @@ -1027,7 +1027,7 @@ EX namespace reg3 { k = f->matcode[ f->mmul(f->mmul(f->matrices[k], f->matrices[moveid[b]]), f->P) ]; for(int l=0; lgmul(k, l) % lgr == 0) { tmatrices[a][b] = cgi.adjmoves[b] * f->fullv[l]; - allh[a]->c.connect(b, allh[k/lgr], movedir[l], false); + allh[a]->c().connect(b, allh[k/lgr], movedir[l], false); } } } @@ -1206,7 +1206,7 @@ EX namespace reg3 { initialize(1); tmatrices[0].resize(S7); for(int b=0; bc.connect(b, allh[0], (b+S7/2) % S7, false); + allh[0]->c().connect(b, allh[0], (b+S7/2) % S7, false); transmatrix T = cgi.adjmoves[b]; hyperpoint p = tC0(T); tmatrices[0][b] = rspintox(p) * xpush(hdist0(p)) * cspin(2, 1, angle) * spintox(p); @@ -1226,7 +1226,7 @@ EX namespace reg3 { if(b < 6) x[b]++; else x[b-6]--; int a1 = get_rep(x); - allh[a]->c.connect(b, allh[a1], flip(b), false); + allh[a]->c().connect(b, allh[a1], flip(b), false); transmatrix T = cgi.adjmoves[b]; hyperpoint p = tC0(T); tmatrices[a][b] = rspintox(p) * xpush(hdist0(p)) * cspin(2, 1, 108 * degree) * spintox(p); @@ -1399,7 +1399,7 @@ EX namespace reg3 { hyperpoint old = tC0(p1.second);; #if CAP_FIELD if(quotient_map) { - p2.first->c.connect(counterpart(parent)->c.spin(d), parent, d, false); + p2.first->c().connect(counterpart(parent)->c().spin(d), parent, d, false); fix_distances(p2.first, parent); return p2.first; } @@ -1409,7 +1409,7 @@ EX namespace reg3 { if((err = intval(back, old)) < 1e-3) { if(err > worst_error2) println(hlog, format("worst_error2 = %lg", double(worst_error2 = err))); if(p2.first->move(d2)) println(hlog, "error: repeated edge"); - p2.first->c.connect(d2, parent, d, false); + p2.first->c().connect(d2, parent, d, false); fix_distances(p2.first, parent); fb++; } @@ -1420,7 +1420,7 @@ EX namespace reg3 { for(int d2=0; d2c.connect(d, parent, d, false); + parent->c().connect(d, parent, d, false); return parent; } return p2.first; @@ -1433,8 +1433,8 @@ EX namespace reg3 { #if CAP_FIELD if(quotient_map) { auto cp = counterpart(parent); - d2 = cp->c.spin(d); - fv = cp->c.move(d)->fieldval; + d2 = cp->c().spin(d); + fv = cp->c().move(d)->fieldval; } #endif heptagon *created = init_heptagon(S7); @@ -1453,7 +1453,7 @@ EX namespace reg3 { fixmatrix(T); reg_gmatrix[created] = make_pair(alt, T); altmap[alt].emplace_back(created, T); - created->c.connect(d2, parent, d, false); + created->c().connect(d2, parent, d, false); return created; } @@ -1505,7 +1505,7 @@ EX namespace reg3 { return relative_matrix(h->cmove(d), h, C0); } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { auto p1 = reg_gmatrix[h1]; auto p2 = reg_gmatrix[h2]; transmatrix T = Id; @@ -1529,7 +1529,7 @@ EX namespace reg3 { hyperpoint hfront = tC0(cgi.adjmoves[cw.spin]); cw.at->cmove(j); transmatrix T = currentmap->adj(cw.at, j); - for(int i=0; ic.spin(j)) + for(int i=0; ic().spin(j)) if(hdist(hfront, T * tC0(cgi.adjmoves[i])) < cgi.strafedist + .01) return cellwalker(cw.at->cmove(j), i); throw hr_exception("incorrect strafe"); @@ -1569,7 +1569,7 @@ EX namespace reg3 { for(int d2=0; d2c.connect(d, allh[i1], d2, false); + allh[i]->c().connect(d, allh[i1], d2, false); fb++; tmi.push_back(inverse(T1) * locations[i1]); } @@ -1599,7 +1599,7 @@ EX namespace reg3 { locations.push_back(T); if(isnan(T[0][0])) exit(1); - allh[i]->c.connect(d, h, d2, false); + allh[i]->c().connect(d, h, d2, false); tmi.push_back(inverse(T1) * T); } next_d: ; @@ -1613,7 +1613,7 @@ EX namespace reg3 { clearfrom(allh[0]); } - struct transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { return iso_inverse(locations[h1->fieldval]) * locations[h2->fieldval]; } @@ -1857,8 +1857,8 @@ EX namespace reg3 { if(id < 0) id += (1<<16); auto cp = counterpart(parent); - int d2 = cp->c.spin(d); - int fv = cp->c.move(d)->fieldval; + int d2 = cp->c().spin(d); + int fv = cp->c().move(d)->fieldval; // indenter ind(2); @@ -1883,7 +1883,7 @@ EX namespace reg3 { res->distance = parent->distance + 1; res->fiftyval = id1; find_emeraldval(res, parent, d); - // res->c.connect(d2, parent, d, false); + // res->c().connect(d2, parent, d, false); } else if(other[pos] == ('A' + d) && other[pos+1] == ',') { @@ -1914,7 +1914,7 @@ EX namespace reg3 { if(res->move(d2)) println(hlog, "res conflict"); - res->c.connect(d2, parent, d, false); + res->c().connect(d2, parent, d, false); return res; } @@ -1927,11 +1927,11 @@ EX namespace reg3 { return quotient_map->adj(h, d); } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { return relative_matrix_recursive(h2, h1); } - transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) override { + transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override { if(PURE) return relative_matrix(c2->master, c1->master, hint); return relative_matrix_via_masters(c2, c1, hint); } @@ -1986,7 +1986,7 @@ EX namespace reg3 { void find_cell_connection(cell *c, int d) override { if(PURE) { auto h = c->master->cmove(d); - c->c.connect(d, h->c7, c->master->c.spin(d), false); + c->c().connect(d, h->c7, c->master->c().spin(d), false); return; } int id = cell_id.at(c); @@ -1995,7 +1995,7 @@ EX namespace reg3 { h = h->cmove(dir); auto ac = quotient_map->acells[id]; cell *c1 = get_cell_at(h, quotient_map->local_id[ac->move(d)].first); - c->c.connect(d, c1, ac->c.spin(d), false); + c->c().connect(d, c1, ac->c().spin(d), false); } transmatrix ray_iadj(cell *c, int i) override { @@ -2011,7 +2011,7 @@ EX namespace reg3 { cw.at->cmove(j); transmatrix T = currentmap->adj(cw.at, j); cellwalker res1; - for(int i=0; ic.spin(j)) + for(int i=0; ic().spin(j)) if(hdist(hfront, T * tC0(cgi.adjmoves[i])) < cgi.strafedist + .01) res1 = cellwalker(cw.at->cmove(j), i); diff --git a/rogueviz/banachtarski.cpp b/rogueviz/banachtarski.cpp index 31e9da080..fdc3f4063 100644 --- a/rogueviz/banachtarski.cpp +++ b/rogueviz/banachtarski.cpp @@ -53,7 +53,7 @@ bool test_uniq(cellwalker cw, int z, int lev, cell *par) { template void recursively(cell *c, cell *c1, const T& t) { t(c); for(int i=0; itype; i++) - if(c->move(i) && c->c.spin(i) == 0 && c->move(i) != c1) + if(c->move(i) && c->c().spin(i) == 0 && c->move(i) != c1) recursively(c->move(i), c, t); } diff --git a/rogueviz/fifteen.cpp b/rogueviz/fifteen.cpp index 892847637..5e7a96fc1 100644 --- a/rogueviz/fifteen.cpp +++ b/rogueviz/fifteen.cpp @@ -81,13 +81,13 @@ string dotted(int i) { /** where = empty square */ void make_move(cell *where, int dir) { auto nw = where->cmove(dir); - auto mir = where->c.mirror(dir); + auto mir = where->c().mirror(dir); auto& f0 = fif[where]; auto& f1 = fif[nw]; f0.current = f1.current; f0.currentmirror = f1.currentmirror ^ mir; int d = f1.currentdir; - d -= where->c.spin(dir); + d -= where->c().spin(dir); if(mir) d *= -1; d += dir; if(!mir) d += nw->type/2; @@ -99,7 +99,7 @@ void check_move() { for(int i=0; itype; i++) { cell *c1 = cwt.at->cmove(i); if(fif.count(c1) && fif[c1].current == Empty) { - make_move(c1, cwt.at->c.spin(i)); + make_move(c1, cwt.at->c().spin(i)); } } } diff --git a/rogueviz/grigorchuk.cpp b/rogueviz/grigorchuk.cpp index 0b5200070..c31d34b5d 100644 --- a/rogueviz/grigorchuk.cpp +++ b/rogueviz/grigorchuk.cpp @@ -389,7 +389,7 @@ struct hrmap_grigorchuk : hrmap_standard { gtie(h, pr); } - h->c.connect(d == 2 ? 2 : 1-d, p, d, false);; + h->c().connect(d == 2 ? 2 : 1-d, p, d, false);; return h; } @@ -421,13 +421,13 @@ struct hrmap_grigorchuk : hrmap_standard { } } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { if(gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7)) return inverse_shift(gmatrix0[h1->c7], gmatrix0[h2->c7]); return Id; } - transmatrix relative_matrix(cell *c2, cell *c1, const struct hyperpoint& hint) override { + transmatrix relative_matrixc(cell *c2, cell *c1, const struct hyperpoint& hint) override { if(gmatrix0.count(c2) && gmatrix0.count(c1)) return inverse_shift(gmatrix0[c1], gmatrix0[c2]); return Id; diff --git a/rogueviz/kohonen.cpp b/rogueviz/kohonen.cpp index 77beba65f..a1056bce5 100644 --- a/rogueviz/kohonen.cpp +++ b/rogueviz/kohonen.cpp @@ -561,7 +561,7 @@ pair get_cellcrawler_id(cell *c) { #endif else { id = c->type == S7; - // if(id == 0) ld = c->c.spin(0); + // if(id == 0) ld = c->c().spin(0); } /* if(geometry == gZebraQuotient) { id = 8*id + ld; diff --git a/rogueviz/notknot.cpp b/rogueviz/notknot.cpp index c5fe91b3e..221fd21f0 100644 --- a/rogueviz/notknot.cpp +++ b/rogueviz/notknot.cpp @@ -239,7 +239,7 @@ struct hrmap_notknot : hrmap { return euc::get_at(co); } - /* make sure that where->move(d) and where->c.spin(d) are known */ + /* make sure that where->move(d) and where->c().spin(d) are known */ void cmov(heptagon *where, int d) { if(where->move(d)) return; dynamicval g(geometry, base); @@ -393,7 +393,7 @@ struct hrmap_notknot : hrmap { if(u->ptr[d]) return u->ptr[d]; cmov(u->where, d); auto x = u->where->move(d); - auto d1 = u->where->c.spin(d); + auto d1 = u->where->c().spin(d); auto z = x->zebraval; if(z & 6) { throw hr_exception("zebraval failure!"); @@ -537,7 +537,7 @@ struct hrmap_notknot : hrmap { vector> visited; auto visit = [&] (ucover *from, ucover *at, int ldir, const transmatrix& T) { - // println(hlog, from ? from->where : (heptagon*)nullptr, " -> ", at->where, " (", i, ")", " (reverse ", at->where->c.spin(i), ")"); + // println(hlog, from ? from->where : (heptagon*)nullptr, " -> ", at->where, " (", i, ")", " (reverse ", at->where->c().spin(i), ")"); if(camefrom.count(at->where)) { vector path; vector rpath; @@ -545,7 +545,7 @@ struct hrmap_notknot : hrmap { while(at->where != u->where) { int d = camefrom[at->where]; // println(hlog, "from ", at->where, " going back ", d); - rpath.push_back(at->where->c.spin(d)); + rpath.push_back(at->where->c().spin(d)); at = gen_adj(at, d); } while(!rpath.empty()) { path.push_back(rpath.back()); rpath.pop_back(); } @@ -587,7 +587,7 @@ struct hrmap_notknot : hrmap { for(auto v: cgi.vertices_only) for(auto v1: cgi.vertices_only) if(hdist(M * v1, Tj * v) < 1e-3) adj = true; - if(adj) visit(at, u2, at->where->c.spin(j), Tj); + if(adj) visit(at, u2, at->where->c().spin(j), Tj); } } } @@ -755,7 +755,7 @@ struct hrmap_notknot : hrmap { throw hr_exception("where confusion"); for(int d=0; dwhere->type; d++) { cmov(uf->where, d); - auto d1 = uf->where->c.spin(d); + auto d1 = uf->where->c().spin(d); if(uf->ptr[d]) { if(!ut->ptr[d]) { /* was a known connection in uf, but not in ut -- reconnect it to ut */ @@ -950,15 +950,15 @@ struct hrmap_notknot : hrmap { for(int d=0; dwhere, d); - auto d1 = u->where->c.spin(d); + auto d1 = u->where->c().spin(d); if(u->ptr[d] && u->ptr[d]->result == nullptr) throw hr_exception(lalign(0, "connection to null in state ", u->ptr[d]->state, " from state ", u->state, " i=", i, " .. ", u->ptr[d]->index)); if(u->ptr[d] && u->ptr[d]->ptr[d1] != u) throw hr_exception("wrong connection"); if(u->ptr[d]) - u->result->c.connect(d, u->ptr[d]->result, d1, false); + u->result->c().connect(d, u->ptr[d]->result, d1, false); else - u->result->c.connect(d, u->result, d, false); + u->result->c().connect(d, u->result, d, false); } } @@ -1103,7 +1103,7 @@ struct hrmap_notknot : hrmap { ray::volumetric::enable(); } - transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { + transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { return Id; } diff --git a/rogueviz/rewriting.cpp b/rogueviz/rewriting.cpp index c1260b924..c7f8ee0ea 100644 --- a/rogueviz/rewriting.cpp +++ b/rogueviz/rewriting.cpp @@ -51,7 +51,7 @@ struct hrmap_rewrite : hrmap_hyperbolic { int next = h->zebraval; if(matches.empty() && next == 0) { - h->c.connect(0, h, 0, false); + h->c().connect(0, h, 0, false); return h; } @@ -76,12 +76,12 @@ struct hrmap_rewrite : hrmap_hyperbolic { } int next1 = 0; for(auto& match2: matches1) { if(match2.first == s) break; next1++; } - h->c.connect(next, h1, next1, false); + h->c().connect(next, h1, next1, false); } else { int deg = 1 + isize(find_matches(m)); auto h1 = tailored_alloc (deg); - h->c.connect(next, h1, 0, false); + h->c().connect(next, h1, 0, false); h1->alt = NULL; h1->s = hsA; diff --git a/savemem.cpp b/savemem.cpp index 7bf9e74c6..3c2d9e62a 100644 --- a/savemem.cpp +++ b/savemem.cpp @@ -44,7 +44,7 @@ void slow_delete_cell(cell *c) { degrade(c); for(int i=0; itype; i++) if(c->move(i)) - c->move(i)->move(c->c.spin(i)) = NULL; + c->move(i)->move(c->c().spin(i)) = NULL; removed_cells.push_back(c); delete c; } @@ -59,7 +59,7 @@ void delete_heptagon(heptagon *h2) { slow_delete_cell(c); for(int i=0; imove(i)) - h2->move(i)->move(h2->c.spin(i)) = NULL; + h2->move(i)->move(h2->c().spin(i)) = NULL; delete h2; } diff --git a/shmup.cpp b/shmup.cpp index fa62a65a9..1f092f6e7 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1113,7 +1113,7 @@ void movePlayer(monster *m, int delta) { } else if(isPushable(c2->wall) && !nonAdjacent(c2, m->base)) { int sd1 = neighborId(c2, m->base); - int sd = m->base->c.spin(sd1); + int sd = m->base->c().spin(sd1); int subdir = 1; double bestd = 9999; for(int di=-1; di<2; di+=2) { diff --git a/sphere.cpp b/sphere.cpp index 7ed5a9c1b..c116f1ac7 100644 --- a/sphere.cpp +++ b/sphere.cpp @@ -32,7 +32,7 @@ struct hrmap_spherical : hrmap_standard { h.emeraldval = i; h.zebraval = i; h.fiftyval = i; - h.c.fullclear(); + h.c().fullclear(); h.fieldval = i; if(!IRREGULAR) h.c7 = newCell(S7, &h); } @@ -44,27 +44,27 @@ struct hrmap_spherical : hrmap_standard { if(S7 == 3 && S3 == 4) { for(int i=0; i<8; i++) { dodecahedron[i]->move(0) = dodecahedron[i^1]; - dodecahedron[i]->c.setspin(0, 0, false); + dodecahedron[i]->c().setspin(0, 0, false); dodecahedron[i]->move(1) = dodecahedron[i^2]; - dodecahedron[i]->c.setspin(1, 1, false); + dodecahedron[i]->c().setspin(1, 1, false); dodecahedron[i]->move(2) = dodecahedron[i^4]; - dodecahedron[i]->c.setspin(2, 2, false); + dodecahedron[i]->c().setspin(2, 2, false); } for(int i=0; i<8; i++) { int s = (i&1)+((i&2)>>1)+((i&4)>>2); if((s&1) == 1) { swap(dodecahedron[i]->move(1), dodecahedron[i]->move(2)); - int a = dodecahedron[i]->c.spin(1); - int b = dodecahedron[i]->c.spin(2); - dodecahedron[i]->c.setspin(1, b, false); - dodecahedron[i]->c.setspin(2, a, false); - dodecahedron[i]->move(1)->c.setspin(b, 1, false); - dodecahedron[i]->move(2)->c.setspin(a, 2, false); + int a = dodecahedron[i]->c().spin(1); + int b = dodecahedron[i]->c().spin(2); + dodecahedron[i]->c().setspin(1, b, false); + dodecahedron[i]->c().setspin(2, a, false); + dodecahedron[i]->move(1)->c().setspin(b, 1, false); + dodecahedron[i]->move(2)->c().setspin(a, 2, false); } } for(int i=0; i<8; i++) for(int j=0; j<3; j++) - if(dodecahedron[i]->move(j)->move(dodecahedron[i]->c.spin(j)) != dodecahedron[i]) + if(dodecahedron[i]->move(j)->move(dodecahedron[i]->c().spin(j)) != dodecahedron[i]) println(hlog, "8"); } @@ -73,59 +73,59 @@ struct hrmap_spherical : hrmap_standard { int i1 = (i+1)%3; int i2 = (i+2)%3; dodecahedron[i]->move(0) = dodecahedron[i1]; - dodecahedron[i]->c.setspin(0, 1, false); + dodecahedron[i]->c().setspin(0, 1, false); dodecahedron[i]->move(1) = dodecahedron[i2]; - dodecahedron[i]->c.setspin(1, 0, false); + dodecahedron[i]->c().setspin(1, 0, false); dodecahedron[i]->move(2) = dodecahedron[i1]; - dodecahedron[i]->c.setspin(2, 3, true); + dodecahedron[i]->c().setspin(2, 3, true); dodecahedron[i]->move(3) = dodecahedron[i2]; - dodecahedron[i]->c.setspin(3, 2, true); + dodecahedron[i]->c().setspin(3, 2, true); } } else for(int i=0; imove(i) = dodecahedron[i+1]; - dodecahedron[0]->c.setspin(i, 0, false); + dodecahedron[0]->c().setspin(i, 0, false); dodecahedron[i+1]->move(0) = dodecahedron[0]; - dodecahedron[i+1]->c.setspin(0, i, false); + dodecahedron[i+1]->c().setspin(0, i, false); dodecahedron[i+1]->move(1) = dodecahedron[(i+S7-1)%S7+1]; - dodecahedron[i+1]->c.setspin(1, S7-1, false); + dodecahedron[i+1]->c().setspin(1, S7-1, false); dodecahedron[i+1]->move(S7-1) = dodecahedron[(i+1)%S7+1]; - dodecahedron[i+1]->c.setspin(S7-1, 1, false); + dodecahedron[i+1]->c().setspin(S7-1, 1, false); if(S7 == 5 && elliptic) { dodecahedron[i+1]->move(2) = dodecahedron[(i+2)%S7+1]; - dodecahedron[i+1]->c.setspin(2, 3, true); + dodecahedron[i+1]->c().setspin(2, 3, true); dodecahedron[i+1]->move(3) = dodecahedron[(i+3)%S7+1]; - dodecahedron[i+1]->c.setspin(3, 2, true); + dodecahedron[i+1]->c().setspin(3, 2, true); } else if(S7 == 5) { dodecahedron[6]->move(i) = dodecahedron[7+i]; - dodecahedron[6]->c.setspin(i, 0, false); + dodecahedron[6]->c().setspin(i, 0, false); dodecahedron[7+i]->move(0) = dodecahedron[6]; - dodecahedron[7+i]->c.setspin(0, i, false); + dodecahedron[7+i]->c().setspin(0, i, false); dodecahedron[i+7]->move(1) = dodecahedron[(i+4)%5+7]; - dodecahedron[i+7]->c.setspin(1, 4, false); + dodecahedron[i+7]->c().setspin(1, 4, false); dodecahedron[i+7]->move(4) = dodecahedron[(i+1)%5+7]; - dodecahedron[i+7]->c.setspin(4, 1, false); + dodecahedron[i+7]->c().setspin(4, 1, false); dodecahedron[i+1]->move(2) = dodecahedron[7+(10-i)%5]; - dodecahedron[i+1]->c.setspin(2, 2, false); + dodecahedron[i+1]->c().setspin(2, 2, false); dodecahedron[7+(10-i)%5]->move(2) = dodecahedron[1+i]; - dodecahedron[7+(10-i)%5]->c.setspin(2, 2, false); + dodecahedron[7+(10-i)%5]->c().setspin(2, 2, false); dodecahedron[i+1]->move(3) = dodecahedron[7+(9-i)%5]; - dodecahedron[i+1]->c.setspin(3, 3, false); + dodecahedron[i+1]->c().setspin(3, 3, false); dodecahedron[7+(9-i)%5]->move(3) = dodecahedron[i+1]; - dodecahedron[7+(9-i)%5]->c.setspin(3, 3, false); + dodecahedron[7+(9-i)%5]->c().setspin(3, 3, false); } if(S7 == 4) { dodecahedron[5]->move(3-i) = dodecahedron[i+1]; - dodecahedron[5]->c.setspin(3-i, 2, false); + dodecahedron[5]->c().setspin(3-i, 2, false); dodecahedron[i+1]->move(2) = dodecahedron[5]; - dodecahedron[i+1]->c.setspin(2, 3-i, false); + dodecahedron[i+1]->c().setspin(2, 3-i, false); } } @@ -172,7 +172,7 @@ struct hrmap_spherical : hrmap_standard { return Id; } - transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) override { + transmatrix relative_matrixc(cell *c2, cell *c1, const hyperpoint& hint) override { transmatrix T = iso_inverse(get_where(c1)) * get_where(c2); if(elliptic) fixelliptic(T); return T;