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

fix(game/five): crash when no medium lod exists on a vehicle #2965

Merged
merged 1 commit into from
Dec 25, 2024

Conversation

packfile
Copy link
Contributor

Goal of this PR

Fixes a crash that occurs when a vehicle only has the highest lod set up. Usually people work around this by duplicating the model file & appending _hi (as further explained in code)

How is this PR achieving the goal

If the original function does not return a valid lod, we find the first suitable one and return it to prevent a crash later on.

This PR applies to the following area(s)

FiveM

Successfully tested on

Game builds: 1604, 2189, 2699, 3095, 3258

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 triage Needs a preliminary assessment to determine the urgency and required action label Nov 27, 2024
@st860923
Copy link

This is a great improvement, and I appreciate the effort put into preventing crashes due to missing LOD setups.

As a suggestion, perhaps adding debug information, such as a warning message when the module lacks LOD_MED, could provide developers with more helpful information. It would also highlight best practices for setting up about modelling.

@iridium-cfx
Copy link
Contributor

Can this use hook::trampoline instead? Seems a bit unnecessary to find CDecalCallbacks_GetLod via a pattern, but then patch the vftable entry.

@packfile packfile force-pushed the fix-decal-callbacks-lod branch from 1935d5d to f45bbc3 Compare November 28, 2024 10:41
@packfile
Copy link
Contributor Author

Can this use hook::trampoline instead? Seems a bit unnecessary to find CDecalCallbacks_GetLod via a pattern, but then patch the vftable entry.

Thanks, code has been ammended

Copy link
Contributor

@dalekenium-cfx dalekenium-cfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No complaints here, looks good.

@dalekenium-cfx dalekenium-cfx added ready-to-merge This PR is enqueued for merging and removed triage Needs a preliminary assessment to determine the urgency and required action labels Dec 5, 2024
@prikolium-cfx prikolium-cfx merged commit 34eea2e into citizenfx:master Dec 25, 2024
6 checks passed
@packfile packfile deleted the fix-decal-callbacks-lod branch December 28, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR is enqueued for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants