mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 16:07:55 +00:00
Split action parsing out of ParseStates() and into ParseAction()
This commit is contained in:
parent
910451a351
commit
00274c5e4c
2 changed files with 35 additions and 25 deletions
|
@ -189,6 +189,7 @@ AFuncDesc *FindFunction(const char * string);
|
||||||
void ParseStates(FScanner &sc, PClassActor *actor, AActor *defaults, Baggage &bag);
|
void ParseStates(FScanner &sc, PClassActor *actor, AActor *defaults, Baggage &bag);
|
||||||
void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression *> &out_params,
|
void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression *> &out_params,
|
||||||
PFunction *afd, FString statestring, FStateDefinitions *statedef);
|
PFunction *afd, FString statestring, FStateDefinitions *statedef);
|
||||||
|
bool ParseAction(FScanner &sc, FState state, FString statestring, FStateTempCall *tcall, Baggage &bag);
|
||||||
|
|
||||||
PFunction *FindGlobalActionFunction(const char *name);
|
PFunction *FindGlobalActionFunction(const char *name);
|
||||||
|
|
||||||
|
|
|
@ -314,34 +314,10 @@ do_stop:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the action name lowercase
|
if (ParseAction(sc, state, statestring, tcall, bag))
|
||||||
strlwr (sc.String);
|
|
||||||
|
|
||||||
tcall->Call = DoActionSpecials(sc, state, bag);
|
|
||||||
if (tcall->Call != NULL)
|
|
||||||
{
|
{
|
||||||
goto endofstate;
|
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();
|
sc.UnGet();
|
||||||
endofstate:
|
endofstate:
|
||||||
|
@ -372,6 +348,39 @@ endofstate:
|
||||||
sc.SetEscape(true); // re-enable escape sequences
|
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
|
// ParseFunctionParameters
|
||||||
|
|
Loading…
Reference in a new issue