AIN build and saving now fully works

AI is pretty much completed.
All that has to be done currently is making a simplified mesh of a map to cast a NavMesh on.
This commit is contained in:
Kawe Mazidjatari 2022-03-21 13:48:34 +01:00
parent b99f310198
commit a49a5bb781
4 changed files with 27 additions and 34 deletions

View File

@ -9,25 +9,24 @@
class CAI_Network
{
public:
void* m_pVTable;
void* m_pVTable; // <-- 'this'.
// this is uninitialised and never set on ain build, fun!
int m_iNumLinks; // +8
char unk1[124]; // +12
int m_iNumZones; // +136
char unk2[16]; // +140
int m_iNumLinks; // +0x0008
char unk1[0x7C]; // +0x000C
int m_iNumZones; // +0x0088
char unk2[0x10]; // +0x008C
// unk8 on disk
int unk5; // +156
char unk6[4]; // +160
int m_iNumHints; // +164
int unk5; // +0x009C
char unk6[0x4]; // +0x00A0
int m_iNumHints; // +0x00A4
// these probably aren't actually hints, but there's 1 of them per hint so idk
short m_Hints[2000]; // +168
int m_iNumScriptNodes; // +4168
char pad[28]; // unk
int64_t m_iNumNodes; // +4200
CAI_Node** m_pAInode; // +4208
short m_Hints[0x7D0]; // +0x00A8 <-- '2000' hints.
CAI_ScriptNode* m_ScriptNode; // +0x1048 <-- '[r5apex_ds.exe + 0xc6fd39]'.
int m_iNumScriptNodes; // +0x1050
CAI_ScriptNode m_ScriptNode[4000]; // +4172
};
char pad0[0x14]; // +0x1054 <-- !TODO
int64_t m_iNumNodes; // +0x1070
CAI_Node** m_pAInode; // +0x1078
};

View File

@ -17,7 +17,6 @@
const unsigned int PLACEHOLDER_CRC = 0;
const int AINET_SCRIPT_VERSION_NUMBER = 21;
const int AINET_VERSION_NUMBER = 57;
const int MAP_VERSION_TEMP = 30;
/*
==============================
@ -83,7 +82,7 @@ void CAI_NetworkBuilder::BuildFile(CAI_Network* pNetwork)
DevMsg(eDLL_T::SERVER, "Writing node '%d' from '%llx' to '%llx'\n", pNetwork->m_pAInode[i]->m_nIndex, reinterpret_cast<void*>(pNetwork->m_pAInode[i]), static_cast<size_t>(writeStream.tellp()));
writeStream.write(reinterpret_cast<char*>(&diskNode), sizeof(CAI_NodeDisk));
nCalculatedLinkcount += pNetwork->m_pAInode[i]->linkcount;
nCalculatedLinkcount += pNetwork->m_pAInode[i]->m_nNumLinks;
}
// links
@ -104,7 +103,7 @@ void CAI_NetworkBuilder::BuildFile(CAI_Network* pNetwork)
for (int i = 0; i < pNetwork->m_iNumNodes; i++)
{
for (int j = 0; j < pNetwork->m_pAInode[i]->linkcount; j++)
for (int j = 0; j < pNetwork->m_pAInode[i]->m_nNumLinks; j++)
{
// skip links that don't originate from current node
if (pNetwork->m_pAInode[i]->links[j]->m_iSrcID != pNetwork->m_pAInode[i]->m_nIndex)
@ -187,13 +186,13 @@ void CAI_NetworkBuilder::BuildFile(CAI_Network* pNetwork)
// Tf2-exclusive stuff past this point, i.e. ain v57 only.
DevMsg(eDLL_T::SERVER, "Writing '%d' script nodes at '%llx'\n", pNetwork->m_iNumScriptNodes, static_cast<size_t>(writeStream.tellp()));
//writeStream.write(reinterpret_cast<char*>(&pNetwork->scriptnodecount), sizeof(pNetwork->scriptnodecount));
//for (int i = 0; i < pNetwork->scriptnodecount; i++)
//{
// // disk and memory structs are literally identical here so just directly write
// DevMsg(eDLL_T::SERVER, "Writing script node '%d' at '%llx'\n", i, static_cast<size_t>(writeStream.tellp()));
// writeStream.write(reinterpret_cast<char*>(&pNetwork->scriptnodes[i]), sizeof(pNetwork->scriptnodes[i]));
//}
writeStream.write(reinterpret_cast<char*>(&pNetwork->m_iNumScriptNodes), sizeof(pNetwork->m_iNumScriptNodes));
for (int i = 0; i < pNetwork->m_iNumScriptNodes; i++)
{
// disk and memory structs are literally identical here so just directly write
DevMsg(eDLL_T::SERVER, "Writing script node '%d' at '%llx'\n", i, static_cast<size_t>(writeStream.tellp()));
writeStream.write(reinterpret_cast<char*>(&pNetwork->m_ScriptNode[i]), sizeof(pNetwork->m_ScriptNode[i]));
}
DevMsg(eDLL_T::SERVER, "Writing '%d' hints at '%llx'\n", pNetwork->m_iNumHints, static_cast<size_t>(writeStream.tellp()));
writeStream.write(reinterpret_cast<char*>(&pNetwork->m_iNumHints), sizeof(pNetwork->m_iNumHints));

View File

@ -55,7 +55,7 @@ struct CAI_Node
CAI_NodeLink** links;
char unk5[16];
int linkcount;
int m_nNumLinks;
int unk11; // Bad name lmao
short unk6; // Should match up to unk4 on disk
char unk7[16]; // Padding until next bit
@ -117,9 +117,6 @@ struct AINodeClusters
char unk5;
};
//int* pUnkStruct0Count;
//UnkNodeStruct0*** pppUnkNodeStruct0s;
struct AINodeClusterLinks
{
short unk0;
@ -129,6 +126,3 @@ struct AINodeClusterLinks
char unk4;
char unk5;
};
//int* pUnkLinkStruct1Count;
//UnkLinkStruct1*** pppUnkStruct1s;

View File

@ -169,6 +169,7 @@ namespace VSquirrel
{
int iServerIndex = hsq_getinteger(sqvm, 1);
// !TODO: Create glue class instead.
g_pIBrowser->ConnectToServer(g_pIBrowser->m_vServerList[iServerIndex].svIpAddress, g_pIBrowser->m_vServerList[iServerIndex].svPort, g_pIBrowser->m_vServerList[iServerIndex].svEncryptionKey);
return SQ_OK;