Load map from PAK

Hi guys, I have a method that’s meant to load a map from a PAK file from local disk. Loading the PAK from disk works however I can’t seem to repath the map so ServerTravel works. How do I get the path of the mounted map that’s loaded from the PAK? The method in question is below:


void UMapManager::LoadMap(FString MapName, UWorld* World)
{
	IPlatformFile& InnerPlatform = FPlatformFileManager::Get().GetPlatformFile();
	FPakPlatformFile* PakPlatform = new FPakPlatformFile();
	FPakFile* Pak = new FPakFile(*(UMapManager::GenerateMapFullPath(MapName)), false);

	// Initialize the variables
	PakPlatform->Initialize(&InnerPlatform, TEXT(""));
	Pak->SetMountPoint(*FPaths::EngineContentDir());

	// Mount the pak file
	if(PakPlatform->Mount(*(UMapManager::GenerateMapFullPath(MapName)), 0, *FPaths::EngineContentDir()))
		GEngine->AddOnScreenDebugMessage(2, 5.0f, FColor::Green, TEXT("PAK loaded"));
	else
		GEngine->AddOnScreenDebugMessage(2, 5.0f, FColor::Red, TEXT("PAK not loaded"));

	// Iterate through all the files in the pak
	TArray<FStringAssetReference> AssetFiles;
	TSet<FString> FileList;
	Pak->FindFilesAtPath(FileList, *FPaths::EngineContentDir(), true, false, true);
	for(TSet<FString>::TConstIterator FileItem(FileList); FileItem; ++FileItem)
	{
		FString AssetName = *FileItem;
		GEngine->AddOnScreenDebugMessage(4, 5.0f, FColor::Red, *AssetName);

		if(AssetName.EndsWith(FPackageName::GetMapPackageExtension()))
		{
			FString MapPath = "/Engine/";

			// Change the path to be engine path
			FString AssetShortName = FPackageName::GetShortName(AssetName);
			AssetShortName.RemoveFromEnd(FPackageName::GetMapPackageExtension());

			MapPath += AssetShortName + "." + AssetShortName;
			GEngine->AddOnScreenDebugMessage(5, 5.0f, FColor::Red, *MapPath);
			
			// Load the actual map that's found
			if(World)
				World->ServerTravel(FPaths::GameContentDir() + AssetShortName);
			else
				GEngine->AddOnScreenDebugMessage(3, 5.0f, FColor::Green, "Invalid world pointer");
		}
	}
}

Bump. There’s no documentation on this topic at all and every question I find has no definitive answer.

Please wait at least 4 days before bumping threads … this prevents excessive noise from being generated on the forums. Thanks.

Not really sure what your goal is but none of that code is necessary to load maps from pak files; just cook and package your game using the pak option on either the unreal front end, the in-editor tools or run unreal automation tool from the command line with the required flags and the cooked version of your game will have all its contents in a pak.