1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 13:07:16 +00:00

fixed compass pointers with illegal values or not reaching the target

This commit is contained in:
Zeno Rogue 2024-06-18 19:39:29 +02:00
parent d987895171
commit 5eefd06765

View File

@ -122,14 +122,28 @@ EX int compassDist(cell *c) {
return NOCOMPASS; return NOCOMPASS;
} }
/** identify the compass target that compassDist is talking about */
EX const void *whichCompass(cell *c) {
if(sphere || quotient) return nullptr;
if(eubinary || c->master->alt) return c->master->alt->alt;
if(isHaunted(c->land) || c->land == laGraveyard) return &linf[laHaunted];
return &NOCOMPASS;
}
EX cell *findcompass(cell *c) { EX cell *findcompass(cell *c) {
int d = compassDist(c); int d = compassDist(c);
if(d == NOCOMPASS) return NULL; if(among(d, NOCOMPASS, ALTDIST_BOUNDARY, ALTDIST_UNKNOWN, ALTDIST_ERROR)) return NULL;
auto w = whichCompass(c);
while(inscreenrange(c)) { while(inscreenrange(c)) {
if(!eubinary && !sphere && !quotient) if(!eubinary && !sphere && !quotient)
currentmap->extend_altmap(c->master); currentmap->extend_altmap(c->master);
forCellEx(c2, c) if(compassDist(c2) < d) { forCellEx(c2, c) if(w == whichCompass(c2) && compassDist(c2) < d) {
c = c2;
d = compassDist(c2);
goto nextk;
}
for(int i=0; i<c->master->type; i++) for(int j=0; j<c->master->cmove(i)->type; j++) if(cell *c2 = c->master->cmove(i)->cmove(j)->c7) if(w == whichCompass(c2) && compassDist(c2) < d) {
c = c2; c = c2;
d = compassDist(c2); d = compassDist(c2);
goto nextk; goto nextk;