From 729bfcb941e78295113ac7ec984014215f28dfdf Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 9 Jan 2022 18:05:52 +0100 Subject: [PATCH] Fix build --- .../Cooker/Platform/UWP/UWPPlatformTools.cpp | 24 ++++++++-------- .../Engine/ContentExporters/ExportModel.cpp | 28 +++++++++---------- Source/Engine/Serialization/Stream.cpp | 6 ++++ Source/Engine/Serialization/WriteStream.h | 1 + 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp b/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp index d399c7f63..c74368348 100644 --- a/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp @@ -179,12 +179,12 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data) if (file) { auto now = DateTime::Now(); - file->WriteTextFormatted( + file->WriteText(StringAnsi::Format( fileTemplate.Get() , gameSettings->ProductName.ToStringAnsi() , gameSettings->CompanyName.ToStringAnsi() , now.GetYear() - ); + )); hasError = file->HasError(); Delete(file); } @@ -210,10 +210,10 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data) bool hasError = true; if (file) { - file->WriteTextFormatted( + file->WriteText(StringAnsi::Format( fileTemplate.Get() , defaultNamespace.ToStringAnsi() // {0} Default Namespace - ); + )); hasError = file->HasError(); Delete(file); } @@ -264,11 +264,11 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data) bool hasError = true; if (file) { - file->WriteTextFormatted( + file->WriteText(StringAnsi::Format( fileTemplate.Get() , autoRotationPreferences.Get() , preferredLaunchWindowingMode.Get() - ); + )); hasError = file->HasError(); Delete(file); } @@ -296,12 +296,12 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data) bool hasError = true; if (file) { - file->WriteTextFormatted( + file->WriteText(StringAnsi::Format( fileTemplate.Get() , projectName.ToStringAnsi() // {0} Project Name , mode // {1} Platform Mode , projectGuid.ToStringAnsi() // {2} Project ID - ); + )); hasError = file->HasError(); Delete(file); } @@ -344,14 +344,14 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data) bool hasError = true; if (file) { - file->WriteTextFormatted( + file->WriteText(StringAnsi::Format( fileTemplate.Get() , projectName.ToStringAnsi() // {0} Project Name , mode // {1} Platform Mode , projectGuid.Get() // {2} Project ID , filesInclude.ToString().ToStringAnsi() // {3} Files to include , defaultNamespace.ToStringAnsi() // {4} Default Namespace - ); + )); hasError = file->HasError(); Delete(file); } @@ -394,13 +394,13 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data) bool hasError = true; if (file) { - file->WriteTextFormatted( + file->WriteText(StringAnsi::Format( fileTemplate.Get() , projectName.ToStringAnsi() // {0} Display Name , gameSettings->CompanyName.ToStringAnsi() // {1} Company Name , productId.ToStringAnsi() // {2} Product ID , defaultNamespace.ToStringAnsi() // {3} Default Namespace - ); + )); hasError = file->HasError(); Delete(file); } diff --git a/Source/Engine/ContentExporters/ExportModel.cpp b/Source/Engine/ContentExporters/ExportModel.cpp index 7fdd011f9..9dd3a8124 100644 --- a/Source/Engine/ContentExporters/ExportModel.cpp +++ b/Source/Engine/ContentExporters/ExportModel.cpp @@ -34,7 +34,7 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context) DeleteMe outputDeleteMe(output); const auto name = StringUtils::GetFileNameWithoutExtension(asset->GetPath()).ToStringAnsi(); - output->WriteTextFormatted("# Exported model {0}\n", name.Get()); + output->WriteText(StringAnsi::Format("# Exported model {0}\n", name.Get())); // Extract all meshes const auto& lod = asset->LODs[lodIndex]; @@ -63,12 +63,12 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context) } auto ib = stream.Read(indicesCount * ibStride); - output->WriteTextFormatted("# Mesh {0}\n", meshIndex); + output->WriteText(StringAnsi::Format("# Mesh {0}\n", meshIndex)); for (uint32 i = 0; i < vertices; i++) { auto v = vb0[i].Position; - output->WriteTextFormatted("v {0} {1} {2}\n", v.X, v.Y, v.Z); + output->WriteText(StringAnsi::Format("v {0} {1} {2}\n", v.X, v.Y, v.Z)); } output->WriteChar('\n'); @@ -76,7 +76,7 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context) for (uint32 i = 0; i < vertices; i++) { auto v = vb1[i].TexCoord; - output->WriteTextFormatted("vt {0} {1}\n", Float16Compressor::Decompress(v.X), Float16Compressor::Decompress(v.Y)); + output->WriteText(StringAnsi::Format("vt {0} {1}\n", Float16Compressor::Decompress(v.X), Float16Compressor::Decompress(v.Y))); } output->WriteChar('\n'); @@ -84,7 +84,7 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context) for (uint32 i = 0; i < vertices; i++) { auto v = vb1[i].Normal.ToVector3() * 2.0f - 1.0f; - output->WriteTextFormatted("vn {0} {1} {2}\n", v.X, v.Y, v.Z); + output->WriteText(StringAnsi::Format("vn {0} {1} {2}\n", v.X, v.Y, v.Z)); } output->WriteChar('\n'); @@ -97,7 +97,7 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context) auto i0 = vertexStart + *t++; auto i1 = vertexStart + *t++; auto i2 = vertexStart + *t++; - output->WriteTextFormatted("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2); + output->WriteText(StringAnsi::Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2)); } } else @@ -108,7 +108,7 @@ ExportAssetResult AssetExporters::ExportModel(ExportAssetContext& context) auto i0 = vertexStart + *t++; auto i1 = vertexStart + *t++; auto i2 = vertexStart + *t++; - output->WriteTextFormatted("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2); + output->WriteText(StringAnsi::Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2)); } } @@ -146,7 +146,7 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context DeleteMe outputDeleteMe(output); const auto name = StringUtils::GetFileNameWithoutExtension(asset->GetPath()).ToStringAnsi(); - output->WriteTextFormatted("# Exported model {0}\n", name.Get()); + output->WriteText(StringAnsi::Format("# Exported model {0}\n", name.Get())); // Extract all meshes const auto& lod = asset->LODs[lodIndex]; @@ -168,12 +168,12 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context auto vb0 = stream.Read(vertices); auto ib = stream.Read(indicesCount * ibStride); - output->WriteTextFormatted("# Mesh {0}\n", meshIndex); + output->WriteText(StringAnsi::Format("# Mesh {0}\n", meshIndex)); for (uint32 i = 0; i < vertices; i++) { auto v = vb0[i].Position; - output->WriteTextFormatted("v {0} {1} {2}\n", v.X, v.Y, v.Z); + output->WriteText(StringAnsi::Format("v {0} {1} {2}\n", v.X, v.Y, v.Z)); } output->WriteChar('\n'); @@ -181,7 +181,7 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context for (uint32 i = 0; i < vertices; i++) { auto v = vb0[i].TexCoord; - output->WriteTextFormatted("vt {0} {1}\n", Float16Compressor::Decompress(v.X), Float16Compressor::Decompress(v.Y)); + output->WriteText(StringAnsi::Format("vt {0} {1}\n", Float16Compressor::Decompress(v.X), Float16Compressor::Decompress(v.Y))); } output->WriteChar('\n'); @@ -189,7 +189,7 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context for (uint32 i = 0; i < vertices; i++) { auto v = vb0[i].Normal.ToVector3() * 2.0f - 1.0f; - output->WriteTextFormatted("vn {0} {1} {2}\n", v.X, v.Y, v.Z); + output->WriteText(StringAnsi::Format("vn {0} {1} {2}\n", v.X, v.Y, v.Z)); } output->WriteChar('\n'); @@ -202,7 +202,7 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context auto i0 = vertexStart + *t++; auto i1 = vertexStart + *t++; auto i2 = vertexStart + *t++; - output->WriteTextFormatted("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2); + output->WriteText(StringAnsi::Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2)); } } else @@ -213,7 +213,7 @@ ExportAssetResult AssetExporters::ExportSkinnedModel(ExportAssetContext& context auto i0 = vertexStart + *t++; auto i1 = vertexStart + *t++; auto i2 = vertexStart + *t++; - output->WriteTextFormatted("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2); + output->WriteText(StringAnsi::Format("f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}\n", i0, i1, i2)); } } diff --git a/Source/Engine/Serialization/Stream.cpp b/Source/Engine/Serialization/Stream.cpp index 067c5e269..28874f976 100644 --- a/Source/Engine/Serialization/Stream.cpp +++ b/Source/Engine/Serialization/Stream.cpp @@ -523,6 +523,12 @@ void WriteStream::WriteText(const StringView& text) WriteChar(text[i]); } +void WriteStream::WriteText(const StringAnsiView& text) +{ + for (int32 i = 0; i < text.Length(); i++) + WriteChar(text[i]); +} + void WriteStream::WriteString(const StringView& data) { const int32 length = data.Length(); diff --git a/Source/Engine/Serialization/WriteStream.h b/Source/Engine/Serialization/WriteStream.h index 1bc4ee692..97bb4c66d 100644 --- a/Source/Engine/Serialization/WriteStream.h +++ b/Source/Engine/Serialization/WriteStream.h @@ -165,6 +165,7 @@ public: // Writes text to the stream // @param data Text to write void WriteText(const StringView& text); + void WriteText(const StringAnsiView& text); // Writes String to the stream // @param data Data to write