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

Disallow factory clone #55

Merged
merged 2 commits into from
Jul 25, 2024
Merged

Disallow factory clone #55

merged 2 commits into from
Jul 25, 2024

Conversation

Kenzzer
Copy link
Collaborator

@Kenzzer Kenzzer commented Jul 25, 2024

Reported as bug on Alliedmodders discord by user magnat2645, if a plugin clones the entity factory handle with sourcemod's CloneHandle native and then deletes the original handle. Calling CEntityFactory.GetFactoryOfEntity will end up returning the now deleted and therefore invalid factory handle.

Rather than allowing the cloning of handles for entity factories, as it's still not clear how we want cross-plugin interaction to work, and because it would require a significant rewrite of the internal code base to allow us. I opt to fully restrict handle cloning for entity factories. Instead the constructor for entity factories has been edited like so

-CEntityFactory(const char[] classname, CEntityFactoryPostConstructor postConstructor=INVALID_FUNCTION, CEntityFactoryOnRemoveCallback onRemove=INVALID_FUNCTION)
+CEntityFactory(const char[] classname, CEntityFactoryPostConstructor postConstructor=INVALID_FUNCTION, CEntityFactoryOnRemoveCallback onRemove=INVALID_FUNCTION, Handle plugin = INVALID_HANDLE)

This will allow plugins to allocate entity factories for other plugins.

@Kenzzer Kenzzer merged commit 9aead65 into master Jul 25, 2024
7 checks passed
@Kenzzer Kenzzer deleted the factory_clone branch July 25, 2024 16:59
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