Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修正各Chunk资源互相包含 #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 101 additions & 102 deletions HotPatcher/Source/HotPatcherRuntime/Private/FlibPatchParserHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,108 +930,107 @@ FChunkAssetDescribe UFlibPatchParserHelper::CollectFChunkAssetsDescribeByChunk(
SCOPED_NAMED_EVENT_TEXT("CollectFChunkAssetsDescribeByChunk",FColor::Red);
FChunkAssetDescribe ChunkAssetDescribe;
// Collect Chunk Assets
// {
//
// FAssetDependenciesInfo SpecifyDependAssets;
//
// FAssetDependenciesParser Parser;
// FAssetDependencies Conf;
// TArray<FString> AssetFilterPaths = UFlibAssetManageHelper::DirectoriesToStrings(Chunk.AssetIncludeFilters);
// Conf.IncludeFilters = AssetFilterPaths;
// Conf.IgnoreFilters = UFlibAssetManageHelper::DirectoriesToStrings(Chunk.AssetIgnoreFilters);
// Conf.ForceSkipPackageNames = UFlibAssetManageHelper::SoftObjectPathsToStrings(Chunk.ForceSkipAssets);
// Conf.InIncludeSpecifyAsset = Chunk.IncludeSpecifyAssets;
// Conf.AssetRegistryDependencyTypes = Chunk.AssetRegistryDependencyTypes;
// Conf.AnalysicFilterDependencies = Chunk.bAnalysisFilterDependencies;
// Conf.ForceSkipContents = UFlibAssetManageHelper::DirectoriesToStrings(Chunk.ForceSkipContentRules);
// Conf.ForceSkipContents.Append(UFlibAssetManageHelper::DirectoriesToStrings(PatcheSettings->GetAssetScanConfig().ForceSkipContentRules));
//
// auto AddForceSkipAssets = [&Conf](const TArray<FSoftObjectPath>& Assets)
// {
// for(const auto& forceSkipAsset:Assets)
// {
// Conf.ForceSkipContents.Add(forceSkipAsset.GetLongPackageName());
// }
// };
// AddForceSkipAssets(Chunk.ForceSkipAssets);
// AddForceSkipAssets(PatcheSettings->GetAssetScanConfig().ForceSkipAssets);
//
// auto AddSkipClassesLambda = [&Conf](const TArray<UClass*>& Classes)
// {
// for(const auto& ForceSkipClass:Classes)
// {
// Conf.IgnoreAseetTypes.Add(*ForceSkipClass->GetName());
// }
// };
// AddSkipClassesLambda(Chunk.ForceSkipClasses);
// AddSkipClassesLambda(PatcheSettings->GetAssetScanConfig().ForceSkipClasses);
//
// Parser.Parse(Conf);
// TSet<FName> AssetLongPackageNames = Parser.GetrParseResults();
//
// for(FName LongPackageName:AssetLongPackageNames)
// {
// if(LongPackageName.IsNone())
// {
// continue;
// }
// AssetFilterPaths.AddUnique(LongPackageName.ToString());
// }
//
// const FAssetDependenciesInfo& AddAssetsRef = DiffInfo.AssetDiffInfo.AddAssetDependInfo;
// const FAssetDependenciesInfo& ModifyAssetsRef = DiffInfo.AssetDiffInfo.ModifyAssetDependInfo;
//
//
// auto CollectChunkAssets = [](const FAssetDependenciesInfo& SearchBase, const TArray<FString>& SearchFilters)->FAssetDependenciesInfo
// {
// SCOPED_NAMED_EVENT_TEXT("CollectChunkAssets",FColor::Red);
// FAssetDependenciesInfo ResultAssetDependInfos;
//
// for (const auto& SearchItem : SearchFilters)
// {
// if (SearchItem.IsEmpty())
// continue;
//
// FString SearchModuleName;
// int32 findedPos = SearchItem.Find(TEXT("/"), ESearchCase::IgnoreCase, ESearchDir::FromStart, 1);
// if (findedPos != INDEX_NONE)
// {
// SearchModuleName = UKismetStringLibrary::GetSubstring(SearchItem, 1, findedPos - 1);
// }
// else
// {
// SearchModuleName = UKismetStringLibrary::GetSubstring(SearchItem, 1, SearchItem.Len() - 1);
// }
//
// if (!SearchModuleName.IsEmpty() && (SearchBase.AssetsDependenciesMap.Contains(SearchModuleName)))
// {
// if (!ResultAssetDependInfos.AssetsDependenciesMap.Contains(SearchModuleName))
// ResultAssetDependInfos.AssetsDependenciesMap.Add(SearchModuleName, FAssetDependenciesDetail(SearchModuleName, TMap<FString, FAssetDetail>{}));
//
// const FAssetDependenciesDetail& SearchBaseModule = *SearchBase.AssetsDependenciesMap.Find(SearchModuleName);
//
// TArray<FString> AllAssetKeys;
// SearchBaseModule.AssetDependencyDetails.GetKeys(AllAssetKeys);
//
// for (const auto& KeyItem : AllAssetKeys)
// {
// if (KeyItem.StartsWith(SearchItem))
// {
// FAssetDetail FindedAsset = *SearchBaseModule.AssetDependencyDetails.Find(KeyItem);
// if (!ResultAssetDependInfos.AssetsDependenciesMap.Find(SearchModuleName)->AssetDependencyDetails.Contains(KeyItem))
// {
// ResultAssetDependInfos.AssetsDependenciesMap.Find(SearchModuleName)->AssetDependencyDetails.Add(KeyItem, FindedAsset);
// }
// }
// }
// }
// }
// return ResultAssetDependInfos;
// };
//}
{
ChunkAssetDescribe.AddAssets = DiffInfo.AssetDiffInfo.AddAssetDependInfo; // CollectChunkAssets(AddAssetsRef, AssetFilterPaths);
ChunkAssetDescribe.ModifyAssets = DiffInfo.AssetDiffInfo.ModifyAssetDependInfo; //CollectChunkAssets(ModifyAssetsRef, AssetFilterPaths);
{

FAssetDependenciesInfo SpecifyDependAssets;

FAssetDependenciesParser Parser;
FAssetDependencies Conf;
TArray<FString> AssetFilterPaths = UFlibAssetManageHelper::DirectoriesToStrings(Chunk.AssetIncludeFilters);
Conf.IncludeFilters = AssetFilterPaths;
Conf.IgnoreFilters = UFlibAssetManageHelper::DirectoriesToStrings(Chunk.AssetIgnoreFilters);
Conf.ForceSkipPackageNames = UFlibAssetManageHelper::SoftObjectPathsToStrings(Chunk.ForceSkipAssets);
Conf.InIncludeSpecifyAsset = Chunk.IncludeSpecifyAssets;
Conf.AssetRegistryDependencyTypes = Chunk.AssetRegistryDependencyTypes;
Conf.AnalysicFilterDependencies = Chunk.bAnalysisFilterDependencies;
Conf.ForceSkipContents = UFlibAssetManageHelper::DirectoriesToStrings(Chunk.ForceSkipContentRules);
Conf.ForceSkipContents.Append(UFlibAssetManageHelper::DirectoriesToStrings(PatcheSettings->GetAssetScanConfig().ForceSkipContentRules));

auto AddForceSkipAssets = [&Conf](const TArray<FSoftObjectPath>& Assets)
{
for(const auto& forceSkipAsset:Assets)
{
Conf.ForceSkipContents.Add(forceSkipAsset.GetLongPackageName());
}
};
AddForceSkipAssets(Chunk.ForceSkipAssets);
AddForceSkipAssets(PatcheSettings->GetAssetScanConfig().ForceSkipAssets);

auto AddSkipClassesLambda = [&Conf](const TArray<UClass*>& Classes)
{
for(const auto& ForceSkipClass:Classes)
{
Conf.IgnoreAseetTypes.Add(*ForceSkipClass->GetName());
}
};
AddSkipClassesLambda(Chunk.ForceSkipClasses);
AddSkipClassesLambda(PatcheSettings->GetAssetScanConfig().ForceSkipClasses);

Parser.Parse(Conf);
TSet<FName> AssetLongPackageNames = Parser.GetrParseResults();

for(FName LongPackageName:AssetLongPackageNames)
{
if(LongPackageName.IsNone())
{
continue;
}
AssetFilterPaths.AddUnique(LongPackageName.ToString());
}

const FAssetDependenciesInfo& AddAssetsRef = DiffInfo.AssetDiffInfo.AddAssetDependInfo;
const FAssetDependenciesInfo& ModifyAssetsRef = DiffInfo.AssetDiffInfo.ModifyAssetDependInfo;


auto CollectChunkAssets = [](const FAssetDependenciesInfo& SearchBase, const TArray<FString>& SearchFilters)->FAssetDependenciesInfo
{
SCOPED_NAMED_EVENT_TEXT("CollectChunkAssets",FColor::Red);
FAssetDependenciesInfo ResultAssetDependInfos;

for (const auto& SearchItem : SearchFilters)
{
if (SearchItem.IsEmpty())
continue;

FString SearchModuleName;
int32 findedPos = SearchItem.Find(TEXT("/"), ESearchCase::IgnoreCase, ESearchDir::FromStart, 1);
if (findedPos != INDEX_NONE)
{
SearchModuleName = UKismetStringLibrary::GetSubstring(SearchItem, 1, findedPos - 1);
}
else
{
SearchModuleName = UKismetStringLibrary::GetSubstring(SearchItem, 1, SearchItem.Len() - 1);
}

if (!SearchModuleName.IsEmpty() && (SearchBase.AssetsDependenciesMap.Contains(SearchModuleName)))
{
if (!ResultAssetDependInfos.AssetsDependenciesMap.Contains(SearchModuleName))
ResultAssetDependInfos.AssetsDependenciesMap.Add(SearchModuleName, FAssetDependenciesDetail(SearchModuleName, TMap<FString, FAssetDetail>{}));

const FAssetDependenciesDetail& SearchBaseModule = *SearchBase.AssetsDependenciesMap.Find(SearchModuleName);

TArray<FString> AllAssetKeys;
SearchBaseModule.AssetDependencyDetails.GetKeys(AllAssetKeys);

for (const auto& KeyItem : AllAssetKeys)
{
if (KeyItem.StartsWith(SearchItem))
{
FAssetDetail FindedAsset = *SearchBaseModule.AssetDependencyDetails.Find(KeyItem);
if (!ResultAssetDependInfos.AssetsDependenciesMap.Find(SearchModuleName)->AssetDependencyDetails.Contains(KeyItem))
{
ResultAssetDependInfos.AssetsDependenciesMap.Find(SearchModuleName)->AssetDependencyDetails.Add(KeyItem, FindedAsset);
}
}
}
}
}
return ResultAssetDependInfos;
};

ChunkAssetDescribe.AddAssets = CollectChunkAssets(AddAssetsRef, AssetFilterPaths);
ChunkAssetDescribe.ModifyAssets = CollectChunkAssets(ModifyAssetsRef, AssetFilterPaths);
ChunkAssetDescribe.Assets = UFlibAssetManageHelper::CombineAssetDependencies(ChunkAssetDescribe.AddAssets, ChunkAssetDescribe.ModifyAssets);
}

Expand Down