Server: add traverse table count array for navmesh

Allows for quick lookups to check how many traverse tables a certain navmesh has.
This commit is contained in:
Kawe Mazidjatari 2024-07-06 18:43:12 +02:00
parent 1346a74933
commit b456825016

View File

@ -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