1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-02-02 20:29:17 +00:00

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

This commit is contained in:
Zeno Rogue 2024-07-17 11:16:01 +02:00
parent 497790e54b
commit ec96ad2718
6 changed files with 19 additions and 12 deletions

View File

@ -36,7 +36,7 @@ struct display_data {
/** The view relative to the player character. */ /** The view relative to the player character. */
shiftmatrix player_matrix; shiftmatrix player_matrix;
/** On-screen coordinates for all the visible cells. */ /** On-screen coordinates for all the visible cells. */
map<cell*, shiftmatrix> cellmatrices, old_cellmatrices; map<cell*, shiftmatrix_or_null> cellmatrices, old_cellmatrices;
/** Position of the current map view, relative to the screen (0 to 1). */ /** Position of the current map view, relative to the screen (0 to 1). */
ld xmin, ymin, xmax, ymax; ld xmin, ymin, xmax, ymax;
/** Position of the current map view, in pixels. */ /** Position of the current map view, in pixels. */

View File

@ -2040,8 +2040,8 @@ EX int debug_tiles;
void celldrawer::bookkeeping() { void celldrawer::bookkeeping() {
bool orig = false; bool orig = false;
if(!inmirrorcount) { if(!inmirrorcount) {
shiftmatrix& gm = gmatrix[c]; auto& gm = gmatrix[c];
orig = (gm[LDIM][LDIM] == 0) || hdist0(tC0(gm)) >= hdist0(tC0(V)); orig = gm.is_null || hdist0(tC0(gm)) >= hdist0(tC0(V));
if(orig) gm = V; if(orig) gm = V;
current_display->all_drawn_copies[c].emplace_back(V); current_display->all_drawn_copies[c].emplace_back(V);
} }

View File

@ -201,9 +201,10 @@ transmatrix hrmap_standard::relative_matrixh(heptagon *h2, heptagon *h1, const h
} }
EX shiftmatrix &ggmatrix(cell *c) { EX shiftmatrix &ggmatrix(cell *c) {
shiftmatrix& t = gmatrix[c]; auto& t = gmatrix[c];
if(t[LDIM][LDIM] == 0) { if(t.is_null) {
if(sl2) return t = twist::nmul(shiftless(actual_view_transform * View), twist::relative_shiftmatrix(c, centerover)); 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.T = actual_view_transform * View * calc_relative_matrix(c, centerover, C0);
t.shift = 0; t.shift = 0;
} }

View File

@ -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) { inline shiftmatrix shiftless(const transmatrix& T, ld shift = 0) {
shiftmatrix res; res.T = T; res.shift = shift; return res; shiftmatrix res; res.T = T; res.shift = shift; return res;
} }

View File

@ -10,18 +10,18 @@ namespace rogueviz {
namespace fullnet { namespace fullnet {
void drawExtra() { void drawExtra() {
for(map<cell*, shiftmatrix>::iterator it = gmatrix.begin(); it != gmatrix.end(); it++) { for(auto& p: gmatrix) {
cell *c = it->first; cell *c = p.first;
c->wall = waChasm; c->wall = waChasm;
} }
int index = 0; int index = 0;
for(map<cell*, shiftmatrix>::iterator it = gmatrix.begin(); it != gmatrix.end(); it++) { for(auto& p: gmatrix) {
cell *c = it->first; cell *c = p.first;
bool draw = true; bool draw = true;
for(int i=0; i<isize(named); i++) if(named[i] == c) draw = false; for(int i=0; i<isize(named); i++) if(named[i] == c) draw = false;
if(draw && gmatrix.count(c)) if(draw && gmatrix.count(c))
queuedisk(it->second, dftcolor, false, NULL, index++); queuedisk(p.second, dftcolor, false, NULL, index++);
// queuepolyat(it->second, shDisk, dftcolor., PPR::LINE); // queuepolyat(it->second, shDisk, dftcolor., PPR::LINE);
} }

View File

@ -2624,8 +2624,8 @@ EX void turn(int delta) {
if(doall) if(doall)
for(cell *c: currentmap->allcells()) activateMonstersAt(c); for(cell *c: currentmap->allcells()) activateMonstersAt(c);
else else
for(map<cell*, shiftmatrix>::iterator it = gmatrix.begin(); it != gmatrix.end(); it++) for(auto& p: gmatrix)
activateMonstersAt(it->first); activateMonstersAt(p.first);
/* printf("size: gmatrix = %ld, active = %ld, monstersAt = %ld, delta = %d\n", /* printf("size: gmatrix = %ld, active = %ld, monstersAt = %ld, delta = %d\n",
gmatrix.size(), active.size(), monstersAt.size(), gmatrix.size(), active.size(), monstersAt.size(),