Spoiler: Original: compareptr.zipI have updated this. New definition:
Core submission - modifications of the original
ACS: bool ComparePointers(int ptr_selector, int ptr_compare); (returns true if two equal pointers are retrieved; treats two NULL-results (no actor) as equal)
To check that two actors are equal and that they do both exist: ComparePointers(AAPTR_SOMETHING, AAPTR_ELSE) && !ComparePointers(AAPTR_SOMETHING, AAPTR_NULL)
Decorate: A_ComparePointers(state jumpto, int ptr_selector, int ptr_compare)
Same rules as the ACS function. Jumps to the chosen state if the actors are equal.
To jump only for non-null equality:
... A_ComparePointers(2, AAPTR_SOMETHING, AAPTR_NULL)
... A_ComparePointers("dest", AAPTR_SOMETHING, AAPTR_ELSE)
......
The non-null checks are not needed when (a) you want to jump if both are null, (b) you can be sure that at least one of them is non-null.
String/Name features (Imports feature from http://forum.zdoom.org/viewtopic.php?f=34&t=30806)
int StringID(str stringConstant): Constant decorate expression returning an int that can be resolved to stringConstant. For "name" strings, that int is unique to that string.
int ClassID([int ptr_selector]): Decorate expression returning an int that can be resolved into a class name. For "name" strings, that int is unique to that string.
ptr_selector: Default = AAPTR_DEFAULT (self).
ClassID() returns the string id for the calling actor's class.
ClassID(AAPTR_TARGET) returns the string id for the calling actor's target's class, or NAME_None (0) if there is no target.
ClassID(a) == ClassID(b) is conclusive evidence that two actors are of the same class
StringID("ClassName") == ClassID(a) is conclusive evidence that an actor is of class ClassName.
(( StringID and ClassID are designed for use with A_JumpIf(), but also work with A_ChangeFlag() and any other int-accepting function ))
The ACC/ZDOOM patch contains an extension (from http://forum.zdoom.org/viewtopic.php?f=34&t=30806) to the print syntax: g:x. It resolves a ClassID(x) or StringID("x") from its integer value and back to the string.
PS: I believe you can use StringID("something") in const-declarations. Didn't try, but it should work. (You would often not need that. But the possibility is there.)
... Summary ...
ACS bool ComparePointers(int ptr_selector, int ptr_compare)
Decorate A_ComparePointers(state jumpto, int ptr_selector, int ptr_compare)
Decorate constant int StringID(str stringLiteral) -- int is a stringID-entry, unique to that string
Decorate int ClassID([int ptr_selector]) -- int is a StringID-entry, unique to that string
ACS print syntax g:x converts a stringID to a string.
Possible modification: Make comparisons return false if either actor is NULL. Why? Because it might be more useful to determine both that the actor is not null and that it is equal to another actor, than just to determine one. I'm not sure the loss of flexibility is such a cost.