Skip to content

Take into account the returned value in SDKHook_Think callbacks#1397

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

Take into account the returned value in SDKHook_Think callbacks#1397
KyleSanderson merged 2 commits intoalliedmodders:masterfrom
einyux:feature-sdk-think

Conversation

@einyux
Copy link
Contributor

@einyux einyux commented Dec 5, 2020

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
Copy link
Contributor Author

einyux commented Dec 7, 2020

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
Copy link
Member

KyleSanderson commented Mar 8, 2021

@psychonic
image

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

EDIT: Github styling was not expected.

@KyleSanderson
Copy link
Member

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

@asherkin
Copy link
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
Copy link
Contributor Author

einyux commented May 21, 2021

@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
Copy link
Contributor Author

einyux commented Jul 10, 2021

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