#!/bin/sh
# if you want to use native libs rather than qvm, give this script the option 
# -native

native_libs="+set sv_pure 0 +set vm_cgame 0 +set vm_game 0 +set vm_ui 0"
installdir=/usr/lib/quake3
cd $installdir

#make sure the data files are installed  
if [ ! -f $installdir/baseq3/pak0.pk3 ]; then
	echo Quake3 data files not installed.
	[ -f $installdir/install-quake3-data.sh ] && /usr/bin/install-quake3-data
	exit 0
fi

#automatically enable native libs if we are using the demo pak0.pk3
echo "0613b3d4ef05e613a2b470571498690f  baseq3/pak0.pk3"|md5sum --status -c && opt=$native_libs

#set options, choose the binary and run it with those options
arch=$(uname -m)
case $arch in
        i?86) arch=i386 ;;
        ppc) arch_args=$native_libs ;;
esac
[ "$1" == "-native" ] && opt=$native_libs
exec "./ioquake3.$arch" $arch_args $opt $extra_args $@

