Merge branch 'master' into careminster
commit
e2dc04586a
|
@ -0,0 +1,139 @@
|
||||||
|
/*
|
||||||
|
* 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 OpenSimulator 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.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework.Console
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used to generated a formatted table for the console.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Currently subject to change. If you use this, be prepared to change your code when this class changes.
|
||||||
|
/// </remarks>
|
||||||
|
public class ConsoleTable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Default number of spaces between table columns.
|
||||||
|
/// </summary>
|
||||||
|
public const int DefaultTableSpacing = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Table columns.
|
||||||
|
/// </summary>
|
||||||
|
public List<ConsoleTableColumn> Columns { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Table rows
|
||||||
|
/// </summary>
|
||||||
|
public List<ConsoleTableRow> Rows { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of spaces to indent the table.
|
||||||
|
/// </summary>
|
||||||
|
public int Indent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Spacing between table columns
|
||||||
|
/// </summary>
|
||||||
|
public int TableSpacing { get; set; }
|
||||||
|
|
||||||
|
public ConsoleTable()
|
||||||
|
{
|
||||||
|
TableSpacing = DefaultTableSpacing;
|
||||||
|
Columns = new List<ConsoleTableColumn>();
|
||||||
|
Rows = new List<ConsoleTableRow>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
AddToStringBuilder(sb);
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddToStringBuilder(StringBuilder sb)
|
||||||
|
{
|
||||||
|
string formatString = GetFormatString();
|
||||||
|
// System.Console.WriteLine("FORMAT STRING [{0}]", formatString);
|
||||||
|
|
||||||
|
// columns
|
||||||
|
sb.AppendFormat(formatString, Columns.ConvertAll(c => c.Header).ToArray());
|
||||||
|
|
||||||
|
// rows
|
||||||
|
foreach (ConsoleTableRow row in Rows)
|
||||||
|
sb.AppendFormat(formatString, row.Cells.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the format string for the table.
|
||||||
|
/// </summary>
|
||||||
|
private string GetFormatString()
|
||||||
|
{
|
||||||
|
StringBuilder formatSb = new StringBuilder();
|
||||||
|
|
||||||
|
formatSb.Append(' ', Indent);
|
||||||
|
|
||||||
|
for (int i = 0; i < Columns.Count; i++)
|
||||||
|
{
|
||||||
|
formatSb.Append(' ', TableSpacing);
|
||||||
|
|
||||||
|
// Can only do left formatting for now
|
||||||
|
formatSb.AppendFormat("{{{0},-{1}}}", i, Columns[i].Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
formatSb.Append('\n');
|
||||||
|
|
||||||
|
return formatSb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ConsoleTableColumn
|
||||||
|
{
|
||||||
|
public string Header { get; set; }
|
||||||
|
public int Width { get; set; }
|
||||||
|
|
||||||
|
public ConsoleTableColumn(string header, int width) : this()
|
||||||
|
{
|
||||||
|
Header = header;
|
||||||
|
Width = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ConsoleTableRow
|
||||||
|
{
|
||||||
|
public List<string> Cells { get; private set; }
|
||||||
|
|
||||||
|
public ConsoleTableRow(List<string> cells) : this()
|
||||||
|
{
|
||||||
|
Cells = cells;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -724,6 +724,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
||||||
}
|
}
|
||||||
if (shouldTaint)
|
if (shouldTaint)
|
||||||
{
|
{
|
||||||
|
m_scene.EventManager.TriggerTerrainTainted();
|
||||||
m_tainted = true;
|
m_tainted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public event ClientMovement OnClientMovement;
|
public event ClientMovement OnClientMovement;
|
||||||
|
|
||||||
|
public delegate void OnTerrainTaintedDelegate();
|
||||||
|
|
||||||
|
public event OnTerrainTaintedDelegate OnTerrainTainted;
|
||||||
|
|
||||||
public delegate void OnTerrainTickDelegate();
|
public delegate void OnTerrainTickDelegate();
|
||||||
|
|
||||||
public delegate void OnTerrainUpdateDelegate();
|
public delegate void OnTerrainUpdateDelegate();
|
||||||
|
@ -938,6 +942,27 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TriggerTerrainTainted()
|
||||||
|
{
|
||||||
|
OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted;
|
||||||
|
if (handlerTerrainTainted != null)
|
||||||
|
{
|
||||||
|
foreach (OnTerrainTickDelegate d in handlerTerrainTainted.GetInvocationList())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
d();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat(
|
||||||
|
"[EVENT MANAGER]: Delegate for TriggerTerrainTainted failed - continuing. {0} {1}",
|
||||||
|
e.Message, e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
|
public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
|
||||||
{
|
{
|
||||||
OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd;
|
OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd;
|
||||||
|
|
|
@ -1403,6 +1403,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Apply taints in terrain module to terrain in physics scene
|
||||||
|
if (Frame % m_update_terrain == 0)
|
||||||
|
{
|
||||||
|
terMS = Util.EnvironmentTickCount();
|
||||||
|
UpdateTerrain();
|
||||||
|
terrainMS = Util.EnvironmentTickCountSubtract(terMS);
|
||||||
|
}
|
||||||
|
|
||||||
tmpPhysicsMS2 = Util.EnvironmentTickCount();
|
tmpPhysicsMS2 = Util.EnvironmentTickCount();
|
||||||
if ((Frame % m_update_physics == 0) && m_physics_enabled)
|
if ((Frame % m_update_physics == 0) && m_physics_enabled)
|
||||||
m_sceneGraph.UpdatePreparePhysics();
|
m_sceneGraph.UpdatePreparePhysics();
|
||||||
|
@ -1467,13 +1475,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
backupMS = Util.EnvironmentTickCountSubtract(backMS);
|
backupMS = Util.EnvironmentTickCountSubtract(backMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Frame % m_update_terrain == 0)
|
|
||||||
{
|
|
||||||
terMS = Util.EnvironmentTickCount();
|
|
||||||
UpdateTerrain();
|
|
||||||
terrainMS = Util.EnvironmentTickCountSubtract(terMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (Frame % m_update_land == 0)
|
//if (Frame % m_update_land == 0)
|
||||||
//{
|
//{
|
||||||
// int ldMS = Util.EnvironmentTickCount();
|
// int ldMS = Util.EnvironmentTickCount();
|
||||||
|
|
|
@ -0,0 +1,195 @@
|
||||||
|
/*
|
||||||
|
* 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 OpenSimulator 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.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using log4net;
|
||||||
|
using Mono.Addins;
|
||||||
|
using Nini.Config;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Framework.Statistics;
|
||||||
|
using OpenSim.Region.ClientStack.LindenUDP;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.OptionalModules.Avatar.Attachments
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A module that just holds commands for inspecting avatar appearance.
|
||||||
|
/// </summary>
|
||||||
|
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsCommandModule")]
|
||||||
|
public class AttachmentsCommandModule : ISharedRegionModule
|
||||||
|
{
|
||||||
|
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
private List<Scene> m_scenes = new List<Scene>();
|
||||||
|
// private IAvatarFactoryModule m_avatarFactory;
|
||||||
|
|
||||||
|
public string Name { get { return "Attachments Command Module"; } }
|
||||||
|
|
||||||
|
public Type ReplaceableInterface { get { return null; } }
|
||||||
|
|
||||||
|
public void Initialise(IConfigSource source)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: INITIALIZED MODULE");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PostInitialise()
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: POST INITIALIZED MODULE");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: CLOSED MODULE");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRegion(Scene scene)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveRegion(Scene scene)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
lock (m_scenes)
|
||||||
|
m_scenes.Remove(scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegionLoaded(Scene scene)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
lock (m_scenes)
|
||||||
|
m_scenes.Add(scene);
|
||||||
|
|
||||||
|
scene.AddCommand(
|
||||||
|
"Users", this, "attachments show",
|
||||||
|
"attachments show [<first-name> <last-name>]",
|
||||||
|
"Show attachment information for avatars in this simulator.",
|
||||||
|
HandleShowAttachmentsCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void HandleShowAttachmentsCommand(string module, string[] cmd)
|
||||||
|
{
|
||||||
|
if (cmd.Length != 2 && cmd.Length < 4)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.OutputFormat("Usage: attachments show [<first-name> <last-name>]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool targetNameSupplied = false;
|
||||||
|
string optionalTargetFirstName = null;
|
||||||
|
string optionalTargetLastName = null;
|
||||||
|
|
||||||
|
if (cmd.Length >= 4)
|
||||||
|
{
|
||||||
|
targetNameSupplied = true;
|
||||||
|
optionalTargetFirstName = cmd[2];
|
||||||
|
optionalTargetLastName = cmd[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
lock (m_scenes)
|
||||||
|
{
|
||||||
|
foreach (Scene scene in m_scenes)
|
||||||
|
{
|
||||||
|
if (targetNameSupplied)
|
||||||
|
{
|
||||||
|
ScenePresence sp = scene.GetScenePresence(optionalTargetFirstName, optionalTargetLastName);
|
||||||
|
if (sp != null && !sp.IsChildAgent)
|
||||||
|
GetAttachmentsReport(sp, sb);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scene.ForEachRootScenePresence(sp => GetAttachmentsReport(sp, sb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MainConsole.Instance.Output(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb)
|
||||||
|
{
|
||||||
|
sb.AppendFormat("Attachments for {0}\n", sp.Name);
|
||||||
|
|
||||||
|
ConsoleTable ct = new ConsoleTable() { Indent = 2 };
|
||||||
|
ct.Columns.Add(new ConsoleTableColumn("Attachment Name", 36));
|
||||||
|
ct.Columns.Add(new ConsoleTableColumn("Local ID", 10));
|
||||||
|
ct.Columns.Add(new ConsoleTableColumn("Item ID", 36));
|
||||||
|
ct.Columns.Add(new ConsoleTableColumn("Attach Point", 14));
|
||||||
|
ct.Columns.Add(new ConsoleTableColumn("Position", 15));
|
||||||
|
|
||||||
|
// sb.AppendFormat(
|
||||||
|
// " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n",
|
||||||
|
// "Attachment Name", "Local ID", "Item ID", "Attach Point", "Position");
|
||||||
|
|
||||||
|
List<SceneObjectGroup> attachmentObjects = sp.GetAttachments();
|
||||||
|
foreach (SceneObjectGroup attachmentObject in attachmentObjects)
|
||||||
|
{
|
||||||
|
// InventoryItemBase attachmentItem
|
||||||
|
// = m_scenes[0].InventoryService.GetItem(new InventoryItemBase(attachmentObject.FromItemID));
|
||||||
|
|
||||||
|
// if (attachmentItem == null)
|
||||||
|
// {
|
||||||
|
// sb.AppendFormat(
|
||||||
|
// "WARNING: Couldn't find attachment for item {0} at point {1}\n",
|
||||||
|
// attachmentData.ItemID, (AttachmentPoint)attachmentData.AttachPoint);
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// sb.AppendFormat(
|
||||||
|
// " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n",
|
||||||
|
// attachmentObject.Name, attachmentObject.LocalId, attachmentObject.FromItemID,
|
||||||
|
// (AttachmentPoint)attachmentObject.AttachmentPoint, attachmentObject.RootPart.AttachedPos);
|
||||||
|
ct.Rows.Add(
|
||||||
|
new ConsoleTableRow(
|
||||||
|
new List<string>()
|
||||||
|
{
|
||||||
|
attachmentObject.Name,
|
||||||
|
attachmentObject.LocalId.ToString(),
|
||||||
|
attachmentObject.FromItemID.ToString(),
|
||||||
|
((AttachmentPoint)attachmentObject.AttachmentPoint).ToString(),
|
||||||
|
attachmentObject.RootPart.AttachedPos.ToString()
|
||||||
|
}));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
ct.AddToStringBuilder(sb);
|
||||||
|
sb.Append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -66,7 +66,7 @@ namespace OpenSim.Tests.Common
|
||||||
private AgentCircuitManager m_acm = new AgentCircuitManager();
|
private AgentCircuitManager m_acm = new AgentCircuitManager();
|
||||||
private ISimulationDataService m_simDataService
|
private ISimulationDataService m_simDataService
|
||||||
= OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
|
= OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
|
||||||
private IEstateDataService m_estateDataService;
|
private IEstateDataService m_estateDataService = null;
|
||||||
|
|
||||||
private LocalAssetServicesConnector m_assetService;
|
private LocalAssetServicesConnector m_assetService;
|
||||||
private LocalAuthenticationServicesConnector m_authenticationService;
|
private LocalAuthenticationServicesConnector m_authenticationService;
|
||||||
|
|
|
@ -43,6 +43,14 @@ using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
namespace pCampBot
|
namespace pCampBot
|
||||||
{
|
{
|
||||||
|
public enum ConnectionState
|
||||||
|
{
|
||||||
|
Disconnected,
|
||||||
|
Connecting,
|
||||||
|
Connected,
|
||||||
|
Disconnecting
|
||||||
|
}
|
||||||
|
|
||||||
public class Bot
|
public class Bot
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
@ -86,7 +94,7 @@ namespace pCampBot
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is this bot connected to the grid?
|
/// Is this bot connected to the grid?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsConnected { get; private set; }
|
public ConnectionState ConnectionState { get; private set; }
|
||||||
|
|
||||||
public string FirstName { get; private set; }
|
public string FirstName { get; private set; }
|
||||||
public string LastName { get; private set; }
|
public string LastName { get; private set; }
|
||||||
|
@ -130,6 +138,8 @@ namespace pCampBot
|
||||||
BotManager bm, List<IBehaviour> behaviours,
|
BotManager bm, List<IBehaviour> behaviours,
|
||||||
string firstName, string lastName, string password, string loginUri)
|
string firstName, string lastName, string password, string loginUri)
|
||||||
{
|
{
|
||||||
|
ConnectionState = ConnectionState.Disconnected;
|
||||||
|
|
||||||
behaviours.ForEach(b => b.Initialize(this));
|
behaviours.ForEach(b => b.Initialize(this));
|
||||||
|
|
||||||
Client = new GridClient();
|
Client = new GridClient();
|
||||||
|
@ -157,10 +167,10 @@ namespace pCampBot
|
||||||
Behaviours.ForEach(
|
Behaviours.ForEach(
|
||||||
b =>
|
b =>
|
||||||
{
|
{
|
||||||
|
Thread.Sleep(Random.Next(3000, 10000));
|
||||||
|
|
||||||
// m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType());
|
// m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType());
|
||||||
b.Action();
|
b.Action();
|
||||||
|
|
||||||
Thread.Sleep(Random.Next(1000, 10000));
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -178,6 +188,8 @@ namespace pCampBot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void shutdown()
|
public void shutdown()
|
||||||
{
|
{
|
||||||
|
ConnectionState = ConnectionState.Disconnecting;
|
||||||
|
|
||||||
if (m_actionThread != null)
|
if (m_actionThread != null)
|
||||||
m_actionThread.Abort();
|
m_actionThread.Abort();
|
||||||
|
|
||||||
|
@ -209,9 +221,11 @@ namespace pCampBot
|
||||||
Client.Network.Disconnected += this.Network_OnDisconnected;
|
Client.Network.Disconnected += this.Network_OnDisconnected;
|
||||||
Client.Objects.ObjectUpdate += Objects_NewPrim;
|
Client.Objects.ObjectUpdate += Objects_NewPrim;
|
||||||
|
|
||||||
|
ConnectionState = ConnectionState.Connecting;
|
||||||
|
|
||||||
if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
|
if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name"))
|
||||||
{
|
{
|
||||||
IsConnected = true;
|
ConnectionState = ConnectionState.Connected;
|
||||||
|
|
||||||
Thread.Sleep(Random.Next(1000, 10000));
|
Thread.Sleep(Random.Next(1000, 10000));
|
||||||
m_actionThread = new Thread(Action);
|
m_actionThread = new Thread(Action);
|
||||||
|
@ -241,6 +255,8 @@ namespace pCampBot
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ConnectionState = ConnectionState.Disconnected;
|
||||||
|
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage);
|
"{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage);
|
||||||
|
|
||||||
|
@ -439,6 +455,8 @@ namespace pCampBot
|
||||||
|
|
||||||
public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
|
public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
|
||||||
{
|
{
|
||||||
|
ConnectionState = ConnectionState.Disconnected;
|
||||||
|
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[BOT]: Bot {0} disconnected reason {1}, message {2}", Name, args.Reason, args.Message);
|
"[BOT]: Bot {0} disconnected reason {1}, message {2}", Name, args.Reason, args.Message);
|
||||||
|
|
||||||
|
@ -456,7 +474,6 @@ namespace pCampBot
|
||||||
&& OnDisconnected != null)
|
&& OnDisconnected != null)
|
||||||
// if (OnDisconnected != null)
|
// if (OnDisconnected != null)
|
||||||
{
|
{
|
||||||
IsConnected = false;
|
|
||||||
OnDisconnected(this, EventType.DISCONNECTED);
|
OnDisconnected(this, EventType.DISCONNECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,14 @@ namespace pCampBot
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
public const int DefaultLoginDelay = 5000;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delay between logins of multiple bots.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>TODO: This value needs to be configurable by a command line argument.</remarks>
|
||||||
|
public int LoginDelay { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command console
|
/// Command console
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -84,6 +92,8 @@ namespace pCampBot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BotManager()
|
public BotManager()
|
||||||
{
|
{
|
||||||
|
LoginDelay = DefaultLoginDelay;
|
||||||
|
|
||||||
Rng = new Random(Environment.TickCount);
|
Rng = new Random(Environment.TickCount);
|
||||||
AssetsReceived = new Dictionary<UUID, bool>();
|
AssetsReceived = new Dictionary<UUID, bool>();
|
||||||
RegionsKnown = new Dictionary<ulong, GridRegion>();
|
RegionsKnown = new Dictionary<ulong, GridRegion>();
|
||||||
|
@ -151,10 +161,20 @@ namespace pCampBot
|
||||||
Array.ForEach<string>(
|
Array.ForEach<string>(
|
||||||
cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
|
cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
|
||||||
|
|
||||||
|
MainConsole.Instance.OutputFormat(
|
||||||
|
"[BOT MANAGER]: Starting {0} bots connecting to {1}, named {2} {3}_<n>",
|
||||||
|
botcount,
|
||||||
|
loginUri,
|
||||||
|
firstName,
|
||||||
|
lastNameStem);
|
||||||
|
|
||||||
|
MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay);
|
||||||
|
|
||||||
for (int i = 0; i < botcount; i++)
|
for (int i = 0; i < botcount; i++)
|
||||||
{
|
{
|
||||||
string lastName = string.Format("{0}_{1}", lastNameStem, i);
|
string lastName = string.Format("{0}_{1}", lastNameStem, i);
|
||||||
|
|
||||||
|
// We must give each bot its own list of instantiated behaviours since they store state.
|
||||||
List<IBehaviour> behaviours = new List<IBehaviour>();
|
List<IBehaviour> behaviours = new List<IBehaviour>();
|
||||||
|
|
||||||
// Hard-coded for now
|
// Hard-coded for now
|
||||||
|
@ -170,10 +190,6 @@ namespace pCampBot
|
||||||
if (behaviourSwitches.Contains("c"))
|
if (behaviourSwitches.Contains("c"))
|
||||||
behaviours.Add(new CrossBehaviour());
|
behaviours.Add(new CrossBehaviour());
|
||||||
|
|
||||||
MainConsole.Instance.OutputFormat(
|
|
||||||
"[BOT MANAGER]: Bot {0} {1} configured for behaviours {2}",
|
|
||||||
firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
|
|
||||||
|
|
||||||
StartBot(this, behaviours, firstName, lastName, password, loginUri);
|
StartBot(this, behaviours, firstName, lastName, password, loginUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,6 +227,10 @@ namespace pCampBot
|
||||||
BotManager bm, List<IBehaviour> behaviours,
|
BotManager bm, List<IBehaviour> behaviours,
|
||||||
string firstName, string lastName, string password, string loginUri)
|
string firstName, string lastName, string password, string loginUri)
|
||||||
{
|
{
|
||||||
|
MainConsole.Instance.OutputFormat(
|
||||||
|
"[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
|
||||||
|
firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
|
||||||
|
|
||||||
Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
|
Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
|
||||||
|
|
||||||
pb.OnConnected += handlebotEvent;
|
pb.OnConnected += handlebotEvent;
|
||||||
|
@ -222,7 +242,11 @@ namespace pCampBot
|
||||||
Thread pbThread = new Thread(pb.startup);
|
Thread pbThread = new Thread(pb.startup);
|
||||||
pbThread.Name = pb.Name;
|
pbThread.Name = pb.Name;
|
||||||
pbThread.IsBackground = true;
|
pbThread.IsBackground = true;
|
||||||
|
|
||||||
pbThread.Start();
|
pbThread.Start();
|
||||||
|
|
||||||
|
// Stagger logins
|
||||||
|
Thread.Sleep(LoginDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -242,7 +266,7 @@ namespace pCampBot
|
||||||
|
|
||||||
lock (m_lBot)
|
lock (m_lBot)
|
||||||
{
|
{
|
||||||
if (m_lBot.TrueForAll(b => !b.IsConnected))
|
if (m_lBot.TrueForAll(b => b.ConnectionState == ConnectionState.Disconnected))
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -251,13 +275,21 @@ namespace pCampBot
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shutting down all bots
|
/// Shut down all bots
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// We launch each shutdown on its own thread so that a slow shutting down bot doesn't hold up all the others.
|
||||||
|
/// </remarks>
|
||||||
public void doBotShutdown()
|
public void doBotShutdown()
|
||||||
{
|
{
|
||||||
lock (m_lBot)
|
lock (m_lBot)
|
||||||
foreach (Bot pb in m_lBot)
|
{
|
||||||
pb.shutdown();
|
foreach (Bot bot in m_lBot)
|
||||||
|
{
|
||||||
|
Bot thisBot = bot;
|
||||||
|
Util.FireAndForget(o => thisBot.shutdown());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -271,11 +303,8 @@ namespace pCampBot
|
||||||
|
|
||||||
private void HandleShutdown(string module, string[] cmd)
|
private void HandleShutdown(string module, string[] cmd)
|
||||||
{
|
{
|
||||||
Util.FireAndForget(o =>
|
m_log.Info("[BOTMANAGER]: Shutting down bots");
|
||||||
{
|
|
||||||
m_log.Warn("[BOTMANAGER]: Shutting down bots");
|
|
||||||
doBotShutdown();
|
doBotShutdown();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleShowRegions(string module, string[] cmd)
|
private void HandleShowRegions(string module, string[] cmd)
|
||||||
|
@ -302,9 +331,11 @@ namespace pCampBot
|
||||||
{
|
{
|
||||||
foreach (Bot pb in m_lBot)
|
foreach (Bot pb in m_lBot)
|
||||||
{
|
{
|
||||||
|
Simulator currentSim = pb.Client.Network.CurrentSim;
|
||||||
|
|
||||||
MainConsole.Instance.OutputFormat(
|
MainConsole.Instance.OutputFormat(
|
||||||
outputFormat,
|
outputFormat,
|
||||||
pb.Name, pb.Client.Network.CurrentSim.Name, pb.IsConnected ? "Connected" : "Disconnected");
|
pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -67,7 +68,9 @@ namespace pCampBot
|
||||||
BotManager bm = new BotManager();
|
BotManager bm = new BotManager();
|
||||||
|
|
||||||
//startup specified number of bots. 1 is the default
|
//startup specified number of bots. 1 is the default
|
||||||
bm.dobotStartup(botcount, config);
|
Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, config));
|
||||||
|
startBotThread.Name = "Initial start bots thread";
|
||||||
|
startBotThread.Start();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue