From 3b7d3ac8a2ad3ee7a2afc263f46ed5275b2b9923 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 10 Mar 2019 04:41:50 +0100 Subject: [PATCH] Clean up types in sound.cpp (#603) --- Source/sound.cpp | 21 +++++++++++---------- Source/wave.cpp | 2 +- Source/wave.h | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/sound.cpp b/Source/sound.cpp index a37ec3223..043690659 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -190,8 +190,8 @@ BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) rv = FALSE; - WOpenFile(sound_file->sound_path, &file, 0); - WSetFilePointer(file, sound_file->chunk.dwOffset, 0, 0); + WOpenFile(sound_file->sound_path, &file, FALSE); + WSetFilePointer(file, sound_file->chunk.dwOffset, NULL, 0); #ifdef __cplusplus if (DSB->Lock(0, sound_file->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0) == DS_OK) { @@ -214,7 +214,8 @@ BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) TSnd *__fastcall sound_file_load(char *path) { - void *file, *wave_file; + HANDLE file; + BYTE *wave_file; TSnd *pSnd; LPVOID buf1, buf2; DWORD size1, size2; @@ -223,8 +224,8 @@ TSnd *__fastcall sound_file_load(char *path) if (!sglpDS) return NULL; - WOpenFile(path, &file, 0); - pSnd = (TSnd *)DiabloAllocPtr(40); + WOpenFile(path, &file, FALSE); + pSnd = (TSnd *)DiabloAllocPtr(sizeof(TSnd)); memset(pSnd, 0, sizeof(TSnd)); pSnd->sound_path = path; pSnd->start_tc = GetTickCount() - 81; @@ -243,7 +244,7 @@ TSnd *__fastcall sound_file_load(char *path) if (error_code != DS_OK) DSErrMsg(error_code, 318, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - memcpy(buf1, (char *)wave_file + pSnd->chunk.dwOffset, size1); + memcpy(buf1, wave_file + pSnd->chunk.dwOffset, size1); #ifdef __cplusplus error_code = pSnd->DSB->Unlock(buf1, size1, buf2, size2); @@ -253,7 +254,7 @@ TSnd *__fastcall sound_file_load(char *path) if (error_code != DS_OK) DSErrMsg(error_code, 325, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - mem_free_dbg(wave_file); + mem_free_dbg((void *)wave_file); WCloseFile(file); return pSnd; @@ -314,7 +315,7 @@ void __fastcall snd_init(HWND hWnd) #else if (sglpDS && sglpDS->lpVtbl->SetCooperativeLevel(sglpDS, hWnd, DSSCL_EXCLUSIVE) == DS_OK) #endif - sound_create_primary_buffer(0); + sound_create_primary_buffer(NULL); SVidInitialize(sglpDS); SFileDdaInitialize(sglpDS); @@ -442,7 +443,7 @@ void __cdecl music_stop() if (sgpMusicTrack) { SFileDdaEnd(sgpMusicTrack); SFileCloseFile(sgpMusicTrack); - sgpMusicTrack = 0; + sgpMusicTrack = NULL; sgnMusicTrack = 6; } } @@ -463,7 +464,7 @@ void __fastcall music_start(int nTrack) #endif sound_create_primary_buffer(sgpMusicTrack); if (!success) { - sgpMusicTrack = 0; + sgpMusicTrack = NULL; } else { SFileDdaBeginEx(sgpMusicTrack, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); sgnMusicTrack = nTrack; diff --git a/Source/wave.cpp b/Source/wave.cpp index 2feb34b5f..146600a31 100644 --- a/Source/wave.cpp +++ b/Source/wave.cpp @@ -202,7 +202,7 @@ BOOL __fastcall ReadWaveSection(MEMFILE *pMemFile, DWORD id, CKINFO *chunk) return chunk->dwOffset != (DWORD)-1; } -void *__fastcall LoadWaveFile(HANDLE hsFile, WAVEFORMATEX *pwfx, CKINFO *chunk) +BYTE *__fastcall LoadWaveFile(HANDLE hsFile, WAVEFORMATEX *pwfx, CKINFO *chunk) { MEMFILE wave_file; diff --git a/Source/wave.h b/Source/wave.h index 733919125..c5f93aeee 100644 --- a/Source/wave.h +++ b/Source/wave.h @@ -16,6 +16,6 @@ BOOL __fastcall ReadMemFile(MEMFILE *pMemFile, void *lpBuf, size_t length); void __fastcall FillMemFile(MEMFILE *pMemFile); int __fastcall SeekMemFile(MEMFILE *pMemFile, LONG lDist, DWORD dwMethod); BOOL __fastcall ReadWaveSection(MEMFILE *pMemFile, DWORD id, CKINFO *chunk); -void *__fastcall LoadWaveFile(HANDLE hsFile, WAVEFORMATEX *pwfx, CKINFO *chunk); +BYTE *__fastcall LoadWaveFile(HANDLE hsFile, WAVEFORMATEX *pwfx, CKINFO *chunk); #endif /* __WAVE_H__ */