Heroes III on GNU/Linux

UPDATED: 18.07.2014

I’m long time fan of Heroes Of Might and magic series. Especially Heroes III. Today I decided to spend some time playing it on my OpenSUSE box.

This article is not about running Heroes III under Wine, it’s about installing the GNU/Linux version produced by Loki Software years ago, under modern GNU/Linux distribution.

heroes3-gnu-linux-opensuse12.3

1. Get a copy of the game. Since Loki is no more, the game cannot be ordered from them, but there are chances that some copies are still available on eBay or other online store. Google “Heroes III Linux”, for other ways of obtaining the software.

2. Download the latest patch (1.3.1) from here.

3. Install the game.

This step requires “root” privileges on the system. Open a terminal and become super user by typing

su

or

sudo -i

hitting the Return key and providing you password.

NOTE: You may install the game as your normal every day user. It will be installed in your home directory, and only playable by you, or the users from the “users” group. Depends on how your system is configured.

If you are installing from CD, mount it

cd

to the mount point and run

sh setup.sh

This will start the game installation process. Follow the onscreen instructions.

If during the execution of the a bought command you get error message like the one below:

This installation doesn’t support glibc-2.1 on x86_64 Please contact Loki Technical Support at support@lokigames.com

you are trying to install the game on a 64-bit GNU/Linux distribution. To start the setup program type:

linux32 sh setup.sh

During the setup process you will be asked what part’s of the game you want installed on your hard drive and witch one the game should look for on the CD. I recommend full game installation. This can be achieved by answering Y on the following questions:

Install Base Install? [Y/n] Y
Install Scenarios? [N/y] Y
Install Sounds and Graphics? [N/y] Y
Install Music? [N/y] Y
Install Videos? [N/y] Y

4. Applying the patch.

The patch downloaded in step 2, is the latest patch for the Linux version of Heroes III. It fixes some game play bugs like playing the game on full screen. To install the patch:

4.1 Open a terminal, and go to the folder containing the file heroes3-1.3.1a-unified-x86.run. Become a super user (see step 3) and type

chmod +x heroes3-1.3.1a-unified-x86.run
./heroes3-1.3.1a-unified-x86.run

After executing the a bough commands you probably will get the following error:

Verifying archive integrity...OK
Uncompressing Heroes of Might and Magic III 1.3.1a Update......................................tar: A lone zero block at 12620

./update.sh: line 56: loki_patch: command not found
The program returned an error code (1)

As the error message says the loki_patch command is not found. To overcome this problem, download loki_patch from here and save it in the directory where you downloaded heroes3-1.3.1a-unified-x86.run.

Make it executable by typing:

chmod +x loki_patch

Now it’s time to extract our HoM III update. Run the following command:

./heroes3-1.3.1a-unified-x86.run --keep

The installer will fail with the error mentioned previously, but passing the –keep parameter to the patch executable, forced the installer to keep the update files. Type ls to see the directory listing. You should have a directory called heroes3-1.3.1a-unified-x86. Our task is to replace the loki_patch version contained within the update with the one we have downloaded. Execute the following sequence of commands to replace loki_patch and start the update process.

cp loki_patch heroes3-1.3.1a-unified-x86/bin/Linux/x86/loki_patch
chmod +x heroes3-1.3.1a-unified-x86/bin/Linux/x86/loki_patch
chmod +x heroes3-1.3.1a-unified-x86/update.sh
./heroes3-1.3.1a-unified-x86/update.sh

For 64-bit GNU/Linux distro run:

linux32 ./heroes3-1.3.1a-unified-x86/update.sh

Follow the onscreen instructions. Close your root session by typing exit.

The game is now installed and patched to the latest version available.

NOTE: If during the installation of the patch you get ERROR: No matching delta for /usr/local/games/Heroes3/heroes3.dynamic don’t worry, the patch is installed. You can verify it by executing heroes3 -v. The output should says:

Heroes of Might & Magic III 1.3.1a

Type heroes3 and press enter to start playing. Type heroes3 –help, to view the available command line options, or review them below.

Heroes 3 command line options.

# heroes3 --help
Linux version by Loki Software, Inc.
http://www.lokigames.com/
Support - FAQ: http://faqs.lokigames.com/
          Web: http://fenris.lokigames.com/

          E-mail: support@lokigames.com
          Phone:  1-714-508-2140 (9-5 PM US Pacific Time)

Usage: heroes3 [options]
     [-h | --help]           Display this help message
     [-v | --version]        Display the game version
     [-f | --fullscreen]     Run the game fullscreen
     [-w | --windowed]       Run the game in a window
     [-s | --nosound]        Do not access the soundcard
     [-c | --nocdrom]        Do not access the CD-ROM
     [-u | --update]         Run the Loki auto-update tool
     [-q | --qagent]         Run the Loki QAgent support tool
     [-x | --x11cursor]      Use the X11 hardware mouse cursor
     [-l | --logging]        Enable logging

