Changeset - r6124:7054f2e8fadf
[Not reviewed]
master
0 15 0
Darkvater - 18 years ago 2007-02-23 12:56:10
darkvater@openttd.org
(svn r8860) -Cleanup: some style changes, proper #endif comments, variable initialisation, WINCE ifdef and a vsprintf to vsnprintf change.
15 files changed with 29 insertions and 44 deletions:
0 comments (0 inline, 0 general)
src/fios.cpp
Show inline comments
 
@@ -183,15 +183,13 @@ bool FiosDelete(const char *name)
 
}
 

	
 
bool FileExists(const char *filename)
 
{
 
#if defined(WINCE)
 
	/* There is always one platform that doesn't support basic commands... */
 
	HANDLE hand;
 

	
 
	hand = CreateFile(OTTD2FS(filename), 0, 0, NULL, OPEN_EXISTING, 0, NULL);
 
	HANDLE hand = CreateFile(OTTD2FS(filename), 0, 0, NULL, OPEN_EXISTING, 0, NULL);
 
	if (hand == INVALID_HANDLE_VALUE) return 1;
 
	CloseHandle(hand);
 
	return 0;
 
#else
 
	return access(filename, 0) == 0;
 
#endif
src/music/bemidi.h
Show inline comments
 
@@ -4,7 +4,7 @@
 
#define MUSIC_BEMIDI_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalMusicDriver _bemidi_music_driver;
 

	
 
#endif
 
#endif /* MUSIC_BEMIDI_H */
src/music/dmusic.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 

	
 
#ifdef WIN32_ENABLE_DIRECTMUSIC_SUPPORT
 

	
 
#include "../stdafx.h"
 
#include "../debug.h"
 
#include "../win32.h"
 
#include "dmusic.h"
 

	
 
#include <windows.h>
 
#include <dmksctrl.h>
src/music/extmidi.h
Show inline comments
 
@@ -4,7 +4,7 @@
 
#define MUSIC_EXTERNAL_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalMusicDriver _extmidi_music_driver;
 

	
 
#endif
 
#endif /* MUSIC_EXTERNAL_H */
src/music/null_m.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "null_m.h"
 

	
 
static const char* NullMidiStart(const char* const* parm) { return NULL; }
 
static void NullMidiStop(void) {}
 
static void NullMidiPlaySong(const char *filename) {}
 
static void NullMidiStopSong(void) {}
src/music/os2_m.h
Show inline comments
 
@@ -4,7 +4,7 @@
 
#define MUSIC_OS2_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalMusicDriver _os2_music_driver;
 

	
 
#endif
 
#endif /* MUSIC_OS2_H */
src/music/qtmidi.h
Show inline comments
 
@@ -4,7 +4,7 @@
 
#define MUSIC_MACOSX_QUICKTIME_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalMusicDriver _qtime_music_driver;
 

	
 
#endif /* !MUSIC_MACOSX_QUICKTIME_H */
 
#endif /* MUSIC_MACOSX_QUICKTIME_H */
src/music/win32_m.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#include "../stdafx.h"
 
#include "../openttd.h"
 
#include "win32_m.h"
 
#include <windows.h>
 
#include <mmsystem.h>
 

	
 
static struct {
 
	bool stop_song;
 
@@ -47,26 +46,23 @@ static void Win32MidiSetVolume(byte vol)
 
static MCIERROR CDECL MidiSendCommand(const char* cmd, ...)
 
{
 
	va_list va;
 
	char buf[512];
 

	
 
	va_start(va, cmd);
 
	vsprintf(buf, cmd, va);
 
	vsnprintf(buf, lengthof(buf), cmd, va);
 
	va_end(va);
 
	return mciSendStringA(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;
 
	if (MidiSendCommand("open \"%s\" type sequencer alias song", filename) != 0) return false;
 

	
 
	if (MidiSendCommand("play song from 0") != 0)
 
		return false;
 
	return true;
 
	return MidiSendCommand("play song from 0") == 0;
 
}
 

	
 
static void MidiIntStopSong(void)
 
{
 
	MidiSendCommand("close all");
 
}
 
@@ -101,25 +97,22 @@ static DWORD WINAPI MidiThread(LPVOID ar
 
		s = _midi.start_song;
 
		if (s[0] != '\0') {
 
			_midi.playing = MidiIntPlaySong(s);
 
			s[0] = '\0';
 

	
 
			// Delay somewhat in case we don't manage to play.
 
			if (!_midi.playing) {
 
				Sleep(5000);
 
			}
 
			if (!_midi.playing) Sleep(5000);
 
		}
 

	
 
		if (_midi.stop_song && _midi.playing) {
 
			_midi.stop_song = false;
 
			_midi.playing = false;
 
			MidiIntStopSong();
 
		}
 

	
 
		if (_midi.playing && !MidiIntIsSongPlaying())
 
			_midi.playing = false;
 
		if (_midi.playing && !MidiIntIsSongPlaying()) _midi.playing = false;
 

	
 
		WaitForMultipleObjects(1, &_midi.wait_obj, FALSE, 1000);
 
	} while (!_midi.terminate);
 

	
 
	DeleteObject(_midi.wait_obj);
 
	return 0;
 
@@ -145,14 +138,13 @@ static const char *Win32MidiStart(const 
 
		if (midiOutGetDevCaps(dev, &midicaps, sizeof(midicaps)) == 0 && (midicaps.dwSupport & MIDICAPS_VOLUME)) {
 
			_midi.devid = dev;
 
			break;
 
		}
 
	}
 

	
 
	if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL)
 
		return "Failed to create thread";
 
	if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL) return "Failed to create thread";
 

	
 
	return NULL;
 
}
 

	
 
