The bug is that there is no validity check for when the unit wants to walk to pick up an item, which can cause an endless-loop.
So instead of:
// if we're not standing on it, we should try to get to it.
action->target = targetItem->getTile()->getPosition();
action->type = BA_WALK;
walkToItem = true;
if (pickUpWeaponsMoreActively)
{
// don't end the turn after walking 1-2 tiles... pick up a weapon and shoot!
action->finalAction = false;
action->desperate = false;
action->actor->setHiding(false);
}
it should be something like:
// if we're not standing on it, we should try to get to it.
_save->getPathfinding()->calculate(action->actor, targetItem->getTile()->getPosition(), BAM_NORMAL);
if (_save->getPathfinding()->getStartDirection() != -1 && _save->getPathfinding()->getTotalTUCost() <= action->actor->getTimeUnits())
{
action->target = targetItem->getTile()->getPosition();
action->type = BA_WALK;
walkToItem = true;
if (pickUpWeaponsMoreActively)
{
// don't end the turn after walking 1-2 tiles... pick up a weapon and shoot!
action->finalAction = false;
action->desperate = false;
action->actor->setHiding(false);
}
}