Skip to content

Commit

Permalink
be more aggressive in removing searches when the path they are for is…
Browse files Browse the repository at this point in the history
… deleted.
  • Loading branch information
marcushutchings committed Nov 25, 2023
1 parent 47548a2 commit 0966385
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
24 changes: 21 additions & 3 deletions rts/Sim/Path/QTPFS/PathManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ void QTPFS::PathManager::Load() {
while (threads-- > 0) {
searchThreadData.emplace_back(SearchThreadData(maxAllocedNodes, threads));
}

pmLoadScreen.Kill();
}

{
Expand All @@ -364,6 +362,7 @@ void QTPFS::PathManager::Load() {
snprintf(loadMsg, sizeof(loadMsg), fmtString, __func__, ThreadPool::GetNumThreads(), nodeLayers.size());

pmLoadScreen.AddMessage(loadMsg);
pmLoadScreen.Kill();
}
}

Expand Down Expand Up @@ -901,7 +900,8 @@ void QTPFS::PathManager::ExecuteQueuedSearches() {
}

// LOG("%s: delete search %x", __func__, entt::to_integral(pathSearchEntity));
registry.destroy(pathSearchEntity);
if (registry.valid(pathSearchEntity))
registry.destroy(pathSearchEntity);
}
}

Expand Down Expand Up @@ -1225,6 +1225,7 @@ void QTPFS::PathManager::DeletePath(unsigned int pathID, bool force) {
if (!registry.all_of<PathDelayedDelete>(pathEntity)) {
registry.emplace<PathDelayedDelete>(pathEntity, gs->frameNum + GAME_SPEED);
}
RemovePathSearch(pathEntity);
} else {
DeletePathEntity(pathEntity);
}
Expand All @@ -1237,6 +1238,8 @@ void QTPFS::PathManager::DeletePathEntity(entt::entity pathEntity) {
RemovePathFromPartialShared(pathEntity);

// if (registry.valid(pathEntity)) - check is already done.
RemovePathSearch(pathEntity);

registry.destroy(pathEntity);

if (pathTraceIt != pathTraces.end()) {
Expand Down Expand Up @@ -1278,14 +1281,29 @@ void QTPFS::PathManager::RemovePathFromPartialShared(entt::entity entity) {
auto& chain = registry.get<PartialSharedPathChain>(entity);
if (chain.next == entity) {
partialSharedPaths.erase(path->GetVirtualHash());
if (int(entity) == 0x7140010c)
LOG("%s: path %x partial deleted", __func__, int(entity));
} else {
partialSharedPaths[path->GetVirtualHash()] = chain.next;
if (int(entity) == 0x7140010c)
LOG("%s: path %x partial head is now %x", __func__, int(entity), int(chain.next));
if (int(chain.next) == 0x7140010c)
LOG("%s: path %x is now on partial head", __func__, int(chain.next));
}
}

linkedListHelper.RemoveChain<PartialSharedPathChain>(entity);
}

void QTPFS::PathManager::RemovePathSearch(entt::entity pathEntity) {
auto search = registry.try_get<PathSearchRef>(pathEntity);
if (search != nullptr) {
entt::entity searchId = search->value;
if (registry.valid(searchId))
registry.destroy(searchId);
}
}

unsigned int QTPFS::PathManager::RequestPath(
CSolidObject* object,
const MoveDef* moveDef,
Expand Down
1 change: 1 addition & 0 deletions rts/Sim/Path/QTPFS/PathManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ namespace QTPFS {
bool InitializeSearch(entt::entity searchEntity);
void RemovePathFromShared(entt::entity entity);
void RemovePathFromPartialShared(entt::entity entity);
void RemovePathSearch(entt::entity pathEntity);

void ReadyQueuedSearches();
void ExecuteQueuedSearches();
Expand Down

0 comments on commit 0966385

Please sign in to comment.