From 668d0c744d5b93d471399594916ae6153c071c34 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 21 Jan 2024 12:31:21 -0800 Subject: [PATCH] Add assert for giving func if it won't be used This adds an assert to Graphics::textboxtranslate() to make sure that callers don't accidentally provide a function when specifying a translation type that isn't TEXTTRANSLATE_FUNCTION, because in that case the function won't be used, and then it will make them scratch their heads wondering why their function won't work. And yes, I am stupid enough to blindly type TEXTTRANSLATE_CUTSCENE when I meant to type TEXTTRANSLATE_FUNCTION. This assert has already caught one of my mistakes. :) --- desktop_version/src/Graphics.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 6bf079c6..245f8058 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -3361,6 +3361,11 @@ void Graphics::textboxtranslate(const TextboxTranslate translate, const TextboxF SDL_assert(0 && "function is NULL!"); return; } + if (translate != TEXTTRANSLATE_FUNCTION && function != NULL) + { + SDL_assert(0 && "function provided when it won't be used!"); + return; + } textboxes[m].translate = translate; textboxes[m].function = function;