1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 09:39:43 +01:00

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

View file

@ -3361,6 +3361,11 @@ void Graphics::textboxtranslate(const TextboxTranslate translate, const TextboxF
SDL_assert(0 && "function is NULL!"); SDL_assert(0 && "function is NULL!");
return; 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].translate = translate;
textboxes[m].function = function; textboxes[m].function = function;