Fixed file transfer file paths
This commit is contained in:
parent
fb30cbafac
commit
daf269dd94
|
@ -50,11 +50,19 @@ ACarlaGameModeBase::ACarlaGameModeBase(const FObjectInitializer& ObjectInitializ
|
|||
CarlaSettingsDelegate = CreateDefaultSubobject<UCarlaSettingsDelegate>(TEXT("CarlaSettingsDelegate"));
|
||||
}
|
||||
|
||||
const FString ACarlaGameModeBase::GetMapPath() const
|
||||
const FString ACarlaGameModeBase::GetRelativeMapPath() const
|
||||
{
|
||||
UWorld* World = GetWorld();
|
||||
TSoftObjectPtr<UWorld> AssetPtr (World);
|
||||
return AssetPtr.GetLongPackageName();
|
||||
FString Path = FPaths::GetPath(AssetPtr.GetLongPackageName());
|
||||
Path.RemoveFromStart("/Game/");
|
||||
return Path;
|
||||
}
|
||||
|
||||
const FString ACarlaGameModeBase::GetFullMapPath() const
|
||||
{
|
||||
FString Path = GetRelativeMapPath();
|
||||
return FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()) + Path;
|
||||
}
|
||||
|
||||
void ACarlaGameModeBase::InitGame(
|
||||
|
|
|
@ -48,7 +48,10 @@ public:
|
|||
return Map;
|
||||
}
|
||||
|
||||
const FString GetMapPath() const;
|
||||
const FString GetFullMapPath() const;
|
||||
|
||||
// get path relative to Content folder
|
||||
const FString GetRelativeMapPath() const;
|
||||
|
||||
UFUNCTION(Exec, Category = "CARLA Game Mode")
|
||||
void DebugShowSignals(bool enable);
|
||||
|
|
|
@ -70,9 +70,7 @@ FString UOpenDrive::GetXODR(const UWorld *World)
|
|||
|
||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(World);
|
||||
|
||||
auto RelativePath = FPaths::GetPath(GameMode->GetMapPath());
|
||||
RelativePath.RemoveFromStart("/Game/");
|
||||
auto MapDir = FPaths::ProjectContentDir() + RelativePath;
|
||||
auto MapDir = GameMode->GetFullMapPath();
|
||||
const auto FolderDir = MapDir + "/OpenDrive/";
|
||||
const auto FileName = MapDir.EndsWith(MapName) ? "*" : MapName;
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ void FCarlaServer::FPimpl::BindActions()
|
|||
REQUIRE_CARLA_EPISODE();
|
||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
||||
const auto &SpawnPoints = Episode->GetRecommendedSpawnPoints();
|
||||
FString FullMapPath = FPaths::GetPath(GameMode->GetMapPath());
|
||||
FString FullMapPath = GameMode->GetFullMapPath();
|
||||
FString MapDir = FullMapPath.RightChop(FullMapPath.Find("Content/", ESearchCase::CaseSensitive) + 8);
|
||||
MapDir += "/" + Episode->GetMapName();
|
||||
return cr::MapInfo{
|
||||
|
@ -378,14 +378,14 @@ void FCarlaServer::FPimpl::BindActions()
|
|||
|
||||
// Get the map's folder absolute path and check if it's in its own folder
|
||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
||||
const auto mapDir = FPaths::GetPath(GameMode->GetMapPath());
|
||||
const auto folderDir = mapDir + "/" + folder.c_str();
|
||||
const auto mapDir = GameMode->GetFullMapPath();
|
||||
const auto folderDir = mapDir + folder.c_str();
|
||||
const auto fileName = mapDir.EndsWith(Episode->GetMapName()) ? "*" : Episode->GetMapName();
|
||||
|
||||
// Find all the xodr and bin files from the map
|
||||
TArray<FString> Files;
|
||||
IFileManager::Get().FindFilesRecursive(Files, *folderDir, *FString(fileName + ".xodr"), true, false, false);
|
||||
IFileManager::Get().FindFilesRecursive(Files, *folderDir, *FString(fileName + ".bin"), true, false, false);
|
||||
IFileManager::Get().FindFilesRecursive(Files, *folderDir, *(fileName + ".xodr"), true, false, false);
|
||||
IFileManager::Get().FindFilesRecursive(Files, *folderDir, *(fileName + ".bin"), true, false, false);
|
||||
|
||||
// Remove the start of the path until the content folder and put each file in the result
|
||||
std::vector<std::string> result;
|
||||
|
|
Loading…
Reference in New Issue