Codechange: Remove the now meaningless console_cp parameter from OTTD2FS

pull/239/head
Niels Martin Hansen 3 years ago
parent e0561dbded
commit 746f1ca11a

@ -133,7 +133,7 @@ static void debug_print(const char *dbg, const char *buf)
seprintf(buffer, lastof(buffer), "%sdbg: [%s] %s\n", GetLogPrefix(), dbg, buf);
#if defined(_WIN32)
wchar_t system_buf[512];
convert_to_fs(buffer, system_buf, lengthof(system_buf), true);
convert_to_fs(buffer, system_buf, lengthof(system_buf));
fputws(system_buf, stderr);
#else
fputs(buffer, stderr);

@ -705,21 +705,21 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA
/* Add path to crash.log and crash.dmp (if any) to the crash window text */
size_t len = wcslen(_crash_desc) + 2;
len += wcslen(convert_to_fs(CrashLogWindows::current->crashlog_filename, filenamebuf, lengthof(filenamebuf), false)) + 2;
len += wcslen(convert_to_fs(CrashLogWindows::current->crashdump_filename, filenamebuf, lengthof(filenamebuf), false)) + 2;
len += wcslen(convert_to_fs(CrashLogWindows::current->screenshot_filename, filenamebuf, lengthof(filenamebuf), false)) + 1;
len += wcslen(convert_to_fs(CrashLogWindows::current->crashlog_filename, filenamebuf, lengthof(filenamebuf))) + 2;
len += wcslen(convert_to_fs(CrashLogWindows::current->crashdump_filename, filenamebuf, lengthof(filenamebuf))) + 2;
len += wcslen(convert_to_fs(CrashLogWindows::current->screenshot_filename, filenamebuf, lengthof(filenamebuf))) + 1;
wchar_t *text = AllocaM(wchar_t, len);
int printed = _snwprintf(text, len, _crash_desc, convert_to_fs(CrashLogWindows::current->crashlog_filename, filenamebuf, lengthof(filenamebuf), false));
int printed = _snwprintf(text, len, _crash_desc, convert_to_fs(CrashLogWindows::current->crashlog_filename, filenamebuf, lengthof(filenamebuf)));
if (printed < 0 || (size_t)printed > len) {
MessageBox(wnd, L"Catastrophic failure trying to display crash message. Could not perform text formatting.", L"OpenTTD", MB_ICONERROR);
return FALSE;
}
if (convert_to_fs(CrashLogWindows::current->crashdump_filename, filenamebuf, lengthof(filenamebuf), false)[0] != L'\0') {
if (convert_to_fs(CrashLogWindows::current->crashdump_filename, filenamebuf, lengthof(filenamebuf))[0] != L'\0') {
wcscat(text, L"\n");
wcscat(text, filenamebuf);
}
if (convert_to_fs(CrashLogWindows::current->screenshot_filename, filenamebuf, lengthof(filenamebuf), false)[0] != L'\0') {
if (convert_to_fs(CrashLogWindows::current->screenshot_filename, filenamebuf, lengthof(filenamebuf))[0] != L'\0') {
wcscat(text, L"\n");
wcscat(text, filenamebuf);
}
@ -738,7 +738,7 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA
wchar_t filenamebuf[MAX_PATH * 2];
char filename[MAX_PATH];
if (CrashLogWindows::current->WriteSavegame(filename, lastof(filename))) {
convert_to_fs(filename, filenamebuf, lengthof(filenamebuf), false);
convert_to_fs(filename, filenamebuf, lengthof(filenamebuf));
size_t len = lengthof(_save_succeeded) + wcslen(filenamebuf) + 1;
wchar_t *text = AllocaM(wchar_t, len);
_snwprintf(text, len, _save_succeeded, filenamebuf);

@ -606,12 +606,12 @@ void LoadWin32Font(FontSize fs)
/* See if this is an absolute path. */
if (FileExists(settings->font)) {
convert_to_fs(settings->font, fontPath, lengthof(fontPath), false);
convert_to_fs(settings->font, fontPath, lengthof(fontPath));
} else {
/* Scan the search-paths to see if it can be found. */
std::string full_font = FioFindFullPath(BASE_DIR, settings->font);
if (!full_font.empty()) {
convert_to_fs(full_font.c_str(), fontPath, lengthof(fontPath), false);
convert_to_fs(full_font.c_str(), fontPath, lengthof(fontPath));
}
}
@ -649,7 +649,7 @@ void LoadWin32Font(FontSize fs)
if (logfont.lfFaceName[0] == 0) {
logfont.lfWeight = strcasestr(settings->font, " bold") != nullptr ? FW_BOLD : FW_NORMAL; // Poor man's way to allow selecting bold fonts.
convert_to_fs(settings->font, logfont.lfFaceName, lengthof(logfont.lfFaceName), false);
convert_to_fs(settings->font, logfont.lfFaceName, lengthof(logfont.lfFaceName));
}
HFONT font = CreateFontIndirect(&logfont);

@ -578,7 +578,7 @@ std::string FS2OTTD(const std::wstring &name)
* @param console_cp convert to the console encoding instead of the normal system encoding.
* @return converted string; if failed string is of zero-length
*/
std::wstring OTTD2FS(const std::string &name, bool console_cp)
std::wstring OTTD2FS(const std::string &name)
{
int name_len = (name.length() >= INT_MAX) ? INT_MAX : (int)name.length();
int len = MultiByteToWideChar(CP_UTF8, 0, name.c_str(), name_len, nullptr, 0);
@ -618,7 +618,7 @@ char *convert_from_fs(const wchar_t *name, char *utf8_buf, size_t buflen)
* @param console_cp convert to the console encoding instead of the normal system encoding.
* @return pointer to system_buf. If conversion fails the string is of zero-length
*/
wchar_t *convert_to_fs(const char *name, wchar_t *system_buf, size_t buflen, bool console_cp)
wchar_t *convert_to_fs(const char *name, wchar_t *system_buf, size_t buflen)
{
int len = MultiByteToWideChar(CP_UTF8, 0, name, -1, system_buf, (int)buflen);
if (len == 0) system_buf[0] = '\0';

@ -17,7 +17,7 @@ typedef void (*Function)(int);
bool LoadLibraryList(Function proc[], const char *dll);
char *convert_from_fs(const wchar_t *name, char *utf8_buf, size_t buflen);
wchar_t *convert_to_fs(const char *name, wchar_t *utf16_buf, size_t buflen, bool console_cp = false);
wchar_t *convert_to_fs(const char *name, wchar_t *utf16_buf, size_t buflen);
#if defined(__MINGW32__) && !defined(__MINGW64__)
#define SHGFP_TYPE_CURRENT 0

@ -263,7 +263,7 @@
# define unlink(file) _wunlink(OTTD2FS(file).c_str())
std::string FS2OTTD(const std::wstring &name);
std::wstring OTTD2FS(const std::string &name, bool console_cp = false);
std::wstring OTTD2FS(const std::string &name);
# elif defined(WITH_ICONV)
# define fopen(file, mode) fopen(OTTD2FS(file).c_str(), mode)
std::string FS2OTTD(const std::string &name);

Loading…
Cancel
Save