Skip to content

Conversation

@drcxd
Copy link

@drcxd drcxd commented Aug 14, 2025

There is an offset stored in AssetRegistryData, the AssetRegistryDependencyDataOffset. It is not correctly updated if any table precedes it has expanded or shrunk. See ReadPackageDataMain and WritePackageData in Unreal Engine code for more detail about this offset. This patch may not work for all cases, since it does not replicate the computation of the offset. It is based on the assumption that the difference between AssetRegistryDataOffset and AssetRegistryDependencyDataOffset usually does not change.

drcxd added 5 commits August 14, 2025 17:36
There is an offset stored in AssetRegistryData, the AssetRegistryDependencyDataOffset. It is not correctly updated if any table precedes it has expanded or shrunk. See ReadPackageDataMain and WritePackageData in Unreal Engine code for more detail about this offset. This patch may not work for all cases, since it does not replicate the computation of the offset. It is based on the assumption that the difference between AssetRegistryDataOffset and AssetRegistryDependencyDataOffset usually does not change.
@atenfyr
Copy link
Owner

atenfyr commented Oct 2, 2025

looks good at a glance, will merge if you can do me a favor and double check that all tests still pass with your changes

@drcxd
Copy link
Author

drcxd commented Oct 9, 2025

Hello, I have updated the condition for reading/writing asset registry dependency data to fix some tests, but there is still some problems.

The failing test is TestJsonOnFile("Map_FrontEnd_Hotel_LS_Night.umap", EngineVersion.VER_UE4_27);. It seems that it does not contain asset registry dependency data, for reading the AssetRegistryDependencyDataOffset yields some meaningless value: 446676598784. However, the asset satisfies the condition for an asset to contain asset registry dependency data, i.e. version >= VER_UE4_ASSETREGISTRY_DEPENDENCYFLAGS. I found that SetEngineVersion converts EngineVersion.VER_UE4_27 to VER_UE4_AUTOMATIC_VERSION.

To fix this problem, we have to either change the condition for determining if the asset contains asset registry dependency data or change the version mapping. I can't see how to do either properly, can you give some advice? The current condition is based on the following engine code, I am working with Unreal Engine 5.1:

void WritePackageData(FStructuredArchiveRecord& ParentRecord, bool bIsCooking, const UPackage* Package, FLinkerSave* Linker, const TSet<UObject*>& ImportsUsedInGame, const TSet<FName>& SoftPackagesUsedInGame, const ITargetPlatform* TargetPlatform)	{	// To avoid large patch sizes, we have frozen cooked package format at the format before VER_UE4_ASSETREGISTRY_DEPENDENCYFLAGS	bool bPreDependencyFormat = bIsCooking; 
@drcxd
Copy link
Author

drcxd commented Oct 9, 2025

It came to me that I can see how Unreal Engine read the asset, so in ReadPackageDataMain I found the following code:

// To avoid large patch sizes, we have frozen cooked package format at the format before VER_UE4_ASSETREGISTRY_DEPENDENCYFLAGS	bool bPreDependencyFormat = PackageFileSummary.GetFileVersionUE() < VER_UE4_ASSETREGISTRY_DEPENDENCYFLAGS || !!(PackageFileSummary.GetPackageFlags() & PKG_FilterEditorOnly); 

I updated the code as above and passed all 20 tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants