Menudef bool arguments expect integers Fix

This commit is contained in:
SAN4EZDREAMS 2025-08-01 23:53:05 +03:00 committed by GitHub
commit 0418bec4b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -511,20 +511,33 @@ static void DoParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc, bool &s
}
else if (args[i]->isIntCompatible())
{
char *endp;
int v = (int)strtoll(sc.String, &endp, 0);
if (*endp != 0)
int v;
if (sc.Compare("true"))
{
// special check for font color ranges.
v = V_FindFontColor(sc.String);
if (v == CR_UNTRANSLATED && !sc.Compare("untranslated"))
v = 1;
}
else if (sc.Compare("false"))
{
v = 0;
}
else
{
char *endp;
v = (int)strtoll(sc.String, &endp, 0);
if (*endp != 0)
{
// todo: check other data types that may get used.
sc.ScriptError("Integer expected, got %s", sc.String);
// special check for font color ranges.
v = V_FindFontColor(sc.String);
if (v == CR_UNTRANSLATED && !sc.Compare("untranslated"))
{
// todo: check other data types that may get used.
sc.ScriptError("Integer expected, got %s", sc.String);
}
}
}
if (args[i] == TypeBool) v = !!v;
params.Push(v);
if (args[i] == TypeBool) v = !!v;
params.Push(v);
}
else if (args[i]->isFloat())
{
@ -1114,19 +1127,32 @@ static void ParseOptionMenuBody(FScanner &sc, DOptionMenuDescriptor *desc, int i
}
else if (args[i]->isIntCompatible())
{
char *endp;
int v = (int)strtoll(sc.String, &endp, 0);
if (*endp != 0)
int v;
if (sc.Compare("true"))
{
// special check for font color ranges.
v = V_FindFontColor(sc.String);
if (v == CR_UNTRANSLATED && !sc.Compare("untranslated"))
v = 1;
}
else if (sc.Compare("false"))
{
v = 0;
}
else
{
char *endp;
v = (int)strtoll(sc.String, &endp, 0);
if (*endp != 0)
{
// todo: check other data types that may get used.
sc.ScriptError("Integer expected, got %s", sc.String);
// special check for font color ranges.
v = V_FindFontColor(sc.String);
if (v == CR_UNTRANSLATED && !sc.Compare("untranslated"))
{
// todo: check other data types that may get used.
sc.ScriptError("Integer expected, got %s", sc.String);
}
// Color ranges need to be marked for option menu items to support an older feature where a boolean number could be passed instead.
v |= 0x12340000;
}
// Color ranges need to be marked for option menu items to support an older feature where a boolean number could be passed instead.
v |= 0x12340000;
}
if (args[i] == TypeBool) v = !!v;
params.Push(v);
@ -1403,16 +1429,29 @@ static void ParseImageScrollerBody(FScanner& sc, DImageScrollerDescriptor* desc)
}
else if (args[i]->isIntCompatible())
{
char* endp;
int v = (int)strtoll(sc.String, &endp, 0);
if (*endp != 0)
int v;
if (sc.Compare("true"))
{
// special check for font color ranges.
v = V_FindFontColor(sc.String);
if (v == CR_UNTRANSLATED && !sc.Compare("untranslated"))
v = 1;
}
else if (sc.Compare("false"))
{
v = 0;
}
else
{
char* endp;
v = (int)strtoll(sc.String, &endp, 0);
if (*endp != 0)
{
// todo: check other data types that may get used.
sc.ScriptError("Integer expected, got %s", sc.String);
// special check for font color ranges.
v = V_FindFontColor(sc.String);
if (v == CR_UNTRANSLATED && !sc.Compare("untranslated"))
{
// todo: check other data types that may get used.
sc.ScriptError("Integer expected, got %s", sc.String);
}
}
}
if (args[i] == TypeBool) v = !!v;