Railway Editor - Sage-of-Mirrors/NaviGator GitHub Wiki
The Railway Editor allows you to add, remove, and edit the paths that trains can travel along. This does not include the visuals, e.g. track models and bridges; those must be added separately.
The Railroad Editor operates on individual files that must be extracted from common_0.rpf
. This can be accomplished with any RPF tool that can extract files decrypted and uncompressed.
Extract the following files into a new folder:
common:/data/levels/rdr3/trains1.dat
common:/data/levels/rdr3/trains2.dat
common:/data/levels/rdr3/trains3.dat
common:/data/levels/rdr3/trolley1.dat
common:/data/levels/rdr3/trolley2.dat
common:/data/levels/rdr3/trolley3.dat
common:/data/levels/rdr3/trolley4.dat
common:/data/levels/rdr3/minecart_Jam3_4.dat
common:/data/levels/rdr3/rivers1.dat
common:/data/levels/rdr3/trolley_intersection2.dat
common:/data/levels/rdr3/trolley_intersection3.dat
common:/data/levels/rdr3/trolley_intersection5.dat
common:/data/levels/rdr3/trains_nb1.dat
common:/data/levels/rdr3/trains_nb2.dat
common:/data/levels/rdr3/trains_nb3.dat
common:/data/levels/rdr3/trains_rob3.dat
common:/data/levels/rdr3/trains_intersection1_3.dat
common:/data/levels/rdr3/trains_intersection2_3.dat
common:/data/levels/rdr3/trains_intersection1_ann.dat
common:/data/levels/rdr3/trains_intersection2_ann.dat
common:/data/levels/rdr3/trains_intersection3_cor.dat
common:/data/levels/rdr3/trains_intersection1_app.dat
common:/data/levels/rdr3/trains_old_west03.dat
common:/data/levels/rdr3/trains_old_west02.dat
common:/data/levels/rdr3/trains_old_west01.dat
common:/data/levels/rdr3/trains_old_west_intersection02.dat
common:/data/levels/rdr3/trains_old_west_intersection01.dat
common:/data/levels/rdr3/freight_nb1_inter.dat
common:/data/levels/rdr3/traintracks.xml
Note that the *.dat
files and traintracks.xml
must be placed in the same folder together.
When that's done, you can load the railroad data by either dragging traintracks.xml
onto the app window, or opening the XML file via File -> Open
. If any of the *.dat
files are missing, a popup will open to warn you; if this happens, ensure that you have extracted all of the required files and try opening the XML file again.
The Railroad Editor is composed of three components: the viewport, on the right; the scene hierarchy, on the top left; and the data editors, on the bottom left.
The viewport allows you to interact with the loaded data in 3D. Basic controls are as follows:
- Right mouse button: Look around
- W/A/S/D/Q/E: Move forward/left/backward/right/down/up
-
Left mouse button: Select railroad node or handle
- CTRL + left mouse button: Select multiple railway nodes
Hovering the mouse over a railroad node will cause it to turn orange; clicking on it will cause it turn red, and the translation gizmo will appear. If Is curve?
is checked in the Node Data Editor, the left and right curve handles will also appear in pink on either side of the selected node.
Click and drag on the translation gizmo's arrows and squares to move the selected node(s) in 3D space. If you have a single node selected, you can hold the CTRL key before moving the gizmo to duplicate the selected node and add it to the railroad.
navigator_2024-03-05_22-50-10.mp4
If you select a node's curve handles, you will be able to modify how the railroad's curve passes through that node. As with the node itself, click and drag on the translation gizmo. The default mode is "asymmetrical", moving only the selected handle. Hold the SHIFT key while using the translation gizmo to move both handles "symmetrically", i.e. at the same time.
navigator_2024-03-05_22-45-50.mp4
The scene hierarchy shows the railroad tracks that are currently loaded. Right-click on the Track Configs
label at the top, and you will be able to add a new track to the scene. Any new tracks must have a unique name, as this initial name is used as the name of the track's *.dat
file. RDR2 has a hard cap of 50 railroad tracks per level. traintracks.xml
only defines 29 tracks by default, but the game may load others dynamically for certain missions; be careful if you are approaching the cap. You can also click on the Show
/Hide
buttons to show or hide a given track, and selecting a track will show its data in the Data Editor.
The data editors show you the properties that you can edit on the currently selected railroad track and/or railroad node.
Tracks have the following editable properties:
- Name: The config name of the track, which other tracks can use to reference it.
- Braking Distance: Not entirely sure; probably how many units the train needs to travel before it can start slowing down?
- Loops?: Whether the track is a closed loop, i.e. the first node connects to the last node, or an open line segment.
- Stops at Stations?: Whether AI-controlled trains should stop at stations while traveling on the track.
Nodes have the following editable properties:
-
Station Type: Whether the node has a station on its left (
Left Side
), its right (Right Side
), or does not represent a station (None
).- If
Station Type
is set toLeft Side
orRight Side
, theStation Name
property will be visible. This is the internal name of the station for audio queues. - If
Station Type
is set toNone
, you will instead see the interface for setting up junctions - nodes that reference each other so that a train can move from one track to another. To set up a junction, click theChoose Junction
button, and then click on a node in another railroad track. This will snap the two nodes together, linking them. To clear a junction, simply click theClear Junction
button on a junctioned node. NOTE: This system is a bit unstable at the moment.
- If
- Is in a tunnel?: Whether the node is inside of a tunnel. Purpose uncertain; may cause the train's audio to act as if it's in an enclosed space?
- Is curve?: Whether the node forms a straight line with its neighbors or is a segment of a curve. If this is checked, selecting the node will display its curve handles for editing.
NaviGator's Railroad Editor provides a a rough way to convert RDR1's railroad data into RDR2's format. Extract
redemption/territory_swall/swrailroad.rpf/swrailroad/swrailroad/swrailroad.wsi
from the Nintendo Switch version of Red Dead Redemption into a new folder; then, drag the *.wsi
file onto the app window. This will output several *.dat
files alongside a traintracks.xml
. You may open this XML file like RDR2's native railroad data, but note the following:
- There are no junctions or stations defined in the RDR1 data, so the converted RDR2 data does not have them either; tracks will not automatically link together.
- The railroad points from RDR1 have been shifted to match their RDR2 counterparts. However, RDR2 lacks track sections that exist in RDR1, which would be the tracks in the Great Plains and Mexico. The tracks in these areas do not touch the ground or line up properly, so they must be modified manually to fit RDR2's version of the terrain.
Once you've made your railroad edits and saved them, you can import them into the game using either Lenny's Mod Loader (LML) or RedM.
While it is not required, it is suggested that mods updating the railroad should follow this folder structure:
mod_root
|--data
|--traintracks.xml
|--[base-game *.dat files being overridden]
|--stream
|--[New *.dat files not in the base game]
traintracks.xml
should go in data/
, as should any base-game *.dat
files being replaced. Any new *.dat
files should be placed in stream/
.
For the game to use any new *.dat
files you create, you will need to include traintracks.xml
as a <FileReplacement>
element inside a <Resource>
block:
<FileReplacement>
<GamePath>common:/data/levels/rdr3/traintracks.xml</GamePath>
<FilePath>data/traintracks.xml</FilePath>
</FileReplacement>
Additionally, you must change the filenames of the new *.dat
files within traintracks.xml
itself. By default, the *.dat
filenames are output with the base game's paths, e.g. common:/data/levels/rdr3/trains_old_west01.dat
. This should be modified to be addonDLC:/[mod_name]/stream/[file_name].dat
, e.g.:
<train_track
filename="addonDLC:/NaviGator/stream/greatplains_jnctw_rdr1.dat"
trainConfigName="greatplains_jnctw_rdr1"
stopsAtStations="true"
brakingDist="10" />
*.dat
files being overridden from the base game can be replaced via the <FileReplacement>
element:
<FileReplacement>
<GamePath>common:/data/levels/rdr3/[file_name].dat</GamePath>
<FilePath>data/[file_name].dat</FilePath>
</FileReplacement>
If you are adding any new *.dat
files, you can simply add the <StreamingFiles>
element to your <Resource>
:
<StreamingFiles>stream</StreamingFiles>
Custom railroads are currently limited to isolated loops of track in RedM. RedM does not have the ability to override the base-game tracks like LML does, which is necessary for junctions to work correctly. Please keep this in mind going forward.
While it is not required, it is suggested that resources updating the railroad should follow this folder structure:
res_root
|--data
|--traintracks.xml
|--[New *.dat files not in the base game]
|--.fxmanifest
Additionally, there is currently a bug where using dashes (-
) in the directory structure will cause a crash. It is recommend that dashes be replaced with underscores (_
) for train track resources.
Inside your .fxmanifest
, add your traintracks.xml
and custom *.dat
files to a files
block:
files {
'path/to/traintracks.xml',
'path/to/new_track_1.dat',
'path/to/new_track_2.dat',
# etc.
}
Afterwards, add a data_file
statement:
data_file 'TRAINTRACK_FILE' 'path/to/traintracks.xml'
Your custom railroads will now be loaded when the resource is mounted.