Skip to content

Take into account the returned value in SDKHook_Think callbacks - #1397

Merged
KyleSanderson merged 2 commits into
alliedmodders:masterfrom
einyux:feature-sdk-think
Jul 10, 2021
Merged

KyleSanderson merged 2 commits into
alliedmodders:masterfrom
einyux:feature-sdk-think

Conversation

@einyux

@einyux einyux commented Dec 5, 2020

Copy link
Copy Markdown
Contributor

To disable entirely the call of "EntityX::Think()", using the property "m_nNextThinkTick" is enough.
But sometimes I want to use the "EntityX::Think()" to do something else, i.e. to replace it with my own code.

In SDKHook_Think callbacks, the returned value need to be taken into account to do this.

@einyux

einyux commented Dec 7, 2020

Copy link
Copy Markdown
Contributor Author

It must be noticed that SDKHook_Think doesn't seem to be the only case.

  • SDKHook_PreThink
  • SDKHook_PostThink
  • SDKHook_VPhysicsUpdate

have the same issue.

It should be let to the user the possibility to block any game call in pre-hooks (At his own risk...), or else put in the documentation that for these cases the return value is discarded (For security purposes...).

@KyleSanderson

KyleSanderson commented Mar 8, 2021 •

Copy link
Copy Markdown
Member

@psychonic
image

this seems fine to me outside of the crunched style. WDYT?

EDIT: Github styling was not expected.

@KyleSanderson

Copy link
Copy Markdown
Member

@asherkin do you know the implications of what happens when an entity stops thinking by chance?

@asherkin

Copy link
Copy Markdown
Member

@asherkin do you know the implications of what happens when an entity stops thinking by chance?

I do not, but it'll be entity-specific and should generally be fine.

or else put in the documentation that for these cases the return value is discarded.

It is in the documentation,

typeset SDKHookCB
{
	// PreThink/Post
	// PostThink/Post
	function void (int client);

	// Spawn
	function Action (int entity);

	// GroundEntChanged
	// SpawnPost
	// Think/Post
	// VPhysicsUpdate/Post
	function void (int entity);

That'll need updating for this change as well.

@einyux

einyux commented May 21, 2021

Copy link
Copy Markdown
Contributor Author

@asherkin Indeed, I missed the callback prototype. Thinking about it now, but will it not break the compatibility with some plugins (And are we okay with this)...?

By the way, what's your opinion about doing the same thing for the three following hooks:

  • SDKHook_PreThink
  • SDKHook_PostThink
  • SDKHook_VPhysicsUpdate

@einyux

einyux commented Jul 10, 2021

Copy link
Copy Markdown
Contributor Author

I updated sdkhooks.inc. Let's see for other hooks later.

@KyleSanderson
KyleSanderson merged commit 823b55c into alliedmodders:master Jul 10, 2021
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