Merge branch 'master' into jgrpp

# Conflicts:
#	src/cheat_gui.cpp
#	src/industry_gui.cpp
#	src/linkgraph/linkgraphschedule.cpp
#	src/misc/getoptdata.h
#	src/music/dmusic.cpp
#	src/network/core/os_abstraction.cpp
#	src/newgrf_engine.cpp
#	src/openttd.cpp
#	src/order_gui.cpp
#	src/os/windows/win32.cpp
#	src/pathfinder/npf/queue.cpp
#	src/smallmap_gui.cpp
#	src/strgen/strgen.cpp
This commit is contained in:
Jonathan G Rennison
2024-06-08 22:55:56 +01:00
31 changed files with 202 additions and 278 deletions

View File

@@ -22,7 +22,7 @@ static std::string GetLoadError()
wchar_t buffer[512];
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error_code,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, lengthof(buffer), nullptr) == 0) {
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, static_cast<DWORD>(std::size(buffer)), nullptr) == 0) {
return fmt::format("Unknown error {}", error_code);
}

View File

@@ -199,7 +199,7 @@ void FiosGetDrives(FileList &file_list)
wchar_t drives[256];
const wchar_t *s;
GetLogicalDriveStrings(lengthof(drives), drives);
GetLogicalDriveStrings(static_cast<DWORD>(std::size(drives)), drives);
for (s = drives; *s != '\0';) {
FiosItem *fios = &file_list.emplace_back();
fios->type = FIOS_TYPE_DRIVE;
@@ -419,7 +419,7 @@ void DetermineBasePaths(const char *exe)
/* Use the folder of the config file as working directory. */
wchar_t config_dir[MAX_PATH];
wcsncpy(path, convert_to_fs(_config_file, path, lengthof(path)), lengthof(path));
if (!GetFullPathName(path, lengthof(config_dir), config_dir, nullptr)) {
if (!GetFullPathName(path, static_cast<DWORD>(std::size(config_dir)), config_dir, nullptr)) {
DEBUG(misc, 0, "GetFullPathName failed (%lu)\n", GetLastError());
_searchpaths[SP_WORKING_DIR].clear();
} else {
@@ -431,13 +431,13 @@ void DetermineBasePaths(const char *exe)
}
}
if (!GetModuleFileName(nullptr, path, lengthof(path))) {
if (!GetModuleFileName(nullptr, path, static_cast<DWORD>(std::size(path)))) {
DEBUG(misc, 0, "GetModuleFileName failed (%lu)\n", GetLastError());
_searchpaths[SP_BINARY_DIR].clear();
} else {
wchar_t exec_dir[MAX_PATH];
wcsncpy(path, convert_to_fs(exe, path, lengthof(path)), lengthof(path));
if (!GetFullPathName(path, lengthof(exec_dir), exec_dir, nullptr)) {
wcsncpy(path, convert_to_fs(exe, path, std::size(path)), lengthof(path));
if (!GetFullPathName(path, static_cast<DWORD>(std::size(exec_dir)), exec_dir, nullptr)) {
DEBUG(misc, 0, "GetFullPathName failed (%lu)\n", GetLastError());
_searchpaths[SP_BINARY_DIR].clear();
} else {
@@ -551,8 +551,8 @@ const char *GetCurrentLocale(const char *)
const LCID userUiLocale = MAKELCID(userUiLang, SORT_DEFAULT);
char lang[9], country[9];
if (GetLocaleInfoA(userUiLocale, LOCALE_SISO639LANGNAME, lang, lengthof(lang)) == 0 ||
GetLocaleInfoA(userUiLocale, LOCALE_SISO3166CTRYNAME, country, lengthof(country)) == 0) {
if (GetLocaleInfoA(userUiLocale, LOCALE_SISO639LANGNAME, lang, static_cast<int>(std::size(lang))) == 0 ||
GetLocaleInfoA(userUiLocale, LOCALE_SISO3166CTRYNAME, country, static_cast<int>(std::size(country))) == 0) {
/* Unable to retrieve the locale. */
return nullptr;
}
@@ -578,7 +578,7 @@ void Win32SetCurrentLocaleName(std::string iso_code)
}
}
MultiByteToWideChar(CP_UTF8, 0, iso_code.c_str(), -1, _cur_iso_locale, lengthof(_cur_iso_locale));
MultiByteToWideChar(CP_UTF8, 0, iso_code.c_str(), -1, _cur_iso_locale, static_cast<int>(std::size(_cur_iso_locale)));
}
int OTTDStringCompare(std::string_view s1, std::string_view s2)