mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
IsPointerEqual (ACS and Decorate)
Decorate: IsPointerEqual(int aaptr_selector1, int aaptr_selector2) ACS: IsPointerEqual(int aaptr_selector1, int aaptr_selector2, int tid1 = 0, int tid2 = 0) Compare the pointers values returned by two pointer select operations. Returns true if they both resolve to the same value. Null values can be explicitly tested using IsPointerEqual(AAPTR_NULL, ...) ACS: IsPointerEqual(int aaptr1, int aaptr2, int tid1 = 0, int tid2 = 0) This function lets you compare pointers from other actors than the activator, using tids. Tid1 determines the actor used to resolve aaptr1, Tid2 does the same for aaptr2. If tid1 and tid2 are equal, the same actor will be used for resolving both pointers (that could always happen randomly; this way you know it will happen).
This commit is contained in:
parent
42c1ff2310
commit
a2f7b86a0f
3 changed files with 52 additions and 1 deletions
|
@ -299,6 +299,7 @@ xx(ACS_NamedExecuteWithResult)
|
||||||
xx(CallACS)
|
xx(CallACS)
|
||||||
xx(Sqrt)
|
xx(Sqrt)
|
||||||
xx(CheckClass)
|
xx(CheckClass)
|
||||||
|
xx(IsPointerEqual)
|
||||||
|
|
||||||
// Various actor names which are used internally
|
// Various actor names which are used internally
|
||||||
xx(MapSpot)
|
xx(MapSpot)
|
||||||
|
|
|
@ -4373,6 +4373,7 @@ enum EACSFunctions
|
||||||
ACSF_GetArmorInfo,
|
ACSF_GetArmorInfo,
|
||||||
ACSF_DropInventory,
|
ACSF_DropInventory,
|
||||||
ACSF_PickActor,
|
ACSF_PickActor,
|
||||||
|
ACSF_IsPointerEqual,
|
||||||
|
|
||||||
/* Zandronum's - these must be skipped when we reach 99!
|
/* Zandronum's - these must be skipped when we reach 99!
|
||||||
-100:ResetMap(0),
|
-100:ResetMap(0),
|
||||||
|
@ -5630,6 +5631,22 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ACSF_IsPointerEqual:
|
||||||
|
{
|
||||||
|
int tid1 = 0, tid2 = 0;
|
||||||
|
switch (argCount)
|
||||||
|
{
|
||||||
|
case 4: tid2 = args[3];
|
||||||
|
case 3: tid1 = args[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
actor = SingleActorFromTID(tid1, activator);
|
||||||
|
AActor * actor2 = tid2 == tid1 ? actor : SingleActorFromTID(tid2, activator);
|
||||||
|
|
||||||
|
return COPY_AAPTR(actor, args[0]) == COPY_AAPTR(actor2, args[1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,4 +260,37 @@ class FxGlobalFunctionCall_CheckClass : public FxGlobalFunctionCall
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GLOBALFUNCTION_ADDER(CheckClass);
|
GLOBALFUNCTION_ADDER(CheckClass);
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Function: ispointerequal
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
class FxGlobalFunctionCall_IsPointerEqual : public FxGlobalFunctionCall
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GLOBALFUNCTION_DEFINE(IsPointerEqual);
|
||||||
|
|
||||||
|
FxExpression *Resolve(FCompileContext& ctx)
|
||||||
|
{
|
||||||
|
CHECKRESOLVED();
|
||||||
|
|
||||||
|
if (!ResolveArgs(ctx, 2, 2, true))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ValueType = VAL_Int;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpVal EvalExpression(AActor *self)
|
||||||
|
{
|
||||||
|
ExpVal ret;
|
||||||
|
ret.Type = VAL_Int;
|
||||||
|
ret.Int = COPY_AAPTR(self, (*ArgList)[0]->EvalExpression(self).GetInt()) == COPY_AAPTR(self, (*ArgList)[1]->EvalExpression(self).GetInt());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GLOBALFUNCTION_ADDER(IsPointerEqual);
|
Loading…
Reference in a new issue