mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 23:50:27 +00:00
altmap:: generate_random_path used
This commit is contained in:
parent
0f2f435534
commit
3972e5a6bb
46
bigstuff.cpp
46
bigstuff.cpp
@ -258,27 +258,10 @@ EX heptagon *create_altmap(cell *c, int rad, hstate firststate, int special IS(0
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we always go to the opposite tile on a {even,x} tiling,
|
cellwalker bf(c, gdir); bf += rev;
|
||||||
// it will be too easy
|
auto p = generate_random_path(bf, rad, false, false);
|
||||||
int flip = 0;
|
|
||||||
if(WDIM == 2 && S7 % 2 == 0) flip = hrand(2) ? 1 : -1;
|
|
||||||
|
|
||||||
// okay, let's go then!
|
heptagon *h = p.last.at->master;
|
||||||
cellwalker bf(c, gdir);
|
|
||||||
std::vector<cell *> cx(rad+1);
|
|
||||||
for(int i=0; i<rad; i++) {
|
|
||||||
cx[i] = bf.at;
|
|
||||||
bf += revstep;
|
|
||||||
if(flip && hrand(2) == 0) { bf += flip; flip *= -1; }
|
|
||||||
|
|
||||||
#if MAXMDIM >= 4
|
|
||||||
// in 3D honeycombs we vary the direction, but never for three successive i's
|
|
||||||
if(WDIM == 3 && firststate == hsOrigin && (i%3))
|
|
||||||
bf.spin = hrandom_adjacent(bf);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
cx[rad] = bf.at;
|
|
||||||
heptagon *h = bf.at->master;
|
|
||||||
|
|
||||||
if(h->alt) {
|
if(h->alt) {
|
||||||
printf("Error: creatingAlternateMap while one already exists\n");
|
printf("Error: creatingAlternateMap while one already exists\n");
|
||||||
@ -286,36 +269,29 @@ EX heptagon *create_altmap(cell *c, int rad, hstate firststate, int special IS(0
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(special == waPalace) {
|
if(special == waPalace) {
|
||||||
|
cell *c = p.last.at;
|
||||||
// type 7 is ensured
|
if(!ctof(c) || cdist50(c) != 0 || !polarb50(c)) return nullptr;
|
||||||
cell *c = bf.at;
|
|
||||||
|
|
||||||
if(cdist50(c) != 0) return NULL;
|
|
||||||
if(!polarb50(c)) return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bf += rev;
|
|
||||||
|
|
||||||
heptagon *alt = init_heptagon(h->type);
|
heptagon *alt = init_heptagon(h->type);
|
||||||
allmaps.push_back(newAltMap(alt));
|
allmaps.push_back(newAltMap(alt));
|
||||||
//printf("new alt {%p}\n", hr::voidp(alt));
|
|
||||||
alt->s = firststate;
|
alt->s = firststate;
|
||||||
if(hybri) hybrid::altmap_heights[alt] = hybrid::get_where(centerover).second;
|
if(!currentmap->link_alt(h, alt, firststate, p.last.spin)) {
|
||||||
alt->alt = alt;
|
|
||||||
if(!currentmap->link_alt(h, alt, firststate, bf.spin)) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if(hybri) hybrid::altmap_heights[alt] = hybrid::get_where(centerover).second;
|
||||||
|
alt->alt = alt;
|
||||||
h->alt = alt;
|
h->alt = alt;
|
||||||
alt->cdata = (cdata*) h;
|
alt->cdata = (cdata*) h;
|
||||||
|
|
||||||
for(int d=rad; d>=0; d--) {
|
for(int d=rad; d>=0; d--) {
|
||||||
currentmap->extend_altmap(cx[d]->master);
|
currentmap->extend_altmap(p.path[d]->master);
|
||||||
preventbarriers(cx[d]);
|
preventbarriers(p.path[d]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(special == waPalace) {
|
if(special == waPalace) {
|
||||||
|
|
||||||
cell *c = bf.at;
|
cell *c = p.last.at;
|
||||||
|
|
||||||
princess::generating = true;
|
princess::generating = true;
|
||||||
c->land = laPalace;
|
c->land = laPalace;
|
||||||
|
Loading…
Reference in New Issue
Block a user