You can use the HEROES3_DATA environment variable to force the
Heroes III installation directory

NOTE: -u | –update and -q | –qagent does not work!

5. Known problems with the game.

There are some known problems with the game on modern GNU/Linux distributions as follows:

* No sound.

When starting the game you may see the following error:

Couldn't open audio:

The solution to this problem varies from distribution to distribution. Please consult your distro community. In some cases the sound just works.

* Random game crashes.

Sometimes the game may crash. It’s useful to start the game with the -l option, to enable logging. The log files are stored under ./home/<username>/.loki/heroes3.

6. Adding custom maps

Custom maps can be installed by copying them to .loki/heroes3/maps (available only for the current user) or in <game installation folder>/maps (available for all the users).

NOTE: <game installation folder>, by the means of this tutorial is /usr/local/games/Heroes3.

Happy adventuring :) . Tutorials about installing other Loki Software products will be available soon.

Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD) and OpenSUSE 11.4

UPDATE: There is some strange lag while copping files from or to the SD card!

I recently reinstalled my laptop (Acer Extensa 5620z) with OpenSUSE 11.4. Everything worked out of the box, (which is impressive) except the card reader.

If you look at /var/log/messages when you insert a card, you will see something like this:

tifm_core: MMC/SD card detected in socket 0:1

It means that the kernel has detected your card but it don’t think it’s memory card or storage device. Here the setpci command comes handy.

NOTE: You need to be root in order to preform the steps required

1. List your devices with lspci and find your card reader entry:

0f:06.2 Mass storage controller: Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)

Notice the first colum 0f:06.2. This is your device ID, you will need it later.

2. Execute the following command:
Replace 0f:06.2 with your device ID!

setpci -s 0f:06.2 4c.b=0x02

Your card reader should work now. In order to make this change permanent, you may place the command from step 2 in /etc/rc.d/after.local.

P.S: Here is my laptop Smolt profile.

Update system time using ntp and NetworkManager (Gentoo)

On my laptop I use NetworkManager to control network interfaces (LAN/WLAN).

Here is a simple script that will sync your clock with Internet time when LAN or WLAN interface is up and stop ntp-client when the interface is down. Put the script in /etc/NetworkManager/dispatcher.d and make it executable (chmod +x ).

#!/bin/bash
IF=$1;
STATE=$2;
 
if [ "$IF" = "eth0" ] || [ "$IF" = "wlan0" ] && [ "$STATE" = "up" ]; then
        /etc/init.d/ntp-client start
else
        /etc/init.d/ntp-client stop
fi

In order for the script to work you need net-misc/ntp package.

Using OpenSSL with Apache Tomcat 6

First we need Apache Portable Runtime (APR) in order to enable OpenSSL support and generally optimize Tomcat performance. It you are running Gentoo:

emerge -v tomcat-native

To enable APR edit your server.xml file and add the following line:

<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

Depending on your configuration APR listener may be enabled by default.

Next on the Open SSL part. Back in your server.xml file, add an SSL connector:

<connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               SSLEngine="on" 
               SSLCertificateFile="/path/to/your/certificate.crt"
               SSLCertificateKeyFile="/path/to/your/certificate.key">
</connector>

If you need an intermediate crt file add the following in your connector directive:

SSLCertificateChainFile="/path/to/your/intermediate.crt"

Restart Tomcat and you should be up and running with OpenSSL support. APR complete documentation is available here.

Gentoo GNU/Linux on Acer Extensa 5620Z

This guide will explain the procedures involved in the installation and configuration of Gentoo GNU/Linux on Acer Extensa 5620Z Laptop.

Why Gentoo GNU/Linux?

Gentoo is my favorite GNU/Linux distribution, because it has great package management system a.k.a “Portage” and it gives you the ability to optimize the system for your machine. There is also great community build around it.

More information about Gentoo it’s ideology and the features it provides, is available on Gentoo website.

Hardware Information

Component Description
CPU Intel Pentium dual-core processor T2330 (1.6Ghz, 533MHz FSB, 1MB L2 cache) – 64bit
RAM 2GB SODIMM DDR2 Synchronous 533 MHz (1.9 ns)
SMBus Intel Corporation 82801H (ICH8 Family) SMBus Controller
HDD 160 GB WDC WD1600BEVS-2
SATA controller Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
Video Intel Mobile GM965/GL960 Integrated Graphics Controller
Audio Intel Corporation 82801H (ICH8 Family) HD Audio Controller
Ethernet controller Broadcom Corporation NetLink BCM5787M Gigabit Ethernet PCI Express
Ethernet controller Atheros Communications Inc. AR5001 Wireless Network Adapter
FireWare Texas Instruments PCIxx12 OHCI Compliant IEEE 1394 Host Controller
SD Host controller Texas Instruments PCIxx12 SDA Standard Compliant SD Host Controller
Card Reader Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)
Web Cam SuYin Acer CrystalEye web c

