Add the ability to explicitly specify a login start location to pCampbot via the -start parameter
parent
0feb5da31e
commit
2146b20169
|
@ -97,6 +97,8 @@ namespace pCampBot
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
public string Password { get; private set; }
|
public string Password { get; private set; }
|
||||||
public string LoginUri { get; private set; }
|
public string LoginUri { get; private set; }
|
||||||
|
public string StartLocation { get; private set; }
|
||||||
|
|
||||||
public string saveDir;
|
public string saveDir;
|
||||||
public string wear;
|
public string wear;
|
||||||
|
|
||||||
|
@ -132,7 +134,7 @@ namespace pCampBot
|
||||||
/// <param name="behaviours"></param>
|
/// <param name="behaviours"></param>
|
||||||
public Bot(
|
public Bot(
|
||||||
BotManager bm, List<IBehaviour> behaviours,
|
BotManager bm, List<IBehaviour> behaviours,
|
||||||
string firstName, string lastName, string password, string loginUri)
|
string firstName, string lastName, string password, string startLocation, string loginUri)
|
||||||
{
|
{
|
||||||
ConnectionState = ConnectionState.Disconnected;
|
ConnectionState = ConnectionState.Disconnected;
|
||||||
|
|
||||||
|
@ -146,6 +148,7 @@ namespace pCampBot
|
||||||
Name = string.Format("{0} {1}", FirstName, LastName);
|
Name = string.Format("{0} {1}", FirstName, LastName);
|
||||||
Password = password;
|
Password = password;
|
||||||
LoginUri = loginUri;
|
LoginUri = loginUri;
|
||||||
|
StartLocation = startLocation;
|
||||||
|
|
||||||
Manager = bm;
|
Manager = bm;
|
||||||
Behaviours = behaviours;
|
Behaviours = behaviours;
|
||||||
|
@ -209,7 +212,7 @@ namespace pCampBot
|
||||||
|
|
||||||
ConnectionState = ConnectionState.Connecting;
|
ConnectionState = ConnectionState.Connecting;
|
||||||
|
|
||||||
if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
|
if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", StartLocation, "Your name"))
|
||||||
{
|
{
|
||||||
ConnectionState = ConnectionState.Connected;
|
ConnectionState = ConnectionState.Connected;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace pCampBot
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls whether bots start out sending agent updates on connection.
|
/// Controls whether bots start out sending agent updates on connection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool BotsInitSendAgentUpdates { get; set; }
|
public bool InitBotSendAgentUpdates { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Created bots, whether active or inactive.
|
/// Created bots, whether active or inactive.
|
||||||
|
@ -92,7 +92,7 @@ namespace pCampBot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BotManager()
|
public BotManager()
|
||||||
{
|
{
|
||||||
BotsInitSendAgentUpdates = true;
|
InitBotSendAgentUpdates = true;
|
||||||
|
|
||||||
LoginDelay = DefaultLoginDelay;
|
LoginDelay = DefaultLoginDelay;
|
||||||
|
|
||||||
|
@ -156,21 +156,25 @@ namespace pCampBot
|
||||||
string lastNameStem = startupConfig.GetString("lastname");
|
string lastNameStem = startupConfig.GetString("lastname");
|
||||||
string password = startupConfig.GetString("password");
|
string password = startupConfig.GetString("password");
|
||||||
string loginUri = startupConfig.GetString("loginuri");
|
string loginUri = startupConfig.GetString("loginuri");
|
||||||
|
string startLocation = startupConfig.GetString("start", "last");
|
||||||
string wearSetting = startupConfig.GetString("wear", "no");
|
string wearSetting = startupConfig.GetString("wear", "no");
|
||||||
|
|
||||||
|
string startUri = ParseInputStartLocationToUri(startLocation);
|
||||||
|
|
||||||
HashSet<string> behaviourSwitches = new HashSet<string>();
|
HashSet<string> behaviourSwitches = new HashSet<string>();
|
||||||
Array.ForEach<string>(
|
Array.ForEach<string>(
|
||||||
startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
|
startupConfig.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
|
||||||
|
|
||||||
MainConsole.Instance.OutputFormat(
|
MainConsole.Instance.OutputFormat(
|
||||||
"[BOT MANAGER]: Starting {0} bots connecting to {1}, named {2} {3}_<n>",
|
"[BOT MANAGER]: Starting {0} bots connecting to {1}, location {2}, named {3} {4}_<n>",
|
||||||
botcount,
|
botcount,
|
||||||
loginUri,
|
loginUri,
|
||||||
|
startUri,
|
||||||
firstName,
|
firstName,
|
||||||
lastNameStem);
|
lastNameStem);
|
||||||
|
|
||||||
MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay);
|
MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay);
|
||||||
MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", BotsInitSendAgentUpdates);
|
MainConsole.Instance.OutputFormat("[BOT MANAGER]: BotsSendAgentUpdates is {0}", InitBotSendAgentUpdates);
|
||||||
|
|
||||||
for (int i = 0; i < botcount; i++)
|
for (int i = 0; i < botcount; i++)
|
||||||
{
|
{
|
||||||
|
@ -195,10 +199,49 @@ namespace pCampBot
|
||||||
if (behaviourSwitches.Contains("t"))
|
if (behaviourSwitches.Contains("t"))
|
||||||
behaviours.Add(new TeleportBehaviour());
|
behaviours.Add(new TeleportBehaviour());
|
||||||
|
|
||||||
StartBot(this, behaviours, firstName, lastName, password, loginUri, wearSetting);
|
StartBot(this, behaviours, firstName, lastName, password, loginUri, startUri, wearSetting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the command line start location to a start string/uri that the login mechanism will recognize.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// The input start location to URI.
|
||||||
|
/// </returns>
|
||||||
|
/// <param name='startLocation'>
|
||||||
|
/// Start location.
|
||||||
|
/// </param>
|
||||||
|
private string ParseInputStartLocationToUri(string startLocation)
|
||||||
|
{
|
||||||
|
if (startLocation == "home" || startLocation == "last")
|
||||||
|
return startLocation;
|
||||||
|
|
||||||
|
string regionName;
|
||||||
|
|
||||||
|
// Just a region name or only one (!) extra component. Like a viewer, we will stick 128/128/0 on the end
|
||||||
|
Vector3 startPos = new Vector3(128, 128, 0);
|
||||||
|
|
||||||
|
string[] startLocationComponents = startLocation.Split('/');
|
||||||
|
|
||||||
|
regionName = startLocationComponents[0];
|
||||||
|
|
||||||
|
if (startLocationComponents.Length >= 2)
|
||||||
|
{
|
||||||
|
float.TryParse(startLocationComponents[1], out startPos.X);
|
||||||
|
|
||||||
|
if (startLocationComponents.Length >= 3)
|
||||||
|
{
|
||||||
|
float.TryParse(startLocationComponents[2], out startPos.Y);
|
||||||
|
|
||||||
|
if (startLocationComponents.Length >= 4)
|
||||||
|
float.TryParse(startLocationComponents[3], out startPos.Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("uri:{0}&{1}&{2}&{3}", regionName, startPos.X, startPos.Y, startPos.Z);
|
||||||
|
}
|
||||||
|
|
||||||
// /// <summary>
|
// /// <summary>
|
||||||
// /// Add additional bots (and threads) to our bot pool
|
// /// Add additional bots (and threads) to our bot pool
|
||||||
// /// </summary>
|
// /// </summary>
|
||||||
|
@ -228,18 +271,19 @@ namespace pCampBot
|
||||||
/// <param name="lastName">Last name</param>
|
/// <param name="lastName">Last name</param>
|
||||||
/// <param name="password">Password</param>
|
/// <param name="password">Password</param>
|
||||||
/// <param name="loginUri">Login URI</param>
|
/// <param name="loginUri">Login URI</param>
|
||||||
|
/// <param name="startLocation">Location to start the bot. Can be "last", "home" or a specific sim name.</param>
|
||||||
/// <param name="wearSetting"></param>
|
/// <param name="wearSetting"></param>
|
||||||
public void StartBot(
|
public void StartBot(
|
||||||
BotManager bm, List<IBehaviour> behaviours,
|
BotManager bm, List<IBehaviour> behaviours,
|
||||||
string firstName, string lastName, string password, string loginUri, string wearSetting)
|
string firstName, string lastName, string password, string loginUri, string startLocation, string wearSetting)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.OutputFormat(
|
MainConsole.Instance.OutputFormat(
|
||||||
"[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
|
"[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
|
||||||
firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
|
firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
|
||||||
|
|
||||||
Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
|
Bot pb = new Bot(bm, behaviours, firstName, lastName, password, startLocation, loginUri);
|
||||||
pb.wear = wearSetting;
|
pb.wear = wearSetting;
|
||||||
pb.Client.Settings.SEND_AGENT_UPDATES = BotsInitSendAgentUpdates;
|
pb.Client.Settings.SEND_AGENT_UPDATES = InitBotSendAgentUpdates;
|
||||||
|
|
||||||
pb.OnConnected += handlebotEvent;
|
pb.OnConnected += handlebotEvent;
|
||||||
pb.OnDisconnected += handlebotEvent;
|
pb.OnDisconnected += handlebotEvent;
|
||||||
|
|
|
@ -86,8 +86,8 @@ namespace pCampBot
|
||||||
|
|
||||||
if (botConfig != null)
|
if (botConfig != null)
|
||||||
{
|
{
|
||||||
bm.BotsInitSendAgentUpdates
|
bm.InitBotSendAgentUpdates
|
||||||
= botConfig.GetBoolean("SendAgentUpdates", bm.BotsInitSendAgentUpdates);
|
= botConfig.GetBoolean("SendAgentUpdates", bm.InitBotSendAgentUpdates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +119,7 @@ namespace pCampBot
|
||||||
|
|
||||||
cs.AddSwitch("Startup", "botcount", "n");
|
cs.AddSwitch("Startup", "botcount", "n");
|
||||||
cs.AddSwitch("Startup", "loginuri", "l");
|
cs.AddSwitch("Startup", "loginuri", "l");
|
||||||
|
cs.AddSwitch("Startup", "start", "s");
|
||||||
cs.AddSwitch("Startup", "firstname");
|
cs.AddSwitch("Startup", "firstname");
|
||||||
cs.AddSwitch("Startup", "lastname");
|
cs.AddSwitch("Startup", "lastname");
|
||||||
cs.AddSwitch("Startup", "password");
|
cs.AddSwitch("Startup", "password");
|
||||||
|
@ -137,22 +138,23 @@ namespace pCampBot
|
||||||
// name, to load an specific folder, or save, to save an avatar with some already existing wearables
|
// name, to load an specific folder, or save, to save an avatar with some already existing wearables
|
||||||
// worn to the folder MyAppearance/FirstName_LastName, and the load it.
|
// worn to the folder MyAppearance/FirstName_LastName, and the load it.
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
"usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" +
|
"usage: pCampBot <-loginuri loginuri> [OPTIONS]\n"
|
||||||
"Spawns a set of bots to test an OpenSim region\n\n" +
|
+ "Spawns a set of bots to test an OpenSim region\n\n"
|
||||||
" -l, -loginuri loginuri for sim to log into (required)\n" +
|
+ " -l, -loginuri loginuri for grid/standalone (required)\n"
|
||||||
" -n, -botcount number of bots to start (default: 1)\n" +
|
+ " -s, -start start location for bots. Can be \"last\", \"home\" or a specific location with or without co-ords (e.g. \"region1\" or \"region2/50/30/90\"\n"
|
||||||
" -firstname first name for the bots\n" +
|
+ " -n, -botcount number of bots to start (default: 1)\n"
|
||||||
" -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" +
|
+ " -firstname first name for the bots\n"
|
||||||
" -password password for the bots\n" +
|
+ " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n"
|
||||||
" -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n" +
|
+ " -password password for the bots\n"
|
||||||
" current options are:\n" +
|
+ " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n"
|
||||||
" p (physics - bots constantly move and jump around)\n" +
|
+ " current options are:\n"
|
||||||
" g (grab - bots randomly click prims whether set clickable or not)\n" +
|
+ " p (physics - bots constantly move and jump around)\n"
|
||||||
" n (none - bots do nothing)\n" +
|
+ " g (grab - bots randomly click prims whether set clickable or not)\n"
|
||||||
" t (teleport - bots regularly teleport between regions on the grid)\n" +
|
+ " n (none - bots do nothing)\n"
|
||||||
|
+ " t (teleport - bots regularly teleport between regions on the grid)\n"
|
||||||
// " c (cross)" +
|
// " c (cross)" +
|
||||||
" -wear set appearance folder to load from (default: no)\n" +
|
+ " -wear set appearance folder to load from (default: no)\n"
|
||||||
" -h, -help show this message");
|
+ " -h, -help show this message.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue