--- a/src/music/win32_m.cpp Thu Mar 27 05:15:06 2008 +0000
+++ b/src/music/win32_m.cpp Fri Mar 28 10:32:55 2008 +0000
@@ -13,7 +13,7 @@
HANDLE wait_obj;
HANDLE thread;
UINT_PTR devid;
- char start_song[260];
+ char start_song[MAX_PATH];
} _midi;
static FMusicDriver_Win32 iFMusicDriver_Win32;
@@ -46,28 +46,34 @@
SetEvent(_midi.wait_obj);
}
-static MCIERROR CDECL MidiSendCommand(const char* cmd, ...)
+static MCIERROR CDECL MidiSendCommand(const TCHAR* cmd, ...)
{
va_list va;
- char buf[512];
+ TCHAR buf[512];
va_start(va, cmd);
- vsnprintf(buf, lengthof(buf), cmd, va);
+ _vsntprintf(buf, lengthof(buf), cmd, va);
va_end(va);
- return mciSendStringA(buf, NULL, 0, 0);
+ return mciSendString(buf, NULL, 0, 0);
}
static bool MidiIntPlaySong(const char *filename)
{
- MidiSendCommand("close all");
- if (MidiSendCommand("open \"%s\" type sequencer alias song", filename) != 0) return false;
+ MidiSendCommand(_T("close all"));
- return MidiSendCommand("play song from 0") == 0;
+ if (MidiSendCommand(_T("open \"%s\" type sequencer alias song"), OTTD2FS(filename)) != 0) {
+ /* Let's try the "short name" */
+ TCHAR buf[MAX_PATH];
+ if (GetShortPathName(OTTD2FS(filename), buf, MAX_PATH) == 0) return false;
+ if (MidiSendCommand(_T("open \"%s\" type sequencer alias song"), buf) != 0) return false;
+ }
+
+ return MidiSendCommand(_T("play song from 0")) == 0;
}
static void MidiIntStopSong()
{
- MidiSendCommand("close all");
+ MidiSendCommand(_T("close all"));
}
static void MidiIntSetVolume(int vol)