From a8e4db538f0e3cbd7cd1a89e68cfe222ca596bb7 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 12 Oct 2019 22:55:56 +0200 Subject: [PATCH] Display SDL error messages in UI dialog This will also end the application in most cases --- 3rdParty/Storm/Source/storm.h | 6 +++--- Source/appfat.cpp | 2 +- Source/appfat.h | 2 +- SourceS/miniwin/com.h | 2 +- SourceS/miniwin/misc.h | 4 ++-- SourceX/DiabloUI/art_draw.cpp | 4 ++-- SourceX/DiabloUI/credits.cpp | 9 ++++---- SourceX/DiabloUI/diabloui.cpp | 5 +++-- SourceX/DiabloUI/progress.cpp | 4 ++-- SourceX/DiabloUI/text_draw.cpp | 4 ++-- SourceX/dx.cpp | 32 ++++++++++++---------------- SourceX/miniwin/dsound.cpp | 8 +++---- SourceX/miniwin/dsound.h | 2 +- SourceX/miniwin/misc.cpp | 18 +++++----------- SourceX/miniwin/thread.cpp | 26 ++++++++++------------- SourceX/sound.cpp | 8 +++---- SourceX/storm/storm.cpp | 38 +++++++++++++--------------------- SourceX/storm/storm_dx.cpp | 9 +++----- defs.h | 2 ++ 19 files changed, 78 insertions(+), 107 deletions(-) diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index 3b55fc4f8..ccb561222 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -728,7 +728,7 @@ SDrawPostClose(); //BOOL STORMAPI SDrawRealizePalette(); BOOL STORMAPI SDrawUnlockSurface(int surfacenumber, void *lpSurface, int a3, RECT *lpRect); -BOOL STORMAPI SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4); +void SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4); BOOL STORMAPI SEvtDispatch(DWORD dwMessageID, DWORD dwFlags, int type, PS_EVT pEvent); @@ -869,10 +869,10 @@ BOOL STORMAPI STransCreateI(void *pBuffer, int width, int height, int bpp, int a BOOL STORMAPI SVidDestroy(); BOOL STORMAPI SVidGetSize(HANDLE video, int width, int height, int zero); BOOL STORMAPI SVidInitialize(HANDLE video); -BOOL STORMAPI SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video); +void SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video); BOOL STORMAPI SVidPlayContinueSingle(HANDLE video, int a2, int a3); -BOOL STORMAPI SVidPlayEnd(HANDLE video); +void SVidPlayEnd(HANDLE video); /* SErrDisplayError @ 461 * diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 933ebd4b4..bd3c388ff 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -69,7 +69,7 @@ void assert_fail(int nLineNo, const char *pszFile, const char *pszFail) } #endif -void ErrDlg(char *title, char *error, char *log_file_path, int log_line_nr) +void ErrDlg(const char *title, const char *error, char *log_file_path, int log_line_nr) { char text[1024]; diff --git a/Source/appfat.h b/Source/appfat.h index 1f80a52ef..fe41a1a15 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -22,7 +22,7 @@ void assert_fail(int nLineNo, const char *pszFile, const char *pszFail); void DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path); void DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path); void center_window(HWND hDlg); -void ErrDlg(char *title, char *error, char *log_file_path, int log_line_nr); +void ErrDlg(const char *title, const char *error, char *log_file_path, int log_line_nr); BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text); void TextDlg(HWND hDlg, char *text); void FileErrDlg(const char *error); diff --git a/SourceS/miniwin/com.h b/SourceS/miniwin/com.h index 29da7fc2d..ce248af8f 100644 --- a/SourceS/miniwin/com.h +++ b/SourceS/miniwin/com.h @@ -7,7 +7,7 @@ struct IDirectSoundBuffer { virtual void GetStatus(LPDWORD pdwStatus) = 0; virtual void Play(int lVolume, int lPan) = 0; virtual void Stop() = 0; - virtual const char *SetChunk(BYTE *fileData, DWORD dwBytes) = 0; + virtual int SetChunk(BYTE *fileData, DWORD dwBytes) = 0; }; typedef IDirectSoundBuffer *LPDIRECTSOUNDBUFFER; diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index a7149912f..b2cf5216e 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -186,8 +186,8 @@ WINBOOL WINAPI CloseHandle(HANDLE hObject); HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualReset, WINBOOL bInitialState, LPCSTR lpName); BOOL CloseEvent(HANDLE event); -BOOL WINAPI SetEvent(HANDLE hEvent); -BOOL WINAPI ResetEvent(HANDLE hEvent); +void SetEvent(HANDLE hEvent); +void ResetEvent(HANDLE hEvent); int WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds); WINBOOL WINAPI SetCursorPos(int X, int Y); diff --git a/SourceX/DiabloUI/art_draw.cpp b/SourceX/DiabloUI/art_draw.cpp index 0e0ca237a..04d87b21e 100644 --- a/SourceX/DiabloUI/art_draw.cpp +++ b/SourceX/DiabloUI/art_draw.cpp @@ -29,12 +29,12 @@ void DrawArt(int screenX, int screenY, Art *art, int nFrame, if (art->surface->format->BitsPerPixel == 8 && art->palette_version != pal_surface_palette_version) { if (SDLC_SetSurfaceColors(art->surface, pal_surface->format->palette) <= -1) - SDL_Log(SDL_GetError()); + ErrSdl(); art->palette_version = pal_surface_palette_version; } if (SDL_BlitSurface(art->surface, &src_rect, pal_surface, &dst_rect) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } diff --git a/SourceX/DiabloUI/credits.cpp b/SourceX/DiabloUI/credits.cpp index 97544036e..78ada6966 100644 --- a/SourceX/DiabloUI/credits.cpp +++ b/SourceX/DiabloUI/credits.cpp @@ -79,17 +79,16 @@ CachedLine PrepareLine(std::size_t index) // Blit the shadow first: SDL_Rect shadow_rect = { SHADOW_OFFSET_X, SHADOW_OFFSET_Y, 0, 0 }; if (SDL_BlitSurface(text.get(), nullptr, surface.get(), &shadow_rect) <= -1) - SDL_Log(SDL_GetError()); + ErrSdl(); // Change the text surface color and blit again: SDL_Color text_colors[2] = { mask_color, text_color }; - if (SDLC_SetSurfaceColors(text.get(), text_colors, 0, 2) <= -1) - SDL_Log(SDL_GetError()); + ErrSdl(); SDLC_SetColorKey(text.get(), 0); if (SDL_BlitSurface(text.get(), nullptr, surface.get(), nullptr) <= -1) - SDL_Log(SDL_GetError()); + ErrSdl(); } return CachedLine(index, std::move(surface)); @@ -236,7 +235,7 @@ void CreditsRenderer::Render() SDL_Rect dest_rect = { dest_x, dest_y, 0, 0 }; if (SDL_BlitSurface(line.surface.get(), nullptr, pal_surface, &dest_rect) <= -1) - SDL_Log(SDL_GetError()); + ErrSdl(); } SDL_SetClipRect(pal_surface, nullptr); } diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index 9a8532df2..75799fcd5 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -245,8 +245,9 @@ bool UiFocusNavigation(SDL_Event *event) char *clipboard = SDL_GetClipboardText(); if (clipboard == NULL) { SDL_Log(SDL_GetError()); + } else { + selhero_CatToName(clipboard, UiTextInput, UiTextInputLen); } - selhero_CatToName(clipboard, UiTextInput, UiTextInputLen); } return true; #endif @@ -353,7 +354,7 @@ void UiInitialize() LoadArtFonts(); if (ArtCursor.surface != nullptr) { if (SDL_ShowCursor(SDL_DISABLE) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } } diff --git a/SourceX/DiabloUI/progress.cpp b/SourceX/DiabloUI/progress.cpp index 798bd04d7..78171a1fc 100644 --- a/SourceX/DiabloUI/progress.cpp +++ b/SourceX/DiabloUI/progress.cpp @@ -67,12 +67,12 @@ void progress_Render(BYTE progress) static_cast(SCREEN_Y + y + 8), SCREEN_WIDTH, SCREEN_HEIGHT }; if (SDL_BlitSurface(msgSurface, NULL, pal_surface, &dsc_rect) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } dsc_rect.x = SCREEN_X + GetCenterOffset(textWidth) - 1; dsc_rect.y = SCREEN_Y + y + 99 + 4; if (SDL_BlitSurface(cancleSurface, NULL, pal_surface, &dsc_rect) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } } diff --git a/SourceX/DiabloUI/text_draw.cpp b/SourceX/DiabloUI/text_draw.cpp index 63a6cfd09..1de48d42d 100644 --- a/SourceX/DiabloUI/text_draw.cpp +++ b/SourceX/DiabloUI/text_draw.cpp @@ -57,9 +57,9 @@ void DrawTTF(const char *text, const SDL_Rect &rect, int flags, ++shadow_rect.x; ++shadow_rect.y; if (SDL_BlitSurface(shadow_surface, nullptr, pal_surface, &shadow_rect) <= -1) - SDL_Log(SDL_GetError()); + ErrSdl(); if (SDL_BlitSurface(text_surface, nullptr, pal_surface, &dest_rect) <= -1) - SDL_Log(SDL_GetError()); + ErrSdl(); } void DrawArtStr(const char *text, const SDL_Rect &rect, int flags, bool drawTextCursor) diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 2b9d63cc6..73a833924 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -44,15 +44,13 @@ void dx_create_back_buffer() { pal_surface = SDL_CreateRGBSurfaceWithFormat(0, BUFFER_WIDTH, BUFFER_HEIGHT, 8, SDL_PIXELFORMAT_INDEX8); if (pal_surface == NULL) { - SDL_Log(SDL_GetError()); - UiErrorOkDialog("SDL Error", SDL_GetError()); + ErrSdl(); } gpBuffer = (BYTE *)pal_surface->pixels; if (SDLC_SetSurfaceColors(pal_surface, palette) <= -1) { - SDL_Log(SDL_GetError()); - UiErrorOkDialog("SDL Error", SDL_GetError()); + ErrSdl(); } pal_surface_palette_version = 1; @@ -66,19 +64,18 @@ void dx_create_primary_surface() if (renderer) { int width, height; if (SDL_GetRendererOutputSize(renderer, &width, &height) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } Uint32 format; if (SDL_QueryTexture(texture, &format, nullptr, nullptr, nullptr) < 0) - SDL_Log(SDL_GetError()); + ErrSdl(); surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, SDL_BITSPERPIXEL(format), format); } else { surface = SDL_GetWindowSurface(window); } #endif if (surface == NULL) { - SDL_Log(SDL_GetError()); - UiErrorOkDialog("SDL Error", SDL_GetError()); + ErrSdl(); } } @@ -178,8 +175,7 @@ void CreatePalette() { palette = SDL_AllocPalette(256); if (palette == NULL) { - SDL_Log(SDL_GetError()); - UiErrorOkDialog("SDL Error", SDL_GetError()); + ErrSdl(); } } @@ -200,9 +196,7 @@ void BltFast(DWORD dwX, DWORD dwY, LPRECT lpSrcRect) // Convert from 8-bit to 32-bit if (SDL_BlitSurface(pal_surface, &src_rect, surface, &dst_rect) <= -1) { - SDL_Log(SDL_GetError()); - UiErrorOkDialog("SDL Error", SDL_GetError()); - return; + ErrSdl(); } bufferUpdated = true; @@ -218,30 +212,30 @@ void RenderPresent() #ifdef USE_SDL1 if (SDL_Flip(surface) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } #else if (renderer) { if (SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch) <= -1) { //pitch is 2560 - SDL_Log(SDL_GetError()); + ErrSdl(); } // Clear buffer to avoid artifacts in case the window was resized if (SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255) <= -1) { // TODO only do this if window was resized - SDL_Log(SDL_GetError()); + ErrSdl(); } if (SDL_RenderClear(renderer) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } if (SDL_RenderCopy(renderer, texture, NULL, NULL) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } SDL_RenderPresent(renderer); } else { if (SDL_UpdateWindowSurface(window) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } #endif diff --git a/SourceX/miniwin/dsound.cpp b/SourceX/miniwin/dsound.cpp index fd16b0a01..97e2fc72d 100644 --- a/SourceX/miniwin/dsound.cpp +++ b/SourceX/miniwin/dsound.cpp @@ -46,19 +46,19 @@ void DirectSoundBuffer::Stop() } }; -const char *DirectSoundBuffer::SetChunk(BYTE *fileData, DWORD dwBytes) +int DirectSoundBuffer::SetChunk(BYTE *fileData, DWORD dwBytes) { SDL_RWops *buf1 = SDL_RWFromConstMem(fileData, dwBytes); if (buf1 == NULL) { - return SDL_GetError(); + return -1; } chunk = Mix_LoadWAV_RW(buf1, 1); if (chunk == NULL) { - return SDL_GetError(); + return -1; } - return NULL; + return 0; }; } // namespace dvl diff --git a/SourceX/miniwin/dsound.h b/SourceX/miniwin/dsound.h index bbba055d2..0aa5e16b9 100644 --- a/SourceX/miniwin/dsound.h +++ b/SourceX/miniwin/dsound.h @@ -10,7 +10,7 @@ public: void GetStatus(LPDWORD pdwStatus) override; void Play(int lVolume, int lPan) override; void Stop() override; - const char *SetChunk(BYTE *fileData, DWORD dwBytes) override; + int SetChunk(BYTE *fileData, DWORD dwBytes) override; private: Mix_Chunk *chunk; diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index 5fd719525..52d560175 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -129,17 +129,10 @@ WINBOOL DeleteFileA(LPCSTR lpFileName) return true; } -void FakeWMDestroy() -{ - init_cleanup(); - PostMessageA(NULL, DVL_WM_QUERYENDSESSION, 0, 0); -} - bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) { if (SDL_Init(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC) <= -1) { - SDL_Log(SDL_GetError()); - return false; + ErrSdl(); } atexit(SDL_Quit); @@ -185,9 +178,8 @@ bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) window = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, nWidth, nHeight, flags); #endif if (window == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } - atexit(FakeWMDestroy); if (upscale) { #ifdef USE_SDL1 @@ -195,16 +187,16 @@ bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) #else renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); if (renderer == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, nWidth, nHeight); if (texture == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } if (SDL_RenderSetLogicalSize(renderer, nWidth, nHeight) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } #endif } diff --git a/SourceX/miniwin/thread.cpp b/SourceX/miniwin/thread.cpp index 434ce5956..8404171ee 100644 --- a/SourceX/miniwin/thread.cpp +++ b/SourceX/miniwin/thread.cpp @@ -44,7 +44,7 @@ uintptr_t DVL_beginthreadex(void *_Security, unsigned _StackSize, unsigned (*_St SDL_Thread *ret = SDL_CreateThread(thread_translate, NULL, ft); #endif if (ret == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } *_ThrdAddr = SDL_GetThreadID(ret); threads.insert((uintptr_t)ret); @@ -74,7 +74,7 @@ void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { SDL_mutex *m = SDL_CreateMutex(); if (m == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } *lpCriticalSection = m; } @@ -82,14 +82,14 @@ void InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) void EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { if (SDL_LockMutex(*((SDL_mutex **)lpCriticalSection)) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } void LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { if (SDL_UnlockMutex(*((SDL_mutex **)lpCriticalSection)) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } @@ -119,11 +119,11 @@ HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, WINBOOL bManualRese ret = (struct event_emul *)malloc(sizeof(struct event_emul)); ret->mutex = SDL_CreateMutex(); if (ret->mutex == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } ret->cond = SDL_CreateCond(); if (ret->cond == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } events.insert((uintptr_t)ret); return ret; @@ -141,31 +141,27 @@ BOOL CloseEvent(HANDLE hObject) return true; } -BOOL SetEvent(HANDLE hEvent) +void SetEvent(HANDLE hEvent) { struct event_emul *e = (struct event_emul *)hEvent; if (SDL_LockMutex(e->mutex) <= -1 || SDL_CondSignal(e->cond) <= -1 || SDL_UnlockMutex(e->mutex) <= -1) { - SDL_Log(SDL_GetError()); - return 0; + ErrSdl(); } - return 1; } -BOOL ResetEvent(HANDLE hEvent) +void ResetEvent(HANDLE hEvent) { struct event_emul *e = (struct event_emul *)hEvent; if (SDL_LockMutex(e->mutex) <= -1 || SDL_CondWaitTimeout(e->cond, e->mutex, 0) <= -1 || SDL_UnlockMutex(e->mutex) <= -1) { - SDL_Log(SDL_GetError()); - return 0; + ErrSdl(); } - return 1; } static int wait_for_sdl_cond(HANDLE hHandle, DWORD dwMilliseconds) { struct event_emul *e = (struct event_emul *)hHandle; if (SDL_LockMutex(e->mutex) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } int ret; if (dwMilliseconds == DVL_INFINITE) diff --git a/SourceX/sound.cpp b/SourceX/sound.cpp index 1581704a5..b8a47bb21 100644 --- a/SourceX/sound.cpp +++ b/SourceX/sound.cpp @@ -92,7 +92,7 @@ TSnd *sound_file_load(char *path) BYTE *wave_file; TSnd *pSnd; DWORD dwBytes; - const char *error; + int error; WOpenFile(path, &file, false); pSnd = (TSnd *)DiabloAllocPtr(sizeof(TSnd)); @@ -108,8 +108,8 @@ TSnd *sound_file_load(char *path) error = pSnd->DSB->SetChunk(wave_file, dwBytes); WCloseFile(file); mem_free_dbg(wave_file); - if (error != NULL) { - app_fatal("%s: %s", pSnd->sound_path, error); + if (error != 0) { + ErrSdl(); } return pSnd; @@ -210,7 +210,7 @@ void music_start(int nTrack) musicRw = SDL_RWFromConstMem(musicBuffer, bytestoread); if (musicRw == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } music = Mix_LoadMUSType_RW(musicRw, MUS_NONE, 1); Mix_VolumeMusic(MIX_MAX_VOLUME - MIX_MAX_VOLUME * sglMusicVolume / VOLUME_MIN); diff --git a/SourceX/storm/storm.cpp b/SourceX/storm/storm.cpp index 29dc1cb4b..94439aa12 100644 --- a/SourceX/storm/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -77,6 +77,7 @@ BOOL SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDi SDL_RWops *rw = SDL_RWFromConstMem(SFXbuffer, bytestoread); if (rw == NULL) { SDL_Log(SDL_GetError()); + return false; } SFileChunk = Mix_LoadWAV_RW(rw, 1); free(SFXbuffer); @@ -526,10 +527,10 @@ private: static AudioQueue *sVidAudioQueue = new AudioQueue(); #endif -BOOL SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video) +void SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video) { if (flags & 0x10000 || flags & 0x20000000) { - return false; + return; } SVidLoop = flags & 0x40000; @@ -549,7 +550,7 @@ BOOL SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA SVidSMK = smk_open_memory(SVidBuffer, bytestoread); if (SVidSMK == NULL) { - return false; + return; } unsigned char channels[7], depth[7]; @@ -568,17 +569,13 @@ BOOL SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA #ifdef USE_SDL1 sVidAudioQueue->Subscribe(&audioFormat); if (SDL_OpenAudio(&audioFormat, NULL) != 0) { - SDL_Log(SDL_GetError()); - SVidRestartMixer(); - return false; + ErrSdl(); } SDL_PauseAudio(0); #else deviceId = SDL_OpenAudioDevice(NULL, 0, &audioFormat, NULL, 0); if (deviceId == 0) { - SDL_Log(SDL_GetError()); - SVidRestartMixer(); - return false; + ErrSdl(); } SDL_PauseAudioDevice(deviceId, 0); /* start audio playing. */ @@ -598,10 +595,10 @@ BOOL SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA SDL_DestroyTexture(texture); texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, SVidWidth, SVidHeight); if (texture == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } if (SDL_RenderSetLogicalSize(renderer, SVidWidth, SVidHeight) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } #endif @@ -616,23 +613,18 @@ BOOL SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA SVidWidth, SDL_PIXELFORMAT_INDEX8); if (SVidSurface == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } SVidPalette = SDL_AllocPalette(256); if (SVidPalette == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } if (SDLC_SetSurfaceColors(SVidSurface, SVidPalette) <= -1) { - SDL_Log(SDL_GetError()); - if (HaveAudio()) - SVidRestartMixer(); - return false; + ErrSdl(); } SVidFrameEnd = SDL_GetTicks() * 1000 + SVidFrameLength; - - return true; } BOOL SVidLoadNextFrame() @@ -748,7 +740,7 @@ BOOL SVidPlayContinue(void) return SVidLoadNextFrame(); } -BOOL SVidPlayEnd(HANDLE video) +void SVidPlayEnd(HANDLE video) { if (HaveAudio()) { #ifdef USE_SDL1 @@ -785,15 +777,13 @@ BOOL SVidPlayEnd(HANDLE video) SDL_DestroyTexture(texture); texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, SCREEN_WIDTH, SCREEN_HEIGHT); if (texture == NULL) { - SDL_Log(SDL_GetError()); + ErrSdl(); } if (renderer && SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT) <= -1) { - SDL_Log(SDL_GetError()); + ErrSdl(); } } #endif - - return true; } DWORD SErrGetLastError() diff --git a/SourceX/storm/storm_dx.cpp b/SourceX/storm/storm_dx.cpp index b22e5fbb1..afd7cbd86 100644 --- a/SourceX/storm/storm_dx.cpp +++ b/SourceX/storm/storm_dx.cpp @@ -6,7 +6,7 @@ namespace dvl { -BOOL SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) +void SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) { assert(firstentry == 0); assert(numentries == 256); @@ -25,12 +25,9 @@ BOOL SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETT assert(palette); if (SDLC_SetSurfaceAndPaletteColors(pal_surface, palette, colors, firstentry, numentries) <= -1) { - SDL_Log(SDL_GetError()); - return false; + ErrSdl(); } - ++pal_surface_palette_version; - - return true; + pal_surface_palette_version++; } } // namespace dvl diff --git a/defs.h b/defs.h index f42e5e53f..bb6db74a2 100644 --- a/defs.h +++ b/defs.h @@ -163,3 +163,5 @@ #define SwapLE32 SDL_SwapLE32 #define SwapLE16 SDL_SwapLE16 + +#define ErrSdl() ErrDlg("SDL Error", SDL_GetError(), __FILE__, __LINE__)