- Added ACS_NamedExecuteWithResult for DECORATE expressions. Since this is a pretty long name,

you can also use CallACS, if you wish. The two are synonyms.

SVN r3373 (trunk)
This commit is contained in:
Randy Heit 2012-02-21 19:24:02 +00:00
parent d9b8b344ff
commit 7b5612c45a
3 changed files with 50 additions and 7 deletions

View file

@ -270,6 +270,8 @@ xx(MomX)
xx(MomY) xx(MomY)
xx(MomZ) xx(MomZ)
xx(Abs) xx(Abs)
xx(ACS_NamedExecuteWithResult)
xx(CallACS)
// Various actor names which are used internally // Various actor names which are used internally
xx(MapSpot) xx(MapSpot)

View file

@ -336,6 +336,18 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
{ {
return new FxConstant(sc.Float, scpos); return new FxConstant(sc.Float, scpos);
} }
else if (sc.CheckToken(TK_NameConst))
{
return new FxConstant(sc.Name, scpos);
}
else if (sc.CheckToken(TK_StringConst))
{
// String parameters are converted to names. Technically, this should be
// done at a higher level, as needed, but since no functions take string
// arguments and ACS_NamedExecuteWithResult/CallACS need names, this is
// a cheap way to get them working when people use "name" instead of 'name'.
return new FxConstant(FName(sc.String), scpos);
}
else if (sc.CheckToken(TK_Random)) else if (sc.CheckToken(TK_Random))
{ {
FRandom *rng; FRandom *rng;

View file

@ -1868,7 +1868,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
newex = new FxCVar(cv, ScriptPosition); newex = new FxCVar(cv, ScriptPosition);
} }
*/ */
// amd line specials // and line specials
else if ((num = P_FindLineSpecial(Identifier, NULL, NULL))) else if ((num = P_FindLineSpecial(Identifier, NULL, NULL)))
{ {
ScriptPosition.Message(MSG_DEBUGLOG, "Resolving name '%s' as line special %d\n", Identifier.GetChars(), num); ScriptPosition.Message(MSG_DEBUGLOG, "Resolving name '%s' as line special %d\n", Identifier.GetChars(), num);
@ -2293,9 +2293,18 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
return x->Resolve(ctx); return x->Resolve(ctx);
} }
int min, max; int min, max, special;
int special = P_FindLineSpecial(MethodName.GetChars(), &min, &max); if (MethodName == NAME_ACS_NamedExecuteWithResult || MethodName == NAME_CallACS)
if (special > 0 && min >= 0) {
special = -ACS_ExecuteWithResult;
min = 1;
max = 5;
}
else
{
special = P_FindLineSpecial(MethodName.GetChars(), &min, &max);
}
if (special != 0 && min >= 0)
{ {
int paramcount = ArgList? ArgList->Size() : 0; int paramcount = ArgList? ArgList->Size() : 0;
if (paramcount < min) if (paramcount < min)
@ -2326,7 +2335,10 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
//========================================================================== //==========================================================================
// //
// FxActionSpecialCall
// //
// If special is negative, then the first argument will be treated as a
// name for ACS_NamedExecuteWithResult.
// //
//========================================================================== //==========================================================================
@ -2367,7 +2379,15 @@ FxExpression *FxActionSpecialCall::Resolve(FCompileContext& ctx)
{ {
(*ArgList)[i] = (*ArgList)[i]->Resolve(ctx); (*ArgList)[i] = (*ArgList)[i]->Resolve(ctx);
if ((*ArgList)[i] == NULL) failed = true; if ((*ArgList)[i] == NULL) failed = true;
if ((*ArgList)[i]->ValueType != VAL_Int) if (Special < 0 && i == 0)
{
if ((*ArgList)[i]->ValueType != VAL_Name)
{
ScriptPosition.Message(MSG_ERROR, "Name expected for parameter %d", i);
failed = true;
}
}
else if ((*ArgList)[i]->ValueType != VAL_Int)
{ {
if (ctx.lax && ((*ArgList)[i]->ValueType == VAL_Float)) if (ctx.lax && ((*ArgList)[i]->ValueType == VAL_Float))
{ {
@ -2400,6 +2420,7 @@ FxExpression *FxActionSpecialCall::Resolve(FCompileContext& ctx)
ExpVal FxActionSpecialCall::EvalExpression (AActor *self) ExpVal FxActionSpecialCall::EvalExpression (AActor *self)
{ {
int v[5] = {0,0,0,0,0}; int v[5] = {0,0,0,0,0};
int special = Special;
if (Self != NULL) if (Self != NULL)
{ {
@ -2409,13 +2430,21 @@ ExpVal FxActionSpecialCall::EvalExpression (AActor *self)
if (ArgList != NULL) if (ArgList != NULL)
{ {
for(unsigned i = 0; i < ArgList->Size(); i++) for(unsigned i = 0; i < ArgList->Size(); i++)
{
if (special < 0)
{
special = -special;
v[i] = -(*ArgList)[i]->EvalExpression(self).GetName();
}
else
{ {
v[i] = (*ArgList)[i]->EvalExpression(self).GetInt(); v[i] = (*ArgList)[i]->EvalExpression(self).GetInt();
} }
} }
}
ExpVal ret; ExpVal ret;
ret.Type = VAL_Int; ret.Type = VAL_Int;
ret.Int = P_ExecuteSpecial(Special, NULL, self, false, v[0], v[1], v[2], v[3], v[4]); ret.Int = P_ExecuteSpecial(special, NULL, self, false, v[0], v[1], v[2], v[3], v[4]);
return ret; return ret;
} }