From 7a1f0c18d4cffe37d8bbaefaffba6ce0623e81a6 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Sat, 7 Jan 2023 01:40:41 +0300 Subject: [PATCH] Handle xrAI version 9 correctly AI nodes from version 9 are the same as nodes from version 8 Thanks for the builds versions: https://github.com/abramcumner/xray_re-tools/blob/master/sources/xray_re/xr_ai_version.h --- src/Common/LevelStructure.hpp | 13 ++++--- src/xrAICore/Navigation/level_graph_manager.h | 35 +++++++++++-------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Common/LevelStructure.hpp b/src/Common/LevelStructure.hpp index a5aee32d279..90ae8c6f6e0 100644 --- a/src/Common/LevelStructure.hpp +++ b/src/Common/LevelStructure.hpp @@ -288,12 +288,17 @@ const u32 MAX_NODE_BIT_COUNT = 23; enum xrAI_Versions : u8 { - XRAI_VERSION_SOC = 8, - XRAI_VERSION_CS = 9, - XRAI_VERSION_COP = 10, + // Release SOC: builds 2945, 2947 and further + XRAI_VERSION_SOC = 8, + + // PRIQUEL: early CS builds on SOC engine, e.g. build 3120 + XRAI_VERSION_PRIQUEL = 9, + + // Release CS/COP: build 3456 and further + XRAI_VERSION_CS_COP = 10, XRAI_VERSION_ALLOWED = XRAI_VERSION_SOC, - XRAI_VERSION_OPENXRAY = XRAI_VERSION_COP, + XRAI_VERSION_OPENXRAY = XRAI_VERSION_CS_COP, XRAI_CURRENT_VERSION = XRAI_VERSION_OPENXRAY }; diff --git a/src/xrAICore/Navigation/level_graph_manager.h b/src/xrAICore/Navigation/level_graph_manager.h index abc4f18b6ba..065626d1ca5 100644 --- a/src/xrAICore/Navigation/level_graph_manager.h +++ b/src/xrAICore/Navigation/level_graph_manager.h @@ -11,13 +11,18 @@ class CLevelGraphManager size_t m_vertex_count; public: - CLevelGraphManager(IReader* stream, size_t vertex_count, u32 version) : m_vertex_count(vertex_count) + CLevelGraphManager(IReader* stream, size_t vertex_count, xrAI_Versions version) : m_vertex_count(vertex_count) { - if (version == XRAI_VERSION_COP || version == XRAI_VERSION_CS) + switch (version) { + case XRAI_CURRENT_VERSION: + static_assert(XRAI_CURRENT_VERSION == XRAI_VERSION_CS_COP, + "If you have changed the xrAI version, don't forget to add back compatibility with CS/COP xrAI version."); m_nodes = static_cast(stream->pointer()); - } - else if (version == XRAI_VERSION_SOC) + break; + + case XRAI_VERSION_PRIQUEL: + case XRAI_VERSION_SOC: { m_compatibility_mode = true; m_nodes = new CLevelVertex[vertex_count + 1]; // additional one, so we don't trigger access violation @@ -30,27 +35,29 @@ class CLevelGraphManager newNode = oldNode; } - // Mark end node as END NODE SOC + // Mark end node // so we can spot that in debugger, if we need NodeCompressed& endNode = m_nodes[vertex_count + 1]; - endNode.data[0] = 'E'; - endNode.data[1] = 'N'; - endNode.data[2] = 'D'; + endNode.data[0] = 'A'; + endNode.data[1] = 'I'; + endNode.data[2] = version; endNode.data[3] = ' '; endNode.data[4] = 'N'; endNode.data[5] = 'O'; endNode.data[6] = 'D'; endNode.data[7] = 'E'; endNode.data[8] = ' '; - endNode.data[9] = 'S'; - endNode.data[10] = 'O'; - endNode.data[11] = 'C'; + endNode.data[9] = 'E'; + endNode.data[10] = 'N'; + endNode.data[11] = 'D'; static_assert(sizeof(endNode.data) == 12, "If you have changed the NodeCompressed structure, please update the code above."); + break; } - else - { + + default: FATAL("Unsupported level graph version."); - } + NODEFAULT; + } // switch (version) } ~CLevelGraphManager()