From e813f41478eefb50748e9bdc2b825fa8bc25c971 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 9 May 2012 20:52:54 +0100 Subject: [PATCH 01/15] Escape and unescape xml element names if necessary in ServerUtils.BuildXmlData() and ParseElement() If AvatarService appearance data is retrieved over the network, then ServerUtils was attempting to transfer names such as "Wearable 0:0" directly to xml element names, resulting in an exception. Space is not valid in xml element names. Neither is : in this case since the intention is not to namespace. Using names directly as keys is not a good idea. To get around this problem this patch escapes and unescapes the element names as appropriate. This has no impact on existing xml (since it had to be valid in the first place) but allows AvatarService data to be used over the network. Setting appearance (from simulator to AvatarService) did not suffer this problem since the values are passed in the query string which is already properly escaped. --- OpenSim/Server/Base/ServerUtils.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 0cc2a4b57f..42c82cf34c 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -268,7 +268,7 @@ namespace OpenSim.Server.Base continue; XmlElement elem = parent.OwnerDocument.CreateElement("", - kvp.Key, ""); + XmlConvert.EncodeLocalName(kvp.Key), ""); if (kvp.Value is Dictionary) { @@ -323,11 +323,11 @@ namespace OpenSim.Server.Base XmlNode type = part.Attributes.GetNamedItem("type"); if (type == null || type.Value != "List") { - ret[part.Name] = part.InnerText; + ret[XmlConvert.DecodeName(part.Name)] = part.InnerText; } else { - ret[part.Name] = ParseElement(part); + ret[XmlConvert.DecodeName(part.Name)] = ParseElement(part); } } From 6987aef38dbc4f5c24b6e2cc73601f9a7c5f4431 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 9 May 2012 23:12:30 +0100 Subject: [PATCH 02/15] Improve logging on the prim inventory script asset request path for future use. This adds name and description of the request handler to http request logging when DebugLevel >= 1 --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 4 ++-- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 +- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 13 ++++++++----- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index d0463c8121..401dfd3e26 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -447,8 +447,8 @@ namespace OpenSim.Framework.Servers.HttpServer { if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found stream handler for {0} {1}", - request.HttpMethod, request.Url.PathAndQuery); + "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", + request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. byte[] buffer = null; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 9791885ffa..6c28e78f20 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -309,7 +309,7 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( - "POST", capsBase + uploaderPath, uploader.uploaderCaps, "BunchOfCaps", null)); + "POST", capsBase + uploaderPath, uploader.uploaderCaps, "TaskInventoryScriptUpdater", null)); string protocol = "http://"; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index ae5cbfff55..4d6081c447 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -11955,21 +11955,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) { UUID requestID = UUID.Zero; - if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) + int sourceType = transferRequest.TransferInfo.SourceType; + + if (sourceType == (int)SourceType.Asset) { requestID = new UUID(transferRequest.TransferInfo.Params, 0); } - else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) + else if (sourceType == (int)SourceType.SimInventoryItem) { requestID = new UUID(transferRequest.TransferInfo.Params, 80); } - else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimEstate) + else if (sourceType == (int)SourceType.SimEstate) { requestID = taskID; } - -// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); +// m_log.DebugFormat( +// "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}", +// requestID, taskID, (SourceType)sourceType, Name); m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 816d3b64ce..8a26df1dc2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -300,6 +300,10 @@ namespace OpenSim.Region.Framework.Scenes AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); AssetService.Store(asset); +// m_log.DebugFormat( +// "[PRIM INVENTORY]: Stored asset {0} when updating item {1} in prim {2} for {3}", +// asset.ID, item.Name, part.Name, remoteClient.Name); + if (isScriptRunning) { part.Inventory.RemoveScriptInstance(item.ItemID, false); From d8a78374aa11c5460d6e58a6f4110fca61dfded4 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 9 May 2012 23:25:01 +0100 Subject: [PATCH 03/15] Where necessary, rename OpenSim/Services/Connectors/*.cs files to reflect the actual class names. This is usually because the file name was singular (*Service*) but the class name was plural (*Services*). This is to make configuration easier rather than having to look in the c# code itself to find the slightly different name of the connector. This does not affect existing configuration since the files are being renamed rather than the classes. --- .../Asset/{AssetServiceConnector.cs => AssetServicesConnector.cs} | 0 ...tionServiceConnector.cs => AuthenticationServicesConnector.cs} | 0 ...ationServiceConnector.cs => AuthorizationServicesConnector.cs} | 0 .../{AvatarServiceConnector.cs => AvatarServicesConnector.cs} | 0 .../{FriendsServiceConnector.cs => FriendsServicesConnector.cs} | 0 .../Grid/{GridServiceConnector.cs => GridServicesConnector.cs} | 0 .../{GridUserServiceConnector.cs => GridUserServicesConnector.cs} | 0 ...HGFriendsServiceConnector.cs => HGFriendsServicesConnector.cs} | 0 .../{HeloServiceConnector.cs => HeloServicesConnector.cs} | 0 .../{XInventoryConnector.cs => XInventoryServicesConnector.cs} | 0 .../Land/{LandServiceConnector.cs => LandServicesConnector.cs} | 0 .../{MapImageServiceConnector.cs => MapImageServicesConnector.cs} | 0 ...NeighbourServiceConnector.cs => NeighbourServicesConnector.cs} | 0 .../{PresenceServiceConnector.cs => PresenceServicesConnector.cs} | 0 ...AccountServiceConnector.cs => UserAccountServicesConnector.cs} | 0 15 files changed, 0 insertions(+), 0 deletions(-) rename OpenSim/Services/Connectors/Asset/{AssetServiceConnector.cs => AssetServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Authentication/{AuthenticationServiceConnector.cs => AuthenticationServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Authorization/{AuthorizationServiceConnector.cs => AuthorizationServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Avatar/{AvatarServiceConnector.cs => AvatarServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Friends/{FriendsServiceConnector.cs => FriendsServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Grid/{GridServiceConnector.cs => GridServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/GridUser/{GridUserServiceConnector.cs => GridUserServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Hypergrid/{HGFriendsServiceConnector.cs => HGFriendsServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Hypergrid/{HeloServiceConnector.cs => HeloServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Inventory/{XInventoryConnector.cs => XInventoryServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Land/{LandServiceConnector.cs => LandServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/MapImage/{MapImageServiceConnector.cs => MapImageServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Neighbour/{NeighbourServiceConnector.cs => NeighbourServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/Presence/{PresenceServiceConnector.cs => PresenceServicesConnector.cs} (100%) rename OpenSim/Services/Connectors/UserAccounts/{UserAccountServiceConnector.cs => UserAccountServicesConnector.cs} (100%) diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs rename to OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs rename to OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs rename to OpenSim/Services/Connectors/Authorization/AuthorizationServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs rename to OpenSim/Services/Connectors/Avatar/AvatarServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs rename to OpenSim/Services/Connectors/Friends/FriendsServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Grid/GridServiceConnector.cs rename to OpenSim/Services/Connectors/Grid/GridServicesConnector.cs diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs rename to OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs rename to OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Hypergrid/HeloServiceConnector.cs rename to OpenSim/Services/Connectors/Hypergrid/HeloServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs rename to OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Land/LandServiceConnector.cs rename to OpenSim/Services/Connectors/Land/LandServicesConnector.cs diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs rename to OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs rename to OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs rename to OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs similarity index 100% rename from OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs rename to OpenSim/Services/Connectors/UserAccounts/UserAccountServicesConnector.cs From de44734fe9a0b31cd8cb78c0f58e61a35fe2a259 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Thu, 10 May 2012 09:08:40 -0700 Subject: [PATCH 04/15] Saving estate state is really slow (relatively) and it gets completely rewritten every time a region starts up. This makes the data write only when the data was not already read from the database. There is a still a major race condition whenever two regions share the same estate data, but at least it won't be triggered on startup. --- .../LoadRegions/LoadRegionsPlugin.cs | 5 +++-- OpenSim/Region/Application/OpenSim.cs | 5 +++-- OpenSim/Region/Application/OpenSimBase.cs | 12 +++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 45b8d6f4b9..00657028e4 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -122,9 +122,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions Thread.CurrentThread.ManagedThreadId.ToString() + ")"); - m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]); + bool changed = m_openSim.PopulateRegionEstateInfo(regionsToLoad[i]); m_openSim.CreateRegion(regionsToLoad[i], true, out scene); - regionsToLoad[i].EstateSettings.Save(); + if (changed) + regionsToLoad[i].EstateSettings.Save(); if (scene != null) { diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 4ec64eeb55..6796f2bd33 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -618,10 +618,11 @@ namespace OpenSim return; } - PopulateRegionEstateInfo(regInfo); + bool changed = PopulateRegionEstateInfo(regInfo); IScene scene; CreateRegion(regInfo, true, out scene); - regInfo.EstateSettings.Save(); + if (changed) + regInfo.EstateSettings.Save(); } /// diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 79259d8b3c..045e8d2f4a 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -977,13 +977,13 @@ namespace OpenSim /// Load the estate information for the provided RegionInfo object. /// /// - public void PopulateRegionEstateInfo(RegionInfo regInfo) + public bool PopulateRegionEstateInfo(RegionInfo regInfo) { if (EstateDataService != null) regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false); if (regInfo.EstateSettings.EstateID != 0) - return; + return false; // estate info in the database did not change m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); @@ -1018,7 +1018,7 @@ namespace OpenSim } if (defaultEstateJoined) - return; + return true; // need to update the database else m_log.ErrorFormat( "[OPENSIM BASE]: Joining default estate {0} failed", defaultEstateName); @@ -1080,8 +1080,10 @@ namespace OpenSim MainConsole.Instance.Output("Joining the estate failed. Please try again."); } } - } - } + } + + return true; // need to update the database + } } public class OpenSimConfigSource From f374b63ac8a2f75b59b2c0442ab8000f76466f70 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 10 May 2012 14:42:46 -0700 Subject: [PATCH 05/15] Add even for terrain tainting and synchronize terrain module with physics scene before physics simulation step rather than after --- .../World/Terrain/TerrainModule.cs | 1 + .../Region/Framework/Scenes/EventManager.cs | 25 +++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 15 +++++------ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 8535a5aceb..2eac0faa9c 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -722,6 +722,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain } if (shouldTaint) { + m_scene.EventManager.TriggerTerrainTainted(); m_tainted = true; } } diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index ace83135d8..f97b0a9a19 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -53,6 +53,10 @@ namespace OpenSim.Region.Framework.Scenes public event ClientMovement OnClientMovement; + public delegate void OnTerrainTaintedDelegate(); + + public event OnTerrainTaintedDelegate OnTerrainTainted; + public delegate void OnTerrainTickDelegate(); public event OnTerrainTickDelegate OnTerrainTick; @@ -914,6 +918,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) { OnParcelPrimCountAddDelegate handlerParcelPrimCountAdd = OnParcelPrimCountAdd; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4d0aa6f32c..3d2213a9cc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1353,6 +1353,14 @@ namespace OpenSim.Region.Framework.Scenes 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(); if ((Frame % m_update_physics == 0) && m_physics_enabled) m_sceneGraph.UpdatePreparePhysics(); @@ -1417,13 +1425,6 @@ namespace OpenSim.Region.Framework.Scenes backupMS = Util.EnvironmentTickCountSubtract(backMS); } - if (Frame % m_update_terrain == 0) - { - terMS = Util.EnvironmentTickCount(); - UpdateTerrain(); - terrainMS = Util.EnvironmentTickCountSubtract(terMS); - } - //if (Frame % m_update_land == 0) //{ // int ldMS = Util.EnvironmentTickCount(); From bce3e7cb06611db887ee50c793d72674ad326ba7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 10 May 2012 22:48:03 +0100 Subject: [PATCH 06/15] Add "attachments" show console command that will show the server's record of which attachments an in-scene avatar has. For debugging purposes. --- .../Attachments/AttachmentsCommandModule.cs | 177 ++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs new file mode 100644 index 0000000000..ce23613d7e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs @@ -0,0 +1,177 @@ +/* + * 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 +{ + /// + /// A module that just holds commands for inspecting avatar appearance. + /// + [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 m_scenes = new List(); +// 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 [ ]", + "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 [ ]"); + 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); + + sb.AppendFormat( + " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n", + "Attachment Name", "Local ID", "Item ID", "Attach Point", "Position"); + + List 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); +// } + } + + sb.Append("\n"); + } + } +} \ No newline at end of file From 903cff9264ce405d00eab2739fcfb461749b4772 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 10 May 2012 23:47:39 +0100 Subject: [PATCH 07/15] Add ConsoleTable framework class for future uniform formatting of console output tables. Still subject to change - if you use this be prepared to change your output code if/when the methods change. Make new "attachments show" command use this. --- OpenSim/Framework/Console/ConsoleTable.cs | 139 ++++++++++++++++++ .../Attachments/AttachmentsCommandModule.cs | 34 ++++- 2 files changed, 165 insertions(+), 8 deletions(-) create mode 100644 OpenSim/Framework/Console/ConsoleTable.cs diff --git a/OpenSim/Framework/Console/ConsoleTable.cs b/OpenSim/Framework/Console/ConsoleTable.cs new file mode 100644 index 0000000000..be3025be7f --- /dev/null +++ b/OpenSim/Framework/Console/ConsoleTable.cs @@ -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 +{ + /// + /// Used to generated a formatted table for the console. + /// + /// + /// Currently subject to change. If you use this, be prepared to change your code when this class changes. + /// + public class ConsoleTable + { + /// + /// Default number of spaces between table columns. + /// + public const int DefaultTableSpacing = 2; + + /// + /// Table columns. + /// + public List Columns { get; private set; } + + /// + /// Table rows + /// + public List Rows { get; private set; } + + /// + /// Number of spaces to indent the table. + /// + public int Indent { get; set; } + + /// + /// Spacing between table columns + /// + public int TableSpacing { get; set; } + + public ConsoleTable() + { + TableSpacing = DefaultTableSpacing; + Columns = new List(); + Rows = new List(); + } + + 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()); + } + + /// + /// Gets the format string for the table. + /// + 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 Cells { get; private set; } + + public ConsoleTableRow(List cells) : this() + { + Cells = cells; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs index ce23613d7e..a95514c642 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs @@ -53,7 +53,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments private List m_scenes = new List(); // private IAvatarFactoryModule m_avatarFactory; - + public string Name { get { return "Attachments Command Module"; } } public Type ReplaceableInterface { get { return null; } } @@ -145,9 +145,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments { sb.AppendFormat("Attachments for {0}\n", sp.Name); - sb.AppendFormat( - " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n", - "Attachment Name", "Local ID", "Item ID", "Attach Point", "Position"); + 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 attachmentObjects = sp.GetAttachments(); foreach (SceneObjectGroup attachmentObject in attachmentObjects) @@ -164,13 +171,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments // } // 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); +// 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() + { + attachmentObject.Name, + attachmentObject.LocalId.ToString(), + attachmentObject.FromItemID.ToString(), + ((AttachmentPoint)attachmentObject.AttachmentPoint).ToString(), + attachmentObject.RootPart.AttachedPos.ToString() + })); // } } + ct.AddToStringBuilder(sb); sb.Append("\n"); } } From ab4e6a02a52bfd473ea3c2050774103ec8eb3934 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 May 2012 00:37:20 +0100 Subject: [PATCH 08/15] If a bot is not connected, show region name "(none)" instead of throwing an exception in the "show bots" command of pCampbot --- OpenSim/Tools/pCampBot/BotManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 0f501b788b..fd32a6aa6e 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -302,9 +302,11 @@ namespace pCampBot { foreach (Bot pb in m_lBot) { + Simulator currentSim = pb.Client.Network.CurrentSim; + MainConsole.Instance.OutputFormat( outputFormat, - pb.Name, pb.Client.Network.CurrentSim.Name, pb.IsConnected ? "Connected" : "Disconnected"); + pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.IsConnected ? "Connected" : "Disconnected"); } } } From dc39ec82fa8343657ad9b45a7d9cfeb27bf26e79 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 May 2012 00:53:21 +0100 Subject: [PATCH 09/15] Change bot.IsConnected to be ConnectionState with Disconnected, Connecting, Connnected and Disconnecting states --- OpenSim/Tools/pCampBot/Bot.cs | 23 ++++++++++++++++++++--- OpenSim/Tools/pCampBot/BotManager.cs | 4 ++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index da090dda64..2b4a171f5a 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -43,6 +43,14 @@ using Timer = System.Timers.Timer; namespace pCampBot { + public enum ConnectionState + { + Disconnected, + Connecting, + Connected, + Disconnecting + } + public class Bot { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -86,7 +94,7 @@ namespace pCampBot /// /// Is this bot connected to the grid? /// - public bool IsConnected { get; private set; } + public ConnectionState ConnectionState { get; private set; } public string FirstName { get; private set; } public string LastName { get; private set; } @@ -130,6 +138,8 @@ namespace pCampBot BotManager bm, List behaviours, string firstName, string lastName, string password, string loginUri) { + ConnectionState = ConnectionState.Disconnected; + behaviours.ForEach(b => b.Initialize(this)); Client = new GridClient(); @@ -178,6 +188,8 @@ namespace pCampBot /// public void shutdown() { + ConnectionState = ConnectionState.Disconnecting; + if (m_actionThread != null) m_actionThread.Abort(); @@ -209,9 +221,11 @@ namespace pCampBot Client.Network.Disconnected += this.Network_OnDisconnected; Client.Objects.ObjectUpdate += Objects_NewPrim; + ConnectionState = ConnectionState.Connecting; + if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) { - IsConnected = true; + ConnectionState = ConnectionState.Connected; Thread.Sleep(Random.Next(1000, 10000)); m_actionThread = new Thread(Action); @@ -241,6 +255,8 @@ namespace pCampBot } else { + ConnectionState = ConnectionState.Disconnected; + m_log.ErrorFormat( "{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage); @@ -439,6 +455,8 @@ namespace pCampBot public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) { + ConnectionState = ConnectionState.Disconnected; + m_log.DebugFormat( "[BOT]: Bot {0} disconnected reason {1}, message {2}", Name, args.Reason, args.Message); @@ -456,7 +474,6 @@ namespace pCampBot && OnDisconnected != null) // if (OnDisconnected != null) { - IsConnected = false; OnDisconnected(this, EventType.DISCONNECTED); } } diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index fd32a6aa6e..d4bbc2acde 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -242,7 +242,7 @@ namespace pCampBot lock (m_lBot) { - if (m_lBot.TrueForAll(b => !b.IsConnected)) + if (m_lBot.TrueForAll(b => b.ConnectionState == ConnectionState.Disconnected)) Environment.Exit(0); break; @@ -306,7 +306,7 @@ namespace pCampBot MainConsole.Instance.OutputFormat( outputFormat, - pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.IsConnected ? "Connected" : "Disconnected"); + pb.Name, currentSim != null ? currentSim.Name : "(none)", pb.ConnectionState); } } } From 93b615c51df3dec8276aead52141534a7ed32ff9 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 May 2012 01:37:03 +0100 Subject: [PATCH 10/15] Do each bot shutdown on its own threads to prevent one slow shutdown holding up all the rest. This does increase the aggressiveness of shutdown Also prevents the bot list being locked for a long period, which was preventing commands such as "show bots" from working during shutdown --- OpenSim/Tools/pCampBot/BotManager.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index d4bbc2acde..d06c55b111 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -251,13 +251,21 @@ namespace pCampBot } /// - /// Shutting down all bots + /// Shut down all bots /// + /// + /// We launch each shutdown on its own thread so that a slow shutting down bot doesn't hold up all the others. + /// public void doBotShutdown() { 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()); + } + } } /// @@ -271,11 +279,8 @@ namespace pCampBot private void HandleShutdown(string module, string[] cmd) { - Util.FireAndForget(o => - { - m_log.Warn("[BOTMANAGER]: Shutting down bots"); - doBotShutdown(); - }); + m_log.Info("[BOTMANAGER]: Shutting down bots"); + doBotShutdown(); } private void HandleShowRegions(string module, string[] cmd) From 0ddf3c5289f32fc5ed3283d493f305286058e48c Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 May 2012 01:56:00 +0100 Subject: [PATCH 11/15] Do bot startup on another thread so console is responsive during this process --- OpenSim/Tools/pCampBot/BotManager.cs | 1 + OpenSim/Tools/pCampBot/pCampBot.cs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index d06c55b111..6d4bdb102d 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -222,6 +222,7 @@ namespace pCampBot Thread pbThread = new Thread(pb.startup); pbThread.Name = pb.Name; pbThread.IsBackground = true; + pbThread.Start(); } diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index ec5ad04fce..52e750185a 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -27,6 +27,7 @@ using System; using System.Reflection; +using System.Threading; using log4net; using Nini.Config; using OpenSim.Framework; @@ -67,7 +68,9 @@ namespace pCampBot BotManager bm = new BotManager(); //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) { From 9c392f6a6894d532917a3b4b44720fa1e6e30be7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 May 2012 02:05:32 +0100 Subject: [PATCH 12/15] Stagger multiple bot logins by 5 seconds to make this part of the test more 'realistic' TODO: Need to make this value configurable by a command line parameter to pCampbot --- OpenSim/Tools/pCampBot/BotManager.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 6d4bdb102d..b9eabbfffc 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -49,6 +49,14 @@ namespace pCampBot { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public const int DefaultLoginDelay = 5000; + + /// + /// Delay between logins of multiple bots. + /// + /// TODO: This value needs to be configurable by a command line argument. + public int LoginDelay { get; set; } + /// /// Command console /// @@ -84,6 +92,8 @@ namespace pCampBot /// public BotManager() { + LoginDelay = DefaultLoginDelay; + Rng = new Random(Environment.TickCount); AssetsReceived = new Dictionary(); RegionsKnown = new Dictionary(); @@ -224,6 +234,9 @@ namespace pCampBot pbThread.IsBackground = true; pbThread.Start(); + + // Stagger logins + Thread.Sleep(LoginDelay); } /// From f231ac39de7348965b5c4c04d8b29a885501c90d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 May 2012 02:23:18 +0100 Subject: [PATCH 13/15] Increase minimum period between bot actions to 3 seconds, so that teleport doesn't fall under the minimum 2 second limits that clients take to process it --- OpenSim/Tools/pCampBot/Bot.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 2b4a171f5a..95dba9f4a5 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -167,10 +167,10 @@ namespace pCampBot Behaviours.ForEach( b => { + Thread.Sleep(Random.Next(3000, 10000)); + // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); b.Action(); - - Thread.Sleep(Random.Next(1000, 10000)); } ); } From 480216f50f40bdb9709f9c6eec189a2ca027f395 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 11 May 2012 02:38:29 +0100 Subject: [PATCH 14/15] Print out more information on connecting bots --- OpenSim/Tools/pCampBot/Bot.cs | 2 +- OpenSim/Tools/pCampBot/BotManager.cs | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 95dba9f4a5..b6cd287202 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -168,7 +168,7 @@ namespace pCampBot b => { Thread.Sleep(Random.Next(3000, 10000)); - + // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); b.Action(); } diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index b9eabbfffc..d615b3fb8a 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -161,28 +161,34 @@ namespace pCampBot Array.ForEach( 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}_", + botcount, + loginUri, + firstName, + lastNameStem); + + MainConsole.Instance.OutputFormat("[BOT MANAGER]: Delay between logins is {0}ms", LoginDelay); + for (int i = 0; i < botcount; 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 behaviours = new List(); - + // Hard-coded for now if (behaviourSwitches.Contains("p")) behaviours.Add(new PhysicsBehaviour()); - + if (behaviourSwitches.Contains("g")) behaviours.Add(new GrabbingBehaviour()); - + if (behaviourSwitches.Contains("t")) behaviours.Add(new TeleportBehaviour()); - + if (behaviourSwitches.Contains("c")) behaviours.Add(new CrossBehaviour()); - - MainConsole.Instance.OutputFormat( - "[BOT MANAGER]: Bot {0} {1} configured for behaviours {2}", - firstName, lastName, string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray())); StartBot(this, behaviours, firstName, lastName, password, loginUri); } @@ -221,6 +227,10 @@ namespace pCampBot BotManager bm, List behaviours, 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(b => b.Name).ToArray())); + Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri); pb.OnConnected += handlebotEvent; From b0b7b45b943dd94546bcfcf5d3bb871cfe35b507 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Thu, 3 May 2012 19:38:35 +0300 Subject: [PATCH 15/15] Save the Telehub and its Spawn Points in the OAR Signed-off-by: BlueWall --- OpenSim/Framework/RegionSettings.cs | 29 ++++++++++++++- .../External/RegionSettingsSerializer.cs | 37 ++++++++++++++++++- .../Tests/RegionSettingsSerializerTests.cs | 8 ++++ .../World/Archiver/ArchiveReadRequest.cs | 25 ++++++++++++- .../ArchiveWriteRequestPreparation.cs | 2 +- .../World/Archiver/Tests/ArchiverTests.cs | 4 ++ 6 files changed, 100 insertions(+), 5 deletions(-) diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 4ce3392057..011a97a9a3 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.IO; using OpenMetaverse; +using System.Runtime.Serialization; namespace OpenSim.Framework { @@ -71,6 +72,32 @@ namespace OpenSim.Framework return pos + offset; } + + /// + /// Returns a string representation of this SpawnPoint. + /// + /// + public override string ToString() + { + return string.Format("{0},{1},{2}", Yaw, Pitch, Distance); + } + + /// + /// Generate a SpawnPoint from a string + /// + /// + public static SpawnPoint Parse(string str) + { + string[] parts = str.Split(','); + if (parts.Length != 3) + throw new ArgumentException("Invalid string: " + str); + + SpawnPoint sp = new SpawnPoint(); + sp.Yaw = float.Parse(parts[0]); + sp.Pitch = float.Parse(parts[1]); + sp.Distance = float.Parse(parts[2]); + return sp; + } } public class RegionSettings @@ -456,7 +483,7 @@ namespace OpenSim.Framework } // Connected Telehub object - private UUID m_TelehubObject; + private UUID m_TelehubObject = UUID.Zero; public UUID TelehubObject { get diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs index 931898ce10..f18435d308 100644 --- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs +++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs @@ -30,6 +30,8 @@ using System.Text; using System.Xml; using OpenMetaverse; using OpenSim.Framework; +using log4net; +using System.Reflection; namespace OpenSim.Framework.Serialization.External { @@ -187,7 +189,29 @@ namespace OpenSim.Framework.Serialization.External break; } } - + + xtr.ReadEndElement(); + + if (xtr.IsStartElement("Telehub")) + { + xtr.ReadStartElement("Telehub"); + + while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement) + { + switch (xtr.Name) + { + case "TelehubObject": + settings.TelehubObject = UUID.Parse(xtr.ReadElementContentAsString()); + break; + case "SpawnPoint": + string str = xtr.ReadElementContentAsString(); + SpawnPoint sp = SpawnPoint.Parse(str); + settings.AddSpawnPoint(sp); + break; + } + } + } + xtr.Close(); sr.Close(); @@ -243,7 +267,16 @@ namespace OpenSim.Framework.Serialization.External xtw.WriteElementString("SunPosition", settings.SunPosition.ToString()); // Note: 'SunVector' isn't saved because this value is owned by the Sun Module, which // calculates it automatically according to the date and other factors. - xtw.WriteEndElement(); + xtw.WriteEndElement(); + + xtw.WriteStartElement("Telehub"); + if (settings.TelehubObject != UUID.Zero) + { + xtw.WriteElementString("TelehubObject", settings.TelehubObject.ToString()); + foreach (SpawnPoint sp in settings.SpawnPoints()) + xtw.WriteElementString("SpawnPoint", sp.ToString()); + } + xtw.WriteEndElement(); xtw.WriteEndElement(); diff --git a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs index a61e4af65d..09b6f6ddad 100644 --- a/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs +++ b/OpenSim/Framework/Serialization/Tests/RegionSettingsSerializerTests.cs @@ -78,6 +78,10 @@ namespace OpenSim.Framework.Serialization.Tests true 12 + + 00000000-0000-0000-0000-111111111111 + 1,-2,0.33 + "; private RegionSettings m_rs; @@ -116,6 +120,8 @@ namespace OpenSim.Framework.Serialization.Tests m_rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); m_rs.UseEstateSun = true; m_rs.WaterHeight = 23; + m_rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111"); + m_rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33")); } [Test] @@ -129,6 +135,8 @@ namespace OpenSim.Framework.Serialization.Tests Assert.That(deserRs.TerrainTexture2, Is.EqualTo(m_rs.TerrainTexture2)); Assert.That(deserRs.DisablePhysics, Is.EqualTo(m_rs.DisablePhysics)); Assert.That(deserRs.TerrainLowerLimit, Is.EqualTo(m_rs.TerrainLowerLimit)); + Assert.That(deserRs.TelehubObject, Is.EqualTo(m_rs.TelehubObject)); + Assert.That(deserRs.SpawnPoints()[0].ToString(), Is.EqualTo(m_rs.SpawnPoints()[0].ToString())); } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index a6dbaba7d7..bf0ff7516b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -245,6 +245,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Reload serialized prims m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); + UUID oldTelehubUUID = m_scene.RegionInfo.RegionSettings.TelehubObject; + IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface(); int sceneObjectsLoadedCount = 0; @@ -266,11 +268,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); + bool isTelehub = (sceneObject.UUID == oldTelehubUUID); + // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned // on the same region server and multiple examples a single object archive to be imported // to the same scene (when this is possible). sceneObject.ResetIDs(); + if (isTelehub) + { + // Change the Telehub Object to the new UUID + m_scene.RegionInfo.RegionSettings.TelehubObject = sceneObject.UUID; + m_scene.RegionInfo.RegionSettings.Save(); + oldTelehubUUID = UUID.Zero; + } + // Try to retain the original creator/owner/lastowner if their uuid is present on this grid // or creator data is present. Otherwise, use the estate owner instead. foreach (SceneObjectPart part in sceneObject.Parts) @@ -329,7 +341,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver int ignoredObjects = serialisedSceneObjects.Count - sceneObjectsLoadedCount; if (ignoredObjects > 0) - m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); + m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); + + if (oldTelehubUUID != UUID.Zero) + { + m_log.WarnFormat("Telehub object not found: {0}", oldTelehubUUID); + m_scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; + m_scene.RegionInfo.RegionSettings.ClearSpawnPoints(); + } } /// @@ -505,6 +524,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; + currentRegionSettings.TelehubObject = loadedRegionSettings.TelehubObject; + currentRegionSettings.ClearSpawnPoints(); + foreach (SpawnPoint sp in loadedRegionSettings.SpawnPoints()) + currentRegionSettings.AddSpawnPoint(sp); currentRegionSettings.Save(); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index eabe46e936..5679ad5dcb 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -328,7 +328,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// public string CreateControlFile(Dictionary options) { - int majorVersion = MAX_MAJOR_VERSION, minorVersion = 7; + int majorVersion = MAX_MAJOR_VERSION, minorVersion = 8; // // if (options.ContainsKey("version")) // { diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 053c6f59d4..394ca27123 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -534,6 +534,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests rs.TerrainTexture4 = UUID.Parse("00000000-0000-0000-0000-000000000080"); rs.UseEstateSun = true; rs.WaterHeight = 23; + rs.TelehubObject = UUID.Parse("00000000-0000-0000-0000-111111111111"); + rs.AddSpawnPoint(SpawnPoint.Parse("1,-2,0.33")); tar.WriteFile(ArchiveConstants.SETTINGS_PATH + "region1.xml", RegionSettingsSerializer.Serialize(rs)); @@ -580,6 +582,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests Assert.That(loadedRs.TerrainTexture4, Is.EqualTo(UUID.Parse("00000000-0000-0000-0000-000000000080"))); Assert.That(loadedRs.UseEstateSun, Is.True); Assert.That(loadedRs.WaterHeight, Is.EqualTo(23)); + Assert.AreEqual(UUID.Zero, loadedRs.TelehubObject); // because no object was found with the original UUID + Assert.AreEqual(0, loadedRs.SpawnPoints().Count); } ///