Fix SetEntityHealth to support 'any' entities#1846
Merged
psychonic merged 1 commit intoalliedmodders:masterfrom Dec 20, 2022
Merged
Fix SetEntityHealth to support 'any' entities#1846psychonic merged 1 commit intoalliedmodders:masterfrom
SetEntityHealth to support 'any' entities#1846psychonic merged 1 commit intoalliedmodders:masterfrom
Conversation
psychonic
approved these changes
Dec 20, 2022
Member
psychonic
left a comment
There was a problem hiding this comment.
I went back and forth on this in my head a bit, but I think it's fine enough. I am slightly concerned that there could also be reverse cases where the necessary var only exists as a sendprop and not at all in the datadesc. That is probably rarer yet, but we are trading breakage type either way.
Let's toss it in master and see if anyone complains.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR closes #1770
What changed ?
Instead of assuming the prop name given in core gamedata is a networked property. We will instead assume it's the datamap equivalent, and is on the same offset, plus visible on every single entity as it is a CBaseEntity datamap, unlike the netprop which is only visible if the deriving class decided to have it networked.
To maintain the behaviour the old native had (mainly firing a network update, since it used
Prop_Send) we notify the game the entity changed in order to fire a network update. And if the entity isn't networked we do nothing.Benefits
This will allow for a wider range of entity support. Granted plugins could just do
SetEntProp(entity, Prop_Data, "m_iHealth", amount). But Sourcemod aims at being strongly backwards compatible, therefore it is safe to say this native isn't going to be removed anytime soon. So since we already keep track of the property name in the core gamedata might as well just make a native that works on any source games (not that I'm aware of any that changed this property name but still).