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. :)
This commit is contained in:
Misa 2024-01-21 12:31:21 -08:00 committed by Misa Elizabeth Kai
parent 76483f96ef
commit 668d0c744d
1 changed files with 5 additions and 0 deletions

View File

@ -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;