feat(extra-natives/rdr3): Add natives for train tracks #2575
+445
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal of this PR
This PR provides three new natives for RedM for working with train tracks:
traintracks.xml
file. This allows for fully customized rail networks.It also provides patches for three crashes that can occur when using LOAD_TRACKS_FROM_FILE:
This resource can be used to test the track natives. See
client.lua
for the list of commands.How is this PR achieving the goal
The extra natives can be found in
extra-natives-rdr3/src/TrackNatives.cpp
. The patches can be found ingta-core-rdr3/src/PatchTrainTrackCrashes.cpp
.GET_TRACK_COUNT
andGET_TRACK_FROM_INDEX
are just directly accessing the track data.LOAD_TRACKS_FROM_FILE
is based on FiveM's LOAD_WATER_FROM_PATH.The patches for junction crashes and preventing trains from spawning when there are 0 tracks loaded are simple trampolines.
The patch for not loading more tracks than the game has space for is an ASM patch inserted at the original exit condition check for the XML loading loop.
This PR applies to the following area(s)
RedM, Natives
Successfully tested on
Game builds: 1491.50
Platforms: Windows
Checklist
Fixes issues
Resolves #2424.