From 660405505ff0e57cf9d8024f9260a1eafa40d31b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 4 Apr 2020 20:52:33 +0200 Subject: [PATCH] Remove C compat It's unmaintained and clear that we won't be going back since some functions can only be solved with C++ --- Source/capture.cpp | 12 ------- Source/dthread.cpp | 14 -------- Source/dx.cpp | 78 ------------------------------------------- Source/engine.cpp | 10 ------ Source/logging.cpp | 10 ------ Source/nthread.cpp | 14 -------- Source/palette.cpp | 17 ---------- Source/scrollrt.cpp | 7 ---- Source/sound.cpp | 80 --------------------------------------------- 9 files changed, 242 deletions(-) diff --git a/Source/capture.cpp b/Source/capture.cpp index 552b43e26..ba660f7a1 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -141,11 +141,7 @@ static void RedPalette(PALETTEENTRY *pal) red[i].peFlags = 0; } -#ifdef __cplusplus lpDDPalette->SetEntries(0, 0, 256, red); -#else - lpDDPalette->lpVtbl->SetEntries(lpDDPalette, 0, 0, 256, red); -#endif } void CaptureScreen() @@ -158,11 +154,7 @@ void CaptureScreen() hObject = CaptureFile(FileName); if (hObject != INVALID_HANDLE_VALUE) { DrawAndBlit(); -#ifdef __cplusplus lpDDPalette->GetEntries(0, 0, 256, palette); -#else - lpDDPalette->lpVtbl->GetEntries(lpDDPalette, 0, 0, 256, palette); -#endif RedPalette(palette); lock_buf(2); @@ -180,10 +172,6 @@ void CaptureScreen() DeleteFile(FileName); Sleep(300); -#ifdef __cplusplus lpDDPalette->SetEntries(0, 0, 256, palette); -#else - lpDDPalette->lpVtbl->SetEntries(lpDDPalette, 0, 0, 256, palette); -#endif } } diff --git a/Source/dthread.cpp b/Source/dthread.cpp index d6f5ea271..deeb473e6 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -6,9 +6,7 @@ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" -#ifdef __cplusplus static CCritSect sgMemCrit; -#endif unsigned int glpDThreadId; TMegaPkt *sgpInfoHead; /* may not be right struct */ BOOLEAN dthread_running; @@ -21,16 +19,12 @@ void dthread_remove_player(int pnum) { TMegaPkt *pkt; -#ifdef __cplusplus sgMemCrit.Enter(); -#endif for (pkt = sgpInfoHead; pkt; pkt = pkt->pNext) { if (pkt->dwSpaceLeft == pnum) pkt->dwSpaceLeft = MAX_PLRS; } -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen) @@ -48,9 +42,7 @@ void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen) pkt->data[0] = cmd; *(DWORD *)&pkt->data[4] = dwLen; memcpy(&pkt->data[8], pbSrc, dwLen); -#ifdef __cplusplus sgMemCrit.Enter(); -#endif p = (TMegaPkt *)&sgpInfoHead; while (p->pNext) { p = p->pNext; @@ -58,9 +50,7 @@ void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen) p->pNext = pkt; SetEvent(sghWorkToDoEvent); -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } void dthread_start() @@ -98,17 +88,13 @@ unsigned int __stdcall dthread_handler(void *data) app_fatal("dthread4:\n%s", error_buf); } -#ifdef __cplusplus sgMemCrit.Enter(); -#endif pkt = sgpInfoHead; if (sgpInfoHead) sgpInfoHead = sgpInfoHead->pNext; else ResetEvent(sghWorkToDoEvent); -#ifdef __cplusplus sgMemCrit.Leave(); -#endif if (pkt) { if (pkt->dwSpaceLeft != MAX_PLRS) diff --git a/Source/dx.cpp b/Source/dx.cpp index 2ead8b687..ce9c25d90 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -16,9 +16,7 @@ IDirectDrawSurface *lpDDSPrimary; #ifdef _DEBUG int locktbl[256]; #endif -#ifdef __cplusplus static CCritSect sgMemCrit; -#endif char gbBackBuf; char gbEmulate; HMODULE ghDiabMod; @@ -29,27 +27,15 @@ static void dx_create_back_buffer() HRESULT error_code; DDSURFACEDESC ddsd; -#ifdef __cplusplus error_code = lpDDSPrimary->GetCaps(&caps); -#else - error_code = lpDDSPrimary->lpVtbl->GetCaps(lpDDSPrimary, &caps); -#endif if (error_code != DD_OK) DDErrMsg(error_code, 59, "C:\\Src\\Diablo\\Source\\dx.cpp"); if (!gbBackBuf) { ddsd.dwSize = sizeof(ddsd); -#ifdef __cplusplus error_code = lpDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL); -#else - error_code = lpDDSPrimary->lpVtbl->Lock(lpDDSPrimary, NULL, &ddsd, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL); -#endif if (error_code == DD_OK) { -#ifdef __cplusplus lpDDSPrimary->Unlock(NULL); -#else - lpDDSPrimary->lpVtbl->Unlock(lpDDSPrimary, NULL); -#endif sgpBackBuf = (BYTE *)DiabloAllocPtr(BUFFER_HEIGHT * BUFFER_WIDTH); return; } @@ -65,18 +51,10 @@ static void dx_create_back_buffer() ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN; ddsd.dwHeight = BUFFER_HEIGHT; ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); -#ifdef __cplusplus error_code = lpDDSPrimary->GetPixelFormat(&ddsd.ddpfPixelFormat); -#else - error_code = lpDDSPrimary->lpVtbl->GetPixelFormat(lpDDSPrimary, &ddsd.ddpfPixelFormat); -#endif if (error_code != DD_OK) ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 94); -#ifdef __cplusplus error_code = lpDDInterface->CreateSurface(&ddsd, &lpDDSBackBuf, NULL); -#else - error_code = lpDDInterface->lpVtbl->CreateSurface(lpDDInterface, &ddsd, &lpDDSBackBuf, NULL); -#endif if (error_code != DD_OK) ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 96); } @@ -90,11 +68,7 @@ static void dx_create_primary_surface() ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; -#ifdef __cplusplus error_code = lpDDInterface->CreateSurface(&ddsd, &lpDDSPrimary, NULL); -#else - error_code = lpDDInterface->lpVtbl->CreateSurface(lpDDInterface, &ddsd, &lpDDSPrimary, NULL); -#endif if (error_code != DD_OK) ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 109); } @@ -153,11 +127,7 @@ void dx_init(HWND hWnd) fullscreen = TRUE; #endif if (!fullscreen) { -#ifdef __cplusplus hDDVal = lpDDInterface->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); -#else - hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); -#endif if (hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { TriggerBreak(); } else if (hDDVal != DD_OK) { @@ -165,29 +135,17 @@ void dx_init(HWND hWnd) } SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } else { -#ifdef __cplusplus hDDVal = lpDDInterface->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); -#else - hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); -#endif if (hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { TriggerBreak(); } else if (hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); } -#ifdef __cplusplus hDDVal = lpDDInterface->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); -#else - hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); -#endif if (hDDVal != DD_OK) { winw = GetSystemMetrics(SM_CXSCREEN); winh = GetSystemMetrics(SM_CYSCREEN); -#ifdef __cplusplus hDDVal = lpDDInterface->SetDisplayMode(winw, winh, SCREEN_BPP); -#else - hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, winw, winh, SCREEN_BPP); -#endif } if (hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 183); @@ -207,9 +165,7 @@ static void lock_buf_priv() DDSURFACEDESC ddsd; HRESULT error_code; -#ifdef __cplusplus sgMemCrit.Enter(); -#endif if (sgpBackBuf != NULL) { gpBuffer = sgpBackBuf; sgdwLockCount++; @@ -228,11 +184,7 @@ static void lock_buf_priv() return; } ddsd.dwSize = sizeof(ddsd); -#ifdef __cplusplus error_code = lpDDSBackBuf->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL); -#else - error_code = lpDDSBackBuf->lpVtbl->Lock(lpDDSBackBuf, NULL, &ddsd, DDLOCK_WAIT, NULL); -#endif if (error_code != DD_OK) DDErrMsg(error_code, 235, "C:\\Src\\Diablo\\Source\\dx.cpp"); @@ -263,18 +215,12 @@ static void unlock_buf_priv() gpBufEnd -= (size_t)gpBuffer; gpBuffer = NULL; if (sgpBackBuf == NULL) { -#ifdef __cplusplus error_code = lpDDSBackBuf->Unlock(NULL); -#else - error_code = lpDDSBackBuf->lpVtbl->Unlock(lpDDSBackBuf, NULL); -#endif if (error_code != DD_OK) DDErrMsg(error_code, 273, "C:\\Src\\Diablo\\Source\\dx.cpp"); } } -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } void unlock_buf(BYTE idx) @@ -292,46 +238,26 @@ void dx_cleanup() if (ghMainWnd) ShowWindow(ghMainWnd, SW_HIDE); SDrawDestroy(); -#ifdef __cplusplus sgMemCrit.Enter(); -#endif if (sgpBackBuf != NULL) { MemFreeDbg(sgpBackBuf); } else if (lpDDSBackBuf != NULL) { -#ifdef __cplusplus lpDDSBackBuf->Release(); -#else - lpDDSBackBuf->lpVtbl->Release(lpDDSBackBuf); -#endif lpDDSBackBuf = NULL; } sgdwLockCount = 0; gpBuffer = NULL; -#ifdef __cplusplus sgMemCrit.Leave(); -#endif if (lpDDSPrimary) { -#ifdef __cplusplus lpDDSPrimary->Release(); -#else - lpDDSPrimary->lpVtbl->Release(lpDDSPrimary); -#endif lpDDSPrimary = NULL; } if (lpDDPalette) { -#ifdef __cplusplus lpDDPalette->Release(); -#else - lpDDPalette->lpVtbl->Release(lpDDPalette); -#endif lpDDPalette = NULL; } if (lpDDInterface) { -#ifdef __cplusplus lpDDInterface->Release(); -#else - lpDDInterface->lpVtbl->Release(lpDDInterface); -#endif lpDDInterface = NULL; } } @@ -340,9 +266,7 @@ void dx_reinit() { int lockCount; -#ifdef __cplusplus sgMemCrit.Enter(); -#endif ClearCursor(); lockCount = sgdwLockCount; @@ -360,9 +284,7 @@ void dx_reinit() lockCount--; } -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } /* check extern remove stub */ diff --git a/Source/engine.cpp b/Source/engine.cpp index fb4608269..2107a8333 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -24,9 +24,7 @@ int orgseed; int sgnWidth; /** Current game seed */ int sglGameSeed; -#ifdef __cplusplus static CCritSect sgMemCrit; -#endif int SeedCount; BOOL gbNotInView; // valid - if x/y are in bounds @@ -2599,13 +2597,9 @@ BYTE *DiabloAllocPtr(DWORD dwBytes) { BYTE *buf; -#ifdef __cplusplus sgMemCrit.Enter(); -#endif buf = (BYTE *)SMemAlloc(dwBytes, "C:\\Src\\Diablo\\Source\\ENGINE.CPP", 2236, 0); -#ifdef __cplusplus sgMemCrit.Leave(); -#endif if (buf == NULL) { ErrDlg(IDD_DIALOG2, GetLastError(), "C:\\Src\\Diablo\\Source\\ENGINE.CPP", 2269); @@ -2621,13 +2615,9 @@ BYTE *DiabloAllocPtr(DWORD dwBytes) void mem_free_dbg(void *p) { if (p) { -#ifdef __cplusplus sgMemCrit.Enter(); -#endif SMemFree(p, "C:\\Src\\Diablo\\Source\\ENGINE.CPP", 2317, 0); -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } } diff --git a/Source/logging.cpp b/Source/logging.cpp index a3fb3043b..f834e9b24 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -6,9 +6,7 @@ #include "all.h" #include "../3rdParty/Storm/Source/storm.h" -#ifdef __cplusplus static CCritSect sgMemCrit; -#endif CHAR FileName[MAX_PATH]; char log_buffer[388]; LPCVOID lpAddress; @@ -25,9 +23,7 @@ void __cdecl log_flush(BOOL force_close) { DWORD NumberOfBytesWritten; -#ifdef __cplusplus sgMemCrit.Enter(); -#endif if (nNumberOfBytesToWrite) { if (log_file == INVALID_HANDLE_VALUE) { log_file = log_create(); @@ -44,9 +40,7 @@ void __cdecl log_flush(BOOL force_close) CloseHandle(log_file); log_file = INVALID_HANDLE_VALUE; } -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } HANDLE log_create() @@ -132,9 +126,7 @@ void __cdecl log_printf(const char *pszFmt, ...) char msg[512]; va_list va; -#ifdef __cplusplus sgMemCrit.Enter(); -#endif va_start(va, pszFmt); _vsnprintf(msg, 0x200, pszFmt, va); va_end(va); @@ -154,9 +146,7 @@ void __cdecl log_printf(const char *pszFmt, ...) memcpy(&pBuffer[nNumberOfBytesToWrite], msg, size); nNumberOfBytesToWrite += size; } -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } void log_dump_computer_info() diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 43aa04c56..a8673103a 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -8,9 +8,7 @@ BYTE sgbNetUpdateRate; DWORD gdwMsgLenTbl[MAX_PLRS]; -#ifdef __cplusplus static CCritSect sgMemCrit; -#endif DWORD gdwDeltaBytesSec; BOOLEAN nthread_should_run; DWORD gdwTurnsInTransit; @@ -160,9 +158,7 @@ void nthread_start(BOOL set_turn_upper_bit) gdwNormalMsgSize = largestMsgSize; if (gbMaxPlayers > 1) { sgbThreadIsRunning = FALSE; -#ifdef __cplusplus sgMemCrit.Enter(); -#endif nthread_should_run = TRUE; sghThread = (HANDLE)_beginthreadex(NULL, 0, nthread_handler, NULL, 0, &glpNThreadId); if (sghThread == INVALID_HANDLE_VALUE) { @@ -180,9 +176,7 @@ unsigned int __stdcall nthread_handler(void *data) if (nthread_should_run) { while (1) { -#ifdef __cplusplus sgMemCrit.Enter(); -#endif if (!nthread_should_run) break; nthread_send_and_recv_turn(0, 0); @@ -190,17 +184,13 @@ unsigned int __stdcall nthread_handler(void *data) delta = last_tick - GetTickCount(); else delta = 50; -#ifdef __cplusplus sgMemCrit.Leave(); -#endif if (delta > 0) Sleep(delta); if (!nthread_should_run) return 0; } -#ifdef __cplusplus sgMemCrit.Leave(); -#endif } return 0; } @@ -212,10 +202,8 @@ void nthread_cleanup() gdwNormalMsgSize = 0; gdwLargestMsgSize = 0; if (sghThread != INVALID_HANDLE_VALUE && glpNThreadId != GetCurrentThreadId()) { -#ifdef __cplusplus if (!sgbThreadIsRunning) sgMemCrit.Leave(); -#endif if (WaitForSingleObject(sghThread, INFINITE) == -1) { app_fatal("nthread3:\n(%s)", TraceLastError()); } @@ -227,12 +215,10 @@ void nthread_cleanup() void nthread_ignore_mutex(BOOL bStart) { if (sghThread != INVALID_HANDLE_VALUE) { -#ifdef __cplusplus if (bStart) sgMemCrit.Leave(); else sgMemCrit.Enter(); -#endif sgbThreadIsRunning = bStart; } } diff --git a/Source/palette.cpp b/Source/palette.cpp index 65d356650..83fc04f19 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -104,18 +104,10 @@ void palette_init() LoadGamma(); memcpy(system_palette, orig_palette, sizeof(orig_palette)); LoadSysPal(); -#ifdef __cplusplus error_code = lpDDInterface->CreatePalette(DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL); -#else - error_code = lpDDInterface->lpVtbl->CreatePalette(lpDDInterface, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL); -#endif if (error_code) ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 143); -#ifdef __cplusplus error_code = lpDDSPrimary->SetPalette(lpDDPalette); -#else - error_code = lpDDSPrimary->lpVtbl->SetPalette(lpDDSPrimary, lpDDPalette); -#endif #ifndef RGBMODE if (error_code) ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146); @@ -159,13 +151,8 @@ void LoadRndLvlPal(int l) void ResetPal() { if (!lpDDSPrimary -#ifdef __cplusplus || lpDDSPrimary->IsLost() != DDERR_SURFACELOST || !lpDDSPrimary->Restore()) { -#else - || lpDDSPrimary->lpVtbl->IsLost(lpDDSPrimary) != DDERR_SURFACELOST - || !lpDDSPrimary->lpVtbl->Restore(lpDDSPrimary)) { -#endif SDrawRealizePalette(); } } @@ -213,11 +200,7 @@ static void SetFadeLevel(DWORD fadeval) system_palette[i].peBlue = (fadeval * logical_palette[i].peBlue) >> 8; } Sleep(3); -#ifdef __cplusplus lpDDInterface->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL); -#else - lpDDInterface->lpVtbl->WaitForVerticalBlank(lpDDInterface, DDWAITVB_BLOCKBEGIN, NULL); -#endif palette_update(); } } diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index d56272dd8..22efa0056 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -2584,17 +2584,10 @@ static void DrawFPS() if (framerate > 99) framerate = 99; wsprintf(String, "%2d", framerate); -#ifdef __cplusplus if (!lpDDSPrimary->GetDC(&hdc)) { TextOut(hdc, 0, 400, String, strlen(String)); lpDDSPrimary->ReleaseDC(hdc); } -#else - if (!lpDDSPrimary->lpVtbl->GetDC(lpDDSPrimary, &hdc)) { - TextOut(hdc, 0, 400, String, strlen(String)); - lpDDSPrimary->lpVtbl->ReleaseDC(lpDDSPrimary, hdc); - } -#endif } } #endif diff --git a/Source/sound.cpp b/Source/sound.cpp index 3f8fb33fe..d54e6eb5b 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -45,19 +45,11 @@ void snd_update(BOOL bStopAll) if (!DSBs[i]) continue; -#ifdef __cplusplus if (!bStopAll && DSBs[i]->GetStatus(&dwStatus) == DS_OK && dwStatus == DSBSTATUS_PLAYING) continue; DSBs[i]->Stop(); DSBs[i]->Release(); -#else - if (!bStopAll && DSBs[i]->lpVtbl->GetStatus(DSBs[i], &dwStatus) == DS_OK && dwStatus == DSBSTATUS_PLAYING) - continue; - - DSBs[i]->lpVtbl->Stop(DSBs[i]); - DSBs[i]->lpVtbl->Release(DSBs[i]); -#endif DSBs[i] = NULL; } @@ -66,11 +58,7 @@ void snd_update(BOOL bStopAll) void snd_stop_snd(TSnd *pSnd) { if (pSnd && pSnd->DSB) -#ifdef __cplusplus pSnd->DSB->Stop(); -#else - pSnd->DSB->lpVtbl->Stop(pSnd->DSB); -#endif } BOOL snd_playing(TSnd *pSnd) @@ -83,11 +71,7 @@ BOOL snd_playing(TSnd *pSnd) if (pSnd->DSB == NULL) return FALSE; -#ifdef __cplusplus if (pSnd->DSB->GetStatus(&dwStatus) != DS_OK) -#else - if (pSnd->DSB->lpVtbl->GetStatus(pSnd->DSB, &dwStatus) != DS_OK) -#endif return FALSE; return dwStatus == DSBSTATUS_PLAYING; @@ -127,28 +111,17 @@ void snd_play_snd(TSnd *pSnd, int lVolume, int lPan) } else if (lVolume > VOLUME_MAX) { lVolume = VOLUME_MAX; } -#ifdef __cplusplus DSB->SetVolume(lVolume); DSB->SetPan(lPan); error_code = DSB->Play(0, 0, 0); -#else - DSB->lpVtbl->SetVolume(DSB, lVolume); - DSB->lpVtbl->SetPan(DSB, lPan); - - error_code = DSB->lpVtbl->Play(DSB, 0, 0, 0); -#endif if (error_code != DSERR_BUFFERLOST) { if (error_code != DS_OK) { DSErrMsg(error_code, 261, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); } } else if (sound_file_reload(pSnd, DSB)) { -#ifdef __cplusplus DSB->Play(0, 0, 0); -#else - DSB->lpVtbl->Play(DSB, 0, 0, 0); -#endif } pSnd->start_tc = tc; @@ -164,11 +137,7 @@ LPDIRECTSOUNDBUFFER sound_dup_channel(LPDIRECTSOUNDBUFFER DSB) for (i = 0; i < 8; i++) { if (!DSBs[i]) { -#ifdef __cplusplus if (sglpDS->DuplicateSoundBuffer(DSB, &DSBs[i]) != DS_OK) { -#else - if (sglpDS->lpVtbl->DuplicateSoundBuffer(sglpDS, DSB, &DSBs[i]) != DS_OK) { -#endif return NULL; } @@ -186,11 +155,7 @@ BOOL sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) DWORD size1, size2; BOOL rv; -#ifdef __cplusplus if (DSB->Restore() != DS_OK) -#else - if (DSB->lpVtbl->Restore(DSB) != DS_OK) -#endif return FALSE; rv = FALSE; @@ -198,19 +163,11 @@ BOOL sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) 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) { WReadFile(file, buf1, size1); if (DSB->Unlock(buf1, size1, buf2, size2) == DS_OK) rv = TRUE; } -#else - if (DSB->lpVtbl->Lock(DSB, 0, sound_file->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0) == DS_OK) { - WReadFile(file, buf1, size1); - if (DSB->lpVtbl->Unlock(DSB, buf1, size1, buf2, size2) == DS_OK) - rv = TRUE; - } -#endif WCloseFile(file); @@ -241,21 +198,13 @@ TSnd *sound_file_load(char *path) sound_CreateSoundBuffer(pSnd); -#ifdef __cplusplus error_code = pSnd->DSB->Lock(0, pSnd->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0); -#else - error_code = pSnd->DSB->lpVtbl->Lock(pSnd->DSB, 0, pSnd->chunk.dwSize, &buf1, &size1, &buf2, &size2, 0); -#endif if (error_code != DS_OK) DSErrMsg(error_code, 318, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); memcpy(buf1, wave_file + pSnd->chunk.dwOffset, size1); -#ifdef __cplusplus error_code = pSnd->DSB->Unlock(buf1, size1, buf2, size2); -#else - error_code = pSnd->DSB->lpVtbl->Unlock(pSnd->DSB, buf1, size1, buf2, size2); -#endif if (error_code != DS_OK) DSErrMsg(error_code, 325, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); @@ -276,11 +225,7 @@ void sound_CreateSoundBuffer(TSnd *sound_file) DSB.dwSize = sizeof(DSBUFFERDESC); DSB.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_STATIC; -#ifdef __cplusplus error_code = sglpDS->CreateSoundBuffer(&DSB, &sound_file->DSB, NULL); -#else - error_code = sglpDS->lpVtbl->CreateSoundBuffer(sglpDS, &DSB, &sound_file->DSB, NULL); -#endif if (error_code != ERROR_SUCCESS) DSErrMsg(error_code, 282, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); } @@ -289,13 +234,8 @@ void sound_file_cleanup(TSnd *sound_file) { if (sound_file) { if (sound_file->DSB) { -#ifdef __cplusplus sound_file->DSB->Stop(); sound_file->DSB->Release(); -#else - sound_file->DSB->lpVtbl->Stop(sound_file->DSB); - sound_file->DSB->lpVtbl->Release(sound_file->DSB); -#endif sound_file->DSB = NULL; } @@ -316,11 +256,7 @@ void snd_init(HWND hWnd) if (error_code != DS_OK) sglpDS = NULL; -#ifdef __cplusplus if (sglpDS && sglpDS->SetCooperativeLevel(hWnd, DSSCL_EXCLUSIVE) == DS_OK) -#else - if (sglpDS && sglpDS->lpVtbl->SetCooperativeLevel(sglpDS, hWnd, DSSCL_EXCLUSIVE) == DS_OK) -#endif sound_create_primary_buffer(NULL); SVidInitialize(sglpDS); @@ -356,11 +292,7 @@ void sound_create_primary_buffer(HANDLE music_track) dsbuf.dwSize = sizeof(DSBUFFERDESC); dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; -#ifdef __cplusplus error_code = sglpDS->CreateSoundBuffer(&dsbuf, &sglpDSB, NULL); -#else - error_code = sglpDS->lpVtbl->CreateSoundBuffer(sglpDS, &dsbuf, &sglpDSB, NULL); -#endif if (error_code != DS_OK) DSErrMsg(error_code, 375, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); } @@ -369,11 +301,7 @@ void sound_create_primary_buffer(HANDLE music_track) DSCAPS dsbcaps; dsbcaps.dwSize = sizeof(DSCAPS); -#ifdef __cplusplus error_code = sglpDS->GetCaps(&dsbcaps); -#else - error_code = sglpDS->lpVtbl->GetCaps(sglpDS, &dsbcaps); -#endif if (error_code != DS_OK) DSErrMsg(error_code, 383, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); @@ -389,11 +317,7 @@ void sound_create_primary_buffer(HANDLE music_track) format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; -#ifdef __cplusplus sglpDSB->SetFormat(&format); -#else - sglpDSB->lpVtbl->SetFormat(sglpDSB, &format); -#endif } } @@ -423,11 +347,7 @@ void sound_cleanup() SFileDdaDestroy(); if (sglpDS) { -#ifdef __cplusplus sglpDS->Release(); -#else - sglpDS->lpVtbl->Release(sglpDS); -#endif sglpDS = NULL; }