Skip to content

Commit 99d93ba

Browse files
committed
Fix crash nav generation with impossibly-large grid
1 parent 5bf71bd commit 99d93ba

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

regamedll/game_shared/bot/nav_area.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,13 @@ void GenerateNavigationAreaMesh()
17931793
break;
17941794
}
17951795

1796+
if (!TheNavAreaList.size())
1797+
{
1798+
// If we somehow have no areas, don't try to create an impossibly-large grid
1799+
TheNavAreaGrid.Initialize(0, 0, 0, 0);
1800+
return;
1801+
}
1802+
17961803
Extent extent;
17971804
extent.lo.x = 9999999999.9f;
17981805
extent.lo.y = 9999999999.9f;
@@ -4674,6 +4681,12 @@ void CNavAreaGrid::Initialize(float minX, float maxX, float minY, float maxY)
46744681
// Add an area to the grid
46754682
void CNavAreaGrid::AddNavArea(CNavArea *area)
46764683
{
4684+
if (!m_grid)
4685+
{
4686+
// If we somehow have no grid (manually creating a nav area without loading or generating a mesh), don't crash
4687+
TheNavAreaGrid.Initialize(0, 0, 0, 0);
4688+
}
4689+
46774690
// add to grid
46784691
const Extent *extent = area->GetExtent();
46794692

regamedll/game_shared/bot/nav_file.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,11 @@ NavErrorType LoadNavigationMap()
846846
unsigned int count;
847847
result = navFile.Read(&count, sizeof(unsigned int));
848848

849+
if (count == 0)
850+
{
851+
return NAV_INVALID_FILE;
852+
}
853+
849854
Extent extent;
850855
extent.lo.x = 9999999999.9f;
851856
extent.lo.y = 9999999999.9f;

0 commit comments

Comments
 (0)