36 FString MapName = InMapName;
40 FString CorrectedMapName = MapName;
41 constexpr auto PIEPrefix = TEXT(
"UEDPIE_0_");
42 CorrectedMapName.RemoveFromStart(PIEPrefix);
43 MapName = CorrectedMapName;
47 FString XODRFileName = MapName + TEXT(
".xodr");
49 auto &FileManager = IFileManager::Get();
54 if (FileManager.FileExists(*SavedFilePath))
59 const FString DefaultFilePath =
60 FPaths::ProjectContentDir() +
61 TEXT(
"Carla/Maps/OpenDrive/") +
64 if (FileManager.FileExists(*DefaultFilePath))
66 return DefaultFilePath;
75 if (!Pack.bMounted)
continue;
78 if (Map.Name.Equals(MapName, ESearchCase::IgnoreCase) && !Map.Xodr.IsEmpty())
80 const FString PackFilePath = FPaths::ConvertRelativePathToFull(Pack.ContentDir / Map.Xodr);
81 if (FPaths::IsUnderDirectory(PackFilePath, Pack.ContentDir) && FileManager.FileExists(*PackFilePath))
89 for (
const FString &PackContentDir : ContentPacks->GetPackContentDirs())
91 const FString PackFilePath = PackContentDir / TEXT(
"Maps/OpenDrive") / XODRFileName;
92 if (FileManager.FileExists(*PackFilePath))
99 TArray<FString> FilesFound;
100 FileManager.FindFilesRecursive(
102 *FPaths::ProjectContentDir(),
108 if (FilesFound.Num() > 0)
110 return FilesFound[0u];
113 FString PluginPath = FPaths::ProjectDir() + TEXT(
"Plugins/") + MapName + TEXT(
"/Content/Maps/OpenDrive/") + XODRFileName;
115 if (FileManager.FileExists(*PluginPath))
120 FString PluginsDir = FPaths::ProjectDir() + TEXT(
"Plugins/");
122 TArray<FString> PluginFilesFound;
123 FileManager.FindFilesRecursive(
131 if (PluginFilesFound.Num() > 0)
133 return PluginFilesFound[0u];
141 auto MapName = World->GetMapName();
145 FString CorrectedMapName = MapName;
146 constexpr auto PIEPrefix = TEXT(
"UEDPIE_0_");
147 CorrectedMapName.RemoveFromStart(PIEPrefix);
148 MapName = CorrectedMapName;
154 const auto FolderDir = MapDir +
"/OpenDrive/";
155 const auto FileName = MapDir.EndsWith(MapName) ?
"*" : MapName;
157 TArray<FString> Files;
162 if (IFileManager::Get().FileExists(*SavedFilePath))
164 Files.Add(SavedFilePath);
169 IFileManager::Get().FindFilesRecursive(Files, *FolderDir, *FString(FileName +
".xodr"),
true,
false,
false);
174 FString PluginFolder = FPaths::ProjectDir() + TEXT(
"Plugins/") + MapName + TEXT(
"/Content/Maps/OpenDrive/");
175 IFileManager::Get().FindFilesRecursive(Files, *PluginFolder, *FString(FileName +
".xodr"),
true,
false,
false);
182 if (!FoundPath.IsEmpty())
184 Files.Add(FoundPath);
192 UE_LOG(LogCarla, Error, TEXT(
"No OpenDrive file found for map '%s'"), *MapName);
194 else if (FFileHelper::LoadFileToString(Content, *Files[0]))
196 UE_LOG(LogCarla, Log, TEXT(
"Loaded OpenDrive file '%s'"), *Files[0]);
200 UE_LOG(LogCarla, Error, TEXT(
"Failed to load OpenDrive file '%s'"), *Files[0]);
212 if (FilePath.IsEmpty())
214 UE_LOG(LogCarla, Error, TEXT(
"Failed to find OpenDrive file for map '%s'"), *MapName);
216 else if (FFileHelper::LoadFileToString(Content, *FilePath))
218 UE_LOG(LogCarla, Log, TEXT(
"Loaded OpenDrive file '%s'"), *FilePath);
222 UE_LOG(LogCarla, Error, TEXT(
"Failed to load OpenDrive file '%s'"), *FilePath);
232 if (FullPath.IsEmpty())
234 UE_LOG(LogCarla, Error, TEXT(
"Failed to find OpenDrive file for map '%s'"), *FullPath);
236 else if (FFileHelper::LoadFileToString(Content, *FullPath))
238 UE_LOG(LogCarla, Log, TEXT(
"Loaded OpenDrive file '%s'"), *FullPath);
242 UE_LOG(LogCarla, Error, TEXT(
"Failed to load OpenDrive file '%s'"), *FullPath);
254 FString CorrectedMapName = MapName;
255 constexpr auto PIEPrefix = TEXT(
"UEDPIE_0_");
256 CorrectedMapName.RemoveFromStart(PIEPrefix);
257 MapName = CorrectedMapName;
261 FString FileName = XODRPath.EndsWith(MapName) ?
"*" : MapName;
262 FString FolderDir = XODRPath;
263 FolderDir.RemoveFromEnd(MapName +
".xodr");
266 TArray<FString> Files;
267 IFileManager::Get().FindFilesRecursive(Files, *FolderDir, *FString(FileName +
".xodr"),
true,
false,
false);
273 UE_LOG(LogTemp, Error, TEXT(
"Failed to find OpenDrive file for map '%s'"), *MapName);
275 else if (FFileHelper::LoadFileToString(Content, *Files[0]))
277 UE_LOG(LogTemp, Log, TEXT(
"Loaded OpenDrive file '%s'"), *Files[0]);
Mounts CARLA content packs (content-only Unreal plugins cooked as DLC against a base release,...
static UCarlaContentPackManager * Get()
One map declared by a content pack manifest.
A content pack known to the manager (discovered or mounted explicitly).