From 102c0bd1a6ba017b295717c8a12e8c09e7de9641 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Thu, 22 Jan 2026 22:18:41 -0700 Subject: [PATCH 1/3] Reduce team allocation for path reservation Also rename ConVar enabling the path reservation system to be more generic --- src/game/server/neo/bot/neo_bot_path_cost.cpp | 8 ++++---- .../server/neo/bot/neo_bot_path_reservation.cpp | 16 ++++++++-------- .../server/neo/bot/neo_bot_path_reservation.h | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/game/server/neo/bot/neo_bot_path_cost.cpp b/src/game/server/neo/bot/neo_bot_path_cost.cpp index 89f8e173c..a053c4086 100644 --- a/src/game/server/neo/bot/neo_bot_path_cost.cpp +++ b/src/game/server/neo/bot/neo_bot_path_cost.cpp @@ -6,8 +6,8 @@ #include "nav_mesh.h" #include "neo_bot_path_reservation.h" -ConVar neo_bot_path_friendly_reservation_enable("neo_bot_path_friendly_reservation_enable", "1", FCVAR_NONE, - "Enable friendly bot path dispersal", true, 0, false, 1); +ConVar neo_bot_path_reservation_enable("neo_bot_path_reservation_enable", "1", FCVAR_NONE, + "Enable bot path reservation system", true, 0, false, 1); ConVar neo_bot_path_around_friendly_cooldown("neo_bot_path_around_friendly_cooldown", "2.0", FCVAR_CHEAT, "How often to check for friendly path dispersion", false, 0, false, 60); @@ -23,7 +23,7 @@ CNEOBotPathCost::CNEOBotPathCost(CNEOBot* me, RouteType routeType) m_stepHeight = me->GetLocomotionInterface()->GetStepHeight(); m_maxJumpHeight = me->GetLocomotionInterface()->GetMaxJumpHeight(); m_maxDropHeight = me->GetLocomotionInterface()->GetDeathDropHeight(); - m_bIgnoreReservations = !neo_bot_path_friendly_reservation_enable.GetBool(); + m_bIgnoreReservations = !neo_bot_path_reservation_enable.GetBool(); } //------------------------------------------------------------------------------------------------- @@ -112,7 +112,7 @@ float CNEOBotPathCost::operator()(CNavArea* baseArea, CNavArea* fromArea, const // ------------------------------------------------------------------------------------------------ // New path reservation related cost adjustments - if ( neo_bot_path_friendly_reservation_enable.GetBool() + if ( neo_bot_path_reservation_enable.GetBool() && !m_bIgnoreReservations && (m_routeType != FASTEST_ROUTE) ) { diff --git a/src/game/server/neo/bot/neo_bot_path_reservation.cpp b/src/game/server/neo/bot/neo_bot_path_reservation.cpp index a6b229067..89813dc79 100644 --- a/src/game/server/neo/bot/neo_bot_path_reservation.cpp +++ b/src/game/server/neo/bot/neo_bot_path_reservation.cpp @@ -37,7 +37,7 @@ void CNEOBotPathReservationSystem::ReserveArea(CNavArea *area, CNEOBot *bot, flo } int team = bot->GetTeamNumber(); - if (team < 0 || team >= MAX_TEAMS) + if (team < 0 || team >= TEAM__TOTAL) { return; } @@ -92,7 +92,7 @@ void CNEOBotPathReservationSystem::ReleaseArea(CNavArea *area, CNEOBot *bot) } int team = bot->GetTeamNumber(); - if (team < 0 || team >= MAX_TEAMS) + if (team < 0 || team >= TEAM__TOTAL) { return; } @@ -138,7 +138,7 @@ void CNEOBotPathReservationSystem::ReleaseAllAreas(CNEOBot *bot) } int team = bot->GetTeamNumber(); - if (team < 0 || team >= MAX_TEAMS) + if (team < 0 || team >= TEAM__TOTAL) { return; } @@ -190,7 +190,7 @@ bool CNEOBotPathReservationSystem::IsAreaReservedByTeammate(CNavArea *area, CNEO } int team = avoider->GetTeamNumber(); - if (team < 0 || team >= MAX_TEAMS) + if (team < 0 || team >= TEAM__TOTAL) { return false; } @@ -226,7 +226,7 @@ bool CNEOBotPathReservationSystem::IsAreaReservedByTeammate(CNavArea *area, CNEO */ void CNEOBotPathReservationSystem::Clear() { - for (int team = 0; team < MAX_TEAMS; ++team) + for (int team = 0; team < TEAM__TOTAL; ++team) { m_Reservations[team].RemoveAll(); m_AreaPathCounts[team].RemoveAll(); @@ -238,7 +238,7 @@ void CNEOBotPathReservationSystem::Clear() //------------------------------------------------------------------------------------------------- void CNEOBotPathReservationSystem::IncrementPredictedFriendlyPathCount( int areaID, int teamID ) { - if (teamID < 0 || teamID >= MAX_TEAMS) + if (teamID < 0 || teamID >= TEAM__TOTAL) { return; } @@ -257,7 +257,7 @@ void CNEOBotPathReservationSystem::IncrementPredictedFriendlyPathCount( int area //------------------------------------------------------------------------------------------------- void CNEOBotPathReservationSystem::DecrementPredictedFriendlyPathCount( int areaID, int teamID ) { - if (teamID < 0 || teamID >= MAX_TEAMS) + if (teamID < 0 || teamID >= TEAM__TOTAL) { return; } @@ -276,7 +276,7 @@ void CNEOBotPathReservationSystem::DecrementPredictedFriendlyPathCount( int area //------------------------------------------------------------------------------------------------- int CNEOBotPathReservationSystem::GetPredictedFriendlyPathCount( int areaID, int teamID ) const { - if (teamID < 0 || teamID >= MAX_TEAMS) + if (teamID < 0 || teamID >= TEAM__TOTAL) { return 0; } diff --git a/src/game/server/neo/bot/neo_bot_path_reservation.h b/src/game/server/neo/bot/neo_bot_path_reservation.h index c24c32a79..fd2c73974 100644 --- a/src/game/server/neo/bot/neo_bot_path_reservation.h +++ b/src/game/server/neo/bot/neo_bot_path_reservation.h @@ -44,7 +44,7 @@ class CNEOBotPathReservationSystem CNEOBotPathReservationSystem() : m_BotReservedAreas(EHandleLessFunc), m_AreaOnStuckPenalties(DefLessFunc(unsigned int)) { - for (int i = 0; i < MAX_TEAMS; ++i) + for (int i = 0; i < TEAM__TOTAL; ++i) { m_Reservations[i].SetLessFunc(ReservationLessFunc); m_AreaPathCounts[i].SetLessFunc(ReservationLessFunc); @@ -68,9 +68,9 @@ class CNEOBotPathReservationSystem friend CNEOBotPathReservationSystem* CNEOBotPathReservations(); private: - CUtlMap m_Reservations[MAX_TEAMS]; + CUtlMap m_Reservations[TEAM__TOTAL]; CUtlMap m_BotReservedAreas; - CUtlMap m_AreaPathCounts[MAX_TEAMS]; + CUtlMap m_AreaPathCounts[TEAM__TOTAL]; CUtlMap m_AreaOnStuckPenalties; }; From 39daff17422c6ff6ccda5c772fef2642115ca0e7 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 24 Jan 2026 12:46:24 -0700 Subject: [PATCH 2/3] Clean up ConVar usage --- .../server/neo/bot/neo_bot_path_compute.cpp | 4 +-- src/game/server/neo/bot/neo_bot_path_cost.cpp | 7 ++-- .../neo/bot/neo_bot_path_reservation.cpp | 35 ++++++++++++++----- .../server/neo/bot/neo_bot_path_reservation.h | 2 +- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/game/server/neo/bot/neo_bot_path_compute.cpp b/src/game/server/neo/bot/neo_bot_path_compute.cpp index 3d0fb3606..7fb9f287a 100644 --- a/src/game/server/neo/bot/neo_bot_path_compute.cpp +++ b/src/game/server/neo/bot/neo_bot_path_compute.cpp @@ -8,14 +8,14 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -extern ConVar neo_bot_path_reservation_enabled; +extern ConVar neo_bot_path_reservation_enable; extern ConVar neo_bot_path_reservation_penalty; extern ConVar neo_bot_path_reservation_duration; extern ConVar neo_bot_path_reservation_distance; static void CNEOBotReservePath(CNEOBot* me, PathFollower& path) { - if (!neo_bot_path_reservation_enabled.GetBool() || !path.IsValid()) + if (!neo_bot_path_reservation_enable.GetBool() || !path.IsValid()) { return; } diff --git a/src/game/server/neo/bot/neo_bot_path_cost.cpp b/src/game/server/neo/bot/neo_bot_path_cost.cpp index a053c4086..5816fc26c 100644 --- a/src/game/server/neo/bot/neo_bot_path_cost.cpp +++ b/src/game/server/neo/bot/neo_bot_path_cost.cpp @@ -6,8 +6,7 @@ #include "nav_mesh.h" #include "neo_bot_path_reservation.h" -ConVar neo_bot_path_reservation_enable("neo_bot_path_reservation_enable", "1", FCVAR_NONE, - "Enable bot path reservation system", true, 0, false, 1); +extern ConVar neo_bot_path_reservation_enable; ConVar neo_bot_path_around_friendly_cooldown("neo_bot_path_around_friendly_cooldown", "2.0", FCVAR_CHEAT, "How often to check for friendly path dispersion", false, 0, false, 60); @@ -112,9 +111,7 @@ float CNEOBotPathCost::operator()(CNavArea* baseArea, CNavArea* fromArea, const // ------------------------------------------------------------------------------------------------ // New path reservation related cost adjustments - if ( neo_bot_path_reservation_enable.GetBool() - && !m_bIgnoreReservations - && (m_routeType != FASTEST_ROUTE) ) + if ( !m_bIgnoreReservations && (m_routeType != FASTEST_ROUTE) ) { cost += CNEOBotPathReservations()->GetPredictedFriendlyPathCount(area->GetID(), m_me->GetTeamNumber()) * neo_bot_path_reservation_penalty.GetFloat(); cost += CNEOBotPathReservations()->GetAreaStuckPenalty(area->GetID()); diff --git a/src/game/server/neo/bot/neo_bot_path_reservation.cpp b/src/game/server/neo/bot/neo_bot_path_reservation.cpp index 89813dc79..632687556 100644 --- a/src/game/server/neo/bot/neo_bot_path_reservation.cpp +++ b/src/game/server/neo/bot/neo_bot_path_reservation.cpp @@ -7,12 +7,28 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -ConVar neo_bot_path_reservation_enabled("neo_bot_path_reservation_enabled", "1", FCVAR_NONE, "Enable the bot path reservation system."); -ConVar neo_bot_path_reservation_penalty("neo_bot_path_reservation_penalty", "100", FCVAR_NONE, "Pathing cost penalty for a reserved area."); -ConVar neo_bot_path_reservation_duration("neo_bot_path_reservation_duration", "30.0", FCVAR_NONE, "How long a path reservation lasts, in seconds."); -ConVar neo_bot_path_reservation_distance("neo_bot_path_reservation_distance", "10000", FCVAR_NONE, "How far along the path to reserve, in Hammer units."); -ConVar neo_bot_path_reservation_onstuck_penalty_enabled("neo_bot_path_reservation_onstuck_penalty_enabled", "1", FCVAR_NONE, "Whether to update or retrieve the area onstuck penalty."); -ConVar neo_bot_path_reservation_onstuck_penalty("neo_bot_path_reservation_onstuck_penalty", "10000", FCVAR_NONE, "Path selection penalty added to a nav area each time a bot gets stuck moving through that area."); + +ConVar neo_bot_path_reservation_enable("neo_bot_path_reservation_enable", "1", FCVAR_NONE, + "Enable the bot path reservation system.", true, 0, true, 1); + +ConVar neo_bot_path_reservation_duration("neo_bot_path_reservation_duration", "30.0", FCVAR_NONE, + "How long a path reservation lasts, in seconds.", 1, true, 1000000, true); + +ConVar neo_bot_path_reservation_distance("neo_bot_path_reservation_distance", "10000", FCVAR_NONE, + "How far along the path to reserve, in Hammer units.", 0, true, 1000000, true); + +ConVar neo_bot_path_reservation_penalty("neo_bot_path_reservation_penalty", "100", FCVAR_NONE, + "Pathing cost penalty for a reserved area.", true, 0, 1000000, true); + +ConVar neo_bot_path_reservation_friendly_penalty_enable("neo_bot_path_reservation_friendly_penalty_enable", "1", FCVAR_NONE, + "Whether to update or retrieve the area friendly reservation penalty.", true, 0, true, 1); + +ConVar neo_bot_path_reservation_onstuck_penalty_enable("neo_bot_path_reservation_onstuck_penalty_enable", "1", FCVAR_NONE, + "Whether to update or retrieve the area onstuck penalty.", true, 0, true, 1); + +ConVar neo_bot_path_reservation_onstuck_penalty("neo_bot_path_reservation_onstuck_penalty", "10000", FCVAR_NONE, + "Path selection penalty added to a nav area each time a bot gets stuck moving through that area.", true, 0, 1000000, true); + CNEOBotPathReservationSystem* CNEOBotPathReservations() @@ -276,7 +292,8 @@ void CNEOBotPathReservationSystem::DecrementPredictedFriendlyPathCount( int area //------------------------------------------------------------------------------------------------- int CNEOBotPathReservationSystem::GetPredictedFriendlyPathCount( int areaID, int teamID ) const { - if (teamID < 0 || teamID >= TEAM__TOTAL) + if (!neo_bot_path_reservation_friendly_penalty_enable.GetBool() + || teamID < 0 || teamID >= TEAM__TOTAL) { return 0; } @@ -293,7 +310,7 @@ int CNEOBotPathReservationSystem::GetPredictedFriendlyPathCount( int areaID, int //------------------------------------------------------------------------------------------------- void CNEOBotPathReservationSystem::IncrementAreaStuckPenalty(unsigned int navAreaID) { - if ( !neo_bot_path_reservation_onstuck_penalty_enabled.GetBool() ) + if ( !neo_bot_path_reservation_onstuck_penalty_enable.GetBool() ) { return; } @@ -310,7 +327,7 @@ void CNEOBotPathReservationSystem::IncrementAreaStuckPenalty(unsigned int navAre //------------------------------------------------------------------------------------------------- float CNEOBotPathReservationSystem::GetAreaStuckPenalty(unsigned int navAreaID) const { - if ( !neo_bot_path_reservation_onstuck_penalty_enabled.GetBool() ) + if ( !neo_bot_path_reservation_onstuck_penalty_enable.GetBool() ) { return 0.0f; } diff --git a/src/game/server/neo/bot/neo_bot_path_reservation.h b/src/game/server/neo/bot/neo_bot_path_reservation.h index fd2c73974..44e90ae5e 100644 --- a/src/game/server/neo/bot/neo_bot_path_reservation.h +++ b/src/game/server/neo/bot/neo_bot_path_reservation.h @@ -77,7 +77,7 @@ class CNEOBotPathReservationSystem CNEOBotPathReservationSystem* CNEOBotPathReservations(); -extern ConVar neo_bot_path_reservation_enabled; +extern ConVar neo_bot_path_reservation_enable; extern ConVar neo_bot_path_reservation_penalty; extern ConVar neo_bot_path_reservation_duration; extern ConVar neo_bot_path_reservation_distance; From 69b3b2dfcbe41e1e7a9db5ab2a62e912f6df6e44 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Tue, 27 Jan 2026 21:31:00 -0700 Subject: [PATCH 3/3] What was I thinking and why didn't the compiler catch this --- src/game/server/neo/bot/neo_bot_path_reservation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/server/neo/bot/neo_bot_path_reservation.cpp b/src/game/server/neo/bot/neo_bot_path_reservation.cpp index 632687556..d1a4086c9 100644 --- a/src/game/server/neo/bot/neo_bot_path_reservation.cpp +++ b/src/game/server/neo/bot/neo_bot_path_reservation.cpp @@ -12,13 +12,13 @@ ConVar neo_bot_path_reservation_enable("neo_bot_path_reservation_enable", "1", F "Enable the bot path reservation system.", true, 0, true, 1); ConVar neo_bot_path_reservation_duration("neo_bot_path_reservation_duration", "30.0", FCVAR_NONE, - "How long a path reservation lasts, in seconds.", 1, true, 1000000, true); + "How long a path reservation lasts, in seconds.", true, 1, true, 1000000); ConVar neo_bot_path_reservation_distance("neo_bot_path_reservation_distance", "10000", FCVAR_NONE, - "How far along the path to reserve, in Hammer units.", 0, true, 1000000, true); + "How far along the path to reserve, in Hammer units.", true, 0, true, 1000000); ConVar neo_bot_path_reservation_penalty("neo_bot_path_reservation_penalty", "100", FCVAR_NONE, - "Pathing cost penalty for a reserved area.", true, 0, 1000000, true); + "Pathing cost penalty for a reserved area.", true, 0, true, 1000000); ConVar neo_bot_path_reservation_friendly_penalty_enable("neo_bot_path_reservation_friendly_penalty_enable", "1", FCVAR_NONE, "Whether to update or retrieve the area friendly reservation penalty.", true, 0, true, 1); @@ -27,7 +27,7 @@ ConVar neo_bot_path_reservation_onstuck_penalty_enable("neo_bot_path_reservation "Whether to update or retrieve the area onstuck penalty.", true, 0, true, 1); ConVar neo_bot_path_reservation_onstuck_penalty("neo_bot_path_reservation_onstuck_penalty", "10000", FCVAR_NONE, - "Path selection penalty added to a nav area each time a bot gets stuck moving through that area.", true, 0, 1000000, true); + "Path selection penalty added to a nav area each time a bot gets stuck moving through that area.", true, 0, true, 1000000);