mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-19 12:39:11 +00:00
Codechange: Switch to explicit wide strings
This commit is contained in:
@@ -81,7 +81,7 @@ struct DLSFile {
|
||||
std::vector<DLSWave> waves;
|
||||
|
||||
/** Try loading a DLS file into memory. */
|
||||
bool LoadFile(const TCHAR *file);
|
||||
bool LoadFile(const wchar_t *file);
|
||||
|
||||
private:
|
||||
/** Load an articulation structure from a DLS file. */
|
||||
@@ -428,11 +428,11 @@ bool DLSFile::ReadDLSWaveList(FILE *f, DWORD list_length)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DLSFile::LoadFile(const TCHAR *file)
|
||||
bool DLSFile::LoadFile(const wchar_t *file)
|
||||
{
|
||||
DEBUG(driver, 2, "DMusic: Try to load DLS file %s", FS2OTTD(file));
|
||||
|
||||
FILE *f = _tfopen(file, _T("rb"));
|
||||
FILE *f = _wfopen(file, L"rb");
|
||||
if (f == nullptr) return false;
|
||||
|
||||
FileCloser f_scope(f);
|
||||
@@ -861,11 +861,11 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
||||
if (user_dls == nullptr) {
|
||||
/* Try loading the default GM DLS file stored in the registry. */
|
||||
HKEY hkDM;
|
||||
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\DirectMusic"), 0, KEY_READ, &hkDM))) {
|
||||
TCHAR dls_path[MAX_PATH];
|
||||
if (SUCCEEDED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\DirectMusic", 0, KEY_READ, &hkDM))) {
|
||||
wchar_t dls_path[MAX_PATH];
|
||||
DWORD buf_size = sizeof(dls_path); // Buffer size as to be given in bytes!
|
||||
if (SUCCEEDED(RegQueryValueEx(hkDM, _T("GMFilePath"), nullptr, nullptr, (LPBYTE)dls_path, &buf_size))) {
|
||||
TCHAR expand_path[MAX_PATH * 2];
|
||||
if (SUCCEEDED(RegQueryValueEx(hkDM, L"GMFilePath", nullptr, nullptr, (LPBYTE)dls_path, &buf_size))) {
|
||||
wchar_t expand_path[MAX_PATH * 2];
|
||||
ExpandEnvironmentStrings(dls_path, expand_path, lengthof(expand_path));
|
||||
if (!dls_file.LoadFile(expand_path)) DEBUG(driver, 1, "Failed to load default GM DLS file from registry");
|
||||
}
|
||||
@@ -874,8 +874,8 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
|
||||
|
||||
/* If we couldn't load the file from the registry, try again at the default install path of the GM DLS file. */
|
||||
if (dls_file.instruments.size() == 0) {
|
||||
static const TCHAR *DLS_GM_FILE = _T("%windir%\\System32\\drivers\\gm.dls");
|
||||
TCHAR path[MAX_PATH];
|
||||
static const wchar_t *DLS_GM_FILE = L"%windir%\\System32\\drivers\\gm.dls";
|
||||
wchar_t path[MAX_PATH];
|
||||
ExpandEnvironmentStrings(DLS_GM_FILE, path, lengthof(path));
|
||||
|
||||
if (!dls_file.LoadFile(path)) return "Can't load GM DLS collection";
|
||||
|
Reference in New Issue
Block a user