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");
}
}
}