diff --git a/Code/Editor/Export/ExportManager.cpp b/Code/Editor/Export/ExportManager.cpp index 5ba250c960..981e38c029 100644 --- a/Code/Editor/Export/ExportManager.cpp +++ b/Code/Editor/Export/ExportManager.cpp @@ -46,7 +46,7 @@ namespace SEfResTexture* pTex = pRes->GetTextureResource(nSlot); if (pTex) { - azstrcat(outName, Path::GamePathToFullPath(pTex->m_Name.c_str()).toUtf8().data()); + azstrcat(outName, AZ_ARRAY_SIZE(outName), Path::GamePathToFullPath(pTex->m_Name.c_str()).toUtf8().data()); } } @@ -88,7 +88,7 @@ Export::CObject::CObject(const char* pName) nParent = -1; - azstrcpy(name, pName); + azstrcpy(name, AZ_ARRAY_SIZE(name), pName); materialName[0] = '\0'; @@ -102,7 +102,7 @@ Export::CObject::CObject(const char* pName) void Export::CObject::SetMaterialName(const char* pName) { - azstrcpy(materialName, pName); + azstrcpy(materialName, AZ_ARRAY_SIZE(materialName), pName); } diff --git a/Code/Editor/TrackView/CommentNodeAnimator.cpp b/Code/Editor/TrackView/CommentNodeAnimator.cpp index 579bba00ef..cc3e7da972 100644 --- a/Code/Editor/TrackView/CommentNodeAnimator.cpp +++ b/Code/Editor/TrackView/CommentNodeAnimator.cpp @@ -92,7 +92,7 @@ void CCommentNodeAnimator::AnimateCommentTextTrack(CTrackViewTrack* pTrack, cons if (commentKey.m_duration > 0 && ac.time < keyHandle.GetTime() + commentKey.m_duration) { m_commentContext.m_strComment = commentKey.m_strComment; - azstrcpy(m_commentContext.m_strFont, commentKey.m_strFont.c_str()); + azstrcpy(m_commentContext.m_strFont, AZ_ARRAY_SIZE(m_commentContext.m_strFont), commentKey.m_strFont.c_str()); m_commentContext.m_color = commentKey.m_color; m_commentContext.m_align = commentKey.m_align; m_commentContext.m_size = commentKey.m_size; diff --git a/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp b/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp index f66bb19bf3..bf2e39e64d 100644 --- a/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp +++ b/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp @@ -2808,10 +2808,10 @@ void CTrackViewDopeSheetBase::DrawKeys(CTrackViewTrack* pTrack, QPainter* painte } else { - azstrcpy(keydesc, "{"); + azstrcpy(keydesc, AZ_ARRAY_SIZE(keydesc), "{"); } - azstrcat(keydesc, pDescription); - azstrcat(keydesc, "}"); + azstrcat(keydesc, AZ_ARRAY_SIZE(keydesc), pDescription); + azstrcat(keydesc, AZ_ARRAY_SIZE(keydesc), "}"); // Draw key description text. // Find next key. const QRect textRect(QPoint(x + 10, rect.top()), QPoint(x1, rect.bottom())); diff --git a/Code/Editor/TrackView/TrackViewNodes.cpp b/Code/Editor/TrackView/TrackViewNodes.cpp index 000bdf21d0..9652de51ef 100644 --- a/Code/Editor/TrackView/TrackViewNodes.cpp +++ b/Code/Editor/TrackView/TrackViewNodes.cpp @@ -2516,7 +2516,7 @@ int CTrackViewNodesCtrl::GetMatNameAndSubMtlIndexFromName(QString& matName, cons if (const char* pCh = strstr(nodeName, ".[")) { char matPath[MAX_PATH]; - azstrncpy(matPath, nodeName, (size_t)(pCh - nodeName)); + azstrncpy(matPath, AZ_ARRAY_SIZE(matPath), nodeName, (size_t)(pCh - nodeName)); matName = matPath; pCh += 2; if ((*pCh) != 0) diff --git a/Code/Editor/Util/FileUtil.cpp b/Code/Editor/Util/FileUtil.cpp index f5535f5590..3157a04bd8 100644 --- a/Code/Editor/Util/FileUtil.cpp +++ b/Code/Editor/Util/FileUtil.cpp @@ -2217,15 +2217,14 @@ uint32 CFileUtil::GetAttributes(const char* filename, bool bUseSourceControl /*= return SCC_FILE_ATTRIBUTE_READONLY | SCC_FILE_ATTRIBUTE_INPAK; } - AZStd::wstring fileW; - AZStd::to_wstring(fileW, file.GetAdjustedFilename()); - DWORD dwAttrib = ::GetFileAttributesW(fileW.c_str()); - if (dwAttrib == INVALID_FILE_ATTRIBUTES) + + const char* adjustedFile = file.GetAdjustedFilename(); + if (!AZ::IO::SystemFile::Exists(adjustedFile)) { return SCC_FILE_ATTRIBUTE_INVALID; } - if (dwAttrib & FILE_ATTRIBUTE_READONLY) + if (!AZ::IO::SystemFile::IsWritable(adjustedFile)) { return SCC_FILE_ATTRIBUTE_NORMAL | SCC_FILE_ATTRIBUTE_READONLY; } diff --git a/Code/Editor/Util/PathUtil.cpp b/Code/Editor/Util/PathUtil.cpp index e91d85e4d2..2f99f42188 100644 --- a/Code/Editor/Util/PathUtil.cpp +++ b/Code/Editor/Util/PathUtil.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -203,16 +204,7 @@ namespace Path bool IsFolder(const char* pPath) { - AZStd::wstring pPathW; - AZStd::to_wstring(pPathW, pPath); - DWORD attrs = GetFileAttributes(pPathW.c_str()); - - if (attrs == FILE_ATTRIBUTE_DIRECTORY) - { - return true; - } - - return false; + return AZ::IO::FileIOBase::GetInstance()->IsDirectory(pPath); } ////////////////////////////////////////////////////////////////////////// @@ -256,7 +248,6 @@ namespace Path static AZStd::string s_currentModName; // query the editor root. The bus exists in case we want tools to be able to override this. - if (s_currentModName.empty()) { return GetGameAssetsFolder(); diff --git a/Code/Editor/Util/PathUtil.h b/Code/Editor/Util/PathUtil.h index 30887e698b..4ea30d1f74 100644 --- a/Code/Editor/Util/PathUtil.h +++ b/Code/Editor/Util/PathUtil.h @@ -106,7 +106,7 @@ namespace Path path = path_buffer; _makepath_s(path_buffer, AZ_ARRAY_SIZE(path_buffer), 0, 0, fname, ext); #else - _splitpath(filepath, drive, dir, fname, ext); + _splitpath(filepath.c_str(), drive, dir, fname, ext); _makepath(path_buffer, drive, dir, 0, 0); path = path_buffer; _makepath(path_buffer, 0, 0, fname, ext); @@ -148,7 +148,7 @@ namespace Path _splitpath_s(filepath.c_str(), drive, AZ_ARRAY_SIZE(drive), dir, AZ_ARRAY_SIZE(dir), fname, AZ_ARRAY_SIZE(fname), ext, AZ_ARRAY_SIZE(ext)); _makepath_s(path_buffer, AZ_ARRAY_SIZE(path_buffer), drive, dir, 0, 0); #else - _splitpath(filepath, drive, dir, fname, ext); + _splitpath(filepath.c_str(), drive, dir, fname, ext); _makepath(path_buffer, drive, dir, 0, 0); #endif path = path_buffer; diff --git a/Code/Editor/Util/StringHelpers.cpp b/Code/Editor/Util/StringHelpers.cpp index a1e2b4ae08..6c819270bd 100644 --- a/Code/Editor/Util/StringHelpers.cpp +++ b/Code/Editor/Util/StringHelpers.cpp @@ -15,7 +15,7 @@ int StringHelpers::CompareIgnoreCase(const AZStd::string& str0, const AZStd::string& str1) { const size_t minLength = Util::getMin(str0.length(), str1.length()); - const int result = azmemicmp(str0.c_str(), str1.c_str(), minLength); + const int result = azstrnicmp(str0.c_str(), str1.c_str(), minLength); if (result) { return result; diff --git a/Code/Editor/Util/StringHelpers.h b/Code/Editor/Util/StringHelpers.h index 0e393e92dd..b5c84d7fe3 100644 --- a/Code/Editor/Util/StringHelpers.h +++ b/Code/Editor/Util/StringHelpers.h @@ -11,6 +11,9 @@ #define CRYINCLUDE_CRYCOMMONTOOLS_STRINGHELPERS_H #pragma once +#include +#include + namespace StringHelpers { // compares two strings to see if they are the same or different, case is ignored diff --git a/Code/Framework/AzCore/AzCore/base.h b/Code/Framework/AzCore/AzCore/base.h index 252133e781..00fdbf515e 100644 --- a/Code/Framework/AzCore/AzCore/base.h +++ b/Code/Framework/AzCore/AzCore/base.h @@ -51,74 +51,72 @@ # define azvscprintf(_format, _va_list) _vscprintf(_format, _va_list) # define azscwprintf _scwprintf # define azvscwprintf _vscwprintf -# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context) -# define azstrcat strcat_s -# define azstrncat strncat_s -# define strtoll _strtoi64 -# define strtoull _strtoui64 -# define azsscanf sscanf_s -# define azstrcpy strcpy_s -# define azstrncpy strncpy_s -# define azstricmp _stricmp -# define azstrnicmp _strnicmp -# define azisfinite _finite -# define azltoa _ltoa_s -# define azitoa _itoa_s -# define azui64toa _ui64toa_s -# define azswscanf swscanf_s -# define azwcsicmp _wcsicmp -# define azwcsnicmp _wcsnicmp -# define azmemicmp _memicmp +# define azstrtok(_buffer, _size, _delim, _context) strtok_s(_buffer, _delim, _context) +# define azstrcat(_dest, _destSize, _src) strcat_s(_dest, _destSize, _src) +# define azstrncat(_dest, _destSize, _src, _count) strncat_s(_dest, _destSize, _src, _count) +# define strtoll _strtoi64 +# define strtoull _strtoui64 +# define azsscanf sscanf_s +# define azstrcpy(_dest, _destSize, _src) strcpy_s(_dest, _destSize, _src) +# define azstrncpy(_dest, _destSize, _src, _count) strncpy_s(_dest, _destSize, _src, _count) +# define azstricmp _stricmp +# define azstrnicmp _strnicmp +# define azisfinite _finite +# define azltoa _ltoa_s +# define azitoa _itoa_s +# define azui64toa _ui64toa_s +# define azswscanf swscanf_s +# define azwcsicmp _wcsicmp +# define azwcsnicmp _wcsnicmp // note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure. -# define azfopen fopen_s +# define azfopen(_fp, _filename, _attrib) fopen_s(_fp, _filename, _attrib) # define azfscanf fscanf_s -# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__) -# define azstrlwr _strlwr_s -# define azvsprintf vsprintf_s -# define azwcscpy wcscpy_s -# define azstrtime _strtime_s -# define azstrdate _strdate_s -# define azlocaltime(time, result) localtime_s(result, time) +# define azsprintf(_buffer, ...) sprintf_s(_buffer, AZ_ARRAY_SIZE(_buffer), __VA_ARGS__) +# define azstrlwr _strlwr_s +# define azvsprintf vsprintf_s +# define azwcscpy wcscpy_s +# define azstrtime _strtime_s +# define azstrdate _strdate_s +# define azlocaltime(time, result) localtime_s(result, time) #else -# define azsnprintf snprintf -# define azvsnprintf vsnprintf +# define azsnprintf snprintf +# define azvsnprintf vsnprintf # if AZ_TRAIT_COMPILER_DEFINE_AZSWNPRINTF_AS_SWPRINTF -# define azsnwprintf swprintf -# define azvsnwprintf vswprintf +# define azsnwprintf swprintf +# define azvsnwprintf vswprintf # else -# define azsnwprintf snwprintf -# define azvsnwprintf vsnwprintf +# define azsnwprintf snwprintf +# define azvsnwprintf vsnwprintf # endif -# define azscprintf(...) azsnprintf(nullptr, static_cast(0), __VA_ARGS__); -# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast(0), _format, _va_list); -# define azscwprintf(...) azsnwprintf(nullptr, static_cast(0), __VA_ARGS__); -# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast(0), _format, _va_list); -# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim) -# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src) -# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count) -# define azsscanf sscanf -# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src) -# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count) -# define azstricmp strcasecmp -# define azstrnicmp strncasecmp +# define azscprintf(...) azsnprintf(nullptr, static_cast(0), __VA_ARGS__); +# define azvscprintf(_format, _va_list) azvsnprintf(nullptr, static_cast(0), _format, _va_list); +# define azscwprintf(...) azsnwprintf(nullptr, static_cast(0), __VA_ARGS__); +# define azvscwprintf(_format, _va_list) azvsnwprintf(nullptr, static_cast(0), _format, _va_list); +# define azstrtok(_buffer, _size, _delim, _context) strtok(_buffer, _delim) +# define azstrcat(_dest, _destSize, _src) strcat(_dest, _src) +# define azstrncat(_dest, _destSize, _src, _count) strncat(_dest, _src, _count) +# define azsscanf sscanf +# define azstrcpy(_dest, _destSize, _src) strcpy(_dest, _src) +# define azstrncpy(_dest, _destSize, _src, _count) strncpy(_dest, _src, _count) +# define azstricmp strcasecmp +# define azstrnicmp strncasecmp # if defined(NDK_REV_MAJOR) && NDK_REV_MAJOR < 16 -# define azisfinite __isfinitef +# define azisfinite __isfinitef # else -# define azisfinite isfinite +# define azisfinite isfinite # endif -# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix) -# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix) -# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix) -# define azswscanf swscanf -# define azwcsicmp wcsicmp -# define azwcsnicmp wcsnicmp -# define azmemicmp memicmp +# define azltoa(_value, _buffer, _size, _radix) ltoa(_value, _buffer, _radix) +# define azitoa(_value, _buffer, _size, _radix) itoa(_value, _buffer, _radix) +# define azui64toa(_value, _buffer, _size, _radix) _ui64toa(_value, _buffer, _radix) +# define azswscanf swscanf +# define azwcsicmp wcscasecmp +# define azwcsnicmp wcsnicmp // note: for cross-platform compatibility, do not use the return value of azfopen. On Windows, it's an errno_t and 0 indicates success. On other platforms, the return value is a FILE*, and a 0 value indicates failure. -# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib) -# define azfscanf fscanf +# define azfopen(_fp, _filename, _attrib) *(_fp) = fopen(_filename, _attrib) +# define azfscanf fscanf # define azsprintf sprintf # define azstrlwr(_buffer, _size) strlwr(_buffer) diff --git a/Code/Framework/AzCore/AzCore/std/string/conversions.h b/Code/Framework/AzCore/AzCore/std/string/conversions.h index fcfe82ba5f..91af1029b4 100644 --- a/Code/Framework/AzCore/AzCore/std/string/conversions.h +++ b/Code/Framework/AzCore/AzCore/std/string/conversions.h @@ -30,6 +30,8 @@ namespace AZStd template struct WCharTPlatformConverter { + static_assert(Size == size_t{ 2 } || Size == size_t{ 4 }, "only wchar_t types of size 2 or 4 can be converted to utf8"); + template static inline void to_string(AZStd::basic_string& dest, const wchar_t* first, const wchar_t* last) { @@ -41,12 +43,6 @@ namespace AZStd { Utf8::Unchecked::utf32to8(first, last, AZStd::back_inserter(dest), dest.max_size()); } - else - { - // Workaround to defer static_assert evaluation until this function is invoked by using the template parameter - using StringType = AZStd::basic_string; - static_assert(!AZStd::is_same_v, "only wchar_t types of size 2 or 4 can be converted to utf8"); - } } template @@ -60,12 +56,6 @@ namespace AZStd { Utf8::Unchecked::utf32to8(first, last, AZStd::back_inserter(dest), dest.max_size()); } - else - { - // Workaround to defer static_assert evaluation until this function is invoked by using the template parameter - using StringType = AZStd::basic_string; - static_assert(!AZStd::is_same_v, "only wchar_t types of size 2 or 4 can be converted to utf8"); - } } static inline void to_string(char* dest, size_t destSize, const wchar_t* first, const wchar_t* last) @@ -78,10 +68,6 @@ namespace AZStd { Utf8::Unchecked::utf32to8(first, last, dest, destSize); } - else - { - static_assert(false, "only wchar_t types of size 2 or 4 can be converted to utf8"); - } } template @@ -95,12 +81,6 @@ namespace AZStd { Utf8::Unchecked::utf8to32(first, last, AZStd::back_inserter(dest), dest.max_size()); } - else - { - // Workaround to defer static_assert evaluation until this function is invoked by using the template parameter - using StringType = AZStd::basic_string; - static_assert(!AZStd::is_same_v, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4"); - } } template @@ -114,12 +94,6 @@ namespace AZStd { Utf8::Unchecked::utf8to32(first, last, AZStd::back_inserter(dest), dest.max_size()); } - else - { - // Workaround to defer static_assert evaluation until this function is invoked by using the template parameter - using StringType = AZStd::basic_string; - static_assert(!AZStd::is_same_v, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4"); - } } static inline void to_wstring(wchar_t* dest, size_t destSize, const char* first, const char* last) @@ -132,10 +106,6 @@ namespace AZStd { Utf8::Unchecked::utf8to32(first, last, dest, destSize); } - else - { - static_assert(false, "Cannot convert a utf8 string to a wchar_t that isn't size 2 or 4"); - } } }; } diff --git a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Utils/Utils_WinAPI.cpp b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Utils/Utils_WinAPI.cpp index c57f2b31f6..a4af19a2a4 100644 --- a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Utils/Utils_WinAPI.cpp +++ b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Utils/Utils_WinAPI.cpp @@ -30,9 +30,8 @@ namespace AZ result.m_pathIncludesFilename = true; // Platform specific get exe path: http://stackoverflow.com/a/1024937 // https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea - AZStd::wstring pathBuffer; - pathBuffer.resize(exeStorageSize); - const DWORD pathLen = GetModuleFileName(nullptr, pathBuffer.data(), static_cast(exeStorageSize)); + wchar_t pathBufferW[AZ_MAX_PATH_LEN] = { 0 }; + const DWORD pathLen = GetModuleFileNameW(nullptr, pathBufferW, static_cast(exeStorageSize)); const DWORD errorCode = GetLastError(); if (pathLen == exeStorageSize && errorCode == ERROR_INSUFFICIENT_BUFFER) { @@ -44,7 +43,7 @@ namespace AZ } else { - AZStd::to_string(exeStorageBuffer, exeStorageSize, pathBuffer.c_str()); + AZStd::to_string(exeStorageBuffer, exeStorageSize, pathBufferW); } return result; diff --git a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp b/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp index 58afebfb90..61957fced0 100644 --- a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp +++ b/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp @@ -20,7 +20,9 @@ namespace AZ char resolvedPath[AZ_MAX_PATH_LEN]; ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN); - DWORD fileAttributes = GetFileAttributesA(resolvedPath); + wchar_t resolvedPathW[AZ_MAX_PATH_LEN]; + AZStd::to_wstring(resolvedPathW, AZ_MAX_PATH_LEN, resolvedPath); + DWORD fileAttributes = GetFileAttributesW(resolvedPathW); if (fileAttributes == INVALID_FILE_ATTRIBUTES) { return false; @@ -174,7 +176,7 @@ namespace AZ bool LocalFileIO::IsAbsolutePath(const char* path) const { - char drive[16]; + char drive[16] = { 0 }; _splitpath_s(path, drive, 16, nullptr, 0, nullptr, 0, nullptr, 0); return strlen(drive) > 0; } diff --git a/Code/Legacy/CryCommon/CryFile.h b/Code/Legacy/CryCommon/CryFile.h index 0888216f9c..0d2dac7c16 100644 --- a/Code/Legacy/CryCommon/CryFile.h +++ b/Code/Legacy/CryCommon/CryFile.h @@ -221,7 +221,7 @@ inline CCryFile::~CCryFile() inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlagsEx) { char tempfilename[CRYFILE_MAX_PATH] = ""; - azstrcpy(tempfilename, filename); + azstrcpy(tempfilename, CRYFILE_MAX_PATH, filename); #if !defined (_RELEASE) if (gEnv && gEnv->IsEditor() && gEnv->pConsole) @@ -233,7 +233,7 @@ inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlag if (lowercasePaths) { const AZStd::string lowerString = PathUtil::ToLower(tempfilename); - azstrcpy(tempfilename, lowerString.c_str()); + azstrcpy(tempfilename, CRYFILE_MAX_PATH, lowerString.c_str()); } } } @@ -242,7 +242,7 @@ inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlag { Close(); } - azstrcpy(m_filename, tempfilename); + azstrcpy(m_filename, CRYFILE_MAX_PATH, tempfilename); if (m_pIArchive) { @@ -429,7 +429,7 @@ inline const char* CCryFile::GetAdjustedFilename() const // Returns standard path otherwise. if (gameUrl != &szAdjustedFile[0]) { - azstrcpy(szAdjustedFile, gameUrl); + azstrcpy(szAdjustedFile, AZ::IO::IArchive::MaxPath, gameUrl); } return szAdjustedFile; } diff --git a/Code/Legacy/CryCommon/CryListenerSet.h b/Code/Legacy/CryCommon/CryListenerSet.h index 6857cf7e5d..e5be89aa9f 100644 --- a/Code/Legacy/CryCommon/CryListenerSet.h +++ b/Code/Legacy/CryCommon/CryListenerSet.h @@ -418,7 +418,7 @@ inline size_t CListenerSet::MemSize() const size += sizeof(typename TAllocatedNameVec::value_type); for (typename TAllocatedNameVec::const_iterator iter(m_allocatedNames.begin()); iter != m_allocatedNames.end(); ++iter) { - size += iter->GetAllocatedMemory(); + size += iter->capacity() * sizeof(char) + sizeof(AZStd::string); } #endif diff --git a/Code/Legacy/CryCommon/CryName.h b/Code/Legacy/CryCommon/CryName.h index 8e62a52517..552391419a 100644 --- a/Code/Legacy/CryCommon/CryName.h +++ b/Code/Legacy/CryCommon/CryName.h @@ -397,11 +397,11 @@ inline bool CCryName::operator>(const CCryName& n) const inline bool operator==(const AZStd::string& s, const CCryName& n) { - return s == n; + return s == n.c_str(); } inline bool operator!=(const AZStd::string& s, const CCryName& n) { - return s != n; + return s != n.c_str(); } inline bool operator==(const char* s, const CCryName& n) @@ -545,11 +545,11 @@ inline bool CCryNameCRC::operator>(const CCryNameCRC& n) const inline bool operator==(const AZStd::string& s, const CCryNameCRC& n) { - return s == n; + return n == s.c_str(); } inline bool operator!=(const AZStd::string& s, const CCryNameCRC& n) { - return s != n; + return n != s.c_str(); } inline bool operator==(const char* s, const CCryNameCRC& n) diff --git a/Code/Legacy/CryCommon/CryPath.h b/Code/Legacy/CryCommon/CryPath.h index e01e7a2e4b..046006f738 100644 --- a/Code/Legacy/CryCommon/CryPath.h +++ b/Code/Legacy/CryCommon/CryPath.h @@ -419,7 +419,7 @@ namespace PathUtil //! Makes a fully specified file path from path and file name. inline stack_string Make(const stack_string& dir, const stack_string& filename, const stack_string& ext) { - AZStd::string path = filename; + AZStd::string path = filename.c_str(); AZ::StringFunc::Path::ReplaceExtension(path, ext.c_str()); path = AddSlash(dir.c_str()) + path; return stack_string(path.c_str()); diff --git a/Code/Legacy/CryCommon/ISerialize.h b/Code/Legacy/CryCommon/ISerialize.h index 84e665850f..d427e222bb 100644 --- a/Code/Legacy/CryCommon/ISerialize.h +++ b/Code/Legacy/CryCommon/ISerialize.h @@ -387,7 +387,7 @@ public: bool ValueChar(const char* name, char* buffer, int len) { - string temp; + AZStd::string temp; if (IsReading()) { Value(name, temp); @@ -400,7 +400,7 @@ public: } else { - temp = string(buffer, buffer + len); + temp = AZStd::string(buffer, buffer + len); Value(name, temp); } return true; diff --git a/Code/Legacy/CryCommon/Linux_Win32Wrapper.h b/Code/Legacy/CryCommon/Linux_Win32Wrapper.h index e47d16d1bc..6507d7c8ee 100644 --- a/Code/Legacy/CryCommon/Linux_Win32Wrapper.h +++ b/Code/Legacy/CryCommon/Linux_Win32Wrapper.h @@ -14,6 +14,8 @@ #include #include #include +#include + /* Memory block identification */ #define _FREE_BLOCK 0 #define _NORMAL_BLOCK 1 @@ -344,7 +346,7 @@ private: char m_DirectoryName[260]; //!< directory name, needed when getting file attributes on the fly char m_ToMatch[260]; //!< pattern to match with DIR* m_Dir; //!< directory handle - std::vector m_Entries; //!< all file entries in the current directories + std::vector m_Entries; //!< all file entries in the current directories public: inline __finddata64_t() diff --git a/Code/Legacy/CryCommon/WinBase.cpp b/Code/Legacy/CryCommon/WinBase.cpp index fe9c539569..74d383b88d 100644 --- a/Code/Legacy/CryCommon/WinBase.cpp +++ b/Code/Legacy/CryCommon/WinBase.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef APPLE #include @@ -77,8 +78,6 @@ unsigned int g_EnableMultipleAssert = 0;//set to something else than 0 if to ena #include #endif -#include "StringUtils.h" - #if AZ_TRAIT_COMPILER_DEFINE_FS_ERRNO_TYPE typedef int FS_ERRNO_TYPE; #if AZ_TRAIT_COMPILER_DEFINE_FS_STAT_TYPE @@ -349,23 +348,23 @@ void _makepath(char* path, const char* drive, const char* dir, const char* filen } if (dir && dir[0]) { - azstrcat(tmp, dir); + azstrcat(tmp, MAX_PATH, dir); ch = tmp[strlen(tmp) - 1]; if (ch != '/' && ch != '\\') { - azstrcat(tmp, "\\"); + azstrcat(tmp, MAX_PATH, "\\"); } } if (filename && filename[0]) { - azstrcat(tmp, filename); + azstrcat(tmp, MAX_PATH, filename); if (ext && ext[0]) { if (ext[0] != '.') { - azstrcat(tmp, "."); + azstrcat(tmp, MAX_PATH, "."); } - azstrcat(tmp, ext); + azstrcat(tmp, MAX_PATH, ext); } } azstrcpy(path, strlen(tmp) + 1, tmp); @@ -489,9 +488,9 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext typedef AZStd::fixed_string path_stack_string; const path_stack_string inPath(inpath); - string::size_type s = inPath.rfind('/', inPath.size());//position of last / + AZStd::string::size_type s = inPath.rfind('/', inPath.size());//position of last / path_stack_string fName; - if (s == string::npos) + if (s == AZStd::string::npos) { if (dir) { @@ -503,9 +502,9 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext { if (dir) { - azstrcpy(dir, AZ_MAX_PATH_LEN, (inPath.substr((string::size_type)0, (string::size_type)(s + 1))).c_str()); //assign directory + azstrcpy(dir, AZ_MAX_PATH_LEN, (inPath.substr((AZStd::string::size_type)0, (AZStd::string::size_type)(s + 1))).c_str()); //assign directory } - fName = inPath.substr((string::size_type)(s + 1)); //assign remaining string as rest + fName = inPath.substr((AZStd::string::size_type)(s + 1)); //assign remaining string as rest } if (fName.size() == 0) { @@ -521,8 +520,8 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext else { //dir and drive are now set - s = fName.find(".", (string::size_type)0);//position of first . - if (s == string::npos) + s = fName.find(".", (AZStd::string::size_type)0);//position of first . + if (s == AZStd::string::npos) { if (ext) { @@ -547,7 +546,7 @@ void _splitpath(const char* inpath, char* drv, char* dir, char* fname, char* ext } else { - azstrcpy(fname, AZ_MAX_PATH_LEN, (fName.substr((string::size_type)0, s)).c_str()); //assign filename + azstrcpy(fname, AZ_MAX_PATH_LEN, (fName.substr((AZStd::string::size_type)0, s)).c_str()); //assign filename } } } @@ -779,17 +778,17 @@ BOOL SystemTimeToFileTime(const SYSTEMTIME* syst, LPFILETIME ft) return TRUE; } -void adaptFilenameToLinux(string& rAdjustedFilename) +void adaptFilenameToLinux(AZStd::string& rAdjustedFilename) { //first replace all \\ by / - string::size_type loc = 0; - while ((loc = rAdjustedFilename.find("\\", loc)) != string::npos) + AZStd::string::size_type loc = 0; + while ((loc = rAdjustedFilename.find("\\", loc)) != AZStd::string::npos) { rAdjustedFilename.replace(loc, 1, "/"); } loc = 0; //remove /./ - while ((loc = rAdjustedFilename.find("/./", loc)) != string::npos) + while ((loc = rAdjustedFilename.find("/./", loc)) != AZStd::string::npos) { rAdjustedFilename.replace(loc, 3, "/"); } @@ -798,16 +797,16 @@ void adaptFilenameToLinux(string& rAdjustedFilename) void replaceDoublePathFilename(char* szFileName) { //replace "\.\" by "\" - string s(szFileName); - string::size_type loc = 0; + AZStd::string s(szFileName); + AZStd::string::size_type loc = 0; //remove /./ - while ((loc = s.find("/./", loc)) != string::npos) + while ((loc = s.find("/./", loc)) != AZStd::string::npos) { s.replace(loc, 3, "/"); } loc = 0; //remove "\.\" - while ((loc = s.find("\\.\\", loc)) != string::npos) + while ((loc = s.find("\\.\\", loc)) != AZStd::string::npos) { s.replace(loc, 3, "\\"); } @@ -817,8 +816,8 @@ void replaceDoublePathFilename(char* szFileName) const int comparePathNames(const char* cpFirst, const char* cpSecond, unsigned int len) { //create two strings and replace the \\ by / and /./ by / - string first(cpFirst); - string second(cpSecond); + AZStd::string first(cpFirst); + AZStd::string second(cpSecond); adaptFilenameToLinux(first); adaptFilenameToLinux(second); if (strlen(cpFirst) < len || strlen(cpSecond) < len) @@ -1618,14 +1617,16 @@ const bool GetFilenameNoCase return true; } -DWORD GetFileAttributes(LPCSTR lpFileName) +DWORD GetFileAttributes(LPCWSTR lpFileNameW) { + AZStd::string lpFileName; + AZStd::to_string(lpFileName, lpFileNameW); struct stat fileStats; - const int success = stat(lpFileName, &fileStats); + const int success = stat(lpFileName.c_str(), &fileStats); if (success == -1) { char adjustedFilename[MAX_PATH]; - GetFilenameNoCase(lpFileName, adjustedFilename); + GetFilenameNoCase(lpFileName.c_str(), adjustedFilename); if (stat(adjustedFilename, &fileStats) == -1) { return (DWORD)INVALID_FILE_ATTRIBUTES; @@ -1648,7 +1649,7 @@ DWORD GetFileAttributes(LPCSTR lpFileName) uint32 CryGetFileAttributes(const char* lpFileName) { - string fn = lpFileName; + AZStd::string fn = lpFileName; adaptFilenameToLinux(fn); const char* buffer = fn.c_str(); return GetFileAttributes(buffer); diff --git a/Code/Legacy/CrySystem/DebugCallStack.cpp b/Code/Legacy/CrySystem/DebugCallStack.cpp index 289d4070ff..c0923341ad 100644 --- a/Code/Legacy/CrySystem/DebugCallStack.cpp +++ b/Code/Legacy/CrySystem/DebugCallStack.cpp @@ -435,18 +435,18 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) { const char* const szMessage = m_bIsFatalError ? s_szFatalErrorCode : m_szBugMessage; excName = szMessage; - azstrcpy(excCode, szMessage); - azstrcpy(excAddr, ""); - azstrcpy(desc, ""); - azstrcpy(m_excModule, ""); - azstrcpy(excDesc, szMessage); + azstrcpy(excCode, AZ_ARRAY_SIZE(excCode), szMessage); + azstrcpy(excAddr, AZ_ARRAY_SIZE(excAddr), ""); + azstrcpy(desc, AZ_ARRAY_SIZE(desc), ""); + azstrcpy(m_excModule, AZ_ARRAY_SIZE(m_excModule), ""); + azstrcpy(excDesc, AZ_ARRAY_SIZE(excDesc), szMessage); } else { sprintf_s(excAddr, "0x%04X:0x%p", pex->ContextRecord->SegCs, pex->ExceptionRecord->ExceptionAddress); sprintf_s(excCode, "0x%08X", pex->ExceptionRecord->ExceptionCode); excName = TranslateExceptionCode(pex->ExceptionRecord->ExceptionCode); - azstrcpy(desc, ""); + azstrcpy(desc, AZ_ARRAY_SIZE(desc), ""); sprintf_s(excDesc, "%s\r\n%s", excName, desc); @@ -476,9 +476,9 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) WriteLineToLog("Exception Description: %s", desc); - azstrcpy(m_excDesc, excDesc); - azstrcpy(m_excAddr, excAddr); - azstrcpy(m_excCode, excCode); + azstrcpy(m_excDesc, AZ_ARRAY_SIZE(m_excDesc), excDesc); + azstrcpy(m_excAddr, AZ_ARRAY_SIZE(m_excAddr), excAddr); + azstrcpy(m_excCode, AZ_ARRAY_SIZE(m_excCode), excCode); char errs[32768]; @@ -504,7 +504,7 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) dumpCallStack(funcs); // Fill call stack. char str[s_iCallStackSize]; - azstrcpy(str, ""); + azstrcpy(str, AZ_ARRAY_SIZE(str), ""); for (unsigned int i = 0; i < funcs.size(); i++) { char temp[s_iCallStackSize]; @@ -514,7 +514,7 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) azstrcat(errs, temp); azstrcat(errs, "\n"); } - azstrcpy(m_excCallstack, str); + azstrcpy(m_excCallstack, AZ_ARRAY_SIZE(m_excCallstack), str); } azstrcat(errorString, errs); diff --git a/Code/Legacy/CrySystem/IDebugCallStack.cpp b/Code/Legacy/CrySystem/IDebugCallStack.cpp index bee43b237b..1176c15f0e 100644 --- a/Code/Legacy/CrySystem/IDebugCallStack.cpp +++ b/Code/Legacy/CrySystem/IDebugCallStack.cpp @@ -237,7 +237,7 @@ void IDebugCallStack::WriteLineToLog(const char* format, ...) char szBuffer[MAX_WARNING_LENGTH]; va_start(ArgList, format); vsnprintf_s(szBuffer, sizeof(szBuffer), sizeof(szBuffer) - 1, format, ArgList); - azstrcat(szBuffer, "\n"); + azstrcat(szBuffer, MAX_WARNING_LENGTH, "\n"); szBuffer[sizeof(szBuffer) - 1] = '\0'; va_end(ArgList); diff --git a/Code/Legacy/CrySystem/IDebugCallStack.h b/Code/Legacy/CrySystem/IDebugCallStack.h index a2c1d3f5e2..1a65fbbdb7 100644 --- a/Code/Legacy/CrySystem/IDebugCallStack.h +++ b/Code/Legacy/CrySystem/IDebugCallStack.h @@ -41,11 +41,7 @@ public: filename = "[unknown]"; line = 0; baseAddr = addr; -#if defined(PLATFORM_64BIT) - procName = AZStd::string::format("[%016llX]", addr); -#else - procName = AZStd::string::format("[%08X]", addr); -#endif + procName = AZStd::string::format("[%p]", addr); } // returns current filename diff --git a/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp b/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp index 3e6432a721..d21fff3dd3 100644 --- a/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp +++ b/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp @@ -567,7 +567,7 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName) INDENT_LOG_DURING_SCOPE(); char levelName[256]; - azstrcpy(levelName, _levelName); + azstrcpy(levelName, AZ_ARRAY_SIZE(levelName), _levelName); // Not remove a scope!!! { diff --git a/Code/Legacy/CrySystem/LocalizedStringManager.cpp b/Code/Legacy/CrySystem/LocalizedStringManager.cpp index 42bdb3afef..cffe1c38c6 100644 --- a/Code/Legacy/CrySystem/LocalizedStringManager.cpp +++ b/Code/Legacy/CrySystem/LocalizedStringManager.cpp @@ -2762,7 +2762,7 @@ void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool const size_t bufSize = sizeof(buf) / sizeof(buf[0]); wcsftime(buf, bufSize, bShowSeconds ? L"%#X" : L"%X", &theTime); buf[bufSize - 1] = 0; - Unicode::Convert(outTimeString, buf); + AZStd::to_string(outTimeString, buf); } void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString) @@ -2790,7 +2790,7 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool const wchar_t* format = bShort ? (bIncludeWeekday ? L"%a %x" : L"%x") : L"%#x"; // long format always contains Weekday name wcsftime(buf, bufSize, format, &theTime); buf[bufSize - 1] = 0; - Unicode::Convert(outDateString, buf); + AZStd::to_string(outDateString, buf); } diff --git a/Code/Legacy/CrySystem/Log.cpp b/Code/Legacy/CrySystem/Log.cpp index 6ee6af6c22..0385ff8eb3 100644 --- a/Code/Legacy/CrySystem/Log.cpp +++ b/Code/Legacy/CrySystem/Log.cpp @@ -508,7 +508,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo stack_string s = szBuffer; s += "\t "; s += sAssetScope; - azstrcpy(szBuffer, s.c_str()); + azstrcpy(szBuffer, AZ_ARRAY_SIZE(szBuffer), s.c_str()); } } @@ -531,7 +531,7 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo } } i = m_iLastHistoryItem = m_iLastHistoryItem + 1 & sz - 1; - azstrcpy(m_history[i].str, m_history[i].ptr = szSpamCheck); + azstrcpy(m_history[i].str, AZ_ARRAY_SIZE(m_history[i].str), m_history[i].ptr = szSpamCheck); m_history[i].type = type; m_history[i].time = time; } @@ -862,7 +862,7 @@ bool CLog::LogToMainThread(const char* szString, ELogType logType, bool bAdd, SL { // When logging from other thread then main, push all log strings to queue. SLogMsg msg; - azstrcpy(msg.msg, szString); + azstrcpy(msg.msg, AZ_ARRAY_SIZE(msg.msg), szString); msg.bAdd = bAdd; msg.destination = destination; msg.logType = logType; @@ -1277,7 +1277,7 @@ void CLog::CreateBackupFile() const AZStd::string bakdest = PathUtil::Make(LOG_BACKUP_PATH, sFileWithoutExt + sBackupNameAttachment + "." + sExt); fileSystem->CreatePath(LOG_BACKUP_PATH); - azstrcpy(m_sBackupFilename, bakdest.c_str()); + azstrcpy(m_sBackupFilename, AZ_ARRAY_SIZE(m_sBackupFilename), bakdest.c_str()); // Remove any existing backup file with the same name first since the copy will fail otherwise. fileSystem->Remove(m_sBackupFilename); fileSystem->Copy(m_szFilename, bakdest.c_str()); diff --git a/Code/Legacy/CrySystem/SystemWin32.cpp b/Code/Legacy/CrySystem/SystemWin32.cpp index 9fd01f1905..66be2a2ca5 100644 --- a/Code/Legacy/CrySystem/SystemWin32.cpp +++ b/Code/Legacy/CrySystem/SystemWin32.cpp @@ -282,7 +282,7 @@ static const char* GetLastSystemErrorMessage() 0, NULL)) { - azstrcpy(szBuffer, (char*)lpMsgBuf); + azstrcpy(szBuffer, AZ_ARRAY_SIZE(szBuffer), (char*)lpMsgBuf); LocalFree(lpMsgBuf); } else diff --git a/Code/Legacy/CrySystem/XConsole.cpp b/Code/Legacy/CrySystem/XConsole.cpp index 252ab8137d..6da42420f8 100644 --- a/Code/Legacy/CrySystem/XConsole.cpp +++ b/Code/Legacy/CrySystem/XConsole.cpp @@ -1547,31 +1547,31 @@ const char* CXConsole::GetFlagsString(const uint32 dwFlags) // hiding this makes it a bit more difficult for cheaters // if(dwFlags&VF_CHEAT) azstrcat( sFlags,"CHEAT, "); - azstrcpy(sFlags, ""); + azstrcpy(sFlags, AZ_ARRAY_SIZE(sFlags), ""); if (dwFlags & VF_READONLY) { - azstrcat(sFlags, "READONLY, "); + azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "READONLY, "); } if (dwFlags & VF_DEPRECATED) { - azstrcat(sFlags, "DEPRECATED, "); + azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "DEPRECATED, "); } if (dwFlags & VF_DUMPTODISK) { - azstrcat(sFlags, "DUMPTODISK, "); + azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "DUMPTODISK, "); } if (dwFlags & VF_REQUIRE_LEVEL_RELOAD) { - azstrcat(sFlags, "REQUIRE_LEVEL_RELOAD, "); + azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "REQUIRE_LEVEL_RELOAD, "); } if (dwFlags & VF_REQUIRE_APP_RESTART) { - azstrcat(sFlags, "REQUIRE_APP_RESTART, "); + azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "REQUIRE_APP_RESTART, "); } if (dwFlags & VF_RESTRICTEDMODE) { - azstrcat(sFlags, "RESTRICTEDMODE, "); + azstrcat(sFlags, AZ_ARRAY_SIZE(sFlags), "RESTRICTEDMODE, "); } if (sFlags[0] != 0) @@ -3325,7 +3325,7 @@ const char* CXConsole::AutoComplete(const char* substr) const char* szCmd = cmds[i]; size_t cmdlen = strlen(szCmd); - if (cmdlen >= substrLen && azmemicmp(szCmd, substr, substrLen) == 0) + if (cmdlen >= substrLen && azstrnicmp(szCmd, substr, substrLen) == 0) { if (substrLen == cmdlen) { diff --git a/Code/Legacy/CrySystem/XML/XMLBinaryReader.cpp b/Code/Legacy/CrySystem/XML/XMLBinaryReader.cpp index e59f6b8969..c86c0691a9 100644 --- a/Code/Legacy/CrySystem/XML/XMLBinaryReader.cpp +++ b/Code/Legacy/CrySystem/XML/XMLBinaryReader.cpp @@ -32,7 +32,7 @@ const char* XMLBinary::XMLBinaryReader::GetErrorDescription() const void XMLBinary::XMLBinaryReader::SetErrorDescription(const char* text) { - azstrcpy(m_errorDescription, text); + azstrcpy(m_errorDescription, AZ_ARRAY_SIZE(m_errorDescription), text); } diff --git a/Code/Legacy/CrySystem/XML/XMLBinaryWriter.cpp b/Code/Legacy/CrySystem/XML/XMLBinaryWriter.cpp index 81994b26e0..7fd9df30c9 100644 --- a/Code/Legacy/CrySystem/XML/XMLBinaryWriter.cpp +++ b/Code/Legacy/CrySystem/XML/XMLBinaryWriter.cpp @@ -99,7 +99,7 @@ bool XMLBinary::CXMLBinaryWriter::WriteNode(IDataWriter* pFile, XmlNodeRef node, static const uint nMaxNodeCount = (NodeIndex) ~0; if (m_nodes.size() > nMaxNodeCount) { - error = AZStd::string::format("XMLBinary: Too many nodes: %d (max is %i)", m_nodes.size(), nMaxNodeCount); + error = AZStd::string::format("XMLBinary: Too many nodes: %zu (max is %i)", m_nodes.size(), nMaxNodeCount); return false; } diff --git a/Code/Tools/GridHub/GridHub/gridhub.cpp b/Code/Tools/GridHub/GridHub/gridhub.cpp index 978589ab74..24dd440411 100644 --- a/Code/Tools/GridHub/GridHub/gridhub.cpp +++ b/Code/Tools/GridHub/GridHub/gridhub.cpp @@ -543,7 +543,7 @@ GridHubComponent::OnMemberJoined([[maybe_unused]] GridMate::GridSession* session case AZ::PlatformID::PLATFORM_WINDOWS_64: case AZ::PlatformID::PLATFORM_APPLE_MAC: { - GridMate::string localMachineName = GridMate::Utils::GetMachineAddress(); + AZStd::string localMachineName = GridMate::Utils::GetMachineAddress(); if( member->GetMachineName() == localMachineName ) { ExternalProcessMonitor mi; @@ -629,7 +629,7 @@ bool GridHubComponent::StartSession(bool isRestarting) AZ_Assert(GridMate::HasGridMateService(m_gridMate), "Failed to start multiplayer service for LAN!"); // if we get an address 169.X.X.X (AZCP is NOT ready) or 127.0.0.1 when network is not ready - GridMate::string machineIP = GridMate::Utils::GetMachineAddress(); + AZStd::string machineIP = GridMate::Utils::GetMachineAddress(); if( machineIP == "127.0.0.1" || machineIP.compare(0,4,"169.") == 0 ) { AZ_Warning("GridHub", false, "\nCurrent IP %s might be invalid.\n",machineIP.c_str()); diff --git a/Code/Tools/GridHub/GridHub/gridhub.hxx b/Code/Tools/GridHub/GridHub/gridhub.hxx index 468cf525a0..849dbb92e1 100644 --- a/Code/Tools/GridHub/GridHub/gridhub.hxx +++ b/Code/Tools/GridHub/GridHub/gridhub.hxx @@ -141,7 +141,7 @@ public: /// Callback that notifies the title when a session will be left. session pointer is NOT valid after the callback returns. void OnSessionDelete(GridMate::GridSession* session) override; /// Called when a session error occurs. - void OnSessionError(GridMate::GridSession* session, const GridMate::string& errorMsg ) { (void)session; (void)errorMsg; } + void OnSessionError(GridMate::GridSession* session, const AZStd::string& errorMsg ) { (void)session; (void)errorMsg; } /// Called when the actual game(match) starts void OnSessionStart(GridMate::GridSession* session) { (void)session; } /// Called when the actual game(match) ends diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/Process/TestImpactWin32_Process.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/Process/TestImpactWin32_Process.cpp index 2630a63bee..dd65722560 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/Process/TestImpactWin32_Process.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Platform/Windows/Process/TestImpactWin32_Process.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace TestImpact { @@ -55,9 +56,11 @@ namespace TestImpact CreatePipes(sa, si); - if (!CreateProcess( + AZStd::wstring argsW; + AZStd::to_wstring(argsW, args.c_str()); + if (!CreateProcessW( NULL, - &args[0], + argsW.c_str(), NULL, NULL, IsPiping(), diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp index ae0880e98e..a38736ff67 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp @@ -2362,10 +2362,10 @@ void CUiAnimViewDopeSheetBase::DrawKeys(CUiAnimViewTrack* pTrack, QPainter* pain } else { - azstrcpy(keydesc, "{"); + azstrcpy(keydesc, AZ_ARRAY_SIZE(keydesc), "{"); } - azstrcat(keydesc, pDescription); - azstrcat(keydesc, "}"); + azstrcat(keydesc, AZ_ARRAY_SIZE(keydesc), pDescription); + azstrcat(keydesc, AZ_ARRAY_SIZE(keydesc), "}"); // Draw key description text. // Find next key. const QRect textRect(QPoint(x + 10, rect.top()), QPoint(x1, rect.bottom())); diff --git a/Gems/LyShine/Code/Source/Platform/Common/Unimplemented/UiClipboard_Unimplemented.cpp b/Gems/LyShine/Code/Source/Platform/Common/Unimplemented/UiClipboard_Unimplemented.cpp index 744cb65ac8..9175c7b2be 100644 --- a/Gems/LyShine/Code/Source/Platform/Common/Unimplemented/UiClipboard_Unimplemented.cpp +++ b/Gems/LyShine/Code/Source/Platform/Common/Unimplemented/UiClipboard_Unimplemented.cpp @@ -8,16 +8,13 @@ // UiClipboard is responsible setting and getting clipboard data for the UI elements in a platform-independent way. #include "UiClipboard.h" -#include -bool UiClipboard::SetText(const AZStd::string& text) +bool UiClipboard::SetText([[maybe_unused]] const AZStd::string& text) { - AZ_UNUSED(text); return false; } AZStd::string UiClipboard::GetText() { - AZStd::string outText; - return outText; + return {}; } diff --git a/Gems/Maestro/Code/Source/Cinematics/CaptureTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/CaptureTrack.cpp index 60d578d1f8..f4faf4dbeb 100644 --- a/Gems/Maestro/Code/Source/Cinematics/CaptureTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/CaptureTrack.cpp @@ -52,7 +52,7 @@ void CCaptureTrack::GetKeyInfo(int key, const char*& description, float& duratio char prefix[64] = "Frame"; if (!m_keys[key].prefix.empty()) { - azstrcpy(prefix, m_keys[key].prefix.c_str()); + azstrcpy(prefix, AZ_ARRAY_SIZE(prefix), m_keys[key].prefix.c_str()); } description = buffer; if (!m_keys[key].folder.empty()) diff --git a/Gems/Maestro/Code/Source/Cinematics/CommentTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/CommentTrack.cpp index 1dd72de567..8c1baf4684 100644 --- a/Gems/Maestro/Code/Source/Cinematics/CommentTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/CommentTrack.cpp @@ -25,7 +25,7 @@ void CCommentTrack::GetKeyInfo(int key, const char*& description, float& duratio description = 0; duration = m_keys[key].m_duration; - azstrcpy(desc, m_keys[key].m_strComment.c_str()); + azstrcpy(desc, AZ_ARRAY_SIZE(desc), m_keys[key].m_strComment.c_str()); description = desc; } diff --git a/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp index 62de2dfdf5..884a90b200 100644 --- a/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp @@ -457,31 +457,31 @@ void CCompoundSplineTrack::GetKeyInfo(int key, const char*& description, float& { float dummy; m_subTracks[0]->GetKeyInfo(m, subDesc, dummy); - azstrcat(str, subDesc); + azstrcat(str, AZ_ARRAY_SIZE(str), subDesc); break; } } if (m == m_subTracks[0]->GetNumKeys()) { - azstrcat(str, m_subTrackNames[0].c_str()); + azstrcat(str, AZ_ARRAY_SIZE(str), m_subTrackNames[0].c_str()); } // Tail cases for (int i = 1; i < GetSubTrackCount(); ++i) { - azstrcat(str, ","); + azstrcat(str, AZ_ARRAY_SIZE(str), ","); for (m = 0; m < m_subTracks[i]->GetNumKeys(); ++m) { if (m_subTracks[i]->GetKeyTime(m) == time) { float dummy; m_subTracks[i]->GetKeyInfo(m, subDesc, dummy); - azstrcat(str, subDesc); + azstrcat(str, AZ_ARRAY_SIZE(str), subDesc); break; } } if (m == m_subTracks[i]->GetNumKeys()) { - azstrcat(str, m_subTrackNames[i].c_str()); + azstrcat(str, AZ_ARRAY_SIZE(str), m_subTrackNames[i].c_str()); } } } diff --git a/Gems/Maestro/Code/Source/Cinematics/EventTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/EventTrack.cpp index 36d468e36d..4d32a4a4a1 100644 --- a/Gems/Maestro/Code/Source/Cinematics/EventTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/EventTrack.cpp @@ -69,11 +69,11 @@ void CEventTrack::GetKeyInfo(int key, const char*& description, float& duration) CheckValid(); description = 0; duration = 0; - azstrcpy(desc, m_keys[key].event.c_str()); + azstrcpy(desc, AZ_ARRAY_SIZE(desc), m_keys[key].event.c_str()); if (!m_keys[key].eventValue.empty()) { - azstrcat(desc, ", "); - azstrcat(desc, m_keys[key].eventValue.c_str()); + azstrcat(desc, AZ_ARRAY_SIZE(desc), ", "); + azstrcat(desc, AZ_ARRAY_SIZE(desc), m_keys[key].eventValue.c_str()); } description = desc; diff --git a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp index 799747eb12..be6d18eeb2 100644 --- a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp @@ -916,8 +916,8 @@ void CAnimSceneNode::ApplyCameraKey(ISelectKey& key, SAnimContext& ec) void CAnimSceneNode::ApplyEventKey(IEventKey& key, [[maybe_unused]] SAnimContext& ec) { char funcName[1024]; - azstrcpy(funcName, "Event_"); - azstrcat(funcName, key.event.c_str()); + azstrcpy(funcName, AZ_ARRAY_SIZE(funcName), "Event_"); + azstrcat(funcName, AZ_ARRAY_SIZE(funcName), key.event.c_str()); gEnv->pMovieSystem->SendGlobalEvent(funcName); } diff --git a/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp index 3541fe718e..9ac19f91ea 100644 --- a/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp @@ -32,7 +32,7 @@ void CScreenFaderTrack::GetKeyInfo(int key, const char*& description, float& dur CheckValid(); description = 0; duration = m_keys[key].m_fadeTime; - azstrcpy(desc, m_keys[key].m_fadeType == IScreenFaderKey::eFT_FadeIn ? "In" : "Out"); + azstrcpy(desc, AZ_ARRAY_SIZE(desc), m_keys[key].m_fadeType == IScreenFaderKey::eFT_FadeIn ? "In" : "Out"); description = desc; } diff --git a/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.cpp index 25d709bcdc..83b141cfb2 100644 --- a/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.cpp @@ -143,11 +143,11 @@ void CTrackEventTrack::GetKeyInfo(int key, const char*& description, float& dura CheckValid(); description = 0; duration = 0; - azstrcpy(desc, m_keys[key].event.c_str()); + azstrcpy(desc, AZ_ARRAY_SIZE(desc), m_keys[key].event.c_str()); if (!m_keys[key].eventValue.empty()) { - azstrcat(desc, ", "); - azstrcat(desc, m_keys[key].eventValue.c_str()); + azstrcat(desc, AZ_ARRAY_SIZE(desc), ", "); + azstrcat(desc, AZ_ARRAY_SIZE(desc), m_keys[key].eventValue.c_str()); } description = desc;