#!/usr/bin/env bash
# Onslaught CE: checks the 32-bit system libraries, then hands over to onslaught-ce-launch, which finds your Battle
# Engine Aquila install (BEA_GAME_DIR, ce.ini, Steam's libraries, or asks once), starts
# the game from this folder (or the updated version in versions/); saves and settings use a separate user folder.
set -euo pipefail
HERE=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
# Mirror the launcher's option prefix: -- or the first unrecognized argument begins game arguments.
# Only recognized commands that cannot start a game may skip the game-library preflight.
preflight=1
for arg in "$@"; do
	case "$arg" in
		--version|--apply) preflight=0; break ;;
		--update-only|--rollback|--report) preflight=0 ;;
		--no-update-check|--record|--no-record) ;;
		*) break ;;
	esac
done
if [ "$preflight" = 1 ] && [ "${BEA_SKIP_PREFLIGHT:-}" != 1 ]; then "$HERE/preflight.sh" || exit 1; fi
export DXVK_WSI_DRIVER=SDL3 DXVK_LOG_LEVEL=${DXVK_LOG_LEVEL:-none}
export LD_LIBRARY_PATH="$HERE/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec "$HERE/onslaught-ce-launch" "$@"
