mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Get rid of disk structures
Less maintenance work; write the fields out directly from memory structures.
This commit is contained in:
parent
7e3f812a97
commit
3d0d8c7081
r5dev/game/server
@ -147,28 +147,28 @@ void CAI_NetworkBuilder::SaveNetworkGraph(CAI_Network* pNetwork)
|
||||
{
|
||||
const CAI_Node* aiNode = pNetwork->m_pAInode[i];
|
||||
|
||||
// Construct on-disk node struct.
|
||||
CAI_NodeDisk diskNode;
|
||||
DevMsg(eDLL_T::SERVER, " |-- Copying node '#%d' from '0x%p' to '0x%zX'\n", aiNode->m_nIndex, aiNode, FileSystem()->Tell(pAIGraph));
|
||||
|
||||
diskNode.m_vOrigin = aiNode->m_vOrigin;
|
||||
diskNode.m_flYaw = aiNode->m_flYaw;
|
||||
FileSystem()->Write(&aiNode->m_vOrigin, sizeof(Vector3D), pAIGraph);
|
||||
FileSystem()->Write(&aiNode->m_flYaw, sizeof(float), pAIGraph);
|
||||
FileSystem()->Write(&aiNode->m_fHulls, sizeof(aiNode->m_fHulls), pAIGraph);
|
||||
|
||||
diskNode.unk0 = static_cast<char>(aiNode->unk0);
|
||||
diskNode.unk1 = aiNode->unk1;
|
||||
FileSystem()->Write(&aiNode->unk0, sizeof(char), pAIGraph);
|
||||
FileSystem()->Write(&aiNode->unk1, sizeof(int), pAIGraph);
|
||||
|
||||
for (int j = 0; j < MAX_HULLS; j++)
|
||||
{
|
||||
diskNode.unk2[j] = static_cast<short>(aiNode->unk2[j]);
|
||||
diskNode.unk3[j] = aiNode->unk3[j];
|
||||
diskNode.hulls[j] = aiNode->m_fHulls[j];
|
||||
FileSystem()->Write(&aiNode->unk2[j], sizeof(short), pAIGraph);
|
||||
}
|
||||
|
||||
diskNode.unk4 = aiNode->unk6;
|
||||
diskNode.unk5 = -1; // aiNetwork->nodes[i]->unk8; // This field is wrong, however it's always -1 in original navmeshes anyway.
|
||||
memcpy(diskNode.unk6, aiNode->unk10, sizeof(diskNode.unk6));
|
||||
FileSystem()->Write(&aiNode->unk3, sizeof(aiNode->unk3), pAIGraph);
|
||||
FileSystem()->Write(&aiNode->unk6, sizeof(short), pAIGraph);
|
||||
|
||||
DevMsg(eDLL_T::SERVER, " |-- Copying node '#%d' from '0x%p' to '0x%zX'\n", aiNode->m_nIndex, aiNode, FileSystem()->Tell(pAIGraph));
|
||||
FileSystem()->Write(&diskNode, sizeof(CAI_NodeDisk), pAIGraph);
|
||||
// aiNetwork->nodes[i]->unk8; // This field is wrong, however it's always -1 in original navmeshes anyway.
|
||||
short unk8 = -1;
|
||||
|
||||
FileSystem()->Write(&unk8/*aiNode->unk8*/, sizeof(short), pAIGraph);
|
||||
FileSystem()->Write(&aiNode->unk10, sizeof(aiNode->unk10), pAIGraph);
|
||||
|
||||
totalLinkCount += aiNode->m_nNumLinks;
|
||||
}
|
||||
@ -208,19 +208,12 @@ void CAI_NetworkBuilder::SaveNetworkGraph(CAI_Network* pNetwork)
|
||||
continue;
|
||||
}
|
||||
|
||||
CAI_NodeLinkDisk diskLink;
|
||||
DevMsg(eDLL_T::SERVER, " |-- Writing link '%hd' => '%hd' to '0x%zX'\n", nodeLink->m_iSrcID, nodeLink->m_iDestID, FileSystem()->Tell(pAIGraph));
|
||||
|
||||
diskLink.m_iSrcID = nodeLink->m_iSrcID;
|
||||
diskLink.m_iDestID = nodeLink->m_iDestID;
|
||||
diskLink.unk0 = nodeLink->unk1;
|
||||
|
||||
for (int k = 0; k < MAX_HULLS; k++)
|
||||
{
|
||||
diskLink.m_bHulls[k] = nodeLink->m_bHulls[k];
|
||||
}
|
||||
|
||||
DevMsg(eDLL_T::SERVER, " |-- Writing link '%hd' => '%hd' to '0x%zX'\n", diskLink.m_iSrcID, diskLink.m_iDestID, FileSystem()->Tell(pAIGraph));
|
||||
FileSystem()->Write(&diskLink, sizeof(CAI_NodeLinkDisk), pAIGraph);
|
||||
FileSystem()->Write(&nodeLink->m_iSrcID, sizeof(short), pAIGraph);
|
||||
FileSystem()->Write(&nodeLink->m_iDestID, sizeof(short), pAIGraph);
|
||||
FileSystem()->Write(&nodeLink->unk1, sizeof(char), pAIGraph);
|
||||
FileSystem()->Write(&nodeLink->m_bHulls, sizeof(nodeLink->m_bHulls), pAIGraph);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class VAI_NetworkManager : public IDetour
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
LogFunAdr("CAI_NetworkManager::LoadNetworkGraph", p_CAI_NetworkManager__LoadNetworkGraph.GetPtr());
|
||||
LogFunAdr("CAI_NetworkManager::ShouldRebuild", p_CAI_NetworkManager__ShouldRebuild.GetPtr());
|
||||
LogFunAdr("CAI_NetworkManager::DelayedInit", p_CAI_NetworkManager__ShouldRebuild.GetPtr());
|
||||
LogFunAdr("CAI_NetworkBuilder::Build", p_CAI_NetworkBuilder__Build.GetPtr());
|
||||
LogVarAdr("g_AIPathClusters< CAI_Cluster* >", reinterpret_cast<uintptr_t>(g_pAIPathClusters));
|
||||
LogVarAdr("g_AIClusterLinks< CAI_ClusterLink* >", reinterpret_cast<uintptr_t>(g_pAIClusterLinks));
|
||||
|
@ -10,7 +10,6 @@ constexpr int MAX_HULLS = 5;
|
||||
constexpr int NOT_CACHED = -2; // Returned if data not in cache
|
||||
constexpr int NO_NODE = -1; // Returned when no node meets the qualification
|
||||
|
||||
#pragma pack(push, 1)
|
||||
//=============================================================================
|
||||
// >> CAI_NodeLink
|
||||
//=============================================================================
|
||||
@ -25,17 +24,6 @@ struct CAI_NodeLink
|
||||
int64_t m_nFlags;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// >> CAI_NodeLinkDisk
|
||||
//=============================================================================
|
||||
struct CAI_NodeLinkDisk
|
||||
{
|
||||
short m_iSrcID;
|
||||
short m_iDestID;
|
||||
char unk0;
|
||||
bool m_bHulls[MAX_HULLS];
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// >> CAI_Node
|
||||
//=============================================================================
|
||||
@ -66,35 +54,18 @@ struct CAI_Node
|
||||
char unk10[8]; // Should match up to unk6 on disk
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// >> CAI_NodeDisk
|
||||
//=============================================================================
|
||||
struct CAI_NodeDisk // The way CAI_Nodes are represented in on-disk ain files
|
||||
{
|
||||
Vector3D m_vOrigin;
|
||||
|
||||
float m_flYaw;
|
||||
float hulls[MAX_HULLS];
|
||||
|
||||
char unk0;
|
||||
int unk1;
|
||||
short unk2[MAX_HULLS];
|
||||
char unk3[MAX_HULLS];
|
||||
short unk4;
|
||||
short unk5;
|
||||
char unk6[8];
|
||||
};
|
||||
static_assert(sizeof(CAI_NodeDisk) == 68);
|
||||
|
||||
//=============================================================================
|
||||
// >> CAI_ScriptNode
|
||||
//=============================================================================
|
||||
struct CAI_ScriptNode
|
||||
{
|
||||
Vector3D m_vOrigin;
|
||||
uint64_t scriptdata;
|
||||
|
||||
// Might be wrong; seems to be used for clamping.
|
||||
// See [r5apex_ds + 0xF28A6E]
|
||||
int m_nMin;
|
||||
int m_nMax;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//=============================================================================
|
||||
// >> CAI_Cluster
|
||||
@ -114,7 +85,7 @@ struct CAI_Cluster
|
||||
CUtlVector<int> unkVec1;
|
||||
|
||||
// This is an array of floats that is indexed
|
||||
// into by teamNum at [r5apex_ds.exe + EC84DC];
|
||||
// into by teamNum at [r5apex_ds + EC84DC];
|
||||
// Seems to be used along with the cvar:
|
||||
// 'ai_path_dangerous_cluster_min_time'.
|
||||
float clusterTime[MAX_TEAMS];
|
||||
|
Loading…
x
Reference in New Issue
Block a user