1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-20 03:54:47 +00:00

faster get_side hard case

This commit is contained in:
Zeno Rogue 2021-08-20 00:44:24 +02:00
parent 0d60ff6bdc
commit 40792a3aa1

View File

@ -852,10 +852,16 @@ int get_side(twalker what) {
debuglist = {what, to_what, wl, wr};
throw rulegen_failure("xsidefreeze");
}
treewalk(wl, -1);
treewalk(wr, +1);
if(wl == to_what) return sidecache[what] = +1;
if(wr == to_what) return sidecache[what] = -1;
bool gl = wl.at->dist <= wr.at->dist;
bool gr = wl.at->dist >= wr.at->dist;
if(gl) {
treewalk(wl, -1);
if(wl == to_what) return sidecache[what] = +1;
}
if(gr) {
treewalk(wr, +1);
if(wr == to_what) return sidecache[what] = -1;
}
}
}