fixed potentially undefined behavior with bool parameters in direct native functions.

This commit is contained in:
Christoph Oelckers 2023-11-06 22:58:06 +01:00
parent 47a77fc8f1
commit 0bcfd5ca92

View file

@ -667,7 +667,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetBottomAlignOffset, GetBottomAlignOffset)
ACTION_RETURN_FLOAT(GetBottomAlignOffset(self, code));
}
static int StringWidth(FFont *font, const FString &str, bool localize)
static int StringWidth(FFont *font, const FString &str, int localize)
{
const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars();
return font->StringWidth(txt);
@ -681,7 +681,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, StringWidth, StringWidth)
ACTION_RETURN_INT(StringWidth(self, str, localize));
}
static int GetMaxAscender(FFont* font, const FString& str, bool localize)
static int GetMaxAscender(FFont* font, const FString& str, int localize)
{
const char* txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars();
return font->GetMaxAscender(txt);
@ -695,7 +695,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetMaxAscender, GetMaxAscender)
ACTION_RETURN_INT(GetMaxAscender(self, str, localize));
}
static int CanPrint(FFont *font, const FString &str, bool localize)
static int CanPrint(FFont *font, const FString &str, int localize)
{
const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars();
return font->CanPrint(txt);