From c9d1f8dfebe2328c7ab3cc3a30a9b547bbe4e45a Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 21 May 2022 17:00:16 +0200 Subject: [PATCH] adj_memo now can keep separate memos for different rules --- cell.cpp | 9 +++++---- system.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cell.cpp b/cell.cpp index 914ff0b7..22f84cc7 100644 --- a/cell.cpp +++ b/cell.cpp @@ -1363,7 +1363,7 @@ struct adj_data { }; #endif -EX map> adj_memo; +EX array>, 2> adj_memo; EX bool geometry_has_alt_mine_rule() { if(S3 >= OINF) return false; @@ -1373,9 +1373,10 @@ EX bool geometry_has_alt_mine_rule() { } EX vector adj_minefield_cells_full(cell *c) { - if(adj_memo.count(c)) return adj_memo[c]; - if(isize(adj_memo) > 10000) adj_memo.clear(); - auto& res = adj_memo[c]; + auto& am = adj_memo[mine_adjacency_rule]; + if(am.count(c)) return am[c]; + if(isize(am) > 10000) am.clear(); + auto& res = am[c]; 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)}); } diff --git a/system.cpp b/system.cpp index c7c34f4e..b46400db 100644 --- a/system.cpp +++ b/system.cpp @@ -1694,7 +1694,7 @@ auto cgm = addHook(hooks_clearmemory, 40, [] () { crush_next.clear(); crush_now.clear(); rosemap.clear(); - adj_memo.clear(); + for(auto &am: adj_memo) am.clear(); }) + addHook(hooks_gamedata, 0, [] (gamedata* gd) { gd->store(pathq);