Check GridSize for 0

Fixes CID 68226 and CID 66437
master
worktycho 2014-06-26 19:04:56 +01:00
parent b832a202ab
commit 25a0264cc4
1 changed files with 10 additions and 0 deletions

View File

@ -53,6 +53,16 @@ cGridStructGen::cGridStructGen(
m_MaxStructureSizeZ(a_MaxStructureSizeZ),
m_MaxCacheSize(a_MaxCacheSize)
{
if (m_GridSizeX == 0)
{
LOG("Grid Size cannot be zero, setting to 1");
m_GridSizeX = 1;
}
if (m_GridSizeZ == 0)
{
LOG("Grid Size cannot be zero, setting to 1");
m_GridSizeZ = 1;
}
size_t NumStructuresPerQuery = (size_t)(((m_MaxStructureSizeX + m_MaxOffsetX) / m_GridSizeX + 1) * ((m_MaxStructureSizeZ + m_MaxOffsetZ) / m_GridSizeZ + 1));
if (NumStructuresPerQuery > m_MaxCacheSize)
{