From 8ffb647686770a2a030b6228c7b85d37375c0cb9 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:47:58 +0200 Subject: [PATCH] Server: use correct type for hull data used for AI Network System uses a CVarBitVec for this hull block data. --- r5dev/game/server/ai_network.cpp | 6 ++++-- r5dev/game/server/ai_network.h | 9 ++------- r5dev/game/server/ai_networkmanager.cpp | 19 +++++++++---------- r5dev/game/server/ai_node.h | 13 ++++++++----- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/r5dev/game/server/ai_network.cpp b/r5dev/game/server/ai_network.cpp index 3604cbd5..2e5591b5 100644 --- a/r5dev/game/server/ai_network.cpp +++ b/r5dev/game/server/ai_network.cpp @@ -63,11 +63,13 @@ int CAI_Network::NumLinks(void) const //----------------------------------------------------------------------------- // Purpose: gets the number of zones +// input : idx - // Output : int //----------------------------------------------------------------------------- -int CAI_Network::NumZones(void) const +int CAI_Network::NumZones(const int idx) const { - return m_iNumZones; + Assert(idx >= 0 && idx < sizeof(m_iNumZones)); + return m_iNumZones[idx]; } //----------------------------------------------------------------------------- diff --git a/r5dev/game/server/ai_network.h b/r5dev/game/server/ai_network.h index ee71feb4..0d81cbfb 100644 --- a/r5dev/game/server/ai_network.h +++ b/r5dev/game/server/ai_network.h @@ -12,7 +12,7 @@ public: static void DebugConnectMsg(int node1, int node2, const char* pszFormat, ...); void* GetVTable(void) const; int NumLinks(void) const; - int NumZones(void) const; + int NumZones(const int idx) const; int NumHints(void) const; int NumScriptNodes(void) const; int NumPathNodes(void) const; @@ -32,12 +32,7 @@ public: int m_nUnk0; CAI_HullData m_HullData[MAX_HULLS]; - - int m_iNumZones; // +0x0088 - int m_iUnkCount0; - int m_iUnkCount1; - int m_iUnkCount2; - int m_iUnkCount4; + int m_iNumZones[MAX_HULLS]; // +0x0088 // unk8 on disk int unk5; // +0x009C diff --git a/r5dev/game/server/ai_networkmanager.cpp b/r5dev/game/server/ai_networkmanager.cpp index 4b8f6abc..f8d8c015 100644 --- a/r5dev/game/server/ai_networkmanager.cpp +++ b/r5dev/game/server/ai_networkmanager.cpp @@ -225,19 +225,18 @@ void CAI_NetworkBuilder::SaveNetworkGraph(CAI_Network* pNetwork) // Dump the hull data blocks // ------------------------------- - // Pointer to numZones counter, incremented up and until - // the last counter field for the hull data block. - int* countPtr = &pNetwork->m_iNumZones; - - for (int i = 0; i < MAX_HULLS; i++, countPtr++) + for (int i = 0; i < MAX_HULLS; i++) { const CAI_HullData& hullData = pNetwork->m_HullData[i]; - const int bufferSize = sizeof(int) * hullData.unk1; + const int numHullZones = pNetwork->m_iNumZones[i]; - buf.PutInt(*countPtr); - buf.PutShort(hullData.m_Count); - buf.PutShort(hullData.unk1); - buf.Put(hullData.pBuffer, bufferSize); + const unsigned short numHullBits = (unsigned short)hullData.m_bitVec.GetNumBits(); + const unsigned short numHullInts = (unsigned short)hullData.m_bitVec.GetNumDWords(); + + buf.PutInt(numHullZones); + buf.PutUnsignedShort(numHullBits); + buf.PutUnsignedShort(numHullInts); + buf.Put(hullData.m_bitVec.Base(), numHullInts * sizeof(int)); } timer.End(); diff --git a/r5dev/game/server/ai_node.h b/r5dev/game/server/ai_node.h index 96a455ea..a315375d 100644 --- a/r5dev/game/server/ai_node.h +++ b/r5dev/game/server/ai_node.h @@ -5,6 +5,7 @@ //=============================================================================// #pragma once #include "mathlib/vector.h" +#include "mathlib/bitvec.h" constexpr int MAX_HULLS = 5; constexpr int NOT_CACHED = -2; // Returned if data not in cache @@ -153,13 +154,15 @@ struct CAI_ScriptNode }; //============================================================================= -// >> CAI_ScriptNode +// >> CAI_HullData //============================================================================= struct CAI_HullData { - short m_Count; // Multiplied by 4; probably total buffer size. - short unk1; - int unk2; - void* pBuffer; // Hull data buffer. + CVarBitVec m_bitVec; + + // Unknown, possible part of CVarBitVec ??? see [r5apex_ds + 1A52B0] if, + // this is part of CVarBitVec, it seems to be unused in any of the + // compiled CVarBitVec and CLargeVarBitVec methods so i think it should be + // just part of this struct. char unk3[8]; };