1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 17:40:36 +00:00

some fixes to celldistance

This commit is contained in:
Zeno Rogue 2018-06-21 08:38:11 +02:00
parent 09c2a2096b
commit 742828125e

View File

@ -1362,7 +1362,7 @@ map<pair<cell*, cell*>, int> saved_distances;
int celldistance(cell *c1, cell *c2) { int celldistance(cell *c1, cell *c2) {
int d = 0; int d = 0;
if(euclid6) { if(euclid6 || (euclid4 && nonbitrunc)) {
if(!torus) if(!torus)
return eudist(decodeId(c1->master) - decodeId(c2->master)); return eudist(decodeId(c1->master) - decodeId(c2->master));
else if(torus && torusconfig::torus_mode == 0) else if(torus && torusconfig::torus_mode == 0)
@ -1387,11 +1387,13 @@ int celldistance(cell *c1, cell *c2) {
return 64; return 64;
} }
if(gp::on) { if(gp::on || euclid) {
if(saved_distances.count(make_pair(c1,c2))) if(saved_distances.count(make_pair(c1,c2)))
return saved_distances[make_pair(c1,c2)]; return saved_distances[make_pair(c1,c2)];
if(size(saved_distances) > 1000000) saved_distances.clear();
celllister cl(c1, 64, 1000, c2); celllister cl(c1, 64, 1000, c2);
for(int i=0; i<size(cl.lst); i++) for(int i=0; i<size(cl.lst); i++)