From 934e3d9a42bd2387578eb0d3671cb0ab5dd0c872 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 11 Apr 2020 14:40:12 -0400 Subject: [PATCH] Consistently name every hookset with prefix `hooks_`. NFC. I'm sure this causes massive merge-conflicts in the non-public code, but I think it'd be a good idea, if only to avoid confusion between e.g. `clearMemory` and the-variable-formerly-known-as `clearmemory`. --- blizzard.cpp | 2 +- cell.cpp | 2 +- complex.cpp | 2 +- complex2.cpp | 2 +- drawing.cpp | 4 ++-- fieldpattern.cpp | 6 +++--- graph.cpp | 2 +- history.cpp | 2 +- mapeditor.cpp | 2 +- pattern2.cpp | 2 +- racing.cpp | 2 +- rogueviz/pentagonal.cpp | 2 +- rogueviz/rogueviz.cpp | 4 ++-- rogueviz/snow.cpp | 2 +- shmup.cpp | 2 +- system.cpp | 14 +++++++------- textures.cpp | 2 +- tour.cpp | 6 +++--- wfcgen.cpp | 2 +- yendor.cpp | 2 +- 20 files changed, 32 insertions(+), 32 deletions(-) diff --git a/blizzard.cpp b/blizzard.cpp index 0826e212..5a9390c5 100644 --- a/blizzard.cpp +++ b/blizzard.cpp @@ -251,7 +251,7 @@ EX void drawArrowTraps() { } } -auto ccm_blizzard = addHook(clearmemory, 0, [] () { +auto ccm_blizzard = addHook(hooks_clearmemory, 0, [] () { arrowtraps.clear(); blizzardcells.clear(); bcells.clear(); diff --git a/cell.cpp b/cell.cpp index 815f1cf1..6ef2e56d 100644 --- a/cell.cpp +++ b/cell.cpp @@ -1175,7 +1175,7 @@ EX void clearCellMemory() { gp::gp_adj.clear(); } -auto cellhooks = addHook(clearmemory, 500, clearCellMemory); +auto cellhooks = addHook(hooks_clearmemory, 500, clearCellMemory); EX bool isNeighbor(cell *c1, cell *c2) { for(int i=0; itype; i++) if(c1->move(i) == c2) return true; diff --git a/complex.cpp b/complex.cpp index 279b6844..f6d768fe 100644 --- a/complex.cpp +++ b/complex.cpp @@ -3418,7 +3418,7 @@ EX namespace ca { } EX } -auto ccm = addHook(clearmemory, 0, [] () { +auto ccm = addHook(hooks_clearmemory, 0, [] () { heat::offscreen_heat.clear(); heat::offscreen_fire.clear(); princess::clear(); diff --git a/complex2.cpp b/complex2.cpp index ed89abdf..3899d747 100644 --- a/complex2.cpp +++ b/complex2.cpp @@ -198,7 +198,7 @@ EX namespace brownian { vector to_remove; for(auto p: futures) if(is_cell_removed(p.first)) to_remove.push_back(p.first); for(auto r: to_remove) futures.erase(r); - }) + addHook(clearmemory, 0, [] () { futures.clear(); }) + }) + addHook(hooks_clearmemory, 0, [] () { futures.clear(); }) + addHook(hooks_gamedata, 0, [] (gamedata* gd) { gd->store(futures); }); EX } diff --git a/drawing.cpp b/drawing.cpp index 441a5625..56a212be 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1846,7 +1846,7 @@ ld xintval(const hyperpoint& h) { EX ld backbrightness = .25; -purehookset hook_drawqueue; +purehookset hooks_drawqueue; constexpr int PMAX = int(PPR::MAX); int qp[PMAX], qp0[PMAX]; @@ -2032,7 +2032,7 @@ EX hookset *hooks_vr_draw_all; #endif EX void drawqueue() { - callhooks(hook_drawqueue); + callhooks(hooks_drawqueue); current_display->next_shader_flags = 0; reset_projection(); // reset_projection() is not sufficient here, because we need to know shaderside_projection diff --git a/fieldpattern.cpp b/fieldpattern.cpp index 4639abd6..52d57b8d 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -1295,8 +1295,8 @@ discovery::~discovery() { schedule_destruction(); if(discoverer) discoverer->joi int hk = #if CAP_THREAD - + addHook(on_geometry_change, 100, [] { for(auto& d:discoveries) if(!d.second.is_suspended) d.second.suspend(); }) - + addHook(final_cleanup, 100, [] { + + addHook(hooks_on_geometry_change, 100, [] { for(auto& d:discoveries) if(!d.second.is_suspended) d.second.suspend(); }) + + addHook(hooks_final_cleanup, 100, [] { for(auto& d:discoveries) { d.second.schedule_destruction(); if(d.second.is_suspended) d.second.activate(); } discoveries.clear(); }) @@ -1314,7 +1314,7 @@ int hk = #endif + 0; -EX purehookset on_geometry_change; +EX purehookset hooks_on_geometry_change; EX int field_celldistance(cell *c1, cell *c2) { if(geometry != gFieldQuotient) return DISTANCE_UNKNOWN; diff --git a/graph.cpp b/graph.cpp index 257ecf60..14d34544 100644 --- a/graph.cpp +++ b/graph.cpp @@ -5150,7 +5150,7 @@ EX void clearAnimations() { fallanims.clear(); } -auto graphcm = addHook(clearmemory, 0, [] () { +auto graphcm = addHook(hooks_clearmemory, 0, [] () { DEBBI(DF_MEMORY, ("clear graph memory")); mouseover = centerover = lmouseover = NULL; gmatrix.clear(); gmatrix0.clear(); current_display->all_drawn_copies.clear(); diff --git a/history.cpp b/history.cpp index 9be80da5..1b09e302 100644 --- a/history.cpp +++ b/history.cpp @@ -689,7 +689,7 @@ EX namespace history { auto hookArg = addHook(hooks_args, 100, readArgs); #endif - auto hooks = addHook(clearmemory, 0, [] () { + auto hooks = addHook(hooks_clearmemory, 0, [] () { history::renderAutoband(); history::on = false; history::killhistory.clear(); diff --git a/mapeditor.cpp b/mapeditor.cpp index 2258e102..9cb85b24 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -2128,7 +2128,7 @@ namespace mapeditor { } #endif - auto hooks = addHook(clearmemory, 0, [] () { + auto hooks = addHook(hooks_clearmemory, 0, [] () { if(mapeditor::painttype == 4) mapeditor::painttype = 0, mapeditor::paintwhat = 0, mapeditor::paintwhat_str = "clear monster"; diff --git a/pattern2.cpp b/pattern2.cpp index 09bbf3ed..6b070d03 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -3013,7 +3013,7 @@ int read_pattern_args() { return 0; } -auto ah_pattern = addHook(hooks_args, 0, read_pattern_args) + addHook(clearmemory, 100, [] { patterns::computed_nearer_map.clear(); patterns::computed_furthest_map.clear(); }); +auto ah_pattern = addHook(hooks_args, 0, read_pattern_args) + addHook(hooks_clearmemory, 100, [] { patterns::computed_nearer_map.clear(); patterns::computed_furthest_map.clear(); }); #endif } diff --git a/racing.cpp b/racing.cpp index 8d28992e..20b427d2 100644 --- a/racing.cpp +++ b/racing.cpp @@ -835,7 +835,7 @@ heptspin sview; #if CAP_COMMANDLINE auto hook = addHook(hooks_args, 100, readArgs) -+ addHook(clearmemory, 0, []() { ++ addHook(hooks_clearmemory, 0, []() { track_ready = false; track.clear(); rti.clear(); diff --git a/rogueviz/pentagonal.cpp b/rogueviz/pentagonal.cpp index 6d4a98f4..48ab2b5e 100644 --- a/rogueviz/pentagonal.cpp +++ b/rogueviz/pentagonal.cpp @@ -346,7 +346,7 @@ bool handleKey(int sym, int uni) { auto xhook = addHook(hooks_args, 100, readArgs) + addHook(hooks_handleKey, 0, handleKey) + addHook(hooks_prestats, 0, frame) -+ addHook(clearmemory, 40, [] () { snubon = false; } ) ++ addHook(hooks_clearmemory, 40, [] () { snubon = false; } ) + addHook(rvtour::hooks_build_rvtour, 142, [] (vector& v) { using namespace tour; v.push_back( diff --git a/rogueviz/rogueviz.cpp b/rogueviz/rogueviz.cpp index fa55e5f4..d6361c01 100644 --- a/rogueviz/rogueviz.cpp +++ b/rogueviz/rogueviz.cpp @@ -1232,7 +1232,7 @@ auto hooks = #if CAP_COMMANDLINE addHook(hooks_args, 100, readArgs) + #endif - addHook(clearmemory, 0, close) + + addHook(hooks_clearmemory, 0, close) + addHook(hooks_prestats, 100, rogueviz_hud) + addHook(shmup::hooks_draw, 100, drawVertex) + addHook(shmup::hooks_describe, 100, describe_monster) + @@ -1240,7 +1240,7 @@ auto hooks = addHook(hooks_o_key, 100, o_key) + #if CAP_RVSLIDES - addHook(tour::ss::extra_slideshows, 100, [] (bool view) { + addHook(tour::ss::hooks_extra_slideshows, 100, [] (bool view) { if(!view) return 1; dialog::addBoolItem(XLAT("RogueViz Tour"), tour::ss::wts == &rvtour::rvslides[0], 'r'); dialog::add_action([] { tour::ss::wts = rvtour::gen_rvtour(); popScreen(); }); diff --git a/rogueviz/snow.cpp b/rogueviz/snow.cpp index 1ba9eb1c..08af64cc 100644 --- a/rogueviz/snow.cpp +++ b/rogueviz/snow.cpp @@ -199,7 +199,7 @@ named_functionality o_key() { auto hchook = addHook(hooks_drawcell, 100, draw_snow) -+ addHook(clearmemory, 40, [] () { ++ addHook(hooks_clearmemory, 40, [] () { matrices_at.clear(); }) diff --git a/shmup.cpp b/shmup.cpp index 94579ef2..653335be 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -2844,7 +2844,7 @@ EX void addShmupHelp(string& out) { } } -auto hooks = addHook(clearmemory, 0, shmup::clearMemory) + +auto hooks = addHook(hooks_clearmemory, 0, shmup::clearMemory) + addHook(hooks_gamedata, 0, shmup::gamedata) + addHook(hooks_removecells, 0, [] () { for(mit it = monstersAt.begin(); it != monstersAt.end();) { diff --git a/system.cpp b/system.cpp index 3e76980b..88ca5721 100644 --- a/system.cpp +++ b/system.cpp @@ -1246,11 +1246,11 @@ eModel default_model() { return mdDisk; } -EX purehookset on_geometry_change; +EX purehookset hooks_on_geometry_change; EX void set_geometry(eGeometry target) { bool was_default = pmodel == default_model(); - callhooks(on_geometry_change); + callhooks(hooks_on_geometry_change); if(geometry != target) { int old_DIM = GDIM; stop_game(); @@ -1497,10 +1497,10 @@ EX void stop_game_and_switch_mode(char switchWhat IS(rg::nothing)) { switch_game_mode(switchWhat); } -EX purehookset clearmemory; +EX purehookset hooks_clearmemory; EX void clearMemory() { - callhooks(clearmemory); + callhooks(hooks_clearmemory); } EX bool fixseed = false; @@ -1544,7 +1544,7 @@ EX void initAll() { polygonal::solve(); } -EX purehookset final_cleanup; +EX purehookset hooks_final_cleanup; EX void finishAll() { achievement_final(!items[itOrbSafety]); @@ -1558,11 +1558,11 @@ EX void finishAll() { #endif achievement_close(); - callhooks(final_cleanup); + callhooks(hooks_final_cleanup); } -auto cgm = addHook(clearmemory, 40, [] () { +auto cgm = addHook(hooks_clearmemory, 40, [] () { pathq.clear(); dcal.clear(); clearshadow(); diff --git a/textures.cpp b/textures.cpp index b2d92342..ea0a07b4 100644 --- a/textures.cpp +++ b/textures.cpp @@ -1725,7 +1725,7 @@ int textureArgs() { auto texture_hook = addHook(hooks_args, 100, textureArgs) -+ addHook(clearmemory, 100, [] () { config.data.pixels_to_draw.clear(); }); ++ addHook(hooks_clearmemory, 100, [] () { config.data.pixels_to_draw.clear(); }); int lastupdate; diff --git a/tour.cpp b/tour.cpp index 3971a0b8..f493bab8 100644 --- a/tour.cpp +++ b/tour.cpp @@ -377,13 +377,13 @@ EX namespace ss { string slidechars = "abcdefghijklmnopqrsvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789!@#$%^&*("; - EX hookset *extra_slideshows; + EX hookset *hooks_extra_slideshows; EX void slideshow_menu() { dialog::init(XLAT("slideshows"), forecolor, 150, 100); dialog::addBoolItem(XLAT("Guided Tour"), wts == default_slides, 't'); dialog::add_action([] { wts = default_slides; popScreen(); }); - callhooks(extra_slideshows, true); + callhooks(hooks_extra_slideshows, true); dialog::addBack(); dialog::display(); } @@ -438,7 +438,7 @@ EX namespace ss { } dialog::addBreak(50); bool b = false; - if(callhandlers(0, extra_slideshows, b)) { + if(callhandlers(0, hooks_extra_slideshows, b)) { dialog::addItem(XLAT("change slideshow"), '1'); dialog::add_action_push(slideshow_menu); } diff --git a/wfcgen.cpp b/wfcgen.cpp index 39140265..eb7041c0 100644 --- a/wfcgen.cpp +++ b/wfcgen.cpp @@ -288,7 +288,7 @@ auto wfc_hook = }); #endif -auto cgm = addHook(clearmemory, 40, [] () { centers.clear(); }) + addHook(hooks_removecells, 0, [] () { eliminate_if(centers, is_cell_removed); }); +auto cgm = addHook(hooks_clearmemory, 40, [] () { centers.clear(); }) + addHook(hooks_removecells, 0, [] () { eliminate_if(centers, is_cell_removed); }); EX } diff --git a/yendor.cpp b/yendor.cpp index 92a58786..0d2af3c3 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -799,7 +799,7 @@ EX namespace yendor { achievement_victory(false); } - auto hooks = addHook(clearmemory, 0, [] () { + auto hooks = addHook(hooks_clearmemory, 0, [] () { yendor::yii = NOYENDOR; yendor::yi.clear(); }) + addHook(hooks_removecells, 0, [] () { eliminate_if(yendor::yi, [] (yendorinfo& i) {