Compare pointers (Decorate, ACS)

Moderator: GZDoom Developers

User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Compare pointers (Decorate, ACS)

Post by Major Cooke »

Okay, that definitely gave me a wave of relief. Thank you.

I would say, this feature is picture perfect! That is, aside from any other code maintenance you might do to it, if any, but that's for you to decide.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Compare pointers (Decorate, ACS)

Post by FDARI »

If an actor that has no target or tracer compares AAPTR_TARGET and AAPTR_TRACER with this function, they will be treated as equal, because they are both null references. Is that the best behaviour? In most situations, you will want to "act" only if they are the same and non-null. If you'd end up adding && !ComparePointer(AAPTR_TARGET, AAPTR_NULL) a lot, you might be happier with a function that returns false/does not jump, if an actor is NULL. I could rewrite it that way, but you'd have to go a little further to check specifically for null, and to allow two null-pointers to be equal.

Current methods:
Pointer equality: ComparePointers(AAPTR_SOMETHING, AAPTR_ELSE)
Pointer is null: ComparePointers(AAPTR_SOMETHING, AAPTR_NULL)
Non-null pointer equality: ComparePointers(AAPTR_SOMETHING, AAPTR_ELSE) && !ComparePointers(AAPTR_SOMETHING, AAPTR_NULL)

Alternative methods:
Pointer equality: Not built in
Pointer is null: Not built in
Non-null pointer equality: ComparePointers(AAPTR_SOMETHING, AAPTR_ELSE)

For specific needs you could complement the alternative method (non-null pointer equality only) with an ACS library / function:
Spoiler: Pointer existence tests
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Compare pointers (Decorate, ACS)

Post by Major Cooke »

Out of curiousity, would it be possible to do A_JumpIf(ClassID(AAPTR_TARGET) == ClassID(AAPTR_PLAYER1),"ItsAPlayer")? I'm guessing that it is, though I haven't tried doing that yet, as I'm currently hog-tied with a bunch of experiments. Still, I just wanted to ensure that it's possible to do a comparison to check and see if the player is it's target.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Compare pointers (Decorate, ACS)

Post by FDARI »

That's not good in concept, although it could work out. Conceptual problems: You depend on a specific player to be in the game, and you depend on that player to be of the appropriate class. If player 1 is guaranteed to be present and of the WhateverPlayer class, it will work.

A few portable utility functions for decorate can be designed in ACS.
Spoiler: Excerpt of my ACS/Decorate interop
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Compare pointers (Decorate, ACS)

Post by Major Cooke »

Yeah. I'm only looking at it for player 1, but I'll keep this in mind.
User avatar
Major Cooke
Posts: 8209
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Compare pointers (Decorate, ACS)

Post by Major Cooke »

Say, FDARI, would you be capable of updating this to the current version of Zdoom's revision? I sincerely think this would be extremely useful.
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Compare pointers (Decorate, ACS)

Post by FDARI »

Superseded by alternate implementation.
Pull requested.

https://github.com/rheit/zdoom/pull/112
https://github.com/rheit/acc/pull/9
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”