Use crawl table based search for item checks

fixes #3207
This commit is contained in:
ephphatha 2021-10-28 19:11:39 +11:00 committed by Anders Jenbo
commit 335b0b9349
2 changed files with 7 additions and 24 deletions

View file

@ -3229,19 +3229,9 @@ int AllocateItem()
Point GetSuperItemLoc(Point position)
{
for (int k = 1; k < 50; k++) {
for (int j = -k; j <= k; j++) {
for (int i = -k; i <= k; i++) {
Displacement offset = { i, j };
Point positionToCheck = position + offset;
if (ItemSpaceOk(positionToCheck)) {
return positionToCheck;
}
}
}
}
std::optional<Point> itemPosition = FindClosestValidPosition(ItemSpaceOk, position, 1, 50);
return { 0, 0 }; // TODO handle no space for dropping items
return itemPosition.value_or(Point { 0, 0 }); // TODO handle no space for dropping items
}
void GetItemAttrs(Item &item, int itemData, int lvl)