Skip to content

Commit

Permalink
Fix issue where mitigrated bad path requests would only have half a p…
Browse files Browse the repository at this point in the history
…ath recorded.
  • Loading branch information
marcushutchings committed Oct 22, 2023
1 parent 8b1f3c9 commit 54ed4fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions rts/Sim/MoveTypes/GroundMoveType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3052,8 +3052,9 @@ void CGroundMoveType::UpdateOwnerPos(const float3& oldSpeedVector, const float3&
owner->SetVelocityAndSpeed(newSpeedVector);
owner->Move(owner->speed, true);

// The series of test done here will benefit from using the same cached results.
MoveDef* md = owner->moveDef;
int tempNum = gs->GetTempNum(); //
int tempNum = gs->GetTempNum();

auto isSquareOpen = [this, tempNum](float3 pos) {
// separate calls because terrain is only checked for in the centre square, while
Expand Down Expand Up @@ -3099,7 +3100,7 @@ void CGroundMoveType::UpdateOwnerPos(const float3& oldSpeedVector, const float3&
// Sometimes now collisions won't happen due to this code preventing that.
// so units need to be able to get themselves out of stuck situations. So adding
// a rerequest path check here.
// ReRequestPath(false);
ReRequestPath(false);
bool updatePos = false;

const int startingSquare = (owner->pos.z / SQUARE_SIZE)*mapDims.mapx + owner->pos.x / SQUARE_SIZE;
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Path/QTPFS/NodeLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ QTPFS::INode* QTPFS::NodeLayer::GetNearestNodeInArea

// The xmin (0), xmax (1), zmin (2), zmax (3) can be accessed by (index.)
// The these are the indicies needed to make the 4 corners of a quad.
const int2 cornerPoints[] =
constexpr int2 cornerPoints[] =
{ {0, 2}, {1, 2}
, {0, 3}, {1, 3}
};
Expand Down
13 changes: 10 additions & 3 deletions rts/Sim/Path/QTPFS/PathSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ bool QTPFS::PathSearch::Execute(unsigned int searchStateOffset) {
void QTPFS::PathSearch::InitStartingSearchNodes() {
fwdPathConnected = false;
bwdPathConnected = false;
fwdAreaSearchLimit = mapDims.mapx * mapDims.mapy;
fwdAreaSearchLimit = std::numeric_limits<int>::max();
searchThreadData->ResetQueue();

for (int i = 0; i < QTPFS::SEARCH_DIRS; ++i) {
Expand Down Expand Up @@ -487,8 +487,7 @@ bool QTPFS::PathSearch::ExecutePathSearch() {
}
}

havePartPath = (fwd.minSearchNode != fwd.srcSearchNode) | (badGoal & haveFullPath);
haveFullPath = (badGoal == true) ? false : haveFullPath;
havePartPath = (fwd.minSearchNode != fwd.srcSearchNode);

#ifdef QTPFS_SUPPORT_PARTIAL_SEARCHES
// adjust the target-point if we only got a partial result
Expand Down Expand Up @@ -749,6 +748,14 @@ void QTPFS::PathSearch::Finalize(IPath* path) {
}

path->SetBoundingBox();

// Bad path is a special path where we did a full path to the nearest good node instead of
// doing an exhaustive search to find a route to node we know cannot be found. This means
// we need to adjust the search results to reflect that - i.e. it shouldn't look like a fully
// successful path request.
havePartPath |= (badGoal & haveFullPath);
haveFullPath = (badGoal == true) ? false : haveFullPath;

path->SetHasFullPath(haveFullPath);
path->SetHasPartialPath(havePartPath);
}
Expand Down

0 comments on commit 54ed4fb

Please sign in to comment.