From ec96ad271824856923d09423388657c1cedc89ae Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 17 Jul 2024 11:16:01 +0200 Subject: [PATCH] gmatrix now uses shiftmatrix_or_null which has an additional field if data is not yet computed -- this seems to fix some bugs in the new compilations of HyperRogue --- basegraph.cpp | 2 +- celldrawer.cpp | 4 ++-- geometry2.cpp | 5 +++-- hyperpoint.cpp | 6 ++++++ rogueviz/fullnet.cpp | 10 +++++----- shmup.cpp | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/basegraph.cpp b/basegraph.cpp index 409225e5..b9789a4a 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -36,7 +36,7 @@ struct display_data { /** The view relative to the player character. */ shiftmatrix player_matrix; /** On-screen coordinates for all the visible cells. */ - map cellmatrices, old_cellmatrices; + map cellmatrices, old_cellmatrices; /** Position of the current map view, relative to the screen (0 to 1). */ ld xmin, ymin, xmax, ymax; /** Position of the current map view, in pixels. */ diff --git a/celldrawer.cpp b/celldrawer.cpp index 1e576507..6d08f926 100644 --- a/celldrawer.cpp +++ b/celldrawer.cpp @@ -2040,8 +2040,8 @@ EX int debug_tiles; void celldrawer::bookkeeping() { bool orig = false; if(!inmirrorcount) { - shiftmatrix& gm = gmatrix[c]; - orig = (gm[LDIM][LDIM] == 0) || hdist0(tC0(gm)) >= hdist0(tC0(V)); + auto& gm = gmatrix[c]; + orig = gm.is_null || hdist0(tC0(gm)) >= hdist0(tC0(V)); if(orig) gm = V; current_display->all_drawn_copies[c].emplace_back(V); } diff --git a/geometry2.cpp b/geometry2.cpp index 93518ec9..002d0654 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -201,9 +201,10 @@ transmatrix hrmap_standard::relative_matrixh(heptagon *h2, heptagon *h1, const h } EX shiftmatrix &ggmatrix(cell *c) { - shiftmatrix& t = gmatrix[c]; - if(t[LDIM][LDIM] == 0) { + auto& t = gmatrix[c]; + if(t.is_null) { if(sl2) return t = twist::nmul(shiftless(actual_view_transform * View), twist::relative_shiftmatrix(c, centerover)); + t.is_null = false; t.T = actual_view_transform * View * calc_relative_matrix(c, centerover, C0); t.shift = 0; } diff --git a/hyperpoint.cpp b/hyperpoint.cpp index fd615502..15ac97c2 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -186,6 +186,12 @@ struct shiftmatrix { } }; +struct shiftmatrix_or_null : shiftmatrix { + bool is_null; + shiftmatrix_or_null& operator = (const shiftmatrix& T) { ((shiftmatrix&) self) = T; is_null = false; return self; } + shiftmatrix_or_null() { is_null = true; } + }; + inline shiftmatrix shiftless(const transmatrix& T, ld shift = 0) { shiftmatrix res; res.T = T; res.shift = shift; return res; } diff --git a/rogueviz/fullnet.cpp b/rogueviz/fullnet.cpp index 600e286a..c038562d 100644 --- a/rogueviz/fullnet.cpp +++ b/rogueviz/fullnet.cpp @@ -10,18 +10,18 @@ namespace rogueviz { namespace fullnet { void drawExtra() { - for(map::iterator it = gmatrix.begin(); it != gmatrix.end(); it++) { - cell *c = it->first; + for(auto& p: gmatrix) { + cell *c = p.first; c->wall = waChasm; } int index = 0; - for(map::iterator it = gmatrix.begin(); it != gmatrix.end(); it++) { - cell *c = it->first; + for(auto& p: gmatrix) { + cell *c = p.first; bool draw = true; for(int i=0; isecond, dftcolor, false, NULL, index++); + queuedisk(p.second, dftcolor, false, NULL, index++); // queuepolyat(it->second, shDisk, dftcolor., PPR::LINE); } diff --git a/shmup.cpp b/shmup.cpp index 56404e63..926e25c6 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -2624,8 +2624,8 @@ EX void turn(int delta) { if(doall) for(cell *c: currentmap->allcells()) activateMonstersAt(c); else - for(map::iterator it = gmatrix.begin(); it != gmatrix.end(); it++) - activateMonstersAt(it->first); + for(auto& p: gmatrix) + activateMonstersAt(p.first); /* printf("size: gmatrix = %ld, active = %ld, monstersAt = %ld, delta = %d\n", gmatrix.size(), active.size(), monstersAt.size(),