From 4a4120864d865550329128ba78d3705a38483dd6 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 6 Oct 2024 23:23:41 +0200 Subject: [PATCH 1/3] Better fix for c6fa20abaab20338dc81e6c7e3481acd3442f544 --- Source/Engine/Tools/TextureTool/TextureTool.stb.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp b/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp index 15058752d..8ca585c32 100644 --- a/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp +++ b/Source/Engine/Tools/TextureTool/TextureTool.stb.cpp @@ -539,17 +539,17 @@ bool TextureTool::ImportTextureStb(ImageType type, const StringView& path, Textu if (options.FlipX) { // TODO: impl this - LOG(Warning "Option 'Flip X' is not supported"); + LOG(Warning, "Option 'Flip X' is not supported"); } if (options.InvertGreenChannel) { // TODO: impl this - LOG(Warning "Option 'Invert Green Channel' is not supported"); + LOG(Warning, "Option 'Invert Green Channel' is not supported"); } if (options.ReconstructZChannel) { // TODO: impl this - LOG(Warning "Option 'Reconstruct Z Channel' is not supported"); + LOG(Warning, "Option 'Reconstruct Z Channel' is not supported"); } // Generate mip maps chain From 28bf60e62d2d6e10b9b17f99daf57f53bb20a0a0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 6 Oct 2024 23:54:20 +0200 Subject: [PATCH 2/3] Fix compilation --- Source/Engine/Platform/Base/StringUtilsBase.cpp | 15 +++++++++++++++ Source/Engine/Platform/StringUtils.h | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Platform/Base/StringUtilsBase.cpp b/Source/Engine/Platform/Base/StringUtilsBase.cpp index 96d4fa338..5ee094a54 100644 --- a/Source/Engine/Platform/Base/StringUtilsBase.cpp +++ b/Source/Engine/Platform/Base/StringUtilsBase.cpp @@ -15,6 +15,21 @@ constexpr char DirectorySeparatorChar = '\\'; constexpr char AltDirectorySeparatorChar = '/'; constexpr char VolumeSeparatorChar = ':'; +#if PLATFORM_TEXT_IS_CHAR16 + +int32 StringUtils::Length(const wchar_t* str) +{ + int32 result = 0; + if (str) + { + while (*str) + str++; + } + return result; +} + +#endif + const Char* StringUtils::FindIgnoreCase(const Char* str, const Char* toFind) { if (toFind == nullptr || str == nullptr) diff --git a/Source/Engine/Platform/StringUtils.h b/Source/Engine/Platform/StringUtils.h index af9267e16..1bff2c2ae 100644 --- a/Source/Engine/Platform/StringUtils.h +++ b/Source/Engine/Platform/StringUtils.h @@ -115,6 +115,9 @@ public: public: // Gets the string length. Returns 0 if str is null. static int32 Length(const Char* str); +#if PLATFORM_TEXT_IS_CHAR16 + static int32 Length(const wchar_t* str); +#endif // Gets the string length. Returns 0 if str is null. static int32 Length(const char* str); @@ -224,7 +227,7 @@ public: template static bool ParseHex(const T* str, uint32* result) { - return StringUtils::ParseHex(str, StringUtils::Length((const T*)str), result); + return StringUtils::ParseHex(str, StringUtils::Length(str), result); } // Parses text to the unsigned integer value. Returns true if failed to convert the value. @@ -321,7 +324,7 @@ public: template static bool Parse(const T* str, U* result) { - return StringUtils::Parse((const T*)str, StringUtils::Length((const T*)str), (U*)result); + return StringUtils::Parse(str, StringUtils::Length(str), result); } // Parses text to the scalar value. Returns true if failed to convert the value. From 3434731c2a9996b7b036815f89a8370e8f411629 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 7 Oct 2024 00:40:22 +0200 Subject: [PATCH 3/3] Another blind fix --- Source/Editor/ProjectInfo.cpp | 37 ++++++++++++++++++- .../Engine/Platform/Base/StringUtilsBase.cpp | 15 -------- Source/Engine/Platform/Defines.h | 4 +- Source/Engine/Platform/StringUtils.h | 3 -- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Source/Editor/ProjectInfo.cpp b/Source/Editor/ProjectInfo.cpp index 28fc0301c..7fef490fe 100644 --- a/Source/Editor/ProjectInfo.cpp +++ b/Source/Editor/ProjectInfo.cpp @@ -13,6 +13,37 @@ using namespace pugi; Array ProjectInfo::ProjectsCache; +struct XmlCharAsChar +{ +#if PLATFORM_TEXT_IS_CHAR16 + Char* Str = nullptr; + + XmlCharAsChar(const pugi::char_t* str) + { + if (!str) + return; + int32 length = 0; + while (str[length]) + length++; + Str = (Char*)Platform::Allocate(length * sizeof(Char), sizeof(Char)); + for (int32 i = 0; i <= length; i++) + Str[i] = (Char)str[i]; + } + + ~XmlCharAsChar() + { + Platform::Free(Str); + } +#else + const Char* Str; + + XmlCharAsChar(const pugi::char_t* str) + : Str(str) + { + } +#endif +}; + void ShowProjectLoadError(const Char* errorMsg, const String& projectRootFolder) { Platform::Error(String::Format(TEXT("Failed to load project. {0}\nPath: '{1}'"), errorMsg, projectRootFolder)); @@ -28,8 +59,9 @@ Vector3 GetVector3FromXml(const xml_node& parent, const PUGIXML_CHAR* name, cons const auto z = node.child_value(PUGIXML_TEXT("Z")); if (x && y && z) { + XmlCharAsChar xs(x), ys(y), zs(z); Vector3 v; - if (!StringUtils::Parse(x, &v.X) && !StringUtils::Parse(y, &v.Y) && !StringUtils::Parse(z, &v.Z)) + if (!StringUtils::Parse(xs.Str, &v.X) && !StringUtils::Parse(ys.Str, &v.Y) && !StringUtils::Parse(zs.Str, &v.Z)) { return v; } @@ -44,8 +76,9 @@ int32 GetIntFromXml(const xml_node& parent, const PUGIXML_CHAR* name, const int3 const auto node = parent.child_value(name); if (node) { + XmlCharAsChar s(node); int32 v; - if (!StringUtils::Parse(node, &v)) + if (!StringUtils::Parse(s.Str, &v)) { return v; } diff --git a/Source/Engine/Platform/Base/StringUtilsBase.cpp b/Source/Engine/Platform/Base/StringUtilsBase.cpp index 5ee094a54..96d4fa338 100644 --- a/Source/Engine/Platform/Base/StringUtilsBase.cpp +++ b/Source/Engine/Platform/Base/StringUtilsBase.cpp @@ -15,21 +15,6 @@ constexpr char DirectorySeparatorChar = '\\'; constexpr char AltDirectorySeparatorChar = '/'; constexpr char VolumeSeparatorChar = ':'; -#if PLATFORM_TEXT_IS_CHAR16 - -int32 StringUtils::Length(const wchar_t* str) -{ - int32 result = 0; - if (str) - { - while (*str) - str++; - } - return result; -} - -#endif - const Char* StringUtils::FindIgnoreCase(const Char* str, const Char* toFind) { if (toFind == nullptr || str == nullptr) diff --git a/Source/Engine/Platform/Defines.h b/Source/Engine/Platform/Defines.h index 40b250983..b2f857937 100644 --- a/Source/Engine/Platform/Defines.h +++ b/Source/Engine/Platform/Defines.h @@ -186,8 +186,8 @@ API_ENUM() enum class ArchitectureType #ifndef PLATFORM_ARCH_ARM64 #define PLATFORM_ARCH_ARM64 0 #endif -#ifndef PLATFORM_WCHAR_IS_CHAR16 -#define PLATFORM_WCHAR_IS_CHAR16 0 +#ifndef PLATFORM_TEXT_IS_CHAR16 +#define PLATFORM_TEXT_IS_CHAR16 0 #endif #ifndef PLATFORM_DEBUG_BREAK #define PLATFORM_DEBUG_BREAK diff --git a/Source/Engine/Platform/StringUtils.h b/Source/Engine/Platform/StringUtils.h index 1bff2c2ae..248f0c3d7 100644 --- a/Source/Engine/Platform/StringUtils.h +++ b/Source/Engine/Platform/StringUtils.h @@ -115,9 +115,6 @@ public: public: // Gets the string length. Returns 0 if str is null. static int32 Length(const Char* str); -#if PLATFORM_TEXT_IS_CHAR16 - static int32 Length(const wchar_t* str); -#endif // Gets the string length. Returns 0 if str is null. static int32 Length(const char* str);