2007-01-27 08:23:17 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using CommandLine.Utility;
|
|
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-01-27 08:23:17 +00:00
|
|
|
{
|
2017-03-24 01:22:28 -04:00
|
|
|
[Serializable]
|
2007-06-04 23:40:57 +00:00
|
|
|
public class CommandLineArgumentsException : Exception
|
|
|
|
|
{
|
2024-06-30 18:14:07 -05:00
|
|
|
public CommandLineArgumentsException()
|
2023-03-11 14:29:59 -06:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CommandLineArgumentsException(string message) : base(message)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CommandLineArgumentsException(string message, Exception innerException) : base(message, innerException)
|
|
|
|
|
{
|
|
|
|
|
}
|
2007-06-04 23:40:57 +00:00
|
|
|
}
|
2008-10-08 20:21:32 +00:00
|
|
|
|
2007-01-27 08:23:17 +00:00
|
|
|
public class Program
|
|
|
|
|
{
|
2008-12-03 20:52:29 +00:00
|
|
|
public static string LoginURI;
|
|
|
|
|
|
2007-01-27 08:23:17 +00:00
|
|
|
private static void Usage()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Usage: " + Environment.NewLine +
|
2009-05-25 19:33:20 +00:00
|
|
|
"TestClient.exe [--first firstname --last lastname --pass password] [--file userlist.txt] [--loginuri=\"uri\"] [--startpos \"sim/x/y/z\"] [--master \"master name\"] [--masterkey \"master uuid\"] [--gettextures] [--scriptfile \"filename\"]");
|
2007-01-27 08:23:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2021-12-12 14:46:05 -06:00
|
|
|
Console.OutputEncoding = System.Text.Encoding.UTF8;
|
|
|
|
|
Console.InputEncoding = System.Text.Encoding.UTF8;
|
|
|
|
|
|
2007-01-27 08:23:17 +00:00
|
|
|
Arguments arguments = new Arguments(args);
|
|
|
|
|
|
|
|
|
|
List<LoginDetails> accounts = new List<LoginDetails>();
|
|
|
|
|
LoginDetails account;
|
2008-02-07 17:32:06 +00:00
|
|
|
bool groupCommands = false;
|
2022-02-25 19:38:11 -06:00
|
|
|
string masterName = string.Empty;
|
2008-07-25 05:15:05 +00:00
|
|
|
UUID masterKey = UUID.Zero;
|
2022-02-25 19:38:11 -06:00
|
|
|
string file = string.Empty;
|
2008-10-09 18:04:06 +00:00
|
|
|
bool getTextures = false;
|
2010-11-20 14:14:26 +00:00
|
|
|
bool noGUI = false; // true if to not prompt for input
|
2022-02-25 19:38:11 -06:00
|
|
|
string scriptFile = string.Empty;
|
2007-01-27 08:23:17 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["groupcommands"] != null)
|
|
|
|
|
groupCommands = true;
|
2008-02-07 17:32:06 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["masterkey"] != null)
|
|
|
|
|
masterKey = UUID.Parse(arguments["masterkey"]);
|
2007-01-27 08:23:17 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["master"] != null)
|
|
|
|
|
masterName = arguments["master"];
|
|
|
|
|
|
|
|
|
|
if (arguments["loginuri"] != null)
|
2008-12-03 20:52:29 +00:00
|
|
|
LoginURI = arguments["loginuri"];
|
2022-02-25 19:38:11 -06:00
|
|
|
if (string.IsNullOrEmpty(LoginURI))
|
2008-12-03 20:52:29 +00:00
|
|
|
LoginURI = Settings.AGNI_LOGIN_SERVER;
|
|
|
|
|
Logger.Log("Using login URI " + LoginURI, Helpers.LogLevel.Info);
|
2008-10-08 20:21:32 +00:00
|
|
|
|
2008-10-09 18:04:06 +00:00
|
|
|
if (arguments["gettextures"] != null)
|
|
|
|
|
getTextures = true;
|
|
|
|
|
|
2010-11-20 14:14:26 +00:00
|
|
|
if (arguments["nogui"] != null)
|
|
|
|
|
noGUI = true;
|
|
|
|
|
|
2008-10-09 21:24:20 +00:00
|
|
|
if (arguments["scriptfile"] != null)
|
|
|
|
|
{
|
|
|
|
|
scriptFile = arguments["scriptfile"];
|
|
|
|
|
if (!File.Exists(scriptFile))
|
|
|
|
|
{
|
2019-10-30 20:39:56 -05:00
|
|
|
Logger.Log($"File {scriptFile} Does not exist", Helpers.LogLevel.Error);
|
2008-10-09 21:24:20 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (arguments["file"] != null)
|
|
|
|
|
{
|
|
|
|
|
file = arguments["file"];
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
if (!File.Exists(file))
|
2007-11-06 09:26:10 +00:00
|
|
|
{
|
2019-10-30 20:39:56 -05:00
|
|
|
Logger.Log($"File {file} Does not exist", Helpers.LogLevel.Error);
|
2008-10-08 20:21:32 +00:00
|
|
|
return;
|
2007-11-06 09:26:10 +00:00
|
|
|
}
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
// Loading names from a file
|
|
|
|
|
try
|
2007-06-04 23:40:57 +00:00
|
|
|
{
|
2019-10-30 20:46:01 -05:00
|
|
|
using (StreamReader reader = new StreamReader(file))
|
2008-04-22 02:00:53 +00:00
|
|
|
{
|
2019-10-30 20:46:01 -05:00
|
|
|
string line;
|
|
|
|
|
int lineNumber = 0;
|
2008-04-22 02:00:53 +00:00
|
|
|
|
2019-10-30 20:46:01 -05:00
|
|
|
while ((line = reader.ReadLine()) != null)
|
2007-06-04 23:40:57 +00:00
|
|
|
{
|
2019-10-30 20:46:01 -05:00
|
|
|
lineNumber++;
|
2022-02-25 19:38:11 -06:00
|
|
|
string[] tokens = line.Trim().Split(' ', ',');
|
2019-10-30 20:39:56 -05:00
|
|
|
|
2019-10-30 20:46:01 -05:00
|
|
|
if (tokens.Length >= 3)
|
2008-10-08 20:21:32 +00:00
|
|
|
{
|
2019-10-30 20:46:01 -05:00
|
|
|
account = new LoginDetails
|
|
|
|
|
{
|
|
|
|
|
FirstName = tokens[0],
|
|
|
|
|
LastName = tokens[1],
|
|
|
|
|
Password = tokens[2]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (tokens.Length >= 4) // Optional starting position
|
|
|
|
|
{
|
2024-07-04 16:26:15 -05:00
|
|
|
const char sep = '/';
|
2019-10-30 20:46:01 -05:00
|
|
|
string[] startbits = tokens[3].Split(sep);
|
|
|
|
|
account.StartLocation = NetworkManager.StartLocation(startbits[0],
|
2022-02-25 19:38:11 -06:00
|
|
|
int.Parse(startbits[1]),
|
|
|
|
|
int.Parse(startbits[2]), int.Parse(startbits[3]));
|
2019-10-30 20:46:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
accounts.Add(account);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Logger.Log("Invalid data on line " + lineNumber +
|
|
|
|
|
", must be in the format of: FirstName LastName Password [Sim/StartX/StartY/StartZ]",
|
|
|
|
|
Helpers.LogLevel.Warning);
|
2007-06-04 23:40:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-12-05 20:23:46 +00:00
|
|
|
}
|
2008-12-03 20:52:29 +00:00
|
|
|
catch (Exception ex)
|
2007-04-23 01:39:14 +00:00
|
|
|
{
|
2008-12-03 20:52:29 +00:00
|
|
|
Logger.Log("Error reading from " + args[1], Helpers.LogLevel.Error, ex);
|
2008-10-08 20:21:32 +00:00
|
|
|
return;
|
2007-04-23 01:39:14 +00:00
|
|
|
}
|
2007-06-04 23:40:57 +00:00
|
|
|
}
|
2008-10-08 20:21:32 +00:00
|
|
|
else if (arguments["first"] != null && arguments["last"] != null && arguments["pass"] != null)
|
|
|
|
|
{
|
|
|
|
|
// Taking a single login off the command-line
|
2019-10-30 20:39:56 -05:00
|
|
|
account = new LoginDetails
|
|
|
|
|
{
|
|
|
|
|
FirstName = arguments["first"],
|
|
|
|
|
LastName = arguments["last"],
|
|
|
|
|
Password = arguments["pass"]
|
|
|
|
|
};
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-08 20:21:32 +00:00
|
|
|
accounts.Add(account);
|
|
|
|
|
}
|
|
|
|
|
else if (arguments["help"] != null)
|
2007-06-04 23:40:57 +00:00
|
|
|
{
|
|
|
|
|
Usage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (LoginDetails a in accounts)
|
|
|
|
|
{
|
2008-02-07 17:32:06 +00:00
|
|
|
a.GroupCommands = groupCommands;
|
2007-06-04 23:40:57 +00:00
|
|
|
a.MasterName = masterName;
|
|
|
|
|
a.MasterKey = masterKey;
|
2008-12-03 20:52:29 +00:00
|
|
|
a.URI = LoginURI;
|
2008-10-09 21:24:20 +00:00
|
|
|
|
|
|
|
|
if (arguments["startpos"] != null)
|
|
|
|
|
{
|
2024-07-04 16:26:15 -05:00
|
|
|
const char sep = '/';
|
2008-10-09 21:24:20 +00:00
|
|
|
string[] startbits = arguments["startpos"].Split(sep);
|
2022-02-25 19:38:11 -06:00
|
|
|
a.StartLocation = NetworkManager.StartLocation(startbits[0], int.Parse(startbits[1]),
|
|
|
|
|
int.Parse(startbits[2]), int.Parse(startbits[3]));
|
2008-10-09 21:24:20 +00:00
|
|
|
}
|
2007-06-04 23:40:57 +00:00
|
|
|
}
|
2007-01-27 08:23:17 +00:00
|
|
|
|
|
|
|
|
// Login the accounts and run the input loop
|
2009-05-08 18:57:45 +00:00
|
|
|
ClientManager.Instance.Start(accounts, getTextures);
|
2008-10-09 21:24:20 +00:00
|
|
|
|
2022-02-25 19:38:11 -06:00
|
|
|
if (!string.IsNullOrEmpty(scriptFile))
|
2009-05-08 18:57:45 +00:00
|
|
|
ClientManager.Instance.DoCommandAll("script " + scriptFile, UUID.Zero);
|
2007-06-04 23:40:57 +00:00
|
|
|
|
2008-10-09 21:24:20 +00:00
|
|
|
// Then Run the ClientManager normally
|
2010-11-20 14:14:26 +00:00
|
|
|
ClientManager.Instance.Run(noGUI);
|
2007-01-27 08:23:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|