Split action parsing out of ParseStates() and into ParseAction()

This commit is contained in:
Randy Heit 2015-01-06 20:02:22 -06:00
parent 910451a351
commit 00274c5e4c
2 changed files with 35 additions and 25 deletions

View file

@ -189,6 +189,7 @@ AFuncDesc *FindFunction(const char * string);
void ParseStates(FScanner &sc, PClassActor *actor, AActor *defaults, Baggage &bag);
void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression *> &out_params,
PFunction *afd, FString statestring, FStateDefinitions *statedef);
bool ParseAction(FScanner &sc, FState state, FString statestring, FStateTempCall *tcall, Baggage &bag);
PFunction *FindGlobalActionFunction(const char *name);

View file

@ -314,34 +314,10 @@ do_stop:
continue;
}
// Make the action name lowercase
strlwr (sc.String);
tcall->Call = DoActionSpecials(sc, state, bag);
if (tcall->Call != NULL)
if (ParseAction(sc, state, statestring, tcall, bag))
{
goto endofstate;
}
PFunction *afd = dyn_cast<PFunction>(bag.Info->Symbols.FindSymbol(FName(sc.String, true), true));
if (afd != NULL)
{
// When creating the FxVMFunctionCall, we only pass args if there are any.
// So if the previous call had no args, then we can use the argument list
// allocated for it. Otherwise, we need to create a new one.
if (args == NULL)
{
args = new FArgumentList;
}
ParseFunctionParameters(sc, bag.Info, *args, afd, statestring, &bag.statedef);
tcall->Call = new FxVMFunctionCall(afd, args->Size() > 0 ? args : NULL, sc);
if (args->Size() > 0)
{
args = NULL;
}
goto endofstate;
}
sc.ScriptError("Invalid state parameter %s\n", sc.String);
}
sc.UnGet();
endofstate:
@ -372,6 +348,39 @@ endofstate:
sc.SetEscape(true); // re-enable escape sequences
}
//==========================================================================
//
// ParseAction
//
//==========================================================================
bool ParseAction(FScanner &sc, FState state, FString statestring, FStateTempCall *tcall, Baggage &bag)
{
// Make the action name lowercase
strlwr (sc.String);
tcall->Call = DoActionSpecials(sc, state, bag);
if (tcall->Call != NULL)
{
return true;
}
PFunction *afd = dyn_cast<PFunction>(bag.Info->Symbols.FindSymbol(FName(sc.String, true), true));
if (afd != NULL)
{
FArgumentList *args = new FArgumentList;
ParseFunctionParameters(sc, bag.Info, *args, afd, statestring, &bag.statedef);
tcall->Call = new FxVMFunctionCall(afd, args->Size() > 0 ? args : NULL, sc);
if (args->Size() == 0)
{
delete args;
}
return true;
}
sc.ScriptError("Invalid state parameter %s\n", sc.String);
return false;
}
//==========================================================================
//
// ParseFunctionParameters