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.
This commit is contained in:
Kawe Mazidjatari 2022-07-18 21:38:07 +02:00
parent 9f27b58f95
commit 3d0162038a
3 changed files with 7 additions and 6 deletions

View File

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

View File

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

View File

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