From 21b623b70e33b80dc8caae3b1730bcd8069e3caa Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Fri, 15 Feb 2008 02:53:05 +0000
Subject: Moved pCampBot to OpenSim/Tools
---
OpenSim/Tools/pCampBot/BotManager.cs | 235 ++++++++++++++++++++++
OpenSim/Tools/pCampBot/PhysicsBot.cs | 191 ++++++++++++++++++
OpenSim/Tools/pCampBot/PhysicsCamperBotREADME.txt | 36 ++++
OpenSim/Tools/pCampBot/pCampBot.cs | 76 +++++++
OpenSim/Tools/pCampBot/prebuild.xml | 63 ++++++
OpenSim/Tools/pCampBot/runprebuild.bat | 2 +
OpenSim/Tools/pCampBot/runprebuild.sh | 4 +
pCampBot/BotManager.cs | 235 ----------------------
pCampBot/PhysicsBot.cs | 191 ------------------
pCampBot/PhysicsCamperBotREADME.txt | 36 ----
pCampBot/pCampBot.cs | 76 -------
pCampBot/prebuild.xml | 63 ------
pCampBot/runprebuild.bat | 2 -
pCampBot/runprebuild.sh | 4 -
14 files changed, 607 insertions(+), 607 deletions(-)
create mode 100644 OpenSim/Tools/pCampBot/BotManager.cs
create mode 100644 OpenSim/Tools/pCampBot/PhysicsBot.cs
create mode 100644 OpenSim/Tools/pCampBot/PhysicsCamperBotREADME.txt
create mode 100644 OpenSim/Tools/pCampBot/pCampBot.cs
create mode 100644 OpenSim/Tools/pCampBot/prebuild.xml
create mode 100755 OpenSim/Tools/pCampBot/runprebuild.bat
create mode 100755 OpenSim/Tools/pCampBot/runprebuild.sh
delete mode 100644 pCampBot/BotManager.cs
delete mode 100644 pCampBot/PhysicsBot.cs
delete mode 100644 pCampBot/PhysicsCamperBotREADME.txt
delete mode 100644 pCampBot/pCampBot.cs
delete mode 100644 pCampBot/prebuild.xml
delete mode 100755 pCampBot/runprebuild.bat
delete mode 100755 pCampBot/runprebuild.sh
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
new file mode 100644
index 0000000..0c7fa4e
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -0,0 +1,235 @@
+/*
+* Copyright (c) Contributors, http://opensimulator.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using libsecondlife;
+using libsecondlife.Packets;
+using Nini.Config;
+using System.Threading;
+using OpenSim.Framework;
+using OpenSim.Framework.Console;
+
+namespace pCampBot
+{
+ ///
+ /// Thread/Bot manager for the application
+ ///
+ public class BotManager : conscmd_callback
+ {
+ private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+
+ protected ConsoleBase m_console;
+ protected List m_lBot;
+ protected Thread[] m_td;
+ protected bool m_verbose = true;
+ protected Random somthing = new Random(System.Environment.TickCount);
+ protected int numbots = 0;
+ protected IConfig Previous_config;
+
+ ///
+ /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
+ ///
+ public BotManager()
+ {
+ m_console = CreateConsole();
+ MainConsole.Instance = m_console;
+ m_lBot = new List();
+ }
+
+ ///
+ /// Startup number of bots specified in the starting arguments
+ ///
+ /// How many bots to start up
+ /// The configuration for the bots to use
+ public void dobotStartup(int botcount, IConfig cs)
+ {
+ Previous_config = cs;
+ m_td = new Thread[botcount];
+ for (int i = 0; i < botcount; i++)
+ {
+ startupBot(i, cs);
+ }
+ }
+
+ ///
+ /// 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);
+ }
+ }
+
+ ///
+ /// 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)
+ {
+ PhysicsBot pb = new PhysicsBot(cs);
+
+ 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].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
+ ///
+ ///
+ ///
+ public void handlebotEvent(PhysicsBot callbot, EventType eventt)
+ {
+ switch (eventt)
+ {
+ case EventType.CONNECTED:
+ m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected");
+ numbots++;
+ break;
+ case EventType.DISCONNECTED:
+ m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Disconnected");
+ m_td[m_lBot.IndexOf(callbot)].Abort();
+ numbots--;
+ if (numbots >1)
+ Environment.Exit(0);
+ break;
+ }
+ }
+
+ ///
+ /// Shutting down all bots
+ ///
+ public void doBotShutdown()
+ {
+ foreach (PhysicsBot pb in m_lBot)
+ {
+ pb.shutdown();
+ }
+ }
+
+ ///
+ /// Standard CreateConsole routine
+ ///
+ ///
+ protected ConsoleBase CreateConsole()
+ {
+ return new ConsoleBase("Region", this);
+ }
+
+ ///
+ /// I don't think the bots use this..
+ ///
+ ///
+ ///
+ ///
+ private string CombineParams(string[] commandParams, int pos)
+ {
+ string result = String.Empty;
+ for (int i = pos; i < commandParams.Length; i++)
+ {
+ result += commandParams[i] + " ";
+ }
+ result = result.TrimEnd(' ');
+ return result;
+ }
+
+ ///
+ /// Command runnint tool.. Currently use it to add bots, shutdown and (dangerous)Forcequit
+ ///
+ ///
+ ///
+ public void RunCmd(string command, string[] cmdparams)
+ {
+ switch (command)
+ {
+ case "shutdown":
+ m_console.Warn("BOTMANAGER", "Shutting down bots");
+ doBotShutdown();
+ break;
+ case "quit":
+ m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit");
+ Environment.Exit(0);
+ break;
+ case "addbots":
+ int newbots = 0;
+ Helpers.TryParse(cmdparams[0], out newbots);
+
+ if (newbots > 0)
+ addbots(newbots);
+ break;
+ case "help":
+ m_console.Notice("HELP", "\nshutdown - graceful shutdown\naddbots - adds n bots to the test\nquit - forcequits, dangerous if you have not already run shutdown");
+ break;
+ }
+ }
+
+ ///
+ /// Required method to implement the conscmd_callback interface
+ ///
+ ///
+ public void Show(string ShowWhat)
+ {
+ }
+ }
+}
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
new file mode 100644
index 0000000..500683a
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -0,0 +1,191 @@
+/*
+* Copyright (c) Contributors, http://opensimulator.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using libsecondlife;
+using libsecondlife.Packets;
+using Nini.Config;
+using System.Threading;
+using OpenSim.Framework;
+using OpenSim.Framework.Console;
+using Timer=System.Timers.Timer;
+
+namespace pCampBot
+{
+ public class PhysicsBot
+ {
+ 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 event AnEvent OnConnected;
+ public event AnEvent OnDisconnected;
+
+ protected Timer m_action; // Action Timer
+
+ protected Random somthing = new Random(System.Environment.TickCount);// We do stuff randomly here
+
+ //New instance of a SecondLife client
+ public SecondLife client = new SecondLife();
+
+ protected string[] talkarray;
+ ///
+ ///
+ ///
+ /// nini config for the bot
+ public PhysicsBot(IConfig bsconfig)
+ {
+ startupConfig = bsconfig;
+ readconfig();
+ talkarray = readexcuses();
+ }
+
+ //We do our actions here. This is where one would
+ //add additional steps and/or things the bot should do
+
+ void m_action_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ //client.Throttle.Task = 500000f;
+ //client.Throttle.Set();
+
+ client.Self.Movement.AlwaysRun = true;
+ LLVector3 pos = client.Self.SimPosition;
+ LLVector3 newpos = new LLVector3(somthing.Next(255),somthing.Next(255),somthing.Next(255));
+
+
+ client.Self.Movement.TurnToward(newpos);
+ for (int i = 0; i < 2000; i++)
+ {
+ client.Self.Movement.AtPos = true;
+ }
+ client.Self.Jump();
+ string randomf = talkarray[somthing.Next(talkarray.Length)];
+ if (talkarray.Length > 1 && randomf.Length > 1)
+ client.Self.Chat("Can't do it, " + randomf, 0, ChatType.Normal);
+
+ Thread.Sleep(somthing.Next(1,20));
+
+ }
+
+ ///
+ /// Read the Nini config and initialize
+ ///
+ public void readconfig()
+ {
+ firstname = startupConfig.GetString("firstname", "random");
+ lastname = startupConfig.GetString("lastname", "random");
+ password = startupConfig.GetString("password", "12345");
+ loginURI = startupConfig.GetString("loginuri", "http://10.1.1.5:9000");
+
+
+
+ }
+
+ ///
+ /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes.
+ ///
+ public void shutdown()
+ {
+ client.Network.Logout();
+ }
+
+ ///
+ /// This is the bot startup loop.
+ ///
+ public void startup()
+ {
+ client.Settings.LOGIN_SERVER = loginURI;
+ client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected);
+ client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected);
+ client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected);
+ if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name"))
+ {
+
+ if (OnConnected != null)
+ {
+ m_action = new Timer(somthing.Next(1000, 10000));
+ m_action.Elapsed += new System.Timers.ElapsedEventHandler(m_action_Elapsed);
+ m_action.Start();
+ OnConnected(this, EventType.CONNECTED);
+ client.Self.Jump();
+
+ }
+ }
+ else
+ {
+ MainConsole.Instance.Error(firstname + " " + lastname, "Can't login: " + client.Network.LoginMessage);
+ if (OnDisconnected != null)
+ {
+ OnDisconnected(this, EventType.DISCONNECTED);
+ }
+ }
+ }
+
+ public void Network_OnConnected(object sender)
+ {
+ if (OnConnected != null)
+ {
+ OnConnected(this, EventType.CONNECTED);
+ }
+ }
+
+ public void Simulator_Connected(object sender)
+ {
+ }
+
+ public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)
+ {
+ if (OnDisconnected != null)
+ {
+ OnDisconnected(this,EventType.DISCONNECTED);
+ }
+ }
+
+ public string[] readexcuses()
+ {
+ string allexcuses = "";
+
+ string file = Path.Combine(Util.configDir(), "excuses");
+ if (File.Exists(file))
+ {
+ StreamReader csr = File.OpenText(file);
+ allexcuses = csr.ReadToEnd();
+ csr.Close();
+ }
+
+ return allexcuses.Split(Environment.NewLine.ToCharArray());
+ }
+ }
+}
diff --git a/OpenSim/Tools/pCampBot/PhysicsCamperBotREADME.txt b/OpenSim/Tools/pCampBot/PhysicsCamperBotREADME.txt
new file mode 100644
index 0000000..afa5fbd
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/PhysicsCamperBotREADME.txt
@@ -0,0 +1,36 @@
+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 the BOFH
+
+**Warning:** Using this bot on a public grid could get you banned perminantly, so just say No! to greifing!
+
+-----Setup -----
+Linux: chmod the .sh runprebuild file, run it. Then run nant like;
+
+nant -buildfile: pCampBot.build
+
+and pCampBot.exe will end up in the regular opensim/bin folder
+
+Windows:
+Run the prebuild bat IN THIS FOLDER and then open the created solution and compile it. the Exe file 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
+-------
+
+The bot also 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)
\ No newline at end of file
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs
new file mode 100644
index 0000000..704a3f5
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/pCampBot.cs
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) Contributors, http://opensimulator.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using libsecondlife;
+using libsecondlife.Packets;
+using Nini.Config;
+using System.Threading;
+using OpenSim.Framework.Console;
+
+namespace pCampBot
+{
+ ///
+ /// Event Types from the BOT. Add new events here
+ ///
+ public enum EventType:int
+ {
+ NONE = 0,
+ CONNECTED = 1,
+ DISCONNECTED = 2
+ }
+
+ public class pCampBot
+ {
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ //Set up our nifty config.. thanks to nini
+ ArgvConfigSource cs = new ArgvConfigSource(args);
+
+ cs.AddSwitch("Startup", "botcount");
+ cs.AddSwitch("Startup", "loginuri");
+ cs.AddSwitch("Startup", "firstname");
+ cs.AddSwitch("Startup", "lastname");
+ cs.AddSwitch("Startup", "password");
+
+ IConfig ol = cs.Configs["Startup"];
+ int botcount = ol.GetInt("botcount", 1);
+ BotManager bm = new BotManager();
+
+ //startup specified number of bots. 1 is the default
+ bm.dobotStartup(botcount, ol);
+ while (true)
+ {
+ MainConsole.Instance.Prompt();
+ }
+ }
+ }
+}
diff --git a/OpenSim/Tools/pCampBot/prebuild.xml b/OpenSim/Tools/pCampBot/prebuild.xml
new file mode 100644
index 0000000..bfaf408
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/prebuild.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+ TRACE;DEBUG
+ false
+ false
+ false
+ 4
+ false
+
+ ../../../bin
+ true
+ true
+ false
+
+
+
+
+ TRACE
+ true
+ false
+ false
+ 4
+ false
+
+ ../../../bin
+ false
+ true
+ false
+
+
+
+
+
+
+
+
+ ../../../bin/
+
+
+
+
+ ../../../bin/
+
+
+
+ ../../../bin/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OpenSim/Tools/pCampBot/runprebuild.bat b/OpenSim/Tools/pCampBot/runprebuild.bat
new file mode 100755
index 0000000..0427d2e
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/runprebuild.bat
@@ -0,0 +1,2 @@
+..\..\..\bin\Prebuild.exe /target nant
+..\..\..\bin\Prebuild.exe /target vs2005
diff --git a/OpenSim/Tools/pCampBot/runprebuild.sh b/OpenSim/Tools/pCampBot/runprebuild.sh
new file mode 100755
index 0000000..7215bc5
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/runprebuild.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+mono ../../../bin/Prebuild.exe /target nant
+mono ../../../bin/Prebuild.exe /target vs2005
diff --git a/pCampBot/BotManager.cs b/pCampBot/BotManager.cs
deleted file mode 100644
index 0c7fa4e..0000000
--- a/pCampBot/BotManager.cs
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
-* Copyright (c) Contributors, http://opensimulator.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.IO;
-using libsecondlife;
-using libsecondlife.Packets;
-using Nini.Config;
-using System.Threading;
-using OpenSim.Framework;
-using OpenSim.Framework.Console;
-
-namespace pCampBot
-{
- ///
- /// Thread/Bot manager for the application
- ///
- public class BotManager : conscmd_callback
- {
- private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
- protected ConsoleBase m_console;
- protected List m_lBot;
- protected Thread[] m_td;
- protected bool m_verbose = true;
- protected Random somthing = new Random(System.Environment.TickCount);
- protected int numbots = 0;
- protected IConfig Previous_config;
-
- ///
- /// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
- ///
- public BotManager()
- {
- m_console = CreateConsole();
- MainConsole.Instance = m_console;
- m_lBot = new List();
- }
-
- ///
- /// Startup number of bots specified in the starting arguments
- ///
- /// How many bots to start up
- /// The configuration for the bots to use
- public void dobotStartup(int botcount, IConfig cs)
- {
- Previous_config = cs;
- m_td = new Thread[botcount];
- for (int i = 0; i < botcount; i++)
- {
- startupBot(i, cs);
- }
- }
-
- ///
- /// 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);
- }
- }
-
- ///
- /// 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)
- {
- PhysicsBot pb = new PhysicsBot(cs);
-
- 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].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
- ///
- ///
- ///
- public void handlebotEvent(PhysicsBot callbot, EventType eventt)
- {
- switch (eventt)
- {
- case EventType.CONNECTED:
- m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected");
- numbots++;
- break;
- case EventType.DISCONNECTED:
- m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Disconnected");
- m_td[m_lBot.IndexOf(callbot)].Abort();
- numbots--;
- if (numbots >1)
- Environment.Exit(0);
- break;
- }
- }
-
- ///
- /// Shutting down all bots
- ///
- public void doBotShutdown()
- {
- foreach (PhysicsBot pb in m_lBot)
- {
- pb.shutdown();
- }
- }
-
- ///
- /// Standard CreateConsole routine
- ///
- ///
- protected ConsoleBase CreateConsole()
- {
- return new ConsoleBase("Region", this);
- }
-
- ///
- /// I don't think the bots use this..
- ///
- ///
- ///
- ///
- private string CombineParams(string[] commandParams, int pos)
- {
- string result = String.Empty;
- for (int i = pos; i < commandParams.Length; i++)
- {
- result += commandParams[i] + " ";
- }
- result = result.TrimEnd(' ');
- return result;
- }
-
- ///
- /// Command runnint tool.. Currently use it to add bots, shutdown and (dangerous)Forcequit
- ///
- ///
- ///
- public void RunCmd(string command, string[] cmdparams)
- {
- switch (command)
- {
- case "shutdown":
- m_console.Warn("BOTMANAGER", "Shutting down bots");
- doBotShutdown();
- break;
- case "quit":
- m_console.Warn("DANGER", "This should only be used to quit the program if you've already used the shutdown command and the program hasn't quit");
- Environment.Exit(0);
- break;
- case "addbots":
- int newbots = 0;
- Helpers.TryParse(cmdparams[0], out newbots);
-
- if (newbots > 0)
- addbots(newbots);
- break;
- case "help":
- m_console.Notice("HELP", "\nshutdown - graceful shutdown\naddbots - adds n bots to the test\nquit - forcequits, dangerous if you have not already run shutdown");
- break;
- }
- }
-
- ///
- /// Required method to implement the conscmd_callback interface
- ///
- ///
- public void Show(string ShowWhat)
- {
- }
- }
-}
diff --git a/pCampBot/PhysicsBot.cs b/pCampBot/PhysicsBot.cs
deleted file mode 100644
index 500683a..0000000
--- a/pCampBot/PhysicsBot.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-* Copyright (c) Contributors, http://opensimulator.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using libsecondlife;
-using libsecondlife.Packets;
-using Nini.Config;
-using System.Threading;
-using OpenSim.Framework;
-using OpenSim.Framework.Console;
-using Timer=System.Timers.Timer;
-
-namespace pCampBot
-{
- public class PhysicsBot
- {
- 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 event AnEvent OnConnected;
- public event AnEvent OnDisconnected;
-
- protected Timer m_action; // Action Timer
-
- protected Random somthing = new Random(System.Environment.TickCount);// We do stuff randomly here
-
- //New instance of a SecondLife client
- public SecondLife client = new SecondLife();
-
- protected string[] talkarray;
- ///
- ///
- ///
- /// nini config for the bot
- public PhysicsBot(IConfig bsconfig)
- {
- startupConfig = bsconfig;
- readconfig();
- talkarray = readexcuses();
- }
-
- //We do our actions here. This is where one would
- //add additional steps and/or things the bot should do
-
- void m_action_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
- {
- //client.Throttle.Task = 500000f;
- //client.Throttle.Set();
-
- client.Self.Movement.AlwaysRun = true;
- LLVector3 pos = client.Self.SimPosition;
- LLVector3 newpos = new LLVector3(somthing.Next(255),somthing.Next(255),somthing.Next(255));
-
-
- client.Self.Movement.TurnToward(newpos);
- for (int i = 0; i < 2000; i++)
- {
- client.Self.Movement.AtPos = true;
- }
- client.Self.Jump();
- string randomf = talkarray[somthing.Next(talkarray.Length)];
- if (talkarray.Length > 1 && randomf.Length > 1)
- client.Self.Chat("Can't do it, " + randomf, 0, ChatType.Normal);
-
- Thread.Sleep(somthing.Next(1,20));
-
- }
-
- ///
- /// Read the Nini config and initialize
- ///
- public void readconfig()
- {
- firstname = startupConfig.GetString("firstname", "random");
- lastname = startupConfig.GetString("lastname", "random");
- password = startupConfig.GetString("password", "12345");
- loginURI = startupConfig.GetString("loginuri", "http://10.1.1.5:9000");
-
-
-
- }
-
- ///
- /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes.
- ///
- public void shutdown()
- {
- client.Network.Logout();
- }
-
- ///
- /// This is the bot startup loop.
- ///
- public void startup()
- {
- client.Settings.LOGIN_SERVER = loginURI;
- client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected);
- client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected);
- client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected);
- if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name"))
- {
-
- if (OnConnected != null)
- {
- m_action = new Timer(somthing.Next(1000, 10000));
- m_action.Elapsed += new System.Timers.ElapsedEventHandler(m_action_Elapsed);
- m_action.Start();
- OnConnected(this, EventType.CONNECTED);
- client.Self.Jump();
-
- }
- }
- else
- {
- MainConsole.Instance.Error(firstname + " " + lastname, "Can't login: " + client.Network.LoginMessage);
- if (OnDisconnected != null)
- {
- OnDisconnected(this, EventType.DISCONNECTED);
- }
- }
- }
-
- public void Network_OnConnected(object sender)
- {
- if (OnConnected != null)
- {
- OnConnected(this, EventType.CONNECTED);
- }
- }
-
- public void Simulator_Connected(object sender)
- {
- }
-
- public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)
- {
- if (OnDisconnected != null)
- {
- OnDisconnected(this,EventType.DISCONNECTED);
- }
- }
-
- public string[] readexcuses()
- {
- string allexcuses = "";
-
- string file = Path.Combine(Util.configDir(), "excuses");
- if (File.Exists(file))
- {
- StreamReader csr = File.OpenText(file);
- allexcuses = csr.ReadToEnd();
- csr.Close();
- }
-
- return allexcuses.Split(Environment.NewLine.ToCharArray());
- }
- }
-}
diff --git a/pCampBot/PhysicsCamperBotREADME.txt b/pCampBot/PhysicsCamperBotREADME.txt
deleted file mode 100644
index afa5fbd..0000000
--- a/pCampBot/PhysicsCamperBotREADME.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-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 the BOFH
-
-**Warning:** Using this bot on a public grid could get you banned perminantly, so just say No! to greifing!
-
------Setup -----
-Linux: chmod the .sh runprebuild file, run it. Then run nant like;
-
-nant -buildfile: pCampBot.build
-
-and pCampBot.exe will end up in the regular opensim/bin folder
-
-Windows:
-Run the prebuild bat IN THIS FOLDER and then open the created solution and compile it. the Exe file 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
--------
-
-The bot also 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)
\ No newline at end of file
diff --git a/pCampBot/pCampBot.cs b/pCampBot/pCampBot.cs
deleted file mode 100644
index 704a3f5..0000000
--- a/pCampBot/pCampBot.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-* Copyright (c) Contributors, http://opensimulator.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using libsecondlife;
-using libsecondlife.Packets;
-using Nini.Config;
-using System.Threading;
-using OpenSim.Framework.Console;
-
-namespace pCampBot
-{
- ///
- /// Event Types from the BOT. Add new events here
- ///
- public enum EventType:int
- {
- NONE = 0,
- CONNECTED = 1,
- DISCONNECTED = 2
- }
-
- public class pCampBot
- {
- [STAThread]
- public static void Main(string[] args)
- {
- //Set up our nifty config.. thanks to nini
- ArgvConfigSource cs = new ArgvConfigSource(args);
-
- cs.AddSwitch("Startup", "botcount");
- cs.AddSwitch("Startup", "loginuri");
- cs.AddSwitch("Startup", "firstname");
- cs.AddSwitch("Startup", "lastname");
- cs.AddSwitch("Startup", "password");
-
- IConfig ol = cs.Configs["Startup"];
- int botcount = ol.GetInt("botcount", 1);
- BotManager bm = new BotManager();
-
- //startup specified number of bots. 1 is the default
- bm.dobotStartup(botcount, ol);
- while (true)
- {
- MainConsole.Instance.Prompt();
- }
- }
- }
-}
diff --git a/pCampBot/prebuild.xml b/pCampBot/prebuild.xml
deleted file mode 100644
index 1f49082..0000000
--- a/pCampBot/prebuild.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
- TRACE;DEBUG
- false
- false
- false
- 4
- false
-
- ../bin
- true
- true
- false
-
-
-
-
- TRACE
- true
- false
- false
- 4
- false
-
- ../bin
- false
- true
- false
-
-
-
-
-
-
-
-
- ../bin/
-
-
-
-
- ../bin/
-
-
-
- ../bin/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pCampBot/runprebuild.bat b/pCampBot/runprebuild.bat
deleted file mode 100755
index 05dfe16..0000000
--- a/pCampBot/runprebuild.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-..\bin\Prebuild.exe /target nant
-..\bin\Prebuild.exe /target vs2005
\ No newline at end of file
diff --git a/pCampBot/runprebuild.sh b/pCampBot/runprebuild.sh
deleted file mode 100755
index 23fbfef..0000000
--- a/pCampBot/runprebuild.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-mono ../bin/Prebuild.exe /target nant
-mono ../bin/Prebuild.exe /target vs2005
--
cgit v1.1