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

tweak(extra-natives/five): sanitize mission train creation #2982

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

Conversation

Ehbw
Copy link
Contributor

@Ehbw Ehbw commented Dec 5, 2024

Goal of this PR

Prevent client crashes when using the CREATE_MISSION_TRAIN native.

How is this PR achieving the goal

By adding checks that are missing with the original native implementation. Such as invalid train variations (that do not exist in trains.xml), required carriage models not being loaded, and checking to ensure that there is at least a single track enabled to create a train on (this wouldn't crash the client, but would rather return a native error in the console which could be confusing to users).

This PR also moves some Train structs from TrackNatives to a Train header file to reduce code duplication

This PR applies to the following area(s)

FiveM

Successfully tested on

Game builds: 1604, 3258

Platforms: Windows

I've created a repro resource to reproduce the crashes and their new behaviour with this PR.
train-crash-test.zip

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.

Fixes issues

Sorry, something went wrong.

@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 Dec 5, 2024
@dalekenium-cfx
Copy link
Contributor

There was a bug that broke building the server project, but it has been fixed in master. Can you merge that fix into your branch? I will do a review once that's done. Thank you!

@Ehbw Ehbw force-pushed the fix/validate-train-native branch from 6a690f8 to 8d91379 Compare December 9, 2024 15:51
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Dec 9, 2024
@Ehbw
Copy link
Contributor Author

Ehbw commented Dec 9, 2024

There was a bug that broke building the server project, but it has been fixed in master. Can you merge that fix into your branch? I will do a review once that's done. Thank you!

Done

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.

The only thing that jumps out at me is whether train.h should be in extra-natives-five, but I don't think that's a big enough reason to not approve this MR at this point. 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 9, 2024
@Legacy-TacticalGamingInteractive

hey @Ehbw in case you did not notice yet but @prikolium-cfx merged some of your other commits recently :)
keep up the awesome work guys! <3

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.

None yet

3 participants