Fixed bug of accumulating Opendrive actors for maps
This commit is contained in:
parent
85c8fd88d4
commit
a9eafaba25
|
@ -165,21 +165,29 @@ bool UCookAssetsCommandlet::SaveWorld(
|
||||||
// Check if OpenDrive file exists
|
// Check if OpenDrive file exists
|
||||||
FString PathXODR = FPaths::ProjectContentDir() + PackageName + TEXT("/Maps/") + WorldName + TEXT(
|
FString PathXODR = FPaths::ProjectContentDir() + PackageName + TEXT("/Maps/") + WorldName + TEXT(
|
||||||
"/OpenDrive/") + WorldName + TEXT(".xodr");
|
"/OpenDrive/") + WorldName + TEXT(".xodr");
|
||||||
|
|
||||||
|
bool bPackageSaved = false;
|
||||||
if (FPaths::FileExists(PathXODR))
|
if (FPaths::FileExists(PathXODR))
|
||||||
{
|
{
|
||||||
// Filling the map stuff (Code only applied for maps)
|
// Filling the map stuff (Code only applied for maps)
|
||||||
AOpenDriveActor *OpenWorldActor =
|
AOpenDriveActor *OpenWorldActor =
|
||||||
CastChecked<AOpenDriveActor>(World->SpawnActor(AOpenDriveActor::StaticClass(),
|
CastChecked<AOpenDriveActor>(World->SpawnActor(AOpenDriveActor::StaticClass(),
|
||||||
new FVector(), NULL));
|
new FVector(), NULL));
|
||||||
|
|
||||||
OpenWorldActor->BuildRoutes(WorldName);
|
OpenWorldActor->BuildRoutes(WorldName);
|
||||||
OpenWorldActor->AddSpawners();
|
OpenWorldActor->AddSpawners();
|
||||||
}
|
|
||||||
|
|
||||||
// Saving the package
|
SavePackage(PackagePath, Package);
|
||||||
FString PackageFileName = FPackageName::LongPackageNameToFilename(PackagePath,
|
|
||||||
FPackageName::GetMapPackageExtension());
|
OpenWorldActor->RemoveRoutes();
|
||||||
return UPackage::SavePackage(Package, World, EObjectFlags::RF_Public | EObjectFlags::RF_Standalone,
|
OpenWorldActor->RemoveSpawners();
|
||||||
*PackageFileName, GError, nullptr, true, true, SAVE_NoError);
|
OpenWorldActor->Destroy();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SavePackage(PackagePath, Package);
|
||||||
|
}
|
||||||
|
return bPackageSaved;
|
||||||
}
|
}
|
||||||
|
|
||||||
FAssetsPaths UCookAssetsCommandlet::GetAssetsPathFromPackage(const FString &PackageName) const
|
FAssetsPaths UCookAssetsCommandlet::GetAssetsPathFromPackage(const FString &PackageName) const
|
||||||
|
@ -254,6 +262,15 @@ bool SaveStringTextToFile(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UCookAssetsCommandlet::SavePackage(const FString &PackagePath, UPackage *Package) const
|
||||||
|
{
|
||||||
|
FString PackageFileName = FPackageName::LongPackageNameToFilename(PackagePath,
|
||||||
|
FPackageName::GetMapPackageExtension());
|
||||||
|
|
||||||
|
return UPackage::SavePackage(Package, World, EObjectFlags::RF_Public | EObjectFlags::RF_Standalone,
|
||||||
|
*PackageFileName, GError, nullptr, true, true, SAVE_NoError);
|
||||||
|
}
|
||||||
|
|
||||||
int32 UCookAssetsCommandlet::Main(const FString &Params)
|
int32 UCookAssetsCommandlet::Main(const FString &Params)
|
||||||
{
|
{
|
||||||
FPackageParams PackageParams = ParseParams(Params);
|
FPackageParams PackageParams = ParseParams(Params);
|
||||||
|
@ -305,5 +322,4 @@ int32 UCookAssetsCommandlet::Main(const FString &Params)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -148,4 +148,9 @@ private:
|
||||||
*/
|
*/
|
||||||
UMaterial *TerrainNodeMaterial;
|
UMaterial *TerrainNodeMaterial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the package
|
||||||
|
*/
|
||||||
|
bool SavePackage(const FString &PackagePath, UPackage *Package) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue