mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Be more robust to visibility checks outside the map. Fixes #765.
This was SVN commit r9333.
This commit is contained in:
parent
6da0027b32
commit
4e74798585
3 changed files with 36 additions and 6 deletions
|
|
@ -194,9 +194,9 @@ void CLOSTexture::GenerateBitmap(ICmpRangeManager::CLosQuerier los, u8* losData,
|
|||
// Fill in the visibility data
|
||||
for (size_t i = 0; i < w; ++i)
|
||||
{
|
||||
if (los.IsVisible(i, j))
|
||||
if (los.IsVisible_UncheckedRange(i, j))
|
||||
*dataPtr++ = 255;
|
||||
else if (los.IsExplored(i, j))
|
||||
else if (los.IsExplored_UncheckedRange(i, j))
|
||||
*dataPtr++ = 127;
|
||||
else
|
||||
*dataPtr++ = 0;
|
||||
|
|
|
|||
|
|
@ -1194,7 +1194,7 @@ public:
|
|||
if (!LosIsOffWorld(i, j))
|
||||
{
|
||||
overallVisibleVertices++;
|
||||
exploredVertices += (i32)los.IsExplored(i, j);
|
||||
exploredVertices += (i32)los.IsExplored_UncheckedRange(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,10 +185,40 @@ public:
|
|||
public:
|
||||
/**
|
||||
* Returns whether the given vertex is visible (i.e. is within a unit's LOS).
|
||||
* i and j must be in the range [0, verticesPerSide).
|
||||
*/
|
||||
inline bool IsVisible(ssize_t i, ssize_t j)
|
||||
{
|
||||
if (!(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide))
|
||||
return false;
|
||||
|
||||
// Check high bit of each bit-pair
|
||||
if ((m_Data[j*m_VerticesPerSide + i] & m_PlayerMask) & 0xAAAAAAAAu)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given vertex is explored (i.e. was (or still is) within a unit's LOS).
|
||||
*/
|
||||
inline bool IsExplored(ssize_t i, ssize_t j)
|
||||
{
|
||||
if (!(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide))
|
||||
return false;
|
||||
|
||||
// Check low bit of each bit-pair
|
||||
if ((m_Data[j*m_VerticesPerSide + i] & m_PlayerMask) & 0x55555555u)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given vertex is visible (i.e. is within a unit's LOS).
|
||||
* i and j must be in the range [0, verticesPerSide), else behaviour is undefined.
|
||||
*/
|
||||
inline bool IsVisible_UncheckedRange(ssize_t i, ssize_t j)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debug_assert(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide);
|
||||
#endif
|
||||
|
|
@ -201,9 +231,9 @@ public:
|
|||
|
||||
/**
|
||||
* Returns whether the given vertex is explored (i.e. was (or still is) within a unit's LOS).
|
||||
* i and j must be in the range [0, verticesPerSide).
|
||||
* i and j must be in the range [0, verticesPerSide), else behaviour is undefined.
|
||||
*/
|
||||
inline bool IsExplored(ssize_t i, ssize_t j)
|
||||
inline bool IsExplored_UncheckedRange(ssize_t i, ssize_t j)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
debug_assert(i >= 0 && j >= 0 && i < m_VerticesPerSide && j < m_VerticesPerSide);
|
||||
|
|
|
|||
Loading…
Reference in a new issue