1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-13 19:00:35 +00:00

Merge pull request #377 from jlmjlm/prune_tab

Prune table of new land candidates.
This commit is contained in:
Zeno Rogue 2024-05-16 22:04:51 +02:00 committed by GitHub
commit 7b3d2c2626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -675,15 +675,24 @@ EX eLand getNewLand(eLand old) {
if(ls::horodisk_structure() && tortoise::seek()) LIKELY tab[cnt++] = laTortoise; if(ls::horodisk_structure() && tortoise::seek()) LIKELY tab[cnt++] = laTortoise;
int attempts = 0; int idx = 0;
eLand n = old; while (idx < cnt) {
while(incompatible(n, old) || !isLandIngame(n)) { eLand n = tab[idx];
n = tab[hrand(cnt)]; if (incompatible(n, old) || !isLandIngame(n))
if(weirdhyperbolic && specialland == laCrossroads4 && isCrossroads(n)) tab[idx] = tab[--cnt];
n = laCrossroads4; else
attempts++; if(attempts == 2000) break; idx++;
} }
if (!cnt) {
addMessage("No eligible land candidates!");
return old;
}
eLand n = tab[hrand(cnt)];
if (weirdhyperbolic && specialland == laCrossroads4 && isCrossroads(n))
n = laCrossroads4;
return n; return n;
} }