From 43e07efbc843ba1edd0c0369c50da331b5a1b2d6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 31 Oct 2011 22:27:12 +0000
Subject: Fix bot disconnection
---
OpenSim/Tools/pCampBot/PhysicsBot.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Tools/pCampBot')
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 1531b27..03c6f85 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -162,7 +162,7 @@ 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"))
--
cgit v1.1
From d366a08ebbc861a9db8ab27dd7f375a349d297ff Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 31 Oct 2011 22:52:49 +0000
Subject: Stop individual bots attempting to download the same asset more than
once
---
OpenSim/Tools/pCampBot/PhysicsBot.cs | 50 ++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 14 deletions(-)
(limited to 'OpenSim/Tools/pCampBot')
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 03c6f85..0344a82 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -56,6 +56,11 @@ namespace pCampBot
public event AnEvent OnConnected;
public event AnEvent OnDisconnected;
+ ///
+ /// Track the assets we have and have not received so we don't endlessly repeat requests.
+ ///
+ public Dictionary AssetsReceived { get; private set; }
+
protected Timer m_action; // Action Timer
protected List objectIDs = new List();
@@ -86,6 +91,8 @@ namespace pCampBot
startupConfig = bsconfig;
readconfig();
talkarray = readexcuses();
+
+ AssetsReceived = new Dictionary();
}
//We do our actions here. This is where one would
@@ -164,7 +171,7 @@ namespace pCampBot
client.Network.SimConnected += this.Network_SimConnected;
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 (OnConnected != null)
@@ -227,7 +234,7 @@ namespace pCampBot
{
if (asset.Decode())
{
- File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}",
+ File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}",
asset.AssetType.ToString().ToLower(),
asset.WearableType)), asset.AssetData);
}
@@ -393,40 +400,55 @@ namespace pCampBot
{
if (prim.Textures.DefaultTexture.TextureID != UUID.Zero)
{
- client.Assets.RequestImage(prim.Textures.DefaultTexture.TextureID, ImageType.Normal, Asset_TextureCallback_Texture);
+ GetTexture(prim.Textures.DefaultTexture.TextureID);
}
for (int i = 0; i < prim.Textures.FaceTextures.Length; i++)
{
- if (prim.Textures.FaceTextures[i] != null)
+ UUID textureID = prim.Textures.FaceTextures[i].TextureID;
+
+ if (textureID != null && textureID != UUID.Zero)
{
- if (prim.Textures.FaceTextures[i].TextureID != UUID.Zero)
- {
- client.Assets.RequestImage(prim.Textures.FaceTextures[i].TextureID, ImageType.Normal, Asset_TextureCallback_Texture);
- }
+ GetTexture(textureID);
}
}
}
if (prim.Sculpt.SculptTexture != UUID.Zero)
{
- client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture);
+ GetTexture(prim.Sculpt.SculptTexture);
}
}
}
+ private void GetTexture(UUID textureID)
+ {
+ lock (AssetsReceived)
+ {
+ // Don't request assets more than once.
+ if (AssetsReceived.ContainsKey(textureID))
+ return;
+
+ AssetsReceived[textureID] = false;
+ client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
+ }
+ }
+
public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture)
{
//TODO: Implement texture saving and applying
}
- public void Asset_ReceivedCallback(AssetDownload transfer,Asset asset)
+ public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
{
- if (wear == "save")
- {
- SaveAsset((AssetWearable) asset);
- }
+ lock (AssetsReceived)
+ AssetsReceived[asset.AssetID] = true;
+
+// if (wear == "save")
+// {
+// SaveAsset((AssetWearable) asset);
+// }
}
public string[] readexcuses()
--
cgit v1.1
From 210868a832439bb226dfcf153ca66563300dc2cf Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 31 Oct 2011 23:10:10 +0000
Subject: Remove OpenSim.TestSuite
Hasn't been touched since 2009 and wasn't more than another copy of pCampBot
---
OpenSim/Tools/pCampBot/BotManager.cs | 4 +++-
OpenSim/Tools/pCampBot/PhysicsBot.cs | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Tools/pCampBot')
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 0aaa226..a4b7f16 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -165,18 +165,20 @@ namespace pCampBot
///
///
///
- public void handlebotEvent(PhysicsBot callbot, EventType eventt)
+ private void handlebotEvent(PhysicsBot callbot, EventType eventt)
{
switch (eventt)
{
case EventType.CONNECTED:
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Connected");
numbots++;
+// m_log.InfoFormat("NUMBOTS {0}", numbots);
break;
case EventType.DISCONNECTED:
m_log.Info("[" + callbot.FirstName + " " + callbot.LastName + "]: Disconnected");
m_td[m_lBot.IndexOf(callbot)].Abort();
numbots--;
+// m_log.InfoFormat("NUMBOTS {0}", numbots);
if (numbots <= 0)
Environment.Exit(0);
break;
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 0344a82..0c399e3 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -29,19 +29,23 @@ using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
+using System.Reflection;
using System.Threading;
using System.Timers;
+using log4net;
using OpenMetaverse;
using OpenMetaverse.Assets;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
-using Timer=System.Timers.Timer;
+using Timer = System.Timers.Timer;
namespace pCampBot
{
public class PhysicsBot
{
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
public IConfig startupConfig; // bot config, passed from BotManager
@@ -384,6 +388,7 @@ namespace pCampBot
public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
{
+// m_log.ErrorFormat("Fired Network_OnDisconnected");
if (OnDisconnected != null)
{
OnDisconnected(this, EventType.DISCONNECTED);
--
cgit v1.1
From b951c7fb1e5a284a9bf95054cb168e64ebfe717d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 31 Oct 2011 23:22:55 +0000
Subject: Make bots share a cache so that asset downloads attempts are only
made once instead of once for each bot
---
OpenSim/Tools/pCampBot/BotManager.cs | 15 +++++++++++----
OpenSim/Tools/pCampBot/PhysicsBot.cs | 29 +++++++++++++----------------
2 files changed, 24 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Tools/pCampBot')
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index a4b7f16..03bb820 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -53,13 +53,20 @@ namespace pCampBot
protected bool m_verbose = true;
protected Random somthing = new Random(Environment.TickCount);
protected int numbots = 0;
- private IConfig Config;
+ public IConfig Config { get; private set; }
+
+ ///
+ /// Track the assets we have and have not received so we don't endlessly repeat requests.
+ ///
+ public Dictionary AssetsReceived { get; private set; }
///
/// Constructor Creates MainConsole.Instance to take commands and provide the place to write data
///
public BotManager()
{
+ AssetsReceived = new Dictionary();
+
m_console = CreateConsole();
MainConsole.Instance = m_console;
@@ -113,7 +120,7 @@ namespace pCampBot
for (int i = 0; i < botcount; i++)
{
string lastName = string.Format("{0}_{1}", lastNameStem, i);
- startupBot(i, cs, firstName, lastName, password, loginUri);
+ startupBot(i, this, firstName, lastName, password, loginUri);
}
}
@@ -146,9 +153,9 @@ namespace pCampBot
/// Last name
/// Password
/// Login URI
- public void startupBot(int pos, IConfig cs, string firstName, string lastName, string password, string loginUri)
+ public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri)
{
- PhysicsBot pb = new PhysicsBot(cs, firstName, lastName, password, loginUri);
+ PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri);
pb.OnConnected += handlebotEvent;
pb.OnDisconnected += handlebotEvent;
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 0c399e3..2070bfd 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -47,7 +47,9 @@ namespace pCampBot
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public delegate void AnEvent(PhysicsBot callbot, EventType someevent); // event delegate for bot events
- public IConfig startupConfig; // bot config, passed from BotManager
+
+ public BotManager BotManager { get; private set; }
+ private IConfig startupConfig; // bot config, passed from BotManager
public string FirstName { get; private set; }
public string LastName { get; private set; }
@@ -60,11 +62,6 @@ namespace pCampBot
public event AnEvent OnConnected;
public event AnEvent OnDisconnected;
- ///
- /// Track the assets we have and have not received so we don't endlessly repeat requests.
- ///
- public Dictionary AssetsReceived { get; private set; }
-
protected Timer m_action; // Action Timer
protected List objectIDs = new List();
@@ -80,23 +77,23 @@ namespace pCampBot
///
/// Constructor
///
- ///
+ ///
///
///
///
///
- public PhysicsBot(IConfig bsconfig, string firstName, string lastName, string password, string loginUri)
+ public PhysicsBot(BotManager bm, 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;
+
+ BotManager = bm;
+ startupConfig = bm.Config;
readconfig();
talkarray = readexcuses();
-
- AssetsReceived = new Dictionary();
}
//We do our actions here. This is where one would
@@ -428,13 +425,13 @@ namespace pCampBot
private void GetTexture(UUID textureID)
{
- lock (AssetsReceived)
+ lock (BotManager.AssetsReceived)
{
// Don't request assets more than once.
- if (AssetsReceived.ContainsKey(textureID))
+ if (BotManager.AssetsReceived.ContainsKey(textureID))
return;
- AssetsReceived[textureID] = false;
+ BotManager.AssetsReceived[textureID] = false;
client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture);
}
}
@@ -447,8 +444,8 @@ namespace pCampBot
public void Asset_ReceivedCallback(AssetDownload transfer, Asset asset)
{
- lock (AssetsReceived)
- AssetsReceived[asset.AssetID] = true;
+ lock (BotManager.AssetsReceived)
+ BotManager.AssetsReceived[asset.AssetID] = true;
// if (wear == "save")
// {
--
cgit v1.1