Advertisement
Guest User

Untitled

a guest
May 2nd, 2018
1,330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. bool AMyPawn::LoadMap(const FString& filename, const FString& levelname, const FString& mountPoint, const FString& mountPath)
  2. {
  3.  
  4.     FString StandardFilename(filename);
  5.     FPaths::MakeStandardFilename(StandardFilename);
  6.     StandardFilename = FPaths::GetPath(StandardFilename);
  7.  
  8.     IPlatformFile& InnerPlatform = FPlatformFileManager::Get().GetPlatformFile();
  9.     FPakPlatformFile* PakPlatform = new FPakPlatformFile();
  10.  
  11.     PakPlatform->Initialize(&InnerPlatform, TEXT(""));
  12.     FPlatformFileManager::Get().SetPlatformFile(*PakPlatform);
  13.  
  14.     bool ret = false;
  15.  
  16.     FPakFile pakFile(PakPlatform, *filename, false);
  17.     if (pakFile.IsValid()) {
  18.  
  19.         pakFile.SetMountPoint(*mountPoint);
  20.         const int32 PakOrder = 0;
  21.         if (PakPlatform->Mount(*filename, PakOrder, *mountPoint)) {
  22.  
  23.             UE_LOG(LogTemp, Warning, TEXT("   loaded and mounted, listing..."));//@@
  24.  
  25.             struct Dump : public IPlatformFile::FDirectoryVisitor {
  26.                 virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) {
  27.                     if (bIsDirectory) {
  28.                         UE_LOG(LogTemp, Warning, TEXT("Directory: %s"), FilenameOrDirectory);
  29.                     }
  30.                     else {
  31.                         UE_LOG(LogTemp, Warning, TEXT("File: %s"), FilenameOrDirectory);
  32.                     }
  33.                     return true;
  34.                 }
  35.             };
  36.  
  37.             Dump visitor;
  38.             if (mountPoint.Len() > 0) {
  39.  
  40.                 PakPlatform->IterateDirectoryRecursively(*mountPoint, visitor);
  41.  
  42.             }
  43.             else {
  44.  
  45.                 PakPlatform->IterateDirectoryRecursively(TEXT("/Game/"), visitor);
  46.             }
  47.  
  48.             ret = true;
  49.  
  50.         }
  51.         else {
  52.  
  53.             UE_LOG(LogTemp, Warning, TEXT("   failed to mount pak file"));
  54.         }
  55.  
  56.     }
  57.     else {
  58.  
  59.         UE_LOG(LogTemp, Warning, TEXT("   failed to load pak file"));
  60.     }
  61.  
  62.     FString ln;
  63.     if (mountPoint.Len() > 0 && mountPath.Len() > 0) {
  64.         FPackageName::RegisterMountPoint(mountPoint, mountPath);
  65.         ln = levelname;
  66.     }
  67.     else {
  68.         ln = levelname;
  69.     }
  70.  
  71.     FName level(*ln);
  72.     UGameplayStatics::OpenLevel(GetWorld(), level);
  73.  
  74.     return true;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement