#!/bin/sh

FindPath()
{
    X=`which "$1"`
    Y=`readlink -e "$X"`
    dirname "$Y"
}

if [ "${QOD_PATH}" = "" ]; then
    QOD_PATH="`FindPath "$0"`"
fi

cd "$QOD_PATH"

if [ "${QOD_ARCH}" = "" ]; then
    QOD_ARCH=`uname -m`
fi

#export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH"

here="$(dirname "$(readlink -f "$(which "$0")")")"

if [ "${QOD_ARCH}" = "x86_64" ] || [ "${QOD_ARCH}" = "amd64" ]; then
    export LD_LIBRARY_PATH="$here/amd64/libs:$LD_LIBRARY_PATH"
    #echo "Quest of Dungeons: amd64"
    exec ./amd64/QuestofDungeons "$@"
else
    export LD_LIBRARY_PATH="$here/x86/libs:$LD_LIBRARY_PATH"
    #echo "Quest of Dungeons: x86"
    exec ./x86/QuestofDungeons "$@"
fi


#!/usr/bin/env bash