The laptop also provides 2x PCMCIA slots, TV Out and DVD-RW drive.

Gentoo installation notes

The installation was preformed using Gentoo amd64 minimal CD (install-amd64-minimal-20101111.iso). After booting the minimal CD all devices needed for a successful installation were recognized.

Please note that to be able to download stage3 and portage-snapshot or to have an active Internet connection during the installation process you need to configure your LAN interface ( usually eth0 ). The wireless card is recognized by the minimal CD but you will need some tools to configure it, not available in the environment provided by the CD.

For complete installation instructions consult Gentoo Handbook available here.

Kernel configuration

This configuration is based on kernel 2.6.34. You can download my config file here.

Code Listing: Using the config file
cp config.txt /usr/src/linux/.config

Note: I use LZO compression method for my kernel image, so if you decide to use my config file, emerge lzop or change the compression method to Bzip2 or other.

Provided config file includes support for all the hardware available on the machine, temperature and other sensors, CPU frequency scalling, ACPI sleep/hibernate, ext2, ext3, ext4, NTFS (read/write support), vfat, nfs client, synaptics, etc… For complete feature overview run make menuconfig.

Every option is compiled in the kernel.

Code Listing: Compiling and installing the kernel
make && make modules_install
cp arch/x86_64/boot/bzImage /boot/kernel-2.6.34-gentoo-r12

Nice terminal resolution

In order to improve the terminal resolution append the lines below to the kernel parameter of your grub.conf.

Code Listing: Setting nice terminal resolution by editing grub.conf
video=vesafb:1280x1024-24@60 vga=9

Function keys

In order to make the Fn key combinations and multimedia keys work copy following HAL policy file 10-laptop-panel-mgmt-policy.fdi from /usr/share/hal/fdi/policy/10osvendor to /etc/hal/fdi/policy.

Restart HAL.

Code Listing: copying HAL policy file for laptop panel managment
cp /usr/share/hal/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi /etc/hal/fdi/policy

X Server configuration

In your /etc/make.conf add VIDEO_CARDS=”intel” and INPUT_DEVICES=”evdev synaptics” then emerge xorg-server.

Synaptics configuration

Configuration of the touchpad is simple, copy HAL policy file 11-x11-synaptics.fdi from /usr/share/hal/fdi/policy/10osvendor
to /etc/hal/fdi/policy open the file in your favorite text editor and remove the comments surrounding the match tag.

Code Listing: copying HAL policy file for synaptics touchpad
cp /usr/share/hal/fdi/policy/10osvendor/11-x11-synaptics.fdi /etc/hal/fdi/policy/99-x11-synaptics.fdi

To enable tapping ( mouse clicks using the touchpad ) add the following line to your 99-x11-synaptics.fdi policy file:<merge key=”input.x11_options.TapButton1″ type=”string”>1</merge>

Restart HAL.

If you want to disable your touchpad while typing make syndaemon start’s with X, by adding exec syndaemon to your .xinitrc or by a desktop specific way. For KDE 4 see below:

Code Listing: Autostart syndaemon when KDE starts
cd .kde4/Autostart
vim (or editor of your choice) syndaemon

*** SYNDAEMON SCRIPT CONTENT BEGIN ***

#!/bin/bash
exec syndaemon

*** SYNDAEMON SCRIPT CONTENT END ***

chmod +x syndaemon

Type man synaptics for additional configuration options and help.

Power management

Most of the laptop power management is preformed by HAL, but additional steps are required for CPU frequency scaling and suspend / hibernate.

CPU frequency scaling

In order to enable CPU frequency scaling one should emerge cpufreqd and add it to the default runlevel. More information about CPU freq scaling is available in Gentoo power management guide.

Suspend / hibernate

Suspend and hibernate are handled by HAL, but in order to use them you should add yourself to the plugdev group and emerge pm_utils.

Code Listing: Adding a user to plugdev group
gpasswd -a <user> plugdev

Resuming from hibernation

In order to resume the system to it’s pre hibernated state ( I assume that you are using my kernel config file, if not enable hibernation in the kernel, if you haven’t done so ) append the following line to your grub.conf file:

Code Listing: Enabling hibernation
resume=/dev/<SWAP>

NOTE: <SWAP> is the location of your SWAP partition

Misc Configuration