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

rogueviz:: do_cleanup as a separate function

This commit is contained in:
Zeno Rogue 2021-03-31 12:19:31 +02:00
parent 4af75fe611
commit 03f55aa372
2 changed files with 10 additions and 4 deletions

View File

@ -918,6 +918,13 @@ int search_for = -1;
vector<reaction_t> cleanup; vector<reaction_t> cleanup;
void do_cleanup() {
while(!cleanup.empty()) {
cleanup.back()();
cleanup.pop_back();
}
}
void close() { void close() {
search_for = -1; search_for = -1;
for(int i=0; i<isize(vdata); i++) for(int i=0; i<isize(vdata); i++)
@ -930,10 +937,7 @@ void close() {
anygraph::coords.clear(); anygraph::coords.clear();
callhooks(hooks_close); callhooks(hooks_close);
edgetypes.clear(); edgetypes.clear();
while(!cleanup.empty()) { do_cleanup();
cleanup.back()();
cleanup.pop_back();
}
relmatrices.clear(); relmatrices.clear();
} }

View File

@ -99,6 +99,8 @@ namespace rogueviz {
extern vector<reaction_t> cleanup; extern vector<reaction_t> cleanup;
void do_cleanup();
template<class T, class U> void rv_hook(hookset<T>& m, int prio, U&& hook) { template<class T, class U> void rv_hook(hookset<T>& m, int prio, U&& hook) {
int p = addHook(m, prio, hook); int p = addHook(m, prio, hook);
auto del = [&m, p] { auto del = [&m, p] {