mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-07-04 18:21:50 +00:00
Clean up code and move recreated functions to game.cpp.
This commit is contained in:
@ -672,6 +672,92 @@ namespace game
|
||||
}
|
||||
}
|
||||
|
||||
game::pathnode_t* Path_ConvertIndexToNode(int index)
|
||||
{
|
||||
return &(*game::gameWorldCurrent)->path.nodes[index];
|
||||
}
|
||||
|
||||
unsigned int __cdecl Path_ConvertNodeToIndex(const game::pathnode_t* node)
|
||||
{
|
||||
return node - (*game::gameWorldCurrent)->path.nodes;
|
||||
}
|
||||
|
||||
game::pathnode_t* Path_GetNegotiationNode(const game::path_t* pPath)
|
||||
{
|
||||
return Path_ConvertIndexToNode(pPath->pts[pPath->wNegotiationStartNode].iNodeNum);
|
||||
}
|
||||
|
||||
void Path_IncrementNodeUserCount(game::path_t* pPath)
|
||||
{
|
||||
game::pathnode_t* negotiationNode; // [esp+4h] [ebp-4h]
|
||||
|
||||
negotiationNode = Path_GetNegotiationNode(pPath);
|
||||
++negotiationNode->dynamic.userCount;
|
||||
}
|
||||
|
||||
void Path_DecrementNodeUserCount(game::path_t* pPath)
|
||||
{
|
||||
game::pathnode_t* negotiationNode; // [esp+4h] [ebp-4h]
|
||||
|
||||
negotiationNode = Path_GetNegotiationNode(pPath);
|
||||
--negotiationNode->dynamic.userCount;
|
||||
}
|
||||
|
||||
void Path_Clear(game::path_t* pPath)
|
||||
{
|
||||
if (pPath->wNegotiationStartNode > 0)
|
||||
{
|
||||
Path_DecrementNodeUserCount(pPath);
|
||||
pPath->wNegotiationStartNode = 0;
|
||||
}
|
||||
pPath->wPathLen = 0;
|
||||
pPath->wOrigPathLen = 0;
|
||||
}
|
||||
|
||||
float Vec2Length(const float* v)
|
||||
{
|
||||
return sqrt((*v * *v) + (v[1] * v[1]));
|
||||
}
|
||||
|
||||
float Path_GetPathDir(float* delta, const float* vFrom, const float* vTo)
|
||||
{
|
||||
float fDist; // [esp+18h] [ebp-4h]
|
||||
|
||||
delta[0] = *vTo - vFrom[0];
|
||||
delta[1] = vTo[1] - vFrom[1];
|
||||
fDist = Vec2Length(delta);
|
||||
delta[0] = (1.0 / fDist) * delta[0];
|
||||
delta[1] = (1.0 / fDist) * delta[1];
|
||||
return fDist;
|
||||
}
|
||||
|
||||
float Vec3DistanceSq(const float* p1, const float* p2)
|
||||
{
|
||||
float vDiffY; // [esp+4h] [ebp-8h]
|
||||
float vDiffZ; // [esp+8h] [ebp-4h]
|
||||
|
||||
vDiffY = p2[1] - p1[1];
|
||||
vDiffZ = p2[2] - p1[2];
|
||||
return vDiffZ * vDiffZ + vDiffY * vDiffY + (float)(*p2 - *p1) * (float)(*p2 - *p1);
|
||||
}
|
||||
|
||||
float EvaluateHeuristic(game::CustomSearchInfo_FindPath* searchInfo, game::pathnode_t* pSuccessor, const float* vGoalPos)
|
||||
{
|
||||
float v[2]; // [esp+18h] [ebp-Ch] BYREF
|
||||
float dist; // [esp+20h] [ebp-4h]
|
||||
|
||||
v[0] = *vGoalPos - pSuccessor->constant.vOrigin[0];
|
||||
v[1] = vGoalPos[1] - pSuccessor->constant.vOrigin[1];
|
||||
dist = Vec2Length(v);
|
||||
dist = (pSuccessor->dynamic.userCount * searchInfo->negotiationOverlapCost) + dist;
|
||||
if (pSuccessor->constant.minUseDistSq > 1.0
|
||||
&& pSuccessor->constant.minUseDistSq > Vec3DistanceSq(pSuccessor->constant.vOrigin, searchInfo->startPos))
|
||||
{
|
||||
dist = dist + searchInfo->negotiationOverlapCost;
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
|
||||
void Sentient_GetVelocity(sentient_s* self, float* vVelOut)
|
||||
{
|
||||
static const auto call_addr = SELECT(0x0, 0x5662A0);
|
||||
|
@ -74,6 +74,17 @@ namespace game
|
||||
void Path_UpdateLookahead(path_t* pPath, const float* vStartPos, int bReduceLookaheadAmount, int a4, int bAllowBacktrack);
|
||||
void Path_AddTrimmedAmount(const float* a1, path_t* a2);
|
||||
void Path_TransferLookahead(path_t* a1, const float* a2);
|
||||
pathnode_t* Path_ConvertIndexToNode(int index);
|
||||
unsigned int __cdecl Path_ConvertNodeToIndex(const game::pathnode_t* node);
|
||||
pathnode_t* Path_GetNegotiationNode(const path_t* pPath);
|
||||
void Path_IncrementNodeUserCount(path_t* pPath);
|
||||
void Path_DecrementNodeUserCount(path_t* pPath);
|
||||
void Path_Clear(path_t* pPath);
|
||||
float Vec2Length(const float* v);
|
||||
float Path_GetPathDir(float* delta, const float* vFrom, const float* vTo);
|
||||
float Vec3DistanceSq(const float* p1, const float* p2);
|
||||
float EvaluateHeuristic(CustomSearchInfo_FindPath* searchInfo, pathnode_t* pSuccessor, const float* vGoalPos);
|
||||
|
||||
void Sentient_GetVelocity(sentient_s* self, float* vVelOut);
|
||||
|
||||
template <typename T>
|
||||
|
Reference in New Issue
Block a user