1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-23 15:36:59 +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. */
shiftmatrix player_matrix;
/** 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). */
ld xmin, ymin, xmax, ymax;
/** Position of the current map view, in pixels. */

View File

@ -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);
}

View File

@ -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;
}

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) {
shiftmatrix res; res.T = T; res.shift = shift; return res;
}

View File

@ -10,18 +10,18 @@ namespace rogueviz {
namespace fullnet {
void drawExtra() {
for(map<cell*, shiftmatrix>::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<cell*, shiftmatrix>::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; i<isize(named); i++) if(named[i] == c) draw = false;
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);
}

View File

@ -2624,8 +2624,8 @@ EX void turn(int delta) {
if(doall)
for(cell *c: currentmap->allcells()) activateMonstersAt(c);
else
for(map<cell*, shiftmatrix>::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(),