From 3102cac9d985f607d67ba0a17208e7d5d94b711c Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 18 Apr 2021 10:58:28 -0700 Subject: [PATCH] Add asserts for missing images and sound effects I don't want to add too many asserts, because sometimes it's okay if a file is missing (mmmmmm.vvv). But currently, the game basically expects all images and sound effects to be present. That might change in the future, but for now, these asserts are okay. --- desktop_version/src/GraphicsResources.cpp | 5 +++++ desktop_version/src/SoundSystem.cpp | 1 + 2 files changed, 6 insertions(+) diff --git a/desktop_version/src/GraphicsResources.cpp b/desktop_version/src/GraphicsResources.cpp index acc1fa71..0b07cd3e 100644 --- a/desktop_version/src/GraphicsResources.cpp +++ b/desktop_version/src/GraphicsResources.cpp @@ -37,6 +37,11 @@ static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool no unsigned char *fileIn; size_t length; FILESYSTEM_loadAssetToMemory(filename, &fileIn, &length, false); + if (fileIn == NULL) + { + SDL_assert(0 && "Image file missing!"); + return NULL; + } if (noAlpha) { lodepng_decode24(&data, &width, &height, fileIn, length); diff --git a/desktop_version/src/SoundSystem.cpp b/desktop_version/src/SoundSystem.cpp index e5d0ead8..8c5f962c 100644 --- a/desktop_version/src/SoundSystem.cpp +++ b/desktop_version/src/SoundSystem.cpp @@ -38,6 +38,7 @@ SoundTrack::SoundTrack(const char* fileName) if (mem == NULL) { fprintf(stderr, "Unable to load WAV file %s\n", fileName); + SDL_assert(0 && "WAV file missing!"); return; } SDL_RWops *fileIn = SDL_RWFromConstMem(mem, length);