Skip to content

Commit c8e8a5e

Browse files
committed
Add support for incursion distances in TF nav meshes without func_respawnroom
1 parent 64f764b commit c8e8a5e

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

src/game/server/tf/nav_mesh/tf_nav_mesh.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,45 @@ void CTFNavMesh::ComputeIncursionDistances( void )
14971497
}
14981498
}
14991499

1500+
#ifdef MAPBASE
1501+
if ( IFuncRespawnRoomAutoList::AutoList().Count() <= 0 )
1502+
{
1503+
// No respawn rooms, mark based on team spawn points instead
1504+
for ( int iTFTeamSpawn=0; iTFTeamSpawn<ITFTeamSpawnAutoList::AutoList().Count(); ++iTFTeamSpawn )
1505+
{
1506+
CTFTeamSpawn *spawnSpot = static_cast< CTFTeamSpawn* >( ITFTeamSpawnAutoList::AutoList()[iTFTeamSpawn] );
1507+
1508+
if ( spawnSpot->GetTeamNumber() == TF_TEAM_RED && isRedComputed )
1509+
continue;
1510+
1511+
if ( spawnSpot->GetTeamNumber() == TF_TEAM_BLUE && isBlueComputed )
1512+
continue;
1513+
1514+
if ( !spawnSpot->IsTriggered( NULL ) )
1515+
continue;
1516+
1517+
if ( spawnSpot->IsDisabled() )
1518+
continue;
1519+
1520+
// found a valid spawn spot, compute travel distances throughout the nav mesh
1521+
CTFNavArea *spawnArea = static_cast< CTFNavArea * >( TheTFNavMesh()->GetNearestNavArea( spawnSpot ) );
1522+
if ( spawnArea )
1523+
{
1524+
ComputeIncursionDistances( spawnArea, spawnSpot->GetTeamNumber() );
1525+
1526+
if ( spawnSpot->GetTeamNumber() == TF_TEAM_RED )
1527+
{
1528+
isRedComputed = true;
1529+
}
1530+
else
1531+
{
1532+
isBlueComputed = true;
1533+
}
1534+
}
1535+
}
1536+
}
1537+
#endif
1538+
15001539
if ( !isRedComputed )
15011540
{
15021541
Warning( "Can't compute incursion distances from the Red spawn room(s). Bots will perform poorly. This is caused by either a missing func_respawnroom, or missing info_player_teamspawn entities within the func_respawnroom.\n" );
@@ -1776,6 +1815,40 @@ void CTFNavMesh::DecorateMesh( void )
17761815
}
17771816
}
17781817
}
1818+
1819+
#ifdef MAPBASE
1820+
if ( IFuncRespawnRoomAutoList::AutoList().Count() <= 0 )
1821+
{
1822+
// No respawn rooms, mark based on team spawn points instead
1823+
for ( int iTFTeamSpawn=0; iTFTeamSpawn<ITFTeamSpawnAutoList::AutoList().Count(); ++iTFTeamSpawn )
1824+
{
1825+
CTFTeamSpawn *spawnSpot = static_cast< CTFTeamSpawn* >( ITFTeamSpawnAutoList::AutoList()[iTFTeamSpawn] );
1826+
1827+
if ( !spawnSpot->IsTriggered( NULL ) )
1828+
continue;
1829+
1830+
if ( spawnSpot->IsDisabled() )
1831+
continue;
1832+
1833+
CNavArea *area = GetNearestNavArea( spawnSpot, GETNAVAREA_CHECK_GROUND | GETNAVAREA_CHECK_LOS, 500.0f );
1834+
if ( area )
1835+
{
1836+
CTFNavArea *tfArea = static_cast<CTFNavArea *>(area);
1837+
1838+
if ( spawnSpot->GetTeamNumber() == TF_TEAM_RED )
1839+
{
1840+
tfArea->SetAttributeTF( TF_NAV_SPAWN_ROOM_RED );
1841+
m_redSpawnRoomAreaVector.AddToTail( tfArea );
1842+
}
1843+
else
1844+
{
1845+
tfArea->SetAttributeTF( TF_NAV_SPAWN_ROOM_BLUE );
1846+
m_blueSpawnRoomAreaVector.AddToTail( tfArea );
1847+
}
1848+
}
1849+
}
1850+
}
1851+
#endif
17791852

17801853
// mark each spawn room area adjacent to a non-spawn room area as an exit
17811854
m_redSpawnRoomExitAreaVector.RemoveAll();

0 commit comments

Comments
 (0)