static void Win32MidiStop(void)
 
{
src/music_gui.cpp
Show inline comments
 
@@ -419,26 +419,25 @@ static void MusicWindowWndProc(Window *w
 
		case 4: // stop playing
 
			msf.playing = false;
 
			break;
 
		case 5: // start playing
 
			msf.playing = true;
 
			break;
 
		case 6:{ // volume sliders
 
			byte *vol,new_vol;
 
		case 6: { // volume sliders
 
			byte *vol, new_vol;
 
			int x = e->we.click.pt.x - 88;
 

	
 
			if (x < 0)
 
				return;
 
			if (x < 0) return;
 

	
 
			vol = &msf.music_vol;
 
			if (x >= 106) {
 
				vol = &msf.effect_vol;
 
				x -= 106;
 
			}
 

	
 
			new_vol = min(max(x-21,0)*2,127);
 
			new_vol = min(max(x - 21, 0) * 2, 127);
 
			if (new_vol != *vol) {
 
				*vol = new_vol;
 
				if (vol == &msf.music_vol)
 
					MusicVolumeChanged(new_vol);
 
				SetWindowDirty(w);
 
			}
src/newgrf_sound.cpp
Show inline comments
 
@@ -34,13 +34,13 @@ void InitializeSoundPool(void)
 
	SndCopyToPool();
 
}
 

	
 

	
 
FileEntry *GetSound(uint index)
 
{
 
	if (index >= _sound_count) return NULL;
 
	if (index >= GetNumSounds()) return NULL;
 
	return GetSoundInternal(index);
 
}
 

	
 

	
 
uint GetNumSounds(void)
 
{
src/sound/cocoa_s.h
Show inline comments
 
@@ -4,7 +4,7 @@
 
#define SOUND_COCOA_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalSoundDriver _cocoa_sound_driver;
 

	
 
#endif
 
#endif /* SOUND_COCOA_H */
src/sound/sdl_s.cpp
Show inline comments
 
/* $Id$ */
 

	
 
#ifdef WITH_SDL
 

	
 
#include "../stdafx.h"
 

	
 
#ifdef WITH_SDL
 

	
 
#include "../openttd.h"
 
#include "../driver.h"
 
#include "../mixer.h"
 
#include "../sdl.h"
 
#include "sdl_s.h"
 
#include <SDL.h>
 

	
src/sound/win32_s.h
Show inline comments
 
@@ -4,7 +4,7 @@
 
#define SOUND_WIN32_H
 

	
 
#include "../hal.h"
 

	
 
extern const HalSoundDriver _win32_sound_driver;
 

	
 
#endif
 
#endif /* SOUND_WIN32_H */
src/video/cocoa_v.h
Show inline comments
 
@@ -7,7 +7,7 @@
 

	
 
#include "../openttd.h"
 
#include "../gfx.h"
 

	
 
extern const HalVideoDriver _cocoa_video_driver;
 

	
 
#endif
 
#endif /* VIDEO_COCOA_H */
src/win32.cpp
Show inline comments
 
@@ -865,18 +865,18 @@ void ShowInfo(const char *str)
 
	#define _OUT_TO_STDERR       1
 
	#define _OUT_TO_MSGBOX       2
 
	#define _REPORT_ERRMODE      3
 
	int _set_error_mode(int);
 
#endif
 

	
 
#if defined(WINCE)
 
int APIENTRY WinMain
 
#else
 
int APIENTRY _tWinMain
 
#endif
 
        (HINSTANCE hInstance, HINSTANCE hPrevInstance,
 
#if defined(WINCE) && !defined(_tWinMain)
 
/* GCC crosscompiler for WINCE doesn't support wide version */
 
# define _tWinMain WinMain
 
#endif /* WINCE */
 

	
 
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
 
	LPTSTR lpCmdLine, int nCmdShow)
 
{
 
	int argc;
 
	char *argv[64]; // max 64 command line arguments
 
	char *cmdline;
 

	
 
@@ -919,18 +919,17 @@ int APIENTRY _tWinMain
 
	return 0;
 
}
 

	
 
#if defined(WINCE)
 
void GetCurrentDirectoryW(int length, wchar_t *path)
 
{
 
	wchar_t *pDest = NULL;
 
	/* Get the name of this module */
 
	GetModuleFileName(NULL, path, length);
 

	
 
	/* Remove the executable name, this we call CurrentDir */
 
	pDest = wcsrchr(path, '\\');
 
	wchar_t *pDest = wcsrchr(path, '\\');
 
	if (pDest != NULL) {
 
		int result = pDest - path + 1;
 
		path[result] = '\0';
 
	}
 
}
 
#endif
0 comments (0 inline, 0 general)