1
1
forked from 0ad/0ad
Follows from d0fc8ff67d, 95dbb8be25.
The original diff asserted that only "real" entities would make range
queries. This proved inaccurate as building previews can too. However,
simply removing the assertion doesn't fix the issue, given that they
still aren't found and we still need to account for their size.

This fixes that properly by special-casing local entities.

Thanks s0600204 for giving this a look.

Reported by: Mr.lie
Differential Revision: https://code.wildfiregames.com/D3132
This was SVN commit r24231.
This commit is contained in:
wraitii 2020-11-22 09:29:45 +00:00
parent 7c04ea0211
commit b3c5347e26

View File

@ -1378,11 +1378,23 @@ public:
if (q.source.GetId() != INVALID_ENTITY && q.maxRange != entity_pos_t::FromInt(-1))
{
EntityMap<EntityData>::const_iterator it = m_EntityData.find(q.source.GetId());
u32 size = 0;
if (ENTITY_IS_LOCAL(q.source.GetId()))
{
CmpPtr<ICmpObstruction> cmpObstruction(GetSimContext(), q.source.GetId());
if (cmpObstruction)
size = cmpObstruction->GetSize().ToInt_RoundToInfinity();
}
else
{
EntityMap<EntityData>::const_iterator it = m_EntityData.find(q.source.GetId());
if (it != m_EntityData.end())
size = it->second.size;
}
// Adjust the range query based on the querier's obstruction radius.
// The smallest side of the obstruction isn't known here, so we can't safely adjust the min-range, only the max.
// 'size' is the diagonal size rounded up so this will cover all possible rotations of the querier.
q.maxRange += fixed::FromInt(it->second.size);
q.maxRange += fixed::FromInt(size);
}
q.ownersMask = 0;