Allow empty parameter lists for action functions without parameters

- Using A_Scream() in a state instead of A_Scream is now valid.
This commit is contained in:
Randy Heit 2015-01-06 19:44:20 -06:00
parent 8c105ff3a0
commit 320fb9aec5

View file

@ -391,6 +391,8 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
const TArray<DWORD> &paramflags = afd->Variants[0].ArgFlags; const TArray<DWORD> &paramflags = afd->Variants[0].ArgFlags;
int numparams = (int)params.Size(); int numparams = (int)params.Size();
int pnum = 0; int pnum = 0;
bool zeroparm;
if (afd->Flags & VARF_Method) if (afd->Flags & VARF_Method)
{ {
numparams--; numparams--;
@ -401,83 +403,80 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
numparams -= 2; numparams -= 2;
pnum += 2; pnum += 2;
} }
if (numparams > 0) assert(numparams >= 0);
zeroparm = numparams == 0;
if (numparams > 0 && !(paramflags[pnum] & VARF_Optional))
{ {
int v; sc.MustGetStringName("(");
}
if (!(paramflags[pnum] & VARF_Optional)) else
{
if (!sc.CheckString("("))
{ {
sc.MustGetStringName("("); return;
} }
else }
while (numparams > 0)
{
FxExpression *x;
if (statedef != NULL && params[pnum] == TypeState && sc.CheckNumber())
{ {
if (!sc.CheckString("(")) // Special case: State label as an offset
if (sc.Number > 0 && statestring.Len() > 1)
{ {
return; sc.ScriptError("You cannot use state jumps commands with a jump offset on multistate definitions\n");
} }
}
int v = sc.Number;
while (numparams > 0) if (v < 0)
{
FxExpression *x;
if (statedef != NULL && params[pnum] == TypeState && sc.CheckNumber())
{ {
// Special case: State label as an offset sc.ScriptError("Negative jump offsets are not allowed");
if (sc.Number > 0 && statestring.Len() > 1) }
{
sc.ScriptError("You cannot use state jumps commands with a jump offset on multistate definitions\n");
}
v = sc.Number; if (v > 0)
if (v<0) {
{ x = new FxStateByIndex(statedef->GetStateCount() + v, sc);
sc.ScriptError("Negative jump offsets are not allowed");
}
if (v > 0)
{
x = new FxStateByIndex(statedef->GetStateCount() + v, sc);
}
else
{
x = new FxConstant((FState*)NULL, sc);
}
} }
else else
{ {
// Use the generic parameter parser for everything else x = new FxConstant((FState*)NULL, sc);
x = ParseParameter(sc, cls, params[pnum], false);
} }
out_params.Push(new FxParameter(x)); }
pnum++; else
numparams--; {
if (numparams > 0) // Use the generic parameter parser for everything else
{ x = ParseParameter(sc, cls, params[pnum], false);
if (params[pnum] == NULL) }
{ // varargs function out_params.Push(new FxParameter(x));
if (sc.CheckString(")")) pnum++;
{ numparams--;
return; if (numparams > 0)
} {
pnum--; if (params[pnum] == NULL)
numparams++; { // varargs function
} if (sc.CheckString(")"))
else if ((paramflags[pnum] & VARF_Optional) && sc.CheckString(")"))
{ {
return; return;
} }
sc.MustGetStringName (","); pnum--;
numparams++;
} }
else if ((paramflags[pnum] & VARF_Optional) && sc.CheckString(")"))
{
return;
}
sc.MustGetStringName (",");
} }
sc.MustGetStringName(")");
} }
else if (zeroparm)
{ {
sc.MustGetString(); if (!sc.CheckString(")"))
if (sc.Compare("("))
{ {
sc.ScriptError("You cannot pass parameters to '%s'\n", afd->SymbolName.GetChars()); sc.ScriptError("You cannot pass parameters to '%s'\n", afd->SymbolName.GetChars());
} }
sc.UnGet(); }
else
{
sc.MustGetStringName(")");
} }
} }