From 5d81260f0bf647dbc090873140f5210923a644a5 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 11 Dec 2021 23:28:05 +0100 Subject: [PATCH] expansion_analyzer is now in cgi --- bigstuff.cpp | 2 +- complex.cpp | 1 + complex2.cpp | 4 ++-- expansion.cpp | 18 ++++++++++++++---- geometry.cpp | 4 ++++ geometry2.cpp | 3 ++- hud.cpp | 2 +- quit.cpp | 2 +- system.cpp | 2 +- yendor.cpp | 1 + 10 files changed, 28 insertions(+), 11 deletions(-) diff --git a/bigstuff.cpp b/bigstuff.cpp index db78c979..472dc7b5 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -1814,7 +1814,7 @@ EX void buildCamelot(cell *c) { c->monst = camelot_monster(); if(d == 1) { // roughly as many knights as table cells - if(hrand(1000000) < 1000000 / expansion.get_growth() && !reptilecheat) + if(hrand(1000000) < 1000000 / get_expansion().get_growth() && !reptilecheat) c->monst = moKnight; if(!eubinary) for(int i=0; imaster->type; i++) currentmap->extend_altmap(c->master->move(i)); for(int i=0; itype; i++) diff --git a/complex.cpp b/complex.cpp index a78e2ff4..92eb2c42 100644 --- a/complex.cpp +++ b/complex.cpp @@ -1003,6 +1003,7 @@ EX namespace clearing { cell *c1 = c; if(c->mondir < c->type) c1 = c->move(c->mondir); + auto& expansion = get_expansion(); return make_tuple( celldistAlt(c), type_in(expansion, c, celldistAlt), celldistAlt(c1), type_in(expansion, c1, celldistAlt) diff --git a/complex2.cpp b/complex2.cpp index 5f00d280..e5eb61c2 100644 --- a/complex2.cpp +++ b/complex2.cpp @@ -460,7 +460,7 @@ EX void knightFlavorMessage(cell *c2) { s = crystal::get_table_boundary(); #endif else if(!quotient && rad) - s = expansion.get_descendants(rad).get_str(100); + s = get_expansion().get_descendants(rad).get_str(100); if(s == "") { msgid++; goto retry; } addMessage(XLAT("\"Our Table seats %1 Knights!\"", s)); } @@ -472,7 +472,7 @@ EX void knightFlavorMessage(cell *c2) { s = crystal::get_table_volume(); #endif else if(!quotient && rad) - s = expansion.get_descendants(rad-1, expansion.diskid).get_str(100); + s = get_expansion().get_descendants(rad-1, get_expansion().diskid).get_str(100); if(s == "") { msgid++; goto retry; } addMessage(XLAT("\"There are %1 floor tiles inside our Table!\"", s)); } diff --git a/expansion.cpp b/expansion.cpp index 953b8522..4a59537a 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -23,6 +23,7 @@ void canonicize(vector& t) { #if HDR struct expansion_analyzer { + int sibling_limit; vector gettype(cell *c); int N; vector samples; @@ -456,6 +457,7 @@ int position; EX int type_in_reduced(expansion_analyzer& ea, cell *c, const cellfunction& f) { int a = ea.N; int t = type_in(ea, c, f); + auto& expansion = get_expansion(); if(expansion.N != a) { expansion.reduce_grouping(); t = type_in(ea, c, f); @@ -598,7 +600,7 @@ void celldrawer::do_viewdist() { if(c->master->alt) t = c->master->alt->fieldval; break; } - else t = type_in_reduced(expansion, c, curr_dist); + else t = type_in_reduced(get_expansion(), c, curr_dist); if(t >= 0) label = its(t), dc = distribute_color(t); break; } @@ -727,6 +729,7 @@ void expansion_analyzer::view_distances_dialog() { int maxlen = bounded ? 128 : 16 + first_distance; vector qty(maxlen); + auto& expansion = get_expansion(); bool really_use_analyzer = use_analyzer && sizes_known(); @@ -826,6 +829,7 @@ void compute_coefficients() { println(hlog, gp::operation_name(), " ", ginf[geometry].tiling_name); start_game(); + auto& expansion = get_expansion(); printf(" sizes:"); for(int i=0; i (); + return *cgi.expansion; + } EX void set_sibling_limit() { + auto& sibling_limit = get_expansion().sibling_limit; if(0) ; #if CAP_IRR else if(IRREGULAR) sibling_limit = 3; @@ -1006,6 +1015,7 @@ EX int hyperbolic_celldistance(cell *c1, cell *c2) { int found_distance = INF; int d = 0, d1 = celldist0(c1), d2 = celldist0(c2), sl_used = 0; + auto& sibling_limit = get_expansion().sibling_limit; cell *cl1=c1, *cr1=c1, *cl2=c2, *cr2=c2; while(true) { diff --git a/geometry.cpp b/geometry.cpp index c95733d1..08491862 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -107,6 +107,8 @@ struct gi_extension { virtual ~gi_extension() {} }; +struct expansion_analyzer; + /** both for 'heptagon' 3D cells and subdivided 3D cells */ struct subcellshape { /** \brief raw coordinates of vertices of all faces */ @@ -499,6 +501,8 @@ hpcshape }; shared_ptr gpdata = nullptr; #endif + + shared_ptr expansion = nullptr; int state = 0; int usershape_state = 0; diff --git a/geometry2.cpp b/geometry2.cpp index 0c5b07cc..7724ceb4 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -876,6 +876,7 @@ EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor, b cellwalker ycw = start; if(for_yendor) setdist(p.path[0], 7, NULL); + auto& expansion = get_expansion(); for(int i=0; isidescreen) return; first_cell_to_draw = true; diff --git a/quit.cpp b/quit.cpp index 45e7ec71..5b8564f8 100644 --- a/quit.cpp +++ b/quit.cpp @@ -254,7 +254,7 @@ EX hint hints[] = { []() { return !canmove && sizes_known() && celldist(cwt.at) >= 50; }, []() { int d = celldist(cwt.at); - string s = expansion.approximate_descendants(d, 10000); + string s = get_expansion().approximate_descendants(d, 10000); dialog::addHelp(XLAT( "You are %1 cells away from the starting point, or " "the place where you used an Orb of Safety last time. " diff --git a/system.cpp b/system.cpp index a26f70b4..62cd9011 100644 --- a/system.cpp +++ b/system.cpp @@ -1561,7 +1561,7 @@ EX void start_game() { arcm::current_or_fake().compute_geometry(); #endif initcells(); - expansion.reset(); + get_expansion().reset(); if(randomPatternsMode) { for(int i=0; iland == laWestWall && trees_known()) { + auto& expansion = get_expansion(); int t = type_in(expansion, yendor, [yendor] (cell *c) { return celldistance(yendor, c); }); int maxage = 10; for(int i=0; i