mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
created a function init_heptagon which does tailored_alloc and clears the data
This commit is contained in:
parent
adb9bd75ee
commit
74486309a6
@ -529,17 +529,8 @@ struct hrmap_archimedean : hrmap {
|
||||
dynamicval<hrmap*> curmap(currentmap, this);
|
||||
int id = DUAL ? current.N * 2 : 0;;
|
||||
int N0 = isize(current.adjacent[id]);
|
||||
origin = tailored_alloc<heptagon> (N0);
|
||||
origin = init_heptagon(N0);
|
||||
origin->s = hsOrigin;
|
||||
origin->emeraldval = 0;
|
||||
origin->zebraval = 0;
|
||||
origin->fiftyval = 0;
|
||||
origin->fieldval = 0;
|
||||
origin->rval0 = origin->rval1 = 0;
|
||||
origin->cdata = NULL;
|
||||
origin->alt = NULL;
|
||||
origin->c7 = NULL;
|
||||
origin->distance = 0;
|
||||
|
||||
parent_index_of(origin) = DUAL ? 1 : 0;
|
||||
id_of(origin) = id;
|
||||
@ -549,14 +540,9 @@ struct hrmap_archimedean : hrmap {
|
||||
|
||||
if(hyperbolic) {
|
||||
dynamicval<eGeometry> g(geometry, gNormal);
|
||||
alt = tailored_alloc<heptagon> (S7);
|
||||
alt = init_heptagon(S7);
|
||||
alt->s = hsOrigin;
|
||||
alt->emeraldval = 0;
|
||||
alt->zebraval = 0;
|
||||
alt->distance = 0;
|
||||
alt->c7 = NULL;
|
||||
alt->alt = alt;
|
||||
alt->cdata = NULL;
|
||||
current_altmap = newAltMap(alt);
|
||||
}
|
||||
|
||||
|
@ -176,15 +176,12 @@ struct hrmap_asonov : hrmap {
|
||||
heptagon *get_at(coord c) {
|
||||
auto& h = at[c];
|
||||
if(h) return h;
|
||||
h = tailored_alloc<heptagon> (S7);
|
||||
h = init_heptagon(S7);
|
||||
h->c7 = newCell(S7, h);
|
||||
coords[h] = c;
|
||||
h->dm4 = 0;
|
||||
h->distance = c[2];
|
||||
h->zebraval = c[0];
|
||||
h->emeraldval = c[1];
|
||||
h->cdata = NULL;
|
||||
h->alt = NULL;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
@ -291,16 +291,11 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special
|
||||
if(!polarb50(c)) return NULL;
|
||||
}
|
||||
|
||||
heptagon *alt = tailored_alloc<heptagon> (h->type);
|
||||
heptagon *alt = init_heptagon(h->type);
|
||||
allmaps.push_back(newAltMap(alt));
|
||||
//printf("new alt {%p}\n", hr::voidp(alt));
|
||||
alt->s = firststate;
|
||||
alt->emeraldval = 0;
|
||||
alt->zebraval = 0;
|
||||
alt->distance = 0;
|
||||
alt->fieldval = 0;
|
||||
if(hybri) alt->fieldval = hybrid::get_where(centerover).second;
|
||||
alt->c7 = NULL;
|
||||
alt->alt = alt;
|
||||
#if MAXMDIM >= 4
|
||||
if(reg3::in_rule()) {
|
||||
|
8
cell.cpp
8
cell.cpp
@ -178,17 +178,11 @@ EX hrmap *newAltMap(heptagon *o) {
|
||||
|
||||
EX heptagon* hyperbolic_origin() {
|
||||
int odegree = geometry == gBinaryTiling ? 6 : S7;
|
||||
heptagon *origin = tailored_alloc<heptagon> (odegree);
|
||||
heptagon *origin = init_heptagon(odegree);
|
||||
heptagon& h = *origin;
|
||||
h.s = hsOrigin;
|
||||
h.emeraldval = a46 ? 0 : 98;
|
||||
h.zebraval = 40;
|
||||
h.fiftyval = 0;
|
||||
h.fieldval = 0;
|
||||
h.rval0 = h.rval1 = 0;
|
||||
h.cdata = NULL;
|
||||
h.alt = NULL;
|
||||
h.distance = 0;
|
||||
#if CAP_IRR
|
||||
if(IRREGULAR) irr::link_start(origin);
|
||||
else
|
||||
|
@ -506,9 +506,7 @@ struct hrmap_crystal : hrmap_standard {
|
||||
heptagon *get_heptagon_at(coord c, int deg) {
|
||||
if(heptagon_at.count(c)) return heptagon_at[c];
|
||||
heptagon*& h = heptagon_at[c];
|
||||
h = tailored_alloc<heptagon> (deg);
|
||||
h->alt = NULL;
|
||||
h->cdata = NULL;
|
||||
h = init_heptagon(deg);
|
||||
h->c7 = newCell(deg, h);
|
||||
|
||||
/* in {6,4} we need emeraldval for some patterns, including (bitruncated) football and (bitruncated) three-color */
|
||||
@ -519,7 +517,6 @@ struct hrmap_crystal : hrmap_standard {
|
||||
h->emeraldval ^= ((c[2] & 2) << 1);
|
||||
if(c[0] & 2) h->emeraldval ^= 1;
|
||||
|
||||
h->distance = 0;
|
||||
if(ginf[gCrystal].vertex == 3)
|
||||
h->fiftyval = fiftyrule(c);
|
||||
for(int i=0; i<cs.dim; i++) h->distance += abs(c[i]);
|
||||
|
@ -180,7 +180,7 @@ EX namespace euc {
|
||||
if(spacemap.count(at))
|
||||
return spacemap[at];
|
||||
else {
|
||||
auto h = tailored_alloc<heptagon> (S7);
|
||||
auto h = init_heptagon(S7);
|
||||
if(!IRREGULAR)
|
||||
h->c7 = newCell(S7, h);
|
||||
#if CAP_IRR
|
||||
@ -197,9 +197,6 @@ EX namespace euc {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
h->distance = 0;
|
||||
h->cdata = NULL;
|
||||
h->alt = NULL;
|
||||
if(S7 != 14)
|
||||
h->zebraval = gmod(at[0] + at[1] * 2 + at[2] * 4, 5);
|
||||
else
|
||||
|
15
heptagon.cpp
15
heptagon.cpp
@ -76,6 +76,21 @@ EX heptagon *buildHeptagon1(heptagon *h, heptagon *parent, int d, hstate s, int
|
||||
h->cdata = NULL;
|
||||
return h;
|
||||
}
|
||||
|
||||
heptagon *init_heptagon(int type) {
|
||||
heptagon *h = tailored_alloc<heptagon> (d);
|
||||
h->emeraldval = 0;
|
||||
h->zebraval = 0;
|
||||
h->fiftyval = 0;
|
||||
h->fieldval = 0;
|
||||
h->rval0 = origin->rval1 = 0;
|
||||
h->cdata = NULL;
|
||||
h->alt = NULL;
|
||||
h->c7 = NULL;
|
||||
h->distance = 0;
|
||||
h->dm4 = 0;
|
||||
return h;
|
||||
}
|
||||
|
||||
heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fixdistance = COMPUTE) {
|
||||
heptagon *h = buildHeptagon1(tailored_alloc<heptagon> (S7), parent, d, s, pard);
|
||||
|
@ -24,13 +24,11 @@ EX namespace inforder {
|
||||
heptagon *create_step(heptagon *h, int direction) {
|
||||
int deg = h->type;
|
||||
if(mixed()) deg = 7 - deg;
|
||||
auto h1 = tailored_alloc<heptagon> (deg);
|
||||
auto h1 = init_heptagon(deg);
|
||||
bool par = h->s == hsA && direction == 0;
|
||||
h->c.connect(direction, h1, par ? 1 + hrand(2) : 0, false);
|
||||
|
||||
h1->alt = NULL;
|
||||
h1->s = hsA;
|
||||
h1->cdata = NULL;
|
||||
h1->distance = h->distance + (par ? -1 : 1);
|
||||
h1->c7 = newCell(deg, h1);
|
||||
|
||||
|
9
kite.cpp
9
kite.cpp
@ -157,18 +157,11 @@ struct hrmap_kite : hrmap {
|
||||
}
|
||||
|
||||
heptagon *newtile(pshape s, int dist) {
|
||||
heptagon *h = tailored_alloc<heptagon> (8);
|
||||
heptagon *h = init_heptagon(8);
|
||||
h->s = hstate(s);
|
||||
h->dm4 = h->distance = dist;
|
||||
if(bt::in() || dist == 0)
|
||||
h->c7 = newCell(euclid ? 4 : s == pKite ? 12 : 10, h);
|
||||
else
|
||||
h->c7 = NULL;
|
||||
h->zebraval = 0;
|
||||
h->emeraldval = 0;
|
||||
h->fieldval = 0;
|
||||
h->cdata = NULL;
|
||||
h->alt = NULL;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
@ -246,16 +246,12 @@ EX namespace sn {
|
||||
heptagon *get_at(heptagon *x, heptagon *y) {
|
||||
auto& h = at[make_pair(x, y)];
|
||||
if(h) return h;
|
||||
h = tailored_alloc<heptagon> (S7);
|
||||
h = init_heptagon(S7);
|
||||
h->c7 = newCell(S7, h);
|
||||
coords[h] = make_pair(x, y);
|
||||
h->distance = x->distance;
|
||||
h->dm4 = 0;
|
||||
h->zebraval = x->emeraldval;
|
||||
h->emeraldval = y->emeraldval;
|
||||
h->fieldval = 0;
|
||||
h->cdata = NULL;
|
||||
h->alt = NULL;
|
||||
return h;
|
||||
}
|
||||
|
||||
@ -266,27 +262,17 @@ EX namespace sn {
|
||||
|
||||
if(true) {
|
||||
dynamicval<eGeometry> g(geometry, gBinary4);
|
||||
alt = tailored_alloc<heptagon> (S7);
|
||||
alt = init_heptagon(S7);
|
||||
alt->s = hsOrigin;
|
||||
alt->alt = alt;
|
||||
alt->cdata = NULL;
|
||||
alt->c7 = NULL;
|
||||
alt->zebraval = 0;
|
||||
alt->distance = 0;
|
||||
alt->emeraldval = 0;
|
||||
binary_map = bt::new_alt_map(alt);
|
||||
}
|
||||
|
||||
if(nih) {
|
||||
dynamicval<eGeometry> g(geometry, gTernary);
|
||||
alt3 = tailored_alloc<heptagon> (S7);
|
||||
alt3 = init_heptagon(S7);
|
||||
alt3->s = hsOrigin;
|
||||
alt3->alt = alt3;
|
||||
alt3->cdata = NULL;
|
||||
alt3->c7 = NULL;
|
||||
alt3->zebraval = 0;
|
||||
alt3->distance = 0;
|
||||
alt3->emeraldval = 0;
|
||||
ternary_map = bt::new_alt_map(alt3);
|
||||
}
|
||||
else {
|
||||
@ -886,15 +872,12 @@ EX namespace nilv {
|
||||
heptagon *get_at(mvec c) {
|
||||
auto& h = at[c];
|
||||
if(h) return h;
|
||||
h = tailored_alloc<heptagon> (S7);
|
||||
h = init_heptagon(S7);
|
||||
h->c7 = newCell(S7, h);
|
||||
coords[h] = c;
|
||||
h->dm4 = 0;
|
||||
h->zebraval = c[0];
|
||||
h->emeraldval = c[1];
|
||||
h->fieldval = c[2];
|
||||
h->cdata = NULL;
|
||||
h->alt = NULL;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
11
quotient.cpp
11
quotient.cpp
@ -353,25 +353,16 @@ struct hrmap_quotient : hrmap_standard {
|
||||
// printf("all cells = %d\n", TOT*(S7+S3)/S3);
|
||||
if(!TOT) exit(1);
|
||||
allh.resize(TOT);
|
||||
for(int i=0; i<TOT; i++) allh[i] = tailored_alloc<heptagon> (S7);
|
||||
for(int i=0; i<TOT; i++) allh[i] = init_heptagon(S7);
|
||||
// heptagon *oldorigin = origin;
|
||||
allh[0]->alt = base.origin;
|
||||
|
||||
for(int i=0; i<TOT; i++) {
|
||||
heptagon *h = allh[i];
|
||||
if(i) {
|
||||
h->alt = NULL;
|
||||
}
|
||||
if(true) {
|
||||
h->s = hsOrigin;
|
||||
h->emeraldval = 0;
|
||||
h->zebraval = 0;
|
||||
h->fiftyval = 0;
|
||||
h->fieldval = S7*i;
|
||||
h->rval0 = h->rval1 = 0; h->cdata = NULL;
|
||||
h->distance = 0;
|
||||
if(!IRREGULAR) h->c7 = newCell(S7, h);
|
||||
else h->c7 = NULL;
|
||||
}
|
||||
for(int j=0; j<S7; j++) {
|
||||
int co = connections[i*S7+j];
|
||||
|
41
reg3.cpp
41
reg3.cpp
@ -303,11 +303,9 @@ EX namespace reg3 {
|
||||
acells.clear();
|
||||
tmatrices.resize(cell_count);
|
||||
for(int a=0; a<cell_count; a++) {
|
||||
allh[a] = tailored_alloc<heptagon> (S7);
|
||||
allh[a] = init_heptagon(S7);
|
||||
allh[a]->c7 = newCell(S7, allh[a]);
|
||||
allh[a]->fieldval = a;
|
||||
allh[a]->zebraval = 0;
|
||||
allh[a]->alt = NULL;
|
||||
acells.push_back(allh[a]->c7);
|
||||
}
|
||||
}
|
||||
@ -616,15 +614,9 @@ EX namespace reg3 {
|
||||
}
|
||||
|
||||
hrmap_reg3() {
|
||||
origin = tailored_alloc<heptagon> (S7);
|
||||
origin = init_heptagon(S7);
|
||||
heptagon& h = *origin;
|
||||
h.s = hsOrigin;
|
||||
h.cdata = NULL;
|
||||
h.alt = NULL;
|
||||
h.distance = 0;
|
||||
h.fiftyval = 0;
|
||||
h.fieldval = 0;
|
||||
h.emeraldval = 0;
|
||||
h.c7 = newCell(S7, origin);
|
||||
if(sphere) spherecells.push_back(h.c7);
|
||||
worst_error1 = 0, worst_error2 = 0;
|
||||
@ -657,14 +649,9 @@ EX namespace reg3 {
|
||||
if(hyperbolic) {
|
||||
dynamicval<eGeometry> g(geometry, gBinary3);
|
||||
bt::build_tmatrix();
|
||||
alt = tailored_alloc<heptagon> (S7);
|
||||
alt = init_heptagon(S7);
|
||||
alt->s = hsOrigin;
|
||||
alt->emeraldval = 0;
|
||||
alt->zebraval = 0;
|
||||
alt->distance = 0;
|
||||
alt->alt = alt;
|
||||
alt->cdata = NULL;
|
||||
alt->c7 = NULL;
|
||||
binary_map = bt::new_alt_map(alt);
|
||||
T = xpush(.01241) * spin(1.4117) * xpush(0.1241) * cspin(0, 2, 1.1249) * xpush(0.07) * Id;
|
||||
}
|
||||
@ -834,11 +821,9 @@ EX namespace reg3 {
|
||||
}
|
||||
println(hlog, "found d2 = ", d2);
|
||||
}
|
||||
heptagon *created = tailored_alloc<heptagon> (S7);
|
||||
heptagon *created = init_heptagon(S7);
|
||||
created->c7 = newCell(S7, created);
|
||||
if(sphere) spherecells.push_back(created->c7);
|
||||
created->alt = NULL;
|
||||
created->cdata = NULL;
|
||||
#if CAP_FIELD
|
||||
if(quotient_map) {
|
||||
created->emeraldval = fv;
|
||||
@ -1048,16 +1033,10 @@ EX namespace reg3 {
|
||||
|
||||
load_ruleset(get_rule_filename());
|
||||
|
||||
origin = tailored_alloc<heptagon> (S7);
|
||||
origin = init_heptagon(S7);
|
||||
heptagon& h = *origin;
|
||||
h.s = hsOrigin;
|
||||
h.cdata = NULL;
|
||||
h.alt = NULL;
|
||||
h.distance = 0;
|
||||
h.zebraval = 0;
|
||||
h.fieldval = 0;
|
||||
h.fiftyval = root[0];
|
||||
h.c7 = NULL;
|
||||
h.c7 = newCell(S7, origin);
|
||||
|
||||
int opos = 0;
|
||||
@ -1183,13 +1162,9 @@ EX namespace reg3 {
|
||||
}
|
||||
|
||||
if(id1 != -1) {
|
||||
res = tailored_alloc<heptagon> (S7);
|
||||
res = init_heptagon(S7);
|
||||
if(parent->c7)
|
||||
res->c7 = newCell(S7, res);
|
||||
else
|
||||
res->c7 = nullptr;
|
||||
res->alt = nullptr;
|
||||
res->cdata = nullptr;
|
||||
res->fieldval = fv;
|
||||
res->distance = parent->distance + 1;
|
||||
res->fiftyval = id1;
|
||||
@ -1198,10 +1173,8 @@ EX namespace reg3 {
|
||||
}
|
||||
|
||||
else if(other[pos] == ('A' + d) && other[pos+1] == ',') {
|
||||
res = tailored_alloc<heptagon> (S7);
|
||||
res->c7 = nullptr;
|
||||
res = init_heptagon(S7);
|
||||
res->alt = parent->alt;
|
||||
res->cdata = nullptr;
|
||||
res->fieldval = fv;
|
||||
res->distance = parent->distance - 1;
|
||||
vector<int> possible;
|
||||
|
@ -27,14 +27,11 @@ struct hrmap_spherical : hrmap_standard {
|
||||
|
||||
hrmap_spherical() {
|
||||
for(int i=0; i<spherecells(); i++) {
|
||||
heptagon& h = *(dodecahedron[i] = tailored_alloc<heptagon> (S7));
|
||||
heptagon& h = *(dodecahedron[i] = init_heptagon(S7));
|
||||
h.s = hsOrigin;
|
||||
h.emeraldval = i;
|
||||
h.zebraval = i;
|
||||
h.fiftyval = i;
|
||||
h.rval0 = h.rval1 = 0;
|
||||
h.alt = NULL;
|
||||
h.cdata = NULL;
|
||||
h.c.fullclear();
|
||||
h.fieldval = i;
|
||||
if(!IRREGULAR) h.c7 = newCell(S7, &h);
|
||||
|
Loading…
Reference in New Issue
Block a user