Merge branch 'master' of git://opensimulator.org/git/opensim

remove-scene-viewer
Dan Lake 2011-10-31 15:21:39 -07:00
commit 3a2dcc7298
5 changed files with 98 additions and 102 deletions

View File

@ -53,7 +53,7 @@ namespace pCampBot
protected bool m_verbose = true; protected bool m_verbose = true;
protected Random somthing = new Random(Environment.TickCount); protected Random somthing = new Random(Environment.TickCount);
protected int numbots = 0; protected int numbots = 0;
protected IConfig Previous_config; private IConfig Config;
/// <summary> /// <summary>
/// Constructor Creates MainConsole.Instance to take commands and provide the place to write data /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
@ -81,16 +81,16 @@ namespace pCampBot
m_console.Commands.AddCommand("bot", false, "shutdown", m_console.Commands.AddCommand("bot", false, "shutdown",
"shutdown", "shutdown",
"Gracefully shut down bots", HandleShutdown); "Shutdown bots and exit", HandleShutdown);
m_console.Commands.AddCommand("bot", false, "quit", m_console.Commands.AddCommand("bot", false, "quit",
"quit", "quit",
"Force quit (DANGEROUS, try shutdown first)", "Shutdown bots and exit",
HandleShutdown); HandleShutdown);
m_console.Commands.AddCommand("bot", false, "add bots", // m_console.Commands.AddCommand("bot", false, "add bots",
"add bots <number>", // "add bots <number>",
"Add more bots", HandleAddBots); // "Add more bots", HandleAddBots);
m_lBot = new List<PhysicsBot>(); m_lBot = new List<PhysicsBot>();
} }
@ -102,71 +102,64 @@ namespace pCampBot
/// <param name="cs">The configuration for the bots to use</param> /// <param name="cs">The configuration for the bots to use</param>
public void dobotStartup(int botcount, IConfig cs) public void dobotStartup(int botcount, IConfig cs)
{ {
Previous_config = cs; Config = cs;
m_td = new Thread[botcount]; 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++) 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> // /// <summary>
/// Add additional bots (and threads) to our bot pool // /// Add additional bots (and threads) to our bot pool
/// </summary> // /// </summary>
/// <param name="botcount">How Many of them to add</param> // /// <param name="botcount">How Many of them to add</param>
public void addbots(int botcount) // public void addbots(int botcount)
{ // {
int len = m_td.Length; // int len = m_td.Length;
Thread[] m_td2 = new Thread[len + botcount]; // Thread[] m_td2 = new Thread[len + botcount];
for (int i = 0; i < len; i++) // for (int i = 0; i < len; i++)
{ // {
m_td2[i] = m_td[i]; // m_td2[i] = m_td[i];
} // }
m_td = m_td2; // m_td = m_td2;
int newlen = len + botcount; // int newlen = len + botcount;
for (int i = len; i < newlen; i++) // for (int i = len; i < newlen; i++)
{ // {
startupBot(i, Previous_config); // startupBot(i, Config);
} // }
} // }
/// <summary> /// <summary>
/// This starts up the bot and stores the thread for the bot in the thread array /// This starts up the bot and stores the thread for the bot in the thread array
/// </summary> /// </summary>
/// <param name="pos">The position in the thread array to stick the bot's thread</param> /// <param name="pos">The position in the thread array to stick the bot's thread</param>
/// <param name="cs">Configuration of the bot</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.OnConnected += handlebotEvent;
pb.OnDisconnected += 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] = new Thread(pb.startup);
m_td[pos].Name = "CampBot_" + pos; m_td[pos].Name = pb.Name;
m_td[pos].IsBackground = true; m_td[pos].IsBackground = true;
m_td[pos].Start(); m_td[pos].Start();
m_lBot.Add(pb); 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> /// <summary>
/// High level connnected/disconnected events so we can keep track of our threads by proxy /// High level connnected/disconnected events so we can keep track of our threads by proxy
/// </summary> /// </summary>
@ -177,14 +170,14 @@ namespace pCampBot
switch (eventt) switch (eventt)
{ {
case EventType.CONNECTED: case EventType.CONNECTED:
m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected"); m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
numbots++; numbots++;
break; break;
case EventType.DISCONNECTED: 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(); m_td[m_lBot.IndexOf(callbot)].Abort();
numbots--; numbots--;
if (numbots >1) if (numbots <= 0)
Environment.Exit(0); Environment.Exit(0);
break; break;
} }
@ -223,17 +216,17 @@ namespace pCampBot
Environment.Exit(0); Environment.Exit(0);
} }
*/ */
//
private void HandleAddBots(string module, string[] cmd) // private void HandleAddBots(string module, string[] cmd)
{ // {
int newbots = 0; // int newbots = 0;
//
if (cmd.Length > 2) // if (cmd.Length > 2)
{ // {
Int32.TryParse(cmd[2], out newbots); // Int32.TryParse(cmd[2], out newbots);
} // }
if (newbots > 0) // if (newbots > 0)
addbots(newbots); // addbots(newbots);
} // }
} }
} }

