Friday, July 8, 2011

Heroes of Might and Magic 3 on Linux

This tutorial presumes that you have a cd or an iso of HOMM3 released by Loki Software, which runs natively on linux. This is not for the Windows version which can be run through Wine.
This is tutorial is particularly for Debian and/or Debian derivatives, but it should work for other distros as well.

Let's say the cd is mounted at /mnt/cdrom
apt-get install ksh
cd /mnt/cdrom
ksh setup.sh
At this point, sound may not work, and fullscreen may not work. Let's fix that.
cd ~
wget ftp://mirrors.dotsrc.org/lokigames/updates/heroes3/heroes3-1.3.1a-unified-x86.run
This will give some errors and possibly segfault, but don't bother with it.
sh heroes3-1.3.1a-unified-x86.run --keep
cd heroes3-1.3.1a-unified-x86/bin/Linux/x86/
The patch is of course faulty, so we'll have to patch the patch ...
rm loki_patch
wget http://icculus.org/~msphil/loki/x86/loki_patch
chmod +x loki_patch
cd ../../../
sudo sh update.sh
cd ~
At this point fullscreen works from start, but the sound may have some errors, or it may not work at all.
wget http://www.swanson.ukfsn.org/loki/loki_compat_libs-1.3.tar.bz2
tar -xf loki_compat_libs-1.3.tar.bz2
mv Loki_Compat /usr/local/lib/
And run the game with :
LD_PRELOAD=/usr/local/lib/Loki_Compat/libstdc++-3-libc6.2-2-2.10.0.so:/usr/local/lib/Loki_Compat/libsmpeg-0.4.so.0.1.3:/usr/local/lib/Loki_Compat/libsmjpeg-0.2.so.0 /usr/local/games/Heroes3/heroes3.dynamic
You can create an alias for this, and update your menu/shortcuts.
Sound should work now.

Also, remember to run the game as a regular user, otherwise your config and save files will be stored in the root's home directory.

Have fun.