forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 167
Open
Description
The same unit can repeatedly call requestPath() for the same regular point while already waiting for the same path. This causes unnecessary duplicate requests to be sent to the pathfinder and create churn. Avoid repeated queueForPath() calls if the request not actually changes
File GeneralsGameCode\GeneralsMD\Code\GameEngine\Source\GameLogic\Object\Update\AIUpdate.cpp
/* Requests a path to be found. Note that if it is possible to do it without having to use the
pathfinder (air units just move point to point) it generates the path immediately. Otherwise the path
will be processed when we get to the front of the pathfind queue. jba */
//-------------------------------------------------------------------------------------------------
void AIUpdateInterface::requestPath( Coord3D *destination, Bool isFinalGoal )
{
if (m_locomotorSet.getValidSurfaces() == 0) {
DEBUG_CRASH(("Attempting to path immobile unit."));
}
// we are already waiting for same normal path request
// do not requeue pathfinding for identical destination
if (m_waitingForPath &&
m_requestedVictimID == INVALID_ID &&
!m_isAttackPath &&
!m_isApproachPath &&
!m_isSafePath &&
m_isFinalGoal == isFinalGoal)
{
Real dx = m_requestedDestination.x - destination->x;
Real dy = m_requestedDestination.y - destination->y;
Real dz = m_requestedDestination.z - destination->z;
Real distSqr = sqr(dx) + sqr(dy) + sqr(dz);
if (distSqr <= 1.0f) return;
}
not changing the rest because it's the same
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels