Server: use correct type for hull data used for AI Network

System uses a CVarBitVec for this hull block data.
This commit is contained in:
Kawe Mazidjatari 2024-04-16 16:47:58 +02:00
parent 9de5f4988f
commit 8ffb647686
4 changed files with 23 additions and 24 deletions

View File

@ -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];
}
//-----------------------------------------------------------------------------

View File

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

View File

@ -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();

View File

@ -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];
};