mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
Cleanup c-style casts from Windows.cpp
This commit is contained in:
@@ -172,8 +172,8 @@ bool platform_get_steam_path(utf8* outPath, size_t outSize)
|
||||
return false;
|
||||
}
|
||||
|
||||
wSteamPath = (wchar_t*)malloc(size);
|
||||
result = RegQueryValueExW(hKey, L"SteamPath", nullptr, &type, (LPBYTE)wSteamPath, &size);
|
||||
wSteamPath = reinterpret_cast<wchar_t*>(malloc(size));
|
||||
result = RegQueryValueExW(hKey, L"SteamPath", nullptr, &type, reinterpret_cast<LPBYTE>(wSteamPath), &size);
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
auto utf8SteamPath = String::ToUtf8(wSteamPath);
|
||||
@@ -213,7 +213,7 @@ uint16_t platform_get_locale_language()
|
||||
{
|
||||
CHAR langCode[4];
|
||||
|
||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, (LPSTR)&langCode, sizeof(langCode)) == 0)
|
||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, reinterpret_cast<LPSTR>(&langCode), sizeof(langCode)) == 0)
|
||||
{
|
||||
return LANGUAGE_UNDEFINED;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ time_t platform_file_get_modified_time(const utf8* path)
|
||||
uint8_t platform_get_locale_currency()
|
||||
{
|
||||
CHAR currCode[4];
|
||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SINTLSYMBOL, (LPSTR)&currCode, sizeof(currCode)) == 0)
|
||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SINTLSYMBOL, reinterpret_cast<LPSTR>(&currCode), sizeof(currCode)) == 0)
|
||||
{
|
||||
return platform_get_currency_value(nullptr);
|
||||
}
|
||||
@@ -312,7 +312,8 @@ MeasurementFormat platform_get_locale_measurement_format()
|
||||
{
|
||||
UINT measurement_system;
|
||||
if (GetLocaleInfo(
|
||||
LOCALE_USER_DEFAULT, LOCALE_IMEASURE | LOCALE_RETURN_NUMBER, (LPSTR)&measurement_system, sizeof(measurement_system))
|
||||
LOCALE_USER_DEFAULT, LOCALE_IMEASURE | LOCALE_RETURN_NUMBER, reinterpret_cast<LPSTR>(&measurement_system),
|
||||
sizeof(measurement_system))
|
||||
== 0)
|
||||
{
|
||||
return MeasurementFormat::Metric;
|
||||
@@ -334,7 +335,10 @@ TemperatureUnit platform_get_locale_temperature_format()
|
||||
|
||||
// GetLocaleInfo will set fahrenheit to 1 if the locale on this computer
|
||||
// uses the United States measurement system or 0 otherwise.
|
||||
if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE | LOCALE_RETURN_NUMBER, (LPSTR)&fahrenheit, sizeof(fahrenheit)) == 0)
|
||||
if (GetLocaleInfo(
|
||||
LOCALE_USER_DEFAULT, LOCALE_IMEASURE | LOCALE_RETURN_NUMBER, reinterpret_cast<LPSTR>(&fahrenheit),
|
||||
sizeof(fahrenheit))
|
||||
== 0)
|
||||
{
|
||||
// Assume celsius by default if function call fails
|
||||
return TemperatureUnit::Celsius;
|
||||
@@ -351,7 +355,7 @@ uint8_t platform_get_locale_date_format()
|
||||
# if _WIN32_WINNT >= 0x0600
|
||||
// Retrieve short date format, eg "MM/dd/yyyy"
|
||||
wchar_t dateFormat[20];
|
||||
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SSHORTDATE, dateFormat, (int)std::size(dateFormat)) == 0)
|
||||
if (GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SSHORTDATE, dateFormat, static_cast<int>(std::size(dateFormat))) == 0)
|
||||
{
|
||||
return DATE_FORMAT_DAY_MONTH_YEAR;
|
||||
}
|
||||
@@ -446,7 +450,8 @@ std::string platform_get_absolute_path(const utf8* relativePath, const utf8* bas
|
||||
|
||||
auto pathToResolveW = String::ToWideChar(pathToResolve);
|
||||
wchar_t fullPathW[MAX_PATH]{};
|
||||
auto fullPathLen = GetFullPathNameW(pathToResolveW.c_str(), (DWORD)std::size(fullPathW), fullPathW, nullptr);
|
||||
auto fullPathLen = GetFullPathNameW(
|
||||
pathToResolveW.c_str(), static_cast<DWORD>(std::size(fullPathW)), fullPathW, nullptr);
|
||||
if (fullPathLen != 0)
|
||||
{
|
||||
result = String::ToUtf8(fullPathW);
|
||||
@@ -460,7 +465,8 @@ datetime64 platform_get_datetime_now_utc()
|
||||
// Get file time
|
||||
FILETIME fileTime;
|
||||
GetSystemTimeAsFileTime(&fileTime);
|
||||
uint64_t fileTime64 = ((uint64_t)fileTime.dwHighDateTime << 32ULL) | ((uint64_t)fileTime.dwLowDateTime);
|
||||
uint64_t fileTime64 = (static_cast<uint64_t>(fileTime.dwHighDateTime) << 32ULL)
|
||||
| (static_cast<uint64_t>(fileTime.dwLowDateTime));
|
||||
|
||||
// File time starts from: 1601-01-01T00:00:00Z
|
||||
// Convert to start from: 0001-01-01T00:00:00Z
|
||||
|
||||
Reference in New Issue
Block a user