mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
some work on the savemem feature
This commit is contained in:
parent
2f9e5186f6
commit
22d3d2590f
@ -234,4 +234,7 @@ auto ccm_blizzard = addHook(clearmemory, 0, [] () {
|
||||
arrowtraps.clear();
|
||||
blizzardcells.clear();
|
||||
bcells.clear();
|
||||
}) +
|
||||
addHook(hooks_removecells, 0, [] () {
|
||||
eliminate_if(arrowtraps, is_cell_removed);
|
||||
});
|
||||
|
23
complex.cpp
23
complex.cpp
@ -3025,7 +3025,28 @@ auto ccm = addHook(clearmemory, 0, [] () {
|
||||
prairie::tchoices.clear();
|
||||
prairie::beaststogen.clear();
|
||||
mirror::clearcache();
|
||||
});
|
||||
}) +
|
||||
addHook(hooks_removecells, 0, [] () {
|
||||
eliminate_if(heat::offscreen_heat, is_cell_removed);
|
||||
eliminate_if(heat::offscreen_fire, is_cell_removed);
|
||||
eliminate_if(princess::infos, [] (princess::info*& i) {
|
||||
if(is_cell_removed(i->princess) || is_cell_removed(i->prison)) {
|
||||
DEBSM(printf("removing a princess\n");)
|
||||
if(i->princess && !is_cell_removed(i->princess)) {
|
||||
DEBSM(printf("faking a princess\n");)
|
||||
princess::newFakeInfo(i->princess);
|
||||
}
|
||||
delete i;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
set_if_removed(prairie::lasttreasure, NULL);
|
||||
set_if_removed(prairie::enter, NULL);
|
||||
eliminate_if(prairie::tchoices, is_cell_removed);
|
||||
eliminate_if(prairie::beaststogen, is_cell_removed);
|
||||
for(auto& bpd: clearing::bpdata) set_if_removed(bpd.second.root, NULL);
|
||||
});
|
||||
|
||||
// windcode arrays precomputed for speed
|
||||
|
||||
|
13
hyper.h
13
hyper.h
@ -28,6 +28,8 @@ typedef long double ld;
|
||||
|
||||
#define DEBMEM(x) // { x fflush(stdout); }
|
||||
|
||||
#define DEBSM(x)
|
||||
|
||||
struct hyperpoint {
|
||||
ld tab[3];
|
||||
ld& operator [] (int i) { return tab[i]; }
|
||||
@ -1722,7 +1724,7 @@ template<class T, class U> int addHook(hookset<T>*& m, int prio, const U& hook)
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern purehookset hooks_frame, hooks_stats, clearmemory, hooks_config, hooks_tests;
|
||||
extern purehookset hooks_frame, hooks_stats, clearmemory, hooks_config, hooks_tests, hooks_removecells;
|
||||
|
||||
template<class T, class... U> void callhooks(hookset<T> *h, U... args) {
|
||||
if(h) for(auto& p: *h) p.second(args...);
|
||||
@ -2497,3 +2499,12 @@ transmatrix rotmatrix(double rotation, int c0, int c1);
|
||||
|
||||
void destroycellcontents(cell *c);
|
||||
extern heptagon *last_cleared;
|
||||
|
||||
template<class T, class U> void eliminate_if(vector<T>& data, U pred) {
|
||||
for(int i=0; i<size(data); i++)
|
||||
if(pred(data[i]))
|
||||
data[i] = data.back(), data.pop_back(), i--;
|
||||
}
|
||||
|
||||
bool is_cell_removed(cell *c);
|
||||
void set_if_removed(cell*& c, cell *val);
|
||||
|
@ -6649,3 +6649,14 @@ S("level to save:", "mapa do zapisu:")
|
||||
S("pics to load:", "obrazki do wczytania:")
|
||||
S("level to load:", "mapa do wczytania:")
|
||||
|
||||
S("remove faraway cells from memory", "usuwaj odległe pola z pamięci")
|
||||
N("Lost Memory", GEN_F, "Utracona Pamięć", "Utracone Pamięci", "Utraconą Pamięć", "w Utraconej Pamięci")
|
||||
S( "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.",
|
||||
|
||||
"Ze względu na właściwości geometrii hiperbolicznej praktycznie niemożliwe jest, by "
|
||||
"przypadkowo wrócić do odległego miejsca, w którym się było wcześniej. Ale jakoś Ci się to udało... "
|
||||
"W międzyczasie pamięć została wyczyczona, ze względu na włączoną opcję 'usuwaj odległe pola z pamięci'.'"
|
||||
)
|
||||
|
@ -1591,7 +1591,11 @@ namespace mapeditor {
|
||||
if(!cheater) patterns::displaycodes = 0;
|
||||
if(!cheater) patterns::whichShape = 0;
|
||||
modelcell.clear();
|
||||
});
|
||||
}) +
|
||||
addHook(hooks_removecells, 0, [] () {
|
||||
modelcell.clear();
|
||||
set_if_removed(mapeditor::copysource.c, NULL);
|
||||
});;;
|
||||
#endif
|
||||
|
||||
void initdraw(cell *c) {
|
||||
|
15
shmup.cpp
15
shmup.cpp
@ -2972,6 +2972,7 @@ void turn(int delta) {
|
||||
if(havewhat&HF_RIVER) prairie::move();
|
||||
}
|
||||
if(recallCell && !markOrb(itOrbRecall)) activateRecall();
|
||||
save_memory();
|
||||
}
|
||||
if(elec::havecharge) elec::act();
|
||||
popmonsters();
|
||||
@ -3468,6 +3469,16 @@ void addShmupHelp(string& out) {
|
||||
}
|
||||
}
|
||||
|
||||
auto hooks = addHook(clearmemory, 0, shmup::clearMemory);
|
||||
|
||||
auto hooks = addHook(clearmemory, 0, shmup::clearMemory) +
|
||||
addHook(hooks_removecells, 0, [] () {
|
||||
for(mit it = monstersAt.begin(); it != monstersAt.end();) {
|
||||
if(is_cell_removed(it->first)) {
|
||||
monstersAt.insert(make_pair(nullptr, it->second));
|
||||
auto it0 = it; it++;
|
||||
monstersAt.erase(it0);
|
||||
}
|
||||
else it++;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
10
system.cpp
10
system.cpp
@ -1224,5 +1224,13 @@ auto cgm = addHook(clearmemory, 40, [] () {
|
||||
buggycells.clear();
|
||||
crush_next.clear();
|
||||
crush_now.clear();
|
||||
});
|
||||
}) +
|
||||
addHook(hooks_removecells, 0, [] () {
|
||||
eliminate_if(crush_next, is_cell_removed);
|
||||
eliminate_if(crush_now, is_cell_removed);
|
||||
eliminate_if(buggycells, is_cell_removed);
|
||||
eliminate_if(butterflies, [] (pair<cell*,int>& p) { return is_cell_removed(p.first); });
|
||||
for(int i=0; i<SHSIZE; i++) for(int p=0; p<MAXPLAYER; p++)
|
||||
set_if_removed(shpos[p][i], NULL);
|
||||
});;
|
||||
|
||||
|
@ -549,6 +549,15 @@ namespace yendor {
|
||||
|
||||
auto hooks = addHook(clearmemory, 0, [] () {
|
||||
yendor::yii = NOYENDOR; yendor::yi.clear();
|
||||
}) + addHook(hooks_removecells, 0, [] () {
|
||||
eliminate_if(yendor::yi, [] (yendorinfo& i) {
|
||||
for(int j=0; j<YDIST; j++) if(is_cell_removed(i.path[j])) {
|
||||
DEBSM(printf("removing a Yendor\n");)
|
||||
if(&yi[yii] == &i) yii = NOYENDOR;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user