-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat(extra-natives-rdr3): Add GET_VEHICLE_ADDITIONAL_PROP_SET_HASH na… #3686
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
base: master
Are you sure you want to change the base?
feat(extra-natives-rdr3): Add GET_VEHICLE_ADDITIONAL_PROP_SET_HASH na… #3686
Conversation
de01219 to
65fa9ae
Compare
|
Could you please share more information about what propset for vehicle is? |
|
On vehicle you can set main and additional propset (secondary) Native are called ADD but it more a SET than an ADD But you can only get the main propset with GET_VEHICLE_PROP_SET_HASH not the additional On a vehicle a propset is used to add various props on the vehicle like with entitySets in a MLO |
Thank you |
| template<typename T> | ||
| inline static T readValue(fwEntity* ptr, int offset) | ||
| { | ||
| return (T)*(T*)((char*)ptr + offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like is repeating behavior of Hook::FlexStruct. Please use FlexStruct where possible to reduce code duplication. Also for virtual method calls below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thx for your review
65fa9ae to
bcc4c5f
Compare
| bool fwEntity::IsOfTypeH(uint32_t hash) | ||
| { | ||
| void** vtbl = *(void***)this; | ||
| return ((bool(*)(fwEntity*, const uint32_t&)) vtbl[1])(this, hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this call can be done with FlexStruct as well and will look better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done the change to access to the memory address, i have try to directly use CallVirtual without success
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have done the change to access to the memory address, i have try to directly use CallVirtual without success
Can you show me how you use CallVirtual?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should work. No need to pass this, it will be passed automatically
return ((Hook::FlexStruct*)this)->CallVirtual<bool, const uint32_t&>(1, hash);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have try
bool fwEntity::IsOfTypeH(uint32_t hash)
{
hook::FlexStruct* flexStruct = reinterpret_cast<hook::FlexStruct*>(this);
return flexStruct->CallVirtual<bool>(sizeof(void*), static_cast<const uint32_t&>(hash));
}
bool fwEntity::IsOfTypeH(uint32_t hash)
{
hook::FlexStruct* flexStruct = reinterpret_cast<hook::FlexStruct*>(this);
return flexStruct->CallVirtual<bool>(1, static_cast<const uint32_t&>(hash));
}
And your way make the game crash
bool fwEntity::IsOfTypeH(uint32_t hash)
{
hook::FlexStruct* flexStruct = reinterpret_cast<hook::FlexStruct*>(this);
return flexStruct->CallVirtual<bool, const uint32_t&>(1, hash);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok with sizeof(void*) instead of 1 it's ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok with sizeof(void*) instead of 1 it's ok
Right, sorry, there should be real offset in bytes in virtual table.
bcc4c5f to
aceeac1
Compare
aceeac1 to
894e6ec
Compare
Goal of this PR
Add GET_VEHICLE_ADDITIONAL_PROP_SET_HASH native to enable access to vehicle additional propset hash functionality, like we have on main vehicle propset GET_VEHICLE_PROP_SET_HASH
Why ? to avoid storing the data on every entity using statebag when you want to init your list at the current selected additional propset
How is this PR achieving the goal
Native Implementation:
Supporting Infrastructure:
This PR applies to the following area(s)
RedM, Natives, Vehicle System, EntitySystem
Successfully tested on
Game builds: RedM latest
Platforms: Windows
Checklist