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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants