1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

cleaner sightrange

This commit is contained in:
Zeno Rogue 2018-04-11 13:16:40 +02:00
parent fa86a88ea3
commit 848a135135
5 changed files with 72 additions and 51 deletions

View File

@ -14,6 +14,7 @@ int utfsize(char c) {
} }
int get_sightrange() { return getDistLimit() + sightrange_bonus; } int get_sightrange() { return getDistLimit() + sightrange_bonus; }
int get_sightrange_ambush() { return max(get_sightrange(), ambush_distance); }
namespace stereo { namespace stereo {
eStereo mode; eStereo mode;

View File

@ -2743,9 +2743,34 @@ bool nogoSlow(cell *to, cell *from) {
} }
// pathdist begin // pathdist begin
cell *pd_from;
int pd_range;
void compute_graphical_distance() {
cell *c1 = centerover.c ? centerover.c : cwt.c;
int sr = get_sightrange_ambush();
if(pd_from == c1 && pd_range == sr) return;
for(auto c: pathq) c->pathdist = PINFD;
pathq.clear();
pd_from = c1;
pd_range = sr;
c1->pathdist = 0;
pathq.push_back(pd_from);
for(int qb=0; qb<size(pathq); qb++) {
cell *c = pathq[qb];
if(c->pathdist == pd_range) break;
forCellEx(c1, c)
if(c1->pathdist == PINFD)
c1->pathdist = c->pathdist + 1,
pathq.push_back(c1);
}
}
void computePathdist(eMonster param) { void computePathdist(eMonster param) {
int pqs = size(pathq); pd_from = NULL;
for(int i=0; i<pqs; i++) pathq[i]->pathdist = PINFD; for(auto c: pathq) c->pathdist = PINFD;
pathq.clear(); pathq.clear();
pathqm.clear(); pathqm.clear();
reachedfrom.clear(); reachedfrom.clear();

View File

@ -8,7 +8,6 @@ int inmirrorcount = 0;
bool wmspatial, wmescher, wmplain, wmblack, wmascii; bool wmspatial, wmescher, wmplain, wmblack, wmascii;
bool mmspatial, mmhigh, mmmon, mmitem; bool mmspatial, mmhigh, mmmon, mmitem;
int maxreclevel, reclevel;
int detaillevel = 0; int detaillevel = 0;
@ -2814,7 +2813,7 @@ void setcolors(cell *c, int& wcol, int &fcol) {
// xcol = (c->landparam&1) ? 0xD00000 : 0x00D000; // xcol = (c->landparam&1) ? 0xD00000 : 0x00D000;
fcol = 0x10101 * (32 + (c->landparam&1) * 32) - 0x000010; fcol = 0x10101 * (32 + (c->landparam&1) * 32) - 0x000010;
int ed = edgeDepth(c); int ed = edgeDepth(c);
int sr = max(get_sightrange(), ambush_distance); int sr = get_sightrange_ambush();
while(ed > clev + sr) ed -= 2; while(ed > clev + sr) ed -= 2;
while(ed < clev - sr) ed += 2; while(ed < clev - sr) ed += 2;
fcol = gradient(fcol, 0x0000D0, clev-sr, edgeDepth(c), clev+sr); fcol = gradient(fcol, 0x0000D0, clev-sr, edgeDepth(c), clev+sr);
@ -3296,18 +3295,13 @@ void pushdown(cell *c, int& q, const transmatrix &V, double down, bool rezoom, b
} }
bool dodrawcell(cell *c) { bool dodrawcell(cell *c) {
// todo: fix when scrolling // do not display out of range cells, unless on torus
if(!buggyGeneration && !debugmode && c->land != laCanvas && sightrange_bonus < 3) { if(c->pathdist == PINFD && geometry != gTorus)
// not yet created return false;
// do not display not fully generated cells, unless a cheater
if(c->mpdist > 7 && !cheater) return false; if(c->mpdist > 7 && !cheater) return false;
// always show on the torus rug
if(rug::rugged && torus) return true;
if(cmode & sm::TORUSCONFIG) return true;
// in the Yendor Challenge, scrolling back is forbidden // in the Yendor Challenge, scrolling back is forbidden
if(c->cpdist > 7 && (yendor::on && !cheater)) return false; if(c->cpdist > 7 && yendor::on && !cheater) return false;
// (incorrect comment) too far, no bugs nearby
if(playermoved && c->cpdist > get_sightrange() && c->cpdist > ambush_distance) return false;
}
return true; return true;
} }
@ -5054,7 +5048,7 @@ void drawMarkers() {
cell *keycell = NULL; cell *keycell = NULL;
int i; int i;
for(i=0; i<YDIST; i++) for(i=0; i<YDIST; i++)
if(yi[yii].path[i]->cpdist <= get_sightrange()) { if(yi[yii].path[i]->cpdist <= get_sightrange_ambush()) {
keycell = yi[yii].path[i]; keycell = yi[yii].path[i];
break; break;
} }
@ -5273,6 +5267,8 @@ void drawthemap() {
modist = 1e20; mouseover = NULL; modist = 1e20; mouseover = NULL;
modist2 = 1e20; mouseover2 = NULL; modist2 = 1e20; mouseover2 = NULL;
compute_graphical_distance();
centdist = 1e20; centdist = 1e20;
if(!euclid) centerover.c = NULL; if(!euclid) centerover.c = NULL;
@ -5296,17 +5292,8 @@ void drawthemap() {
profile_start(1); profile_start(1);
if(euclid) if(euclid)
drawEuclidean(); drawEuclidean();
else { else
int sr = max(get_sightrange(), ambush_distance); drawrec(viewctr, hsOrigin, cview());
maxreclevel =
conformal::on ? sr + 2:
(!playermoved) ? sr+1 : sr + 4;
if(S3>3) maxreclevel+=2;
if(gp::on) maxreclevel += gp::dist_2();
drawrec(viewctr, maxreclevel, hsOrigin, cview());
}
drawWormSegments(); drawWormSegments();
drawBlizzards(); drawBlizzards();
drawArrowTraps(); drawArrowTraps();
@ -5941,7 +5928,7 @@ cell *viewcenter() {
bool inscreenrange(cell *c) { bool inscreenrange(cell *c) {
if(sphere) return true; if(sphere) return true;
if(euclid) return celldistance(viewcenter(), c) <= get_sightrange(); if(euclid) return celldistance(viewcenter(), c) <= get_sightrange_ambush();
return heptdistance(viewcenter(), c) <= 5; return heptdistance(viewcenter(), c) <= 5;
} }

View File

@ -3016,6 +3016,8 @@ namespace gp {
} }
int get_sightrange(); int get_sightrange();
int get_sightrange_ambush();
int gamerange(); int gamerange();
int numplayers(); int numplayers();

View File

@ -464,6 +464,12 @@ transmatrix applyspin(const heptspin& hs, const transmatrix& V) {
return (hs.spin || nonbitrunc) ? V * spin(hs.spin*2*M_PI/S7) : V; return (hs.spin || nonbitrunc) ? V * spin(hs.spin*2*M_PI/S7) : V;
} }
// in hyperbolic quotient geometries, relying on pathdist is not sufficient
bool in_qrange(const transmatrix& V) {
if(!quotient || !hyperbolic) return true;
return V[2][2] < cosh(crossf * get_sightrange_ambush());
}
namespace gp { namespace gp {
/* /*
@ -486,7 +492,9 @@ void drawrec(cell *c, const transmatrix& V) {
if(fix6(dir) != fix6(li.total_dir)) printf("totaldir %d/%d\n", dir, li.total_dir); if(fix6(dir) != fix6(li.total_dir)) printf("totaldir %d/%d\n", dir, li.total_dir);
if(at != li.relative) printf("at %s/%s\n", disp(at), disp(li.relative)); if(at != li.relative) printf("at %s/%s\n", disp(at), disp(li.relative));
if(maindir != li.last_dir) printf("ld %d/%d\n", maindir, li.last_dir); */ if(maindir != li.last_dir) printf("ld %d/%d\n", maindir, li.last_dir); */
drawcell(c, V * Tf[maindir][at.first&31][at.second&31][fix6(dir)], 0, false); transmatrix V1 = V * Tf[maindir][at.first&31][at.second&31][fix6(dir)];
if(in_qrange(V1))
drawcell(c, V1, 0, false);
} }
for(int i=0; i<c->type; i++) { for(int i=0; i<c->type; i++) {
cell *c2 = c->mov[i]; cell *c2 = c->mov[i];
@ -510,7 +518,7 @@ void drawrec(cell *c, const transmatrix& V) {
} }
} }
void drawrec(const heptspin& hs, int lev, hstate s, const transmatrix& V) { void drawrec(const heptspin& hs, hstate s, const transmatrix& V) {
// shmup::calc_relative_matrix(cwt.c, hs.h); // shmup::calc_relative_matrix(cwt.c, hs.h);
@ -523,30 +531,29 @@ void drawrec(const heptspin& hs, int lev, hstate s, const transmatrix& V) {
gp::drawrec(c, actualV(hs, V1)); gp::drawrec(c, actualV(hs, V1));
} }
else if(dodrawcell(c)) { else {
reclevel = maxreclevel - lev; if(dodrawcell(c)) {
transmatrix V2 = actualV(hs, V1); transmatrix V2 = actualV(hs, V1);
drawcell(c, V2, 0, hs.mirrored); drawcell(c, V2, 0, hs.mirrored);
} }
if(lev <= 0) return;
if(!nonbitrunc) for(int d=0; d<S7; d++) { if(!nonbitrunc) for(int d=0; d<S7; d++) {
int ds = fixrot(hs.spin + d); int ds = fixrot(hs.spin + d);
reclevel = maxreclevel - lev + 1;
// createMov(c, ds); // createMov(c, ds);
if(c->mov[ds] && c->spn(ds) == 0 && dodrawcell(c->mov[ds])) { if(c->mov[ds] && c->spn(ds) == 0 && dodrawcell(c->mov[ds])) {
drawcell(c->mov[ds], V1 * hexmove[d], 0, hs.mirrored ^ c->mirror(ds)); transmatrix V2 = V1 * hexmove[d];
if(in_qrange(V2))
drawcell(c->mov[ds], V2, 0, hs.mirrored ^ c->mirror(ds));
}
} }
} }
if(lev <= 1) return; if(c->pathdist < PINFD && in_qrange(V))
for(int d=0; d<S7; d++) { for(int d=0; d<S7; d++) {
hstate s2 = transition(s, d); hstate s2 = transition(s, d);
if(s2 == hsError) continue; if(s2 == hsError) continue;
heptspin hs2 = hs + d + wstep; heptspin hs2 = hs + d + wstep;
drawrec(hs2, lev-gp::dist_2(), s2, V * heptmove[d]); drawrec(hs2, s2, V * heptmove[d]);
} }
} }
@ -632,7 +639,6 @@ void drawEuclidean() {
for(int dy=minsy; dy<=maxsy; dy++) { for(int dy=minsy; dy<=maxsy; dy++) {
torusconfig::torus_cx = dx; torusconfig::torus_cx = dx;
torusconfig::torus_cy = dy; torusconfig::torus_cy = dy;
reclevel = eudist(dx, dy);
cellwalker cw = vec_to_cellwalker(pvec + euclid_getvec(dx, dy)); cellwalker cw = vec_to_cellwalker(pvec + euclid_getvec(dx, dy));
transmatrix Mat = eumove(dx,dy); transmatrix Mat = eumove(dx,dy);