Hi,
We are in the process of building a host game menu and while we were looking at UT4 we came across their UTLevelSummary object and LoadLevelSummary() function. This stores information (Title, author, screenshot etc) and then is saved into the map file. Then when they use the asset registry to look up all map files and then manually load the map data until they find the level summary object and use it.
We copied this structure and found that calling UEngine::LoadMap() results in an assert being triggered.
// Normal map loading
if (NewWorld == NULL)
{
// Set the world type in the static map, so that UWorld::PostLoad can set the world type
const FName URLMapFName = FName(*URL.Map);
UWorld::WorldTypePreLoadMap.FindOrAdd( URLMapFName ) = WorldContext.WorldType;
// See if the level is already in memory
WorldPackage = FindPackage(nullptr, *URL.Map);
// If the level isn't already in memory, load level from disk
if (WorldPackage == NULL)
{
WorldPackage = LoadPackage(nullptr, *URL.Map, (WorldContext.WorldType == EWorldType::PIE ? LOAD_PackageForPIE : LOAD_None));
}
// Clean up the world type list now that PostLoad has occurred
UWorld::WorldTypePreLoadMap.Remove( URLMapFName );
if( WorldPackage == NULL )
{
// it is now the responsibility of the caller to deal with a NULL return value and alert the user if necessary
Error = FString::Printf(TEXT("Failed to load package '%s'"), *URL.Map);
return false;
}
// Find the newly loaded world.
NewWorld = UWorld::FindWorldInPackage(WorldPackage);
// If the world was not found, it could be a redirector to a world. If so, follow it to the destination world.
if ( !NewWorld )
{
NewWorld = UWorld::FollowWorldRedirectorInPackage(WorldPackage);
if ( NewWorld )
{
WorldPackage = NewWorld->GetOutermost();
}
}
check(NewWorld);
//Snip
}
What we believe is happening is the manual loading of the map is causing the call to FindPackage to return a half loaded package (so WorldPackage doesn’t equal NULL), but the call to UWorld::FindWorldInPackage() doesn’t find a world because that part of the map hasn’t been loaded yet.
We were wondering if this is a known issue (that LoadMap doesn’t work with assets that are partially loaded) and if it is whether or not it is being looked at or if that feature of UT4 is being abandoned. After running into this issue we investigated the feature in UT4 a bit more and realised that it wasn’t actually being called from anywhere so we were unsure if this was a half completed feature or if they had run into the same issues as us.
Cheers