From b1647f6d045a4ec0559d0f49d09f17f6e4cf2930 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 31 Oct 2011 22:14:49 +0000 Subject: adjust pCampbot so it starts up bots with the name format " _" 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 authentication --- OpenSim/Tools/pCampBot/BotManager.cs | 107 ++++++++++++++++------------------- OpenSim/Tools/pCampBot/PhysicsBot.cs | 45 +++++++++------ OpenSim/Tools/pCampBot/README.txt | 25 +++----- OpenSim/Tools/pCampBot/pCampBot.cs | 6 +- 4 files changed, 89 insertions(+), 94 deletions(-) (limited to 'OpenSim/Tools/pCampBot') diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index c9d1446..0aaa226 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -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; /// /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data @@ -102,72 +102,65 @@ namespace pCampBot /// The configuration for the bots to use 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); } } - /// - /// Add additional bots (and threads) to our bot pool - /// - /// How Many of them to add - 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); - } - } +// /// +// /// Add additional bots (and threads) to our bot pool +// /// +// /// How Many of them to add +// 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); +// } +// } /// /// This starts up the bot and stores the thread for the bot in the thread array /// /// The position in the thread array to stick the bot's thread /// Configuration of the bot - public void startupBot(int pos, IConfig cs) + /// First name + /// Last name + /// Password + /// Login URI + 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); } /// - /// Creates a random name for the bot - /// - /// - 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; - } - - /// /// High level connnected/disconnected events so we can keep track of our threads by proxy /// /// @@ -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); +// } } } diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index de54836..1531b27 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -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 + /// + /// New instance of a SecondLife client + /// public GridClient client = new GridClient(); protected string[] talkarray; + /// - /// + /// Constructor /// - /// nini config for the bot - public PhysicsBot(IConfig bsconfig) + /// + /// + /// + /// + /// + 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 /// 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 /// 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); diff --git a/OpenSim/Tools/pCampBot/README.txt b/OpenSim/Tools/pCampBot/README.txt index 7ecbde1..c4fcf33 100644 --- a/OpenSim/Tools/pCampBot/README.txt +++ b/OpenSim/Tools/pCampBot/README.txt @@ -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 -clients that log in, randomly jump/walk around, and say excuses from +This is designed to stress test the simulator. It creates +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 _ 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 -loginuri -*nix: mono pCampBot.exe -botcount -loginuri - -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 -loginuri -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 -loginuri -firstname -lastname -password +*nix: mono pCampBot.exe -botcount -loginuri -firstname -lastname -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) diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index 77110bf..a69fbf0 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -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 _ 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" ); -- cgit v1.1