#!/bin/sh
# Launch script for Omnispeak
# Questions to David Gow, https://davidgow.net/
# Set $DEBUGGER to launch the game with a debugger.

# Change to game directory
GAMEPATH="`readlink -f "$0"`"
GAMEDIR="`dirname "$GAMEPATH"`"

# What architecture are we running?
MACHINE=`uname -m`
if [ "$MACHINE" = "x86_64" ]
then
	# Set path to libraries and binary (64 bit)
	BIN="$GAMEDIR/omnispeak.x86_64"
	LIBPATH="$GAMEDIR/x86_64"
else
	# Default to x86. If it's not x86, it might be able to emulate it.
	BIN="$GAMEDIR/omnispeak.x86"
	LIBPATH="$GAMEDIR/x86"
fi

# Run the game, (optionally) with the debugger
LD_LIBRARY_PATH="$LIBPATH:$LD_LIBRARY_PATH" $DEBUGGER "$BIN" $@

# Get the game's exit code, and return it.
e=$?
exit $e
