From 59232a6ea8739f4a83c21771e550893e75672b50 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 2 Nov 2011 20:05:31 +0000 Subject: Change default say distance to 20m from 30m, the same as on the big grid. This is to improve the migration of scripts that expect a 20m say distance. If you want to keep a 30m say distance then please set this as the say_distance parameter in the [Chat] section of OpenSim.ini. --- OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 2 +- OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | 2 +- bin/OpenSim.ini.example | 4 ++-- bin/OpenSimDefaults.ini | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 2cd71c4..f5cc4c3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat private const int DEBUG_CHANNEL = 2147483647; private bool m_enabled = true; - private int m_saydistance = 30; + private int m_saydistance = 20; private int m_shoutdistance = 100; private int m_whisperdistance = 10; private List m_scenes = new List(); diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index a14a84b..640a60b 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -95,7 +95,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private Queue m_pendingQ; private Scene m_scene; private int m_whisperdistance = 10; - private int m_saydistance = 30; + private int m_saydistance = 20; private int m_shoutdistance = 100; #region IRegionModule Members diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 80f4c0e..e71fb05 100755 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -339,9 +339,9 @@ ;; Distance in meters that whispers should travel. ; whisper_distance = 10 - ;# {say_distance} {} {Distance at which normal chat is heard, in meters? (SL uses 20 here)} {} 30 + ;# {say_distance} {} {Distance at which normal chat is heard, in meters?} {} 20 ;; Distance in meters that ordinary chat should travel. - ; say_distance = 30 + ; say_distance = 20 ;# {shout_distance} {Distance at which a shout is heard, in meters?} {} 100 ;; Distance in meters that shouts should travel. diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index d79cb1e..bf1976c 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -563,8 +563,8 @@ ; Distance in meters that whispers should travel. Default is 10m whisper_distance = 10 - ; Distance in meters that ordinary chat should travel. Default is 30m - say_distance = 30 + ; Distance in meters that ordinary chat should travel. Default is 20m + say_distance = 20 ; Distance in meters that shouts should travel. Default is 100m shout_distance = 100 -- cgit v1.1 From 40a1eddfd173609923b0c8d24517b8ddb1a91bbd Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 2 Nov 2011 18:55:54 -0700 Subject: Drop the CopyTo parameter from Int32.MaxValue to 4096. This is a buffer size not a target size. Mono 2.10 appears to try to allocate the full buffer which immediately crashes. Tested on mono 2.6.7 and 2.10.5 --- OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 30d3147..d8089ac 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs @@ -473,7 +473,7 @@ namespace OpenSim.Services.Connectors.SimianGrid // Grab the asset data from the response stream using (MemoryStream stream = new MemoryStream()) { - responseStream.CopyTo(stream, Int32.MaxValue); + responseStream.CopyTo(stream, 4096); asset.Data = stream.ToArray(); } } -- cgit v1.1 From 66c60c56a0bac01e0f4f2a9d5c673a48ff94642b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 21:16:24 +0000 Subject: Separate out physics testing actions into a separate PhysicsBehaviour class --- OpenSim/Tools/pCampBot/BotManager.cs | 16 ++- OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs | 37 ++++++ OpenSim/Tools/pCampBot/PhysicsBehaviour.cs | 97 +++++++++++++++ OpenSim/Tools/pCampBot/PhysicsBot.cs | 152 ++++++++++-------------- OpenSim/Tools/pCampBot/pCampBot.cs | 14 ++- 5 files changed, 221 insertions(+), 95 deletions(-) create mode 100644 OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs create mode 100644 OpenSim/Tools/pCampBot/PhysicsBehaviour.cs diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index b05bd6d..0505c97 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -37,6 +37,7 @@ using log4net.Repository; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; +using pCampBot.Interfaces; namespace pCampBot { @@ -119,10 +120,14 @@ namespace pCampBot string password = cs.GetString("password"); string loginUri = cs.GetString("loginuri"); + // Hardcoded for new + List behaviours = new List(); + behaviours.Add(new PhysicsBehaviour()); + for (int i = 0; i < botcount; i++) { string lastName = string.Format("{0}_{1}", lastNameStem, i); - startupBot(i, this, firstName, lastName, password, loginUri); + startupBot(i, this, behaviours, firstName, lastName, password, loginUri); } } @@ -150,14 +155,17 @@ namespace pCampBot /// This starts up the bot and stores the thread for the bot in the thread array /// /// The position in the thread array to stick the bot's thread - /// Configuration of the bot + /// + /// Behaviours for this bot to perform. /// First name /// Last name /// Password /// Login URI - public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri) + public void startupBot( + int pos, BotManager bm, List behaviours, + string firstName, string lastName, string password, string loginUri) { - PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri); + PhysicsBot pb = new PhysicsBot(bm, behaviours, firstName, lastName, password, loginUri); pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs new file mode 100644 index 0000000..f9eaa1c --- /dev/null +++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs @@ -0,0 +1,37 @@ +/* + * 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 pCampBot; +using System; + +namespace pCampBot.Interfaces +{ + public interface IBehaviour + { + void Action(PhysicsBot bot); + } +} \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs new file mode 100644 index 0000000..e76c0b3 --- /dev/null +++ b/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs @@ -0,0 +1,97 @@ +/* + * 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.IO; +using System.Threading; +using OpenMetaverse; +using OpenSim.Framework; +using pCampBot.Interfaces; + +namespace pCampBot +{ + /// + /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot. + /// + /// + /// TODO: talkarray should be in a separate behaviour. + /// + public class PhysicsBehaviour : IBehaviour + { + private string[] talkarray; + + public PhysicsBehaviour() + { + talkarray = readexcuses(); + } + + public void Action(PhysicsBot bot) + { + int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number, + // the greater the bot's chances to walk instead of run. + bot.Client.Self.Jump(false); + if (walkorrun == 0) + { + bot.Client.Self.Movement.AlwaysRun = true; + } + else + { + bot.Client.Self.Movement.AlwaysRun = false; + } + + // TODO: unused: Vector3 pos = client.Self.SimPosition; + Vector3 newpos = new Vector3(bot.Random.Next(1, 254), bot.Random.Next(1, 254), bot.Random.Next(1, 254)); + bot.Client.Self.Movement.TurnToward(newpos); + + bot.Client.Self.Movement.AtPos = true; + Thread.Sleep(bot.Random.Next(3000, 13000)); + bot.Client.Self.Movement.AtPos = false; + bot.Client.Self.Jump(true); + + string randomf = talkarray[bot.Random.Next(talkarray.Length)]; + if (talkarray.Length > 1 && randomf.Length > 1) + bot.Client.Self.Chat(randomf, 0, ChatType.Normal); + + Thread.Sleep(bot.Random.Next(1000, 10000)); + } + + private string[] readexcuses() + { + string allexcuses = ""; + + string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); + if (File.Exists(file)) + { + StreamReader csr = File.OpenText(file); + allexcuses = csr.ReadToEnd(); + csr.Close(); + } + + return allexcuses.Split(Environment.NewLine.ToCharArray()); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index a8b2426..c1bd49f 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -36,6 +36,7 @@ using log4net; using OpenMetaverse; using OpenMetaverse.Assets; using Nini.Config; +using pCampBot.Interfaces; using OpenSim.Framework; using OpenSim.Framework.Console; using Timer = System.Timers.Timer; @@ -52,6 +53,11 @@ namespace pCampBot private IConfig startupConfig; // bot config, passed from BotManager /// + /// Behaviours implemented by this bot. + /// + public List Behaviours { get; private set; } + + /// /// Is this bot connected to the grid? /// public bool IsConnected { get; private set; } @@ -74,25 +80,33 @@ namespace pCampBot protected List objectIDs = new List(); - protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here + /// + /// Random number generator. + /// + public Random Random { get; private set; } /// /// New instance of a SecondLife client /// - public GridClient client = new GridClient(); - - protected string[] talkarray; + public GridClient Client { get; private set; } /// /// Constructor /// /// + /// Behaviours for this bot to perform /// /// /// /// - public PhysicsBot(BotManager bm, string firstName, string lastName, string password, string loginUri) + /// + public PhysicsBot( + BotManager bm, List behaviours, + string firstName, string lastName, string password, string loginUri) { + Client = new GridClient(); + + Random = new Random(Environment.TickCount);// We do stuff randomly here FirstName = firstName; LastName = lastName; Name = string.Format("{0} {1}", FirstName, LastName); @@ -102,7 +116,8 @@ namespace pCampBot BotManager = bm; startupConfig = bm.Config; readconfig(); - talkarray = readexcuses(); + + Behaviours = behaviours; } //We do our actions here. This is where one would @@ -110,34 +125,7 @@ namespace pCampBot private void Action() { while (true) - { - int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number, - // the greater the bot's chances to walk instead of run. - client.Self.Jump(false); - if (walkorrun == 0) - { - client.Self.Movement.AlwaysRun = true; - } - else - { - client.Self.Movement.AlwaysRun = false; - } - - // TODO: unused: Vector3 pos = client.Self.SimPosition; - Vector3 newpos = new Vector3(somthing.Next(1, 254), somthing.Next(1, 254), somthing.Next(1, 254)); - client.Self.Movement.TurnToward(newpos); - - client.Self.Movement.AtPos = true; - Thread.Sleep(somthing.Next(3000, 13000)); - client.Self.Movement.AtPos = false; - client.Self.Jump(true); - - string randomf = talkarray[somthing.Next(talkarray.Length)]; - if (talkarray.Length > 1 && randomf.Length > 1) - client.Self.Chat(randomf, 0, ChatType.Normal); - - Thread.Sleep(somthing.Next(1000, 10000)); - } + Behaviours.ForEach(b => b.Action(this)); } /// @@ -145,7 +133,7 @@ namespace pCampBot /// public void readconfig() { - wear = startupConfig.GetString("wear","no"); + wear = startupConfig.GetString("wear", "no"); } /// @@ -156,7 +144,7 @@ namespace pCampBot if (m_actionThread != null) m_actionThread.Abort(); - client.Network.Logout(); + Client.Network.Logout(); } /// @@ -164,50 +152,50 @@ namespace pCampBot /// public void startup() { - client.Settings.LOGIN_SERVER = LoginUri; - client.Settings.ALWAYS_DECODE_OBJECTS = false; - client.Settings.AVATAR_TRACKING = false; - client.Settings.OBJECT_TRACKING = false; - client.Settings.SEND_AGENT_THROTTLE = true; - client.Settings.SEND_PINGS = true; - client.Settings.STORE_LAND_PATCHES = false; - client.Settings.USE_ASSET_CACHE = false; - client.Settings.MULTIPLE_SIMS = true; - client.Throttle.Asset = 100000; - client.Throttle.Land = 100000; - client.Throttle.Task = 100000; - client.Throttle.Texture = 100000; - client.Throttle.Wind = 100000; - client.Throttle.Total = 400000; - client.Network.LoginProgress += this.Network_LoginProgress; - client.Network.SimConnected += this.Network_SimConnected; - client.Network.Disconnected += this.Network_OnDisconnected; - client.Objects.ObjectUpdate += Objects_NewPrim; - - if (client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) + Client.Settings.LOGIN_SERVER = LoginUri; + Client.Settings.ALWAYS_DECODE_OBJECTS = false; + Client.Settings.AVATAR_TRACKING = false; + Client.Settings.OBJECT_TRACKING = false; + Client.Settings.SEND_AGENT_THROTTLE = true; + Client.Settings.SEND_PINGS = true; + Client.Settings.STORE_LAND_PATCHES = false; + Client.Settings.USE_ASSET_CACHE = false; + Client.Settings.MULTIPLE_SIMS = true; + Client.Throttle.Asset = 100000; + Client.Throttle.Land = 100000; + Client.Throttle.Task = 100000; + Client.Throttle.Texture = 100000; + Client.Throttle.Wind = 100000; + Client.Throttle.Total = 400000; + Client.Network.LoginProgress += this.Network_LoginProgress; + Client.Network.SimConnected += this.Network_SimConnected; + Client.Network.Disconnected += this.Network_OnDisconnected; + Client.Objects.ObjectUpdate += Objects_NewPrim; + + if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) { IsConnected = true; - Thread.Sleep(somthing.Next(1000, 10000)); + Thread.Sleep(Random.Next(1000, 10000)); m_actionThread = new Thread(Action); m_actionThread.Start(); // OnConnected(this, EventType.CONNECTED); if (wear == "save") { - client.Appearance.SetPreviousAppearance(); + Client.Appearance.SetPreviousAppearance(); SaveDefaultAppearance(); } else if (wear != "no") { MakeDefaultAppearance(wear); } - client.Self.Jump(true); + Client.Self.Jump(true); } else { MainConsole.Instance.OutputFormat( - "{0} {1} cannot login: {2}", FirstName, LastName, client.Network.LoginMessage); + "{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage); if (OnDisconnected != null) { @@ -227,11 +215,11 @@ namespace pCampBot Array wtypes = Enum.GetValues(typeof(WearableType)); foreach (WearableType wtype in wtypes) { - UUID wearable = client.Appearance.GetWearableAsset(wtype); + UUID wearable = Client.Appearance.GetWearableAsset(wtype); if (wearable != UUID.Zero) { - client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); - client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); + Client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); + Client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); } } } @@ -306,11 +294,11 @@ namespace pCampBot UUID assetID = UUID.Random(); AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); asset.Decode(); - asset.Owner = client.Self.AgentID; + asset.Owner = Client.Self.AgentID; asset.WearableType = GetWearableType(clothing[i]); asset.Encode(); - transid = client.Assets.RequestUpload(asset,true); - client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, + transid = Client.Assets.RequestUpload(asset,true); + Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) { if (success) @@ -328,11 +316,11 @@ namespace pCampBot UUID assetID = UUID.Random(); AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); asset.Decode(); - asset.Owner = client.Self.AgentID; + asset.Owner = Client.Self.AgentID; asset.WearableType = GetWearableType(bodyparts[i]); asset.Encode(); - transid = client.Assets.RequestUpload(asset,true); - client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, + transid = Client.Assets.RequestUpload(asset,true); + Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) { if (success) @@ -352,7 +340,7 @@ namespace pCampBot else { MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count)); - client.Appearance.WearOutfit(listwearables, false); + Client.Appearance.WearOutfit(listwearables, false); } } catch (Exception ex) @@ -363,8 +351,8 @@ namespace pCampBot public InventoryFolder FindClothingFolder() { - UUID rootfolder = client.Inventory.Store.RootFolder.UUID; - List listfolders = client.Inventory.Store.GetContents(rootfolder); + UUID rootfolder = Client.Inventory.Store.RootFolder.UUID; + List listfolders = Client.Inventory.Store.GetContents(rootfolder); InventoryFolder clothfolder = new InventoryFolder(UUID.Random()); foreach (InventoryBase folder in listfolders) { @@ -453,10 +441,9 @@ namespace pCampBot return; BotManager.AssetsReceived[textureID] = false; - client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); + Client.Assets.RequestImage(textureID, ImageType.Normal, Asset_TextureCallback_Texture); } } - public void Asset_TextureCallback_Texture(TextureRequestState state, AssetTexture assetTexture) { @@ -473,20 +460,5 @@ namespace pCampBot // SaveAsset((AssetWearable) asset); // } } - - public string[] readexcuses() - { - string allexcuses = ""; - - string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); - if (File.Exists(file)) - { - StreamReader csr = File.OpenText(file); - allexcuses = csr.ReadToEnd(); - csr.Close(); - } - - return allexcuses.Split(Environment.NewLine.ToCharArray()); - } } } diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index a69fbf0..cae96e1 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -26,6 +26,8 @@ */ using System; +using System.Reflection; +using log4net; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; @@ -44,6 +46,8 @@ namespace pCampBot public class pCampBot { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + [STAThread] public static void Main(string[] args) { @@ -60,9 +64,17 @@ namespace pCampBot //startup specified number of bots. 1 is the default bm.dobotStartup(botcount, config); + while (true) { - MainConsole.Instance.Prompt(); + try + { + MainConsole.Instance.Prompt(); + } + catch (Exception e) + { + m_log.ErrorFormat("Command error: {0}", e); + } } } } -- cgit v1.1 From 3ea379e4cd2c96e3a21705c752175e9d25b364b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 21:25:27 +0000 Subject: Move PhysicsBehaviour into a spearate behaviours folder --- .../Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 97 ++++++++++++++++++++++ OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs | 1 - OpenSim/Tools/pCampBot/PhysicsBehaviour.cs | 97 ---------------------- OpenSim/Tools/pCampBot/PhysicsBot.cs | 4 +- 4 files changed, 99 insertions(+), 100 deletions(-) create mode 100644 OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs delete mode 100644 OpenSim/Tools/pCampBot/PhysicsBehaviour.cs diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs new file mode 100644 index 0000000..e76c0b3 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -0,0 +1,97 @@ +/* + * 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.IO; +using System.Threading; +using OpenMetaverse; +using OpenSim.Framework; +using pCampBot.Interfaces; + +namespace pCampBot +{ + /// + /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot. + /// + /// + /// TODO: talkarray should be in a separate behaviour. + /// + public class PhysicsBehaviour : IBehaviour + { + private string[] talkarray; + + public PhysicsBehaviour() + { + talkarray = readexcuses(); + } + + public void Action(PhysicsBot bot) + { + int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number, + // the greater the bot's chances to walk instead of run. + bot.Client.Self.Jump(false); + if (walkorrun == 0) + { + bot.Client.Self.Movement.AlwaysRun = true; + } + else + { + bot.Client.Self.Movement.AlwaysRun = false; + } + + // TODO: unused: Vector3 pos = client.Self.SimPosition; + Vector3 newpos = new Vector3(bot.Random.Next(1, 254), bot.Random.Next(1, 254), bot.Random.Next(1, 254)); + bot.Client.Self.Movement.TurnToward(newpos); + + bot.Client.Self.Movement.AtPos = true; + Thread.Sleep(bot.Random.Next(3000, 13000)); + bot.Client.Self.Movement.AtPos = false; + bot.Client.Self.Jump(true); + + string randomf = talkarray[bot.Random.Next(talkarray.Length)]; + if (talkarray.Length > 1 && randomf.Length > 1) + bot.Client.Self.Chat(randomf, 0, ChatType.Normal); + + Thread.Sleep(bot.Random.Next(1000, 10000)); + } + + private string[] readexcuses() + { + string allexcuses = ""; + + string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); + if (File.Exists(file)) + { + StreamReader csr = File.OpenText(file); + allexcuses = csr.ReadToEnd(); + csr.Close(); + } + + return allexcuses.Split(Environment.NewLine.ToCharArray()); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs index f9eaa1c..8a1015d 100644 --- a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs @@ -25,7 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using pCampBot; using System; namespace pCampBot.Interfaces diff --git a/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs deleted file mode 100644 index e76c0b3..0000000 --- a/OpenSim/Tools/pCampBot/PhysicsBehaviour.cs +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the 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.IO; -using System.Threading; -using OpenMetaverse; -using OpenSim.Framework; -using pCampBot.Interfaces; - -namespace pCampBot -{ - /// - /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot. - /// - /// - /// TODO: talkarray should be in a separate behaviour. - /// - public class PhysicsBehaviour : IBehaviour - { - private string[] talkarray; - - public PhysicsBehaviour() - { - talkarray = readexcuses(); - } - - public void Action(PhysicsBot bot) - { - int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number, - // the greater the bot's chances to walk instead of run. - bot.Client.Self.Jump(false); - if (walkorrun == 0) - { - bot.Client.Self.Movement.AlwaysRun = true; - } - else - { - bot.Client.Self.Movement.AlwaysRun = false; - } - - // TODO: unused: Vector3 pos = client.Self.SimPosition; - Vector3 newpos = new Vector3(bot.Random.Next(1, 254), bot.Random.Next(1, 254), bot.Random.Next(1, 254)); - bot.Client.Self.Movement.TurnToward(newpos); - - bot.Client.Self.Movement.AtPos = true; - Thread.Sleep(bot.Random.Next(3000, 13000)); - bot.Client.Self.Movement.AtPos = false; - bot.Client.Self.Jump(true); - - string randomf = talkarray[bot.Random.Next(talkarray.Length)]; - if (talkarray.Length > 1 && randomf.Length > 1) - bot.Client.Self.Chat(randomf, 0, ChatType.Normal); - - Thread.Sleep(bot.Random.Next(1000, 10000)); - } - - private string[] readexcuses() - { - string allexcuses = ""; - - string file = Path.Combine(Util.configDir(), "pCampBotSentences.txt"); - if (File.Exists(file)) - { - StreamReader csr = File.OpenText(file); - allexcuses = csr.ReadToEnd(); - csr.Close(); - } - - return allexcuses.Split(Environment.NewLine.ToCharArray()); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index c1bd49f..05a510a 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -36,9 +36,9 @@ using log4net; using OpenMetaverse; using OpenMetaverse.Assets; using Nini.Config; -using pCampBot.Interfaces; using OpenSim.Framework; using OpenSim.Framework.Console; +using pCampBot.Interfaces; using Timer = System.Timers.Timer; namespace pCampBot @@ -105,7 +105,7 @@ namespace pCampBot string firstName, string lastName, string password, string loginUri) { Client = new GridClient(); - + Random = new Random(Environment.TickCount);// We do stuff randomly here FirstName = firstName; LastName = lastName; -- cgit v1.1 From 5a67940acc17c80c419781fddc9efa0c18ce1f15 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 22:31:31 +0000 Subject: Add click/grab behaviour to pCampbot, which gets bots to randomly click things. This can be specified on pCampbot.exe by using g in the list of behaviours for the new -behaviours,-b switch e.g. -b p,g to get both existing physics and grabbing behaviours. grabbing is primitive, it attempts grabs on random prims whether they're actually signalled as clickable or not. behaviour is currently primitive overall, behaviours are just executed in a list --- .../Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | 56 ++++++++++++++++++++++ .../Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 2 +- OpenSim/Tools/pCampBot/BotManager.cs | 16 +++++-- OpenSim/Tools/pCampBot/PhysicsBot.cs | 31 +++++++++++- OpenSim/Tools/pCampBot/pCampBot.cs | 8 ++-- prebuild.xml | 1 + 6 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs new file mode 100644 index 0000000..00313b8 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs @@ -0,0 +1,56 @@ +/* + * 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 OpenMetaverse; +using System; +using System.Collections.Generic; +using System.Linq; +using pCampBot.Interfaces; + +namespace pCampBot +{ + /// + /// Click (grab) on random objects in the scene. + /// + /// + /// The viewer itself does not give the option of grabbing objects that haven't been signalled as grabbable. + /// + public class GrabbingBehaviour : IBehaviour + { + public void Action(PhysicsBot bot) + { + Dictionary objects = bot.Objects; + + Primitive prim = objects.ElementAt(bot.Random.Next(0, objects.Count)).Value; + + // This appears to be a typical message sent when a viewer user clicks a clickable object + bot.Client.Self.Grab(prim.LocalID); + bot.Client.Self.GrabUpdate(prim.ID, Vector3.Zero); + bot.Client.Self.DeGrab(prim.LocalID); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs index e76c0b3..bd4a7a2 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -35,7 +35,7 @@ using pCampBot.Interfaces; namespace pCampBot { /// - /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot. + /// Stress physics by moving and bouncing around bots a whole lot. /// /// /// TODO: talkarray should be in a separate behaviour. diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 0505c97..dac6e0e 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -120,13 +120,23 @@ namespace pCampBot string password = cs.GetString("password"); string loginUri = cs.GetString("loginuri"); - // Hardcoded for new - List behaviours = new List(); - behaviours.Add(new PhysicsBehaviour()); + HashSet behaviourSwitches = new HashSet(); + Array.ForEach( + cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); for (int i = 0; i < botcount; i++) { string lastName = string.Format("{0}_{1}", lastNameStem, i); + + List behaviours = new List(); + + // Hard-coded for now + if (behaviourSwitches.Contains("p")) + behaviours.Add(new PhysicsBehaviour()); + + if (behaviourSwitches.Contains("g")) + behaviours.Add(new GrabbingBehaviour()); + startupBot(i, this, behaviours, firstName, lastName, password, loginUri); } } diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 05a510a..6e40ca7 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -55,9 +55,28 @@ namespace pCampBot /// /// Behaviours implemented by this bot. /// + /// + /// Lock this list before manipulating it. + /// public List Behaviours { get; private set; } /// + /// Objects that the bot has discovered. + /// + /// + /// Returns a list copy. Inserting new objects manually will have no effect. + /// + public Dictionary Objects + { + get + { + lock (m_objects) + return new Dictionary(m_objects); + } + } + private Dictionary m_objects = new Dictionary(); + + /// /// Is this bot connected to the grid? /// public bool IsConnected { get; private set; } @@ -125,7 +144,14 @@ namespace pCampBot private void Action() { while (true) - Behaviours.ForEach(b => b.Action(this)); + lock (Behaviours) + Behaviours.ForEach( + b => + { + // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); + b.Action(this); + } + ); } /// @@ -407,6 +433,9 @@ namespace pCampBot if (prim != null) { + lock (m_objects) + m_objects[prim.ID] = prim; + if (prim.Textures != null) { if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index cae96e1..4d3b06d 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -84,12 +84,13 @@ namespace pCampBot //Set up our nifty config.. thanks to nini ArgvConfigSource cs = new ArgvConfigSource(args); - cs.AddSwitch("Startup", "botcount","n"); - cs.AddSwitch("Startup", "loginuri","l"); + cs.AddSwitch("Startup", "botcount", "n"); + cs.AddSwitch("Startup", "loginuri", "l"); cs.AddSwitch("Startup", "firstname"); cs.AddSwitch("Startup", "lastname"); cs.AddSwitch("Startup", "password"); - cs.AddSwitch("Startup", "help","h"); + cs.AddSwitch("Startup", "behaviours", "b"); + cs.AddSwitch("Startup", "help", "h"); cs.AddSwitch("Startup", "wear"); IConfig ol = cs.Configs["Startup"]; @@ -110,6 +111,7 @@ namespace pCampBot " -firstname first name for the bots\n" + " -lastname lastname for the bots. Each lastname will have _ appended, e.g. Ima Bot_0\n" + " -password password for the bots\n" + + " -b, behaviours behaviours for bots. Current options p (physics), g (grab). Comma separated, e.g. p,g. Default is p", " -wear set appearance folder to load from (default: no)\n" + " -h, -help show this message" ); diff --git a/prebuild.xml b/prebuild.xml index bf11b0f..4e4bc61 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2487,6 +2487,7 @@ ../../../bin/ + -- cgit v1.1 From ca2c25ece2d9a65b0cb5292ee52f10776c7f71c3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 22:35:21 +0000 Subject: Move one of the old physics sleeps out into the main bot loop, so leaving out PhysicsBehaviour doesn't result in continuous other behaviours --- OpenSim/Tools/pCampBot/PhysicsBot.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 6e40ca7..1b7c9a7 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -150,6 +150,8 @@ namespace pCampBot { // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); b.Action(this); + + Thread.Sleep(Random.Next(1000, 10000)); } ); } -- cgit v1.1 From f26fdbd8da89ee35a23886defc13b44bc63b1349 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 22:39:06 +0000 Subject: Rename PhysicsBot => Bot since it doesn't just exercise physics anymore --- .../Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | 2 +- .../Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 2 +- OpenSim/Tools/pCampBot/Bot.cs | 495 +++++++++++++++++++++ OpenSim/Tools/pCampBot/BotManager.cs | 12 +- OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs | 2 +- OpenSim/Tools/pCampBot/PhysicsBot.cs | 495 --------------------- 6 files changed, 504 insertions(+), 504 deletions(-) create mode 100644 OpenSim/Tools/pCampBot/Bot.cs delete mode 100644 OpenSim/Tools/pCampBot/PhysicsBot.cs diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs index 00313b8..7084ab4 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs @@ -41,7 +41,7 @@ namespace pCampBot /// public class GrabbingBehaviour : IBehaviour { - public void Action(PhysicsBot bot) + public void Action(Bot bot) { Dictionary objects = bot.Objects; diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs index bd4a7a2..8d1d1ce 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -49,7 +49,7 @@ namespace pCampBot talkarray = readexcuses(); } - public void Action(PhysicsBot bot) + public void Action(Bot bot) { int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number, // the greater the bot's chances to walk instead of run. diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs new file mode 100644 index 0000000..bf01065 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -0,0 +1,495 @@ +/* + * 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.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 pCampBot.Interfaces; +using Timer = System.Timers.Timer; + +namespace pCampBot +{ + public class Bot + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public delegate void AnEvent(Bot callbot, EventType someevent); // event delegate for bot events + + public BotManager BotManager { get; private set; } + private IConfig startupConfig; // bot config, passed from BotManager + + /// + /// Behaviours implemented by this bot. + /// + /// + /// Lock this list before manipulating it. + /// + public List Behaviours { get; private set; } + + /// + /// Objects that the bot has discovered. + /// + /// + /// Returns a list copy. Inserting new objects manually will have no effect. + /// + public Dictionary Objects + { + get + { + lock (m_objects) + return new Dictionary(m_objects); + } + } + private Dictionary m_objects = new Dictionary(); + + /// + /// Is this bot connected to the grid? + /// + public bool IsConnected { get; private set; } + + public string FirstName { get; private set; } + public string LastName { get; private set; } + public string Name { get; private set; } + public string Password { get; private set; } + public string LoginUri { get; private set; } + public string saveDir; + public string wear; + + public event AnEvent OnConnected; + public event AnEvent OnDisconnected; + + /// + /// Keep a track of the continuously acting thread so that we can abort it. + /// + private Thread m_actionThread; + + protected List objectIDs = new List(); + + /// + /// Random number generator. + /// + public Random Random { get; private set; } + + /// + /// New instance of a SecondLife client + /// + public GridClient Client { get; private set; } + + /// + /// Constructor + /// + /// + /// Behaviours for this bot to perform + /// + /// + /// + /// + /// + public Bot( + BotManager bm, List behaviours, + string firstName, string lastName, string password, string loginUri) + { + Client = new GridClient(); + + Random = new Random(Environment.TickCount);// We do stuff randomly here + FirstName = firstName; + LastName = lastName; + Name = string.Format("{0} {1}", FirstName, LastName); + Password = password; + LoginUri = loginUri; + + BotManager = bm; + startupConfig = bm.Config; + readconfig(); + + Behaviours = behaviours; + } + + //We do our actions here. This is where one would + //add additional steps and/or things the bot should do + private void Action() + { + while (true) + lock (Behaviours) + Behaviours.ForEach( + b => + { + // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); + b.Action(this); + + Thread.Sleep(Random.Next(1000, 10000)); + } + ); + } + + /// + /// Read the Nini config and initialize + /// + public void readconfig() + { + wear = startupConfig.GetString("wear", "no"); + } + + /// + /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes. + /// + public void shutdown() + { + if (m_actionThread != null) + m_actionThread.Abort(); + + Client.Network.Logout(); + } + + /// + /// This is the bot startup loop. + /// + public void startup() + { + Client.Settings.LOGIN_SERVER = LoginUri; + Client.Settings.ALWAYS_DECODE_OBJECTS = false; + Client.Settings.AVATAR_TRACKING = false; + Client.Settings.OBJECT_TRACKING = false; + Client.Settings.SEND_AGENT_THROTTLE = true; + Client.Settings.SEND_PINGS = true; + Client.Settings.STORE_LAND_PATCHES = false; + Client.Settings.USE_ASSET_CACHE = false; + Client.Settings.MULTIPLE_SIMS = true; + Client.Throttle.Asset = 100000; + Client.Throttle.Land = 100000; + Client.Throttle.Task = 100000; + Client.Throttle.Texture = 100000; + Client.Throttle.Wind = 100000; + Client.Throttle.Total = 400000; + Client.Network.LoginProgress += this.Network_LoginProgress; + Client.Network.SimConnected += this.Network_SimConnected; + Client.Network.Disconnected += this.Network_OnDisconnected; + Client.Objects.ObjectUpdate += Objects_NewPrim; + + if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) + { + IsConnected = true; + + Thread.Sleep(Random.Next(1000, 10000)); + m_actionThread = new Thread(Action); + m_actionThread.Start(); + +// OnConnected(this, EventType.CONNECTED); + if (wear == "save") + { + Client.Appearance.SetPreviousAppearance(); + SaveDefaultAppearance(); + } + else if (wear != "no") + { + MakeDefaultAppearance(wear); + } + Client.Self.Jump(true); + } + else + { + MainConsole.Instance.OutputFormat( + "{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage); + + if (OnDisconnected != null) + { + OnDisconnected(this, EventType.DISCONNECTED); + } + } + } + + public void SaveDefaultAppearance() + { + saveDir = "MyAppearance/" + FirstName + "_" + LastName; + if (!Directory.Exists(saveDir)) + { + Directory.CreateDirectory(saveDir); + } + + Array wtypes = Enum.GetValues(typeof(WearableType)); + foreach (WearableType wtype in wtypes) + { + UUID wearable = Client.Appearance.GetWearableAsset(wtype); + if (wearable != UUID.Zero) + { + Client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); + Client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); + } + } + } + + public void SaveAsset(AssetWearable asset) + { + if (asset != null) + { + try + { + if (asset.Decode()) + { + File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", + asset.AssetType.ToString().ToLower(), + asset.WearableType)), asset.AssetData); + } + else + { + MainConsole.Instance.Output(String.Format("Failed to decode {0} asset {1}", asset.AssetType, asset.AssetID)); + } + } + catch (Exception e) + { + MainConsole.Instance.Output(String.Format("Exception: {0}",e.ToString())); + } + } + } + + public WearableType GetWearableType(string path) + { + string type = ((((path.Split('/'))[2]).Split('.'))[0]).Trim(); + switch (type) + { + case "Eyes": + return WearableType.Eyes; + case "Hair": + return WearableType.Hair; + case "Pants": + return WearableType.Pants; + case "Shape": + return WearableType.Shape; + case "Shirt": + return WearableType.Shirt; + case "Skin": + return WearableType.Skin; + default: + return WearableType.Shape; + } + } + + public void MakeDefaultAppearance(string wear) + { + try + { + if (wear == "yes") + { + //TODO: Implement random outfit picking + MainConsole.Instance.Output("Picks a random outfit. Not yet implemented."); + } + else if (wear != "save") + saveDir = "MyAppearance/" + wear; + saveDir = saveDir + "/"; + + string[] clothing = Directory.GetFiles(saveDir, "*.clothing", SearchOption.TopDirectoryOnly); + string[] bodyparts = Directory.GetFiles(saveDir, "*.bodypart", SearchOption.TopDirectoryOnly); + InventoryFolder clothfolder = FindClothingFolder(); + UUID transid = UUID.Random(); + List listwearables = new List(); + + for (int i = 0; i < clothing.Length; i++) + { + UUID assetID = UUID.Random(); + AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); + asset.Decode(); + asset.Owner = Client.Self.AgentID; + asset.WearableType = GetWearableType(clothing[i]); + asset.Encode(); + transid = Client.Assets.RequestUpload(asset,true); + Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, + transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) + { + if (success) + { + listwearables.Add(item); + } + else + MainConsole.Instance.Output(String.Format("Failed to create item {0}",item.Name)); + } + ); + } + + for (int i = 0; i < bodyparts.Length; i++) + { + UUID assetID = UUID.Random(); + AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); + asset.Decode(); + asset.Owner = Client.Self.AgentID; + asset.WearableType = GetWearableType(bodyparts[i]); + asset.Encode(); + transid = Client.Assets.RequestUpload(asset,true); + Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, + transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) + { + if (success) + { + listwearables.Add(item); + } + else + MainConsole.Instance.Output(String.Format("Failed to create item {0}",item.Name)); + } + ); + } + + Thread.Sleep(1000); + + if (listwearables == null || listwearables.Count == 0) + MainConsole.Instance.Output("Nothing to send on this folder!"); + else + { + MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count)); + Client.Appearance.WearOutfit(listwearables, false); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + } + } + + public InventoryFolder FindClothingFolder() + { + UUID rootfolder = Client.Inventory.Store.RootFolder.UUID; + List listfolders = Client.Inventory.Store.GetContents(rootfolder); + InventoryFolder clothfolder = new InventoryFolder(UUID.Random()); + foreach (InventoryBase folder in listfolders) + { + if (folder.Name == "Clothing") + { + clothfolder = (InventoryFolder)folder; + break; + } + } + return clothfolder; + } + + public void Network_LoginProgress(object sender, LoginProgressEventArgs args) + { + if (args.Status == LoginStatus.Success) + { + if (OnConnected != null) + { + OnConnected(this, EventType.CONNECTED); + } + } + } + + public void Network_SimConnected(object sender, SimConnectedEventArgs args) + { + } + + public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) + { +// m_log.ErrorFormat("Fired Network_OnDisconnected"); + +// if ( +// (args.Reason == NetworkManager.DisconnectType.SimShutdown +// || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) +// && OnDisconnected != null) + + if ( + (args.Reason == NetworkManager.DisconnectType.ClientInitiated + || args.Reason == NetworkManager.DisconnectType.ServerInitiated + || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) + && OnDisconnected != null) +// if (OnDisconnected != null) + { + IsConnected = false; + OnDisconnected(this, EventType.DISCONNECTED); + } + } + + public void Objects_NewPrim(object sender, PrimEventArgs args) + { + Primitive prim = args.Prim; + + if (prim != null) + { + lock (m_objects) + m_objects[prim.ID] = prim; + + if (prim.Textures != null) + { + if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) + { + GetTexture(prim.Textures.DefaultTexture.TextureID); + } + + for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) + { + UUID textureID = prim.Textures.FaceTextures[i].TextureID; + + if (textureID != null && textureID != UUID.Zero) + { + GetTexture(textureID); + } + } + } + + if (prim.Sculpt.SculptTexture != UUID.Zero) + { + GetTexture(prim.Sculpt.SculptTexture); + } + } + } + + private void GetTexture(UUID textureID) + { + lock (BotManager.AssetsReceived) + { + // Don't request assets more than once. + if (BotManager.AssetsReceived.ContainsKey(textureID)) + return; + + BotManager.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) + { + lock (BotManager.AssetsReceived) + BotManager.AssetsReceived[asset.AssetID] = true; + +// if (wear == "save") +// { +// SaveAsset((AssetWearable) asset); +// } + } + } +} diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index dac6e0e..704770a 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -49,7 +49,7 @@ namespace pCampBot private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected CommandConsole m_console; - protected List m_lBot; + protected List m_lBot; protected Random somthing = new Random(Environment.TickCount); protected int numbots = 0; public IConfig Config { get; private set; } @@ -103,7 +103,7 @@ namespace pCampBot // "add bots ", // "Add more bots", HandleAddBots); - m_lBot = new List(); + m_lBot = new List(); } /// @@ -175,7 +175,7 @@ namespace pCampBot int pos, BotManager bm, List behaviours, string firstName, string lastName, string password, string loginUri) { - PhysicsBot pb = new PhysicsBot(bm, behaviours, firstName, lastName, password, loginUri); + Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri); pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; @@ -194,7 +194,7 @@ namespace pCampBot /// /// /// - private void handlebotEvent(PhysicsBot callbot, EventType eventt) + private void handlebotEvent(Bot callbot, EventType eventt) { switch (eventt) { @@ -219,7 +219,7 @@ namespace pCampBot public void doBotShutdown() { lock (m_lBot) - foreach (PhysicsBot pb in m_lBot) + foreach (Bot pb in m_lBot) pb.shutdown(); } @@ -245,7 +245,7 @@ namespace pCampBot lock (m_lBot) { - foreach (PhysicsBot pb in m_lBot) + foreach (Bot pb in m_lBot) { MainConsole.Instance.OutputFormat( outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected")); diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs index 8a1015d..d4ae0f0 100644 --- a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs @@ -31,6 +31,6 @@ namespace pCampBot.Interfaces { public interface IBehaviour { - void Action(PhysicsBot bot); + void Action(Bot bot); } } \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs deleted file mode 100644 index 1b7c9a7..0000000 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ /dev/null @@ -1,495 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the 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.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 pCampBot.Interfaces; -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 BotManager BotManager { get; private set; } - private IConfig startupConfig; // bot config, passed from BotManager - - /// - /// Behaviours implemented by this bot. - /// - /// - /// Lock this list before manipulating it. - /// - public List Behaviours { get; private set; } - - /// - /// Objects that the bot has discovered. - /// - /// - /// Returns a list copy. Inserting new objects manually will have no effect. - /// - public Dictionary Objects - { - get - { - lock (m_objects) - return new Dictionary(m_objects); - } - } - private Dictionary m_objects = new Dictionary(); - - /// - /// Is this bot connected to the grid? - /// - public bool IsConnected { get; private set; } - - public string FirstName { get; private set; } - public string LastName { get; private set; } - public string Name { get; private set; } - public string Password { get; private set; } - public string LoginUri { get; private set; } - public string saveDir; - public string wear; - - public event AnEvent OnConnected; - public event AnEvent OnDisconnected; - - /// - /// Keep a track of the continuously acting thread so that we can abort it. - /// - private Thread m_actionThread; - - protected List objectIDs = new List(); - - /// - /// Random number generator. - /// - public Random Random { get; private set; } - - /// - /// New instance of a SecondLife client - /// - public GridClient Client { get; private set; } - - /// - /// Constructor - /// - /// - /// Behaviours for this bot to perform - /// - /// - /// - /// - /// - public PhysicsBot( - BotManager bm, List behaviours, - string firstName, string lastName, string password, string loginUri) - { - Client = new GridClient(); - - Random = new Random(Environment.TickCount);// We do stuff randomly here - FirstName = firstName; - LastName = lastName; - Name = string.Format("{0} {1}", FirstName, LastName); - Password = password; - LoginUri = loginUri; - - BotManager = bm; - startupConfig = bm.Config; - readconfig(); - - Behaviours = behaviours; - } - - //We do our actions here. This is where one would - //add additional steps and/or things the bot should do - private void Action() - { - while (true) - lock (Behaviours) - Behaviours.ForEach( - b => - { - // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); - b.Action(this); - - Thread.Sleep(Random.Next(1000, 10000)); - } - ); - } - - /// - /// Read the Nini config and initialize - /// - public void readconfig() - { - wear = startupConfig.GetString("wear", "no"); - } - - /// - /// Tells LibSecondLife to logout and disconnect. Raises the disconnect events once it finishes. - /// - public void shutdown() - { - if (m_actionThread != null) - m_actionThread.Abort(); - - Client.Network.Logout(); - } - - /// - /// This is the bot startup loop. - /// - public void startup() - { - Client.Settings.LOGIN_SERVER = LoginUri; - Client.Settings.ALWAYS_DECODE_OBJECTS = false; - Client.Settings.AVATAR_TRACKING = false; - Client.Settings.OBJECT_TRACKING = false; - Client.Settings.SEND_AGENT_THROTTLE = true; - Client.Settings.SEND_PINGS = true; - Client.Settings.STORE_LAND_PATCHES = false; - Client.Settings.USE_ASSET_CACHE = false; - Client.Settings.MULTIPLE_SIMS = true; - Client.Throttle.Asset = 100000; - Client.Throttle.Land = 100000; - Client.Throttle.Task = 100000; - Client.Throttle.Texture = 100000; - Client.Throttle.Wind = 100000; - Client.Throttle.Total = 400000; - Client.Network.LoginProgress += this.Network_LoginProgress; - Client.Network.SimConnected += this.Network_SimConnected; - Client.Network.Disconnected += this.Network_OnDisconnected; - Client.Objects.ObjectUpdate += Objects_NewPrim; - - if (Client.Network.Login(FirstName, LastName, Password, "pCampBot", "Your name")) - { - IsConnected = true; - - Thread.Sleep(Random.Next(1000, 10000)); - m_actionThread = new Thread(Action); - m_actionThread.Start(); - -// OnConnected(this, EventType.CONNECTED); - if (wear == "save") - { - Client.Appearance.SetPreviousAppearance(); - SaveDefaultAppearance(); - } - else if (wear != "no") - { - MakeDefaultAppearance(wear); - } - Client.Self.Jump(true); - } - else - { - MainConsole.Instance.OutputFormat( - "{0} {1} cannot login: {2}", FirstName, LastName, Client.Network.LoginMessage); - - if (OnDisconnected != null) - { - OnDisconnected(this, EventType.DISCONNECTED); - } - } - } - - public void SaveDefaultAppearance() - { - saveDir = "MyAppearance/" + FirstName + "_" + LastName; - if (!Directory.Exists(saveDir)) - { - Directory.CreateDirectory(saveDir); - } - - Array wtypes = Enum.GetValues(typeof(WearableType)); - foreach (WearableType wtype in wtypes) - { - UUID wearable = Client.Appearance.GetWearableAsset(wtype); - if (wearable != UUID.Zero) - { - Client.Assets.RequestAsset(wearable, AssetType.Clothing, false, Asset_ReceivedCallback); - Client.Assets.RequestAsset(wearable, AssetType.Bodypart, false, Asset_ReceivedCallback); - } - } - } - - public void SaveAsset(AssetWearable asset) - { - if (asset != null) - { - try - { - if (asset.Decode()) - { - File.WriteAllBytes(Path.Combine(saveDir, String.Format("{1}.{0}", - asset.AssetType.ToString().ToLower(), - asset.WearableType)), asset.AssetData); - } - else - { - MainConsole.Instance.Output(String.Format("Failed to decode {0} asset {1}", asset.AssetType, asset.AssetID)); - } - } - catch (Exception e) - { - MainConsole.Instance.Output(String.Format("Exception: {0}",e.ToString())); - } - } - } - - public WearableType GetWearableType(string path) - { - string type = ((((path.Split('/'))[2]).Split('.'))[0]).Trim(); - switch (type) - { - case "Eyes": - return WearableType.Eyes; - case "Hair": - return WearableType.Hair; - case "Pants": - return WearableType.Pants; - case "Shape": - return WearableType.Shape; - case "Shirt": - return WearableType.Shirt; - case "Skin": - return WearableType.Skin; - default: - return WearableType.Shape; - } - } - - public void MakeDefaultAppearance(string wear) - { - try - { - if (wear == "yes") - { - //TODO: Implement random outfit picking - MainConsole.Instance.Output("Picks a random outfit. Not yet implemented."); - } - else if (wear != "save") - saveDir = "MyAppearance/" + wear; - saveDir = saveDir + "/"; - - string[] clothing = Directory.GetFiles(saveDir, "*.clothing", SearchOption.TopDirectoryOnly); - string[] bodyparts = Directory.GetFiles(saveDir, "*.bodypart", SearchOption.TopDirectoryOnly); - InventoryFolder clothfolder = FindClothingFolder(); - UUID transid = UUID.Random(); - List listwearables = new List(); - - for (int i = 0; i < clothing.Length; i++) - { - UUID assetID = UUID.Random(); - AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i])); - asset.Decode(); - asset.Owner = Client.Self.AgentID; - asset.WearableType = GetWearableType(clothing[i]); - asset.Encode(); - transid = Client.Assets.RequestUpload(asset,true); - Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing, - transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) - { - if (success) - { - listwearables.Add(item); - } - else - MainConsole.Instance.Output(String.Format("Failed to create item {0}",item.Name)); - } - ); - } - - for (int i = 0; i < bodyparts.Length; i++) - { - UUID assetID = UUID.Random(); - AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i])); - asset.Decode(); - asset.Owner = Client.Self.AgentID; - asset.WearableType = GetWearableType(bodyparts[i]); - asset.Encode(); - transid = Client.Assets.RequestUpload(asset,true); - Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart, - transid, InventoryType.Wearable, asset.WearableType, PermissionMask.All, delegate(bool success, InventoryItem item) - { - if (success) - { - listwearables.Add(item); - } - else - MainConsole.Instance.Output(String.Format("Failed to create item {0}",item.Name)); - } - ); - } - - Thread.Sleep(1000); - - if (listwearables == null || listwearables.Count == 0) - MainConsole.Instance.Output("Nothing to send on this folder!"); - else - { - MainConsole.Instance.Output(String.Format("Sending {0} wearables...",listwearables.Count)); - Client.Appearance.WearOutfit(listwearables, false); - } - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public InventoryFolder FindClothingFolder() - { - UUID rootfolder = Client.Inventory.Store.RootFolder.UUID; - List listfolders = Client.Inventory.Store.GetContents(rootfolder); - InventoryFolder clothfolder = new InventoryFolder(UUID.Random()); - foreach (InventoryBase folder in listfolders) - { - if (folder.Name == "Clothing") - { - clothfolder = (InventoryFolder)folder; - break; - } - } - return clothfolder; - } - - public void Network_LoginProgress(object sender, LoginProgressEventArgs args) - { - if (args.Status == LoginStatus.Success) - { - if (OnConnected != null) - { - OnConnected(this, EventType.CONNECTED); - } - } - } - - public void Network_SimConnected(object sender, SimConnectedEventArgs args) - { - } - - public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) - { -// m_log.ErrorFormat("Fired Network_OnDisconnected"); - -// if ( -// (args.Reason == NetworkManager.DisconnectType.SimShutdown -// || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) -// && OnDisconnected != null) - - if ( - (args.Reason == NetworkManager.DisconnectType.ClientInitiated - || args.Reason == NetworkManager.DisconnectType.ServerInitiated - || args.Reason == NetworkManager.DisconnectType.NetworkTimeout) - && OnDisconnected != null) -// if (OnDisconnected != null) - { - IsConnected = false; - OnDisconnected(this, EventType.DISCONNECTED); - } - } - - public void Objects_NewPrim(object sender, PrimEventArgs args) - { - Primitive prim = args.Prim; - - if (prim != null) - { - lock (m_objects) - m_objects[prim.ID] = prim; - - if (prim.Textures != null) - { - if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) - { - GetTexture(prim.Textures.DefaultTexture.TextureID); - } - - for (int i = 0; i < prim.Textures.FaceTextures.Length; i++) - { - UUID textureID = prim.Textures.FaceTextures[i].TextureID; - - if (textureID != null && textureID != UUID.Zero) - { - GetTexture(textureID); - } - } - } - - if (prim.Sculpt.SculptTexture != UUID.Zero) - { - GetTexture(prim.Sculpt.SculptTexture); - } - } - } - - private void GetTexture(UUID textureID) - { - lock (BotManager.AssetsReceived) - { - // Don't request assets more than once. - if (BotManager.AssetsReceived.ContainsKey(textureID)) - return; - - BotManager.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) - { - lock (BotManager.AssetsReceived) - BotManager.AssetsReceived[asset.AssetID] = true; - -// if (wear == "save") -// { -// SaveAsset((AssetWearable) asset); -// } - } - } -} -- cgit v1.1 From e4bdf1e78ff452136908adb6556143ab6cb8fa74 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 22:50:40 +0000 Subject: actually remove the sleep from PhysicsBehaviour that I shifted to Bot a couple of commits ago --- OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs index 8d1d1ce..3ce08bf 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -75,8 +75,6 @@ namespace pCampBot string randomf = talkarray[bot.Random.Next(talkarray.Length)]; if (talkarray.Length > 1 && randomf.Length > 1) bot.Client.Self.Chat(randomf, 0, ChatType.Normal); - - Thread.Sleep(bot.Random.Next(1000, 10000)); } private string[] readexcuses() -- cgit v1.1 From 69a405713583ca309ee4c5310ae87a942e614ebe Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 Nov 2011 22:52:14 +0000 Subject: remove the pointless check of the face texture struct against null in Bot.Objects_NewPrim() --- OpenSim/Tools/pCampBot/Bot.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index bf01065..1b30766 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -449,10 +449,8 @@ namespace pCampBot { UUID textureID = prim.Textures.FaceTextures[i].TextureID; - if (textureID != null && textureID != UUID.Zero) - { + if (textureID != UUID.Zero) GetTexture(textureID); - } } } -- cgit v1.1 From 94dc7d07ebc22ce0e0d9b77e91538ddc90799bee Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 3 Nov 2011 17:06:08 -0700 Subject: Renamed ForEachRootScenePresence to ForEachAvatar. Cleaned up calls to the 3 iteration functions so more of them are using the correct iteration for the action they are performing. The 3 iterators that seem to fit all actions within OpenSim at this time are: ForEachAvatar: Perform an action on all avatars (root presences) ForEachClient: Perform an action on all clients (root or child clients) ForEachRootClient: Perform an action on all clients that have an avatar There are still a dozen places or so calling the old ForEachScenePresence that will take a little more refactoring to eliminate. --- .../Rest/Inventory/tests/Remote.cs | 2 +- .../Region/CoreModules/Avatar/Chat/ChatModule.cs | 14 ++-- .../CoreModules/Avatar/Dialog/DialogModule.cs | 8 +-- .../Region/CoreModules/Avatar/Gods/GodsModule.cs | 10 ++- .../CoreModules/LightShare/LightShareModule.cs | 49 +++++--------- .../World/Estate/EstateManagementModule.cs | 10 +-- .../Region/CoreModules/World/Land/LandObject.cs | 2 +- .../Region/CoreModules/World/Sound/SoundModule.cs | 4 +- OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 4 +- .../Region/CoreModules/World/Wind/WindModule.cs | 4 +- .../CoreModules/World/WorldMap/WorldMapModule.cs | 4 +- OpenSim/Region/Framework/Scenes/Scene.cs | 76 ++++++++++------------ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneManager.cs | 12 ++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 +++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +- .../Avatar/Appearance/AppearanceInfoModule.cs | 13 ++-- .../Avatar/Concierge/ConciergeModule.cs | 2 +- .../RegionCombinerModule/RegionCombinerModule.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 19 +++--- .../Shared/Api/Implementation/OSSL_Api.cs | 6 +- .../Api/Implementation/Plugins/SensorRepeat.cs | 4 +- 23 files changed, 121 insertions(+), 154 deletions(-) diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs index b53806c..8700786 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs @@ -148,7 +148,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests Rest.main.SceneManager.ForEachScene(delegate(Scene s) { - s.ForEachScenePresence(delegate(ScenePresence sp) + s.ForEachAvatar(delegate(ScenePresence sp) { if (sp.Firstname == names[0] && sp.Lastname == names[1]) { diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index f5cc4c3..783a03b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -228,7 +228,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat foreach (Scene s in m_scenes) { - s.ForEachScenePresence( + // This should use ForEachClient, but clients don't have a position. + // If camera is moved into client, then camera position can be used + s.ForEachAvatar( delegate(ScenePresence presence) { if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) @@ -279,11 +281,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat HashSet receiverIDs = new HashSet(); - ((Scene)c.Scene).ForEachRootScenePresence( - delegate(ScenePresence presence) + ((Scene)c.Scene).ForEachRootClient( + delegate(IClientAPI client) { - IClientAPI client = presence.ControllingClient; - // don't forward SayOwner chat from objects to // non-owner agents if ((c.Type == ChatTypeEnum.Owner) && @@ -292,8 +292,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat return; client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, - (byte)sourceType, (byte)ChatAudibleLevel.Fully); - receiverIDs.Add(presence.UUID); + (byte)sourceType, (byte)ChatAudibleLevel.Fully); + receiverIDs.Add(client.AgentId); }); (c.Scene as Scene).EventManager.TriggerOnChatToClients( diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 3ce446b..ffe7718 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -98,9 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendGeneralAlert(string message) { - m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) + m_scene.ForEachRootClient(delegate(IClientAPI client) { - presence.ControllingClient.SendAlertMessage(message); + client.SendAlertMessage(message); }); } @@ -162,9 +162,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog public void SendNotificationToUsersInRegion( UUID fromAvatarID, string fromAvatarName, string message) { - m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) + m_scene.ForEachRootClient(delegate(IClientAPI client) { - presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); + client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); }); } diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 562c3b1..2e3312f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs @@ -140,14 +140,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods // This is a bit crude. It seems the client will be null before it actually stops the thread // The thread will kill itself eventually :/ // Is there another way to make sure *all* clients get this 'inter region' message? - m_scene.ForEachRootScenePresence( - delegate(ScenePresence p) + m_scene.ForEachRootClient( + delegate(IClientAPI client) { - if (p.UUID != godID) + if (client.AgentId != godID) { - // Possibly this should really be p.Close() though that method doesn't send a close - // to the client - p.ControllingClient.Close(); + client.Close(); } } ); diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs index 2de8d7a..cabbd31 100644 --- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs @@ -145,57 +145,38 @@ namespace OpenSim.Region.CoreModules.World.LightShare param.Add(mBlock); return param; } - public void SendProfileToClient(ScenePresence presence) + + public void SendProfileToClient(IClientAPI client) { - IClientAPI client = presence.ControllingClient; - if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) - { - if (presence.IsChildAgent == false) - { - List param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings); - client.SendGenericMessage("Windlight", param); - } - } - else - { - //We probably don't want to spam chat with this.. probably - //m_log.Debug("[WINDLIGHT]: Module disabled"); - } + SendProfileToClient(client, m_scene.RegionInfo.WindlightSettings); } - public void SendProfileToClient(ScenePresence presence, RegionLightShareData wl) + + public void SendProfileToClient(IClientAPI client, RegionLightShareData wl) { - IClientAPI client = presence.ControllingClient; if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid) { - if (presence.IsChildAgent == false) - { - List param = compileWindlightSettings(wl); - client.SendGenericMessage("Windlight", param); - } - } - else - { - //We probably don't want to spam chat with this.. probably - //m_log.Debug("[WINDLIGHT]: Module disabled"); + List param = compileWindlightSettings(wl); + client.SendGenericMessage("Windlight", param); } } + private void EventManager_OnMakeRootAgent(ScenePresence presence) { m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); - SendProfileToClient(presence); + SendProfileToClient(presence.ControllingClient); } + private void EventManager_OnSendNewWindlightProfileTargeted(RegionLightShareData wl, UUID pUUID) { - ScenePresence Sc; - if (m_scene.TryGetScenePresence(pUUID,out Sc)) - { - SendProfileToClient(Sc,wl); - } + IClientAPI client; + m_scene.TryGetClient(pUUID, out client); + SendProfileToClient(client, wl); } + private void EventManager_OnSaveNewWindlightProfile() { if (m_scene.RegionInfo.WindlightSettings.valid) - m_scene.ForEachScenePresence(SendProfileToClient); + m_scene.ForEachRootClient(SendProfileToClient); } public void PostInitialise() diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 5427b68..58d9455 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -658,14 +658,14 @@ namespace OpenSim.Region.CoreModules.World.Estate if (!Scene.Permissions.CanIssueEstateCommand(remover_client.AgentId, false)) return; - Scene.ForEachRootScenePresence(delegate(ScenePresence sp) + Scene.ForEachRootClient(delegate(IClientAPI client) { - if (sp.UUID != senderID) + if (client.AgentId != senderID) { // make sure they are still there, we could be working down a long list // Also make sure they are actually in the region ScenePresence p; - if(Scene.TryGetScenePresence(sp.UUID, out p)) + if(Scene.TryGetScenePresence(client.AgentId, out p)) Scene.TeleportClientHome(p.UUID, p.ControllingClient); } }); @@ -927,9 +927,9 @@ namespace OpenSim.Region.CoreModules.World.Estate public void sendRegionInfoPacketToAll() { - Scene.ForEachRootScenePresence(delegate(ScenePresence sp) + Scene.ForEachRootClient(delegate(IClientAPI client) { - HandleRegionInfoRequest(sp.ControllingClient); + HandleRegionInfoRequest(client); }); } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 0da0de3..ff3b107 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -476,7 +476,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandUpdateToAvatarsOverMe(bool snap_selection) { - m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar) + m_scene.ForEachAvatar(delegate(ScenePresence avatar) { ILandObject over = null; try diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 93b1005..fcbc159 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.World.Sound SceneObjectGroup grp = part.ParentGroup; - m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_scene.ForEachAvatar(delegate(ScenePresence sp) { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance @@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.World.Sound } } - m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_scene.ForEachAvatar(delegate(ScenePresence sp) { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index d2c1289..a838e1e 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs @@ -488,9 +488,9 @@ namespace OpenSim.Region.CoreModules private void SunUpdateToAllClients() { - m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootClient(delegate(IClientAPI client) { - SunToClient(sp.ControllingClient); + SunToClient(client); }); } diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index bea5db1..a488725 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs @@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules m_frameLastUpdateClientArray = m_frame; } - m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_scene.ForEachRootClient(delegate(IClientAPI client) { - sp.ControllingClient.SendWindData(windSpeeds); + client.SendWindData(windSpeeds); }); } } diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 00d7d55..cd4d7e3 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -401,7 +401,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } else { - m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_scene.ForEachAvatar(delegate(ScenePresence sp) { // Don't send a green dot for yourself if (sp.UUID != remoteClient.AgentId) @@ -1180,7 +1180,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap else { OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); - m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_scene.ForEachAvatar(delegate(ScenePresence sp) { OSDMap responsemapdata = new OSDMap(); responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X)); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index dff43fd..b996e86 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -872,7 +872,7 @@ namespace OpenSim.Region.Framework.Scenes try { - ForEachRootScenePresence(delegate(ScenePresence agent) + ForEachAvatar(delegate(ScenePresence agent) { //agent.ControllingClient.new //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); @@ -1017,7 +1017,7 @@ namespace OpenSim.Region.Framework.Scenes GridRegion r = new GridRegion(region); try { - ForEachRootScenePresence(delegate(ScenePresence agent) + ForEachAvatar(delegate(ScenePresence agent) { if (m_teleportModule != null) m_teleportModule.EnableChildAgent(agent, r); @@ -1423,12 +1423,10 @@ namespace OpenSim.Region.Framework.Scenes /// Stats on the Simulator's performance private void SendSimStatsPackets(SimStats stats) { - ForEachRootScenePresence( - delegate(ScenePresence agent) - { - agent.ControllingClient.SendSimStats(stats); - } - ); + ForEachRootClient(delegate(IClientAPI client) + { + client.SendSimStats(stats); + }); } /// @@ -4214,35 +4212,32 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.GetScenePresence(localID); } + /// + /// Returns true if scene presence is a child (no avatar in this scene) + /// + /// + /// public override bool PresenceChildStatus(UUID avatarID) { - ScenePresence cp = GetScenePresence(avatarID); - - // FIXME: This is really crap - some logout code is relying on a NullReferenceException to halt its processing - // This needs to be fixed properly by cleaning up the logout code. - //if (cp != null) - // return cp.IsChildAgent; - - //return false; - - return cp.IsChildAgent; + ScenePresence sp; + return TryGetScenePresence(avatarID, out sp) && sp.IsChildAgent; } /// - /// Performs action on all ROOT (not child) scene presences. - /// This is just a shortcut function since frequently actions only appy to root SPs + /// Performs action on all avatars in the scene (root scene presences) + /// Avatars may be an NPC or a 'real' client. /// /// - public void ForEachRootScenePresence(Action action) + public void ForEachAvatar(Action action) { if(m_sceneGraph != null) { - m_sceneGraph.ForEachRootScenePresence(action); + m_sceneGraph.ForEachAvatar(action); } } /// - /// Performs action on all scene presences. + /// Performs action on all scene presences (root and child) /// /// public void ForEachScenePresence(Action action) @@ -4254,25 +4249,6 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Perform the given action for each object - /// - /// - // public void ForEachObject(Action action) - // { - // List presenceList; - // - // lock (m_sceneObjects) - // { - // presenceList = new List(m_sceneObjects.Values); - // } - // - // foreach (SceneObjectGroup presence in presenceList) - // { - // action(presence); - // } - // } - - /// /// Get a group via its UUID /// /// @@ -4344,6 +4320,22 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.TryGetAvatarByName(avatarName, out avatar); } + /// + /// Perform an action on all clients with an avatar in this scene (root only) + /// + /// + public void ForEachRootClient(Action action) + { + ForEachAvatar(delegate(ScenePresence presence) + { + action(presence.ControllingClient); + }); + } + + /// + /// Perform an action on all clients connected to the region (root and child) + /// + /// public void ForEachClient(Action action) { m_clientManager.ForEachSync(action); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 82ded28..a137bca 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1190,7 +1190,7 @@ namespace OpenSim.Region.Framework.Scenes /// This is just a shortcut function since frequently actions only appy to root SPs /// /// - public void ForEachRootScenePresence(Action action) + public void ForEachAvatar(Action action) { ForEachScenePresence(delegate(ScenePresence sp) { diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 3bfd866..9b72bee 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -458,16 +458,16 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachRootClient(delegate(IClientAPI client) { - if (name == null || scenePresence.Name == name) + if (name == null || client.Name == name) { m_log.DebugFormat("Packet debug for {0} {1} set to {2}", - scenePresence.Firstname, - scenePresence.Lastname, + client.FirstName, + client.LastName, newDebug); - scenePresence.ControllingClient.DebugPacketLevel = newDebug; + client.DebugPacketLevel = newDebug; } }); } @@ -481,7 +481,7 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + scene.ForEachAvatar(delegate(ScenePresence scenePresence) { avatars.Add(scenePresence); }); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a0a7344..3c80eb5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1150,7 +1150,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = parts[i]; - Scene.ForEachScenePresence(delegate(ScenePresence avatar) + Scene.ForEachAvatar(delegate(ScenePresence avatar) { if (avatar.ParentID == LocalId) avatar.StandUp(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 44f822c..1a709e9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -992,7 +992,7 @@ namespace OpenSim.Region.Framework.Scenes public PrimitiveBaseShape Shape { get { return m_shape; } - set { m_shape = value; } + set { m_shape = value;} } /// @@ -1336,12 +1336,12 @@ namespace OpenSim.Region.Framework.Scenes /// private void SendRootPartPropertiesToClient(UUID AgentID) { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) + m_parentGroup.Scene.ForEachClient(delegate(IClientAPI client) { // Ugly reference :( - if (avatar.UUID == AgentID) + if (client.AgentId == AgentID) { - m_parentGroup.SendPropertiesToClient(avatar.ControllingClient); + m_parentGroup.SendPropertiesToClient(client); } }); } @@ -1461,9 +1461,9 @@ namespace OpenSim.Region.Framework.Scenes if (volume < 0) volume = 0; - m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachRootClient(delegate(IClientAPI client) { - sp.ControllingClient.SendAttachedSoundGainChange(UUID, (float)volume); + client.SendAttachedSoundGainChange(UUID, (float)volume); }); } @@ -2216,7 +2216,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2347,7 +2347,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2470,7 +2470,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2696,7 +2696,7 @@ namespace OpenSim.Region.Framework.Scenes } } - m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence sp) { if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1d77b06..5fc597c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -956,7 +956,7 @@ namespace OpenSim.Region.Framework.Scenes } // send the animations of the other presences to me - m_scene.ForEachScenePresence(delegate(ScenePresence presence) + m_scene.ForEachAvatar(delegate(ScenePresence presence) { if (presence != this) presence.Animator.SendAnimPackToClient(ControllingClient); @@ -2596,7 +2596,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendOtherAgentsAvatarDataToMe() { int count = 0; - m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + m_scene.ForEachAvatar(delegate(ScenePresence scenePresence) { // only send information about other root agents if (scenePresence.UUID == UUID) @@ -2660,7 +2660,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} {1}", Name, UUID); int count = 0; - m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) + m_scene.ForEachAvatar(delegate(ScenePresence scenePresence) { // only send information about other root agents if (scenePresence.UUID == UUID) diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index f8120aa..5a3a62f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance { foreach (Scene scene in m_scenes.Values) { - scene.ForEachRootScenePresence(sp => scene.AvatarFactory.SendAppearance(sp.UUID)); + scene.ForEachAvatar(sp => scene.AvatarFactory.SendAppearance(sp.UUID)); } } } @@ -123,15 +123,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance { foreach (Scene scene in m_scenes.Values) { - scene.ForEachScenePresence( + scene.ForEachAvatar( delegate(ScenePresence sp) { - if (sp.ControllingClient is LLClientView && !((LLClientView)sp.ControllingClient).ChildAgentStatus()) - { - bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); - MainConsole.Instance.OutputFormat( - "{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); - } + bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); + MainConsole.Instance.OutputFormat( + "{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); }); } } diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index e22618d..bea5807 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs @@ -373,7 +373,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge scene.GetRootAgentCount(), scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, DateTime.UtcNow.ToString("s"))); - scene.ForEachRootScenePresence(delegate(ScenePresence sp) + scene.ForEachAvatar(delegate(ScenePresence sp) { list.Append(String.Format(" \n", sp.Name, sp.UUID)); list.Append(""); diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 92cbbc6..33abae2 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -711,7 +711,7 @@ namespace OpenSim.Region.RegionCombinerModule List CoarseLocations = new List(); List AvatarUUIDs = new List(); - connectiondata.RegionScene.ForEachRootScenePresence(delegate(ScenePresence sp) + connectiondata.RegionScene.ForEachAvatar(delegate(ScenePresence sp) { if (sp.UUID != presence.UUID) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0750579..d2ddcef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1644,7 +1644,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (flexi) { part.Shape.FlexiEntry = true; // this setting flexi true isn't working, but the below parameters do - // work once the prim is already flexi + // work once the prim is already flexi part.Shape.FlexiSoftness = softness; part.Shape.FlexiGravity = gravity; part.Shape.FlexiDrag = friction; @@ -1654,10 +1654,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.Shape.FlexiForceY = (float)Force.y; part.Shape.FlexiForceZ = (float)Force.z; part.Shape.PathCurve = 0x80; + part.ParentGroup.HasGroupChanged = true; + part.ScheduleFullUpdate(); } - - part.ParentGroup.HasGroupChanged = true; - part.ScheduleFullUpdate(); } /// @@ -3741,7 +3740,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); List keytable = new List(); // parse for sitting avatare-uuids - World.ForEachRootScenePresence(delegate(ScenePresence presence) + World.ForEachAvatar(delegate(ScenePresence presence) { if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) keytable.Add(presence.UUID); @@ -3803,7 +3802,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // parse for sitting avatare-names List nametable = new List(); - World.ForEachRootScenePresence(delegate(ScenePresence presence) + World.ForEachAvatar(delegate(ScenePresence presence) { if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) nametable.Add(presence.ControllingClient.Name); @@ -7612,7 +7611,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); int avatarCount = 0; - World.ForEachRootScenePresence(delegate(ScenePresence presence) + World.ForEachAvatar(delegate(ScenePresence presence) { if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) avatarCount++; @@ -9380,7 +9379,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api landObject.SetMediaUrl(url); // now send to all (non-child) agents in the parcel - World.ForEachRootScenePresence(delegate(ScenePresence sp) + World.ForEachAvatar(delegate(ScenePresence sp) { if (sp.currentParcelUUID == landData.GlobalID) { @@ -9413,7 +9412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence == null) { // send to all (non-child) agents in the parcel - World.ForEachRootScenePresence(delegate(ScenePresence sp) + World.ForEachAvatar(delegate(ScenePresence sp) { if (sp.currentParcelUUID == landData.GlobalID) { @@ -10528,7 +10527,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (checkAgents) { - World.ForEachScenePresence(delegate(ScenePresence sp) + World.ForEachAvatar(delegate(ScenePresence sp) { if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X)) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f3206ac..3138131 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -873,7 +873,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetAgents"); LSL_List result = new LSL_List(); - World.ForEachRootScenePresence(delegate(ScenePresence sp) + World.ForEachAvatar(delegate(ScenePresence sp) { result.Add(new LSL_String(sp.Name)); }); @@ -2581,7 +2581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) { - World.ForEachRootScenePresence(delegate(ScenePresence sp) + World.ForEachAvatar(delegate(ScenePresence sp) { if (sp.Firstname == FirstName && sp.Lastname == SurName) { @@ -2715,7 +2715,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); LSL_List result = new LSL_List(); - World.ForEachRootScenePresence(delegate (ScenePresence avatar) + World.ForEachAvatar(delegate (ScenePresence avatar) { if (avatar != null && avatar.UUID != m_host.OwnerID) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 4ac7f8b..eb05f16 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -507,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins senseEntity(sp); if ((ts.type & AGENT_BY_USERNAME) != 0) { - m_CmdManager.m_ScriptEngine.World.ForEachScenePresence( + m_CmdManager.m_ScriptEngine.World.ForEachAvatar( delegate (ScenePresence ssp) { if (ssp.Lastname == "Resident") @@ -526,7 +526,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } else { - m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(senseEntity); + m_CmdManager.m_ScriptEngine.World.ForEachAvatar(senseEntity); } return sensedEntities; } -- cgit v1.1 From b8d50b10fbb03ed8c8a9aac94564c354559c3bb0 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 3 Nov 2011 17:53:51 -0700 Subject: Rename ForEachAvatar back to ForEachScenePresence. The other changes from previous commit which sort out which iterator is used are left intact. A discussion is needed as to what constitutes an avatar vs a ScenePresence. --- OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs | 2 +- OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 2 +- OpenSim/Region/CoreModules/World/Land/LandObject.cs | 2 +- OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 4 ++-- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 4 ++-- OpenSim/Region/Framework/Scenes/Scene.cs | 8 ++++---- OpenSim/Region/Framework/Scenes/SceneManager.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++--- .../Avatar/Appearance/AppearanceInfoModule.cs | 4 ++-- .../OptionalModules/Avatar/Concierge/ConciergeModule.cs | 2 +- OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | 2 +- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++------ .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 6 +++--- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 4 ++-- 16 files changed, 35 insertions(+), 35 deletions(-) diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs index 8700786..1c1afd0 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs @@ -148,7 +148,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests Rest.main.SceneManager.ForEachScene(delegate(Scene s) { - s.ForEachAvatar(delegate(ScenePresence sp) + s.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.Firstname == names[0] && sp.Lastname == names[1]) { diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 783a03b..10b4c37 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat { // This should use ForEachClient, but clients don't have a position. // If camera is moved into client, then camera position can be used - s.ForEachAvatar( + s.ForEachRootScenePresence( delegate(ScenePresence presence) { if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index ff3b107..0da0de3 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -476,7 +476,7 @@ namespace OpenSim.Region.CoreModules.World.Land public void SendLandUpdateToAvatarsOverMe(bool snap_selection) { - m_scene.ForEachAvatar(delegate(ScenePresence avatar) + m_scene.ForEachRootScenePresence(delegate(ScenePresence avatar) { ILandObject over = null; try diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index fcbc159..93b1005 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.World.Sound SceneObjectGroup grp = part.ParentGroup; - m_scene.ForEachAvatar(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance @@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.World.Sound } } - m_scene.ForEachAvatar(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); if (dis > 100.0) // Max audio distance diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index cd4d7e3..00d7d55 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -401,7 +401,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap } else { - m_scene.ForEachAvatar(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { // Don't send a green dot for yourself if (sp.UUID != remoteClient.AgentId) @@ -1180,7 +1180,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap else { OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); - m_scene.ForEachAvatar(delegate(ScenePresence sp) + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) { OSDMap responsemapdata = new OSDMap(); responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X)); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b996e86..0832975 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -872,7 +872,7 @@ namespace OpenSim.Region.Framework.Scenes try { - ForEachAvatar(delegate(ScenePresence agent) + ForEachRootScenePresence(delegate(ScenePresence agent) { //agent.ControllingClient.new //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); @@ -1017,7 +1017,7 @@ namespace OpenSim.Region.Framework.Scenes GridRegion r = new GridRegion(region); try { - ForEachAvatar(delegate(ScenePresence agent) + ForEachRootScenePresence(delegate(ScenePresence agent) { if (m_teleportModule != null) m_teleportModule.EnableChildAgent(agent, r); @@ -4228,7 +4228,7 @@ namespace OpenSim.Region.Framework.Scenes /// Avatars may be an NPC or a 'real' client. /// /// - public void ForEachAvatar(Action action) + public void ForEachRootScenePresence(Action action) { if(m_sceneGraph != null) { @@ -4326,7 +4326,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ForEachRootClient(Action action) { - ForEachAvatar(delegate(ScenePresence presence) + ForEachRootScenePresence(delegate(ScenePresence presence) { action(presence.ControllingClient); }); diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 9b72bee..eeb087f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs @@ -481,7 +481,7 @@ namespace OpenSim.Region.Framework.Scenes ForEachCurrentScene( delegate(Scene scene) { - scene.ForEachAvatar(delegate(ScenePresence scenePresence) + scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { avatars.Add(scenePresence); }); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3c80eb5..ef2682f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1150,7 +1150,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = parts[i]; - Scene.ForEachAvatar(delegate(ScenePresence avatar) + Scene.ForEachRootScenePresence(delegate(ScenePresence avatar) { if (avatar.ParentID == LocalId) avatar.StandUp(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1a709e9..b77f1b6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2216,7 +2216,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2347,7 +2347,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2470,7 +2470,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence av) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) { if (av.LocalId == localId) { @@ -2696,7 +2696,7 @@ namespace OpenSim.Region.Framework.Scenes } } - m_parentGroup.Scene.ForEachAvatar(delegate(ScenePresence sp) + m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) { if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5fc597c..f6df3c3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -956,7 +956,7 @@ namespace OpenSim.Region.Framework.Scenes } // send the animations of the other presences to me - m_scene.ForEachAvatar(delegate(ScenePresence presence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) { if (presence != this) presence.Animator.SendAnimPackToClient(ControllingClient); @@ -2596,7 +2596,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendOtherAgentsAvatarDataToMe() { int count = 0; - m_scene.ForEachAvatar(delegate(ScenePresence scenePresence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { // only send information about other root agents if (scenePresence.UUID == UUID) @@ -2660,7 +2660,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} {1}", Name, UUID); int count = 0; - m_scene.ForEachAvatar(delegate(ScenePresence scenePresence) + m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) { // only send information about other root agents if (scenePresence.UUID == UUID) diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 5a3a62f..28f04b3 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance { foreach (Scene scene in m_scenes.Values) { - scene.ForEachAvatar(sp => scene.AvatarFactory.SendAppearance(sp.UUID)); + scene.ForEachRootScenePresence(sp => scene.AvatarFactory.SendAppearance(sp.UUID)); } } } @@ -123,7 +123,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance { foreach (Scene scene in m_scenes.Values) { - scene.ForEachAvatar( + scene.ForEachRootScenePresence( delegate(ScenePresence sp) { bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index bea5807..e22618d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs @@ -373,7 +373,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge scene.GetRootAgentCount(), scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, DateTime.UtcNow.ToString("s"))); - scene.ForEachAvatar(delegate(ScenePresence sp) + scene.ForEachRootScenePresence(delegate(ScenePresence sp) { list.Append(String.Format(" \n", sp.Name, sp.UUID)); list.Append(""); diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 33abae2..92cbbc6 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -711,7 +711,7 @@ namespace OpenSim.Region.RegionCombinerModule List CoarseLocations = new List(); List AvatarUUIDs = new List(); - connectiondata.RegionScene.ForEachAvatar(delegate(ScenePresence sp) + connectiondata.RegionScene.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.UUID != presence.UUID) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d2ddcef..5ed8c47 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3740,7 +3740,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); List keytable = new List(); // parse for sitting avatare-uuids - World.ForEachAvatar(delegate(ScenePresence presence) + World.ForEachRootScenePresence(delegate(ScenePresence presence) { if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) keytable.Add(presence.UUID); @@ -3802,7 +3802,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // parse for sitting avatare-names List nametable = new List(); - World.ForEachAvatar(delegate(ScenePresence presence) + World.ForEachRootScenePresence(delegate(ScenePresence presence) { if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) nametable.Add(presence.ControllingClient.Name); @@ -7611,7 +7611,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); int avatarCount = 0; - World.ForEachAvatar(delegate(ScenePresence presence) + World.ForEachRootScenePresence(delegate(ScenePresence presence) { if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) avatarCount++; @@ -9379,7 +9379,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api landObject.SetMediaUrl(url); // now send to all (non-child) agents in the parcel - World.ForEachAvatar(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.currentParcelUUID == landData.GlobalID) { @@ -9412,7 +9412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence == null) { // send to all (non-child) agents in the parcel - World.ForEachAvatar(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.currentParcelUUID == landData.GlobalID) { @@ -10527,7 +10527,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (checkAgents) { - World.ForEachAvatar(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X)) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3138131..f3206ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -873,7 +873,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetAgents"); LSL_List result = new LSL_List(); - World.ForEachAvatar(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { result.Add(new LSL_String(sp.Name)); }); @@ -2581,7 +2581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) { - World.ForEachAvatar(delegate(ScenePresence sp) + World.ForEachRootScenePresence(delegate(ScenePresence sp) { if (sp.Firstname == FirstName && sp.Lastname == SurName) { @@ -2715,7 +2715,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.None, "osGetAvatarList"); LSL_List result = new LSL_List(); - World.ForEachAvatar(delegate (ScenePresence avatar) + World.ForEachRootScenePresence(delegate (ScenePresence avatar) { if (avatar != null && avatar.UUID != m_host.OwnerID) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index eb05f16..5527d14 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -507,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins senseEntity(sp); if ((ts.type & AGENT_BY_USERNAME) != 0) { - m_CmdManager.m_ScriptEngine.World.ForEachAvatar( + m_CmdManager.m_ScriptEngine.World.ForEachRootScenePresence( delegate (ScenePresence ssp) { if (ssp.Lastname == "Resident") @@ -526,7 +526,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } else { - m_CmdManager.m_ScriptEngine.World.ForEachAvatar(senseEntity); + m_CmdManager.m_ScriptEngine.World.ForEachRootScenePresence(senseEntity); } return sensedEntities; } -- cgit v1.1