How to get a playable Linux Railroad Tycoon 2 install

By following these instructions, I was able to frankenstein together the Loki Software Linux Railroad Tycoon 2 binaries with the data from a Windows Railroad Tycoon 2 Platinum disc.

WARNING: The installation produced by this will be missing the music and video cutscenes.

  • Music (It doesn’t even seem to be trying to load it, so I have no idea where to start diagnosing.)
  • Video cutscenes (I didn’t care enough to spend the effort. See this blog post for instructions on converting Smacker video to the type of MPEG Loki games expect and read further for how to identify what filenames it’s looking for.)

Required tools:

  • unshield or Wine to unpack the Windows installer
  • unzip to bypass the “Please insert ‘Railroad Tycoon 2 Loki disc'” message in the Linux installer
  • Perl and the /usr/bin/rename symlink to Perl’s prename

Required files:

Instructions (all approaches):

  1. Put rt.2_1.54c-multilingual_x86.mojo.run into your target directory
  2. Insert the Railroad Tycoon 2 CD into your CD drive
  3. Type or copy-paste the following commands, adjusting paths as appropriate:
# Unpack the Linux binaries
unzip rt.2_1.54c-multilingual_x86.mojo.run
cd data
tar xvf patch-1.54c.tar

# Unpack the data files from the CD into the expected layout
unshield /media/*/RT2_PLAT/_setup/data1.cab
unshield /media/*/RT2_PLAT/_setup/data2.cab
mv Root_Files/* .
rmdir Root_Files

# Fix issues caused by Windows being case-insensitive and Linux 
# being case-sensitive
mv Data data
(cd data; rename 'y/A-Z/a-z/' *)
(cd maps; rename 's/.MP2/.mp2/' *; rename 's/.MAP/.map/' *; rename 'y/A-Z/a-z/' \#*)

That will get the statically-built binary (./rt2) playable but you won’t get any sound because the static linking prevents PulseAudio from faking ALSA’s API. (It may play audio if run via pasuspender but I don’t like how pasuspender mucks with things, so I didn’t test it.)

Additional Instructions for working audio:

The simplest way to get working audio is to use the dynamic version. For that, you need some old library dependencies and a wrapper script capable of providing a 32-bit version of padsp’s functionality on 64-bit Linux:

tar xvaf loki_compat_libs-1.3.tar.bz2 --wildcards 'Loki_Compat/libsmjpeg-0.2.*' 'Loki_Compat/libSDL-1.*'
cat > run-dynamic.sh << EOF
export LD_PRELOAD='/usr/lib/i386-linux-gnu/pulseaudio/libpulsedsp.so'
export SDL_AUDIODRIVER=alsa
export LD_LIBRARY_PATH=Loki_Compat
if [ "$1" = '--strace' ]; then
    strace ./rt2.dynamic 2>&1 | egrep -v '/(var|etc|lib)/|.loki/rt2|[./]pulse|Loki_Compat' | grep -i 'No such file'
else
    ./rt2.dynamic
fi
EOF
chmod +x run-dynamic.sh

Now, you can use run-dynamic.sh to launch it and your sound effects will work too.

Additional Instructions if you want to try to get videos or music working:

First, the most important trick I used to figure out which files to rename and how was running the game via this command:

strace ./rt2 2>&1 | grep -v '.loki/rt2' | grep -i 'No such file'

I’ve incorporated a more polished version into run-dynamic.sh which can be triggered by running it as ./run-dynamic.sh --strace

(Don’t worry about the LD_PRELOAD errors. That’s just strace complaining that it can’t use the 32-bit PulseAudio library that we’re requesting for the game itself.)

Second, be aware that, if you break the audio on the dynamic version, don’t click the Quit button. It’ll freeze the game without releasing your pointer. Instead, if audio isn’t working, hit Alt+F4 to ungrab the mouse and keyboard and switch to windowed mode, then use xkill to kill the window.

In case you forget, I also advise running these so you can recover from a freeze while fullscreened by using Ctrl+Alt+F1 to switch to a console, logging in, running ./rt2_release_gui.sh, and then using Ctrl+Alt+F7 to return to your desktop.

echo "DISPLAY=:0.0 xkill -id $(DISPLAY=:0.0 wmctrl -l | grep Railroad | cut -d' ' -f1)" > ~/rt2_release_gui.sh
chmod +x ~/rt2_release_gui.sh

CC BY-SA 4.0 How to get a playable Linux Railroad Tycoon 2 install by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

This entry was posted in Geek Stuff. Bookmark the permalink.

2 Responses to How to get a playable Linux Railroad Tycoon 2 install

  1. This game, like other Loki games is on game-data-packager TODO list.

    https://anonscm.debian.org/cgit/pkg-games/game-data-packager.git/tree/debian/TODO#n37

    The Gentoo loki_compat_libs-1.3.tar.bz2 thing wouldn’t pass the bar;
    this should be handled by the packages of the distribution.

  2. Sodbuster says:

    There are probably multiple solutions.

    Mine (running on Fedora 24):
    install Linux version of RT2 and patch to 1.54c
    install snd_pcm_oss
    setup /etc/sysconfig/modues for peristent loading of snd_pcm_oss
    reboot

    start RT2
    load a campaign, sound works
    quit campaign and run my scenario sound works
    Sound only works if I start a campaign first, so I presume something different is executed in that scenario

    Enjoy. I like the old games (like me)

Leave a Reply

Your email address will not be published. Required fields are marked *

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution under the same terms as the associated post.

All comments are moderated. If your comment is generic enough to apply to any post, it will be assumed to be spam. Borderline comments will have their URL field erased before being approved.