mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r224) -Fix: Music now finally works on WinXP. DirectMusic is now default for an OS >= WinNT4 (WinNT4, Win2k, WinXP), and MIDI driver for lower OS's (Win95, Win98, WinME, etc).
This commit is contained in:
parent
e295e46e3e
commit
989ed101bc
|
@ -730,7 +730,7 @@ void IConsoleCmdHook(const byte * name, byte type, void * proc)
|
|||
|
||||
bool IConsoleCmdHookHandle(_iconsole_cmd * hook_cmd, byte type)
|
||||
{
|
||||
bool (*proc)(_iconsole_cmd * hook_cmd);
|
||||
bool (*proc)(_iconsole_cmd * hook_cmd) = NULL;
|
||||
switch (type) {
|
||||
case ICONSOLE_HOOK_AFTER_EXEC:
|
||||
proc = hook_cmd->hook_after_exec;
|
||||
|
@ -741,11 +741,9 @@ bool IConsoleCmdHookHandle(_iconsole_cmd * hook_cmd, byte type)
|
|||
case ICONSOLE_HOOK_ACCESS:
|
||||
proc = hook_cmd->hook_access;
|
||||
break;
|
||||
default:
|
||||
proc = NULL;
|
||||
break;
|
||||
default: return true;
|
||||
}
|
||||
if (proc == NULL) return true;
|
||||
|
||||
return proc(hook_cmd);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@ void CheckSwitchToEuro();
|
|||
void LoadFromConfig();
|
||||
void SaveToConfig();
|
||||
int ttd_main(int argc, char* argv[]);
|
||||
byte GetOSVersion();
|
||||
|
||||
void DeterminePaths();
|
||||
char * CDECL str_fmt(const char *str, ...);
|
||||
|
|
2
hal.h
2
hal.h
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
const char *name;
|
||||
const char *longname;
|
||||
const void *drv;
|
||||
uint flags;
|
||||
uint32 flags;
|
||||
} DriverDesc;
|
||||
|
||||
enum {
|
||||
|
|
4
ttd.c
4
ttd.c
|
@ -52,6 +52,7 @@ extern void HalGameLoop();
|
|||
uint32 _pixels_redrawn;
|
||||
bool _dbg_screen_rect;
|
||||
bool disable_computer;
|
||||
static byte _os_version = 0;
|
||||
|
||||
void CDECL error(const char *s, ...) {
|
||||
va_list va;
|
||||
|
@ -192,7 +193,7 @@ static const DriverDesc *ChooseDefaultDriver(const DriverDesc *dd)
|
|||
const DriverDesc *best = NULL;
|
||||
int best_pri = -1;
|
||||
do {
|
||||
if ((int)(dd->flags&DF_PRIORITY_MASK) > best_pri) {
|
||||
if ((int)(dd->flags&DF_PRIORITY_MASK) > best_pri && _os_version >= (byte)dd->flags) {
|
||||
best_pri = dd->flags&DF_PRIORITY_MASK;
|
||||
best = dd;
|
||||
}
|
||||
|
@ -571,6 +572,7 @@ int ttd_main(int argc, char* argv[])
|
|||
|
||||
// Sample catalogue
|
||||
DEBUG(misc, 1) ("Loading sound effects...");
|
||||
_os_version = GetOSVersion();
|
||||
MxInitialize(11025, "sample.cat");
|
||||
|
||||
// This must be done early, since functions use the InvalidateWindow* calls
|
||||
|
|
7
unix.c
7
unix.c
|
@ -353,6 +353,13 @@ const DriverDesc _music_driver_descs[] = {
|
|||
{ NULL, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
/* GetOSVersion returns the minimal required version of OS to be able to use that driver.
|
||||
Not needed for *nix. */
|
||||
byte GetOSVersion()
|
||||
{
|
||||
return 1; // any arbitrary number bigger then 0
|
||||
}
|
||||
|
||||
bool FileExists(const char *filename)
|
||||
{
|
||||
return access(filename, 0) == 0;
|
||||
|
|
6
w32dm.c
6
w32dm.c
|
@ -64,8 +64,8 @@ static char * DMusicMidiStart(char **parm)
|
|||
{
|
||||
if (InitDirectMusic() == true)
|
||||
return(0);
|
||||
else
|
||||
return("Unable to initialize DirectMusic");
|
||||
|
||||
return("Unable to initialize DirectMusic");
|
||||
}
|
||||
|
||||
static void DMusicMidiStop()
|
||||
|
@ -113,4 +113,4 @@ static void DMusicMidiSetVolume(byte vol)
|
|||
SetVolume(vol);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* WIN32_ENABLE_DIRECTMUSIC_SUPPORT */
|
||||
|
|
|
@ -302,4 +302,4 @@ void SetVolume(long vol)
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // WIN32_ENABLE_DIRECTMUSIC_SUPPORT
|
||||
#endif /* WIN32_ENABLE_DIRECTMUSIC_SUPPORT */
|
||||
|
|
50
win32.c
50
win32.c
|
@ -1775,33 +1775,67 @@ void FiosDelete(const char *name)
|
|||
DeleteFile(path);
|
||||
}
|
||||
|
||||
#define Windows_2000 5
|
||||
#define Windows_NT3_51 4
|
||||
|
||||
/* flags show the minimum required OS to use a given feature. Currently
|
||||
only dwMajorVersion is used
|
||||
MajorVersion MinorVersion
|
||||
Windows Server 2003 5 2
|
||||
Windows XP 5 1
|
||||
Windows 2000 5 0
|
||||
Windows NT 4.0 4 0
|
||||
Windows Me 4 90
|
||||
Windows 98 4 10
|
||||
Windows 95 4 0
|
||||
Windows NT 3.51 3 51
|
||||
*/
|
||||
|
||||
const DriverDesc _video_driver_descs[] = {
|
||||
{"null", "Null Video Driver", &_null_video_driver, 0},
|
||||
{"null", "Null Video Driver", &_null_video_driver, 0},
|
||||
#if defined(WITH_SDL)
|
||||
{"sdl", "SDL Video Driver", &_sdl_video_driver, 1},
|
||||
{"sdl", "SDL Video Driver", &_sdl_video_driver, 1},
|
||||
#endif
|
||||
{"win32", "Win32 GDI Video Driver", &_win32_video_driver, 2},
|
||||
{"win32", "Win32 GDI Video Driver", &_win32_video_driver, Windows_NT3_51},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
const DriverDesc _sound_driver_descs[] = {
|
||||
{"null", "Null Sound Driver", &_null_sound_driver, 0},
|
||||
#if defined(WITH_SDL)
|
||||
{"sdl", "SDL Sound Driver", &_sdl_sound_driver, 1},
|
||||
{"sdl", "SDL Sound Driver", &_sdl_sound_driver, 1},
|
||||
#endif
|
||||
{"win32", "Win32 WaveOut Driver", &_win32_sound_driver, 2},
|
||||
{"win32", "Win32 WaveOut Driver", &_win32_sound_driver, Windows_NT3_51},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
const DriverDesc _music_driver_descs[] = {
|
||||
{"null", "Null Music Driver", &_null_music_driver, 0},
|
||||
{"null", "Null Music Driver", &_null_music_driver, 0},
|
||||
#ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT
|
||||
{"dmusic", "DirectMusic MIDI Driver", &_dmusic_midi_driver, 1},
|
||||
{"dmusic", "DirectMusic MIDI Driver", &_dmusic_midi_driver, Windows_2000},
|
||||
#endif
|
||||
{"win32", "Win32 MIDI Driver", &_win32_music_driver, 2},
|
||||
// Win32 MIDI driver has higher priority then DMusic, so this one is chosen
|
||||
{"win32", "Win32 MIDI Driver", &_win32_music_driver, Windows_NT3_51},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
byte GetOSVersion()
|
||||
{
|
||||
OSVERSIONINFO osvi;
|
||||
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
|
||||
if (GetVersionEx(&osvi)) {
|
||||
DEBUG(misc, 2) ("Windows Version is %d", osvi.dwMajorVersion);
|
||||
return (byte)osvi.dwMajorVersion;
|
||||
}
|
||||
|
||||
// GetVersionEx failed, but we can safely assume at least Win95/WinNT3.51 is used
|
||||
DEBUG(misc, 0) ("Windows version retrieval failed, defaulting to level 4");
|
||||
return Windows_NT3_51;
|
||||
}
|
||||
|
||||
bool FileExists(const char *filename)
|
||||
{
|
||||
HANDLE hand = CreateFile(filename, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
|
Loading…
Reference in New Issue