View File

@ -45,10 +45,11 @@ namespace pCampBot
public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
public IConfig startupConfig; // bot config, passed from BotManager public IConfig startupConfig; // bot config, passed from BotManager
public string firstname; public string FirstName { get; private set; }
public string lastname; public string LastName { get; private set; }
public string password; public string Name { get; private set; }
public string loginURI; public string Password { get; private set; }
public string LoginUri { get; private set; }
public string saveDir; public string saveDir;
public string wear; public string wear;
@ -60,16 +61,28 @@ namespace pCampBot
protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here 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(); public GridClient client = new GridClient();
protected string[] talkarray; protected string[] talkarray;
/// <summary> /// <summary>
/// /// Constructor
/// </summary> /// </summary>
/// <param name="bsconfig">nini config for the bot</param> /// <param name="bsconfig"></param>
public PhysicsBot(IConfig bsconfig) /// <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; startupConfig = bsconfig;
readconfig(); readconfig();
talkarray = readexcuses(); talkarray = readexcuses();
@ -116,10 +129,6 @@ namespace pCampBot
/// </summary> /// </summary>
public void readconfig() 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"); wear = startupConfig.GetString("wear","no");
} }
@ -136,7 +145,7 @@ namespace pCampBot
/// </summary> /// </summary>
public void startup() public void startup()
{ {
client.Settings.LOGIN_SERVER = loginURI; client.Settings.LOGIN_SERVER = LoginUri;
client.Settings.ALWAYS_DECODE_OBJECTS = false; client.Settings.ALWAYS_DECODE_OBJECTS = false;
client.Settings.AVATAR_TRACKING = false; client.Settings.AVATAR_TRACKING = false;
client.Settings.OBJECT_TRACKING = false; client.Settings.OBJECT_TRACKING = false;
@ -153,10 +162,10 @@ namespace pCampBot
client.Throttle.Total = 400000; client.Throttle.Total = 400000;
client.Network.LoginProgress += this.Network_LoginProgress; client.Network.LoginProgress += this.Network_LoginProgress;
client.Network.SimConnected += this.Network_SimConnected; client.Network.SimConnected += this.Network_SimConnected;
client.Network.Disconnected += this.Network_OnDisconnected; // client.Network.Disconnected += this.Network_OnDisconnected;
client.Objects.ObjectUpdate += Objects_NewPrim; client.Objects.ObjectUpdate += Objects_NewPrim;
//client.Assets.OnAssetReceived += Asset_ReceivedCallback; //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) if (OnConnected != null)
{ {
@ -165,7 +174,7 @@ namespace pCampBot
m_action.AutoReset = false; m_action.AutoReset = false;
m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed); m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed);
m_action.Start(); m_action.Start();
OnConnected(this, EventType.CONNECTED); // OnConnected(this, EventType.CONNECTED);
if (wear == "save") if (wear == "save")
{ {
client.Appearance.SetPreviousAppearance(); client.Appearance.SetPreviousAppearance();
@ -180,7 +189,9 @@ namespace pCampBot
} }
else 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) if (OnDisconnected != null)
{ {
OnDisconnected(this, EventType.DISCONNECTED); OnDisconnected(this, EventType.DISCONNECTED);
@ -190,7 +201,7 @@ namespace pCampBot
public void SaveDefaultAppearance() public void SaveDefaultAppearance()
{ {
saveDir = "MyAppearance/" + firstname + "_" + lastname; saveDir = "MyAppearance/" + FirstName + "_" + LastName;
if (!Directory.Exists(saveDir)) if (!Directory.Exists(saveDir))
{ {
Directory.CreateDirectory(saveDir); Directory.CreateDirectory(saveDir);
@ -384,6 +395,7 @@ namespace pCampBot
{ {
client.Assets.RequestImage(prim.Textures.DefaultTexture.TextureID, ImageType.Normal, Asset_TextureCallback_Texture); client.Assets.RequestImage(prim.Textures.DefaultTexture.TextureID, ImageType.Normal, Asset_TextureCallback_Texture);
} }
for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) for (int i = 0; i < prim.Textures.FaceTextures.Length; i++)
{ {
if (prim.Textures.FaceTextures[i] != null) if (prim.Textures.FaceTextures[i] != null)
@ -392,10 +404,10 @@ namespace pCampBot
{ {
client.Assets.RequestImage(prim.Textures.FaceTextures[i].TextureID, ImageType.Normal, Asset_TextureCallback_Texture); client.Assets.RequestImage(prim.Textures.FaceTextures[i].TextureID, ImageType.Normal, Asset_TextureCallback_Texture);
} }
} }
} }
} }
if (prim.Sculpt.SculptTexture != UUID.Zero) if (prim.Sculpt.SculptTexture != UUID.Zero)
{ {
client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture); client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture);

View File

@ -1,10 +1,13 @@
This is the PhysicsCamperbot libslBot tester. This is the PhysicsCamperbot libslBot tester.
This is designed to be run in standalone mode with authorize accounts This is designed to stress test the simulator. It creates <N>
turned off as a way to stress test the simulator. It creates <N> clients that log in, randomly jump/walk around, and can say excuses from
clients that log in, randomly jump/walk around, and say excuses from
the BOFH. 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 *** *** WARNING ***
Using this bot on a public grid could get you banned permanently, so Using this bot on a public grid could get you banned permanently, so
just say No! to griefing! just say No! to griefing!
@ -21,19 +24,8 @@ pCampBot.exe will end up in the regular opensim/bin folder
----- Running the bot ----- ----- Running the bot -----
windows: pCampBot.exe -botcount <N> -loginuri <URI> 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> *nix: mono pCampBot.exe -botcount <N> -loginuri <URI> -firstname <bot-first-name> -lastname <bot-last-name-stem> -password <bot-password>
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
----- Commands ----- ----- Commands -----
@ -41,4 +33,3 @@ The bot has console commands:
help - lists the console commands and what they do help - lists the console commands and what they do
shutdown - gracefully shuts down the bots shutdown - gracefully shuts down the bots
quit - forcefully shuts things down leaving stuff unclean quit - forcefully shuts things down leaving stuff unclean
addbots N - adds N number of random bots. (replace 'N' with a number)

View File

@ -95,9 +95,9 @@ namespace pCampBot
"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 sim to log into (required)\n" +
" -n, -botcount number of bots to start (default: 1)\n" + " -n, -botcount number of bots to start (default: 1)\n" +
" -firstname first name for the bot(s) (default: random string)\n" + " -firstname first name for the bots\n" +
" -lastname lastname for the bot(s) (default: random string)\n" + " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" +
" -password password for the bots(s) (default: random string)\n" + " -password password for the bots\n" +
" -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"
); );

Binary file not shown.