From 3d0162038ae4f1b74bafb3260bea2799e0a43c17 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:38:07 +0200 Subject: [PATCH] Improved navmesh structs New member: header->offMeshEnds (this is used in Detour_LevelInit which sets fields to -1 starting at the pointer to end of offMeshCons array). Currently set to 0 so the paths in opcodes.cpp could be disabled. --- r5dev/common/opcodes.cpp | 2 +- r5dev/thirdparty/recast/Detour/Include/DetourNavMesh.h | 7 ++++--- .../recast/Detour/Source/DetourNavMeshBuilder.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp index 5cfd91c1..6ce6f8f5 100644 --- a/r5dev/common/opcodes.cpp +++ b/r5dev/common/opcodes.cpp @@ -366,7 +366,7 @@ void RuntimePtc_Init() /* .TEXT */ #if defined (GAMEDLL_S2) || defined (GAMEDLL_S3) p_CAI_NetworkManager__ShouldRebuild.Offset(0xA0).FindPatternSelf("FF ?? ?? ?? 00 00", CMemory::Direction::DOWN, 200).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to restart when building AIN (which clears the AIN memory). Remove this once writing to file works. - Detour_LevelInit.Offset(0x100).FindPatternSelf("74", CMemory::Direction::DOWN, 600).Patch({ 0xEB }); // JE --> JMP | Do while loop setting fields to -1 in navmesh is writing out of bounds (!TODO). + //Detour_LevelInit.Offset(0x100).FindPatternSelf("74", CMemory::Direction::DOWN, 600).Patch({ 0xEB }); // JE --> JMP | Do while loop setting fields to -1 in navmesh is writing out of bounds (!TODO). #endif #ifndef CLIENT_DLL Server_S2C_CONNECT_1.Offset(0x7).Patch({ 0xEB }); // JZ --> JMP | Prevent entitlement check to kick player from server on S2C_CONNECT Packet if it does not match the servers one. diff --git a/r5dev/thirdparty/recast/Detour/Include/DetourNavMesh.h b/r5dev/thirdparty/recast/Detour/Include/DetourNavMesh.h index 4b3a5b2f..0ae4d1e9 100644 --- a/r5dev/thirdparty/recast/Detour/Include/DetourNavMesh.h +++ b/r5dev/thirdparty/recast/Detour/Include/DetourNavMesh.h @@ -270,7 +270,7 @@ struct dtMeshHeader unsigned int userId; ///< The user defined id of the tile. int polyCount; ///< The number of polygons in the tile. - int sth_per_poly; + int polyCountMultiplier; int vertCount; ///< The number of vertices in the tile. int maxLinkCount; ///< The number of allocated links. @@ -283,11 +283,11 @@ struct dtMeshHeader int bvNodeCount; ///< The number of bounding volume nodes. (Zero if bounding volumes are disabled.) int offMeshConCount; ///< The number of off-mesh connections. int offMeshBase; ///< The index of the first polygon which is an off-mesh connection. + int offMeshEnds; float walkableHeight; ///< The height of the agents using the tile. float walkableRadius; ///< The radius of the agents using the tile. float walkableClimb; ///< The maximum climb height of the agents using the tile. - int unk1; float bmin[3]; ///< The minimum bounds of the tile's AABB. [(x, y, z)] float bmax[3]; ///< The maximum bounds of the tile's AABB. [(x, y, z)] @@ -304,7 +304,7 @@ struct dtMeshTile unsigned int linksFreeList; ///Index to the next free link. dtMeshHeader* header; ///The tile header. dtPoly* polys; ///The tile polygons. [Size: dtMeshHeader::polyCount] - void* polysEnd; ///The tile polygons array end pointer. + dtPoly* polysEnd; ///The tile polygons array end pointer. float* verts; ///The tile vertices. [Size: dtMeshHeader::vertCount] dtLink* links; ///The tile links. [Size: dtMeshHeader::maxLinkCount] dtPolyDetail* detailMeshes; ///The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount] @@ -322,6 +322,7 @@ struct dtMeshTile void* meshLink; ///< Seems shifted with 8 bytes from here (the rest seems to line up with r2) see field assignments in 'r5apex.exe 0x140F44A00' dtOffMeshConnection* offMeshCons; ///< The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount] + dtOffMeshConnection* offMeshConsEnd; ///< The tile off-mesh connections array end pointer. unsigned char* data; ///< The tile data. (Not directly accessed under normal situations.) diff --git a/r5dev/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp b/r5dev/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp index 26b8b806..cc20af25 100644 --- a/r5dev/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp +++ b/r5dev/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp @@ -491,13 +491,13 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData, header->detailTriCount = detailTriCount; header->bvQuantFactor = 1.0f / params->cs; header->offMeshBase = params->polyCount; + header->offMeshEnds = 0; header->walkableHeight = params->walkableHeight; header->walkableRadius = params->walkableRadius; header->walkableClimb = params->walkableClimb; header->offMeshConCount = storedOffMeshConCount; header->bvNodeCount = params->buildBvTree ? params->polyCount*2 : 0; - - header->sth_per_poly = sth_per_poly_thingy; + header->polyCountMultiplier = sth_per_poly_thingy; const int offMeshVertsBase = params->vertCount; const int offMeshPolyBase = params->polyCount;