diff --git a/PythonAPI/carla/source/libcarla/Client.cpp b/PythonAPI/carla/source/libcarla/Client.cpp index 58aa1756e..5b38acd9d 100644 --- a/PythonAPI/carla/source/libcarla/Client.cpp +++ b/PythonAPI/carla/source/libcarla/Client.cpp @@ -30,10 +30,6 @@ static auto GetAvailableMaps(const carla::client::Client &self) { return result; } -static auto SetFilesBaseFolder(carla::client::Client &self, const std::string &path) { - return self.SetFilesBaseFolder(path); -} - static auto GetRequiredFiles(const carla::client::Client &self, const std::string &folder, const bool download) { boost::python::list result; for (const auto &str : self.GetRequiredFiles(folder, download)) { @@ -42,10 +38,6 @@ static auto GetRequiredFiles(const carla::client::Client &self, const std::strin return result; } -static void RequestFile(const carla::client::Client &self, const std::string &name) { - self.RequestFile(name); -} - static void ApplyBatchCommands( const carla::client::Client &self, const boost::python::object &commands, @@ -196,9 +188,9 @@ void export_client() { .def("get_server_version", CONST_CALL_WITHOUT_GIL(cc::Client, GetServerVersion)) .def("get_world", &cc::Client::GetWorld) .def("get_available_maps", &GetAvailableMaps) - .def("set_files_base_folder", &SetFilesBaseFolder, (arg("path"))) + .def("set_files_base_folder", &cc::Client::SetFilesBaseFolder, (arg("path"))) .def("get_required_files", &GetRequiredFiles, (arg("folder")="", arg("download")=true)) - .def("request_file", &RequestFile, (arg("name"))) + .def("request_file", &cc::Client::RequestFile, (arg("name"))) .def("reload_world", CONST_CALL_WITHOUT_GIL_1(cc::Client, ReloadWorld, bool), (arg("reset_settings")=true)) .def("load_world", CONST_CALL_WITHOUT_GIL_3(cc::Client, LoadWorld, std::string, bool, rpc::MapLayer), (arg("map_name"), arg("reset_settings")=true, arg("map_layers")=rpc::MapLayer::All)) .def("generate_opendrive_world", CONST_CALL_WITHOUT_GIL_3(cc::Client, GenerateOpenDriveWorld, std::string, diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/OpenDrive/OpenDrive.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/OpenDrive/OpenDrive.cpp index d78236a99..cfd138587 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/OpenDrive/OpenDrive.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/OpenDrive/OpenDrive.cpp @@ -12,20 +12,32 @@ FString UOpenDrive::GetXODR(const UWorld *World) { - const auto mapName = World->GetMapName(); - const auto mapDir = FPaths::GetPath(UCarlaStatics::GetGameInstance(World)->GetMapPath()); - const auto folderDir = mapDir + "/OpenDrive/"; - const auto fileName = mapDir.EndsWith(mapName) ? "*" : mapName; + auto MapName = World->GetMapName(); + + // When playing in editor the map name gets an extra prefix, here we + // remove it. + #if WITH_EDITOR + { + FString CorrectedMapName = MapName; + constexpr auto PIEPrefix = TEXT("UEDPIE_0_"); + CorrectedMapName.RemoveFromStart(PIEPrefix); + MapName = CorrectedMapName; + } + #endif // WITH_EDITOR + + const auto MapDir = FPaths::GetPath(UCarlaStatics::GetGameInstance(World)->GetMapPath()); + const auto FolderDir = MapDir + "/OpenDrive/"; + const auto FileName = MapDir.EndsWith(MapName) ? "*" : MapName; // Find all the xodr and bin files from the map TArray Files; - IFileManager::Get().FindFilesRecursive(Files, *folderDir, *FString(fileName + ".xodr"), true, false, false); + IFileManager::Get().FindFilesRecursive(Files, *FolderDir, *FString(FileName + ".xodr"), true, false, false); FString Content; if (!Files.Num()) { - UE_LOG(LogTemp, Error, TEXT("Failed to find OpenDrive file for map '%s'"), *mapName); + UE_LOG(LogTemp, Error, TEXT("Failed to find OpenDrive file for map '%s'"), *MapName); } else if (FFileHelper::LoadFileToString(Content, *Files[0])) {