Skip to content

Conversation

@Identity-labs
Copy link
Contributor

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:

  • Added GET_VEHICLE_ADDITIONAL_PROP_SET_HASH native declaration and implementation
  • Implemented proper vehicle type checking using IsOfType() template
  • Added error handling for invalid vehicle entities

Supporting Infrastructure:

  • Refactor duplicated code in NativeWrappers.h by using EntitySystem.h like it's done in FiveM
  • Implemented missing IsOfType(uint32_t hash) and IsOfTypeH(uint32_t hash) functions

This PR applies to the following area(s)

RedM, Natives, Vehicle System, EntitySystem

Successfully tested on

Game builds: RedM latest

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

@github-actions github-actions bot added the RedM Issues/PRs related to RedM label Oct 21, 2025
@Identity-labs Identity-labs force-pushed the feat-rdr3-additional-propset branch from de01219 to 65fa9ae Compare October 21, 2025 10:04
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Oct 21, 2025
@prikolium-cfx
Copy link
Collaborator

Could you please share more information about what propset for vehicle is?

@Identity-labs
Copy link
Contributor Author

On vehicle you can set main and additional propset (secondary)
ADD_PROP_SET_FOR_VEHICLE
0xD80FAF919A2E56EA
ADD_ADDITIONAL_PROP_SET_FOR_VEHICLE
0x75F90E4051CC084C

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

@prikolium-cfx
Copy link
Collaborator

On vehicle you can set main and additional propset (secondary) ADD_PROP_SET_FOR_VEHICLE 0xD80FAF919A2E56EA ADD_ADDITIONAL_PROP_SET_FOR_VEHICLE 0x75F90E4051CC084C

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);
Copy link
Collaborator

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

Copy link
Contributor Author

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

@Identity-labs Identity-labs force-pushed the feat-rdr3-additional-propset branch from 65fa9ae to bcc4c5f Compare October 21, 2025 12:08
bool fwEntity::IsOfTypeH(uint32_t hash)
{
void** vtbl = *(void***)this;
return ((bool(*)(fwEntity*, const uint32_t&)) vtbl[1])(this, hash);
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Collaborator

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?

Copy link
Collaborator

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); 

Copy link
Contributor Author

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);
}

Copy link
Contributor Author

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

Copy link
Collaborator

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.

@Identity-labs Identity-labs force-pushed the feat-rdr3-additional-propset branch from bcc4c5f to aceeac1 Compare October 21, 2025 13:01
@Identity-labs Identity-labs force-pushed the feat-rdr3-additional-propset branch from aceeac1 to 894e6ec Compare October 21, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid Requires changes before it's considered valid and can be (re)triaged RedM Issues/PRs related to RedM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants