Code/Legacy cleanup
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#include <IMovieSystem.h>
|
||||
#include <ILog.h>
|
||||
#include <CryLibrary.h>
|
||||
#include <StringUtils.h>
|
||||
#include <AzCore/Debug/StackTracer.h>
|
||||
#include <AzCore/IO/SystemFile.h> // for AZ_MAX_PATH_LEN
|
||||
#include <AzCore/std/allocator_stack.h>
|
||||
@@ -127,7 +126,7 @@ const char* CSystem::GetUserName()
|
||||
DWORD dwSize = iNameBufferSize;
|
||||
wchar_t nameW[iNameBufferSize];
|
||||
::GetUserNameW(nameW, &dwSize);
|
||||
azstrcpy(szNameBuffer, CryStringUtils::WStrToUTF8(nameW));
|
||||
AZStd::to_string(szNameBuffer, iNameBufferSize, nameW, dwSize);
|
||||
return szNameBuffer;
|
||||
#else
|
||||
#if defined(LINUX)
|
||||
@@ -171,12 +170,12 @@ int CSystem::GetApplicationInstance()
|
||||
// this code below essentially "locks" an instance of the USER folder to a specific running application
|
||||
if (m_iApplicationInstance == -1)
|
||||
{
|
||||
string suffix;
|
||||
AZStd::wstring suffix;
|
||||
for (int instance = 0;; ++instance)
|
||||
{
|
||||
suffix.Format("(%d)", instance);
|
||||
suffix = AZStd::wstring::format(L"LumberyardApplication(%d)", instance);
|
||||
|
||||
CreateMutex(NULL, TRUE, "LumberyardApplication" + suffix);
|
||||
CreateMutexW(NULL, TRUE, suffix.c_str());
|
||||
// search for duplicates
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
@@ -195,13 +194,13 @@ int CSystem::GetApplicationInstance()
|
||||
int CSystem::GetApplicationLogInstance([[maybe_unused]] const char* logFilePath)
|
||||
{
|
||||
#if AZ_TRAIT_OS_USE_WINDOWS_MUTEX
|
||||
string suffix;
|
||||
AZStd::wstring suffix;
|
||||
int instance = 0;
|
||||
for (;; ++instance)
|
||||
{
|
||||
suffix.Format("(%d)", instance);
|
||||
suffix = AZStd::wstring::format(L"%s(%d)", logFilePath, instance);
|
||||
|
||||
CreateMutex(NULL, TRUE, logFilePath + suffix);
|
||||
CreateMutexW(NULL, TRUE, suffix.c_str());
|
||||
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
break;
|
||||
@@ -218,7 +217,7 @@ struct CryDbgModule
|
||||
{
|
||||
HANDLE heap;
|
||||
WIN_HMODULE handle;
|
||||
string name;
|
||||
AZStd::string name;
|
||||
DWORD dwSize;
|
||||
};
|
||||
|
||||
@@ -343,12 +342,15 @@ void CSystem::FatalError(const char* format, ...)
|
||||
assert(szBuffer[0] >= ' ');
|
||||
// strcpy(szBuffer,szBuffer+1); // remove verbosity tag since it is not supported by ::MessageBox
|
||||
|
||||
OutputDebugString(szBuffer);
|
||||
AZ::Debug::Platform::OutputToDebugger("CrySystem", szBuffer);
|
||||
|
||||
#ifdef WIN32
|
||||
OnFatalError(szBuffer);
|
||||
if (!g_cvars.sys_no_crash_dialog)
|
||||
{
|
||||
::MessageBox(NULL, szBuffer, "Open 3D Engine Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
|
||||
AZStd::wstring szBufferW;
|
||||
AZStd::to_wstring(szBufferW, szBuffer);
|
||||
::MessageBoxW(NULL, szBufferW.c_str(), L"Open 3D Engine Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
|
||||
}
|
||||
|
||||
// Dump callstack.
|
||||
@@ -461,20 +463,20 @@ bool CSystem::ReLaunchMediaCenter()
|
||||
}
|
||||
|
||||
// Get the path to Media Center
|
||||
char szExpandedPath[AZ_MAX_PATH_LEN];
|
||||
if (!ExpandEnvironmentStrings("%SystemRoot%\\ehome\\ehshell.exe", szExpandedPath, AZ_MAX_PATH_LEN))
|
||||
wchar_t szExpandedPath[AZ_MAX_PATH_LEN];
|
||||
if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\ehome\\ehshell.exe", szExpandedPath, AZ_MAX_PATH_LEN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Skip if ehshell.exe doesn't exist
|
||||
if (GetFileAttributes(szExpandedPath) == 0xFFFFFFFF)
|
||||
if (GetFileAttributesW(szExpandedPath) == 0xFFFFFFFF)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Launch ehshell.exe
|
||||
INT_PTR result = (INT_PTR)ShellExecute(NULL, TEXT("open"), szExpandedPath, NULL, NULL, SW_SHOWNORMAL);
|
||||
INT_PTR result = (INT_PTR)ShellExecuteW(NULL, TEXT("open"), szExpandedPath, NULL, NULL, SW_SHOWNORMAL);
|
||||
return (result > 32);
|
||||
}
|
||||
#else
|
||||
@@ -491,7 +493,7 @@ bool CSystem::GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize)
|
||||
bool bSucceeded = false;
|
||||
// check Vista and later OS first
|
||||
|
||||
HMODULE shell32 = LoadLibraryA("Shell32.dll");
|
||||
HMODULE shell32 = LoadLibraryW(L"Shell32.dll");
|
||||
if (shell32)
|
||||
{
|
||||
typedef long (__stdcall * T_SHGetKnownFolderPath)(REFKNOWNFOLDERID rfid, unsigned long dwFlags, void* hToken, wchar_t** ppszPath);
|
||||
@@ -505,7 +507,7 @@ bool CSystem::GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize)
|
||||
if (bSucceeded)
|
||||
{
|
||||
// Convert from UNICODE to UTF-8
|
||||
azstrcpy(szMyDocumentsPath, maxPathSize, CryStringUtils::WStrToUTF8(wMyDocumentsPath));
|
||||
AZStd::to_string(szMyDocumentsPath, maxPathSize, wMyDocumentsPath);
|
||||
CoTaskMemFree(wMyDocumentsPath);
|
||||
}
|
||||
}
|
||||
@@ -519,7 +521,7 @@ bool CSystem::GetWinGameFolder(char* szMyDocumentsPath, int maxPathSize)
|
||||
bSucceeded = SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, wMyDocumentsPath));
|
||||
if (bSucceeded)
|
||||
{
|
||||
azstrcpy(szMyDocumentsPath, maxPathSize, CryStringUtils::WStrToUTF8(wMyDocumentsPath));
|
||||
AZStd::to_string(szMyDocumentsPath, maxPathSize, wMyDocumentsPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +549,7 @@ void CSystem::DetectGameFolderAccessRights()
|
||||
BOOL bAccessStatus = FALSE;
|
||||
|
||||
// Get a pointer to the existing DACL.
|
||||
dwRes = GetNamedSecurityInfo(".", SE_FILE_OBJECT,
|
||||
dwRes = GetNamedSecurityInfoW(L".", SE_FILE_OBJECT,
|
||||
DACL_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION,
|
||||
NULL, NULL, &pDACL, NULL, &pSD);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user