Friday, July 22, 2011

How To: Substitute words using vim

It's always nice when you learn something useful. I've been using vim for a while but I only use a fraction of its functionality. Today I picked up a nice little feature for substituting words. While in Normal Mode use:
:%s/word/substitution/gc
The g and c on the end are not required but they suit my needs. The g is to search globally and the c is used so that it will ask you to confirm the substitution each time it comes across a matching work. Always better to play it safe.

Wednesday, July 06, 2011

How To: Install Unreal 2004 on Ubuntu Linux

It's unfortunate that Epic will never release a native Linux installer for UT3 but UT2004 is still, after all these years, a great game to play after a long day at work.

This guide aims to provide all the steps needed to get up and running in Ubuntu 11.04 (64-bit), as well as a few additional tweaks. Much of the information here was found on the Ubuntu Forums, I just wanted to keep it all together. The installation was done using the DVD version of the game (released by Atari).

Things to consider before you continue

Unreal 2004 is pretty old now so it's not just a case of running the installer. There is nothing hard about the installation though. The two main issues are that the game requires an old version of the GNU Standard C++ Library and the sound uses OSS (Open Sound System) which has been disabled in Ubuntu for some time. Another problem that effects 64 bit users is that after applying the 3369.2 patch the game does not start. This is easily remedied by editing the startup script.

Download libstdc++.so.5

Ubuntu 11.04 uses libstdc++.so.6 but libstdc++.so.5 is still available through the repositories:
sudo apt-get install libstdc++5

Run the installer

When running the installer, I recommend using the default settings as it'll make things easier. When the installation is complete it'll ask if you want to run the game select no otherwise you'll be running it as the root user.
sudo sh /media/UT2004_DVD/linux-installer.sh

Update to the latest patch - 3369.2

December 2005 saw the last patch for the game being released: ut2004-lnxpatch3369-2.tar.bz2
To install it the contents need to be extracted then copied to the installation directory (which be default is "/usr/local/games/ut2004/").
tar -jxvf ut2004-lnxpatch3369-2.tar.bz2
cd UT2004-Patch/
sudo cp -R * /usr/local/games/ut2004/


Fix the startup script

After patching the game I found that running ut2004 from the terminal would no longer start the game. This can be fixed by editing the startup script using a text editor such as gedit or vim to replace 'ut2004-bin' (the 32-bit binary) with 'ut2004-bin-linux-amd64' (64-bit binary):
sudo vim /usr/local/games/ut2004/ut2004

Solve the audio problem

At this point running ut2004 in the terminal should start Unreal. However, you may see an error "open /dev/[sound/]dsp: No such file or directory" and find there is no sound. You can get around this by launching the game with the PulseAudio OSS Wrapper (padsp):
padsp /usr/local/bin/ut2004

Create a launcher

To make the integration with the Ubuntu desktop a little nicer I chose to create my own launcher. To start with I got a 256x256 pixel png icon for the game and moved it to "/usr/share/icons/hicolor/256x256/apps/" and set the permissions for it:
sudo mv ut2004-256px.png /usr/share/icons/hicolor/256x256/apps/ut2004-icon.png
sudo chown root:root /usr/share/icons/hicolor/256x256/apps/ut2004-icon.png
sudo chmod 644 /usr/share/icons/hicolor/256x256/apps/ut2004-icon.png

I then created a .desktop file in "~/.local/share/applications/". This can be done in any text editor using something like:
gedit ~/.local/share/applications/ut2004.desktop
Then it's just a case using the following within the file:
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_GB]=/usr/share/icons/hicolor/256x256/apps/ut2004-icon.png
Name[en_GB]=Unreal 2004
Exec=padsp /usr/local/bin/ut2004
Name=Unreal 2004
Icon=/usr/share/icons/hicolor/256x256/apps/ut2004-icon.png

You will need to log out and back in again, then the launcher will be available along with the rest of your applications.

Improve the graphics and enable dynamic shadows

Ok that's it you're done. You should start the game up and configure the settings for optimum performance. Most people by now will have a pc that can easily play this at full settings. Once you've had a play around with the game and already maxed all the settings in the game menu, do the following for that little extra.

In your home directory will be a hidden .ut2004 folder that contains your save games and settings. Some parameters will need to be set in UT2004.ini and User.ini. Find the relevant sections as described below. For the sections that require an amount in MB, make sure to use a value based on your hardware.

~/.ut2004/System/UT2004.ini

[Engine.Engine]
DetectedVideoMemory=384 (Number in MB, usually set to 0 by default)

[Engine.GameEngine]
CacheSizeMegs=128 (Number in MB, usually set to 64. Set higher for better performance)

[OpenGLDrv.OpenGLRenderDevice]
UseRenderTargets=True (required for dynamic shadows)
UseVSync=True (Set False by default. 'True' provides a more consistent framerate.)
UseVBO=True (Gives access to the OpenGL VBO. Set True for performance gain.)
UseVSync=True (This appears twice in the settings, for some reason. Set this to True as well.)
UsePixelShaders=True (Set to False by default. Gives access to pixel shaders.)

~/.ut2004/System/User.ini

[UnrealGame.UnrealPawn]
bPlayerShadows=True
bBlobShadow=False

[Engine.Vehicle]
bVehicleShadows=True