diff --git a/bigstuff.cpp b/bigstuff.cpp index f87c80ab..2803e572 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -142,6 +142,7 @@ void generateAlts(heptagon *h, int levs) { continue; } ho->alt = hm; + hm->cdata = (cdata*) ho; if(levs) generateAlts(ho, levs-1); } } @@ -199,6 +200,7 @@ heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special) { alt->c7 = NULL; alt->alt = alt; h->alt = alt; + alt->cdata = (cdata*) h; for(int d=rad; d>=0; d--) { generateAlts(cx[d]->master); diff --git a/cell.cpp b/cell.cpp index 5d190a25..28a754ee 100644 --- a/cell.cpp +++ b/cell.cpp @@ -839,6 +839,10 @@ void clearcell(cell *c) { heptagon deletion_marker; void clearHexes(heptagon *at) { + if(at->c7 && at->cdata) { + delete at->cdata; + at->cdata = NULL; + } if(at->c7) { if(!nonbitrunc) for(int i=0; ic7->mov[i]); @@ -849,6 +853,10 @@ void clearHexes(heptagon *at) { void clearfrom(heptagon *at) { queue q; q.push(at); + if(at->alt && at->c7) { + printf("disconnect %p -> %p (from real)\n", at, at->alt); + at->alt->cdata = NULL; + } at->alt = &deletion_marker; //int maxq = 0; while(!q.empty()) { @@ -856,9 +864,21 @@ void clearfrom(heptagon *at) { // if(q.size() > maxq) maxq = q.size(); q.pop(); DEBMEM ( printf("from %p\n", at); ) + if(!at->c7) { + heptagon *h = (heptagon*) at->cdata; + if(h) { + if(h->alt != at) printf("alt error :: h->alt = %p\n", h->alt); + cell *c = h->c7; + destroycellcontents(c); + forCellEx(c2, c) destroycellcontents(c2); + h->alt = NULL; + at->cdata = NULL; + } + } for(int i=0; imove[i]) { if(at->move[i]->alt != &deletion_marker) q.push(at->move[i]); + if(at->move[i]->alt && at->move[i]->c7) at->move[i]->alt->cdata = NULL; at->move[i]->alt = &deletion_marker; DEBMEM ( printf("!mov %p [%p]\n", at->move[i], at->move[i]->move[at->spin(i)]); ) if(at->move[i]->move[at->spin(i)] != NULL && @@ -1381,8 +1401,11 @@ int celldistance(cell *c1, cell *c2) { } void clearCellMemory() { - for(int i=0; iland != laWhirlpool && !whirlpool::escaped) { diff --git a/help.cpp b/help.cpp index fa061c50..566bff1e 100644 --- a/help.cpp +++ b/help.cpp @@ -715,6 +715,7 @@ void describeMouseover() { } if(c->wall && !(c->wall == waChasm && c->land == laDual && ctof(c)) && + !(c->land == laMemory) && !((c->wall == waFloorA || c->wall == waFloorB) && c->item)) { out += ", "; out += XLAT1(winf[c->wall].name); diff --git a/heptagon.cpp b/heptagon.cpp index 586e1e79..b895e1d3 100644 --- a/heptagon.cpp +++ b/heptagon.cpp @@ -89,6 +89,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix h->c7 = NULL; h->emeraldval = 0; h->fiftyval = 0; + h->cdata = NULL; } //generateEmeraldval(parent); //generateEmeraldval(h); diff --git a/hyper.h b/hyper.h index 3be4f5e6..e60251ad 100644 --- a/hyper.h +++ b/hyper.h @@ -165,7 +165,7 @@ struct heptagon { int fieldval; // evolution data short rval0, rval1; - struct cdata *cdata; + struct cdata *cdata; // for alts, this contains the pointer to the original // central cell cell *c7; // associated generator of alternate structure, for Camelot and horocycles @@ -2492,3 +2492,6 @@ void mainloop(); void clearAnimations(); transmatrix rotmatrix(double rotation, int c0, int c1); + +void destroycellcontents(cell *c); +extern heptagon *last_cleared; diff --git a/landgen.cpp b/landgen.cpp index 35c802e5..ca1b96b9 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -2142,6 +2142,12 @@ void giantLandSwitch(cell *c, int d, cell *from) { c->monst = moRatling; } break; + + case laMemory: + c->wall = waChasm; + if(d == 7 && !c->monst && hrand(2000) < 4) + c->monst = moGhost; + break; } } diff --git a/landlock.cpp b/landlock.cpp index 0e38c3bb..b29a9077 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -58,7 +58,8 @@ int isNative(eLand l, eMonster m) { case laCrossroads: case laCrossroads2: case laCrossroads3: case laCrossroads4: case laCrossroads5: - case laNone: case laBarrier: case laOceanWall: case laCanvas: return 0; + case laNone: case laBarrier: case laOceanWall: case laCanvas: case laMemory: + return 0; case laEmerald: return (m == moFlailer || m == moLancer || m == moMiner) ? 2 : @@ -253,6 +254,7 @@ eItem treasureType(eLand l) { case laBarrier: return itNone; case laOceanWall: return itNone; case laCanvas: return itNone; + case laMemory: return itNone; case laEmerald: return itEmerald; case laWineyard: return itWine; @@ -478,7 +480,7 @@ bool landUnlocked(eLand l) { case laEAir: case laEEarth: case laEWater: case laEFire: case laElementalWall: return elementalUnlocked(); - case laBarrier: case laNone: case laOceanWall: case laCanvas: case laCA: + case laBarrier: case laNone: case laOceanWall: case laCanvas: case laCA: case laMemory: return false; case laMirrorOld: