1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

'remove faraway cells from the memory' option

This commit is contained in:
Zeno Rogue 2018-01-25 19:49:19 +01:00
parent 91a07dd856
commit 8713d34d19
12 changed files with 58 additions and 6 deletions

View File

@ -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);

View File

@ -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; i<S7; i++)
clearcell(at->c7->mov[i]);
@ -849,6 +853,10 @@ void clearHexes(heptagon *at) {
void clearfrom(heptagon *at) {
queue<heptagon*> 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; i<S7; i++) if(at->move[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; i<size(allmaps); i++) delete allmaps[i];
for(int i=0; i<size(allmaps); i++)
if(allmaps[i])
delete allmaps[i];
allmaps.clear();
last_cleared = NULL;
}
auto cellhooks = addHook(clearmemory, 500, clearCellMemory);

View File

@ -1604,6 +1604,12 @@ const landtype linf[landtypes] = {
{ 0x306030, "Ruined City", ruindesc},
{ 0x306030, "Magnetosphere", NODESCYET},
{ 0x306030, "Jelly Kingdom", jellydesc},
{ 0xFF00FF, "Lost Memory",
"Because of the properties of hyperbolic geometry, it is extremely unlikely to randomly "
"get back to a faraway place you have been to. However, you have managed to get there "
"somehow. In the meantime, its memory has been cleared, since the 'remove faraway cells from the memory'"
" option was on."
},
};
struct landtacinfo { eLand l; int tries, multiplier; };

View File

@ -164,7 +164,7 @@ enum eWall { waNone, waIcewall, waBarrier, waFloorA, waFloorB, waCavewall, waCav
waDock, waBurningDock, waRuinWall
};
static const int landtypes = 83;
static const int landtypes = 84;
struct landtype {
int color;
@ -191,7 +191,7 @@ enum eLand { laNone, laBarrier, laCrossroads, laDesert, laIce, laCaves, laJungle
laMirrorOld,
laVolcano, laBlizzard, laHunting, laTerracotta, laMercuryRiver,
laDual, laSnakeNest, laDocks, laRuins, laMagnetic,
laSwitch
laSwitch, laMemory
};
enum eGeometry {gNormal, gEuclid, gSphere, gElliptic, gQuotient, gQuotient2, gTorus, gOctagon, g45, g46, g47, gSmallSphere, gTinySphere, gEuclidSquare, gGUARD};

View File

@ -33,6 +33,7 @@
#include "flags.cpp"
#include "yendor.cpp"
#include "complex.cpp"
#include "savemem.cpp"
#include "game.cpp"
#include "orbgen.cpp"
#include "monstergen.cpp"

View File

@ -268,6 +268,8 @@ void initConfig() {
addsaver(geom3::tc_alpha, "3D TC alpha");
addsaver(geom3::highdetail, "3D highdetail");
addsaver(geom3::middetail, "3D middetail");
addsaver(memory_saving_mode, "memory_saving_mode", (ISMOBILE || ISPANDORA) ? 1 : 0);
addsaver(rug::renderonce, "rug-renderonce");
addsaver(rug::rendernogl, "rug-rendernogl");
@ -665,6 +667,7 @@ void showGraphConfig() {
dialog::addSelItem(XLAT("font scale"), its(fontscale), 'b');
dialog::addSelItem(XLAT("sight range"), its(sightrange), 'r');
dialog::addSelItem(XLAT("remove faraway cells from memory"), its(memory_saving_mode), 'y');
dialog::addSelItem(XLAT("compass size"), its(vid.mobilecompasssize), 'c');
@ -684,6 +687,8 @@ void showGraphConfig() {
if(xuni == 'u') vid.particles = !vid.particles;
if(xuni == 'd') vid.graphglyph = (1+vid.graphglyph)%3;
if(xuni == 'y') memory_saving_mode = !memory_saving_mode;
if(xuni == 'j') {
dialog::editNumber(whatever, -10, 10, 1, 0, XLAT("whatever"),
XLAT("Whatever."));

View File

@ -7784,6 +7784,8 @@ bool movepcto(int d, int subdir, bool checkonly) {
if(multi::players == 1) monstersTurn();
save_memory();
check_total_victory();
if(items[itWhirlpool] && cwt.c->land != laWhirlpool && !whirlpool::escaped) {

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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: