From b8d9737a47696952bedec33dface8f18df47341f Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 17 Sep 2007 12:52:03 +0000 Subject: fixing me some line endings --- .../Interfaces/IDynamicTextureManager.cs | 54 +- .../Region/Environment/Interfaces/IHttpRequests.cs | 24 +- .../Region/Environment/Interfaces/IRegionModule.cs | 30 +- OpenSim/Region/Environment/Interfaces/ISimChat.cs | 24 +- OpenSim/Region/Environment/Interfaces/ITerrain.cs | 92 +-- OpenSim/Region/Environment/Interfaces/IXfer.cs | 22 +- OpenSim/Region/Environment/ModuleLoader.cs | 320 ++++---- .../Environment/Modules/AssetDownloadModule.cs | 100 +-- .../Environment/Modules/AvatarProfilesModule.cs | 142 ++-- OpenSim/Region/Environment/Modules/ChatModule.cs | 432 +++++------ .../Environment/Modules/DynamicTextureModule.cs | 318 ++++---- OpenSim/Region/Environment/Modules/EmailModule.cs | 20 +- .../Region/Environment/Modules/FriendsModule.cs | 80 +- OpenSim/Region/Environment/Modules/GroupsModule.cs | 80 +- .../Environment/Modules/InstantMessageModule.cs | 80 +- .../Region/Environment/Modules/InventoryModule.cs | 80 +- .../Environment/Modules/ScriptsHttpRequests.cs | 20 +- .../Region/Environment/Modules/TeleportModule.cs | 20 +- .../Environment/Modules/TextureDownloadModule.cs | 108 +-- OpenSim/Region/Environment/Modules/XferModule.cs | 360 ++++----- OpenSim/Region/Environment/PermissionManager.cs | 610 +++++++-------- .../Region/Environment/Scenes/Scene.Inventory.cs | 854 ++++++++++----------- OpenSim/Region/Environment/Scenes/SceneManager.cs | 474 ++++++------ .../Environment/Scenes/Scripting/IScriptHost.cs | 40 +- .../Environment/Scenes/Scripting/NullScriptHost.cs | 112 +-- .../Scenes/Scripting/ScriptEngineInterface.cs | 86 +-- .../Scenes/Scripting/ScriptEngineLoader.cs | 248 +++--- .../Region/Environment/Types/BasicQuadTreeNode.cs | 334 ++++---- OpenSim/Region/Environment/Types/UpdateQueue.cs | 108 +-- 29 files changed, 2636 insertions(+), 2636 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs index 8fdfa8f..727b386 100644 --- a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs @@ -1,27 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using libsecondlife; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IDynamicTextureManager - { - void RegisterRender(string handleType, IDynamicTextureRender render); - void ReturnData(LLUUID id, byte[] data); - LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer); - LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer); - } - - public interface IDynamicTextureRender - { - string GetName(); - string GetContentType(); - bool SupportsAsynchronous(); - byte[] ConvertUrl(string url, string extraParams); - byte[] ConvertStream(Stream data, string extraParams); - bool AsyncConvertUrl(LLUUID id, string url, string extraParams); - bool AsyncConvertData(LLUUID id, string bodyData, string extraParams); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IDynamicTextureManager + { + void RegisterRender(string handleType, IDynamicTextureRender render); + void ReturnData(LLUUID id, byte[] data); + LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer); + LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer); + } + + public interface IDynamicTextureRender + { + string GetName(); + string GetContentType(); + bool SupportsAsynchronous(); + byte[] ConvertUrl(string url, string extraParams); + byte[] ConvertStream(Stream data, string extraParams); + bool AsyncConvertUrl(LLUUID id, string url, string extraParams); + bool AsyncConvertData(LLUUID id, string bodyData, string extraParams); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs index 2294631..e974e25 100644 --- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IHttpRequests - { - LLUUID MakeHttpRequest(string url, string type, string body); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IHttpRequests + { + LLUUID MakeHttpRequest(string url, string type, string body); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs index 11989fe..47f3d92 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs @@ -1,15 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IRegionModule - { - void Initialise(Scenes.Scene scene); - void PostInitialise(); - void CloseDown(); - string GetName(); - bool IsSharedModule(); - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IRegionModule + { + void Initialise(Scenes.Scene scene); + void PostInitialise(); + void CloseDown(); + string GetName(); + bool IsSharedModule(); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs index 73ef476..f0adabc 100644 --- a/OpenSim/Region/Environment/Interfaces/ISimChat.cs +++ b/OpenSim/Region/Environment/Interfaces/ISimChat.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface ISimChat - { - void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface ISimChat + { + void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/ITerrain.cs b/OpenSim/Region/Environment/Interfaces/ITerrain.cs index a07168e..576c5b4 100644 --- a/OpenSim/Region/Environment/Interfaces/ITerrain.cs +++ b/OpenSim/Region/Environment/Interfaces/ITerrain.cs @@ -1,46 +1,46 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Interfaces; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface ITerrain - { - bool Tainted(); - bool Tainted(int x, int y); - void ResetTaint(); - void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser); - void CheckHeightValues(); - float[] GetHeights1D(); - float[,] GetHeights2D(); - double[,] GetHeights2DD(); - void GetHeights1D(float[] heights); - void SetHeights2D(float[,] heights); - void SetHeights2D(double[,] heights); - void SwapRevertMaps(); - void SaveRevertMap(); - bool RunTerrainCmd(string[] args, ref string resultText, string simName); - void SetRange(float min, float max); - void LoadFromFileF64(string filename); - void LoadFromFileF32(string filename); - void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); - void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); - void LoadFromFileSLRAW(string filename); - void WriteToFileF64(string filename); - void WriteToFileF32(string filename); - void WriteToFileRAW(string filename); - void WriteToFileHiRAW(string filename); - void SetSeed(int val); - void RaiseTerrain(double rx, double ry, double size, double amount); - void LowerTerrain(double rx, double ry, double size, double amount); - void FlattenTerrain(double rx, double ry, double size, double amount); - void NoiseTerrain(double rx, double ry, double size, double amount); - void RevertTerrain(double rx, double ry, double size, double amount); - void SmoothTerrain(double rx, double ry, double size, double amount); - void HillsGenerator(); - double GetHeight(int x, int y); - void ExportImage(string filename, string gradientmap); - byte[] ExportJpegImage(string gradientmap); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface ITerrain + { + bool Tainted(); + bool Tainted(int x, int y); + void ResetTaint(); + void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser); + void CheckHeightValues(); + float[] GetHeights1D(); + float[,] GetHeights2D(); + double[,] GetHeights2DD(); + void GetHeights1D(float[] heights); + void SetHeights2D(float[,] heights); + void SetHeights2D(double[,] heights); + void SwapRevertMaps(); + void SaveRevertMap(); + bool RunTerrainCmd(string[] args, ref string resultText, string simName); + void SetRange(float min, float max); + void LoadFromFileF64(string filename); + void LoadFromFileF32(string filename); + void LoadFromFileF32(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); + void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY); + void LoadFromFileSLRAW(string filename); + void WriteToFileF64(string filename); + void WriteToFileF32(string filename); + void WriteToFileRAW(string filename); + void WriteToFileHiRAW(string filename); + void SetSeed(int val); + void RaiseTerrain(double rx, double ry, double size, double amount); + void LowerTerrain(double rx, double ry, double size, double amount); + void FlattenTerrain(double rx, double ry, double size, double amount); + void NoiseTerrain(double rx, double ry, double size, double amount); + void RevertTerrain(double rx, double ry, double size, double amount); + void SmoothTerrain(double rx, double ry, double size, double amount); + void HillsGenerator(); + double GetHeight(int x, int y); + void ExportImage(string filename, string gradientmap); + byte[] ExportJpegImage(string gradientmap); + } +} diff --git a/OpenSim/Region/Environment/Interfaces/IXfer.cs b/OpenSim/Region/Environment/Interfaces/IXfer.cs index a19ba8d..7482ec0 100644 --- a/OpenSim/Region/Environment/Interfaces/IXfer.cs +++ b/OpenSim/Region/Environment/Interfaces/IXfer.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Interfaces -{ - public interface IXfer - { - bool AddNewFile(string fileName, byte[] data); - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface IXfer + { + bool AddNewFile(string fileName, byte[] data); + } +} diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index ea416cb..5e27f50 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -1,160 +1,160 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules; - -namespace OpenSim.Region.Environment -{ - public class ModuleLoader - { - - public Dictionary LoadedAssemblys = new Dictionary(); - - public List LoadedModules = new List(); - public Dictionary LoadedSharedModules = new Dictionary(); - - public ModuleLoader() - { - - } - - /// - /// Should have a module factory? - /// - /// - public void CreateDefaultModules(Scene scene, string exceptModules) - { - IRegionModule module = new XferModule(); - InitialiseModule(module, scene); - - module = new ChatModule(); - InitialiseModule(module, scene); - - module = new AvatarProfilesModule(); - InitialiseModule(module, scene); - - this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); - - string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); - this.LoadRegionModule(lslPath, "LSLScriptingModule", scene); - - } - - - public void LoadDefaultSharedModules(string exceptModules) - { - DynamicTextureModule dynamicModule = new DynamicTextureModule(); - this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); - } - - public void InitialiseSharedModules(Scene scene) - { - foreach (IRegionModule module in this.LoadedSharedModules.Values) - { - module.Initialise(scene); - scene.AddModule(module.GetName(), module); //should be doing this? - } - } - - private void InitialiseModule(IRegionModule module, Scene scene) - { - module.Initialise(scene); - scene.AddModule(module.GetName(), module); - LoadedModules.Add(module); - } - - /// - /// Loads/initialises a Module instance that can be used by mutliple Regions - /// - /// - /// - /// - public void LoadSharedModule(string dllName, string moduleName) - { - IRegionModule module = this.LoadModule(dllName, moduleName); - if (module != null) - { - this.LoadedSharedModules.Add(module.GetName(), module); - } - } - - public void LoadRegionModule(string dllName, string moduleName, Scene scene) - { - IRegionModule module = this.LoadModule(dllName, moduleName); - if (module != null) - { - this.InitialiseModule(module, scene); - } - } - - /// - /// Loads a external Module (if not already loaded) and creates a new instance of it. - /// - /// - /// - /// - public IRegionModule LoadModule(string dllName, string moduleName) - { - Assembly pluginAssembly = null; - if (LoadedAssemblys.ContainsKey(dllName)) - { - pluginAssembly = LoadedAssemblys[dllName]; - } - else - { - pluginAssembly = Assembly.LoadFrom(dllName); - this.LoadedAssemblys.Add(dllName, pluginAssembly); - } - - IRegionModule module = null; - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IRegionModule", true); - - if (typeInterface != null) - { - module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - break; - } - typeInterface = null; - } - } - } - pluginAssembly = null; - - if ((module != null ) || (module.GetName() == moduleName)) - { - return module; - } - - return null; - - } - - public void PostInitialise() - { - foreach (IRegionModule module in this.LoadedSharedModules.Values) - { - module.PostInitialise(); - } - - foreach (IRegionModule module in this.LoadedModules) - { - module.PostInitialise(); - } - } - - public void ClearCache() - { - this.LoadedAssemblys.Clear(); - } - } -} +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules; + +namespace OpenSim.Region.Environment +{ + public class ModuleLoader + { + + public Dictionary LoadedAssemblys = new Dictionary(); + + public List LoadedModules = new List(); + public Dictionary LoadedSharedModules = new Dictionary(); + + public ModuleLoader() + { + + } + + /// + /// Should have a module factory? + /// + /// + public void CreateDefaultModules(Scene scene, string exceptModules) + { + IRegionModule module = new XferModule(); + InitialiseModule(module, scene); + + module = new ChatModule(); + InitialiseModule(module, scene); + + module = new AvatarProfilesModule(); + InitialiseModule(module, scene); + + this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); + + string lslPath = System.IO.Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.DotNetEngine.dll"); + this.LoadRegionModule(lslPath, "LSLScriptingModule", scene); + + } + + + public void LoadDefaultSharedModules(string exceptModules) + { + DynamicTextureModule dynamicModule = new DynamicTextureModule(); + this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); + } + + public void InitialiseSharedModules(Scene scene) + { + foreach (IRegionModule module in this.LoadedSharedModules.Values) + { + module.Initialise(scene); + scene.AddModule(module.GetName(), module); //should be doing this? + } + } + + private void InitialiseModule(IRegionModule module, Scene scene) + { + module.Initialise(scene); + scene.AddModule(module.GetName(), module); + LoadedModules.Add(module); + } + + /// + /// Loads/initialises a Module instance that can be used by mutliple Regions + /// + /// + /// + /// + public void LoadSharedModule(string dllName, string moduleName) + { + IRegionModule module = this.LoadModule(dllName, moduleName); + if (module != null) + { + this.LoadedSharedModules.Add(module.GetName(), module); + } + } + + public void LoadRegionModule(string dllName, string moduleName, Scene scene) + { + IRegionModule module = this.LoadModule(dllName, moduleName); + if (module != null) + { + this.InitialiseModule(module, scene); + } + } + + /// + /// Loads a external Module (if not already loaded) and creates a new instance of it. + /// + /// + /// + /// + public IRegionModule LoadModule(string dllName, string moduleName) + { + Assembly pluginAssembly = null; + if (LoadedAssemblys.ContainsKey(dllName)) + { + pluginAssembly = LoadedAssemblys[dllName]; + } + else + { + pluginAssembly = Assembly.LoadFrom(dllName); + this.LoadedAssemblys.Add(dllName, pluginAssembly); + } + + IRegionModule module = null; + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IRegionModule", true); + + if (typeInterface != null) + { + module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + break; + } + typeInterface = null; + } + } + } + pluginAssembly = null; + + if ((module != null ) || (module.GetName() == moduleName)) + { + return module; + } + + return null; + + } + + public void PostInitialise() + { + foreach (IRegionModule module in this.LoadedSharedModules.Values) + { + module.PostInitialise(); + } + + foreach (IRegionModule module in this.LoadedModules) + { + module.PostInitialise(); + } + } + + public void ClearCache() + { + this.LoadedAssemblys.Clear(); + } + } +} diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs index 21a7e61..7a53f6f 100644 --- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs @@ -1,50 +1,50 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class AssetDownloadModule : IRegionModule - { - private Scene m_scene; - - public AssetDownloadModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "AssetDownloadModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class AssetDownloadModule : IRegionModule + { + private Scene m_scene; + + public AssetDownloadModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "AssetDownloadModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + } + } +} diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs index 1ad061a..c349888 100644 --- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs @@ -1,71 +1,71 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class AvatarProfilesModule :IRegionModule - { - - private Scene m_scene; - - public AvatarProfilesModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - - } - - public string GetName() - { - return "AvatarProfilesModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - client.OnRequestAvatarProperties += RequestAvatarProperty; - } - - public void RemoveClient(IClientAPI client) - { - client.OnRequestAvatarProperties -= RequestAvatarProperty; - } - - /// - /// - /// - /// - /// - public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) - { - string about = "OpenSim crash test dummy"; - string bornOn = "Before now"; - string flAbout = "First life? What is one of those? OpenSim is my life!"; - LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class AvatarProfilesModule :IRegionModule + { + + private Scene m_scene; + + public AvatarProfilesModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + + } + + public string GetName() + { + return "AvatarProfilesModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + client.OnRequestAvatarProperties += RequestAvatarProperty; + } + + public void RemoveClient(IClientAPI client) + { + client.OnRequestAvatarProperties -= RequestAvatarProperty; + } + + /// + /// + /// + /// + /// + public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) + { + string about = "OpenSim crash test dummy"; + string bornOn = "Before now"; + string flAbout = "First life? What is one of those? OpenSim is my life!"; + LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); + remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); + } + } +} diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index a46343b..8d3a553 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -1,216 +1,216 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.IO; -using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Console; - -namespace OpenSim.Region.Environment.Modules -{ - public class ChatModule : IRegionModule, ISimChat - { - private Scene m_scene; - - private string m_server = "irc2.choopa.net"; - - // private int m_port = 6668; - //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; - private string m_nick = "OSimBot"; - private string m_channel = "#opensim"; - - // private NetworkStream m_stream; - private TcpClient m_irc; - private StreamWriter m_ircWriter; - private StreamReader m_ircReader; - - // private Thread pingSender; - // private Thread listener; - - private bool connected = false; - - public ChatModule() - { - m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); - m_irc = null; - m_ircWriter = null; - m_ircReader = null; - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - - m_scene.RegisterModuleInterface(this); - } - - public void PostInitialise() - { - /* - try - { - m_irc = new TcpClient(m_server, m_port); - m_stream = m_irc.GetStream(); - m_ircReader = new StreamReader(m_stream); - m_ircWriter = new StreamWriter(m_stream); - - pingSender = new Thread(new ThreadStart(this.PingRun)); - pingSender.Start(); - - listener = new Thread(new ThreadStart(this.ListenerRun)); - listener.Start(); - - m_ircWriter.WriteLine(m_user); - m_ircWriter.Flush(); - m_ircWriter.WriteLine("NICK " + m_nick); - m_ircWriter.Flush(); - m_ircWriter.WriteLine("JOIN " + m_channel); - m_ircWriter.Flush(); - connected = true; - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - */ - } - - public void CloseDown() - { - m_ircWriter.Close(); - m_ircReader.Close(); - m_irc.Close(); - } - - public string GetName() - { - return "ChatModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - client.OnChatFromViewer += SimChat; - } - - public void PingRun() - { - while (true) - { - m_ircWriter.WriteLine("PING :" + m_server); - m_ircWriter.Flush(); - Thread.Sleep(15000); - } - } - - public void ListenerRun() - { - string inputLine; - LLVector3 pos = new LLVector3(128, 128, 20); - while (true) - { - while ((inputLine = m_ircReader.ReadLine()) != null) - { - Console.WriteLine(inputLine); - if (inputLine.Contains(m_channel)) - { - string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - presence.ControllingClient.SendChatMessage(Helpers.StringToField(mess), 255, pos, "IRC:", - LLUUID.Zero); - }); - } - } - } - } - - public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) - { - ScenePresence avatar = null; - avatar = m_scene.RequestAvatar(fromAgentID); - if (avatar != null) - { - fromPos = avatar.AbsolutePosition; - fromName = avatar.Firstname + " " + avatar.Lastname; - avatar = null; - } - - if (connected) - { - m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + - Util.FieldToString(message)); - m_ircWriter.Flush(); - } - - if (channel == 0) - { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - int dis = -1000; - - //err ??? the following code seems to be request a scenePresence when it already has a ref to it - avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId); - if (avatar != null) - { - dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); - } - - switch (type) - { - case 0: // Whisper - if ((dis < 10) && (dis > -10)) - { - //should change so the message is sent through the avatar rather than direct to the ClientView - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case 1: // Say - if ((dis < 30) && (dis > -30)) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case 2: // Shout - if ((dis < 100) && (dis > -100)) - { - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - - case 0xff: // Broadcast - presence.ControllingClient.SendChatMessage(message, type, - fromPos, - fromName, - fromAgentID); - break; - } - }); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.IO; +using libsecondlife; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Console; + +namespace OpenSim.Region.Environment.Modules +{ + public class ChatModule : IRegionModule, ISimChat + { + private Scene m_scene; + + private string m_server = "irc2.choopa.net"; + + // private int m_port = 6668; + //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; + private string m_nick = "OSimBot"; + private string m_channel = "#opensim"; + + // private NetworkStream m_stream; + private TcpClient m_irc; + private StreamWriter m_ircWriter; + private StreamReader m_ircReader; + + // private Thread pingSender; + // private Thread listener; + + private bool connected = false; + + public ChatModule() + { + m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); + m_irc = null; + m_ircWriter = null; + m_ircReader = null; + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() + { + /* + try + { + m_irc = new TcpClient(m_server, m_port); + m_stream = m_irc.GetStream(); + m_ircReader = new StreamReader(m_stream); + m_ircWriter = new StreamWriter(m_stream); + + pingSender = new Thread(new ThreadStart(this.PingRun)); + pingSender.Start(); + + listener = new Thread(new ThreadStart(this.ListenerRun)); + listener.Start(); + + m_ircWriter.WriteLine(m_user); + m_ircWriter.Flush(); + m_ircWriter.WriteLine("NICK " + m_nick); + m_ircWriter.Flush(); + m_ircWriter.WriteLine("JOIN " + m_channel); + m_ircWriter.Flush(); + connected = true; + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + */ + } + + public void CloseDown() + { + m_ircWriter.Close(); + m_ircReader.Close(); + m_irc.Close(); + } + + public string GetName() + { + return "ChatModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + client.OnChatFromViewer += SimChat; + } + + public void PingRun() + { + while (true) + { + m_ircWriter.WriteLine("PING :" + m_server); + m_ircWriter.Flush(); + Thread.Sleep(15000); + } + } + + public void ListenerRun() + { + string inputLine; + LLVector3 pos = new LLVector3(128, 128, 20); + while (true) + { + while ((inputLine = m_ircReader.ReadLine()) != null) + { + Console.WriteLine(inputLine); + if (inputLine.Contains(m_channel)) + { + string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + presence.ControllingClient.SendChatMessage(Helpers.StringToField(mess), 255, pos, "IRC:", + LLUUID.Zero); + }); + } + } + } + } + + public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, LLUUID fromAgentID) + { + ScenePresence avatar = null; + avatar = m_scene.RequestAvatar(fromAgentID); + if (avatar != null) + { + fromPos = avatar.AbsolutePosition; + fromName = avatar.Firstname + " " + avatar.Lastname; + avatar = null; + } + + if (connected) + { + m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + + Util.FieldToString(message)); + m_ircWriter.Flush(); + } + + if (channel == 0) + { + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + int dis = -1000; + + //err ??? the following code seems to be request a scenePresence when it already has a ref to it + avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId); + if (avatar != null) + { + dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); + } + + switch (type) + { + case 0: // Whisper + if ((dis < 10) && (dis > -10)) + { + //should change so the message is sent through the avatar rather than direct to the ClientView + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case 1: // Say + if ((dis < 30) && (dis > -30)) + { + //Console.WriteLine("sending chat"); + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case 2: // Shout + if ((dis < 100) && (dis > -100)) + { + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + + case 0xff: // Broadcast + presence.ControllingClient.SendChatMessage(message, type, + fromPos, + fromName, + fromAgentID); + break; + } + }); + } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index 8223919..bbd9810 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs @@ -1,159 +1,159 @@ -using System.Text; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.IO; -using System.Collections.Generic; -using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Framework.Console; -using OpenSim.Framework.Types; - -namespace OpenSim.Region.Environment.Modules -{ - public class DynamicTextureModule :IRegionModule, IDynamicTextureManager - { - private Dictionary RegisteredScenes = new Dictionary(); - private Dictionary RenderPlugins= new Dictionary(); - private Dictionary Updaters = new Dictionary(); - - public void Initialise(Scene scene) - { - if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID)) - { - RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene); - scene.RegisterModuleInterface(this); - } - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "DynamicTextureModule"; - } - - public bool IsSharedModule() - { - return true; - } - - public void RegisterRender(string handleType, IDynamicTextureRender render) - { - if (!RenderPlugins.ContainsKey(handleType)) - { - RenderPlugins.Add(handleType, render); - } - } - - public void ReturnData(LLUUID id, byte[] data) - { - if (Updaters.ContainsKey(id)) - { - DynamicTextureUpdater updater = Updaters[id]; - if (RegisteredScenes.ContainsKey(updater.SimUUID)) - { - Scene scene = RegisteredScenes[updater.SimUUID]; - updater.DataReceived(data, scene); - } - } - } - - public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer) - { - System.Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); - if (this.RenderPlugins.ContainsKey(contentType)) - { - DynamicTextureUpdater updater = new DynamicTextureUpdater(); - updater.SimUUID = simID; - updater.PrimID = primID; - updater.ContentType = contentType; - updater.Url = url; - updater.UpdateTimer = updateTimer; - updater.UpdaterID = LLUUID.Random(); - updater.Params = extraParams; - - if (!this.Updaters.ContainsKey(updater.UpdaterID)) - { - Updaters.Add(updater.UpdaterID, updater); - } - - RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); - return updater.UpdaterID; - } - return LLUUID.Zero; - } - - public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer) - { - if (this.RenderPlugins.ContainsKey(contentType)) - { - DynamicTextureUpdater updater = new DynamicTextureUpdater(); - updater.SimUUID = simID; - updater.PrimID = primID; - updater.ContentType = contentType; - updater.BodyData = data; - updater.UpdateTimer = updateTimer; - updater.UpdaterID = LLUUID.Random(); - updater.Params = extraParams; - - if (!this.Updaters.ContainsKey(updater.UpdaterID)) - { - Updaters.Add(updater.UpdaterID, updater); - } - - RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); - return updater.UpdaterID; - } - return LLUUID.Zero; - } - - public class DynamicTextureUpdater - { - public LLUUID SimUUID; - public LLUUID UpdaterID; - public string ContentType; - public string Url; - public string BodyData; - public LLUUID PrimID; - public int UpdateTimer; - public LLUUID LastAssetID; - public string Params; - - public DynamicTextureUpdater() - { - LastAssetID = LLUUID.Zero; - UpdateTimer = 0; - BodyData = null; - } - - public void DataReceived(byte[] data, Scene scene) - { - //TODO delete the last asset(data), if it was a dynamic texture - - AssetBase asset = new AssetBase(); - asset.FullID = LLUUID.Random(); - asset.Data = data; - asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); - asset.Type = 0; - scene.commsManager.AssetCache.AddAsset(asset); - - this.LastAssetID = asset.FullID; - - SceneObjectPart part = scene.GetSceneObjectPart(PrimID); - part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); - part.ScheduleFullUpdate(); - } - } - } -} +using System.Text; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.IO; +using System.Collections.Generic; +using libsecondlife; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Framework.Console; +using OpenSim.Framework.Types; + +namespace OpenSim.Region.Environment.Modules +{ + public class DynamicTextureModule :IRegionModule, IDynamicTextureManager + { + private Dictionary RegisteredScenes = new Dictionary(); + private Dictionary RenderPlugins= new Dictionary(); + private Dictionary Updaters = new Dictionary(); + + public void Initialise(Scene scene) + { + if (!RegisteredScenes.ContainsKey(scene.RegionInfo.SimUUID)) + { + RegisteredScenes.Add(scene.RegionInfo.SimUUID, scene); + scene.RegisterModuleInterface(this); + } + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "DynamicTextureModule"; + } + + public bool IsSharedModule() + { + return true; + } + + public void RegisterRender(string handleType, IDynamicTextureRender render) + { + if (!RenderPlugins.ContainsKey(handleType)) + { + RenderPlugins.Add(handleType, render); + } + } + + public void ReturnData(LLUUID id, byte[] data) + { + if (Updaters.ContainsKey(id)) + { + DynamicTextureUpdater updater = Updaters[id]; + if (RegisteredScenes.ContainsKey(updater.SimUUID)) + { + Scene scene = RegisteredScenes[updater.SimUUID]; + updater.DataReceived(data, scene); + } + } + } + + public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, string extraParams, int updateTimer) + { + System.Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); + if (this.RenderPlugins.ContainsKey(contentType)) + { + DynamicTextureUpdater updater = new DynamicTextureUpdater(); + updater.SimUUID = simID; + updater.PrimID = primID; + updater.ContentType = contentType; + updater.Url = url; + updater.UpdateTimer = updateTimer; + updater.UpdaterID = LLUUID.Random(); + updater.Params = extraParams; + + if (!this.Updaters.ContainsKey(updater.UpdaterID)) + { + Updaters.Add(updater.UpdaterID, updater); + } + + RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); + return updater.UpdaterID; + } + return LLUUID.Zero; + } + + public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, string extraParams, int updateTimer) + { + if (this.RenderPlugins.ContainsKey(contentType)) + { + DynamicTextureUpdater updater = new DynamicTextureUpdater(); + updater.SimUUID = simID; + updater.PrimID = primID; + updater.ContentType = contentType; + updater.BodyData = data; + updater.UpdateTimer = updateTimer; + updater.UpdaterID = LLUUID.Random(); + updater.Params = extraParams; + + if (!this.Updaters.ContainsKey(updater.UpdaterID)) + { + Updaters.Add(updater.UpdaterID, updater); + } + + RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); + return updater.UpdaterID; + } + return LLUUID.Zero; + } + + public class DynamicTextureUpdater + { + public LLUUID SimUUID; + public LLUUID UpdaterID; + public string ContentType; + public string Url; + public string BodyData; + public LLUUID PrimID; + public int UpdateTimer; + public LLUUID LastAssetID; + public string Params; + + public DynamicTextureUpdater() + { + LastAssetID = LLUUID.Zero; + UpdateTimer = 0; + BodyData = null; + } + + public void DataReceived(byte[] data, Scene scene) + { + //TODO delete the last asset(data), if it was a dynamic texture + + AssetBase asset = new AssetBase(); + asset.FullID = LLUUID.Random(); + asset.Data = data; + asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); + asset.Type = 0; + scene.commsManager.AssetCache.AddAsset(asset); + + this.LastAssetID = asset.FullID; + + SceneObjectPart part = scene.GetSceneObjectPart(PrimID); + part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); + part.ScheduleFullUpdate(); + } + } + } +} diff --git a/OpenSim/Region/Environment/Modules/EmailModule.cs b/OpenSim/Region/Environment/Modules/EmailModule.cs index 2a90dd3..fff9539 100644 --- a/OpenSim/Region/Environment/Modules/EmailModule.cs +++ b/OpenSim/Region/Environment/Modules/EmailModule.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Modules -{ - class EmailModule - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Modules +{ + class EmailModule + { + } +} diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs index d46039c..411b838 100644 --- a/OpenSim/Region/Environment/Modules/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class FriendsModule : IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "FriendsModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class FriendsModule : IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "FriendsModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs index 8e4b409..9ed0e96 100644 --- a/OpenSim/Region/Environment/Modules/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class GroupsModule : IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "GroupsModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} - +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class GroupsModule : IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "GroupsModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} + diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index acf031b..25c118a 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class InstantMessageModule :IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "InstantMessageModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class InstantMessageModule :IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "InstantMessageModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/InventoryModule.cs index 00b4d8e..bfcb7d7 100644 --- a/OpenSim/Region/Environment/Modules/InventoryModule.cs +++ b/OpenSim/Region/Environment/Modules/InventoryModule.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - - -namespace OpenSim.Region.Environment.Modules -{ - public class InventoryModule :IRegionModule - { - private Scene m_scene; - - public void Initialise(Scene scene) - { - m_scene = scene; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "InventoryModule"; - } - - public bool IsSharedModule() - { - return false; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + + +namespace OpenSim.Region.Environment.Modules +{ + public class InventoryModule :IRegionModule + { + private Scene m_scene; + + public void Initialise(Scene scene) + { + m_scene = scene; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "InventoryModule"; + } + + public bool IsSharedModule() + { + return false; + } + } +} diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index 11af718..e47cc9e 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Modules -{ - class ScriptsHttpRequests - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Modules +{ + class ScriptsHttpRequests + { + } +} diff --git a/OpenSim/Region/Environment/Modules/TeleportModule.cs b/OpenSim/Region/Environment/Modules/TeleportModule.cs index 08fc202..1c01b27 100644 --- a/OpenSim/Region/Environment/Modules/TeleportModule.cs +++ b/OpenSim/Region/Environment/Modules/TeleportModule.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Environment.Modules -{ - class TeleportModule - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.Environment.Modules +{ + class TeleportModule + { + } +} diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 7d31644..59c0839 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -1,54 +1,54 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class TextureDownloadModule :IRegionModule - { - private Scene m_scene; - - public TextureDownloadModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - } - - public string GetName() - { - return "TextureDownloadModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - } - - public void TextureAssetCallback(LLUUID texture, byte[] data) - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class TextureDownloadModule :IRegionModule + { + private Scene m_scene; + + public TextureDownloadModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + } + + public string GetName() + { + return "TextureDownloadModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + } + + public void TextureAssetCallback(LLUUID texture, byte[] data) + { + + } + } +} diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs index 44b4d7a..216d10a 100644 --- a/OpenSim/Region/Environment/Modules/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/XferModule.cs @@ -1,180 +1,180 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; - -namespace OpenSim.Region.Environment.Modules -{ - public class XferModule : IRegionModule, IXfer - { - public Dictionary NewFiles = new Dictionary(); - public Dictionary Transfers = new Dictionary(); - - private Scene m_scene; - - public XferModule() - { - - } - - public void Initialise(Scene scene) - { - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - - m_scene.RegisterModuleInterface(this); - } - - public void PostInitialise() - { - - } - - public void CloseDown() - { - - } - - public string GetName() - { - return "XferModule"; - } - - public bool IsSharedModule() - { - return false; - } - - public void NewClient(IClientAPI client) - { - client.OnRequestXfer += RequestXfer; - client.OnConfirmXfer += AckPacket; - } - - /// - /// - /// - /// - /// - /// - public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) - { - lock (NewFiles) - { - if (NewFiles.ContainsKey(fileName)) - { - if (!Transfers.ContainsKey(xferID)) - { - byte[] fileData = NewFiles[fileName]; - XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); - Transfers.Add(xferID, transaction); - NewFiles.Remove(fileName); - transaction.StartSend(); - } - } - } - } - - public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) - { - if (this.Transfers.ContainsKey(xferID)) - { - Transfers[xferID].AckPacket(packet); - } - } - - public bool AddNewFile(string fileName, byte[] data) - { - lock (NewFiles) - { - if (NewFiles.ContainsKey(fileName)) - { - NewFiles[fileName] = data; - } - else - { - NewFiles.Add(fileName, data); - } - } - return true; - } - - - public class XferDownLoad - { - public byte[] Data = new byte[0]; - public string FileName = ""; - public ulong XferID = 0; - public int DataPointer = 0; - public uint Packet = 0; - public IClientAPI Client; - public uint Serial = 1; - private bool complete = false; - - public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) - { - FileName = fileName; - Data = data; - XferID = xferID; - Client = client; - } - - public XferDownLoad() - { - - } - - public void StartSend() - { - if (Data.Length < 1000) - { - // for now (testing ) we only support files under 1000 bytes - byte[] transferData = new byte[Data.Length + 4]; - Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); - Array.Copy(Data, 0, transferData, 4, Data.Length); - Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); - complete = true; - } - else - { - byte[] transferData = new byte[1000 +4]; - Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); - Array.Copy(Data, 0, transferData, 4, 1000); - Client.SendXferPacket(XferID, 0 , transferData); - Packet++; - DataPointer = 1000; - } - } - - public void AckPacket(uint packet) - { - if (!complete) - { - if ((Data.Length - DataPointer) > 1000) - { - byte[] transferData = new byte[1000]; - Array.Copy(Data, DataPointer, transferData, 0, 1000); - Client.SendXferPacket(XferID, Packet, transferData); - Packet++; - DataPointer += 1000; - } - else - { - byte[] transferData = new byte[Data.Length - DataPointer]; - Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); - uint endPacket = Packet |= (uint)0x80000000; - Client.SendXferPacket(XferID, endPacket, transferData); - Packet++; - DataPointer += (Data.Length - DataPointer); - complete = true; - } - } - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; + +namespace OpenSim.Region.Environment.Modules +{ + public class XferModule : IRegionModule, IXfer + { + public Dictionary NewFiles = new Dictionary(); + public Dictionary Transfers = new Dictionary(); + + private Scene m_scene; + + public XferModule() + { + + } + + public void Initialise(Scene scene) + { + m_scene = scene; + m_scene.EventManager.OnNewClient += NewClient; + + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + + } + + public string GetName() + { + return "XferModule"; + } + + public bool IsSharedModule() + { + return false; + } + + public void NewClient(IClientAPI client) + { + client.OnRequestXfer += RequestXfer; + client.OnConfirmXfer += AckPacket; + } + + /// + /// + /// + /// + /// + /// + public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) + { + lock (NewFiles) + { + if (NewFiles.ContainsKey(fileName)) + { + if (!Transfers.ContainsKey(xferID)) + { + byte[] fileData = NewFiles[fileName]; + XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); + Transfers.Add(xferID, transaction); + NewFiles.Remove(fileName); + transaction.StartSend(); + } + } + } + } + + public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) + { + if (this.Transfers.ContainsKey(xferID)) + { + Transfers[xferID].AckPacket(packet); + } + } + + public bool AddNewFile(string fileName, byte[] data) + { + lock (NewFiles) + { + if (NewFiles.ContainsKey(fileName)) + { + NewFiles[fileName] = data; + } + else + { + NewFiles.Add(fileName, data); + } + } + return true; + } + + + public class XferDownLoad + { + public byte[] Data = new byte[0]; + public string FileName = ""; + public ulong XferID = 0; + public int DataPointer = 0; + public uint Packet = 0; + public IClientAPI Client; + public uint Serial = 1; + private bool complete = false; + + public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) + { + FileName = fileName; + Data = data; + XferID = xferID; + Client = client; + } + + public XferDownLoad() + { + + } + + public void StartSend() + { + if (Data.Length < 1000) + { + // for now (testing ) we only support files under 1000 bytes + byte[] transferData = new byte[Data.Length + 4]; + Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); + Array.Copy(Data, 0, transferData, 4, Data.Length); + Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); + complete = true; + } + else + { + byte[] transferData = new byte[1000 +4]; + Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); + Array.Copy(Data, 0, transferData, 4, 1000); + Client.SendXferPacket(XferID, 0 , transferData); + Packet++; + DataPointer = 1000; + } + } + + public void AckPacket(uint packet) + { + if (!complete) + { + if ((Data.Length - DataPointer) > 1000) + { + byte[] transferData = new byte[1000]; + Array.Copy(Data, DataPointer, transferData, 0, 1000); + Client.SendXferPacket(XferID, Packet, transferData); + Packet++; + DataPointer += 1000; + } + else + { + byte[] transferData = new byte[Data.Length - DataPointer]; + Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); + uint endPacket = Packet |= (uint)0x80000000; + Client.SendXferPacket(XferID, endPacket, transferData); + Packet++; + DataPointer += (Data.Length - DataPointer); + complete = true; + } + } + } + } + } +} diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 110a130..cb455f4 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -1,305 +1,305 @@ -using System.Collections.Generic; -using OpenSim.Framework; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; - -using libsecondlife; - -namespace OpenSim.Region.Environment -{ - public class PermissionManager - { - protected Scene m_scene; - - // Bypasses the permissions engine (always returns OK) - // disable in any production environment - // TODO: Change this to false when permissions are a desired default - // TODO: Move to configuration option. - private bool m_bypassPermissions = true; - public bool BypassPermissions - { - get { return m_bypassPermissions; } - set { m_bypassPermissions = value; } - } - - - public PermissionManager(Scene scene) - { - m_scene = scene; - } - - protected virtual void SendPermissionError(LLUUID user, string reason) - { - m_scene.EventManager.TriggerPermissionError(user, reason); - } - - protected virtual bool IsAdministrator(LLUUID user) - { - if (m_bypassPermissions) - { - return true; - } - - return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; - } - - protected virtual bool IsEstateManager(LLUUID user) - { - if (m_bypassPermissions) - { - return true; - } - - return false; - } - - protected virtual bool IsGridUser(LLUUID user) - { - return true; - } - - protected virtual bool IsGuest(LLUUID user) - { - return false; - } - - public virtual bool CanRezObject(LLUUID user, LLVector3 position) - { - bool permission = false; - - string reason = "Insufficient permission"; - - if (IsAdministrator(user)) - { - permission = true; - } - else - { - reason = "Not an administrator"; - } - - if (GenericParcelPermission(user, position)) - { - permission = true; - } - else - { - reason = "Not the parcel owner"; - } - - if (!permission) - SendPermissionError(user, reason); - - return permission; - } - - #region Object Permissions - - protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) - { - // Default: deny - bool permission = false; - - if( !m_scene.Entities.ContainsKey( objId )) - { - return false; - } - - // If it's not an object, we cant edit it. - if (!(m_scene.Entities[objId] is SceneObjectGroup)) - { - return false; - } - - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId]; - LLUUID taskOwner = null; - - // Object owners should be able to edit their own content - if (user == taskOwner) - permission = true; - - // Users should be able to edit what is over their land. - if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == user) - permission = true; - - // Estate users should be able to edit anything in the sim - if (IsEstateManager(user)) - permission = true; - - // Admin objects should not be editable by the above - if (IsAdministrator(taskOwner)) - permission = false; - - // Admin should be able to edit anything in the sim (including admin objects) - if (IsAdministrator(user)) - permission = true; - - return permission; - } - - /// - /// Permissions check - can user delete an object? - /// - /// User attempting the delete - /// Target object - /// Has permission? - public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) - { - return GenericObjectPermission(user, obj); - } - - public virtual bool CanEditObject(LLUUID user, LLUUID obj) - { - return GenericObjectPermission(user, obj); - } - - public virtual bool CanReturnObject(LLUUID user, LLUUID obj) - { - return GenericObjectPermission(user, obj); - } - - #endregion - - #region Communication Permissions - - public virtual bool GenericCommunicationPermission(LLUUID user, LLUUID target) - { - bool permission = false; - string reason = "Only registered users may communicate with another account."; - - if (IsGridUser(user)) - permission = true; - - if (!IsGridUser(user)) - { - permission = false; - reason = "The person that you are messaging is not a registered user."; - } - if (IsAdministrator(user)) - permission = true; - - if (IsEstateManager(user)) - permission = true; - - if (!permission) - SendPermissionError(user, reason); - - return permission; - } - - public virtual bool CanInstantMessage(LLUUID user, LLUUID target) - { - return GenericCommunicationPermission(user, target); - } - - public virtual bool CanInventoryTransfer(LLUUID user, LLUUID target) - { - return GenericCommunicationPermission(user, target); - } - - #endregion - - public virtual bool CanEditScript(LLUUID user, LLUUID script) - { - return IsAdministrator(user); - } - - public virtual bool CanRunScript(LLUUID user, LLUUID script) - { - return IsAdministrator(user); - } - - public virtual bool CanTerraform(LLUUID user, LLVector3 position) - { - bool permission = false; - - // Estate override - if (GenericEstatePermission(user)) - permission = true; - - // Land owner can terraform too - if (GenericParcelPermission(user, m_scene.LandManager.getLandObject(position.X, position.Y))) - permission = true; - - if (!permission) - SendPermissionError(user, "Not authorized to terraform at this location."); - - return permission; - } - - #region Estate Permissions - - protected virtual bool GenericEstatePermission(LLUUID user) - { - // Default: deny - bool permission = false; - - // Estate admins should be able to use estate tools - if (IsEstateManager(user)) - permission = true; - - // Administrators always have permission - if (IsAdministrator(user)) - permission = true; - - return permission; - } - - public virtual bool CanEditEstateTerrain(LLUUID user) - { - return GenericEstatePermission(user); - } - - #endregion - - #region Parcel Permissions - - protected virtual bool GenericParcelPermission(LLUUID user, Land parcel) - { - bool permission = false; - - if (parcel.landData.ownerID == user) - permission = true; - - if (parcel.landData.isGroupOwned) - { - // TODO: Need to do some extra checks here. Requires group code. - } - - if(IsEstateManager(user)) - permission = true; - - if (IsAdministrator(user)) - permission = true; - - return permission; - } - - protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos) - { - return GenericParcelPermission(user, m_scene.LandManager.getLandObject(pos.X, pos.Y)); - } - - public virtual bool CanEditParcel(LLUUID user, Land parcel) - { - return GenericParcelPermission(user, parcel); - } - - public virtual bool CanSellParcel(LLUUID user, Land parcel) - { - return GenericParcelPermission(user, parcel); - } - - public virtual bool CanAbandonParcel(LLUUID user, Land parcel) - { - return GenericParcelPermission(user, parcel); - } - - #endregion - - } -} +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Framework.Types; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers; +using OpenSim.Region.Capabilities; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.LandManagement; + +using libsecondlife; + +namespace OpenSim.Region.Environment +{ + public class PermissionManager + { + protected Scene m_scene; + + // Bypasses the permissions engine (always returns OK) + // disable in any production environment + // TODO: Change this to false when permissions are a desired default + // TODO: Move to configuration option. + private bool m_bypassPermissions = true; + public bool BypassPermissions + { + get { return m_bypassPermissions; } + set { m_bypassPermissions = value; } + } + + + public PermissionManager(Scene scene) + { + m_scene = scene; + } + + protected virtual void SendPermissionError(LLUUID user, string reason) + { + m_scene.EventManager.TriggerPermissionError(user, reason); + } + + protected virtual bool IsAdministrator(LLUUID user) + { + if (m_bypassPermissions) + { + return true; + } + + return m_scene.RegionInfo.MasterAvatarAssignedUUID == user; + } + + protected virtual bool IsEstateManager(LLUUID user) + { + if (m_bypassPermissions) + { + return true; + } + + return false; + } + + protected virtual bool IsGridUser(LLUUID user) + { + return true; + } + + protected virtual bool IsGuest(LLUUID user) + { + return false; + } + + public virtual bool CanRezObject(LLUUID user, LLVector3 position) + { + bool permission = false; + + string reason = "Insufficient permission"; + + if (IsAdministrator(user)) + { + permission = true; + } + else + { + reason = "Not an administrator"; + } + + if (GenericParcelPermission(user, position)) + { + permission = true; + } + else + { + reason = "Not the parcel owner"; + } + + if (!permission) + SendPermissionError(user, reason); + + return permission; + } + + #region Object Permissions + + protected virtual bool GenericObjectPermission(LLUUID user, LLUUID objId) + { + // Default: deny + bool permission = false; + + if( !m_scene.Entities.ContainsKey( objId )) + { + return false; + } + + // If it's not an object, we cant edit it. + if (!(m_scene.Entities[objId] is SceneObjectGroup)) + { + return false; + } + + SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objId]; + LLUUID taskOwner = null; + + // Object owners should be able to edit their own content + if (user == taskOwner) + permission = true; + + // Users should be able to edit what is over their land. + if (m_scene.LandManager.getLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y).landData.ownerID == user) + permission = true; + + // Estate users should be able to edit anything in the sim + if (IsEstateManager(user)) + permission = true; + + // Admin objects should not be editable by the above + if (IsAdministrator(taskOwner)) + permission = false; + + // Admin should be able to edit anything in the sim (including admin objects) + if (IsAdministrator(user)) + permission = true; + + return permission; + } + + /// + /// Permissions check - can user delete an object? + /// + /// User attempting the delete + /// Target object + /// Has permission? + public virtual bool CanDeRezObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); + } + + public virtual bool CanEditObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); + } + + public virtual bool CanReturnObject(LLUUID user, LLUUID obj) + { + return GenericObjectPermission(user, obj); + } + + #endregion + + #region Communication Permissions + + public virtual bool GenericCommunicationPermission(LLUUID user, LLUUID target) + { + bool permission = false; + string reason = "Only registered users may communicate with another account."; + + if (IsGridUser(user)) + permission = true; + + if (!IsGridUser(user)) + { + permission = false; + reason = "The person that you are messaging is not a registered user."; + } + if (IsAdministrator(user)) + permission = true; + + if (IsEstateManager(user)) + permission = true; + + if (!permission) + SendPermissionError(user, reason); + + return permission; + } + + public virtual bool CanInstantMessage(LLUUID user, LLUUID target) + { + return GenericCommunicationPermission(user, target); + } + + public virtual bool CanInventoryTransfer(LLUUID user, LLUUID target) + { + return GenericCommunicationPermission(user, target); + } + + #endregion + + public virtual bool CanEditScript(LLUUID user, LLUUID script) + { + return IsAdministrator(user); + } + + public virtual bool CanRunScript(LLUUID user, LLUUID script) + { + return IsAdministrator(user); + } + + public virtual bool CanTerraform(LLUUID user, LLVector3 position) + { + bool permission = false; + + // Estate override + if (GenericEstatePermission(user)) + permission = true; + + // Land owner can terraform too + if (GenericParcelPermission(user, m_scene.LandManager.getLandObject(position.X, position.Y))) + permission = true; + + if (!permission) + SendPermissionError(user, "Not authorized to terraform at this location."); + + return permission; + } + + #region Estate Permissions + + protected virtual bool GenericEstatePermission(LLUUID user) + { + // Default: deny + bool permission = false; + + // Estate admins should be able to use estate tools + if (IsEstateManager(user)) + permission = true; + + // Administrators always have permission + if (IsAdministrator(user)) + permission = true; + + return permission; + } + + public virtual bool CanEditEstateTerrain(LLUUID user) + { + return GenericEstatePermission(user); + } + + #endregion + + #region Parcel Permissions + + protected virtual bool GenericParcelPermission(LLUUID user, Land parcel) + { + bool permission = false; + + if (parcel.landData.ownerID == user) + permission = true; + + if (parcel.landData.isGroupOwned) + { + // TODO: Need to do some extra checks here. Requires group code. + } + + if(IsEstateManager(user)) + permission = true; + + if (IsAdministrator(user)) + permission = true; + + return permission; + } + + protected virtual bool GenericParcelPermission(LLUUID user, LLVector3 pos) + { + return GenericParcelPermission(user, m_scene.LandManager.getLandObject(pos.X, pos.Y)); + } + + public virtual bool CanEditParcel(LLUUID user, Land parcel) + { + return GenericParcelPermission(user, parcel); + } + + public virtual bool CanSellParcel(LLUUID user, Land parcel) + { + return GenericParcelPermission(user, parcel); + } + + public virtual bool CanAbandonParcel(LLUUID user, Land parcel) + { + return GenericParcelPermission(user, parcel); + } + + #endregion + + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 70b34cf..a259dd0 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1,427 +1,427 @@ -using System; -using System.IO; -using System.Collections.Generic; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Framework.Communications.Caches; -using OpenSim.Framework.Data; -using OpenSim.Framework.Utilities; -using OpenSim.Region.Physics.Manager; - -namespace OpenSim.Region.Environment.Scenes -{ - public partial class Scene - { - //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete - // or at least some of they can be moved somewhere else - - public void AddInventoryItem(LLUUID userID, InventoryItemBase item) - { - if (this.Avatars.ContainsKey(userID)) - { - this.AddInventoryItem(this.Avatars[userID].ControllingClient, item); - } - } - - public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - userInfo.AddItem(remoteClient.AgentId, item); - remoteClient.SendInventoryItemUpdate(item); - } - } - - public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) - { - if (this.Avatars.ContainsKey(userID)) - { - return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data); - } - return LLUUID.Zero; - } - - public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - AssetBase asset; - asset = new AssetBase(); - asset.FullID = LLUUID.Random(); - asset.Type = (sbyte)item.assetType; - asset.InvType = (sbyte)item.invType; - asset.Name = item.inventoryName; - asset.Data = data; - commsManager.AssetCache.AddAsset(asset); - - item.assetID = asset.FullID; - userInfo.UpdateItem(remoteClient.AgentId, item); - - // remoteClient.SendInventoryItemUpdate(item); - if (item.invType == 7) - { - //do we want to know about updated note cards? - } - else if (item.invType == 10) - { - // do we want to know about updated scripts - } - - return (asset.FullID); - } - } - } - return LLUUID.Zero; - } - - public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); - if (transactions != null) - { - AssetBase asset = null; - bool addToCache = false; - - asset = commsManager.AssetCache.GetAsset(assetID); - if (asset == null) - { - asset = transactions.GetTransactionAsset(transactionID); - addToCache = true; - } - - if (asset != null) - { - if (asset.FullID == assetID) - { - asset.Name = item.inventoryName; - asset.Description = item.inventoryDescription; - asset.InvType = (sbyte)item.invType; - asset.Type = (sbyte)item.assetType; - item.assetID = asset.FullID; - - if (addToCache) - { - commsManager.AssetCache.AddAsset(asset); - } - - userInfo.UpdateItem(remoteClient.AgentId, item); - } - } - } - } - } - } - } - - /// - /// temporary method to test out creating new inventory items - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) - { - if (transActionID == LLUUID.Zero) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - AssetBase asset = new AssetBase(); - asset.Name = name; - asset.Description = description; - asset.InvType = invType; - asset.Type = type; - asset.FullID = LLUUID.Random(); - asset.Data = new byte[1]; - this.commsManager.AssetCache.AddAsset(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.avatarID = remoteClient.AgentId; - item.creatorsID = remoteClient.AgentId; - item.inventoryID = LLUUID.Random(); - item.assetID = asset.FullID; - item.inventoryDescription = description; - item.inventoryName = name; - item.assetType = invType; - item.invType = invType; - item.parentFolderID = folderID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = nextOwnerMask; - - userInfo.AddItem(remoteClient.AgentId, item); - remoteClient.SendInventoryItemUpdate(item); - } - } - else - { - commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); - //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); - } - } - - /// - /// - /// - /// - /// - public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) - { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); - if (hasPrim != false) - { - bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); - if (fileChange) - { - if (this.XferManager != null) - { - ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, XferManager); - } - } - break; - } - } - } - } - - public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) - { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); - if (hasPrim != false) - { - int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID); - ((SceneObjectGroup)ent).GetProperites(remoteClient); - if (type == 10) - { - this.EventManager.TriggerRemoveScript(localID, itemID); - } - } - } - } - } - - public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - LLUUID copyID = LLUUID.Random(); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - bool isTexture = false; - bool rezzed = false; - if (item.invType == 0) - { - isTexture = true; - } - AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); - if (rezAsset != null) - { - string script = Util.FieldToString(rezAsset.Data); - //Console.WriteLine("rez script "+script); - this.EventManager.TriggerRezScript(localID, copyID, script); - rezzed = true; - } - else - { - //lets try once more incase the asset cache is being slow getting the asset from server - rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); - if (rezAsset != null) - { - string script = Util.FieldToString(rezAsset.Data); - // Console.WriteLine("rez script " + script); - this.EventManager.TriggerRezScript(localID, copyID, script); - rezzed = true; - } - } - - if (rezzed) - { - bool hasPrim = false; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObjectGroup) - { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); - if (hasPrim != false) - { - - bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item, copyID); - ((SceneObjectGroup)ent).GetProperites(remoteClient); - } - } - } - } - } - } - } - } - - /// - /// - /// - /// - /// - public void DeRezObject(Packet packet, IClientAPI remoteClient) - { - DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; - - if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) - { - //currently following code not used (or don't know of any case of destination being zero - } - else - { - foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) - { - EntityBase selectedEnt = null; - //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); - foreach (EntityBase ent in this.Entities.Values) - { - if (ent.LocalId == Data.ObjectLocalID) - { - selectedEnt = ent; - break; - } - } - if (selectedEnt != null) - { - if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID)) - { - string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString(); - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - AssetBase asset = new AssetBase(); - asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId); - asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId); - asset.InvType = 6; - asset.Type = 6; - asset.FullID = LLUUID.Random(); - asset.Data = Helpers.StringToField(sceneObjectXml); - commsManager.AssetCache.AddAsset(asset); - - - InventoryItemBase item = new InventoryItemBase(); - item.avatarID = remoteClient.AgentId; - item.creatorsID = remoteClient.AgentId; - item.inventoryID = LLUUID.Random(); - item.assetID = asset.FullID; - item.inventoryDescription = asset.Description; - item.inventoryName = asset.Name; - item.assetType = asset.Type; - item.invType = asset.InvType; - item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; - item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = 2147483647; - - userInfo.AddItem(remoteClient.AgentId, item); - remoteClient.SendInventoryItemUpdate(item); - } - - SceneObjectPart rootPart = ((SceneObjectGroup)selectedEnt).GetChildPart(((SceneObjectGroup)selectedEnt).UUID); - if (rootPart.PhysActor != null) - { - this.phyScene.RemovePrim(rootPart.PhysActor); - rootPart.PhysActor = null; - } - - storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID); - ((SceneObjectGroup)selectedEnt).DeleteGroup(); - - lock (Entities) - { - Entities.Remove(((SceneObjectGroup)selectedEnt).UUID); - } - ((SceneObjectGroup)selectedEnt).DeleteParts(); - } - } - } - } - } - - public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) - { - CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); - if (userInfo != null) - { - if (userInfo.RootFolder != null) - { - InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); - if (item != null) - { - AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); - if (rezAsset != null) - { - this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); - userInfo.DeleteItem(remoteClient.AgentId, item); - remoteClient.SendRemoveInventoryItem(itemID); - } - else - { - //lets try once more incase the asset cache is being slow getting the asset from server - rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); - if (rezAsset != null) - { - this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); - userInfo.DeleteItem(remoteClient.AgentId, item); - remoteClient.SendRemoveInventoryItem(itemID); - } - } - } - } - } - } - - private void AddRezObject(string xmlData, LLVector3 pos) - { - SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData); - this.AddEntity(group); - group.AbsolutePosition = pos; - SceneObjectPart rootPart = group.GetChildPart(group.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) - rootPart.PhysActor = phyScene.AddPrim( - new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), - new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); - } - } - -} +using System; +using System.IO; +using System.Collections.Generic; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Framework.Communications.Caches; +using OpenSim.Framework.Data; +using OpenSim.Framework.Utilities; +using OpenSim.Region.Physics.Manager; + +namespace OpenSim.Region.Environment.Scenes +{ + public partial class Scene + { + //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete + // or at least some of they can be moved somewhere else + + public void AddInventoryItem(LLUUID userID, InventoryItemBase item) + { + if (this.Avatars.ContainsKey(userID)) + { + this.AddInventoryItem(this.Avatars[userID].ControllingClient, item); + } + } + + public void AddInventoryItem(IClientAPI remoteClient, InventoryItemBase item) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + userInfo.AddItem(remoteClient.AgentId, item); + remoteClient.SendInventoryItemUpdate(item); + } + } + + public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data) + { + if (this.Avatars.ContainsKey(userID)) + { + return this.CapsUpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data); + } + return LLUUID.Zero; + } + + public LLUUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + AssetBase asset; + asset = new AssetBase(); + asset.FullID = LLUUID.Random(); + asset.Type = (sbyte)item.assetType; + asset.InvType = (sbyte)item.invType; + asset.Name = item.inventoryName; + asset.Data = data; + commsManager.AssetCache.AddAsset(asset); + + item.assetID = asset.FullID; + userInfo.UpdateItem(remoteClient.AgentId, item); + + // remoteClient.SendInventoryItemUpdate(item); + if (item.invType == 7) + { + //do we want to know about updated note cards? + } + else if (item.invType == 10) + { + // do we want to know about updated scripts + } + + return (asset.FullID); + } + } + } + return LLUUID.Zero; + } + + public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + AgentAssetTransactions transactions = commsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); + if (transactions != null) + { + AssetBase asset = null; + bool addToCache = false; + + asset = commsManager.AssetCache.GetAsset(assetID); + if (asset == null) + { + asset = transactions.GetTransactionAsset(transactionID); + addToCache = true; + } + + if (asset != null) + { + if (asset.FullID == assetID) + { + asset.Name = item.inventoryName; + asset.Description = item.inventoryDescription; + asset.InvType = (sbyte)item.invType; + asset.Type = (sbyte)item.assetType; + item.assetID = asset.FullID; + + if (addToCache) + { + commsManager.AssetCache.AddAsset(asset); + } + + userInfo.UpdateItem(remoteClient.AgentId, item); + } + } + } + } + } + } + } + + /// + /// temporary method to test out creating new inventory items + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + { + if (transActionID == LLUUID.Zero) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + AssetBase asset = new AssetBase(); + asset.Name = name; + asset.Description = description; + asset.InvType = invType; + asset.Type = type; + asset.FullID = LLUUID.Random(); + asset.Data = new byte[1]; + this.commsManager.AssetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = remoteClient.AgentId; + item.creatorsID = remoteClient.AgentId; + item.inventoryID = LLUUID.Random(); + item.assetID = asset.FullID; + item.inventoryDescription = description; + item.inventoryName = name; + item.assetType = invType; + item.invType = invType; + item.parentFolderID = folderID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = nextOwnerMask; + + userInfo.AddItem(remoteClient.AgentId, item); + remoteClient.SendInventoryItemUpdate(item); + } + } + else + { + commsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); + } + } + + /// + /// + /// + /// + /// + public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) + { + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + if (hasPrim != false) + { + bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); + if (fileChange) + { + if (this.XferManager != null) + { + ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, XferManager); + } + } + break; + } + } + } + } + + public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID) + { + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) + { + int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID); + ((SceneObjectGroup)ent).GetProperites(remoteClient); + if (type == 10) + { + this.EventManager.TriggerRemoveScript(localID, itemID); + } + } + } + } + } + + public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + LLUUID copyID = LLUUID.Random(); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + bool isTexture = false; + bool rezzed = false; + if (item.invType == 0) + { + isTexture = true; + } + AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); + if (rezAsset != null) + { + string script = Util.FieldToString(rezAsset.Data); + //Console.WriteLine("rez script "+script); + this.EventManager.TriggerRezScript(localID, copyID, script); + rezzed = true; + } + else + { + //lets try once more incase the asset cache is being slow getting the asset from server + rezAsset = commsManager.AssetCache.GetAsset(item.assetID, isTexture); + if (rezAsset != null) + { + string script = Util.FieldToString(rezAsset.Data); + // Console.WriteLine("rez script " + script); + this.EventManager.TriggerRezScript(localID, copyID, script); + rezzed = true; + } + } + + if (rezzed) + { + bool hasPrim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) + { + + bool added = ((SceneObjectGroup)ent).AddInventoryItem(remoteClient, localID, item, copyID); + ((SceneObjectGroup)ent).GetProperites(remoteClient); + } + } + } + } + } + } + } + } + + /// + /// + /// + /// + /// + public void DeRezObject(Packet packet, IClientAPI remoteClient) + { + DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; + + if (DeRezPacket.AgentBlock.DestinationID == LLUUID.Zero) + { + //currently following code not used (or don't know of any case of destination being zero + } + else + { + foreach (DeRezObjectPacket.ObjectDataBlock Data in DeRezPacket.ObjectData) + { + EntityBase selectedEnt = null; + //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LocalID:" + Data.ObjectLocalID.ToString()); + foreach (EntityBase ent in this.Entities.Values) + { + if (ent.LocalId == Data.ObjectLocalID) + { + selectedEnt = ent; + break; + } + } + if (selectedEnt != null) + { + if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup)selectedEnt).UUID)) + { + string sceneObjectXml = ((SceneObjectGroup)selectedEnt).ToXmlString(); + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + AssetBase asset = new AssetBase(); + asset.Name = ((SceneObjectGroup)selectedEnt).GetPartName(selectedEnt.LocalId); + asset.Description = ((SceneObjectGroup)selectedEnt).GetPartDescription(selectedEnt.LocalId); + asset.InvType = 6; + asset.Type = 6; + asset.FullID = LLUUID.Random(); + asset.Data = Helpers.StringToField(sceneObjectXml); + commsManager.AssetCache.AddAsset(asset); + + + InventoryItemBase item = new InventoryItemBase(); + item.avatarID = remoteClient.AgentId; + item.creatorsID = remoteClient.AgentId; + item.inventoryID = LLUUID.Random(); + item.assetID = asset.FullID; + item.inventoryDescription = asset.Description; + item.inventoryName = asset.Name; + item.assetType = asset.Type; + item.invType = asset.InvType; + item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; + item.inventoryCurrentPermissions = 2147483647; + item.inventoryNextPermissions = 2147483647; + + userInfo.AddItem(remoteClient.AgentId, item); + remoteClient.SendInventoryItemUpdate(item); + } + + SceneObjectPart rootPart = ((SceneObjectGroup)selectedEnt).GetChildPart(((SceneObjectGroup)selectedEnt).UUID); + if (rootPart.PhysActor != null) + { + this.phyScene.RemovePrim(rootPart.PhysActor); + rootPart.PhysActor = null; + } + + storageManager.DataStore.RemoveObject(((SceneObjectGroup)selectedEnt).UUID, m_regInfo.SimUUID); + ((SceneObjectGroup)selectedEnt).DeleteGroup(); + + lock (Entities) + { + Entities.Remove(((SceneObjectGroup)selectedEnt).UUID); + } + ((SceneObjectGroup)selectedEnt).DeleteParts(); + } + } + } + } + } + + public void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos) + { + CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + if (userInfo.RootFolder != null) + { + InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); + if (item != null) + { + AssetBase rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); + if (rezAsset != null) + { + this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); + userInfo.DeleteItem(remoteClient.AgentId, item); + remoteClient.SendRemoveInventoryItem(itemID); + } + else + { + //lets try once more incase the asset cache is being slow getting the asset from server + rezAsset = commsManager.AssetCache.GetAsset(item.assetID, false); + if (rezAsset != null) + { + this.AddRezObject(Util.FieldToString(rezAsset.Data), pos); + userInfo.DeleteItem(remoteClient.AgentId, item); + remoteClient.SendRemoveInventoryItem(itemID); + } + } + } + } + } + } + + private void AddRezObject(string xmlData, LLVector3 pos) + { + SceneObjectGroup group = new SceneObjectGroup(this, this.m_regionHandle, xmlData); + this.AddEntity(group); + group.AbsolutePosition = pos; + SceneObjectPart rootPart = group.GetChildPart(group.UUID); + if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + rootPart.PhysActor = phyScene.AddPrim( + new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), + new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), + new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, + rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); + } + } + +} diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index dfac406..4a99a80 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -1,237 +1,237 @@ -using System.Collections.Generic; -using System; -using OpenSim.Framework.Console; -using OpenSim.Framework.Types; - -namespace OpenSim.Region.Environment.Scenes -{ - public class SceneManager - { - private readonly List m_localScenes; - private Scene m_currentScene = null; - public Scene CurrentScene - { - get - { - return m_currentScene; - } - } - - private Scene CurrentOrFirstScene - { - get - { - if (m_currentScene == null) - { - return m_localScenes[0]; - } - else - { - return m_currentScene; - } - } - } - - public SceneManager() - { - m_localScenes = new List(); - } - - public void Close() - { - for (int i = 0; i < m_localScenes.Count; i++) - { - m_localScenes[i].Close(); - } - } - - public void Add(Scene scene) - { - m_localScenes.Add(scene); - } - - public void SavePrimsToXml(string filename) - { - CurrentOrFirstScene.SavePrimsToXml(filename); - } - - public void LoadPrimsFromXml(string filename) - { - CurrentOrFirstScene.LoadPrimsFromXml(filename); - } - - public bool RunTerrainCmd(string[] cmdparams, ref string result) - { - if (m_currentScene == null) - { - bool success = true; - foreach (Scene scene in m_localScenes) - { - if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName)) - { - success = false; - } - } - - return success; - } - else - { - return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName); - } - } - - public void SendCommandToScripts(string[] cmdparams) - { - ForEach(delegate(Scene scene) - { - scene.SendCommandToScripts(cmdparams); - }); - } - - public void BypassPermissions(bool bypassPermissions) - { - ForEach(delegate(Scene scene) - { - scene.PermissionsMngr.BypassPermissions = bypassPermissions; - }); - } - - private void ForEach(Action func) - { - if (m_currentScene == null) - { - m_localScenes.ForEach(func); - } - else - { - func(m_currentScene); - } - } - - public void Backup() - { - ForEach(delegate(Scene scene) - { - scene.Backup(); - }); - } - - public void HandleAlertCommand(string[] cmdparams) - { - ForEach(delegate(Scene scene) - { - scene.HandleAlertCommand(cmdparams); - }); - } - - public bool TrySetCurrentRegion(string regionName) - { - if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) - { - m_currentScene = null; - return true; - } - else - { - Console.WriteLine("Searching for Region: '" + regionName + "'"); - Scene foundScene = null; - - foreach (Scene scene in m_localScenes) - { - if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) - { - m_currentScene = scene; - return true; - } - } - - return false; - } - } - - public void DebugPacket(LogBase log, int newDebug) - { - ForEach(delegate(Scene scene) - { - foreach (EntityBase entity in scene.Entities.Values) - { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.childAgent) - { - log.Error(String.Format("Packet debug for {0} {1} set to {2}", - scenePrescence.Firstname, scenePrescence.Lastname, - newDebug)); - - scenePrescence.ControllingClient.SetDebug(newDebug); - } - } - } - }); - } - - public List GetAvatars() - { - List avatars = new List(); - - ForEach(delegate(Scene scene) - { - foreach (EntityBase entity in scene.Entities.Values) - { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.childAgent) - { - avatars.Add(scenePrescence); - } - } - } - }); - - return avatars; - } - - public RegionInfo GetRegionInfo(ulong regionHandle) - { - foreach (Scene scene in m_localScenes) - { - if (scene.RegionInfo.RegionHandle == regionHandle) - { - return scene.RegionInfo; - } - } - - return null; - } - - public void SetTimePhase(int timePhase) - { - ForEach(delegate(Scene scene) - { - scene.SetTimePhase( - timePhase) - ; - }); - } - - - public void ForceClientUpdate() - { - ForEach(delegate(Scene scene) - { - scene.ForceClientUpdate(); - }); - } - - public void HandleEditCommand(string[] cmdparams) - { - ForEach(delegate(Scene scene) - { - scene.HandleEditCommand(cmdparams); - }); - } - } -} +using System.Collections.Generic; +using System; +using OpenSim.Framework.Console; +using OpenSim.Framework.Types; + +namespace OpenSim.Region.Environment.Scenes +{ + public class SceneManager + { + private readonly List m_localScenes; + private Scene m_currentScene = null; + public Scene CurrentScene + { + get + { + return m_currentScene; + } + } + + private Scene CurrentOrFirstScene + { + get + { + if (m_currentScene == null) + { + return m_localScenes[0]; + } + else + { + return m_currentScene; + } + } + } + + public SceneManager() + { + m_localScenes = new List(); + } + + public void Close() + { + for (int i = 0; i < m_localScenes.Count; i++) + { + m_localScenes[i].Close(); + } + } + + public void Add(Scene scene) + { + m_localScenes.Add(scene); + } + + public void SavePrimsToXml(string filename) + { + CurrentOrFirstScene.SavePrimsToXml(filename); + } + + public void LoadPrimsFromXml(string filename) + { + CurrentOrFirstScene.LoadPrimsFromXml(filename); + } + + public bool RunTerrainCmd(string[] cmdparams, ref string result) + { + if (m_currentScene == null) + { + bool success = true; + foreach (Scene scene in m_localScenes) + { + if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName)) + { + success = false; + } + } + + return success; + } + else + { + return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName); + } + } + + public void SendCommandToScripts(string[] cmdparams) + { + ForEach(delegate(Scene scene) + { + scene.SendCommandToScripts(cmdparams); + }); + } + + public void BypassPermissions(bool bypassPermissions) + { + ForEach(delegate(Scene scene) + { + scene.PermissionsMngr.BypassPermissions = bypassPermissions; + }); + } + + private void ForEach(Action func) + { + if (m_currentScene == null) + { + m_localScenes.ForEach(func); + } + else + { + func(m_currentScene); + } + } + + public void Backup() + { + ForEach(delegate(Scene scene) + { + scene.Backup(); + }); + } + + public void HandleAlertCommand(string[] cmdparams) + { + ForEach(delegate(Scene scene) + { + scene.HandleAlertCommand(cmdparams); + }); + } + + public bool TrySetCurrentRegion(string regionName) + { + if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) + { + m_currentScene = null; + return true; + } + else + { + Console.WriteLine("Searching for Region: '" + regionName + "'"); + Scene foundScene = null; + + foreach (Scene scene in m_localScenes) + { + if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) + { + m_currentScene = scene; + return true; + } + } + + return false; + } + } + + public void DebugPacket(LogBase log, int newDebug) + { + ForEach(delegate(Scene scene) + { + foreach (EntityBase entity in scene.Entities.Values) + { + if (entity is ScenePresence) + { + ScenePresence scenePrescence = entity as ScenePresence; + if (!scenePrescence.childAgent) + { + log.Error(String.Format("Packet debug for {0} {1} set to {2}", + scenePrescence.Firstname, scenePrescence.Lastname, + newDebug)); + + scenePrescence.ControllingClient.SetDebug(newDebug); + } + } + } + }); + } + + public List GetAvatars() + { + List avatars = new List(); + + ForEach(delegate(Scene scene) + { + foreach (EntityBase entity in scene.Entities.Values) + { + if (entity is ScenePresence) + { + ScenePresence scenePrescence = entity as ScenePresence; + if (!scenePrescence.childAgent) + { + avatars.Add(scenePrescence); + } + } + } + }); + + return avatars; + } + + public RegionInfo GetRegionInfo(ulong regionHandle) + { + foreach (Scene scene in m_localScenes) + { + if (scene.RegionInfo.RegionHandle == regionHandle) + { + return scene.RegionInfo; + } + } + + return null; + } + + public void SetTimePhase(int timePhase) + { + ForEach(delegate(Scene scene) + { + scene.SetTimePhase( + timePhase) + ; + }); + } + + + public void ForceClientUpdate() + { + ForEach(delegate(Scene scene) + { + scene.ForceClientUpdate(); + }); + } + + public void HandleEditCommand(string[] cmdparams) + { + ForEach(delegate(Scene scene) + { + scene.HandleEditCommand(cmdparams); + }); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs index 2f248ce..7cf9cb7 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public interface IScriptHost - { - string Name { get; set;} - string SitName{ get; set;} - string TouchName { get; set;} - string Description { get; set; } - LLUUID UUID { get; } - LLUUID ObjectOwner { get;} - LLUUID ObjectCreator { get; } - LLVector3 AbsolutePosition { get; } - void SetText(string text, Axiom.Math.Vector3 color, double alpha); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public interface IScriptHost + { + string Name { get; set;} + string SitName{ get; set;} + string TouchName { get; set;} + string Description { get; set; } + LLUUID UUID { get; } + LLUUID ObjectOwner { get;} + LLUUID ObjectCreator { get; } + LLVector3 AbsolutePosition { get; } + void SetText(string text, Axiom.Math.Vector3 color, double alpha); + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs index 5e3dcae..875e4cb 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs @@ -1,56 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public class NullScriptHost : IScriptHost - { - - LLVector3 m_pos = new LLVector3( 128, 128, 30 ); - public string Name - { - get { return "Object"; } - set { } - } - - public string SitName - { - get { return ""; } - set { } - } - - public string TouchName - { - get { return ""; } - set { } - } - - public string Description - { - get { return ""; } - set { } - } - - public LLUUID UUID - { - get { return LLUUID.Zero; } - } - - public LLUUID ObjectOwner - { get { return LLUUID.Zero; } } - - public LLUUID ObjectCreator { get { return LLUUID.Zero; } } - - public LLVector3 AbsolutePosition - { - get { return m_pos; } - } - - public void SetText(string text, Axiom.Math.Vector3 color, double alpha) - { - Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public class NullScriptHost : IScriptHost + { + + LLVector3 m_pos = new LLVector3( 128, 128, 30 ); + public string Name + { + get { return "Object"; } + set { } + } + + public string SitName + { + get { return ""; } + set { } + } + + public string TouchName + { + get { return ""; } + set { } + } + + public string Description + { + get { return ""; } + set { } + } + + public LLUUID UUID + { + get { return LLUUID.Zero; } + } + + public LLUUID ObjectOwner + { get { return LLUUID.Zero; } } + + public LLUUID ObjectCreator { get { return LLUUID.Zero; } } + + public LLVector3 AbsolutePosition + { + get { return m_pos; } + } + + public void SetText(string text, Axiom.Math.Vector3 color, double alpha) + { + Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs index d3d58fe..5e8ff87 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs @@ -1,43 +1,43 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -/* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes.Scripting; - -//TODO: WHERE TO PLACE THIS? -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public interface ScriptEngineInterface - { - void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger); - void Shutdown(); -// void StartScript(string ScriptID, IScriptHost ObjectID); - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +/* Original code: Tedd Hansen */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes.Scripting; + +//TODO: WHERE TO PLACE THIS? +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public interface ScriptEngineInterface + { + void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger); + void Shutdown(); +// void StartScript(string ScriptID, IScriptHost ObjectID); + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs index 3500545..83bd0ab 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs @@ -1,124 +1,124 @@ -/* -* Copyright (c) Contributors, http://opensimulator.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -/* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Reflection; - -namespace OpenSim.Region.Environment.Scenes.Scripting -{ - public class ScriptEngineLoader - { - private OpenSim.Framework.Console.LogBase m_log; - public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger) - { - m_log = logger; - } - - public ScriptEngineInterface LoadScriptEngine(string EngineName) - { - ScriptEngineInterface ret = null; - try - { - ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), - "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); - } - catch (Exception e) - { - m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); - } - return ret; - } - - /// - /// Does actual loading and initialization of script Assembly - /// - /// AppDomain to load script into - /// FileName of script assembly (.dll) - /// - private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) - { - //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); - // Load .Net Assembly (.dll) - // Initialize and return it - - // TODO: Add error handling - - Assembly a; - //try - //{ - - - // Load to default appdomain (temporary) - a = Assembly.LoadFrom(FileName); - // Load to specified appdomain - // TODO: Insert security - //a = FreeAppDomain.Load(FileName); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); - //} - - - //Console.WriteLine("Loading: " + FileName); - //foreach (Type _t in a.GetTypes()) - //{ - // Console.WriteLine("Type: " + _t.ToString()); - //} - - Type t; - //try - //{ - t = a.GetType(NameSpace, true); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); - //} - - ScriptEngineInterface ret; - //try - //{ - ret = (ScriptEngineInterface)Activator.CreateInstance(t); - //} - //catch (Exception e) - //{ - // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); - //} - - return ret; - - - } - - - } -} +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +/* Original code: Tedd Hansen */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Reflection; + +namespace OpenSim.Region.Environment.Scenes.Scripting +{ + public class ScriptEngineLoader + { + private OpenSim.Framework.Console.LogBase m_log; + public ScriptEngineLoader(OpenSim.Framework.Console.LogBase logger) + { + m_log = logger; + } + + public ScriptEngineInterface LoadScriptEngine(string EngineName) + { + ScriptEngineInterface ret = null; + try + { + ret = LoadAndInitAssembly(Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"), + "OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine"); + } + catch (Exception e) + { + m_log.Error("ScriptEngine", "Error loading assembly \"" + EngineName + "\": " + e.Message + ", " + e.StackTrace.ToString()); + } + return ret; + } + + /// + /// Does actual loading and initialization of script Assembly + /// + /// AppDomain to load script into + /// FileName of script assembly (.dll) + /// + private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace) + { + //Common.SendToDebug("Loading ScriptEngine Assembly " + FileName); + // Load .Net Assembly (.dll) + // Initialize and return it + + // TODO: Add error handling + + Assembly a; + //try + //{ + + + // Load to default appdomain (temporary) + a = Assembly.LoadFrom(FileName); + // Load to specified appdomain + // TODO: Insert security + //a = FreeAppDomain.Load(FileName); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error loading assembly \"" + FileName + "\": " + e.ToString()); + //} + + + //Console.WriteLine("Loading: " + FileName); + //foreach (Type _t in a.GetTypes()) + //{ + // Console.WriteLine("Type: " + _t.ToString()); + //} + + Type t; + //try + //{ + t = a.GetType(NameSpace, true); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); + //} + + ScriptEngineInterface ret; + //try + //{ + ret = (ScriptEngineInterface)Activator.CreateInstance(t); + //} + //catch (Exception e) + //{ + // m_log.Error("ScriptEngine", "Error initializing type \"" + NameSpace + "\" from \"" + FileName + "\": " + e.ToString()); + //} + + return ret; + + + } + + + } +} diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs index c7b0524..3b4dd9a 100644 --- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs +++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs @@ -1,167 +1,167 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Environment.Types -{ - public class BasicQuadTreeNode - { - private List m_objects = new List(); - private BasicQuadTreeNode[] m_childNodes = null; - private BasicQuadTreeNode m_parent = null; - - private short m_leftX; - private short m_leftY; - private short m_width; - private short m_height; - - public BasicQuadTreeNode(BasicQuadTreeNode parent, short leftX, short leftY, short width, short height) - { - m_parent = parent; - m_leftX = leftX; - m_leftY = leftY; - m_width = width; - m_height = height; - } - - public void AddObject(SceneObjectGroup obj) - { - if (m_childNodes == null) - { - if (!m_objects.Contains(obj)) - { - m_objects.Add(obj); - } - } - else - { - if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) - { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) - { - m_childNodes[0].AddObject(obj); - } - else - { - m_childNodes[2].AddObject(obj); - } - } - else - { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) - { - m_childNodes[1].AddObject(obj); - } - else - { - m_childNodes[3].AddObject(obj); - } - } - } - } - - public void Subdivide() - { - if (m_childNodes == null) - { - m_childNodes = new BasicQuadTreeNode[4]; - m_childNodes[0] = new BasicQuadTreeNode(this, m_leftX, m_leftY,(short) (m_width / 2), (short)( m_height / 2)); - m_childNodes[1] = new BasicQuadTreeNode(this,(short)( m_leftX + (m_width / 2)), m_leftY,(short)( m_width / 2),(short) (m_height / 2)); - m_childNodes[2] = new BasicQuadTreeNode(this, m_leftX, (short)( m_leftY + (m_height / 2)), (short)(m_width / 2),(short)( m_height / 2)); - m_childNodes[3] = new BasicQuadTreeNode(this, (short)( m_leftX + (m_width / 2)),(short)( m_height + (m_height / 2)),(short)( m_width / 2), (short)(m_height / 2)); - } - else - { - for (int i = 0; i < m_childNodes.Length; i++) - { - m_childNodes[i].Subdivide(); - } - } - } - - public List GetObjectsFrom(int x, int y) - { - if (m_childNodes == null) - { - return m_objects; - } - else - { - if (x < (m_leftX + (m_width / 2))) - { - if (y < (m_leftY + (m_height / 2))) - { - return m_childNodes[0].GetObjectsFrom(x, y); - } - else - { - return m_childNodes[2].GetObjectsFrom(x, y); - } - } - else - { - if (y < (m_leftY + (m_height / 2))) - { - return m_childNodes[1].GetObjectsFrom(x, y); - } - else - { - return m_childNodes[3].GetObjectsFrom(x, y); - } - } - } - } - - public void Update() - { - if (m_childNodes != null) - { - for (int i = 0; i < 4; i++) - { - m_childNodes[i].Update(); - } - } - else - { - List outBounds = new List(); - foreach (SceneObjectGroup group in m_objects) - { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) - { - //still in bounds - } - else - { - outBounds.Add(group); - } - } - - foreach (SceneObjectGroup removee in outBounds) - { - m_objects.Remove(removee); - if (m_parent != null) - { - m_parent.PassUp(removee); - } - } - outBounds.Clear(); - } - } - - public void PassUp(SceneObjectGroup group) - { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) - { - this.AddObject(group); - } - else - { - if (m_parent != null) - { - m_parent.PassUp(group); - } - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.Environment.Types +{ + public class BasicQuadTreeNode + { + private List m_objects = new List(); + private BasicQuadTreeNode[] m_childNodes = null; + private BasicQuadTreeNode m_parent = null; + + private short m_leftX; + private short m_leftY; + private short m_width; + private short m_height; + + public BasicQuadTreeNode(BasicQuadTreeNode parent, short leftX, short leftY, short width, short height) + { + m_parent = parent; + m_leftX = leftX; + m_leftY = leftY; + m_width = width; + m_height = height; + } + + public void AddObject(SceneObjectGroup obj) + { + if (m_childNodes == null) + { + if (!m_objects.Contains(obj)) + { + m_objects.Add(obj); + } + } + else + { + if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) + { + if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + { + m_childNodes[0].AddObject(obj); + } + else + { + m_childNodes[2].AddObject(obj); + } + } + else + { + if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + { + m_childNodes[1].AddObject(obj); + } + else + { + m_childNodes[3].AddObject(obj); + } + } + } + } + + public void Subdivide() + { + if (m_childNodes == null) + { + m_childNodes = new BasicQuadTreeNode[4]; + m_childNodes[0] = new BasicQuadTreeNode(this, m_leftX, m_leftY,(short) (m_width / 2), (short)( m_height / 2)); + m_childNodes[1] = new BasicQuadTreeNode(this,(short)( m_leftX + (m_width / 2)), m_leftY,(short)( m_width / 2),(short) (m_height / 2)); + m_childNodes[2] = new BasicQuadTreeNode(this, m_leftX, (short)( m_leftY + (m_height / 2)), (short)(m_width / 2),(short)( m_height / 2)); + m_childNodes[3] = new BasicQuadTreeNode(this, (short)( m_leftX + (m_width / 2)),(short)( m_height + (m_height / 2)),(short)( m_width / 2), (short)(m_height / 2)); + } + else + { + for (int i = 0; i < m_childNodes.Length; i++) + { + m_childNodes[i].Subdivide(); + } + } + } + + public List GetObjectsFrom(int x, int y) + { + if (m_childNodes == null) + { + return m_objects; + } + else + { + if (x < (m_leftX + (m_width / 2))) + { + if (y < (m_leftY + (m_height / 2))) + { + return m_childNodes[0].GetObjectsFrom(x, y); + } + else + { + return m_childNodes[2].GetObjectsFrom(x, y); + } + } + else + { + if (y < (m_leftY + (m_height / 2))) + { + return m_childNodes[1].GetObjectsFrom(x, y); + } + else + { + return m_childNodes[3].GetObjectsFrom(x, y); + } + } + } + } + + public void Update() + { + if (m_childNodes != null) + { + for (int i = 0; i < 4; i++) + { + m_childNodes[i].Update(); + } + } + else + { + List outBounds = new List(); + foreach (SceneObjectGroup group in m_objects) + { + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + { + //still in bounds + } + else + { + outBounds.Add(group); + } + } + + foreach (SceneObjectGroup removee in outBounds) + { + m_objects.Remove(removee); + if (m_parent != null) + { + m_parent.PassUp(removee); + } + } + outBounds.Clear(); + } + } + + public void PassUp(SceneObjectGroup group) + { + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + { + this.AddObject(group); + } + else + { + if (m_parent != null) + { + m_parent.PassUp(group); + } + } + } + } +} diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs index dab4258..3b7c182 100644 --- a/OpenSim/Region/Environment/Types/UpdateQueue.cs +++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs @@ -1,54 +1,54 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using libsecondlife; - -namespace OpenSim.Region.Environment.Types -{ - public class UpdateQueue - { - private Queue m_queue; - - private List m_ids; - - public int Count - { - get { return m_queue.Count; } - } - - public UpdateQueue() - { - m_queue = new Queue(); - m_ids = new List(); - } - - public void Enqueue(SceneObjectPart part) - { - lock (m_ids) - { - if (!m_ids.Contains(part.UUID)) - { - m_ids.Add(part.UUID); - m_queue.Enqueue(part); - } - } - } - - public SceneObjectPart Dequeue() - { - SceneObjectPart part = null; - if (m_queue.Count > 0) - { - part = m_queue.Dequeue(); - lock (m_ids) - { - m_ids.Remove(part.UUID); - } - } - - return part; - } - - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; +using libsecondlife; + +namespace OpenSim.Region.Environment.Types +{ + public class UpdateQueue + { + private Queue m_queue; + + private List m_ids; + + public int Count + { + get { return m_queue.Count; } + } + + public UpdateQueue() + { + m_queue = new Queue(); + m_ids = new List(); + } + + public void Enqueue(SceneObjectPart part) + { + lock (m_ids) + { + if (!m_ids.Contains(part.UUID)) + { + m_ids.Add(part.UUID); + m_queue.Enqueue(part); + } + } + } + + public SceneObjectPart Dequeue() + { + SceneObjectPart part = null; + if (m_queue.Count > 0) + { + part = m_queue.Dequeue(); + lock (m_ids) + { + m_ids.Remove(part.UUID); + } + } + + return part; + } + + } +} -- cgit v1.1