adjust pCampbot so it starts up bots with the name format "<firstname> <lastname>_<bot-number>"
e.g. starting up two bots called "Ima Bot" will give them the names "Ima Bot_0" and "Ima Bot_1" This is necessary since bots with random names can no longer be created, as there's no easy way to turn off account authenticationremove-scene-viewer
parent
74cc834fec
commit
b1647f6d04
|
@ -53,7 +53,7 @@ namespace pCampBot
|
|||
protected bool m_verbose = true;
|
||||
protected Random somthing = new Random(Environment.TickCount);
|
||||
protected int numbots = 0;
|
||||
protected IConfig Previous_config;
|
||||
private IConfig Config;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
|
||||
|
@ -102,71 +102,64 @@ namespace pCampBot
|
|||
/// <param name="cs">The configuration for the bots to use</param>
|
||||
public void dobotStartup(int botcount, IConfig cs)
|
||||
{
|
||||
Previous_config = cs;
|
||||
Config = cs;
|
||||
m_td = new Thread[botcount];
|
||||
|
||||
string firstName = cs.GetString("firstname");
|
||||
string lastNameStem = cs.GetString("lastname");
|
||||
string password = cs.GetString("password");
|
||||
string loginUri = cs.GetString("loginuri");
|
||||
|
||||
for (int i = 0; i < botcount; i++)
|
||||
{
|
||||
startupBot(i, cs);
|
||||
string lastName = string.Format("{0}_{1}", lastNameStem, i);
|
||||
startupBot(i, cs, firstName, lastName, password, loginUri);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add additional bots (and threads) to our bot pool
|
||||
/// </summary>
|
||||
/// <param name="botcount">How Many of them to add</param>
|
||||
public void addbots(int botcount)
|
||||
{
|
||||
int len = m_td.Length;
|
||||
Thread[] m_td2 = new Thread[len + botcount];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
m_td2[i] = m_td[i];
|
||||
}
|
||||
m_td = m_td2;
|
||||
int newlen = len + botcount;
|
||||
for (int i = len; i < newlen; i++)
|
||||
{
|
||||
startupBot(i, Previous_config);
|
||||
}
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Add additional bots (and threads) to our bot pool
|
||||
// /// </summary>
|
||||
// /// <param name="botcount">How Many of them to add</param>
|
||||
// public void addbots(int botcount)
|
||||
// {
|
||||
// int len = m_td.Length;
|
||||
// Thread[] m_td2 = new Thread[len + botcount];
|
||||
// for (int i = 0; i < len; i++)
|
||||
// {
|
||||
// m_td2[i] = m_td[i];
|
||||
// }
|
||||
// m_td = m_td2;
|
||||
// int newlen = len + botcount;
|
||||
// for (int i = len; i < newlen; i++)
|
||||
// {
|
||||
// startupBot(i, Config);
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// This starts up the bot and stores the thread for the bot in the thread array
|
||||
/// </summary>
|
||||
/// <param name="pos">The position in the thread array to stick the bot's thread</param>
|
||||
/// <param name="cs">Configuration of the bot</param>
|
||||
public void startupBot(int pos, IConfig cs)
|
||||
/// <param name="firstName">First name</param>
|
||||
/// <param name="lastName">Last name</param>
|
||||
/// <param name="password">Password</param>
|
||||
/// <param name="loginUri">Login URI</param>
|
||||
public void startupBot(int pos, IConfig cs, string firstName, string lastName, string password, string loginUri)
|
||||
{
|
||||
PhysicsBot pb = new PhysicsBot(cs);
|
||||
PhysicsBot pb = new PhysicsBot(cs, firstName, lastName, password, loginUri);
|
||||
|
||||
pb.OnConnected += handlebotEvent;
|
||||
pb.OnDisconnected += handlebotEvent;
|
||||
if (cs.GetString("firstname", "random") == "random") pb.firstname = CreateRandomName();
|
||||
if (cs.GetString("lastname", "random") == "random") pb.lastname = CreateRandomName();
|
||||
|
||||
m_td[pos] = new Thread(pb.startup);
|
||||
m_td[pos].Name = "CampBot_" + pos;
|
||||
m_td[pos].Name = pb.Name;
|
||||
m_td[pos].IsBackground = true;
|
||||
m_td[pos].Start();
|
||||
m_lBot.Add(pb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random name for the bot
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string CreateRandomName()
|
||||
{
|
||||
string returnstring = "";
|
||||
string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
returnstring += chars.Substring(somthing.Next(chars.Length),1);
|
||||
}
|
||||
return returnstring;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// High level connnected/disconnected events so we can keep track of our threads by proxy
|
||||
/// </summary>
|
||||
|
@ -177,11 +170,11 @@ namespace pCampBot
|
|||
switch (eventt)
|
||||
{
|
||||
case EventType.CONNECTED:
|
||||
m_log.Info("[" + callbot.firstname + " " + callbot.lastname + "]: Connected");
|
||||
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
|
||||
numbots++;
|
||||
break;
|
||||
case EventType.DISCONNECTED:
|
||||
m_log.Info("[" + callbot.firstname + " " + callbot.lastname + "]: Disconnected");
|
||||
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected");
|
||||
m_td[m_lBot.IndexOf(callbot)].Abort();
|
||||
numbots--;
|
||||
if (numbots <= 0)
|
||||
|
@ -223,17 +216,17 @@ namespace pCampBot
|
|||
Environment.Exit(0);
|
||||
}
|
||||
*/
|
||||
|
||||
private void HandleAddBots(string module, string[] cmd)
|
||||
{
|
||||
int newbots = 0;
|
||||
|
||||
if (cmd.Length > 2)
|
||||
{
|
||||
Int32.TryParse(cmd[2], out newbots);
|
||||
}
|
||||
if (newbots > 0)
|
||||
addbots(newbots);
|
||||
}
|
||||
//
|
||||
// private void HandleAddBots(string module, string[] cmd)
|
||||
// {
|
||||
// int newbots = 0;
|
||||
//
|
||||
// if (cmd.Length > 2)
|
||||
// {
|
||||
// Int32.TryParse(cmd[2], out newbots);
|
||||
// }
|
||||
// if (newbots > 0)
|
||||
// addbots(newbots);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,10 +45,11 @@ namespace pCampBot
|
|||
public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
|
||||
public IConfig startupConfig; // bot config, passed from BotManager
|
||||
|
||||
public string firstname;
|
||||
public string lastname;
|
||||
public string password;
|
||||
public string loginURI;
|
||||
public string FirstName { get; private set; }
|
||||
public string LastName { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Password { get; private set; }
|
||||
public string LoginUri { get; private set; }
|
||||
public string saveDir;
|
||||
public string wear;
|
||||
|
||||
|
@ -60,16 +61,28 @@ namespace pCampBot
|
|||
|
||||
protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here
|
||||
|
||||
//New instance of a SecondLife client
|
||||
/// <summary>
|
||||
/// New instance of a SecondLife client
|
||||
/// </summary>
|
||||
public GridClient client = new GridClient();
|
||||
|
||||
protected string[] talkarray;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="bsconfig">nini config for the bot</param>
|
||||
public PhysicsBot(IConfig bsconfig)
|
||||
/// <param name="bsconfig"></param>
|
||||
/// <param name="firstName"></param>
|
||||
/// <param name="lastName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="loginUri"></param>
|
||||
public PhysicsBot(IConfig bsconfig, string firstName, string lastName, string password, string loginUri)
|
||||
{
|
||||
FirstName = firstName;
|
||||
LastName = lastName;
|
||||
Name = string.Format("{0} {1}", FirstName, LastName);
|
||||
Password = password;
|
||||
LoginUri = loginUri;
|
||||
startupConfig = bsconfig;
|
||||
readconfig();
|
||||
talkarray = readexcuses();
|
||||
|
@ -116,10 +129,6 @@ namespace pCampBot
|
|||
/// </summary>
|
||||
public void readconfig()
|
||||
{
|
||||
firstname = startupConfig.GetString("firstname", "random");
|
||||
lastname = startupConfig.GetString("lastname", "random");
|
||||
password = startupConfig.GetString("password", "12345");
|
||||
loginURI = startupConfig.GetString("loginuri");
|
||||
wear = startupConfig.GetString("wear","no");
|
||||
}
|
||||
|
||||
|
@ -136,7 +145,7 @@ namespace pCampBot
|
|||
/// </summary>
|
||||
public void startup()
|
||||
{
|
||||
client.Settings.LOGIN_SERVER = loginURI;
|
||||
client.Settings.LOGIN_SERVER = LoginUri;
|
||||
client.Settings.ALWAYS_DECODE_OBJECTS = false;
|
||||
client.Settings.AVATAR_TRACKING = false;
|
||||
client.Settings.OBJECT_TRACKING = false;
|
||||
|
@ -153,10 +162,10 @@ namespace pCampBot
|
|||
client.Throttle.Total = 400000;
|
||||
client.Network.LoginProgress += this.Network_LoginProgress;
|
||||
client.Network.SimConnected += this.Network_SimConnected;
|
||||
client.Network.Disconnected += this.Network_OnDisconnected;
|
||||
// client.Network.Disconnected += this.Network_OnDisconnected;
|
||||
client.Objects.ObjectUpdate += Objects_NewPrim;
|
||||
//client.Assets.OnAssetReceived += Asset_ReceivedCallback;
|
||||
if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name"))
|
||||
if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
|
||||
{
|
||||
if (OnConnected != null)
|
||||
{
|
||||
|
@ -180,7 +189,9 @@ namespace pCampBot
|
|||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output(firstname + " " + lastname + " Can't login: " + client.Network.LoginMessage);
|
||||
MainConsole.Instance.OutputFormat(
|
||||
"{0} {1} cannot login: {2}", FirstName, LastName, client.Network.LoginMessage);
|
||||
|
||||
if (OnDisconnected != null)
|
||||
{
|
||||
OnDisconnected(this, EventType.DISCONNECTED);
|
||||
|
@ -190,7 +201,7 @@ namespace pCampBot
|
|||
|
||||
public void SaveDefaultAppearance()
|
||||
{
|
||||
saveDir = "MyAppearance/" + firstname + "_" + lastname;
|
||||
saveDir = "MyAppearance/" + FirstName + "_" + LastName;
|
||||
if (!Directory.Exists(saveDir))
|
||||
{
|
||||
Directory.CreateDirectory(saveDir);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
This is the PhysicsCamperbot libslBot tester.
|
||||
|
||||
This is designed to be run in standalone mode with authorize accounts
|
||||
turned off as a way to stress test the simulator. It creates <N>
|
||||
clients that log in, randomly jump/walk around, and say excuses from
|
||||
This is designed to stress test the simulator. It creates <N>
|
||||
clients that log in, randomly jump/walk around, and can say excuses from
|
||||
the BOFH.
|
||||
|
||||
Bots must have accounts already created. Each bot will have the same firstname and password
|
||||
but their lastname will be appended with _<bot-number> starting from 0. So if you have two bots called ima bot, their
|
||||
first names will be ima_bot_0 and ima_bot_1.
|
||||
|
||||
*** WARNING ***
|
||||
Using this bot on a public grid could get you banned permanently, so
|
||||
just say No! to griefing!
|
||||
|
@ -21,19 +24,8 @@ pCampBot.exe will end up in the regular opensim/bin folder
|
|||
|
||||
----- Running the bot -----
|
||||
|
||||
windows: pCampBot.exe -botcount <N> -loginuri <URI>
|
||||
*nix: mono pCampBot.exe -botcount <N> -loginuri <URI>
|
||||
|
||||
The names it produces are random by default, however, you can specify
|
||||
either a firstname or a lastname in the command line also.
|
||||
|
||||
ex: pCampBot.exe -botcount <N> -loginuri <URI> -lastname <lastname>
|
||||
|
||||
If you specify both a firstname *and* a lastname, you'll likely run
|
||||
into trouble unless you're only running a single bot. In that case,
|
||||
there's also a password option.
|
||||
|
||||
pCampBot.exe -botcount 1 -loginuri http://somegrid.com:8002 -firstname SomeDude -lastname SomeDude -password GobbleDeGook
|
||||
windows: pCampBot.exe -botcount <N> -loginuri <URI> -firstname <bot-first-name> -lastname <bot-last-name-stem> -password <bot-password>
|
||||
*nix: mono pCampBot.exe -botcount <N> -loginuri <URI> -firstname <bot-first-name> -lastname <bot-last-name-stem> -password <bot-password>
|
||||
|
||||
----- Commands -----
|
||||
|
||||
|
@ -41,4 +33,3 @@ The bot has console commands:
|
|||
help - lists the console commands and what they do
|
||||
shutdown - gracefully shuts down the bots
|
||||
quit - forcefully shuts things down leaving stuff unclean
|
||||
addbots N - adds N number of random bots. (replace 'N' with a number)
|
||||
|
|
|
@ -95,9 +95,9 @@ namespace pCampBot
|
|||
"Spawns a set of bots to test an OpenSim region\n\n" +
|
||||
" -l, -loginuri loginuri for sim to log into (required)\n" +
|
||||
" -n, -botcount number of bots to start (default: 1)\n" +
|
||||
" -firstname first name for the bot(s) (default: random string)\n" +
|
||||
" -lastname lastname for the bot(s) (default: random string)\n" +
|
||||
" -password password for the bots(s) (default: random string)\n" +
|
||||
" -firstname first name for the bots\n" +
|
||||
" -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" +
|
||||
" -password password for the bots\n" +
|
||||
" -wear set appearance folder to load from (default: no)\n" +
|
||||
" -h, -help show this message"
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue