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

helper_functions: added IsPlayer and Center own implementations to not rely on hooked virtual functions #540

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

SmileyAG
Copy link
Collaborator

@SmileyAG SmileyAG commented Jul 14, 2024

If you want an answer, is it really necessary to overloading the same function first with each individual argument, and then only with edict_t as an argument? I'll answer yes, because it solves two issues at once:

  • In defense of edict_t: you can simply give only the edict as input, and the rest the function will do everything for you, wonderful, isn’t it?
  • In defense of the function with each separate argument: this also allows for use in client code, for example, where you can get similar information but not with edict_t

Also In case someone wants to merge it if I would inactive for a while: simply rebase to the latest master as soon as #531 is merged to solve the build errors

Copy link
Owner

@YaLTeR YaLTeR left a comment

Choose a reason for hiding this comment

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

If you want an answer, is it really necessary to overloading the same function first with each individual argument, and then only with edict_t as an argument?

Makes sense

Comment on lines +17 to +18
if (!(ent->v.flags & FL_CLIENT))
return false;
Copy link
Owner

Choose a reason for hiding this comment

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

I'd move this above the strcmp because it's a much cheaper check.

void *pToucher = pevToucher->pContainingEntity->pvPrivateData;
_IsPlayer IsPlayerFunc = *reinterpret_cast<_IsPlayer *>(*reinterpret_cast<uintptr_t *>(pToucher) + offFuncIsPlayer);
if (!IsPlayerFunc(pToucher))
if (!helper_functions::IsPlayer(pevToucher->pContainingEntity))
Copy link
Owner

Choose a reason for hiding this comment

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

I'd squash this commit into the previous one


Vector playerCenter;
Vector inflictorCenter;
entvars_t *pev = *reinterpret_cast<entvars_t**>(reinterpret_cast<uintptr_t>(thisptr) + 4); // _Smiley: TODO: replace it with GET_PEV macro once it's merged.
Copy link
Owner

Choose a reason for hiding this comment

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

Same, I'd squash. And now you can GET_PEV too

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.

2 participants