From 0eb0d73ae18e96e322ed9a27bc4ac58b9c40317c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:15:15 +0200 Subject: [PATCH] Game: make AI utility class instance static Static allocation instead of dynamic. --- src/engine/debugoverlay.cpp | 2 +- src/game/shared/ai_utility_shared.cpp | 12 ++++++------ src/game/shared/ai_utility_shared.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/debugoverlay.cpp b/src/engine/debugoverlay.cpp index 57f525f4..a7d8ee10 100644 --- a/src/engine/debugoverlay.cpp +++ b/src/engine/debugoverlay.cpp @@ -297,7 +297,7 @@ void DrawAllOverlays(bool bRender) #ifndef CLIENT_DLL if (bOverlayEnabled) { - g_pAIUtility->RunRenderFrame(); + g_AIUtility.RunRenderFrame(); } #endif // !CLIENT_DLL diff --git a/src/game/shared/ai_utility_shared.cpp b/src/game/shared/ai_utility_shared.cpp index cb0f171f..43f0ba90 100644 --- a/src/game/shared/ai_utility_shared.cpp +++ b/src/game/shared/ai_utility_shared.cpp @@ -82,15 +82,15 @@ void CAI_Utility::RunRenderFrame(void) const bool bUseDepthBuffer = r_debug_draw_depth_test.GetBool(); if (iScriptNodeIndex > -1) - g_pAIUtility->DrawAIScriptNetwork(*g_pAINetwork, vCamera, iScriptNodeIndex, flCameraRange, bUseDepthBuffer); + g_AIUtility.DrawAIScriptNetwork(*g_pAINetwork, vCamera, iScriptNodeIndex, flCameraRange, bUseDepthBuffer); if (iNavMeshBVTreeIndex > -1) - g_pAIUtility->DrawNavMeshBVTree(nullptr, vCamera, vCullPlane, iNavMeshBVTreeIndex, flCameraRange, nTileRange, bUseDepthBuffer); + g_AIUtility.DrawNavMeshBVTree(nullptr, vCamera, vCullPlane, iNavMeshBVTreeIndex, flCameraRange, nTileRange, bUseDepthBuffer); if (iNavMeshPortalIndex > -1) - g_pAIUtility->DrawNavMeshPortals(nullptr, vCamera, vCullPlane, iNavMeshPortalIndex, flCameraRange, nTileRange, bUseDepthBuffer); + g_AIUtility.DrawNavMeshPortals(nullptr, vCamera, vCullPlane, iNavMeshPortalIndex, flCameraRange, nTileRange, bUseDepthBuffer); if (iNavMeshPolyIndex > -1) - g_pAIUtility->DrawNavMeshPolys(nullptr, vCamera, vCullPlane, iNavMeshPolyIndex, flCameraRange, nTileRange, bUseDepthBuffer); + g_AIUtility.DrawNavMeshPolys(nullptr, vCamera, vCullPlane, iNavMeshPolyIndex, flCameraRange, nTileRange, bUseDepthBuffer); if (iNavMeshPolyBoundIndex > -1) - g_pAIUtility->DrawNavMeshPolyBoundaries(nullptr, vCamera, vCullPlane, iNavMeshPolyBoundIndex, flCameraRange, nTileRange, bUseDepthBuffer); + g_AIUtility.DrawNavMeshPolyBoundaries(nullptr, vCamera, vCullPlane, iNavMeshPolyBoundIndex, flCameraRange, nTileRange, bUseDepthBuffer); } //------------------------------------------------------------------------------ @@ -723,4 +723,4 @@ int CAI_Utility::GetNearestNodeToPos(const CAI_Network* pAINetwork, const Vector return result; } -CAI_Utility* g_pAIUtility = new (CAI_Utility); +CAI_Utility g_AIUtility; diff --git a/src/game/shared/ai_utility_shared.h b/src/game/shared/ai_utility_shared.h index d8e32b81..516bbd1a 100644 --- a/src/game/shared/ai_utility_shared.h +++ b/src/game/shared/ai_utility_shared.h @@ -66,5 +66,5 @@ private: Color m_LinkColor; }; -extern CAI_Utility* g_pAIUtility; +extern CAI_Utility g_AIUtility; #endif // AI_UTILITY_SHARED_H