Add EntityCollisionRulesChanged & SetEntityOwner natives#1620
Add EntityCollisionRulesChanged & SetEntityOwner natives#1620KyleSanderson merged 11 commits intoalliedmodders:masterfrom Kenzzer:master
Conversation
|
@KyleSanderson tagging you (hope you don't mind), since you wanted to review this and I can't seem to be able to request reviews. Sorry for the 3 months delay! |
|
I have a suggestion to add a |
KyleSanderson
left a comment
There was a problem hiding this comment.
were you able to test over the weekend? I'm really optimistic about this PR as it's going to help a lot of people.
extensions/sdktools/vnatives.cpp
Outdated
| // Returns false if CollisionRulesChanged hack isn't supported for this game | ||
| if (!CollisionRulesChanged(pEntity)) | ||
| { | ||
| return pContext->ThrowNativeError("\"SetEntityCollisionGroup\" unsupported entity"); |
There was a problem hiding this comment.
"is not supported on this engine." ? Something like that - it shouldn't be the same message if it fails the datamap lookup.
Not yet, unfortunately time flew by without me noticing, I also need to come up with a good test plugin to ensure everything's fine. But I've built the ext for tf2 & csgo (linux) and setup my local server already, hopefully this shouldn't take much longer. |
Damn. Let us know when this is closer (I think we're close, too). |
|
The requested changes have been done, and the PR has been tested on TF2 both linux & windows. Here's a test plugin for those interested to test this out on their own I believe this time we're ready. |
|
Like often a little too late, but I think it would have been better to keep the real function name "SetOwnerEntity()" instead of "SetEntityOwner()" :). |
SetEntityOwner is more in line with the rest of the SourceMod API. The full original function name is CBaseEntity::SetOwnerEntity, implying that you're operating on an entity to set it's owner entity. SetEntityOwner also implies that you're operating on an entity to set it's owner. The only part lost is that the owner is an entity, but I think that's better left implied rather than SetEntityOwnerEntity. |
|
Indeed, I understand the issue for SetOwnerEntity(). However, I don't really see a problem with SetEntityOwnerEntity(), which is in line with CBaseEntity::SetOwnerEntity, knowing that CXX::SetOwner() exists too. Here we're loosing the info that we're setting "m_hOwnerEntity" and not "m_hOwner". |

Introduction
#1507
Famous last words... or not!
First I'd like to apologise for not having made this PR earlier.
What changed ?
SetCollisionGroupsignature has been removed, this signature was used by sdktools to callCBaseEntity::SetCollisionGroup.The main point, was to call
CBaseEntity::CollisionRulesChangedafter setting the collision group.So instead now we go through
CBaseEntity::SetEntityOwner, a virtual function which should ideally provide easier maintenance of gamedata (if ever needed) and easier support accross all source games.Bypassing the if statement is trivial, as
m_hOwnerEntityis both a datamap and netprop. With this little hack, we get an easy access toCBaseEntity::CollisionRulesChanged.The native
SetEntityCollisionGrouphas been rewritten to mimic whatCBaseEntity::SetCollisionGroupdoes.Added
EntityCollisionRulesChangedas native, since we have an access to it.And finally added
SetEntityOwneras native, because we have to maintain that vtable offset in order to keep the other two natives working.Final note
As said in introduction, I have not tested anything yet and I'd be very grateful if anyone could test this on csgo, css and l4d.
I also want to mention, that the vtable offsets for CSGO and Left 4 Dead 1 were guessed, there's a chance they're invalid. If someone can provide or confirm them that'd be helpful too!
I'm planning on testing this for CSGO & TF2 this weekend.