#!/usr/bin/perl -w
#       Copyright (C) 2017 HikariKnight <rshikariknight@gmail.com>
#       and contributors found in the AUTHORS file.
#       Use of this script is governed by a GPL v2 license
#       that can be found in the LICENSE file.
#       Source code and contact info at https://github.com/HikariKnight/runescape

# This script is provided for legacy support

# Use the FindBin module so we can get the scriptname
use FindBin;

# Get the script name
my $scriptname = $FindBin::Script;

# Get the scriptdir
my $scriptdir = $FindBin::RealBin;

# Remove rsu- from the name
$scriptname =~ s/rsu-//;

# If scriptname is runescape and no parameters are passed
if ($scriptname =~ /^runescape$/ && "@ARGV" eq '')
{
	# Try launch the launcher (if not it will fallback to starting runescape directly)
	system "\"$scriptdir/rsu/rsu-query\"";
}
# Else if scriptname is runescape and parameters are passed and the parameters do not start with - then
elsif($scriptname =~ /^runescape$/ && "@ARGV" ne '' && "@ARGV" !~ /^(-|jagex-jav:\/\/)/)
{
	# Do an rsu-query
	system "\"$scriptdir/rsu/rsu-query\" @ARGV";
}
# Else
else
{
	# Launch the actual script
	system "\"$scriptdir/rsu/rsu-query\" client.launch.$scriptname @ARGV";
}
