Blob Blame History Raw
#!/bin/bash

set -e

. /usr/share/opengl-games-utils/opengl-game-functions.sh

checkDriOK "Urban Terror"

if [ ! -f ~/.q3a/q3ut4/zpak000.pk3 ]; then
  set +e
  /usr/share/autodl/AutoDL.py /usr/share/quake3/urbanterror.autodlrc
  STATUS=$?
  set -e
  # status 2 means download was ok, but the user choice not to start the game
  if [ "$STATUS" = "0" -o "$STATUS" = "2" ]; then
    pushd ~/.q3a > /dev/null
    unzip -qq -u UrbanTerror_41_FULL.zip
    # remove any old versions (if present) otherwise the mv fails
    rm -fr q3ut4
    mv UrbanTerror/q3ut4 .
    rm -r UrbanTerror UrbanTerror_41_FULL.zip
    popd > /dev/null
  fi
  if [ "$STATUS" != "0" ]; then
    exit $STATUS
  fi
fi

# We used to run from under ~/.q3a, but that is a bad idea as that will
# cause com_standalone to get unset if regular quake3 is also present
# So now we run from ~/.q3ut4, but we keep the data files under
# ~/.q3a for compatibilities with older autodl "installs"
mkdir -p $HOME/.q3ut4
ln -f -s ../.q3a/q3ut4 $HOME/.q3ut4/q3ut4

# we're a standalone game
CVARS="+set com_standalone 1"
CVARS="$CVARS +set fs_basegame q3ut4"
CVARS="$CVARS +set fs_basepath /usr/share/q3ut4"
CVARS="$CVARS +set fs_homepath \"$HOME/.q3ut4\""
# Urban Terror's default master server is different
CVARS="$CVARS +set sv_master1 master.urbanterror.net"
# update.quake3arena.com is pretty irrelevant if you're playing ut
CVARS="$CVARS +set cl_motd 0"
# And last some Urban Terror specific settings
CVARS="$CVARS +set com_hunkMegs 256 +set cl_allowdownload 1"

exec quake3 $CVARS "$@"