Closed glebm closed 1 month ago
Do we care about keeping the exact drop pattern as vanilla here? I was thinking FindClosestValidPosition
would be close enough:
std::optional<Point> dropPoint = FindClosestValidPosition(ItemSpaceOk, playerTile, 1, 50);
if (dropPoint) {
RespawnDeadItem(std ::move(item), *dropPoint);
}
I'm not sure whether we care, so I went with an optimization that exactly preserves the current behaviour for now.
As long as we do not start dropping items on new tiles we don't care about the order here.
Consider this approved, I'm just not doing so in case you want to change it since that would cause it to auto merge :)
Opened https://github.com/diasurgical/devilutionX/pull/7318 instead
Previously, the same tiles were rechecked over and over again.
O(k^3) -> O(k^2)
While looking at this, I've noticed we have 3 different methods for checking where to drop an item, all slightly different:
DeadItem
: usesItemSpaceOk
.FindAdjacentPositionForItem
: usesCanPut
.GetSuperItemLoc
: usesFindClosestValidPosition
(which usesCrawl
) +ItemSpaceOk
.