Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZScriptify a detection check in P_LookForPlayers #2731

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mykola-ambar
Copy link
Contributor

This PR zscriptifies a detection check in P_LookForPlayers, and adds two new functions to Actor: virtual bool CanDetect(Actor other) and virtual bool CanBeDetectedBy(Actor other). Both must return true for the check to pass.

@mykola-ambar mykola-ambar force-pushed the zscriptify-invisibility-check branch from d8e8645 to ad1b6ea Compare September 29, 2024 04:33
Copy link
Member

@coelckers coelckers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three things:

  1. Please do not remove comments in unrelated code.
  2. The way you set the static FName variables is VERY inefficient and involves a mutex! Please change this to constants to be defined in namedef_custom.h. With this function I am not even sure that fully scriptifying it would be better because it also saves the dynamic lookup of the two variables.
  3. Making CanDetect native is pointless. The VM has a shortcut for empty functions that is a lot faster than calling into an empty native function. So this should be moved into script code as well.

@mykola-ambar
Copy link
Contributor Author

Regarding 2: thanks for letting me know - I'm not as familiar with inner workings of those parts of GZDoom, so I didn't realise that FName had so much going under the hood - I thought it was a trivial data type that wouldn't have mutexes or other side effects. I'll rework it.

Question regarding 3: what do you mean by an empty function? As in, I can see how a void function can be empty, but this function has to return true - will a simple return true; count as empty in this case? I tried making an empty virtual bool TestBool() {} function in ZScript, and GZDoom violently crashed while loading ZScript, so I assume that's not what you meant. I need some clarification before I push something useless. Thanks in advance!

@RicardoLuis0
Copy link
Collaborator

will a simple return true; count as empty in this case?

yes

@mykola-ambar
Copy link
Contributor Author

Thanks @RicardoLuis0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants