mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Reimplement CheckClass and IsPointerEqual functions
- The definition of FxGlobalFunctionCall_CheckClass was big and scary. I would say this is a big improvement, since now it gets to leverage the same framework that action functions use. - The definition of FxGlobalFunctionCall_IsPointerEqual was not so big and scary, so this can't be called so much of an improvement as CheckClass was. (Which is not to say that it isn't better anyway.)
This commit is contained in:
parent
c6c2b21901
commit
85a2042394
2 changed files with 64 additions and 0 deletions
|
@ -152,6 +152,67 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state)
|
||||||
return !!result;
|
return !!result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// CheckClass
|
||||||
|
//
|
||||||
|
// NON-ACTION function to check a pointer's class.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(AActor, CheckClass)
|
||||||
|
{
|
||||||
|
if (numret > 0)
|
||||||
|
{
|
||||||
|
assert(ret != NULL);
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_OBJECT (self, AActor);
|
||||||
|
PARAM_CLASS (checktype, AActor);
|
||||||
|
PARAM_INT_OPT (pick_pointer) { pick_pointer = AAPTR_DEFAULT; }
|
||||||
|
PARAM_BOOL_OPT (match_superclass) { match_superclass = false; }
|
||||||
|
|
||||||
|
self = COPY_AAPTR(self, pick_pointer);
|
||||||
|
if (self == NULL)
|
||||||
|
{
|
||||||
|
ret->SetInt(false);
|
||||||
|
}
|
||||||
|
else if (match_superclass)
|
||||||
|
{
|
||||||
|
ret->SetInt(self->IsKindOf(checktype));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret->SetInt(self->GetClass() == checktype);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// IsPointerEqual
|
||||||
|
//
|
||||||
|
// NON-ACTION function to check if two pointers are equal.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, IsPointerEqual)
|
||||||
|
{
|
||||||
|
if (numret > 0)
|
||||||
|
{
|
||||||
|
assert(ret != NULL);
|
||||||
|
PARAM_PROLOGUE;
|
||||||
|
PARAM_OBJECT (self, AActor);
|
||||||
|
PARAM_INT (ptr_select1);
|
||||||
|
PARAM_INT (ptr_select2);
|
||||||
|
|
||||||
|
ret->SetInt(COPY_AAPTR(self, ptr_select1) == COPY_AAPTR(self, ptr_select2));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// A_RearrangePointers
|
// A_RearrangePointers
|
||||||
|
|
|
@ -66,6 +66,9 @@ ACTOR Actor native //: Thinker
|
||||||
native fixed_t meleerange;
|
native fixed_t meleerange;
|
||||||
native fixed_t speed;
|
native fixed_t speed;
|
||||||
|
|
||||||
|
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
|
||||||
|
native bool IsPointerEqual(int ptr_select1, int ptr_select2);
|
||||||
|
|
||||||
// Meh, MBF redundant functions. Only for DeHackEd support.
|
// Meh, MBF redundant functions. Only for DeHackEd support.
|
||||||
action native A_Turn(float angle = 0);
|
action native A_Turn(float angle = 0);
|
||||||
action native A_LineEffect(int boomspecial = 0, int tag = 0);
|
action native A_LineEffect(int boomspecial = 0, int tag = 0);
|
||||||
|
|
Loading…
Reference in a new issue