mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-26 10:00:42 +00:00
Merge pull request #377 from jlmjlm/prune_tab
Prune table of new land candidates.
This commit is contained in:
commit
7b3d2c2626
23
landlock.cpp
23
landlock.cpp
@ -675,15 +675,24 @@ EX eLand getNewLand(eLand old) {
|
||||
|
||||
if(ls::horodisk_structure() && tortoise::seek()) LIKELY tab[cnt++] = laTortoise;
|
||||
|
||||
int attempts = 0;
|
||||
eLand n = old;
|
||||
while(incompatible(n, old) || !isLandIngame(n)) {
|
||||
n = tab[hrand(cnt)];
|
||||
if(weirdhyperbolic && specialland == laCrossroads4 && isCrossroads(n))
|
||||
n = laCrossroads4;
|
||||
attempts++; if(attempts == 2000) break;
|
||||
int idx = 0;
|
||||
while (idx < cnt) {
|
||||
eLand n = tab[idx];
|
||||
if (incompatible(n, old) || !isLandIngame(n))
|
||||
tab[idx] = tab[--cnt];
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user