adj_memo now can keep separate memos for different rules

This commit is contained in:
Zeno Rogue 2022-05-21 17:00:16 +02:00
parent c80d6134e3
commit c9d1f8dfeb
2 changed files with 6 additions and 5 deletions

View File

@ -1363,7 +1363,7 @@ struct adj_data {
}; };
#endif #endif
EX map<cell*, vector<adj_data>> adj_memo; EX array<map<cell*, vector<adj_data>>, 2> adj_memo;
EX bool geometry_has_alt_mine_rule() { EX bool geometry_has_alt_mine_rule() {
if(S3 >= OINF) return false; if(S3 >= OINF) return false;
@ -1373,9 +1373,10 @@ EX bool geometry_has_alt_mine_rule() {
} }
EX vector<adj_data> adj_minefield_cells_full(cell *c) { EX vector<adj_data> adj_minefield_cells_full(cell *c) {
if(adj_memo.count(c)) return adj_memo[c]; auto& am = adj_memo[mine_adjacency_rule];
if(isize(adj_memo) > 10000) adj_memo.clear(); if(am.count(c)) return am[c];
auto& res = adj_memo[c]; if(isize(am) > 10000) am.clear();
auto& res = am[c];
if(mine_adjacency_rule == 0 || !geometry_has_alt_mine_rule()) { if(mine_adjacency_rule == 0 || !geometry_has_alt_mine_rule()) {
forCellIdCM(c2, i, c) res.emplace_back(adj_data{c2, c->c.mirror(i), currentmap->adj(c, i)}); forCellIdCM(c2, i, c) res.emplace_back(adj_data{c2, c->c.mirror(i), currentmap->adj(c, i)});
} }

View File

@ -1694,7 +1694,7 @@ auto cgm = addHook(hooks_clearmemory, 40, [] () {
crush_next.clear(); crush_next.clear();
crush_now.clear(); crush_now.clear();
rosemap.clear(); rosemap.clear();
adj_memo.clear(); for(auto &am: adj_memo) am.clear();
}) + }) +
addHook(hooks_gamedata, 0, [] (gamedata* gd) { addHook(hooks_gamedata, 0, [] (gamedata* gd) {
gd->store(pathq); gd->store(pathq);