diff --git a/bigstuff.cpp b/bigstuff.cpp index add22184..df6b8498 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -134,8 +134,11 @@ EX cell *findcompass(cell *c) { int d = compassDist(c); if(among(d, NOCOMPASS, ALTDIST_BOUNDARY, ALTDIST_UNKNOWN, ALTDIST_ERROR)) return NULL; auto w = whichCompass(c); + + auto gc = c; while(inscreenrange(c)) { + gc = c; if(!eubinary && !sphere && !quotient) currentmap->extend_altmap(c->master); forCellEx(c2, c) if(w == whichCompass(c2) && compassDist(c2) < d) { @@ -152,7 +155,7 @@ EX cell *findcompass(cell *c) { nextk: ; } - return c; + return gc; } EX bool grailWasFound(cell *c) { diff --git a/graph.cpp b/graph.cpp index a58a5585..2966fbdd 100644 --- a/graph.cpp +++ b/graph.cpp @@ -6315,12 +6315,27 @@ EX void drawBug(const cellwalker& cw, color_t col) { #endif } +EX bool inscreenrange_actual(cell *c) { + if(GDIM == 3) return true; + hyperpoint h1; applymodel(ggmatrix(c) * tile_center(), h1); + if(invalid_point(h1)) return false; + auto hscr = toscrcoord(h1); + auto& x = hscr[0], y = hscr[1]; + if(x > current_display->xtop + current_display->xsize) return false; + if(x < current_display->xtop) return false; + if(y > current_display->ytop + current_display->ysize) return false; + if(y < current_display->ytop) return false; + return true; + } + EX bool inscreenrange(cell *c) { if(sphere) return true; - if(euclid) return celldistance(centerover, c) <= get_sightrange_ambush(); + if(euclid) return celldistance(centerover, c) <= get_sightrange_ambush() && inscreenrange_actual(c); if(nonisotropic) return gmatrix.count(c); - if(geometry == gCrystal344) return gmatrix.count(c); - return heptdistance(centerover, c) <= 8; + if(geometry == gCrystal344) return gmatrix.count(c) && inscreenrange_actual(c); + auto hd = heptdistance(centerover, c); + if(hd <= 1) return true; + return hd <= 8 && inscreenrange_actual(c); } #if MAXMDIM >= 4