From b4568250167006f3792eae28aa5407a9f62edb0e Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 6 Jul 2024 18:43:12 +0200 Subject: [PATCH] Server: add traverse table count array for navmesh Allows for quick lookups to check how many traverse tables a certain navmesh has. --- src/public/game/server/ai_navmesh.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/public/game/server/ai_navmesh.h b/src/public/game/server/ai_navmesh.h index 3abd6391..b3753200 100644 --- a/src/public/game/server/ai_navmesh.h +++ b/src/public/game/server/ai_navmesh.h @@ -30,11 +30,26 @@ inline const char* const g_navMeshNames[NAVMESH_COUNT] = { inline const char* NavMesh_GetNameForType(const NavMeshType_e navMeshType) { - Assert(navMeshType >= 0 && navMeshType < NAVMESH_COUNT); + Assert(navMeshType >= 0 && navMeshType < V_ARRAYSIZE(g_navMeshNames)); return g_navMeshNames[navMeshType]; } -inline const int g_traverseAnimTypeSetTableIndices[ANIMTYPE_COUNT] = { +inline const int g_navMeshTraverseTableCountIndicesPerType[NAVMESH_COUNT] = { + // NAVMESH_SMALL supports the first 5 enumerants in TraverseAnimType_e + 5, + + // All other navmeshes support one each, counting from after the last one + // supported by NAVMESH_SMALL + 1, 1, 1, 1 +}; + +inline int NavMesh_GetTraversalTableCountForNavMeshType(const NavMeshType_e navMeshType) +{ + Assert(navMeshType >= 0 && navMeshType < V_ARRAYSIZE(g_navMeshTraverseTableCountIndicesPerType)); + return g_navMeshTraverseTableCountIndicesPerType[navMeshType]; +} + +inline const int g_navMeshTraverseTableIndicesPerType[ANIMTYPE_COUNT] = { // NAVMESH_SMALL has 5 traversal tables, so each traverse anim type indexes // into its own. 0, 0, 0, 0, 0, @@ -46,8 +61,8 @@ inline const int g_traverseAnimTypeSetTableIndices[ANIMTYPE_COUNT] = { inline int NavMesh_GetTraversalTableIndexForAnimType(const TraverseAnimType_e animType) { - Assert(animType >= 0 && animType < V_ARRAYSIZE(g_traverseAnimTypeSetTableIndices)); - return animType + g_traverseAnimTypeSetTableIndices[animType]; + Assert(animType >= 0 && animType < V_ARRAYSIZE(g_navMeshTraverseTableIndicesPerType)); + return animType + g_navMeshTraverseTableIndicesPerType[animType]; } #endif // AI_NAVMESH_H