#!/bin/sh

# This is a wrapper script to launch the real ufoai binary, suitable
# for a site-wide install on a UNIX-like OS.
#
# It assumes the game was installed in $INSTDIR, and
# $INSTDIR/base/save/ does not exist (reasonable assumption for a
# site-wide install).
#
# It creates a ~/.ufoai/ dir, suitable as a current-directory
# to launch the game in, such that ufo can write player's data.
# The user is allowed to some extent to replace the symlinks to system
# data with copies, maybe modified.

# Known limitations:
# - the script does not detect if the user has replaced the symlinks
# with invalid ones.

# Copyright (c) 2004 Yann Dirson <ydirson@altern.org>
# Available under the terms of the GNU General Public Licence, version 2.

set -e

BINDIR=/usr/lib/games/uforadiant/
INSTDIR=/usr/share/games/uforadiant/
FILE=

if [ $# -eq 1 ]; then
	if [ -f "$1" ]; then
		FILE=$(readlink -f "$1" || echo $1)
		shift
	fi
fi

cd $INSTDIR
${BINDIR}/uforadiant $FILE "$@"
