From efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 21:41:48 +0000 Subject: * Optimized usings * shortened references * Removed redundant 'this' * Normalized EOF --- .../LoadRegions/LoadRegionsPlugin.cs | 23 +- .../LoadRegions/Properties/AssemblyInfo.cs | 31 +- .../RemoteController/RemoteAdminPlugin.cs | 78 ++-- OpenSim/Framework/AgentCircuitData.cs | 10 +- OpenSim/Framework/AgentCircuitManager.cs | 2 +- OpenSim/Framework/AgentInventory.cs | 2 +- OpenSim/Framework/AssetBase.cs | 2 +- OpenSim/Framework/AssetLandmark.cs | 2 +- OpenSim/Framework/AssetStorage.cs | 2 +- OpenSim/Framework/AuthenticateResponse.cs | 2 +- OpenSim/Framework/AvatarWearable.cs | 2 +- OpenSim/Framework/BlockingQueue.cs | 4 +- OpenSim/Framework/ChildAgentDataUpdate.cs | 8 +- OpenSim/Framework/ClientManager.cs | 21 +- .../Framework/Communications/Cache/AssetCache.cs | 49 ++- .../Framework/Communications/Cache/AssetServer.cs | 6 +- .../Communications/Cache/AssetServerBase.cs | 10 +- .../Cache/AssetTransactionManager.cs | 2 +- .../Communications/Cache/AssetTransactions.cs | 6 +- .../Communications/Cache/CachedUserInfo.cs | 2 +- .../Communications/Cache/GridAssetClient.cs | 15 +- .../Communications/Cache/InventoryFolderImpl.cs | 4 +- .../Communications/Cache/LibraryRootFolder.cs | 37 +- .../Communications/Cache/SQLAssetServer.cs | 8 +- .../Cache/UserProfileCacheService.cs | 37 +- .../Framework/Communications/Capabilities/Caps.cs | 82 ++-- .../Framework/Communications/Capabilities/LLSD.cs | 42 ++- .../Communications/Capabilities/LLSDArray.cs | 2 +- .../Capabilities/LLSDAssetUploadComplete.cs | 2 +- .../Communications/Capabilities/LLSDCapEvent.cs | 2 +- .../Communications/Capabilities/LLSDCapsDetails.cs | 2 +- .../Communications/Capabilities/LLSDEmpty.cs | 2 +- .../Communications/Capabilities/LLSDHelpers.cs | 15 +- .../Communications/Capabilities/LLSDMapLayer.cs | 2 +- .../Capabilities/LLSDMapLayerResponse.cs | 2 +- .../Capabilities/LLSDStreamHandler.cs | 8 +- .../LLSDTaskInventoryUploadComplete.cs | 14 +- .../Capabilities/LLSDTaskScriptUpdate.cs | 12 +- .../Communications/Capabilities/LLSDTest.cs | 2 +- .../Communications/Capabilities/LLSDType.cs | 2 +- .../Communications/CommunicationsManager.cs | 7 +- OpenSim/Framework/Communications/IGridServices.cs | 4 +- .../Communications/IInterRegionCommunications.cs | 6 +- .../Framework/Communications/IInventoryServices.cs | 2 +- .../Communications/InventoryServiceBase.cs | 5 +- OpenSim/Framework/Communications/LoginResponse.cs | 6 +- OpenSim/Framework/Communications/LoginService.cs | 25 +- .../Communications/Properties/AssemblyInfo.cs | 2 +- .../Communications/RestClient/RestClient.cs | 16 +- .../Framework/Communications/UserManagerBase.cs | 32 +- .../Configuration/XML/XmlConfiguration.cs | 2 +- OpenSim/Framework/ConfigurationMember.cs | 135 ++++--- OpenSim/Framework/ConfigurationOption.cs | 1 - OpenSim/Framework/Console/AssemblyInfo.cs | 2 +- OpenSim/Framework/Console/ConsoleCallbacksBase.cs | 2 +- OpenSim/Framework/Console/LogBase.cs | 6 +- OpenSim/Framework/Console/MainLog.cs | 2 +- OpenSim/Framework/Data.DB4o/DB4oGridData.cs | 5 +- OpenSim/Framework/Data.DB4o/DB4oManager.cs | 2 +- OpenSim/Framework/Data.DB4o/DB4oUserData.cs | 10 +- OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs | 59 ++- OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs | 46 ++- OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs | 163 ++++---- OpenSim/Framework/Data.MSSQL/MSSQLLogData.cs | 13 +- OpenSim/Framework/Data.MSSQL/MSSQLManager.cs | 261 ++++++------- OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | 142 +++---- OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | 14 +- OpenSim/Framework/Data.MySQL/MySQLDataStore.cs | 404 ++++++++++---------- OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 49 ++- OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 4 +- OpenSim/Framework/Data.MySQL/MySQLLogData.cs | 2 +- OpenSim/Framework/Data.MySQL/MySQLManager.cs | 2 +- OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 53 ++- OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | 2 +- OpenSim/Framework/Data.SQLite/SQLiteBase.cs | 2 +- OpenSim/Framework/Data.SQLite/SQLiteGridData.cs | 5 +- .../Framework/Data.SQLite/SQLiteInventoryStore.cs | 6 +- OpenSim/Framework/Data.SQLite/SQLiteManager.cs | 2 +- OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 44 ++- OpenSim/Framework/Data/GridData.cs | 7 +- OpenSim/Framework/Data/ILogData.cs | 2 +- OpenSim/Framework/Data/IniConfig.cs | 2 +- OpenSim/Framework/Data/RegionProfileData.cs | 2 +- OpenSim/Framework/Data/ReservationData.cs | 2 +- OpenSim/Framework/EstateSettings.cs | 4 +- OpenSim/Framework/GridConfig.cs | 5 +- OpenSim/Framework/IAssetServer.cs | 2 +- OpenSim/Framework/IClientAPI.cs | 56 +-- OpenSim/Framework/IGenericConfig.cs | 2 +- OpenSim/Framework/IRegionCommsListener.cs | 5 +- OpenSim/Framework/IRegionLoader.cs | 7 +- OpenSim/Framework/IScene.cs | 7 +- OpenSim/Framework/IUserData.cs | 8 +- OpenSim/Framework/IUserService.cs | 4 +- OpenSim/Framework/InventoryItemBase.cs | 2 +- OpenSim/Framework/LandData.cs | 7 +- OpenSim/Framework/Login.cs | 2 +- OpenSim/Framework/NeighbourInfo.cs | 2 +- OpenSim/Framework/NetworkServersInfo.cs | 8 +- OpenSim/Framework/PrimitiveBaseShape.cs | 32 +- OpenSim/Framework/RegionCommsListener.cs | 13 +- OpenSim/Framework/RegionInfo.cs | 205 +++++----- .../Filesystem/RegionLoaderFileSystem.cs | 8 +- .../RegionLoader/Web/RegionLoaderWebServer.cs | 37 +- OpenSim/Framework/Remoting.cs | 2 +- OpenSim/Framework/SerializableRegionInfo.cs | 79 ++-- OpenSim/Framework/Servers/BaseHttpServer.cs | 66 ++-- OpenSim/Framework/Servers/CheckSumServer.cs | 2 +- OpenSim/Framework/Servers/RestMethod.cs | 2 +- OpenSim/Framework/Servers/RestObjectPoster.cs | 8 +- .../Framework/Servers/RestObjectPosterResponse.cs | 14 +- .../Servers/SynchronousRestObjectPoster.cs | 14 +- OpenSim/Framework/Servers/XmlRpcMethod.cs | 2 +- OpenSim/Framework/UserConfig.cs | 11 +- OpenSim/Framework/UserProfileData.cs | 15 +- OpenSim/Framework/Util.cs | 17 +- OpenSim/Framework/sLLVector3.cs | 7 +- OpenSim/Grid/AssetServer/Main.cs | 2 +- .../Grid/AssetServer/Properties/AssemblyInfo.cs | 2 +- OpenSim/Grid/AssetServer/RestService.cs | 4 +- OpenSim/Grid/GridServer/GridManager.cs | 17 +- OpenSim/Grid/GridServer/Main.cs | 4 +- OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs | 2 +- .../Grid/InventoryServer/GridInventoryService.cs | 45 ++- OpenSim/Grid/InventoryServer/InventoryManager.cs | 43 ++- OpenSim/Grid/InventoryServer/Main.cs | 34 +- OpenSim/Grid/ScriptServer/Application.cs | 2 +- .../ScriptServer/ScriptServer/RegionCommManager.cs | 2 +- .../ScriptEngineManager/ScriptEngineInterface.cs | 2 +- .../ScriptEngineManager/ScriptEngineLoader.cs | 2 +- OpenSim/Grid/UserServer/Main.cs | 21 +- OpenSim/Grid/UserServer/UserLoginService.cs | 65 ++-- OpenSim/Grid/UserServer/UserManager.cs | 32 +- OpenSim/Region/Application/Application.cs | 2 +- OpenSim/Region/Application/IApplicationPlugin.cs | 11 +- OpenSim/Region/Application/OpenSimMain.cs | 85 +++-- OpenSim/Region/Application/VersionInfo.cs | 2 +- .../ClientStack/ClientStackNetworkHandler.cs | 2 +- OpenSim/Region/ClientStack/ClientView.cs | 378 ++++++++++--------- OpenSim/Region/ClientStack/PacketQueue.cs | 198 +++++----- OpenSim/Region/ClientStack/PacketServer.cs | 13 +- OpenSim/Region/ClientStack/PacketThrottle.cs | 43 +-- OpenSim/Region/ClientStack/QueItem.cs | 18 +- .../Region/ClientStack/RegionApplicationBase.cs | 9 +- OpenSim/Region/ClientStack/UDPServer.cs | 87 ++--- .../Communications/Local/CommunicationsLocal.cs | 2 +- .../Communications/Local/LocalBackEndServices.cs | 40 +- .../Communications/Local/LocalInventoryService.cs | 10 +- .../Communications/Local/LocalLoginService.cs | 14 +- .../Communications/Local/LocalUserServices.cs | 3 +- .../Region/Communications/OGS1/OGS1GridServices.cs | 219 ++++++----- .../Communications/OGS1/OGS1InterSimComms.cs | 32 +- .../Communications/OGS1/OGS1InventoryService.cs | 24 +- .../Region/Communications/OGS1/OGS1UserServices.cs | 29 +- OpenSim/Region/Environment/EstateManager.cs | 24 +- .../Environment/Interfaces/IAvatarFactory.cs | 1 - .../Region/Environment/Interfaces/IHttpRequests.cs | 2 +- .../Environment/Interfaces/IRegionDataStore.cs | 7 +- OpenSim/Region/Environment/LandManagement/Land.cs | 61 ++- .../Environment/LandManagement/LandManager.cs | 95 ++--- OpenSim/Region/Environment/ModuleLoader.cs | 2 +- .../Environment/Modules/AvatarFactoryModule.cs | 17 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 10 +- .../Environment/Modules/ScriptsHttpRequests.cs | 260 +++++++------ OpenSim/Region/Environment/Modules/SunModule.cs | 37 +- .../Environment/Modules/TextureDownloadModule.cs | 42 ++- .../Region/Environment/Modules/WorldCommModule.cs | 4 +- OpenSim/Region/Environment/Modules/XMLRPCModule.cs | 9 +- OpenSim/Region/Environment/PermissionManager.cs | 31 +- .../Region/Environment/Scenes/AvatarAnimations.cs | 17 +- .../Region/Environment/Scenes/AvatarAppearance.cs | 14 +- OpenSim/Region/Environment/Scenes/EntityBase.cs | 5 +- .../Environment/Scenes/IScenePresenceBody.cs | 1 - OpenSim/Region/Environment/Scenes/InnerScene.cs | 123 +++--- .../Region/Environment/Scenes/Scene.Inventory.cs | 189 +++++----- .../Environment/Scenes/Scene.PacketHandlers.cs | 19 +- OpenSim/Region/Environment/Scenes/Scene.cs | 400 ++++++++++---------- OpenSim/Region/Environment/Scenes/SceneBase.cs | 11 +- .../Scenes/SceneCommunicationService.cs | 72 ++-- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 12 +- OpenSim/Region/Environment/Scenes/SceneManager.cs | 9 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 93 ++--- .../Region/Environment/Scenes/SceneObjectPart.cs | 414 +++++++++++---------- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 132 +++---- .../Region/Environment/Scenes/SceneXmlLoader.cs | 25 +- .../Scenes/Scripting/ScriptEngineInterface.cs | 2 +- .../Scenes/Scripting/ScriptEngineLoader.cs | 2 +- .../Region/Environment/Scenes/SimStatsReporter.cs | 69 ++-- .../Region/Examples/SimpleApp/FileSystemObject.cs | 1 - .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 27 +- OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 9 +- OpenSim/Region/Examples/SimpleApp/Program.cs | 5 +- .../Engines/CSharp/CSharpScriptEngine.cs | 2 +- .../Engines/CSharp/Examples/ExportRegionToLSL.cs | 2 +- .../Engines/JScript/JScriptEngine.cs | 2 +- .../Engines/JVMEngine/JVM/ClassInstance.cs | 2 +- .../Engines/JVMEngine/JVM/ClassRecord.cs | 2 +- .../Engines/JVMEngine/JVM/Heap.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.Logic.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.Methods.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.Return.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.cs | 2 +- .../Engines/JVMEngine/JVM/MainMemory.cs | 2 +- .../Engines/JVMEngine/JVM/MethodMemory.cs | 2 +- .../Engines/JVMEngine/JVM/Object.cs | 2 +- .../Engines/JVMEngine/JVM/Stack.cs | 2 +- .../Engines/JVMEngine/JVM/StackFrame.cs | 2 +- .../Engines/JVMEngine/JVM/Thread.cs | 2 +- .../Engines/JVMEngine/OpenSimJVM.cs | 2 +- OpenSim/Region/ExtensionsScriptModule/Script.cs | 2 +- .../Region/ExtensionsScriptModule/ScriptInfo.cs | 2 +- .../Region/ExtensionsScriptModule/ScriptManager.cs | 2 +- .../Physics/BasicPhysicsPlugin/AssemblyInfo.cs | 2 +- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 42 ++- .../Region/Physics/BulletXPlugin/AssemblyInfo.cs | 2 +- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 206 ++++++---- .../BulletXPlugin/TriangleIndexVertexArray.cs | 69 +++- OpenSim/Region/Physics/Manager/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/Manager/IMesher.cs | 9 +- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 101 ++--- .../Region/Physics/Manager/PhysicsPluginManager.cs | 8 +- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 15 +- OpenSim/Region/Physics/Manager/PhysicsVector.cs | 15 +- OpenSim/Region/Physics/Manager/ZeroMesher.cs | 9 +- OpenSim/Region/Physics/Meshing/Extruder.cs | 21 +- OpenSim/Region/Physics/Meshing/HelperTypes.cs | 10 +- OpenSim/Region/Physics/Meshing/Mesh.cs | 42 +-- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 74 ++-- OpenSim/Region/Physics/Meshing/SimpleHull.cs | 120 +++--- OpenSim/Region/Physics/Meshing/Simplex.cs | 49 ++- OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 114 +++--- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 175 ++++----- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 336 +++++++++-------- OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 84 +++-- OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 124 +++--- .../Common/LSL_BuiltIn_Commands_Interface.cs | 2 +- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 66 ++-- OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs | 2 +- .../DotNetEngine/Compiler/LSL/Compiler.cs | 9 +- .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 4 +- .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 8 +- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 2 - .../ScriptEngine/DotNetEngine/EventManager.cs | 2 +- .../ScriptEngine/DotNetEngine/EventQueueManager.cs | 21 +- .../ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs | 14 +- .../ScriptEngine/DotNetEngine/ScriptEngine.cs | 2 +- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 65 ++-- .../OpenSim.DataStore.MSSQL/MSSQLDataStore.cs | 309 +++++++-------- .../MonoSqliteDataStore.cs | 306 ++++++++------- .../OpenSim.DataStore.NullStorage/NullDataStore.cs | 5 +- .../Properties/AssemblyInfo.cs | 2 +- .../Region/Terrain.BasicTerrain/TerrainEngine.cs | 35 +- .../Region/Terrain.BasicTerrain/TerrainFilter.cs | 2 +- .../libTerrainBSD/Bitmap/Bitmap.cs | 2 +- .../libTerrainBSD/Channel/Channel.cs | 2 +- .../libTerrainBSD/Channel/Common.cs | 2 +- .../libTerrainBSD/Channel/Editing/Flatten.cs | 2 +- .../libTerrainBSD/Channel/Editing/Raise.cs | 2 +- .../libTerrainBSD/Channel/File.cs | 2 +- .../libTerrainBSD/Channel/Generators/Fracture.cs | 2 +- .../libTerrainBSD/Channel/Generators/Gradient.cs | 2 +- .../Channel/Generators/HillPlanter.cs | 2 +- .../libTerrainBSD/Channel/Generators/Noise.cs | 2 +- .../libTerrainBSD/Channel/Generators/Spiral.cs | 2 +- .../libTerrainBSD/Channel/Generators/Voronoi.cs | 2 +- .../libTerrainBSD/Channel/Generators/Worms.cs | 2 +- .../libTerrainBSD/Channel/Grid.cs | 2 +- .../Channel/Manipulators/AerobicErosion.cs | 2 +- .../Channel/Manipulators/HydraulicErosion.cs | 2 +- .../Channel/Manipulators/NavierStokes.cs | 2 +- .../Channel/Manipulators/ThermalWeathering.cs | 2 +- .../libTerrainBSD/Channel/Neighbours.cs | 2 +- .../libTerrainBSD/Channel/Operators.cs | 2 +- OpenSim/Tools/Export/OpenSimExport.cs | 36 +- 277 files changed, 4704 insertions(+), 4427 deletions(-) diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index 3c27108..b897c60 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -26,21 +26,14 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim; -using OpenSim.Framework.Console; +using Mono.Addins; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Framework.RegionLoader.Filesystem; using OpenSim.Framework.RegionLoader.Web; -using Mono.Addins; -using Mono.Addins.Description; -using Nini; -using Nini.Config; -[assembly:Addin] -[assembly:AddinDependency ("OpenSim", "0.4")] +[assembly : Addin] +[assembly : AddinDependency("OpenSim", "0.4")] namespace OpenSim.ApplicationPlugins.LoadRegions { @@ -65,7 +58,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions regionLoader.SetIniConfigSource(openSim.ConfigSource); RegionInfo[] regionsToLoad = regionLoader.LoadRegions(); - + openSim.ModuleLoader.LoadDefaultSharedModules(); for (int i = 0; i < regionsToLoad.Length; i++) @@ -77,6 +70,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions openSim.ModuleLoader.PostInitialise(); openSim.ModuleLoader.ClearCache(); } + public void LoadRegionFromConfig(OpenSimMain openSim, ulong regionhandle) { MainLog.Instance.Notice("LOADREGIONS", "Load Regions addin being initialised"); @@ -103,11 +97,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions openSim.CreateRegion(regionsToLoad[i]); } } - } + public void Close() { - } } } \ No newline at end of file diff --git a/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs b/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs index 0b5f4bd..ffb3e48 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/Properties/AssemblyInfo.cs @@ -1,26 +1,28 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("OpenSim.Addin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Addin")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Addin")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Addin")] +[assembly : AssemblyCopyright("Copyright � 2007")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] + +[assembly : ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("45b979d9-d8d4-42fd-9780-fe9ac7e86cb4")] + +[assembly : Guid("45b979d9-d8d4-42fd-9780-fe9ac7e86cb4")] // Version information for an assembly consists of the following four values: // @@ -32,5 +34,6 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly : AssemblyVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 9ae1a7b..b57d3e6 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -27,24 +27,19 @@ */ using System; -using System.Collections.Generic; -using System.Text; -using System.Net; -using OpenSim; -using OpenSim.Framework.Console; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using Mono.Addins; -using Mono.Addins.Description; -using Nini; -using Nini.Config; -using Nwc.XmlRpc; using System.Collections; +using System.Net; using System.Timers; using libsecondlife; +using Mono.Addins; +using Nwc.XmlRpc; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Region.Environment.Scenes; -[assembly: Addin] -[assembly: AddinDependency("OpenSim", "0.4")] +[assembly : Addin] +[assembly : AddinDependency("OpenSim", "0.4")] namespace OpenSim.ApplicationPlugins.LoadRegions { @@ -54,6 +49,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions private OpenSimMain m_app; private BaseHttpServer m_httpd; private string requiredPassword = ""; + public void Initialise(OpenSimMain openSim) { try @@ -81,12 +77,13 @@ namespace OpenSim.ApplicationPlugins.LoadRegions public XmlRpcResponse XmlRpcRestartMethod(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; - LLUUID regionID = new LLUUID((string)requestData["regionID"]); + LLUUID regionID = new LLUUID((string) requestData["regionID"]); Hashtable responseData = new Hashtable(); - if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) + if (requiredPassword != "" && + (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) { responseData["accepted"] = "false"; response.Value = responseData; @@ -96,7 +93,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions responseData["accepted"] = "true"; response.Value = responseData; - OpenSim.Region.Environment.Scenes.Scene RebootedScene; + Scene RebootedScene; if (m_app.SceneManager.TryGetScene(regionID, out RebootedScene)) { @@ -115,18 +112,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions public XmlRpcResponse XmlRpcAlertMethod(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); - if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) + if (requiredPassword != "" && + (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) { responseData["accepted"] = "false"; response.Value = responseData; } else { - - string message = (string)requestData["message"]; + string message = (string) requestData["message"]; MainLog.Instance.Verbose("RADMIN", "Broadcasting: " + message); responseData["accepted"] = "true"; @@ -142,23 +139,24 @@ namespace OpenSim.ApplicationPlugins.LoadRegions { MainLog.Instance.Verbose("RADMIN", "Received Shutdown Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); - if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) + if (requiredPassword != "" && + (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) { responseData["accepted"] = "false"; response.Value = responseData; } else { - if ((string)requestData["shutdown"] == "delayed") + if ((string) requestData["shutdown"] == "delayed") { - int timeout = (Int32)requestData["milliseconds"]; + int timeout = (Int32) requestData["milliseconds"]; responseData["accepted"] = "true"; response.Value = responseData; - m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int)(timeout / 1000)).ToString() + + m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() + " second(s). Please save what you are doing and log out."); // Perform shutdown @@ -197,9 +195,10 @@ namespace OpenSim.ApplicationPlugins.LoadRegions { MainLog.Instance.Verbose("RADMIN", "Received Create Region Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); - if (requiredPassword != "" && (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) + if (requiredPassword != "" && + (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) { responseData["created"] = "false"; response.Value = responseData; @@ -210,22 +209,22 @@ namespace OpenSim.ApplicationPlugins.LoadRegions try { - newRegionData.RegionID = (string)requestData["region_id"]; - newRegionData.RegionName = (string)requestData["region_name"]; - newRegionData.RegionLocX = Convert.ToUInt32((Int32)requestData["region_x"]); - newRegionData.RegionLocY = Convert.ToUInt32((Int32)requestData["region_y"]); + newRegionData.RegionID = (string) requestData["region_id"]; + newRegionData.RegionName = (string) requestData["region_name"]; + newRegionData.RegionLocX = Convert.ToUInt32((Int32) requestData["region_x"]); + newRegionData.RegionLocY = Convert.ToUInt32((Int32) requestData["region_y"]); // Security risk - newRegionData.DataStore = (string)requestData["datastore"]; + newRegionData.DataStore = (string) requestData["datastore"]; newRegionData.InternalEndPoint = new IPEndPoint( - IPAddress.Parse((string)requestData["listen_ip"]), 0); + IPAddress.Parse((string) requestData["listen_ip"]), 0); - newRegionData.InternalEndPoint.Port = (Int32)requestData["listen_port"]; - newRegionData.ExternalHostName = (string)requestData["external_address"]; + newRegionData.InternalEndPoint.Port = (Int32) requestData["listen_port"]; + newRegionData.ExternalHostName = (string) requestData["external_address"]; - newRegionData.MasterAvatarFirstName = (string)requestData["region_master_first"]; - newRegionData.MasterAvatarLastName = (string)requestData["region_master_last"]; + newRegionData.MasterAvatarFirstName = (string) requestData["region_master_first"]; + newRegionData.MasterAvatarLastName = (string) requestData["region_master_last"]; m_app.CreateRegion(newRegionData); @@ -245,7 +244,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions public void Close() { - } } } \ No newline at end of file diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index 0617a76..65a072f 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -35,12 +35,13 @@ namespace OpenSim.Framework public AgentCircuitData() { } + public AgentCircuitData(sAgentCircuitData cAgent) { AgentID = new LLUUID(cAgent.AgentID); SessionID = new LLUUID(cAgent.SessionID); SecureSessionID = new LLUUID(cAgent.SecureSessionID); - startpos = new LLVector3(cAgent.startposx,cAgent.startposy,cAgent.startposz); + startpos = new LLVector3(cAgent.startposx, cAgent.startposy, cAgent.startposz); firstname = cAgent.firstname; lastname = cAgent.lastname; circuitcode = cAgent.circuitcode; @@ -69,6 +70,7 @@ namespace OpenSim.Framework public sAgentCircuitData() { } + public sAgentCircuitData(AgentCircuitData cAgent) { AgentID = cAgent.AgentID.UUID; @@ -85,6 +87,7 @@ namespace OpenSim.Framework BaseFolder = cAgent.BaseFolder.UUID; CapsPath = cAgent.CapsPath; } + public Guid AgentID; public Guid SessionID; public Guid SecureSessionID; @@ -98,8 +101,5 @@ namespace OpenSim.Framework public Guid InventoryFolder; public Guid BaseFolder; public string CapsPath = ""; - - - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/AgentCircuitManager.cs b/OpenSim/Framework/AgentCircuitManager.cs index 2803a4a..938dce8 100644 --- a/OpenSim/Framework/AgentCircuitManager.cs +++ b/OpenSim/Framework/AgentCircuitManager.cs @@ -124,4 +124,4 @@ namespace OpenSim.Framework return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/AgentInventory.cs b/OpenSim/Framework/AgentInventory.cs index 541bc27..84a782b 100644 --- a/OpenSim/Framework/AgentInventory.cs +++ b/OpenSim/Framework/AgentInventory.cs @@ -255,4 +255,4 @@ namespace OpenSim.Framework return result; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 5775f06..2bef61b 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -52,4 +52,4 @@ namespace OpenSim.Framework Name = name; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs index d83b43b..050b80f 100644 --- a/OpenSim/Framework/AssetLandmark.cs +++ b/OpenSim/Framework/AssetLandmark.cs @@ -56,4 +56,4 @@ namespace OpenSim.Framework LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out Position); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/AssetStorage.cs b/OpenSim/Framework/AssetStorage.cs index 9e0cf10..7d6cdf0 100644 --- a/OpenSim/Framework/AssetStorage.cs +++ b/OpenSim/Framework/AssetStorage.cs @@ -45,4 +45,4 @@ namespace OpenSim.Framework public string Name; public LLUUID UUID; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/AuthenticateResponse.cs b/OpenSim/Framework/AuthenticateResponse.cs index 7d4cd11..90c9acd 100644 --- a/OpenSim/Framework/AuthenticateResponse.cs +++ b/OpenSim/Framework/AuthenticateResponse.cs @@ -36,4 +36,4 @@ namespace OpenSim.Framework { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs index d0c68de..c7083f3 100644 --- a/OpenSim/Framework/AvatarWearable.cs +++ b/OpenSim/Framework/AvatarWearable.cs @@ -68,4 +68,4 @@ namespace OpenSim.Framework } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs index a3cae63..ae2a189 100644 --- a/OpenSim/Framework/BlockingQueue.cs +++ b/OpenSim/Framework/BlockingQueue.cs @@ -34,7 +34,7 @@ namespace OpenSim.Framework { private Queue<T> _queue = new Queue<T>(); private object _queueSync = new object(); - + public void Enqueue(T value) { lock (_queueSync) @@ -55,4 +55,4 @@ namespace OpenSim.Framework } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index fb9a48f..32ce4ab 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Framework { @@ -37,8 +35,8 @@ namespace OpenSim.Framework { public ChildAgentDataUpdate() { - } + public sLLVector3 Position; public ulong regionHandle; public float drawdistance; @@ -47,6 +45,6 @@ namespace OpenSim.Framework public float AVHeight; public Guid AgentID; public float godlevel; - public byte[] throttles; + public byte[] throttles; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs index e32c9eb..da60ed7 100644 --- a/OpenSim/Framework/ClientManager.cs +++ b/OpenSim/Framework/ClientManager.cs @@ -26,9 +26,11 @@ * */ +using System; using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; +using OpenSim.Framework.Console; namespace OpenSim.Framework { @@ -40,7 +42,6 @@ namespace OpenSim.Framework public void ForEachClient(ForEachClientDelegate whatToDo) { - // Wasteful, I know IClientAPI[] LocalClients = new IClientAPI[0]; lock (m_clients) @@ -55,9 +56,11 @@ namespace OpenSim.Framework { whatToDo(LocalClients[i]); } - catch (System.Exception e) + catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Warn("CLIENT", "Unable to do ForEachClient for one of the clients" + "\n Reason: " + e.ToString()); + MainLog.Instance.Warn("CLIENT", + "Unable to do ForEachClient for one of the clients" + "\n Reason: " + + e.ToString()); } } } @@ -107,20 +110,19 @@ namespace OpenSim.Framework IClientAPI client; try { - if (m_clients.TryGetValue(circuits[i], out client)) { Remove(client.CircuitCode); client.Close(false); } } - catch (System.Exception e) + catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Error("CLIENT", "Unable to shutdown circuit for: " + agentId.ToString() + "\n Reason: " + e.ToString()); + MainLog.Instance.Error("CLIENT", + "Unable to shutdown circuit for: " + agentId.ToString() + "\n Reason: " + + e.ToString()); } } - - } private uint[] GetAllCircuits(LLUUID agentId) @@ -135,7 +137,7 @@ namespace OpenSim.Framework } - for (int i = 0; i < LocalClients.Length; i++ ) + for (int i = 0; i < LocalClients.Length; i++) { if (LocalClients[i].AgentId == agentId) { @@ -168,7 +170,6 @@ namespace OpenSim.Framework packet.AgentData.SessionID = LocalClients[i].SessionId; LocalClients[i].OutPacket(packet, ThrottleOutPacketType.Task); } - } } diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 4765548..664625e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Threading; using libsecondlife; using libsecondlife.Packets; @@ -92,7 +91,7 @@ namespace OpenSim.Framework.Communications.Cache Thread.Sleep(500); } catch (Exception e) - { + { m_log.Error("ASSETCACHE", e.ToString()); } } @@ -177,30 +176,29 @@ namespace OpenSim.Framework.Communications.Cache // packets from the client. int pollPeriod = 200; int maxPolls = 15; - + AssetBase asset = GetCachedAsset(assetID); if (asset != null) { return asset; } - - m_assetServer.RequestAsset(assetID, isTexture); - + + m_assetServer.RequestAsset(assetID, isTexture); + do { Thread.Sleep(pollPeriod); - + asset = GetCachedAsset(assetID); if (asset != null) { return asset; } - } - while (--maxPolls > 0); - + } while (--maxPolls > 0); + MainLog.Instance.Warn( "ASSETCACHE", "Asset {0} was not received before the retrieval timeout was reached"); - + return null; } @@ -368,12 +366,13 @@ namespace OpenSim.Framework.Communications.Cache { // over max number of bytes so split up file long restData = data.LongLength - m_maxPacketSize; - int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize); + int restPackets = (int) ((restData + m_maxPacketSize - 1)/m_maxPacketSize); numPackets += restPackets; } return numPackets; } + #region Assets /// <summary> @@ -448,7 +447,7 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req; for (int i = 0; i < num; i++) { - req = (AssetRequest)AssetRequests[i]; + req = (AssetRequest) AssetRequests[i]; //Console.WriteLine("sending asset " + req.RequestAssetID); TransferInfoPacket Transfer = new TransferInfoPacket(); Transfer.TransferInfo.ChannelType = 2; @@ -458,7 +457,7 @@ namespace OpenSim.Framework.Communications.Cache { Transfer.TransferInfo.Params = new byte[20]; Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = (int)req.AssetInf.Type; + int assType = (int) req.AssetInf.Type; Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); } else if (req.AssetRequestSource == 3) @@ -468,7 +467,7 @@ namespace OpenSim.Framework.Communications.Cache //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); } - Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; + Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length; Transfer.TransferInfo.TransferID = req.TransferRequestID; req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); @@ -488,20 +487,20 @@ namespace OpenSim.Framework.Communications.Cache // libsecondlife hardcodes 1500 as the maximum data chunk size int maxChunkSize = 1500; int packetNumber = 0; - + while (processedLength < req.AssetInf.Data.Length) { TransferPacketPacket TransferPacket = new TransferPacketPacket(); TransferPacket.TransferData.Packet = packetNumber; TransferPacket.TransferData.ChannelType = 2; TransferPacket.TransferData.TransferID = req.TransferRequestID; - - int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); + + int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); byte[] chunk = new byte[chunkSize]; - Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); - + Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); + TransferPacket.TransferData.Data = chunk; - + // 0 indicates more packets to come, 1 indicates last packet if (req.AssetInf.Data.Length - processedLength > maxChunkSize) { @@ -510,10 +509,10 @@ namespace OpenSim.Framework.Communications.Cache else { TransferPacket.TransferData.Status = 1; - } - + } + req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - + processedLength += chunkSize; packetNumber++; } @@ -609,4 +608,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index ae6494f..692ee1e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -80,7 +80,7 @@ namespace OpenSim.Framework.Communications.Cache IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); if (result.Count > 0) { - foundAsset = (AssetStorage)result.Next(); + foundAsset = (AssetStorage) result.Next(); found = true; } @@ -93,7 +93,7 @@ namespace OpenSim.Framework.Communications.Cache asset.Name = foundAsset.Name; idata = foundAsset.Data; asset.Data = idata; - + return asset; } else @@ -141,4 +141,4 @@ namespace OpenSim.Framework.Communications.Cache return (asset.UUID == _findID); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 43d3dd9..1b2c836 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -69,7 +69,7 @@ namespace OpenSim.Framework.Communications.Cache { MainLog.Instance.Verbose( "ASSET", "Asset {0} received from asset server", req.AssetID); - + _receiver.AssetReceived(asset, req.IsTexture); } else @@ -112,9 +112,9 @@ namespace OpenSim.Framework.Communications.Cache ProcessRequest(req); } - catch(Exception e) + catch (Exception e) { - MainLog.Instance.Error("ASSETSERVER", e.Message ); + MainLog.Instance.Error("ASSETSERVER", e.Message); } } } @@ -149,7 +149,7 @@ namespace OpenSim.Framework.Communications.Cache req.AssetID = assetID; req.IsTexture = isTexture; _assetRequests.Enqueue(req); - + MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); } @@ -253,4 +253,4 @@ namespace OpenSim.Framework.Communications.Cache assets.ForEach(action); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs index 7de84fa..c9c9541 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -106,4 +106,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 57c1fa6..8aa567c 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -182,7 +182,7 @@ namespace OpenSim.Framework.Communications.Cache Asset.Description = "empty"; Asset.Local = storeLocal; Asset.Temporary = tempFile; - + TransactionID = transaction; m_storeLocal = storeLocal; if (Asset.Data.Length > 2) @@ -312,6 +312,7 @@ namespace OpenSim.Framework.Communications.Cache } #region Nested Classes currently not in use (waiting for them to be enabled) + public class AssetCapsUploader { // Fields @@ -424,6 +425,7 @@ namespace OpenSim.Framework.Communications.Cache return text; } } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index a547c8a..1cf95b7 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -130,4 +130,4 @@ namespace OpenSim.Framework.Communications.Cache return result; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 9c460c7..cf54fa4 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -27,10 +27,8 @@ */ using System; -using System.Collections.Generic; using System.IO; using System.Xml.Serialization; -using libsecondlife; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -65,9 +63,9 @@ namespace OpenSim.Framework.Communications.Cache if (s.Length > 0) { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - - return (AssetBase)xs.Deserialize(s); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); + + return (AssetBase) xs.Deserialize(s); } } catch (Exception e) @@ -76,12 +74,11 @@ namespace OpenSim.Framework.Communications.Cache MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); MainLog.Instance.Error("ASSETCACHE", e.StackTrace); } - + return null; } - public override void UpdateAsset(AssetBase asset) { throw new Exception("The method or operation is not implemented."); @@ -119,8 +116,6 @@ namespace OpenSim.Framework.Communications.Cache throw new Exception("The method or operation is not implemented."); } - - #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index 1d2c920..a1e79b2 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl subFold = new InventoryFolderImpl(); subFold.name = folderName; subFold.folderID = folderID; - subFold.type = (short)type; + subFold.type = (short) type; subFold.parentID = this.folderID; subFold.agentID = agentID; SubFolders.Add(subFold.folderID, subFold); @@ -153,4 +153,4 @@ namespace OpenSim.Framework.Communications.Cache return folderList; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 4c8eddf..fd93b19 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -49,8 +49,8 @@ namespace OpenSim.Framework.Communications.Cache folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); name = "OpenSim Library"; parentID = LLUUID.Zero; - type = (short)-1; - version = (ushort)1; + type = (short) -1; + version = (ushort) 1; InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; @@ -81,28 +81,41 @@ namespace OpenSim.Framework.Communications.Cache private void CreateLibraryItems() { - InventoryItemBase item = CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); + InventoryItemBase item = + CreateItem(new LLUUID("66c41e39-38f9-f75a-024e-585989bfaba9"), + new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"), "Default Shape", "Default Shape", + (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", (int)AssetType.Bodypart, (int)InventoryType.Wearable, folderID); + item = + CreateItem(new LLUUID("77c41e39-38f9-f75a-024e-585989bfabc9"), + new LLUUID("77c41e39-38f9-f75a-024e-585989bbabbb"), "Default Skin", "Default Skin", + (int) AssetType.Bodypart, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); + item = + CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-585989bf0000"), + new LLUUID("00000000-38f9-1111-024e-222222111110"), "Default Shirt", "Default Shirt", + (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); - item = CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", (int)AssetType.Clothing, (int)InventoryType.Wearable, folderID); + item = + CreateItem(new LLUUID("77c41e39-38f9-f75a-0000-5859892f1111"), + new LLUUID("00000000-38f9-1111-024e-222222111120"), "Default Pants", "Default Pants", + (int) AssetType.Clothing, (int) InventoryType.Wearable, folderID); item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; Items.Add(item.inventoryID, item); } - public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, int assetType, int invType, LLUUID parentFolderID) + public InventoryItemBase CreateItem(LLUUID inventoryID, LLUUID assetID, string name, string description, + int assetType, int invType, LLUUID parentFolderID) { InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; @@ -135,10 +148,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = source.Configs[i].GetString("name", ""); item.assetType = source.Configs[i].GetInt("assetType", 0); item.invType = source.Configs[i].GetInt("inventoryType", 0); - item.inventoryCurrentPermissions = (uint)source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); - item.inventoryNextPermissions = (uint)source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); - item.inventoryEveryOnePermissions = (uint)source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); - item.inventoryBasePermissions = (uint)source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); + item.inventoryCurrentPermissions = (uint) source.Configs[i].GetLong("currentPermissions", 0x7FFFFFFF); + item.inventoryNextPermissions = (uint) source.Configs[i].GetLong("nextPermissions", 0x7FFFFFFF); + item.inventoryEveryOnePermissions = (uint) source.Configs[i].GetLong("everyonePermissions", 0x7FFFFFFF); + item.inventoryBasePermissions = (uint) source.Configs[i].GetLong("basePermissions", 0x7FFFFFFF); if (item.assetType == 0) { item.parentFolderID = m_textureFolder.folderID; @@ -152,4 +165,4 @@ namespace OpenSim.Framework.Communications.Cache } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 7fcff10..e4c278f 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Communications.Cache if (typeInterface != null) { IAssetProvider plug = - (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); @@ -84,8 +84,8 @@ namespace OpenSim.Framework.Communications.Cache { asset = m_assetProviderPlugin.FetchAsset(req.AssetID); } - - return asset; + + return asset; } protected override void StoreAsset(AssetBase asset) @@ -98,4 +98,4 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 47f970e..14670fd 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -130,7 +130,8 @@ namespace OpenSim.Framework.Communications.Cache } } - public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID) + public void HandleUpdateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort type, string name, + LLUUID parentID) { CachedUserInfo userProfile; @@ -143,7 +144,7 @@ namespace OpenSim.Framework.Communications.Cache baseFolder.folderID = folderID; baseFolder.name = name; baseFolder.parentID = parentID; - baseFolder.type = (short)type; + baseFolder.type = (short) type; baseFolder.version = userProfile.RootFolder.version; m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder); } @@ -180,12 +181,12 @@ namespace OpenSim.Framework.Communications.Cache bool fetchFolders, bool fetchItems, int sortOrder) { // XXX We're not handling sortOrder yet! - + InventoryFolderImpl fold = null; if (folderID == libraryRoot.folderID) { remoteClient.SendInventoryFolderDetails( - libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(), + libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(), libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -194,7 +195,7 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( - libraryRoot.agentID, folderID, fold.RequestListOfItems(), + libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); return; @@ -209,9 +210,9 @@ namespace OpenSim.Framework.Communications.Cache { remoteClient.SendInventoryFolderDetails( remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), - userProfile.RootFolder.RequestListOfFolders(), + userProfile.RootFolder.RequestListOfFolders(), fetchFolders, fetchItems); - + return; } else @@ -219,9 +220,9 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails( - remoteClient.AgentId, folderID, fold.RequestListOfItems(), + remoteClient.AgentId, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fetchFolders, fetchItems); - + return; } } @@ -230,20 +231,20 @@ namespace OpenSim.Framework.Communications.Cache { MainLog.Instance.Error( "INVENTORYCACHE", "Could not find root folder for user {0}", remoteClient.Name); - + return; } } else { MainLog.Instance.Error( - "INVENTORYCACHE", - "Could not find user profile for {0} for folder {1}", - remoteClient.Name, folderID); - + "INVENTORYCACHE", + "Could not find user profile for {0} for folder {1}", + remoteClient.Name, folderID); + return; } - + // If we've reached this point then we couldn't find the folder, even though the client thinks // it exists MainLog.Instance.Error( @@ -262,8 +263,8 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl subFolder = userProfile.RootFolder.HasSubFolder(folderID); if (subFolder != null) { - List<InventoryItemBase> items=subFolder.RequestListOfItems(); - foreach(InventoryItemBase item in items) + List<InventoryItemBase> items = subFolder.RequestListOfItems(); + foreach (InventoryItemBase item in items) { userProfile.DeleteItem(remoteClient.AgentId, item); } @@ -300,4 +301,4 @@ namespace OpenSim.Framework.Communications.Cache m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index e00f49d..4b42046 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -38,33 +38,33 @@ using OpenSim.Framework.Servers; namespace OpenSim.Region.Capabilities { public delegate void UpLoadedAsset( - string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, + string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType); public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data); - + public delegate void UpdateTaskScript(LLUUID itemID, LLUUID primID, bool isScriptRunning, byte[] data); public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item); public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); - - public delegate void TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, - bool isScriptRunning, byte[] data); + + public delegate void TaskScriptUpdatedCallback(LLUUID userID, LLUUID itemID, LLUUID primID, + bool isScriptRunning, byte[] data); public class Caps { private string m_httpListenerHostName; private uint m_httpListenPort; - + private string m_capsObjectPath = "00001-"; private string m_requestPath = "0000/"; private string m_mapLayerPath = "0001/"; private string m_newInventory = "0002/"; - //private string m_requestTexture = "0003/"; + //private string m_requestTexture = "0003/"; private string m_notecardUpdatePath = "0004/"; private string m_notecardTaskUpdatePath = "0005/"; - + //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; private LLUUID m_agentID; @@ -78,7 +78,7 @@ namespace OpenSim.Region.Capabilities public NewInventoryItem AddNewInventoryItem = null; public ItemUpdatedCallback ItemUpdatedCall = null; public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null; - + public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) { @@ -138,7 +138,7 @@ namespace OpenSim.Region.Capabilities /// <returns></returns> public string CapsRequest(string request, string path, string param) { - //Console.WriteLine("caps request " + request); + //Console.WriteLine("caps request " + request); string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); return result; } @@ -153,7 +153,7 @@ namespace OpenSim.Region.Capabilities string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; caps.MapLayer = capsBaseUrl + m_mapLayerPath; - // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; + // caps.RequestTextureDownload = capsBaseUrl + m_requestTexture; caps.NewFileAgentInventory = capsBaseUrl + m_newInventory; caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath; caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath; @@ -262,7 +262,7 @@ namespace OpenSim.Region.Capabilities } #endregion - + /// <summary> /// Callback for a client request for an upload url for a script task /// inventory update @@ -272,28 +272,28 @@ namespace OpenSim.Region.Capabilities /// <param name="param"></param> /// <returns></returns> public string ScriptTaskInventory(string request, string path, string param) - { + { try { // MainLog.Instance.Debug("CAPS", "request: {0}, path: {1}, param: {2}", request, path, param); - - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDTaskScriptUpdate llsdUpdateRequest = new LLSDTaskScriptUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdUpdateRequest); - + string capsBase = "/CAPS/" + m_capsObjectPath; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - + TaskInventoryScriptUpdater uploader = new TaskInventoryScriptUpdater( - llsdUpdateRequest.item_id, - llsdUpdateRequest.task_id, - llsdUpdateRequest.is_script_running, - capsBase + uploaderPath, - m_httpListener, - m_dumpAssetsToFile); + llsdUpdateRequest.item_id, + llsdUpdateRequest.task_id, + llsdUpdateRequest.is_script_running, + capsBase + uploaderPath, + m_httpListener, + m_dumpAssetsToFile); uploader.OnUpLoad += TaskScriptUpdated; - + m_httpListener.AddStreamHandler( new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + @@ -302,13 +302,13 @@ namespace OpenSim.Region.Capabilities LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; - + // MainLog.Instance.Verbose( // "CAPS", // "ScriptTaskInventory response: {0}", // LLSDHelpers.SerialiseLLSDReply(uploadResponse)); - - return LLSDHelpers.SerialiseLLSDReply(uploadResponse); + + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } catch (Exception e) { @@ -329,7 +329,7 @@ namespace OpenSim.Region.Capabilities public string NoteCardAgentInventory(string request, string path, string param) { //libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap)libsecondlife.StructuredData.LLSDParser.DeserializeBinary(Helpers.StringToField(request)); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); @@ -353,7 +353,7 @@ namespace OpenSim.Region.Capabilities // "CAPS", // "NoteCardAgentInventory response: {0}", // LLSDHelpers.SerialiseLLSDReply(uploadResponse)); - + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } @@ -453,7 +453,7 @@ namespace OpenSim.Region.Capabilities { return ItemUpdatedCall(m_agentID, itemID, data); } - + return LLUUID.Zero; } @@ -613,7 +613,7 @@ namespace OpenSim.Region.Capabilities fs.Close(); } } - + /// <summary> /// This class is a callback invoked when a client sends asset data to /// a task inventory script update url @@ -629,17 +629,17 @@ namespace OpenSim.Region.Capabilities private BaseHttpServer httpListener; private bool m_dumpAssetToFile; - public TaskInventoryScriptUpdater(LLUUID inventoryItemID, LLUUID primID, int isScriptRunning, + public TaskInventoryScriptUpdater(LLUUID inventoryItemID, LLUUID primID, int isScriptRunning, string path, BaseHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; this.inventoryItemID = inventoryItemID; this.primID = primID; - + // This comes in over the packet as an integer, but actually appears to be treated as a bool this.isScriptRunning = (0 == isScriptRunning ? false : true); - + uploaderPath = path; httpListener = httpServer; } @@ -659,7 +659,7 @@ namespace OpenSim.Region.Capabilities // "CAPS", // "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}", // data, path, param); - + string res = ""; LLSDTaskInventoryUploadComplete uploadComplete = new LLSDTaskInventoryUploadComplete(); @@ -668,7 +668,7 @@ namespace OpenSim.Region.Capabilities OnUpLoad(inventoryItemID, primID, isScriptRunning, data); } - uploadComplete.item_id = inventoryItemID; + uploadComplete.item_id = inventoryItemID; uploadComplete.task_id = primID; uploadComplete.state = "complete"; @@ -680,7 +680,7 @@ namespace OpenSim.Region.Capabilities { SaveAssetToFile("updatedtaskscript" + Util.RandomClass.Next(1, 1000) + ".dat", data); } - + // MainLog.Instance.Verbose("CAPS", "TaskInventoryScriptUpdater.uploaderCaps res: {0}", res); return res; @@ -689,9 +689,9 @@ namespace OpenSim.Region.Capabilities { MainLog.Instance.Error("CAPS", e.ToString()); } - + // XXX Maybe this should be some meaningful error packet - return null; + return null; } private void SaveAssetToFile(string filename, byte[] data) @@ -702,6 +702,6 @@ namespace OpenSim.Region.Capabilities bw.Close(); fs.Close(); } - } + } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSD.cs b/OpenSim/Framework/Communications/Capabilities/LLSD.cs index 987d6e6..dab926c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSD.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSD.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -28,12 +28,12 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Xml; +using System.Globalization; using System.IO; -using libsecondlife; using System.Security.Cryptography; using System.Text; +using System.Xml; +using libsecondlife; namespace OpenSim.Region.Capabilities { @@ -47,7 +47,9 @@ namespace OpenSim.Region.Capabilities /// </summary> public class LLSDParseException : Exception { - public LLSDParseException(string message) : base(message) { } + public LLSDParseException(string message) : base(message) + { + } } /// <summary> @@ -55,7 +57,9 @@ namespace OpenSim.Region.Capabilities /// </summary> public class LLSDSerializeException : Exception { - public LLSDSerializeException(string message) : base(message) { } + public LLSDSerializeException(string message) : base(message) + { + } } /// <summary> @@ -129,7 +133,7 @@ namespace OpenSim.Region.Capabilities if (obj is string) { writer.WriteStartElement(String.Empty, "string", String.Empty); - writer.WriteString((string)obj); + writer.WriteString((string) obj); writer.WriteEndElement(); } else if (obj is int) @@ -146,7 +150,7 @@ namespace OpenSim.Region.Capabilities } else if (obj is bool) { - bool b = (bool)obj; + bool b = (bool) obj; writer.WriteStartElement(String.Empty, "boolean", String.Empty); writer.WriteString(b ? "1" : "0"); writer.WriteEndElement(); @@ -157,7 +161,7 @@ namespace OpenSim.Region.Capabilities } else if (obj is LLUUID) { - LLUUID u = (LLUUID)obj; + LLUUID u = (LLUUID) obj; writer.WriteStartElement(String.Empty, "uuid", String.Empty); writer.WriteString(u.ToString()); writer.WriteEndElement(); @@ -463,7 +467,7 @@ namespace OpenSim.Region.Capabilities } else if (obj is string) { - return GetSpaces(indent) + "- string \"" + (string)obj + "\"\n"; + return GetSpaces(indent) + "- string \"" + (string) obj + "\"\n"; } else if (obj is int) { @@ -475,13 +479,13 @@ namespace OpenSim.Region.Capabilities } else if (obj is LLUUID) { - return GetSpaces(indent) + "- uuid " + ((LLUUID)obj).ToString() + Environment.NewLine; + return GetSpaces(indent) + "- uuid " + ((LLUUID) obj).ToString() + Environment.NewLine; } else if (obj is Hashtable) { StringBuilder ret = new StringBuilder(); ret.Append(GetSpaces(indent) + "- map" + Environment.NewLine); - Hashtable map = (Hashtable)obj; + Hashtable map = (Hashtable) obj; foreach (string key in map.Keys) { @@ -495,7 +499,7 @@ namespace OpenSim.Region.Capabilities { StringBuilder ret = new StringBuilder(); ret.Append(GetSpaces(indent) + "- array\n"); - ArrayList list = (ArrayList)obj; + ArrayList list = (ArrayList) obj; foreach (object item in list) { @@ -506,8 +510,8 @@ namespace OpenSim.Region.Capabilities } else if (obj is byte[]) { - return GetSpaces(indent) + "- binary\n" + Helpers.FieldToHexString((byte[])obj, GetSpaces(indent)) + - Environment.NewLine; + return GetSpaces(indent) + "- binary\n" + Helpers.FieldToHexString((byte[]) obj, GetSpaces(indent)) + + Environment.NewLine; } else { @@ -557,8 +561,8 @@ namespace OpenSim.Region.Capabilities double value; endPos = FindEnd(llsd, 1); - if (Double.TryParse(llsd.Substring(1, endPos - 1), System.Globalization.NumberStyles.Float, - Helpers.EnUsCulture.NumberFormat, out value)) + if (Double.TryParse(llsd.Substring(1, endPos - 1), NumberStyles.Float, + Helpers.EnUsCulture.NumberFormat, out value)) return value; else throw new LLSDParseException("Failed to parse double value type"); @@ -652,7 +656,7 @@ namespace OpenSim.Region.Capabilities private static int FindEnd(string llsd, int start) { - int end = llsd.IndexOfAny(new char[] { ',', ']', '}' }); + int end = llsd.IndexOfAny(new char[] {',', ']', '}'}); if (end == -1) end = llsd.Length - 1; return end; } @@ -673,4 +677,4 @@ namespace OpenSim.Region.Capabilities } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs index 2bc1643..d641b5c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -38,4 +38,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index 307e3e3..f838c85 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -41,4 +41,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index eb76d64..3b8c077 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index dfb1683..7b09cb3 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -34,7 +34,7 @@ namespace OpenSim.Region.Capabilities public string MapLayer = ""; public string NewFileAgentInventory = ""; //public string EventQueueGet = ""; - // public string RequestTextureDownload = ""; + // public string RequestTextureDownload = ""; // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; public string UpdateScriptAgentInventory = ""; diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 101d9c0..5e6e917 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -34,4 +34,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 60aa60c..28f838d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -30,7 +30,6 @@ using System.Collections; using System.IO; using System.Reflection; using System.Xml; -using libsecondlife; namespace OpenSim.Region.Capabilities { @@ -77,7 +76,7 @@ namespace OpenSim.Region.Capabilities writer.WriteString(fields[i].Name); writer.WriteEndElement(); LLSD.LLSDWriteOne(writer, fieldValue); - // libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + // libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( // writer, libsecondlife.StructuredData.LLSD.FromObject(fieldValue)); } } @@ -102,8 +101,8 @@ namespace OpenSim.Region.Capabilities else { LLSD.LLSDWriteOne(writer, obj); - //libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( - // writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); + //libsecondlife.StructuredData.LLSDParser.SerializeXmlElement( + // writer, libsecondlife.StructuredData.LLSD.FromObject(obj)); } } @@ -122,12 +121,12 @@ namespace OpenSim.Region.Capabilities FieldInfo field = myType.GetField((string) enumerator.Key); if (field != null) { - // if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) + // if (enumerator.Value is libsecondlife.StructuredData.LLSDMap) if (enumerator.Value is Hashtable) { object fieldValue = field.GetValue(obj); - DeserialiseLLSDMap((Hashtable)enumerator.Value, fieldValue); - // DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); + DeserialiseLLSDMap((Hashtable) enumerator.Value, fieldValue); + // DeserialiseLLSDMap((libsecondlife.StructuredData.LLSDMap) enumerator.Value, fieldValue); } else if (enumerator.Value is ArrayList) { @@ -149,4 +148,4 @@ namespace OpenSim.Region.Capabilities return obj; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 214b9c7..121b36a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -42,4 +42,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 48130b1..93b0f83 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 71cc358..4321d7b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -29,9 +29,7 @@ using System.Collections; using System.IO; using System.Text; -using libsecondlife; using OpenSim.Framework.Servers; -using System.Xml; namespace OpenSim.Region.Capabilities { @@ -54,10 +52,10 @@ namespace OpenSim.Region.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) + // libsecondlife.StructuredData.LLSDMap hash = (libsecondlife.StructuredData.LLSDMap) // libsecondlife.StructuredData.LLSDParser.DeserializeXml(new XmlTextReader(request)); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(request); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); @@ -68,4 +66,4 @@ namespace OpenSim.Region.Capabilities return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs index 3703efc..8d6550b 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskInventoryUploadComplete.cs @@ -25,10 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Capabilities -{ +{ [LLSDMap] public class LLSDTaskInventoryUploadComplete { @@ -36,15 +36,15 @@ namespace OpenSim.Region.Capabilities /// The task inventory item that was updated /// </summary> public LLUUID item_id; - + /// <summary> /// The task that was updated /// </summary> - public LLUUID task_id; - + public LLUUID task_id; + /// <summary> /// State of the upload. So far have only even seen this set to "complete" /// </summary> public string state; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs index 6dcf2b5..e9c77b8 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTaskScriptUpdate.cs @@ -26,10 +26,10 @@ * */ -using libsecondlife; - +using libsecondlife; + namespace OpenSim.Region.Capabilities -{ +{ [LLSDMap] public class LLSDTaskScriptUpdate { @@ -37,15 +37,15 @@ namespace OpenSim.Region.Capabilities /// The item containing the script to update /// </summary> public LLUUID item_id; - + /// <summary> /// The task containing the script /// </summary> public LLUUID task_id; - + /// <summary> /// Signals whether the script is currently active /// </summary> public int is_script_running; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index 70bfd2c..d10b0c0 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 7bbe16e..e851742 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -52,4 +52,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 4614756..02c54e1 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -26,9 +26,9 @@ * */ using System; +using System.Collections.Generic; using libsecondlife; using OpenSim.Framework.Communications.Cache; -using System.Collections.Generic; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; @@ -173,12 +173,13 @@ namespace OpenSim.Framework.Communications } } } + public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { - List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); + List<AvatarPickerAvatar> pickerlist = m_userService.GenerateAgentPickerRequestResponse(queryID, query); return pickerlist; } #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index d51f234..e2c2661 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -25,7 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Collections; using System.Collections.Generic; namespace OpenSim.Framework.Communications @@ -39,6 +38,5 @@ namespace OpenSim.Framework.Communications RegionInfo RequestNeighbourInfo(ulong regionHandle); Dictionary<string, string> GetGridSettings(); List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY); - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 3aa20a3..e2a96f6 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -31,8 +31,7 @@ namespace OpenSim.Framework.Communications { public interface IInterRegionCommunications { - - string rdebugRegionName{ get; set; } + string rdebugRegionName { get; set; } bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData); bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData); bool RegionUp(SearializableRegionInfo region, ulong regionhandle); @@ -45,6 +44,5 @@ namespace OpenSim.Framework.Communications bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID); void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID); - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index 9c493d4..f2e5cc5 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -52,4 +52,4 @@ namespace OpenSim.Framework.Communications /// <returns></returns> List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 534383a..098d08e 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -30,7 +30,6 @@ using System; using System.Collections.Generic; using System.Reflection; using libsecondlife; -using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications @@ -65,7 +64,7 @@ namespace OpenSim.Framework.Communications if (typeInterface != null) { IInventoryData plug = - (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); m_plugins.Add(plug.getName(), plug); MainLog.Instance.Verbose("AGENTINVENTORY", "Added IInventoryData Interface"); @@ -370,4 +369,4 @@ namespace OpenSim.Framework.Communications public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginResponse.cs b/OpenSim/Framework/Communications/LoginResponse.cs index ede3148..954aecb 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -525,9 +525,9 @@ namespace OpenSim.Framework.UserManagement set { welcomeMessage = value; } } - public BuddyList BuddList + public BuddyList BuddList { - get{return m_buddyList;} + get { return m_buddyList; } set { m_buddyList = value; } } @@ -591,4 +591,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 6d4cb68..a284910 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.UserManagement //CFK: CustomizeResponse contains sufficient strings to alleviate the need for this. //CKF: MainLog.Instance.Verbose("LOGIN", "Attempting login now..."); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); @@ -75,17 +75,17 @@ namespace OpenSim.Framework.UserManagement if (GoodXML) { - string firstname = (string)requestData["first"]; - string lastname = (string)requestData["last"]; - string passwd = (string)requestData["passwd"]; + string firstname = (string) requestData["first"]; + string lastname = (string) requestData["last"]; + string passwd = (string) requestData["passwd"]; userProfile = GetTheUser(firstname, lastname); if (userProfile == null) { MainLog.Instance.Verbose( - "LOGIN", + "LOGIN", "Could not find a profile for " + firstname + " " + lastname); - + return logResponse.CreateLoginFailedResponse(); } @@ -103,15 +103,14 @@ namespace OpenSim.Framework.UserManagement else { // If we already have a session... - + if (userProfile.currentAgent != null && userProfile.currentAgent.agentOnline) { userProfile.currentAgent = null; m_userManager.CommitAgent(ref userProfile); - + // Reject the login return logResponse.CreateAlreadyLoggedInResponse(); - } // Otherwise... // Create a new agent session @@ -132,7 +131,7 @@ namespace OpenSim.Framework.UserManagement userProfile.rootInventoryFolderID = inventData.RootFolderID; // Circuit Code - uint circode = (uint)(Util.RandomClass.Next()); + uint circode = (uint) (Util.RandomClass.Next()); logResponse.Lastname = userProfile.surname; logResponse.Firstname = userProfile.username; @@ -150,7 +149,7 @@ namespace OpenSim.Framework.UserManagement logResponse.InventoryLibRoot = InventoryLibRoot; logResponse.InventoryLibraryOwner = GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; + logResponse.CircuitCode = (Int32) circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten logResponse.Home = "!!null temporary value {home}!!"; // Overwritten @@ -277,7 +276,7 @@ namespace OpenSim.Framework.UserManagement TempHash["type_default"] = -1; TempHash["folder_id"] = "00000112-000f-0000-0000-000100bba001"; temp.Add(TempHash); - + return temp; } @@ -328,4 +327,4 @@ namespace OpenSim.Framework.UserManagement } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs index fd8ce38..e9c7bf3 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 5c77193..1aaf68e 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -238,7 +238,7 @@ namespace OpenSim.Framework.Communications } } realuri = sb.ToString(); - MainLog.Instance.Verbose("REST", "RestURL: {0}", realuri); + MainLog.Instance.Verbose("REST", "RestURL: {0}", realuri); return new Uri(sb.ToString()); } @@ -365,7 +365,7 @@ namespace OpenSim.Framework.Communications } public Stream Request(Stream src) - { + { _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; @@ -374,16 +374,16 @@ namespace OpenSim.Framework.Communications _asyncException = null; _request.ContentLength = src.Length; - MainLog.Instance.Verbose("REST", "Request Length {0}", _request.ContentLength); - MainLog.Instance.Verbose("REST", "Sending Web Request {0}", buildUri()); + MainLog.Instance.Verbose("REST", "Request Length {0}", _request.ContentLength); + MainLog.Instance.Verbose("REST", "Sending Web Request {0}", buildUri()); src.Seek(0, SeekOrigin.Begin); - MainLog.Instance.Verbose("REST", "Seek is ok"); + MainLog.Instance.Verbose("REST", "Seek is ok"); Stream dst = _request.GetRequestStream(); - MainLog.Instance.Verbose("REST", "GetRequestStream is ok"); + MainLog.Instance.Verbose("REST", "GetRequestStream is ok"); byte[] buf = new byte[1024]; int length = src.Read(buf, 0, 1024); - MainLog.Instance.Verbose("REST", "First Read is ok"); + MainLog.Instance.Verbose("REST", "First Read is ok"); while (length > 0) { dst.Write(buf, 0, length); @@ -440,4 +440,4 @@ namespace OpenSim.Framework.Communications #endregion Async Invocation } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index d946e00..f913d2c 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -27,7 +27,6 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Security.Cryptography; @@ -93,13 +92,13 @@ namespace OpenSim.Framework.UserManagement foreach (KeyValuePair<string, IUserData> plugin in _plugins) { UserProfileData profile = plugin.Value.GetUserByUUID(uuid); - + if (null != profile) { profile.currentAgent = getUserAgent(profile.UUID); return profile; - } - } + } + } return null; } @@ -112,11 +111,11 @@ namespace OpenSim.Framework.UserManagement try { pickerlist = plugin.Value.GeneratePickerResults(queryID, query); - } catch (Exception) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to generate AgentPickerData via " + plugin.Key + "(" + query + ")"); return new List<AvatarPickerAvatar>(); } } @@ -162,7 +161,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -188,7 +188,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -210,7 +211,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -222,7 +224,7 @@ namespace OpenSim.Framework.UserManagement { UserProfileData profile = GetUserProfile(agentID); profile.currentAgent = null; - + setUserProfile(profile); } @@ -242,7 +244,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -356,7 +359,8 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose("USERSTORAGE", "Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("USERSTORAGE", + "Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -365,6 +369,6 @@ namespace OpenSim.Framework.UserManagement public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); - public abstract UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid); + public abstract UserProfileData SetupMasterUser(LLUUID uuid); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs index b8e64f3..8bb31f8 100644 --- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs +++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs @@ -136,4 +136,4 @@ namespace OpenSim.Framework.Configuration doc = null; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/ConfigurationMember.cs b/OpenSim/Framework/ConfigurationMember.cs index 271c02c..a5ab613 100644 --- a/OpenSim/Framework/ConfigurationMember.cs +++ b/OpenSim/Framework/ConfigurationMember.cs @@ -27,24 +27,20 @@ */ using System; -using System.Reflection; -using System.Collections; using System.Collections.Generic; -using System.Text; +using System.Globalization; using System.Net; +using System.Reflection; using System.Xml; - using libsecondlife; - using OpenSim.Framework.Console; -using OpenSim.Framework; -using System.Globalization; namespace OpenSim.Framework { public class ConfigurationMember { public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result); + public delegate void ConfigurationOptionsLoad(); private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>(); @@ -55,29 +51,36 @@ namespace OpenSim.Framework private ConfigurationOptionResult resultFunction; private IGenericConfig configurationPlugin = null; + /// <summary> /// This is the default configuration DLL loaded /// </summary> private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll"; - public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) + + public ConfigurationMember(string configuration_filename, string configuration_description, + ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) { - this.configurationFilename = configuration_filename; - this.configurationDescription = configuration_description; - this.loadFunction = load_function; - this.resultFunction = result_function; + configurationFilename = configuration_filename; + configurationDescription = configuration_description; + loadFunction = load_function; + resultFunction = result_function; } - public ConfigurationMember(XmlNode configuration_xml, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) + + public ConfigurationMember(XmlNode configuration_xml, string configuration_description, + ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function) { - this.configurationFilename = ""; - this.configurationFromXMLNode = configuration_xml; - this.configurationDescription = configuration_description; - this.loadFunction = load_function; - this.resultFunction = result_function; + configurationFilename = ""; + configurationFromXMLNode = configuration_xml; + configurationDescription = configuration_description; + loadFunction = load_function; + resultFunction = result_function; } + public void setConfigurationFilename(string filename) { configurationFilename = filename; } + public void setConfigurationDescription(string desc) { configurationDescription = desc; @@ -92,9 +95,11 @@ namespace OpenSim.Framework { configurationPluginFilename = dll_filename; } + private void checkAndAddConfigOption(ConfigurationOption option) { - if ((option.configurationKey != "" && option.configurationQuestion != "") || (option.configurationKey != "" && option.configurationUseDefaultNoPrompt)) + if ((option.configurationKey != "" && option.configurationQuestion != "") || + (option.configurationKey != "" && option.configurationUseDefaultNoPrompt)) { if (!configurationOptions.Contains(option)) { @@ -103,11 +108,16 @@ namespace OpenSim.Framework } else { - MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + option.configurationKey + ")"); + MainLog.Instance.Notice( + "Required fields for adding a configuration option is invalid. Will not add this option (" + + option.configurationKey + ")"); } } - public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt) + public void addConfigurationOption(string configuration_key, + ConfigurationOption.ConfigurationTypes configuration_type, + string configuration_question, string configuration_default, + bool use_default_no_prompt) { ConfigurationOption configOption = new ConfigurationOption(); configOption.configurationKey = configuration_key; @@ -119,7 +129,11 @@ namespace OpenSim.Framework checkAndAddConfigOption(configOption); } - public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt, ConfigurationOption.ConfigurationOptionShouldBeAsked shouldIBeAskedDelegate) + public void addConfigurationOption(string configuration_key, + ConfigurationOption.ConfigurationTypes configuration_type, + string configuration_question, string configuration_default, + bool use_default_no_prompt, + ConfigurationOption.ConfigurationOptionShouldBeAsked shouldIBeAskedDelegate) { ConfigurationOption configOption = new ConfigurationOption(); configOption.configurationKey = configuration_key; @@ -133,26 +147,30 @@ namespace OpenSim.Framework public void performConfigurationRetrieve() { - configurationPlugin = this.LoadConfigDll(configurationPluginFilename); + configurationPlugin = LoadConfigDll(configurationPluginFilename); configurationOptions.Clear(); - if(loadFunction == null) + if (loadFunction == null) { - MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); + MainLog.Instance.Error("Load Function for '" + configurationDescription + + "' is null. Refusing to run configuration."); return; } - if(resultFunction == null) + if (resultFunction == null) { - MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration."); + MainLog.Instance.Error("Result Function for '" + configurationDescription + + "' is null. Refusing to run configuration."); return; } MainLog.Instance.Verbose("CONFIG", "Calling Configuration Load Function..."); - this.loadFunction(); + loadFunction(); - if(configurationOptions.Count <= 0) + if (configurationOptions.Count <= 0) { - MainLog.Instance.Error("CONFIG", "No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration."); + MainLog.Instance.Error("CONFIG", + "No configuration options were specified for '" + configurationOptions + + "'. Refusing to continue configuration."); return; } @@ -179,7 +197,7 @@ namespace OpenSim.Framework } else { - if (this.configurationFromXMLNode != null) + if (configurationFromXMLNode != null) { MainLog.Instance.Notice("Loading from XML Node, will not save to the file"); configurationPlugin.LoadDataFromString(configurationFromXMLNode.OuterXml); @@ -219,15 +237,22 @@ namespace OpenSim.Framework } else { - if ((configOption.shouldIBeAsked != null && configOption.shouldIBeAsked(configOption.configurationKey)) || configOption.shouldIBeAsked == null) + if ((configOption.shouldIBeAsked != null && + configOption.shouldIBeAsked(configOption.configurationKey)) || + configOption.shouldIBeAsked == null) { if (configurationDescription.Trim() != "") { - console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault); + console_result = + MainLog.Instance.CmdPrompt( + configurationDescription + ": " + configOption.configurationQuestion, + configOption.configurationDefault); } else { - console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault); + console_result = + MainLog.Instance.CmdPrompt(configOption.configurationQuestion, + configOption.configurationDefault); } } else @@ -235,7 +260,7 @@ namespace OpenSim.Framework //Dont Ask! Just use default console_result = configOption.configurationDefault; } - } + } } else { @@ -366,7 +391,9 @@ namespace OpenSim.Framework break; case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT: float floatResult; - if (float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out floatResult)) + if ( + float.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, + out floatResult)) { convertSuccess = true; return_result = floatResult; @@ -375,7 +402,9 @@ namespace OpenSim.Framework break; case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE: double doubleResult; - if (Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out doubleResult)) + if ( + Double.TryParse(console_result, NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, + out doubleResult)) { convertSuccess = true; return_result = doubleResult; @@ -391,9 +420,10 @@ namespace OpenSim.Framework configurationPlugin.SetAttribute(configOption.configurationKey, console_result); } - if (!this.resultFunction(configOption.configurationKey, return_result)) + if (!resultFunction(configOption.configurationKey, return_result)) { - Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again."); + MainLog.Instance.Notice( + "The handler for the last configuration option denied that input, please try again."); convertSuccess = false; ignoreNextFromConfig = true; } @@ -402,19 +432,27 @@ namespace OpenSim.Framework { if (configOption.configurationUseDefaultNoPrompt) { - MainLog.Instance.Error("CONFIG", string.Format("[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); + MainLog.Instance.Error("CONFIG", + string.Format( + "[{3}]:[{1}] is not valid default for parameter [{0}].\nThe configuration result must be parsable to {2}.\n", + configOption.configurationKey, console_result, errorMessage, + configurationFilename)); convertSuccess = true; } else { - MainLog.Instance.Warn("CONFIG", string.Format("[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", configOption.configurationKey, console_result, errorMessage, configurationFilename)); + MainLog.Instance.Warn("CONFIG", + string.Format( + "[{3}]:[{1}] is not a valid value [{0}].\nThe configuration result must be parsable to {2}.\n", + configOption.configurationKey, console_result, errorMessage, + configurationFilename)); ignoreNextFromConfig = true; } } } } - if(useFile) + if (useFile) { configurationPlugin.Commit(); configurationPlugin.Close(); @@ -436,7 +474,8 @@ namespace OpenSim.Framework if (typeInterface != null) { - plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug = + (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); } } } @@ -448,10 +487,10 @@ namespace OpenSim.Framework public void forceSetConfigurationOption(string configuration_key, string configuration_value) { - this.configurationPlugin.LoadData(); - this.configurationPlugin.SetAttribute(configuration_key, configuration_value); - this.configurationPlugin.Commit(); - this.configurationPlugin.Close(); + configurationPlugin.LoadData(); + configurationPlugin.SetAttribute(configuration_key, configuration_value); + configurationPlugin.Commit(); + configurationPlugin.Close(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/ConfigurationOption.cs b/OpenSim/Framework/ConfigurationOption.cs index b83be5e..7f9b5b5 100644 --- a/OpenSim/Framework/ConfigurationOption.cs +++ b/OpenSim/Framework/ConfigurationOption.cs @@ -30,7 +30,6 @@ namespace OpenSim.Framework { public class ConfigurationOption { - public delegate bool ConfigurationOptionShouldBeAsked(string configuration_key); public enum ConfigurationTypes diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index bba4f95..73ecd18 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs index 93540aa..606469d 100644 --- a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs +++ b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs @@ -32,4 +32,4 @@ namespace OpenSim.Framework.Console void RunCmd(string cmd, string[] cmdparams); void Show(string ShowWhat); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs index dd0c5fa..e7b1945 100644 --- a/OpenSim/Framework/Console/LogBase.cs +++ b/OpenSim/Framework/Console/LogBase.cs @@ -248,12 +248,12 @@ namespace OpenSim.Framework.Console // Some older systems dont support coloured text. System.Console.WriteLine(format, args); } - catch (System.FormatException) + catch (FormatException) { // Some older systems dont support coloured text. System.Console.WriteLine(args); } - + return; } } @@ -479,4 +479,4 @@ namespace OpenSim.Framework.Console } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Console/MainLog.cs b/OpenSim/Framework/Console/MainLog.cs index 16ba2c2..bea2a22 100644 --- a/OpenSim/Framework/Console/MainLog.cs +++ b/OpenSim/Framework/Console/MainLog.cs @@ -37,4 +37,4 @@ namespace OpenSim.Framework.Console set { instance = value; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs index 00999c2..2637166 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs @@ -140,16 +140,17 @@ namespace OpenSim.Framework.Data.DB4o { manager = null; } + /// <summary> /// // Returns a list of avatar and UUIDs that match the query /// </summary> - public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { //Do nothing yet List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); return returnlist; } + /// <summary> /// Returns the providers name /// </summary> @@ -173,4 +174,4 @@ namespace OpenSim.Framework.Data.DB4o return null; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.DB4o/DB4oManager.cs b/OpenSim/Framework/Data.DB4o/DB4oManager.cs index cf1dfae..4b1b451 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oManager.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs @@ -167,4 +167,4 @@ namespace OpenSim.Framework.Data.DB4o } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs index 383bfbe..e0973f1 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs @@ -26,8 +26,8 @@ * */ using System; -using System.IO; using System.Collections.Generic; +using System.IO; using libsecondlife; namespace OpenSim.Framework.Data.DB4o @@ -132,12 +132,14 @@ namespace OpenSim.Framework.Data.DB4o return null; } } - public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) + + public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { //Do nothing yet - List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); + List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); return returnlist; } + /// <summary> /// Creates a new user profile /// </summary> @@ -225,4 +227,4 @@ namespace OpenSim.Framework.Data.DB4o return "0.1"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs index cc0422c..08fbef0 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLAssetData.cs @@ -27,18 +27,18 @@ */ using System; -using System.Data; using System.Collections.Generic; +using System.Data; using System.Data.SqlClient; - using libsecondlife; using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.MSSQL { - class MSSQLAssetData : IAssetProvider + internal class MSSQLAssetData : IAssetProvider { - MSSQLManager database; + private MSSQLManager database; + #region IAssetProvider Members private void UpgradeAssetsTable(string tableName) @@ -46,7 +46,7 @@ namespace OpenSim.Framework.Data.MSSQL // null as the version, indicates that the table didn't exist if (tableName == null) { - MainLog.Instance.Notice("ASSETS", "Creating new database tables"); + MainLog.Instance.Notice("ASSETS", "Creating new database tables"); database.ExecuteResourceSql("CreateAssetsTable.sql"); return; } @@ -57,14 +57,12 @@ namespace OpenSim.Framework.Data.MSSQL /// </summary> private void TestTables() { - Dictionary<string, string> tableList = new Dictionary<string, string>(); tableList["assets"] = null; database.GetTableVersion(tableList); UpgradeAssetsTable(tableList["assets"]); - } public AssetBase FetchAsset(LLUUID assetID) @@ -80,30 +78,27 @@ namespace OpenSim.Framework.Data.MSSQL asset = database.getAssetRow(reader); reader.Close(); result.Dispose(); - + return asset; } public void CreateAsset(AssetBase asset) { - - if (ExistsAsset((LLUUID)asset.FullID)) + if (ExistsAsset((LLUUID) asset.FullID)) { return; } - SqlCommand cmd = new SqlCommand( - "INSERT INTO assets ([id], [name], [description], [assetType], [invType], [local], [temporary], [data])"+ - " VALUES "+ + "INSERT INTO assets ([id], [name], [description], [assetType], [invType], [local], [temporary], [data])" + + " VALUES " + "(@id, @name, @description, @assetType, @invType, @local, @temporary, @data)", database.getConnection()); - + using (cmd) { - //SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar); //p.Value = asset.FullID.ToString(); cmd.Parameters.AddWithValue("id", asset.FullID.ToString()); @@ -127,24 +122,23 @@ namespace OpenSim.Framework.Data.MSSQL { throw; } - + cmd.Dispose(); } - } public void UpdateAsset(AssetBase asset) { SqlCommand command = new SqlCommand("UPDATE assets set id = @id, " + - "name = @name, " + - "description = @description," + - "assetType = @assetType," + - "invType = @invType," + - "local = @local,"+ - "temporary = @temporary," + - "data = @data where " + - "id = @keyId;", database.getConnection()); + "name = @name, " + + "description = @description," + + "assetType = @assetType," + + "invType = @invType," + + "local = @local," + + "temporary = @temporary," + + "data = @data where " + + "id = @keyId;", database.getConnection()); SqlParameter param1 = new SqlParameter("@id", asset.FullID.ToString()); SqlParameter param2 = new SqlParameter("@name", asset.Name); SqlParameter param3 = new SqlParameter("@description", asset.Description); @@ -172,12 +166,12 @@ namespace OpenSim.Framework.Data.MSSQL { MainLog.Instance.Error(e.ToString()); } - } public bool ExistsAsset(LLUUID uuid) { - if (FetchAsset(uuid) != null) { + if (FetchAsset(uuid) != null) + { return true; } return false; @@ -194,11 +188,8 @@ namespace OpenSim.Framework.Data.MSSQL #region IPlugin Members - - public void Initialise() { - IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini"); string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source"); string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog"); @@ -206,7 +197,9 @@ namespace OpenSim.Framework.Data.MSSQL string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - this.database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); + database = + new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, + settingPassword); TestTables(); } @@ -214,7 +207,7 @@ namespace OpenSim.Framework.Data.MSSQL public string Version { // get { return database.getVersion(); } - get { return database.getVersion(); } + get { return database.getVersion(); } } public string Name @@ -224,4 +217,4 @@ namespace OpenSim.Framework.Data.MSSQL #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs index 72db568..7d228e6 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs @@ -57,8 +57,9 @@ namespace OpenSim.Framework.Data.MSSQL string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); - + database = + new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, + settingPassword); } /// <summary> @@ -120,14 +121,13 @@ namespace OpenSim.Framework.Data.MSSQL result.Dispose(); return row; - } catch (Exception) - { - if (reader != null) { + { + if (reader != null) + { reader.Close(); } - } return null; } @@ -135,7 +135,6 @@ namespace OpenSim.Framework.Data.MSSQL /// <summary> /// // Returns a list of avatar and UUIDs that match the query /// </summary> - public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); @@ -152,18 +151,19 @@ namespace OpenSim.Framework.Data.MSSQL param["second"] = querysplit[1]; IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -175,13 +175,9 @@ namespace OpenSim.Framework.Data.MSSQL MainLog.Instance.Error(e.ToString()); return returnlist; } - - - } else if (querysplit.Length == 1) { - try { lock (database) @@ -191,18 +187,19 @@ namespace OpenSim.Framework.Data.MSSQL param["second"] = querysplit[1]; IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -225,8 +222,8 @@ namespace OpenSim.Framework.Data.MSSQL /// <returns>The sim profile</returns> public RegionProfileData GetProfileByLLUUID(LLUUID uuid) { - Dictionary<string, string> param = new Dictionary<string, string>(); - param["uuid"] = uuid.ToString(); + Dictionary<string, string> param = new Dictionary<string, string>(); + param["uuid"] = uuid.ToString(); IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param); IDataReader reader = result.ExecuteReader(); @@ -244,7 +241,6 @@ namespace OpenSim.Framework.Data.MSSQL /// <returns>A dataresponse enum indicating success</returns> public DataResponse AddProfile(RegionProfileData profile) { - try { if (GetProfileByLLUUID(profile.UUID) != null) @@ -310,4 +306,4 @@ namespace OpenSim.Framework.Data.MSSQL return null; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs index a6b8819..4b2c7af 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLInventoryData.cs @@ -26,10 +26,9 @@ * */ using System; -using System.IO; +using System.Collections.Generic; using System.Data; using System.Data.SqlClient; -using System.Collections.Generic; using libsecondlife; using OpenSim.Framework.Console; @@ -57,7 +56,9 @@ namespace OpenSim.Framework.Data.MSSQL string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); + database = + new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, + settingPassword); TestTables(); } @@ -72,7 +73,6 @@ namespace OpenSim.Framework.Data.MSSQL //database.ExecuteResourceSql("UpgradeFoldersTableToVersion2.sql"); return; } - } private void UpgradeItemsTable(string tableName) @@ -88,17 +88,17 @@ namespace OpenSim.Framework.Data.MSSQL private void TestTables() { - Dictionary<string, string> tableList = new Dictionary<string, string>(); tableList["inventoryfolders"] = null; tableList["inventoryitems"] = null; database.GetTableVersion(tableList); - + UpgradeFoldersTable(tableList["inventoryfolders"]); UpgradeItemsTable(tableList["inventoryitems"]); } + #endregion /// <summary> @@ -124,7 +124,7 @@ namespace OpenSim.Framework.Data.MSSQL /// <returns>A string containing the DB provider</returns> public string getVersion() { - return database.getVersion(); + return database.getVersion(); } /// <summary> @@ -143,15 +143,16 @@ namespace OpenSim.Framework.Data.MSSQL Dictionary<string, string> param = new Dictionary<string, string>(); param["parentFolderID"] = folderID.ToString(); - IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID", param); + IDbCommand result = + database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = @parentFolderID", param); IDataReader reader = result.ExecuteReader(); - while(reader.Read()) + while (reader.Read()) items.Add(readInventoryItem(reader)); reader.Close(); result.Dispose(); - + return items; } } @@ -174,16 +175,17 @@ namespace OpenSim.Framework.Data.MSSQL { lock (database) { - Dictionary<string, string> param = new Dictionary<string, string>(); param["uuid"] = user.ToString(); param["zero"] = LLUUID.Zero.ToString(); - IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param); + IDbCommand result = + database.Query( + "SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param); IDataReader reader = result.ExecuteReader(); List<InventoryFolderBase> items = new List<InventoryFolderBase>(); - while(reader.Read()) + while (reader.Read()) items.Add(readInventoryFolder(reader)); @@ -212,24 +214,27 @@ namespace OpenSim.Framework.Data.MSSQL param["uuid"] = user.ToString(); param["zero"] = LLUUID.Zero.ToString(); - IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param); + IDbCommand result = + database.Query( + "SELECT * FROM inventoryfolders WHERE parentFolderID = @zero AND agentID = @uuid", param); IDataReader reader = result.ExecuteReader(); List<InventoryFolderBase> items = new List<InventoryFolderBase>(); - while(reader.Read()) + while (reader.Read()) items.Add(readInventoryFolder(reader)); InventoryFolderBase rootFolder = null; - + // There should only ever be one root folder for a user. However, if there's more // than one we'll simply use the first one rather than failing. It would be even // nicer to print some message to this effect, but this feels like it's too low a // to put such a message out, and it's too minor right now to spare the time to // suitably refactor. - if (items.Count > 0) { + if (items.Count > 0) + { rootFolder = items[0]; } - + reader.Close(); result.Dispose(); @@ -259,12 +264,13 @@ namespace OpenSim.Framework.Data.MSSQL param["parentFolderID"] = parentID.ToString(); - IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @parentFolderID", param); + IDbCommand result = + database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = @parentFolderID", param); IDataReader reader = result.ExecuteReader(); List<InventoryFolderBase> items = new List<InventoryFolderBase>(); - - while(reader.Read()) + + while (reader.Read()) items.Add(readInventoryFolder(reader)); reader.Close(); @@ -292,17 +298,17 @@ namespace OpenSim.Framework.Data.MSSQL { InventoryItemBase item = new InventoryItemBase(); - item.inventoryID = new LLUUID((string)reader["inventoryID"]); - item.assetID = new LLUUID((string)reader["assetID"]); - item.assetType = (int)reader["assetType"]; - item.parentFolderID = new LLUUID((string)reader["parentFolderID"]); - item.avatarID = new LLUUID((string)reader["avatarID"]); - item.inventoryName = (string)reader["inventoryName"]; - item.inventoryDescription = (string)reader["inventoryDescription"]; + item.inventoryID = new LLUUID((string) reader["inventoryID"]); + item.assetID = new LLUUID((string) reader["assetID"]); + item.assetType = (int) reader["assetType"]; + item.parentFolderID = new LLUUID((string) reader["parentFolderID"]); + item.avatarID = new LLUUID((string) reader["avatarID"]); + item.inventoryName = (string) reader["inventoryName"]; + item.inventoryDescription = (string) reader["inventoryDescription"]; item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]); item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]); - item.invType = (int)reader["invType"]; - item.creatorsID = new LLUUID((string)reader["creatorID"]); + item.invType = (int) reader["invType"]; + item.creatorsID = new LLUUID((string) reader["creatorID"]); item.inventoryBasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]); item.inventoryEveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]); return item; @@ -322,7 +328,6 @@ namespace OpenSim.Framework.Data.MSSQL /// <returns>An inventory item</returns> public InventoryItemBase getInventoryItem(LLUUID itemID) { - try { lock (database) @@ -330,11 +335,12 @@ namespace OpenSim.Framework.Data.MSSQL Dictionary<string, string> param = new Dictionary<string, string>(); param["inventoryID"] = itemID.ToString(); - IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID", param); + IDbCommand result = + database.Query("SELECT * FROM inventoryitems WHERE inventoryID = @inventoryID", param); IDataReader reader = result.ExecuteReader(); InventoryItemBase item = null; - if(reader.Read()) + if (reader.Read()) item = readInventoryItem(reader); reader.Close(); @@ -361,12 +367,12 @@ namespace OpenSim.Framework.Data.MSSQL try { InventoryFolderBase folder = new InventoryFolderBase(); - folder.agentID = new LLUUID((string)reader["agentID"]); - folder.parentID = new LLUUID((string)reader["parentFolderID"]); - folder.folderID = new LLUUID((string)reader["folderID"]); - folder.name = (string)reader["folderName"]; - folder.type = (short)reader["type"]; - folder.version = (ushort)((int)reader["version"]); + folder.agentID = new LLUUID((string) reader["agentID"]); + folder.parentID = new LLUUID((string) reader["parentFolderID"]); + folder.folderID = new LLUUID((string) reader["folderID"]); + folder.name = (string) reader["folderName"]; + folder.type = (short) reader["type"]; + folder.version = (ushort) ((int) reader["version"]); return folder; } catch (Exception e) @@ -389,7 +395,7 @@ namespace OpenSim.Framework.Data.MSSQL { lock (database) { - Dictionary<string, string> param = new Dictionary<string,string>(); + Dictionary<string, string> param = new Dictionary<string, string>(); param["uuid"] = folderID.ToString(); IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = @uuid", param); @@ -418,8 +424,10 @@ namespace OpenSim.Framework.Data.MSSQL public void addInventoryItem(InventoryItemBase item) { string sql = "INSERT INTO inventoryitems"; - sql += "([inventoryID], [assetID], [assetType], [parentFolderID], [avatarID], [inventoryName], [inventoryDescription], [inventoryNextPermissions], [inventoryCurrentPermissions], [invType], [creatorID], [inventoryBasePermissions], [inventoryEveryOnePermissions]) VALUES "; - sql += "(@inventoryID, @assetID, @assetType, @parentFolderID, @avatarID, @inventoryName, @inventoryDescription, @inventoryNextPermissions, @inventoryCurrentPermissions, @invType, @creatorID, @inventoryBasePermissions, @inventoryEveryOnePermissions);"; + sql += + "([inventoryID], [assetID], [assetType], [parentFolderID], [avatarID], [inventoryName], [inventoryDescription], [inventoryNextPermissions], [inventoryCurrentPermissions], [invType], [creatorID], [inventoryBasePermissions], [inventoryEveryOnePermissions]) VALUES "; + sql += + "(@inventoryID, @assetID, @assetType, @parentFolderID, @avatarID, @inventoryName, @inventoryDescription, @inventoryNextPermissions, @inventoryCurrentPermissions, @invType, @creatorID, @inventoryBasePermissions, @inventoryEveryOnePermissions);"; try { @@ -441,7 +449,6 @@ namespace OpenSim.Framework.Data.MSSQL IDbCommand result = database.Query(sql, param); result.ExecuteNonQuery(); result.Dispose(); - } catch (SqlException e) { @@ -454,21 +461,21 @@ namespace OpenSim.Framework.Data.MSSQL /// </summary> /// <param name="item">Inventory item to update</param> public void updateInventoryItem(InventoryItemBase item) - { + { SqlCommand command = new SqlCommand("UPDATE inventoryitems set inventoryID = @inventoryID, " + - "assetID = @assetID, " + - "assetType = @assetType" + - "parentFolderID = @parentFolderID" + - "avatarID = @avatarID" + - "inventoryName = @inventoryName"+ - "inventoryDescription = @inventoryDescription" + - "inventoryNextPermissions = @inventoryNextPermissions" + - "inventoryCurrentPermissions = @inventoryCurrentPermissions" + - "invType = @invType" + - "creatorID = @creatorID" + - "inventoryBasePermissions = @inventoryBasePermissions" + - "inventoryEveryOnePermissions = @inventoryEveryOnePermissions) where " + - "invenoryID = @keyInventoryID;", database.getConnection()); + "assetID = @assetID, " + + "assetType = @assetType" + + "parentFolderID = @parentFolderID" + + "avatarID = @avatarID" + + "inventoryName = @inventoryName" + + "inventoryDescription = @inventoryDescription" + + "inventoryNextPermissions = @inventoryNextPermissions" + + "inventoryCurrentPermissions = @inventoryCurrentPermissions" + + "invType = @invType" + + "creatorID = @creatorID" + + "inventoryBasePermissions = @inventoryBasePermissions" + + "inventoryEveryOnePermissions = @inventoryEveryOnePermissions) where " + + "invenoryID = @keyInventoryID;", database.getConnection()); SqlParameter param1 = new SqlParameter("@inventoryID", item.inventoryID.ToString()); SqlParameter param2 = new SqlParameter("@assetID", item.assetID); SqlParameter param3 = new SqlParameter("@assetType", item.assetType); @@ -481,7 +488,7 @@ namespace OpenSim.Framework.Data.MSSQL SqlParameter param10 = new SqlParameter("@invType", item.invType); SqlParameter param11 = new SqlParameter("@creatorID", item.creatorsID); SqlParameter param12 = new SqlParameter("@inventoryBasePermissions", item.inventoryBasePermissions); - SqlParameter param13 = new SqlParameter("@inventoryEveryOnePermissions", item.inventoryEveryOnePermissions); + SqlParameter param13 = new SqlParameter("@inventoryEveryOnePermissions", item.inventoryEveryOnePermissions); SqlParameter param14 = new SqlParameter("@keyInventoryID", item.inventoryID.ToString()); command.Parameters.Add(param1); command.Parameters.Add(param2); @@ -506,7 +513,6 @@ namespace OpenSim.Framework.Data.MSSQL { MainLog.Instance.Error(e.ToString()); } - } /// <summary> @@ -523,8 +529,6 @@ namespace OpenSim.Framework.Data.MSSQL IDbCommand cmd = database.Query("DELETE FROM inventoryitems WHERE inventoryID=@uuid", param); cmd.ExecuteNonQuery(); cmd.Dispose(); - - } catch (SqlException e) { @@ -539,7 +543,8 @@ namespace OpenSim.Framework.Data.MSSQL /// <param name="folder">Folder to create</param> public void addInventoryFolder(InventoryFolderBase folder) { - string sql = "INSERT INTO inventoryfolders ([folderID], [agentID], [parentFolderID], [folderName], [type], [version]) VALUES "; + string sql = + "INSERT INTO inventoryfolders ([folderID], [agentID], [parentFolderID], [folderName], [type], [version]) VALUES "; sql += "(@folderID, @agentID, @parentFolderID, @folderName, @type, @version);"; @@ -550,9 +555,9 @@ namespace OpenSim.Framework.Data.MSSQL param["folderName"] = folder.name; param["type"] = Convert.ToString(folder.type); param["version"] = Convert.ToString(folder.version); - + try - { + { IDbCommand result = database.Query(sql, param); result.ExecuteNonQuery(); result.Dispose(); @@ -567,16 +572,15 @@ namespace OpenSim.Framework.Data.MSSQL /// Updates an inventory folder /// </summary> /// <param name="folder">Folder to update</param> - public void updateInventoryFolder(InventoryFolderBase folder) { SqlCommand command = new SqlCommand("UPDATE inventoryfolders set folderID = @folderID, " + - "agentID = @agentID, " + - "parentFolderID = @parentFolderID," + - "folderName = @folderName," + - "type = @type," + - "version = @version where " + - "folderID = @keyFolderID;", database.getConnection()); + "agentID = @agentID, " + + "parentFolderID = @parentFolderID," + + "folderName = @folderName," + + "type = @type," + + "version = @version where " + + "folderID = @keyFolderID;", database.getConnection()); SqlParameter param1 = new SqlParameter("@folderID", folder.folderID.ToString()); SqlParameter param2 = new SqlParameter("@agentID", folder.agentID.ToString()); SqlParameter param3 = new SqlParameter("@parentFolderID", folder.parentID.ToString()); @@ -600,20 +604,17 @@ namespace OpenSim.Framework.Data.MSSQL { MainLog.Instance.Error(e.ToString()); } - - } /// <summary> /// Updates an inventory folder /// </summary> /// <param name="folder">Folder to update</param> - public void moveInventoryFolder(InventoryFolderBase folder) { SqlCommand command = new SqlCommand("UPDATE inventoryfolders set folderID = @folderID, " + - "parentFolderID = @parentFolderID," + - "folderID = @keyFolderID;", database.getConnection()); + "parentFolderID = @parentFolderID," + + "folderID = @keyFolderID;", database.getConnection()); SqlParameter param1 = new SqlParameter("@folderID", folder.folderID.ToString()); SqlParameter param2 = new SqlParameter("@parentFolderID", folder.parentID.ToString()); SqlParameter param3 = new SqlParameter("@keyFolderID", folder.folderID.ToString()); @@ -629,8 +630,6 @@ namespace OpenSim.Framework.Data.MSSQL { MainLog.Instance.Error(e.ToString()); } - - } /// <summary> @@ -645,7 +644,7 @@ namespace OpenSim.Framework.Data.MSSQL foreach (InventoryFolderBase f in subfolderList) folders.Add(f); } - + /// <summary> /// Returns all child folders in the hierarchy from the parent folder and down /// </summary> @@ -672,7 +671,6 @@ namespace OpenSim.Framework.Data.MSSQL IDbCommand cmd = database.Query("DELETE FROM inventoryfolders WHERE folderID=@folderID", param); cmd.ExecuteNonQuery(); cmd.Dispose(); - } catch (SqlException e) { @@ -689,7 +687,8 @@ namespace OpenSim.Framework.Data.MSSQL param["parentFolderID"] = folderID.ToString(); - IDbCommand cmd = database.Query("DELETE FROM inventoryitems WHERE parentFolderID=@parentFolderID", param); + IDbCommand cmd = + database.Query("DELETE FROM inventoryitems WHERE parentFolderID=@parentFolderID", param); cmd.ExecuteNonQuery(); cmd.Dispose(); } @@ -724,4 +723,4 @@ namespace OpenSim.Framework.Data.MSSQL } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLLogData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLLogData.cs index a5b33ec..c3ec7c6 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLLogData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLLogData.cs @@ -25,14 +25,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; - namespace OpenSim.Framework.Data.MSSQL { /// <summary> /// An interface to the log database for MySQL /// </summary> - class MSSQLLogData : ILogData + internal class MSSQLLogData : ILogData { /// <summary> /// The database manager @@ -51,7 +49,9 @@ namespace OpenSim.Framework.Data.MSSQL string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); + database = + new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, + settingPassword); } /// <summary> @@ -63,7 +63,8 @@ namespace OpenSim.Framework.Data.MSSQL /// <param name="arguments">The arguments passed to the method</param> /// <param name="priority">How critical is this?</param> /// <param name="logMessage">The message to log</param> - public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) + public void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, + string logMessage) { try { @@ -101,4 +102,4 @@ namespace OpenSim.Framework.Data.MSSQL return "0.1"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs index b009a56..0dc3338 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.Collections.Generic; using System.Data; @@ -32,7 +33,6 @@ using System.Data.SqlClient; using System.IO; using System.Reflection; using libsecondlife; - using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.MSSQL @@ -40,12 +40,12 @@ namespace OpenSim.Framework.Data.MSSQL /// <summary> /// A management class for the MS SQL Storage Engine /// </summary> - class MSSQLManager + internal class MSSQLManager { /// <summary> /// The database connection object /// </summary> - IDbConnection dbcon; + private IDbConnection dbcon; /// <summary> /// Connection string for ADO.net @@ -60,12 +60,14 @@ namespace OpenSim.Framework.Data.MSSQL /// <param name="username">The username logging into the database</param> /// <param name="password">The password for the user logging in</param> /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> - public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId, string password) + public MSSQLManager(string dataSource, string initialCatalog, string persistSecurityInfo, string userId, + string password) { try { - - connectionString = "Data Source=" + dataSource + ";Initial Catalog=" + initialCatalog + ";Persist Security Info=" + persistSecurityInfo + ";User ID=" + userId + ";Password=" + password+";"; + connectionString = "Data Source=" + dataSource + ";Initial Catalog=" + initialCatalog + + ";Persist Security Info=" + persistSecurityInfo + ";User ID=" + userId + ";Password=" + + password + ";"; dbcon = new SqlConnection(connectionString); TestTables(dbcon); dbcon.Open(); @@ -78,7 +80,7 @@ namespace OpenSim.Framework.Data.MSSQL private bool TestTables(IDbConnection conn) { - IDbCommand cmd = this.Query("SELECT * FROM regions", new Dictionary<string, string>()); + IDbCommand cmd = Query("SELECT * FROM regions", new Dictionary<string, string>()); //SqlCommand cmd = (SqlCommand)dbcon.CreateCommand(); //cmd.CommandText = "SELECT * FROM regions"; try @@ -90,7 +92,7 @@ namespace OpenSim.Framework.Data.MSSQL } catch (Exception) { - MainLog.Instance.Verbose("DATASTORE", "MSSQL Database doesn't exist... creating"); + MainLog.Instance.Verbose("DATASTORE", "MSSQL Database doesn't exist... creating"); InitDB(conn); } return true; @@ -100,66 +102,66 @@ namespace OpenSim.Framework.Data.MSSQL { string createRegions = defineTable(createRegionsTable()); Dictionary<string, string> param = new Dictionary<string, string>(); - IDbCommand pcmd = this.Query(createRegions, param); - if (conn.State == ConnectionState.Closed) { + IDbCommand pcmd = Query(createRegions, param); + if (conn.State == ConnectionState.Closed) + { conn.Open(); - } + } pcmd.ExecuteNonQuery(); pcmd.Dispose(); - this.ExecuteResourceSql("Mssql-users.sql"); - this.ExecuteResourceSql("Mssql-agents.sql"); - this.ExecuteResourceSql("Mssql-logs.sql"); + ExecuteResourceSql("Mssql-users.sql"); + ExecuteResourceSql("Mssql-agents.sql"); + ExecuteResourceSql("Mssql-logs.sql"); conn.Close(); - } private DataTable createRegionsTable() { DataTable regions = new DataTable("regions"); - createCol(regions, "regionHandle", typeof(ulong)); - createCol(regions, "regionName", typeof(System.String)); - createCol(regions, "uuid", typeof(System.String)); + createCol(regions, "regionHandle", typeof (ulong)); + createCol(regions, "regionName", typeof (String)); + createCol(regions, "uuid", typeof (String)); - createCol(regions, "regionRecvKey", typeof(System.String)); - createCol(regions, "regionSecret", typeof(System.String)); - createCol(regions, "regionSendKey", typeof(System.String)); + createCol(regions, "regionRecvKey", typeof (String)); + createCol(regions, "regionSecret", typeof (String)); + createCol(regions, "regionSendKey", typeof (String)); - createCol(regions, "regionDataURI", typeof(System.String)); - createCol(regions, "serverIP", typeof(System.String)); - createCol(regions, "serverPort", typeof(System.String)); - createCol(regions, "serverURI", typeof(System.String)); + createCol(regions, "regionDataURI", typeof (String)); + createCol(regions, "serverIP", typeof (String)); + createCol(regions, "serverPort", typeof (String)); + createCol(regions, "serverURI", typeof (String)); - createCol(regions, "locX", typeof(uint)); - createCol(regions, "locY", typeof(uint)); - createCol(regions, "locZ", typeof(uint)); + createCol(regions, "locX", typeof (uint)); + createCol(regions, "locY", typeof (uint)); + createCol(regions, "locZ", typeof (uint)); - createCol(regions, "eastOverrideHandle", typeof(ulong)); - createCol(regions, "westOverrideHandle", typeof(ulong)); - createCol(regions, "southOverrideHandle", typeof(ulong)); - createCol(regions, "northOverrideHandle", typeof(ulong)); + createCol(regions, "eastOverrideHandle", typeof (ulong)); + createCol(regions, "westOverrideHandle", typeof (ulong)); + createCol(regions, "southOverrideHandle", typeof (ulong)); + createCol(regions, "northOverrideHandle", typeof (ulong)); - createCol(regions, "regionAssetURI", typeof(System.String)); - createCol(regions, "regionAssetRecvKey", typeof(System.String)); - createCol(regions, "regionAssetSendKey", typeof(System.String)); + createCol(regions, "regionAssetURI", typeof (String)); + createCol(regions, "regionAssetRecvKey", typeof (String)); + createCol(regions, "regionAssetSendKey", typeof (String)); - createCol(regions, "regionUserURI", typeof(System.String)); - createCol(regions, "regionUserRecvKey", typeof(System.String)); - createCol(regions, "regionUserSendKey", typeof(System.String)); + createCol(regions, "regionUserURI", typeof (String)); + createCol(regions, "regionUserRecvKey", typeof (String)); + createCol(regions, "regionUserSendKey", typeof (String)); - createCol(regions, "regionMapTexture", typeof(System.String)); - createCol(regions, "serverHttpPort", typeof(System.String)); - createCol(regions, "serverRemotingPort", typeof(uint)); + createCol(regions, "regionMapTexture", typeof (String)); + createCol(regions, "serverHttpPort", typeof (String)); + createCol(regions, "serverRemotingPort", typeof (uint)); // Add in contraints - regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] }; + regions.PrimaryKey = new DataColumn[] {regions.Columns["UUID"]}; return regions; } - protected static void createCol(DataTable dt, string name, System.Type type) + protected static void createCol(DataTable dt, string name, Type type) { DataColumn col = new DataColumn(name, type); dt.Columns.Add(col); @@ -172,10 +174,11 @@ namespace OpenSim.Framework.Data.MSSQL foreach (DataColumn col in dt.Columns) { if (subsql.Length > 0) - { // a map function would rock so much here + { + // a map function would rock so much here subsql += ",\n"; } - + subsql += col.ColumnName + " " + SqlType(col.DataType); if (col == dt.PrimaryKey[0]) { @@ -192,19 +195,19 @@ namespace OpenSim.Framework.Data.MSSQL // slightly differently. private static string SqlType(Type type) { - if (type == typeof(System.String)) + if (type == typeof (String)) { return "varchar(255)"; } - else if (type == typeof(System.Int32)) + else if (type == typeof (Int32)) { return "integer"; } - else if (type == typeof(System.Double)) + else if (type == typeof (Double)) { return "float"; } - else if (type == typeof(System.Byte[])) + else if (type == typeof (Byte[])) { return "image"; } @@ -254,14 +257,14 @@ namespace OpenSim.Framework.Data.MSSQL /// <returns>A Sql DB Command</returns> public IDbCommand Query(string sql, Dictionary<string, string> parameters) { - SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand(); - dbcommand.CommandText = sql; + SqlCommand dbcommand = (SqlCommand) dbcon.CreateCommand(); + dbcommand.CommandText = sql; foreach (KeyValuePair<string, string> param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - - return (IDbCommand)dbcommand; + + return (IDbCommand) dbcommand; } /// <summary> @@ -277,20 +280,20 @@ namespace OpenSim.Framework.Data.MSSQL { // Region Main regionprofile.regionHandle = Convert.ToUInt64(reader["regionHandle"]); - regionprofile.regionName = (string)reader["regionName"]; - regionprofile.UUID = new LLUUID((string)reader["uuid"]); + regionprofile.regionName = (string) reader["regionName"]; + regionprofile.UUID = new LLUUID((string) reader["uuid"]); // Secrets - regionprofile.regionRecvKey = (string)reader["regionRecvKey"]; - regionprofile.regionSecret = (string)reader["regionSecret"]; - regionprofile.regionSendKey = (string)reader["regionSendKey"]; + regionprofile.regionRecvKey = (string) reader["regionRecvKey"]; + regionprofile.regionSecret = (string) reader["regionSecret"]; + regionprofile.regionSendKey = (string) reader["regionSendKey"]; // Region Server - regionprofile.regionDataURI = (string)reader["regionDataURI"]; + regionprofile.regionDataURI = (string) reader["regionDataURI"]; regionprofile.regionOnline = false; // Needs to be pinged before this can be set. - regionprofile.serverIP = (string)reader["serverIP"]; + regionprofile.serverIP = (string) reader["serverIP"]; regionprofile.serverPort = Convert.ToUInt32(reader["serverPort"]); - regionprofile.serverURI = (string)reader["serverURI"]; + regionprofile.serverURI = (string) reader["serverURI"]; regionprofile.httpPort = Convert.ToUInt32(reader["serverHttpPort"]); regionprofile.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"]); @@ -307,14 +310,14 @@ namespace OpenSim.Framework.Data.MSSQL regionprofile.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"]); // Assets - regionprofile.regionAssetURI = (string)reader["regionAssetURI"]; - regionprofile.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; - regionprofile.regionAssetSendKey = (string)reader["regionAssetSendKey"]; + regionprofile.regionAssetURI = (string) reader["regionAssetURI"]; + regionprofile.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; + regionprofile.regionAssetSendKey = (string) reader["regionAssetSendKey"]; // Userserver - regionprofile.regionUserURI = (string)reader["regionUserURI"]; - regionprofile.regionUserRecvKey = (string)reader["regionUserRecvKey"]; - regionprofile.regionUserSendKey = (string)reader["regionUserSendKey"]; + regionprofile.regionUserURI = (string) reader["regionUserURI"]; + regionprofile.regionUserRecvKey = (string) reader["regionUserRecvKey"]; + regionprofile.regionUserSendKey = (string) reader["regionUserSendKey"]; // World Map Addition string tempRegionMap = reader["regionMapTexture"].ToString(); @@ -331,7 +334,6 @@ namespace OpenSim.Framework.Data.MSSQL { reader.Close(); throw new Exception("No rows to return"); - } return regionprofile; } @@ -347,12 +349,12 @@ namespace OpenSim.Framework.Data.MSSQL if (reader.Read()) { - retval.UUID = new LLUUID((string)reader["UUID"]); - retval.username = (string)reader["username"]; - retval.surname = (string)reader["lastname"]; + retval.UUID = new LLUUID((string) reader["UUID"]); + retval.username = (string) reader["username"]; + retval.surname = (string) reader["lastname"]; - retval.passwordHash = (string)reader["passwordHash"]; - retval.passwordSalt = (string)reader["passwordSalt"]; + retval.passwordHash = (string) reader["passwordHash"]; + retval.passwordSalt = (string) reader["passwordSalt"]; retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); retval.homeLocation = new LLVector3( @@ -367,18 +369,17 @@ namespace OpenSim.Framework.Data.MSSQL retval.created = Convert.ToInt32(reader["created"].ToString()); retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); - retval.userInventoryURI = (string)reader["userInventoryURI"]; - retval.userAssetURI = (string)reader["userAssetURI"]; + retval.userInventoryURI = (string) reader["userInventoryURI"]; + retval.userAssetURI = (string) reader["userAssetURI"]; retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); - retval.profileAboutText = (string)reader["profileAboutText"]; - retval.profileFirstText = (string)reader["profileFirstText"]; - - retval.profileImage = new LLUUID((string)reader["profileImage"]); - retval.profileFirstImage = new LLUUID((string)reader["profileFirstImage"]); + retval.profileAboutText = (string) reader["profileAboutText"]; + retval.profileFirstText = (string) reader["profileFirstText"]; + retval.profileImage = new LLUUID((string) reader["profileImage"]); + retval.profileFirstImage = new LLUUID((string) reader["profileFirstImage"]); } else { @@ -399,12 +400,12 @@ namespace OpenSim.Framework.Data.MSSQL if (reader.Read()) { // Agent IDs - retval.UUID = new LLUUID((string)reader["UUID"]); - retval.sessionID = new LLUUID((string)reader["sessionID"]); - retval.secureSessionID = new LLUUID((string)reader["secureSessionID"]); + retval.UUID = new LLUUID((string) reader["UUID"]); + retval.sessionID = new LLUUID((string) reader["sessionID"]); + retval.secureSessionID = new LLUUID((string) reader["secureSessionID"]); // Agent Who? - retval.agentIP = (string)reader["agentIP"]; + retval.agentIP = (string) reader["agentIP"]; retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); @@ -413,9 +414,9 @@ namespace OpenSim.Framework.Data.MSSQL retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); // Current position - retval.currentRegion = (string)reader["currentRegion"]; + retval.currentRegion = (string) reader["currentRegion"]; retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); - LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); + LLVector3.TryParse((string) reader["currentPos"], out retval.currentPos); } else { @@ -426,20 +427,19 @@ namespace OpenSim.Framework.Data.MSSQL public AssetBase getAssetRow(IDataReader reader) { - AssetBase asset = new AssetBase(); + AssetBase asset = new AssetBase(); if (reader.Read()) { // Region Main asset = new AssetBase(); - asset.Data = (byte[])reader["data"]; - asset.Description = (string)reader["description"]; - asset.FullID = new LLUUID((string)reader["id"]); + asset.Data = (byte[]) reader["data"]; + asset.Description = (string) reader["description"]; + asset.FullID = new LLUUID((string) reader["id"]); asset.InvType = Convert.ToSByte(reader["invType"]); asset.Local = Convert.ToBoolean(reader["local"]); // ((sbyte)reader["local"]) != 0 ? true : false; - asset.Name = (string)reader["name"]; + asset.Name = (string) reader["name"]; asset.Type = Convert.ToSByte(reader["assetType"]); - } else { @@ -455,15 +455,19 @@ namespace OpenSim.Framework.Data.MSSQL /// <returns>Successful?</returns> public bool insertRegionRow(RegionProfileData profile) { - //Insert new region - string sql = "INSERT INTO regions ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], "; - sql += "[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], "; - sql += "[regionAssetSendKey], [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], [serverRemotingPort]) VALUES "; + string sql = + "INSERT INTO regions ([regionHandle], [regionName], [uuid], [regionRecvKey], [regionSecret], [regionSendKey], [regionDataURI], "; + sql += + "[serverIP], [serverPort], [serverURI], [locX], [locY], [locZ], [eastOverrideHandle], [westOverrideHandle], [southOverrideHandle], [northOverrideHandle], [regionAssetURI], [regionAssetRecvKey], "; + sql += + "[regionAssetSendKey], [regionUserURI], [regionUserRecvKey], [regionUserSendKey], [regionMapTexture], [serverHttpPort], [serverRemotingPort]) VALUES "; sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; - sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; - sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort);"; + sql += + "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; + sql += + "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey, @regionMapTexture, @serverHttpPort, @serverRemotingPort);"; Dictionary<string, string> parameters = new Dictionary<string, string>(); @@ -498,9 +502,9 @@ namespace OpenSim.Framework.Data.MSSQL bool returnval = false; try - { + { IDbCommand result = Query(sql, parameters); - + if (result.ExecuteNonQuery() == 1) returnval = true; @@ -509,15 +513,12 @@ namespace OpenSim.Framework.Data.MSSQL catch (Exception e) { MainLog.Instance.Error("MSSQLManager : " + e.ToString()); - } return returnval; - } - /// <summary> /// Inserts a new row into the log database /// </summary> @@ -528,7 +529,8 @@ namespace OpenSim.Framework.Data.MSSQL /// <param name="priority">How critical is this?</param> /// <param name="logMessage">Extra message info</param> /// <returns>Saved successfully?</returns> - public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, string logMessage) + public bool insertLogRow(string serverDaemon, string target, string methodCall, string arguments, int priority, + string logMessage) { string sql = "INSERT INTO logs ([target], [server], [method], [arguments], [priority], [message]) VALUES "; sql += "(@target, @server, @method, @arguments, @priority, @message);"; @@ -588,19 +590,26 @@ namespace OpenSim.Framework.Data.MSSQL /// <param name="profileImage">UUID for profile image</param> /// <param name="firstImage">UUID for firstlife image</param> /// <returns>Success?</returns> - public bool insertUserRow(libsecondlife.LLUUID uuid, string username, string lastname, string passwordHash, string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, - float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, string aboutText, string firstText, - libsecondlife.LLUUID profileImage, libsecondlife.LLUUID firstImage) + public bool insertUserRow(LLUUID uuid, string username, string lastname, string passwordHash, + string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, + float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, + string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, + string aboutText, string firstText, + LLUUID profileImage, LLUUID firstImage) { string sql = "INSERT INTO users "; sql += "([UUID], [username], [lastname], [passwordHash], [passwordSalt], [homeRegion], "; - sql += "[homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], [homeLookAtY], [homeLookAtZ], [created], "; - sql += "[lastLogin], [userInventoryURI], [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], "; + sql += + "[homeLocationX], [homeLocationY], [homeLocationZ], [homeLookAtX], [homeLookAtY], [homeLookAtZ], [created], "; + sql += + "[lastLogin], [userInventoryURI], [userAssetURI], [profileCanDoMask], [profileWantDoMask], [profileAboutText], "; sql += "[profileFirstText], [profileImage], [profileFirstImage]) VALUES "; sql += "(@UUID, @username, @lastname, @passwordHash, @passwordSalt, @homeRegion, "; - sql += "@homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, @homeLookAtY, @homeLookAtZ, @created, "; - sql += "@lastLogin, @userInventoryURI, @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, "; + sql += + "@homeLocationX, @homeLocationY, @homeLocationZ, @homeLookAtX, @homeLookAtY, @homeLookAtZ, @created, "; + sql += + "@lastLogin, @userInventoryURI, @userAssetURI, @profileCanDoMask, @profileWantDoMask, @profileAboutText, "; sql += "@profileFirstText, @profileImage, @profileFirstImage);"; Dictionary<string, string> parameters = new Dictionary<string, string>(); @@ -624,13 +633,13 @@ namespace OpenSim.Framework.Data.MSSQL parameters["profileWantDoMask"] = "0"; parameters["profileAboutText"] = ""; parameters["profileFirstText"] = ""; - parameters["profileImage"] = libsecondlife.LLUUID.Zero.ToString(); - parameters["profileFirstImage"] = libsecondlife.LLUUID.Zero.ToString(); + parameters["profileImage"] = LLUUID.Zero.ToString(); + parameters["profileFirstImage"] = LLUUID.Zero.ToString(); bool returnval = false; try - { + { IDbCommand result = Query(sql, parameters); if (result.ExecuteNonQuery() == 1) @@ -655,8 +664,7 @@ namespace OpenSim.Framework.Data.MSSQL { try { - - SqlCommand cmd = new SqlCommand(getResourceString(name), (SqlConnection)dbcon); + SqlCommand cmd = new SqlCommand(getResourceString(name), (SqlConnection) dbcon); cmd.ExecuteNonQuery(); cmd.Dispose(); } @@ -668,7 +676,7 @@ namespace OpenSim.Framework.Data.MSSQL public SqlConnection getConnection() { - return (SqlConnection)dbcon; + return (SqlConnection) dbcon; } /// <summary> @@ -681,14 +689,15 @@ namespace OpenSim.Framework.Data.MSSQL { Dictionary<string, string> param = new Dictionary<string, string>(); param["dbname"] = dbcon.Database; - IDbCommand tablesCmd = this.Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG=@dbname", param); + IDbCommand tablesCmd = + Query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG=@dbname", param); using (IDataReader tables = tablesCmd.ExecuteReader()) { while (tables.Read()) { try { - string tableName = (string)tables["TABLE_NAME"]; + string tableName = (string) tables["TABLE_NAME"]; if (tableList.ContainsKey(tableName)) tableList[tableName] = tableName; } @@ -704,7 +713,7 @@ namespace OpenSim.Framework.Data.MSSQL private string getResourceString(string name) { - Assembly assem = this.GetType().Assembly; + Assembly assem = GetType().Assembly; string[] names = assem.GetManifestResourceNames(); foreach (string s in names) @@ -726,16 +735,14 @@ namespace OpenSim.Framework.Data.MSSQL /// <returns>A string containing the DB provider</returns> public string getVersion() { - System.Reflection.Module module = this.GetType().Module; + Module module = GetType().Module; string dllName = module.Assembly.ManifestModule.Name; Version dllVersion = module.Assembly.GetName().Version; - return string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, dllVersion.Revision); + return + string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build, + dllVersion.Revision); } - } - - - -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs index eac9826..01ef559 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs @@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.MSSQL /// <summary> /// A database interface class to a user profile storage system /// </summary> - class MSSQLUserData : IUserData + internal class MSSQLUserData : IUserData { /// <summary> /// Database manager for MySQL @@ -58,7 +58,9 @@ namespace OpenSim.Framework.Data.MSSQL string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - database = new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, settingPassword); + database = + new MSSQLManager(settingDataSource, settingInitialCatalog, settingPersistSecurityInfo, settingUserId, + settingPassword); } /// <summary> @@ -77,11 +79,12 @@ namespace OpenSim.Framework.Data.MSSQL param["first"] = user; param["second"] = last; - IDbCommand result = database.Query("SELECT * FROM users WHERE username = @first AND lastname = @second", param); + IDbCommand result = + database.Query("SELECT * FROM users WHERE username = @first AND lastname = @second", param); IDataReader reader = result.ExecuteReader(); UserProfileData row = database.readUserRow(reader); - + reader.Close(); result.Dispose(); @@ -96,9 +99,9 @@ namespace OpenSim.Framework.Data.MSSQL } } - public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) + public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { - List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); + List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); string[] querysplit; querysplit = query.Split(' '); if (querysplit.Length == 2) @@ -112,18 +115,19 @@ namespace OpenSim.Framework.Data.MSSQL param["second"] = querysplit[1]; IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username = @first AND lastname = @second", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { - OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -135,13 +139,9 @@ namespace OpenSim.Framework.Data.MSSQL MainLog.Instance.Error(e.ToString()); return returnlist; } - - - } else if (querysplit.Length == 1) { - try { lock (database) @@ -151,18 +151,19 @@ namespace OpenSim.Framework.Data.MSSQL param["second"] = querysplit[1]; IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username = @first OR lastname = @second", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { - OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -268,21 +269,25 @@ namespace OpenSim.Framework.Data.MSSQL /// <param name="user">The user profile to create</param> public void AddNewUserProfile(UserProfileData user) { - try - { - lock (database) - { - database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, - user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI, user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, - user.profileAboutText, user.profileFirstText, user.profileImage, user.profileFirstImage); - } - } - catch (Exception e) - { - database.Reconnect(); - MainLog.Instance.Error(e.ToString()); - } - + try + { + lock (database) + { + database.insertUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt, + user.homeRegion, user.homeLocation.X, user.homeLocation.Y, + user.homeLocation.Z, + user.homeLookAt.X, user.homeLookAt.Y, user.homeLookAt.Z, user.created, + user.lastLogin, user.userInventoryURI, user.userAssetURI, + user.profileCanDoMask, user.profileWantDoMask, + user.profileAboutText, user.profileFirstText, user.profileImage, + user.profileFirstImage); + } + } + catch (Exception e) + { + database.Reconnect(); + MainLog.Instance.Error(e.ToString()); + } } /// <summary> @@ -293,34 +298,33 @@ namespace OpenSim.Framework.Data.MSSQL { // Do nothing. } - - + + public bool UpdateUserProfile(UserProfileData user) { - SqlCommand command = new SqlCommand("UPDATE users set UUID = @uuid, " + - "username = @username, " + - "lastname = @lastname," + - "passwordHash = @passwordHash," + - "passwordSalt = @passwordSalt," + - "homeRegion = @homeRegion," + - "homeLocationX = @homeLocationX," + - "homeLocationY = @homeLocationY," + - "homeLocationZ = @homeLocationZ," + - "homeLookAtX = @homeLookAtX," + - "homeLookAtY = @homeLookAtY," + - "homeLookAtZ = @homeLookAtZ," + - "created = @created," + - "lastLogin = @lastLogin," + - "userInventoryURI = @userInventoryURI," + - "userAssetURI = @userAssetURI," + - "profileCanDoMask = @profileCanDoMask," + - "profileWantDoMask = @profileWantDoMask," + - "profileAboutText = @profileAboutText," + - "profileFirstText = @profileFirstText," + - "profileImage = @profileImage," + - "profileFirstImage = @profileFirstImage where " + - "UUID = @keyUUUID;", database.getConnection()); + "username = @username, " + + "lastname = @lastname," + + "passwordHash = @passwordHash," + + "passwordSalt = @passwordSalt," + + "homeRegion = @homeRegion," + + "homeLocationX = @homeLocationX," + + "homeLocationY = @homeLocationY," + + "homeLocationZ = @homeLocationZ," + + "homeLookAtX = @homeLookAtX," + + "homeLookAtY = @homeLookAtY," + + "homeLookAtZ = @homeLookAtZ," + + "created = @created," + + "lastLogin = @lastLogin," + + "userInventoryURI = @userInventoryURI," + + "userAssetURI = @userAssetURI," + + "profileCanDoMask = @profileCanDoMask," + + "profileWantDoMask = @profileWantDoMask," + + "profileAboutText = @profileAboutText," + + "profileFirstText = @profileFirstText," + + "profileImage = @profileImage," + + "profileFirstImage = @profileFirstImage where " + + "UUID = @keyUUUID;", database.getConnection()); SqlParameter param1 = new SqlParameter("@uuid", user.UUID.ToString()); SqlParameter param2 = new SqlParameter("@username", user.username); SqlParameter param3 = new SqlParameter("@lastname", user.surname); @@ -341,8 +345,8 @@ namespace OpenSim.Framework.Data.MSSQL SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.profileWantDoMask)); SqlParameter param19 = new SqlParameter("@profileAboutText", user.profileAboutText); SqlParameter param20 = new SqlParameter("@profileFirstText", user.profileFirstText); - SqlParameter param21 = new SqlParameter("@profileImage", libsecondlife.LLUUID.Zero.ToString()); - SqlParameter param22 = new SqlParameter("@profileFirstImage", libsecondlife.LLUUID.Zero.ToString()); + SqlParameter param21 = new SqlParameter("@profileImage", LLUUID.Zero.ToString()); + SqlParameter param22 = new SqlParameter("@profileFirstImage", LLUUID.Zero.ToString()); SqlParameter param23 = new SqlParameter("@keyUUUID", user.UUID.ToString()); command.Parameters.Add(param1); command.Parameters.Add(param2); @@ -370,9 +374,12 @@ namespace OpenSim.Framework.Data.MSSQL try { int affected = command.ExecuteNonQuery(); - if (affected != 0) { + if (affected != 0) + { return true; - } else { + } + else + { return false; } } @@ -433,6 +440,5 @@ namespace OpenSim.Framework.Data.MSSQL public void runQuery(string query) { } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs index 19ae115..b20c54e 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs @@ -83,13 +83,13 @@ namespace OpenSim.Framework.Data.MySQL if (dbReader.Read()) { asset = new AssetBase(); - asset.Data = (byte[])dbReader["data"]; - asset.Description = (string)dbReader["description"]; + asset.Data = (byte[]) dbReader["data"]; + asset.Description = (string) dbReader["description"]; asset.FullID = assetID; - asset.InvType = (sbyte)dbReader["invType"]; - asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false; - asset.Name = (string)dbReader["name"]; - asset.Type = (sbyte)dbReader["assetType"]; + asset.InvType = (sbyte) dbReader["invType"]; + asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false; + asset.Name = (string) dbReader["name"]; + asset.Type = (sbyte) dbReader["assetType"]; } dbReader.Close(); cmd.Dispose(); @@ -98,7 +98,7 @@ namespace OpenSim.Framework.Data.MySQL catch (Exception) { MainLog.Instance.Warn("ASSETS", "MySql failure fetching asset"); - } + } } return asset; } diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index c48c88f..fcf8c6f 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs @@ -31,15 +31,12 @@ using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.IO; -using System.Text; using libsecondlife; using MySql.Data.MySqlClient; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; -using System.Data.SqlClient; -using System.Data.Common; namespace OpenSim.Framework.Data.MySQL { @@ -130,7 +127,7 @@ namespace OpenSim.Framework.Data.MySQL { foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, obj.UUID, regionUUID); @@ -156,7 +153,7 @@ namespace OpenSim.Framework.Data.MySQL DataRow[] primRows = prims.Select(selectExp); foreach (DataRow row in primRows) { - LLUUID uuid = new LLUUID((string)row["UUID"]); + LLUUID uuid = new LLUUID((string) row["UUID"]); DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(uuid)); if (shapeRow != null) { @@ -191,8 +188,8 @@ namespace OpenSim.Framework.Data.MySQL { try { - string uuid = (string)primRow["UUID"]; - string objID = (string)primRow["SceneGroupID"]; + string uuid = (string) primRow["UUID"]; + string objID = (string) primRow["SceneGroupID"]; if (uuid == objID) //is new SceneObjectGroup ? { SceneObjectGroup group = new SceneObjectGroup(); @@ -255,10 +252,9 @@ namespace OpenSim.Framework.Data.MySQL lock (m_dataSet) { MySqlCommand cmd = new MySqlCommand("insert into terrain(RegionUUID, Revision, Heightfield)" + - " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); + " values(?RegionUUID, ?Revision, ?Heightfield)", m_connection); using (cmd) { - cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); cmd.Parameters.Add(new MySqlParameter("?Revision", revision)); cmd.Parameters.Add(new MySqlParameter("?Heightfield", serializeTerrain(ter))); @@ -269,7 +265,7 @@ namespace OpenSim.Framework.Data.MySQL public double[,] LoadTerrain(LLUUID regionID) { - double[,] terret = new double[256, 256]; + double[,] terret = new double[256,256]; terret.Initialize(); MySqlCommand cmd = new MySqlCommand( @@ -278,7 +274,7 @@ namespace OpenSim.Framework.Data.MySQL , m_connection); MySqlParameter param = new MySqlParameter(); - cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); + cmd.Parameters.Add(new MySqlParameter("?RegionUUID", Util.ToRawUuidString(regionID))); if (m_connection.State != ConnectionState.Open) { @@ -290,15 +286,15 @@ namespace OpenSim.Framework.Data.MySQL int rev = 0; if (row.Read()) { - byte[] heightmap = (byte[])row["Heightfield"]; + byte[] heightmap = (byte[]) row["Heightfield"]; for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { - terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8); + terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); } } - rev = (int)row["Revision"]; + rev = (int) row["Revision"]; } else { @@ -322,7 +318,9 @@ namespace OpenSim.Framework.Data.MySQL cmd.ExecuteNonQuery(); } - using (MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?UUID", m_connection)) + using ( + MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?UUID", m_connection) + ) { cmd.Parameters.Add(new MySqlParameter("?UUID", Util.ToRawUuidString(globalID))); cmd.ExecuteNonQuery(); @@ -336,7 +334,7 @@ namespace OpenSim.Framework.Data.MySQL { DataTable land = m_landTable; DataTable landaccesslist = m_landAccessListTable; - + DataRow landRow = land.Rows.Find(Util.ToRawUuidString(parcel.landData.globalID)); if (landRow == null) { @@ -349,7 +347,9 @@ namespace OpenSim.Framework.Data.MySQL fillLandRow(landRow, parcel.landData, regionUUID); } - using (MySqlCommand cmd = new MySqlCommand("delete from landaccesslist where LandUUID=?LandUUID", m_connection)) + using ( + MySqlCommand cmd = + new MySqlCommand("delete from landaccesslist where LandUUID=?LandUUID", m_connection)) { cmd.Parameters.Add(new MySqlParameter("?LandUUID", Util.ToRawUuidString(parcel.landData.globalID))); cmd.ExecuteNonQuery(); @@ -361,13 +361,12 @@ namespace OpenSim.Framework.Data.MySQL fillLandAccessRow(newAccessRow, entry, parcel.landData.globalID); landaccesslist.Rows.Add(newAccessRow); } - } Commit(); } - public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID) + public List<LandData> LoadLandObjects(LLUUID regionUUID) { List<LandData> landDataForRegion = new List<LandData>(); lock (m_dataSet) @@ -403,7 +402,7 @@ namespace OpenSim.Framework.Data.MySQL foreach (DataRow row in table.Rows) { //--- Display the original values, if there are any. - if (row.HasVersion(System.Data.DataRowVersion.Original)) + if (row.HasVersion(DataRowVersion.Original)) { Debug.Write("Original Row Values ===> "); foreach (DataColumn column in table.Columns) @@ -412,7 +411,7 @@ namespace OpenSim.Framework.Data.MySQL Debug.WriteLine(""); } //--- Display the current values, if there are any. - if (row.HasVersion(System.Data.DataRowVersion.Current)) + if (row.HasVersion(DataRowVersion.Current)) { Debug.Write("Current Row Values ====> "); foreach (DataColumn column in table.Columns) @@ -470,9 +469,9 @@ namespace OpenSim.Framework.Data.MySQL { DataTable terrain = new DataTable("terrain"); - createCol(terrain, "RegionUUID", typeof(String)); - createCol(terrain, "Revision", typeof(Int32)); - DataColumn heightField = createCol(terrain, "Heightfield", typeof(Byte[])); + createCol(terrain, "RegionUUID", typeof (String)); + createCol(terrain, "Revision", typeof (Int32)); + DataColumn heightField = createCol(terrain, "Heightfield", typeof (Byte[])); return terrain; } @@ -480,62 +479,62 @@ namespace OpenSim.Framework.Data.MySQL { DataTable prims = new DataTable("prims"); - createCol(prims, "UUID", typeof(String)); - createCol(prims, "RegionUUID", typeof(String)); - createCol(prims, "ParentID", typeof(Int32)); - createCol(prims, "CreationDate", typeof(Int32)); - createCol(prims, "Name", typeof(String)); - createCol(prims, "SceneGroupID", typeof(String)); + createCol(prims, "UUID", typeof (String)); + createCol(prims, "RegionUUID", typeof (String)); + createCol(prims, "ParentID", typeof (Int32)); + createCol(prims, "CreationDate", typeof (Int32)); + createCol(prims, "Name", typeof (String)); + createCol(prims, "SceneGroupID", typeof (String)); // various text fields - createCol(prims, "Text", typeof(String)); - createCol(prims, "Description", typeof(String)); - createCol(prims, "SitName", typeof(String)); - createCol(prims, "TouchName", typeof(String)); + createCol(prims, "Text", typeof (String)); + createCol(prims, "Description", typeof (String)); + createCol(prims, "SitName", typeof (String)); + createCol(prims, "TouchName", typeof (String)); // permissions - createCol(prims, "ObjectFlags", typeof(Int32)); - createCol(prims, "CreatorID", typeof(String)); - createCol(prims, "OwnerID", typeof(String)); - createCol(prims, "GroupID", typeof(String)); - createCol(prims, "LastOwnerID", typeof(String)); - createCol(prims, "OwnerMask", typeof(Int32)); - createCol(prims, "NextOwnerMask", typeof(Int32)); - createCol(prims, "GroupMask", typeof(Int32)); - createCol(prims, "EveryoneMask", typeof(Int32)); - createCol(prims, "BaseMask", typeof(Int32)); + createCol(prims, "ObjectFlags", typeof (Int32)); + createCol(prims, "CreatorID", typeof (String)); + createCol(prims, "OwnerID", typeof (String)); + createCol(prims, "GroupID", typeof (String)); + createCol(prims, "LastOwnerID", typeof (String)); + createCol(prims, "OwnerMask", typeof (Int32)); + createCol(prims, "NextOwnerMask", typeof (Int32)); + createCol(prims, "GroupMask", typeof (Int32)); + createCol(prims, "EveryoneMask", typeof (Int32)); + createCol(prims, "BaseMask", typeof (Int32)); // vectors - createCol(prims, "PositionX", typeof(Double)); - createCol(prims, "PositionY", typeof(Double)); - createCol(prims, "PositionZ", typeof(Double)); - createCol(prims, "GroupPositionX", typeof(Double)); - createCol(prims, "GroupPositionY", typeof(Double)); - createCol(prims, "GroupPositionZ", typeof(Double)); - createCol(prims, "VelocityX", typeof(Double)); - createCol(prims, "VelocityY", typeof(Double)); - createCol(prims, "VelocityZ", typeof(Double)); - createCol(prims, "AngularVelocityX", typeof(Double)); - createCol(prims, "AngularVelocityY", typeof(Double)); - createCol(prims, "AngularVelocityZ", typeof(Double)); - createCol(prims, "AccelerationX", typeof(Double)); - createCol(prims, "AccelerationY", typeof(Double)); - createCol(prims, "AccelerationZ", typeof(Double)); + createCol(prims, "PositionX", typeof (Double)); + createCol(prims, "PositionY", typeof (Double)); + createCol(prims, "PositionZ", typeof (Double)); + createCol(prims, "GroupPositionX", typeof (Double)); + createCol(prims, "GroupPositionY", typeof (Double)); + createCol(prims, "GroupPositionZ", typeof (Double)); + createCol(prims, "VelocityX", typeof (Double)); + createCol(prims, "VelocityY", typeof (Double)); + createCol(prims, "VelocityZ", typeof (Double)); + createCol(prims, "AngularVelocityX", typeof (Double)); + createCol(prims, "AngularVelocityY", typeof (Double)); + createCol(prims, "AngularVelocityZ", typeof (Double)); + createCol(prims, "AccelerationX", typeof (Double)); + createCol(prims, "AccelerationY", typeof (Double)); + createCol(prims, "AccelerationZ", typeof (Double)); // quaternions - createCol(prims, "RotationX", typeof(Double)); - createCol(prims, "RotationY", typeof(Double)); - createCol(prims, "RotationZ", typeof(Double)); - createCol(prims, "RotationW", typeof(Double)); + createCol(prims, "RotationX", typeof (Double)); + createCol(prims, "RotationY", typeof (Double)); + createCol(prims, "RotationZ", typeof (Double)); + createCol(prims, "RotationW", typeof (Double)); // sit target - createCol(prims, "SitTargetOffsetX", typeof(Double)); - createCol(prims, "SitTargetOffsetY", typeof(Double)); - createCol(prims, "SitTargetOffsetZ", typeof(Double)); + createCol(prims, "SitTargetOffsetX", typeof (Double)); + createCol(prims, "SitTargetOffsetY", typeof (Double)); + createCol(prims, "SitTargetOffsetZ", typeof (Double)); - createCol(prims, "SitTargetOrientW", typeof(Double)); - createCol(prims, "SitTargetOrientX", typeof(Double)); - createCol(prims, "SitTargetOrientY", typeof(Double)); - createCol(prims, "SitTargetOrientZ", typeof(Double)); + createCol(prims, "SitTargetOrientW", typeof (Double)); + createCol(prims, "SitTargetOrientX", typeof (Double)); + createCol(prims, "SitTargetOrientY", typeof (Double)); + createCol(prims, "SitTargetOrientZ", typeof (Double)); // Add in contraints - prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; + prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; return prims; } @@ -543,42 +542,42 @@ namespace OpenSim.Framework.Data.MySQL private DataTable createLandTable() { DataTable land = new DataTable("land"); - createCol(land, "UUID", typeof(String)); - createCol(land, "RegionUUID", typeof(String)); - createCol(land, "LocalLandID", typeof(Int32)); + createCol(land, "UUID", typeof (String)); + createCol(land, "RegionUUID", typeof (String)); + createCol(land, "LocalLandID", typeof (Int32)); // Bitmap is a byte[512] - createCol(land, "Bitmap", typeof(Byte[])); - - createCol(land, "Name", typeof(String)); - createCol(land, "Description", typeof(String)); - createCol(land, "OwnerUUID", typeof(String)); - createCol(land, "IsGroupOwned", typeof(Int32)); - createCol(land, "Area", typeof(Int32)); - createCol(land, "AuctionID", typeof(Int32)); //Unemplemented - createCol(land, "Category", typeof(Int32)); //Enum libsecondlife.Parcel.ParcelCategory - createCol(land, "ClaimDate", typeof(Int32)); - createCol(land, "ClaimPrice", typeof(Int32)); - createCol(land, "GroupUUID", typeof(String)); - createCol(land, "SalePrice", typeof(Int32)); - createCol(land, "LandStatus", typeof(Int32)); //Enum. libsecondlife.Parcel.ParcelStatus - createCol(land, "LandFlags", typeof(Int32)); - createCol(land, "LandingType", typeof(Int32)); - createCol(land, "MediaAutoScale", typeof(Int32)); - createCol(land, "MediaTextureUUID", typeof(String)); - createCol(land, "MediaURL", typeof(String)); - createCol(land, "MusicURL", typeof(String)); - createCol(land, "PassHours", typeof(Double)); - createCol(land, "PassPrice", typeof(Int32)); - createCol(land, "SnapshotUUID", typeof(String)); - createCol(land, "UserLocationX", typeof(Double)); - createCol(land, "UserLocationY", typeof(Double)); - createCol(land, "UserLocationZ", typeof(Double)); - createCol(land, "UserLookAtX", typeof(Double)); - createCol(land, "UserLookAtY", typeof(Double)); - createCol(land, "UserLookAtZ", typeof(Double)); - - land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; + createCol(land, "Bitmap", typeof (Byte[])); + + createCol(land, "Name", typeof (String)); + createCol(land, "Description", typeof (String)); + createCol(land, "OwnerUUID", typeof (String)); + createCol(land, "IsGroupOwned", typeof (Int32)); + createCol(land, "Area", typeof (Int32)); + createCol(land, "AuctionID", typeof (Int32)); //Unemplemented + createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory + createCol(land, "ClaimDate", typeof (Int32)); + createCol(land, "ClaimPrice", typeof (Int32)); + createCol(land, "GroupUUID", typeof (String)); + createCol(land, "SalePrice", typeof (Int32)); + createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus + createCol(land, "LandFlags", typeof (Int32)); + createCol(land, "LandingType", typeof (Int32)); + createCol(land, "MediaAutoScale", typeof (Int32)); + createCol(land, "MediaTextureUUID", typeof (String)); + createCol(land, "MediaURL", typeof (String)); + createCol(land, "MusicURL", typeof (String)); + createCol(land, "PassHours", typeof (Double)); + createCol(land, "PassPrice", typeof (Int32)); + createCol(land, "SnapshotUUID", typeof (String)); + createCol(land, "UserLocationX", typeof (Double)); + createCol(land, "UserLocationY", typeof (Double)); + createCol(land, "UserLocationZ", typeof (Double)); + createCol(land, "UserLookAtX", typeof (Double)); + createCol(land, "UserLookAtY", typeof (Double)); + createCol(land, "UserLookAtZ", typeof (Double)); + + land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; return land; } @@ -586,9 +585,9 @@ namespace OpenSim.Framework.Data.MySQL private DataTable createLandAccessListTable() { DataTable landaccess = new DataTable("landaccesslist"); - createCol(landaccess, "LandUUID", typeof(String)); - createCol(landaccess, "AccessUUID", typeof(String)); - createCol(landaccess, "Flags", typeof(Int32)); + createCol(landaccess, "LandUUID", typeof (String)); + createCol(landaccess, "AccessUUID", typeof (String)); + createCol(landaccess, "Flags", typeof (Int32)); return landaccess; } @@ -596,38 +595,38 @@ namespace OpenSim.Framework.Data.MySQL private DataTable createShapeTable() { DataTable shapes = new DataTable("primshapes"); - createCol(shapes, "UUID", typeof(String)); + createCol(shapes, "UUID", typeof (String)); // shape is an enum - createCol(shapes, "Shape", typeof(Int32)); + createCol(shapes, "Shape", typeof (Int32)); // vectors - createCol(shapes, "ScaleX", typeof(Double)); - createCol(shapes, "ScaleY", typeof(Double)); - createCol(shapes, "ScaleZ", typeof(Double)); + createCol(shapes, "ScaleX", typeof (Double)); + createCol(shapes, "ScaleY", typeof (Double)); + createCol(shapes, "ScaleZ", typeof (Double)); // paths - createCol(shapes, "PCode", typeof(Int32)); - createCol(shapes, "PathBegin", typeof(Int32)); - createCol(shapes, "PathEnd", typeof(Int32)); - createCol(shapes, "PathScaleX", typeof(Int32)); - createCol(shapes, "PathScaleY", typeof(Int32)); - createCol(shapes, "PathShearX", typeof(Int32)); - createCol(shapes, "PathShearY", typeof(Int32)); - createCol(shapes, "PathSkew", typeof(Int32)); - createCol(shapes, "PathCurve", typeof(Int32)); - createCol(shapes, "PathRadiusOffset", typeof(Int32)); - createCol(shapes, "PathRevolutions", typeof(Int32)); - createCol(shapes, "PathTaperX", typeof(Int32)); - createCol(shapes, "PathTaperY", typeof(Int32)); - createCol(shapes, "PathTwist", typeof(Int32)); - createCol(shapes, "PathTwistBegin", typeof(Int32)); + createCol(shapes, "PCode", typeof (Int32)); + createCol(shapes, "PathBegin", typeof (Int32)); + createCol(shapes, "PathEnd", typeof (Int32)); + createCol(shapes, "PathScaleX", typeof (Int32)); + createCol(shapes, "PathScaleY", typeof (Int32)); + createCol(shapes, "PathShearX", typeof (Int32)); + createCol(shapes, "PathShearY", typeof (Int32)); + createCol(shapes, "PathSkew", typeof (Int32)); + createCol(shapes, "PathCurve", typeof (Int32)); + createCol(shapes, "PathRadiusOffset", typeof (Int32)); + createCol(shapes, "PathRevolutions", typeof (Int32)); + createCol(shapes, "PathTaperX", typeof (Int32)); + createCol(shapes, "PathTaperY", typeof (Int32)); + createCol(shapes, "PathTwist", typeof (Int32)); + createCol(shapes, "PathTwistBegin", typeof (Int32)); // profile - createCol(shapes, "ProfileBegin", typeof(Int32)); - createCol(shapes, "ProfileEnd", typeof(Int32)); - createCol(shapes, "ProfileCurve", typeof(Int32)); - createCol(shapes, "ProfileHollow", typeof(Int32)); - createCol(shapes, "Texture", typeof(Byte[])); - createCol(shapes, "ExtraParams", typeof(Byte[])); + createCol(shapes, "ProfileBegin", typeof (Int32)); + createCol(shapes, "ProfileEnd", typeof (Int32)); + createCol(shapes, "ProfileCurve", typeof (Int32)); + createCol(shapes, "ProfileHollow", typeof (Int32)); + createCol(shapes, "Texture", typeof (Byte[])); + createCol(shapes, "ExtraParams", typeof (Byte[])); - shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; + shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; return shapes; } @@ -643,23 +642,23 @@ namespace OpenSim.Framework.Data.MySQL private SceneObjectPart buildPrim(DataRow row) { SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new LLUUID((String)row["UUID"]); + prim.UUID = new LLUUID((String) row["UUID"]); // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. prim.ParentID = Convert.ToUInt32(row["ParentID"]); prim.CreationDate = Convert.ToInt32(row["CreationDate"]); - prim.Name = (String)row["Name"]; + prim.Name = (String) row["Name"]; // various text fields - prim.Text = (String)row["Text"]; - prim.Description = (String)row["Description"]; - prim.SitName = (String)row["SitName"]; - prim.TouchName = (String)row["TouchName"]; + prim.Text = (String) row["Text"]; + prim.Description = (String) row["Description"]; + prim.SitName = (String) row["SitName"]; + prim.TouchName = (String) row["TouchName"]; // permissions prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorID = new LLUUID((String)row["CreatorID"]); - prim.OwnerID = new LLUUID((String)row["OwnerID"]); - prim.GroupID = new LLUUID((String)row["GroupID"]); - prim.LastOwnerID = new LLUUID((String)row["LastOwnerID"]); + prim.CreatorID = new LLUUID((String) row["CreatorID"]); + prim.OwnerID = new LLUUID((String) row["OwnerID"]); + prim.GroupID = new LLUUID((String) row["GroupID"]); + prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); @@ -701,19 +700,27 @@ namespace OpenSim.Framework.Data.MySQL try { prim.SetSitTargetLL(new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( - Convert.ToSingle(row["SitTargetOrientX"]), - Convert.ToSingle(row["SitTargetOrientY"]), - Convert.ToSingle(row["SitTargetOrientZ"]), - Convert.ToSingle(row["SitTargetOrientW"]))); + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"]))); } - catch (System.InvalidCastException) + catch (InvalidCastException) { // Database table was created before we got here and needs to be created! :P - using (MySqlCommand cmd = new MySqlCommand("ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", m_connection)) + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", + m_connection)) { cmd.ExecuteNonQuery(); } @@ -725,36 +732,42 @@ namespace OpenSim.Framework.Data.MySQL { LandData newData = new LandData(); - newData.globalID = new LLUUID((String)row["UUID"]); + newData.globalID = new LLUUID((String) row["UUID"]); newData.localID = Convert.ToInt32(row["LocalLandID"]); // Bitmap is a byte[512] - newData.landBitmapByteArray = (Byte[])row["Bitmap"]; + newData.landBitmapByteArray = (Byte[]) row["Bitmap"]; - newData.landName = (String)row["Name"]; - newData.landDesc = (String)row["Description"]; - newData.ownerID = (String)row["OwnerUUID"]; + newData.landName = (String) row["Name"]; + newData.landDesc = (String) row["Description"]; + newData.ownerID = (String) row["OwnerUUID"]; newData.isGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); newData.area = Convert.ToInt32(row["Area"]); newData.auctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented - newData.category = (Parcel.ParcelCategory)Convert.ToInt32(row["Category"]); //Enum libsecondlife.Parcel.ParcelCategory + newData.category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); + //Enum libsecondlife.Parcel.ParcelCategory newData.claimDate = Convert.ToInt32(row["ClaimDate"]); newData.claimPrice = Convert.ToInt32(row["ClaimPrice"]); - newData.groupID = new LLUUID((String)row["GroupUUID"]); + newData.groupID = new LLUUID((String) row["GroupUUID"]); newData.salePrice = Convert.ToInt32(row["SalePrice"]); - newData.landStatus = (Parcel.ParcelStatus)Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus + newData.landStatus = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); + //Enum. libsecondlife.Parcel.ParcelStatus newData.landFlags = Convert.ToUInt32(row["LandFlags"]); newData.landingType = Convert.ToByte(row["LandingType"]); newData.mediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); - newData.mediaID = new LLUUID((String)row["MediaTextureUUID"]); - newData.mediaURL = (String)row["MediaURL"]; - newData.musicURL = (String)row["MusicURL"]; + newData.mediaID = new LLUUID((String) row["MediaTextureUUID"]); + newData.mediaURL = (String) row["MediaURL"]; + newData.musicURL = (String) row["MusicURL"]; newData.passHours = Convert.ToSingle(row["PassHours"]); newData.passPrice = Convert.ToInt32(row["PassPrice"]); - newData.snapshotID = (String)row["SnapshotUUID"]; - - newData.userLocation = new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), Convert.ToSingle(row["UserLocationZ"])); - newData.userLookAt = new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), Convert.ToSingle(row["UserLookAtZ"])); + newData.snapshotID = (String) row["SnapshotUUID"]; + + newData.userLocation = + new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.userLookAt = + new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); newData.parcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); return newData; @@ -763,7 +776,7 @@ namespace OpenSim.Framework.Data.MySQL private ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new LLUUID((string)row["AccessUUID"]); + entry.AgentID = new LLUUID((string) row["AccessUUID"]); entry.Flags = (ParcelManager.AccessList) Convert.ToInt32(row["Flags"]); entry.Time = new DateTime(); return entry; @@ -771,7 +784,7 @@ namespace OpenSim.Framework.Data.MySQL private Array serializeTerrain(double[,] val) { - MemoryStream str = new MemoryStream(65536 * sizeof(double)); + MemoryStream str = new MemoryStream(65536*sizeof (double)); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions @@ -789,7 +802,8 @@ namespace OpenSim.Framework.Data.MySQL row["ParentID"] = prim.ParentID; row["CreationDate"] = prim.CreationDate; row["Name"] = prim.Name; - row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); // the UUID of the root part for this SceneObjectGroup + row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); + // the UUID of the root part for this SceneObjectGroup // various text fields row["Text"] = prim.Text; row["Description"] = prim.Description; @@ -841,18 +855,20 @@ namespace OpenSim.Framework.Data.MySQL row["SitTargetOrientX"] = sitTargetOrient.X; row["SitTargetOrientY"] = sitTargetOrient.Y; row["SitTargetOrientZ"] = sitTargetOrient.Z; - } - catch (MySql.Data.MySqlClient.MySqlException) + } + catch (MySqlException) { // Database table was created before we got here and needs to be created! :P - using (MySqlCommand cmd = new MySqlCommand("ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", m_connection)) + using ( + MySqlCommand cmd = + new MySqlCommand( + "ALTER TABLE `prims` ADD COLUMN `SitTargetOffsetX` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetY` float NOT NULL default 0, ADD COLUMN `SitTargetOffsetZ` float NOT NULL default 0, ADD COLUMN `SitTargetOrientW` float NOT NULL default 0, ADD COLUMN `SitTargetOrientX` float NOT NULL default 0, ADD COLUMN `SitTargetOrientY` float NOT NULL default 0, ADD COLUMN `SitTargetOrientZ` float NOT NULL default 0;", + m_connection)) { cmd.ExecuteNonQuery(); } } - - } private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) @@ -929,11 +945,11 @@ namespace OpenSim.Framework.Data.MySQL s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - - byte[] textureEntry = (byte[])row["Texture"]; + + byte[] textureEntry = (byte[]) row["Texture"]; s.TextureEntry = textureEntry; - - s.ExtraParams = (byte[])row["ExtraParams"]; + + s.ExtraParams = (byte[]) row["ExtraParams"]; return s; } @@ -1146,7 +1162,7 @@ namespace OpenSim.Framework.Data.MySQL da.UpdateCommand = updateCommand; MySqlCommand delete = new MySqlCommand("delete from prims where UUID=?UUID"); - delete.Parameters.Add(createMySqlParameter("UUID", typeof(String))); + delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -1181,7 +1197,7 @@ namespace OpenSim.Framework.Data.MySQL da.UpdateCommand.Connection = conn; MySqlCommand delete = new MySqlCommand("delete from primshapes where UUID = ?UUID"); - delete.Parameters.Add(createMySqlParameter("UUID", typeof(String))); + delete.Parameters.Add(createMySqlParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -1337,27 +1353,27 @@ namespace OpenSim.Framework.Data.MySQL private DbType dbtypeFromType(Type type) { - if (type == typeof(String)) + if (type == typeof (String)) { return DbType.String; } - else if (type == typeof(Int32)) + else if (type == typeof (Int32)) { return DbType.Int32; } - else if (type == typeof(Double)) + else if (type == typeof (Double)) { return DbType.Double; } - else if (type == typeof(Byte)) + else if (type == typeof (Byte)) { return DbType.Byte; } - else if (type == typeof(Double)) + else if (type == typeof (Double)) { return DbType.Double; } - else if (type == typeof(Byte[])) + else if (type == typeof (Byte[])) { return DbType.Binary; } @@ -1371,19 +1387,19 @@ namespace OpenSim.Framework.Data.MySQL // slightly differently. private string MySqlType(Type type) { - if (type == typeof(String)) + if (type == typeof (String)) { return "varchar(255)"; } - else if (type == typeof(Int32)) + else if (type == typeof (Int32)) { return "integer"; } - else if (type == typeof(Double)) + else if (type == typeof (Double)) { return "float"; } - else if (type == typeof(Byte[])) + else if (type == typeof (Byte[])) { return "longblob"; } @@ -1393,4 +1409,4 @@ namespace OpenSim.Framework.Data.MySQL } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index 7843562..7cfac12 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.Data; using System.Security.Cryptography; using System.Text; +using System.Text.RegularExpressions; using libsecondlife; using OpenSim.Framework.Console; @@ -62,7 +63,7 @@ namespace OpenSim.Framework.Data.MySQL database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); - + TestTables(); } @@ -80,7 +81,7 @@ namespace OpenSim.Framework.Data.MySQL UpgradeRegionsTable(tableList["regions"]); } - + /// <summary> /// Create or upgrade the table if necessary /// </summary> @@ -94,10 +95,10 @@ namespace OpenSim.Framework.Data.MySQL database.ExecuteResourceSql("CreateRegionsTable.sql"); return; } - } - + } + #endregion - + /// <summary> /// Shuts down the grid interface /// </summary> @@ -203,42 +204,41 @@ namespace OpenSim.Framework.Data.MySQL return null; } } + /// <summary> /// // Returns a list of avatar and UUIDs that match the query /// </summary> - public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); - System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]"); + Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); string[] querysplit; querysplit = query.Split(' '); if (querysplit.Length == 2) { Dictionary<string, string> param = new Dictionary<string, string>(); - param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%"; + param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], "") + "%"; try { lock (database) { - - IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -250,33 +250,30 @@ namespace OpenSim.Framework.Data.MySQL MainLog.Instance.Error(e.ToString()); return returnlist; } - - - } else if (querysplit.Length == 1) { - try { lock (database) { Dictionary<string, string> param = new Dictionary<string, string>(); - param["?first"] = objAlphaNumericPattern.Replace(querysplit[0],"") + "%"; + param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; IDbCommand result = - database.Query("SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second", param); + database.Query( + "SELECT UUID,username,surname FROM users WHERE username like ?first OR lastname like ?second", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["surname"]; + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["surname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -413,4 +410,4 @@ namespace OpenSim.Framework.Data.MySQL } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index a47a126..c317f4a 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs @@ -232,7 +232,7 @@ namespace OpenSim.Framework.Data.MySQL List<InventoryFolderBase> items = new List<InventoryFolderBase>(); while (reader.Read()) items.Add(readInventoryFolder(reader)); - + InventoryFolderBase rootFolder = null; // There should only ever be one root folder for a user. However, if there's more @@ -637,4 +637,4 @@ namespace OpenSim.Framework.Data.MySQL } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs index eda5cc5..d2605fa 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs @@ -103,4 +103,4 @@ namespace OpenSim.Framework.Data.MySQL return "0.1"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index d652db8..96f0c4d 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs @@ -666,4 +666,4 @@ namespace OpenSim.Framework.Data.MySQL return returnval; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 4b86d80..2d96f6e 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Text.RegularExpressions; using libsecondlife; using OpenSim.Framework.Console; @@ -61,7 +62,7 @@ namespace OpenSim.Framework.Data.MySQL database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); - + TestTables(); } @@ -81,7 +82,7 @@ namespace OpenSim.Framework.Data.MySQL UpgradeAgentsTable(tableList["agents"]); UpgradeUsersTable(tableList["users"]); } - + /// <summary> /// Create or upgrade the table if necessary /// </summary> @@ -95,8 +96,8 @@ namespace OpenSim.Framework.Data.MySQL database.ExecuteResourceSql("CreateAgentsTable.sql"); return; } - } - + } + /// <summary> /// Create or upgrade the table if necessary /// </summary> @@ -110,8 +111,8 @@ namespace OpenSim.Framework.Data.MySQL database.ExecuteResourceSql("CreateUsersTable.sql"); return; } - } - + } + #endregion // see IUserData @@ -144,11 +145,11 @@ namespace OpenSim.Framework.Data.MySQL } } - public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) + public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { - List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); + List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); - System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]"); + Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); string[] querysplit; querysplit = query.Split(' '); @@ -161,21 +162,20 @@ namespace OpenSim.Framework.Data.MySQL { lock (database) { - - IDbCommand result = - database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", param); + database.Query( + "SELECT UUID,username,lastname FROM users WHERE username like ?first AND lastname like ?second LIMIT 100", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { - OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -187,13 +187,9 @@ namespace OpenSim.Framework.Data.MySQL MainLog.Instance.Error(e.ToString()); return returnlist; } - - - } else if (querysplit.Length == 1) { - try { lock (database) @@ -202,18 +198,19 @@ namespace OpenSim.Framework.Data.MySQL param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], "") + "%"; IDbCommand result = - database.Query("SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100", param); + database.Query( + "SELECT UUID,username,lastname FROM users WHERE username like ?first OR lastname like ?first LIMIT 100", + param); IDataReader reader = result.ExecuteReader(); while (reader.Read()) { - OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); - user.AvatarID = new LLUUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); + user.AvatarID = new LLUUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; returnlist.Add(user); - } reader.Close(); result.Dispose(); @@ -402,4 +399,4 @@ namespace OpenSim.Framework.Data.MySQL return "0.1"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs index 3723343..462c433 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs @@ -313,4 +313,4 @@ namespace OpenSim.Framework.Data.SQLite #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs b/OpenSim/Framework/Data.SQLite/SQLiteBase.cs index d9aaa97..2e8d341 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteBase.cs @@ -263,4 +263,4 @@ namespace OpenSim.Framework.Data.SQLite } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs index dddc085..4b790c3 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs @@ -130,16 +130,17 @@ namespace OpenSim.Framework.Data.SQLite return row; } + /// <summary> /// // Returns a list of avatar and UUIDs that match the query /// </summary> - public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { //Do nothing yet List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>(); return returnlist; } + /// <summary> /// Adds a new specified region to the database /// </summary> @@ -201,4 +202,4 @@ namespace OpenSim.Framework.Data.SQLite return null; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs index c696259..64a27f0 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs @@ -159,6 +159,7 @@ namespace OpenSim.Framework.Data.SQLite invFoldersDa.Update(ds, "inventoryfolders"); } + private void addItem(InventoryItemBase item) { DataTable inventoryItemTable = ds.Tables["inventoryitems"]; @@ -248,7 +249,8 @@ namespace OpenSim.Framework.Data.SQLite { List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - string selectExp = "agentID = '" + Util.ToRawUuidString(user) + "' AND parentID = '" + Util.ToRawUuidString(LLUUID.Zero) + "'"; + string selectExp = "agentID = '" + Util.ToRawUuidString(user) + "' AND parentID = '" + + Util.ToRawUuidString(LLUUID.Zero) + "'"; DataRow[] rows = inventoryFolderTable.Select(selectExp); foreach (DataRow row in rows) { @@ -627,4 +629,4 @@ namespace OpenSim.Framework.Data.SQLite return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs index cac37d4..a97b146 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs @@ -275,4 +275,4 @@ namespace OpenSim.Framework.Data.SQLite return returnval; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index 811e0fa..a719fa2 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs @@ -30,7 +30,6 @@ using System.Collections.Generic; using System.Data; using libsecondlife; using Mono.Data.SqliteClient; -using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.SQLite @@ -38,7 +37,6 @@ namespace OpenSim.Framework.Data.SQLite /// <summary> /// A User storage interface for the SQLite database system /// </summary> - public class SQLiteUserData : SQLiteBase, IUserData { /// <summary> @@ -119,46 +117,46 @@ namespace OpenSim.Framework.Data.SQLite } } - public List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) + public List<Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query) { - List<OpenSim.Framework.AvatarPickerAvatar> returnlist = new List<OpenSim.Framework.AvatarPickerAvatar>(); + List<Framework.AvatarPickerAvatar> returnlist = new List<Framework.AvatarPickerAvatar>(); string[] querysplit; querysplit = query.Split(' '); - if (querysplit.Length == 2) + if (querysplit.Length == 2) { string select = "username like '" + querysplit[0] + "%' and surname like '" + querysplit[1] + "%'"; - lock(ds) + lock (ds) { DataRow[] rows = ds.Tables["users"].Select(select); - if (rows.Length > 0) + if (rows.Length > 0) { for (int i = 0; i < rows.Length; i++) { - OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); DataRow row = rows[i]; - user.AvatarID = new LLUUID((string)row["UUID"]); - user.firstName = (string)row["username"]; - user.lastName = (string)row["surname"]; + user.AvatarID = new LLUUID((string) row["UUID"]); + user.firstName = (string) row["username"]; + user.lastName = (string) row["surname"]; returnlist.Add(user); } } } - } - else if (querysplit.Length == 1) + } + else if (querysplit.Length == 1) { - string select = "username like '" + querysplit[0] + "%' OR surname like '" + querysplit[0] + "%'"; - lock(ds) + lock (ds) { DataRow[] rows = ds.Tables["users"].Select(select); - if (rows.Length > 0) + if (rows.Length > 0) { - for (int i = 0;i<rows.Length;i++) { - OpenSim.Framework.AvatarPickerAvatar user = new OpenSim.Framework.AvatarPickerAvatar(); + for (int i = 0; i < rows.Length; i++) + { + Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar(); DataRow row = rows[i]; - user.AvatarID = new LLUUID((string)row[0]); - user.firstName = (string)row[1]; - user.lastName = (string)row[2]; + user.AvatarID = new LLUUID((string) row[0]); + user.firstName = (string) row[1]; + user.lastName = (string) row[2]; returnlist.Add(user); } } @@ -166,6 +164,7 @@ namespace OpenSim.Framework.Data.SQLite } return returnlist; } + /// <summary> /// Returns a user by UUID direct /// </summary> @@ -263,7 +262,6 @@ namespace OpenSim.Framework.Data.SQLite } else { - row.Delete(); ua.AcceptChanges(); } @@ -595,4 +593,4 @@ namespace OpenSim.Framework.Data.SQLite return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs index 7864dda..6072600 100644 --- a/OpenSim/Framework/Data/GridData.cs +++ b/OpenSim/Framework/Data/GridData.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; using System.Collections.Generic; +using libsecondlife; namespace OpenSim.Framework.Data { @@ -35,10 +35,12 @@ namespace OpenSim.Framework.Data public LLUUID AvatarID; public string firstName; public string lastName; + public AvatarPickerAvatar() { } } + public enum DataResponse { RESPONSE_OK, @@ -78,6 +80,7 @@ namespace OpenSim.Framework.Data List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); + /// <summary> /// Authenticates a sim by use of its recv key. /// WARNING: Insecure @@ -119,4 +122,4 @@ namespace OpenSim.Framework.Data ReservationData GetReservationAtPoint(uint x, uint y); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/ILogData.cs b/OpenSim/Framework/Data/ILogData.cs index 2c05f4f..8765b5c 100644 --- a/OpenSim/Framework/Data/ILogData.cs +++ b/OpenSim/Framework/Data/ILogData.cs @@ -88,4 +88,4 @@ namespace OpenSim.Framework.Data /// <returns>A string containing the plugin version</returns> string getVersion(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/IniConfig.cs b/OpenSim/Framework/Data/IniConfig.cs index 6b02553..6af9770 100644 --- a/OpenSim/Framework/Data/IniConfig.cs +++ b/OpenSim/Framework/Data/IniConfig.cs @@ -95,4 +95,4 @@ namespace OpenSim.Framework.Data private string _iniFileName; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs index a1fe901..ec50baa 100644 --- a/OpenSim/Framework/Data/RegionProfileData.cs +++ b/OpenSim/Framework/Data/RegionProfileData.cs @@ -198,4 +198,4 @@ namespace OpenSim.Framework.Data return simData; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/ReservationData.cs b/OpenSim/Framework/Data/ReservationData.cs index acab400..285f9ca 100644 --- a/OpenSim/Framework/Data/ReservationData.cs +++ b/OpenSim/Framework/Data/ReservationData.cs @@ -44,4 +44,4 @@ namespace OpenSim.Framework.Data public string gridSendKey = ""; public string gridRecvKey = ""; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index b95ca83..8c9d7f4 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -482,7 +482,7 @@ namespace OpenSim.Framework // I don't think there is a reason that this actually // needs to be written back to the estate settings // file. - + // configMember.forceSetConfigurationOption("terrain_image_id", m_terrainImageID.ToString()); } } @@ -708,4 +708,4 @@ namespace OpenSim.Framework return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/GridConfig.cs b/OpenSim/Framework/GridConfig.cs index 799be46..8821010 100644 --- a/OpenSim/Framework/GridConfig.cs +++ b/OpenSim/Framework/GridConfig.cs @@ -93,7 +93,8 @@ namespace OpenSim.Framework configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false); - configMember.addConfigurationOption("allow_forceful_banlines", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + configMember.addConfigurationOption("allow_forceful_banlines", + ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Allow Forceful Banlines", "TRUE", true); } @@ -135,7 +136,7 @@ namespace OpenSim.Framework HttpPort = (uint) configuration_result; break; case "allow_forceful_banlines": - AllowForcefulBanlines = (string)configuration_result; + AllowForcefulBanlines = (string) configuration_result; break; } diff --git a/OpenSim/Framework/IAssetServer.cs b/OpenSim/Framework/IAssetServer.cs index 2fa77a0..afd3687 100644 --- a/OpenSim/Framework/IAssetServer.cs +++ b/OpenSim/Framework/IAssetServer.cs @@ -60,4 +60,4 @@ namespace OpenSim.Framework { IAssetServer GetAssetServer(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 18ecd92..8ef5576 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -229,7 +229,8 @@ namespace OpenSim.Framework public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos); public delegate void ModifyTerrain( - float height, float seconds, byte size, byte action, float north, float west, float south, float east, IClientAPI remoteClient); + float height, float seconds, byte size, byte action, float north, float west, float south, float east, + IClientAPI remoteClient); public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam); @@ -269,7 +270,8 @@ namespace OpenSim.Framework public delegate void ObjectSelect(uint localID, IClientAPI remoteClient); - public delegate void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, LLUUID TaskID); + public delegate void RequestObjectPropertiesFamily( + IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, LLUUID TaskID); public delegate void ObjectDeselect(uint localID, IClientAPI remoteClient); @@ -297,13 +299,17 @@ namespace OpenSim.Framework public delegate void AgentSit(IClientAPI remoteClient, LLUUID agentID); - public delegate void AvatarPickerRequest(IClientAPI remoteClient, LLUUID agentdata, LLUUID queryID, string UserQuery); + public delegate void AvatarPickerRequest(IClientAPI remoteClient, LLUUID agentdata, LLUUID queryID, string UserQuery + ); public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient); - public delegate void ParcelAccessListRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID,IClientAPI remote_client); - - public delegate void ParcelAccessListUpdateRequest(LLUUID agentID, LLUUID sessionID,uint flags, int landLocalID, List<libsecondlife.ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client); + public delegate void ParcelAccessListRequest( + LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client); + + public delegate void ParcelAccessListUpdateRequest( + LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, List<ParcelManager.ParcelAccessEntry> entries, + IClientAPI remote_client); public delegate void ParcelPropertiesRequest( int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client); @@ -330,13 +336,14 @@ namespace OpenSim.Framework public delegate void RequestGodlikePowers(LLUUID AgentID, LLUUID SessionID, LLUUID token, IClientAPI remote_client); - public delegate void GodKickUser(LLUUID GodAgentID, LLUUID GodSessionID, LLUUID AgentID, uint kickflags, byte[] reason); + public delegate void GodKickUser( + LLUUID GodAgentID, LLUUID GodSessionID, LLUUID AgentID, uint kickflags, byte[] reason); public delegate void CreateInventoryFolder( IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); public delegate void UpdateInventoryFolder( - IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID); + IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID); public delegate void MoveInventoryFolder( IClientAPI remoteClient, LLUUID folderID, LLUUID parentID); @@ -360,7 +367,8 @@ namespace OpenSim.Framework uint nextOwnerMask); public delegate void CopyInventoryItem( - IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName); + IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, + string newName); public delegate void MoveInventoryItem( IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length, string newName); @@ -372,15 +380,18 @@ namespace OpenSim.Framework public delegate void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID); public delegate void UDPAssetUploadRequest( - IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal, bool tempFile); + IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal, + bool tempFile); public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data); public delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName); public delegate void ConfirmXfer(IClientAPI remoteClient, ulong xferID, uint packetID); - - public delegate void ObjectPermissions(IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID, List<ObjectPermissionsPacket.ObjectDataBlock> permChanges); + + public delegate void ObjectPermissions( + IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID, + List<ObjectPermissionsPacket.ObjectDataBlock> permChanges); public interface IClientAPI { @@ -472,19 +483,19 @@ namespace OpenSim.Framework event EstateOwnerMessageRequest OnEstateOwnerMessage; event RegionInfoRequest OnRegionInfoRequest; event EstateCovenantRequest OnEstateCovenantRequest; - + LLVector3 StartPos { get; set; } LLUUID AgentId { get; } LLUUID SessionId { get; } - + LLUUID SecureSessionId { get; } string FirstName { get; } string LastName { get; } - + /// <summary> /// Returns the full name of the agent/avatar represented by this client /// </summary> @@ -536,26 +547,29 @@ namespace OpenSim.Framework void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint); void SetChildAgentThrottle(byte[] throttle); + void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction); void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation); + void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity); - void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items, - List<InventoryFolderBase> folders, bool fetchFolders, + void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items, + List<InventoryFolderBase> folders, bool fetchFolders, bool fetchItems); + void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item); - + /// <summary> /// Tell the client that we have created the item it requested. /// </summary> /// <param name="Item"></param> void SendInventoryItemCreateUpdate(InventoryItemBase Item); - + void SendRemoveInventoryItem(LLUUID itemID); void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName); void SendXferPacket(ulong xferID, uint packet, byte[] data); @@ -566,7 +580,7 @@ namespace OpenSim.Framework void SendNameReply(LLUUID profileId, string firstname, string lastname); void SendAlertMessage(string message); - + void SendAgentAlertMessage(string message, bool modal); void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url); bool AddMoney(int debit); @@ -587,4 +601,4 @@ namespace OpenSim.Framework event Action<IClientAPI> OnConnectionClosed; void SendLogoutPacket(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IGenericConfig.cs b/OpenSim/Framework/IGenericConfig.cs index cf742cc..0c9689c 100644 --- a/OpenSim/Framework/IGenericConfig.cs +++ b/OpenSim/Framework/IGenericConfig.cs @@ -37,4 +37,4 @@ namespace OpenSim.Framework void Commit(); void Close(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IRegionCommsListener.cs b/OpenSim/Framework/IRegionCommsListener.cs index 363ab27..19608c8 100644 --- a/OpenSim/Framework/IRegionCommsListener.cs +++ b/OpenSim/Framework/IRegionCommsListener.cs @@ -51,8 +51,6 @@ namespace OpenSim.Framework public delegate bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData); - - public interface IRegionCommsListener { event ExpectUserDelegate OnExpectUser; @@ -66,6 +64,5 @@ namespace OpenSim.Framework event CloseAgentConnection OnCloseAgentConnection; event RegionUp OnRegionUp; event ChildAgentUpdate OnChildAgentUpdate; - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IRegionLoader.cs b/OpenSim/Framework/IRegionLoader.cs index fe74737..f3e0a23 100644 --- a/OpenSim/Framework/IRegionLoader.cs +++ b/OpenSim/Framework/IRegionLoader.cs @@ -26,11 +26,8 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework; using Nini.Config; + namespace OpenSim.Framework { public interface IRegionLoader @@ -38,4 +35,4 @@ namespace OpenSim.Framework void SetIniConfigSource(IniConfigSource configSource); RegionInfo[] LoadRegions(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 4b6e9a5..7b9eced 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -29,7 +29,8 @@ using libsecondlife; namespace OpenSim.Framework { - public delegate void restart( RegionInfo thisRegion ); + public delegate void restart(RegionInfo thisRegion); + //public delegate void regionup ( RegionInfo thisRegion ); public enum RegionStatus : int @@ -38,7 +39,7 @@ namespace OpenSim.Framework Up = 1, Crashed = 2, Starting = 3 - }; + } ; public interface IScene { @@ -58,4 +59,4 @@ namespace OpenSim.Framework ClientManager ClientManager { get; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index 0679a68..d06784c 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; using System.Collections.Generic; +using libsecondlife; namespace OpenSim.Framework { @@ -50,7 +50,7 @@ namespace OpenSim.Framework /// <returns>The user data profile</returns> UserProfileData GetUserByName(string fname, string lname); - List<OpenSim.Framework.AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); + List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); /// <summary> /// Returns the current agent for a user searching by it's UUID @@ -127,13 +127,15 @@ namespace OpenSim.Framework /// </summary> void Initialise(); } + public class AvatarPickerAvatar { public LLUUID AvatarID; public string firstName; public string lastName; + public AvatarPickerAvatar() { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index 3440e30..2b08582 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; using System.Collections.Generic; +using libsecondlife; namespace OpenSim.Framework { @@ -48,4 +48,4 @@ namespace OpenSim.Framework /// <param name="user"></param> LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index 8cb3e73..c60fb01 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs @@ -291,4 +291,4 @@ namespace OpenSim.Framework [XmlElement(ElementName = "folder", IsNullable = true)] public SerializableFolder root; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs index 1a94cfd..885545d 100644 --- a/OpenSim/Framework/LandData.cs +++ b/OpenSim/Framework/LandData.cs @@ -25,8 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; using System.Collections.Generic; +using libsecondlife; + namespace OpenSim.Framework { public class LandData @@ -53,7 +54,7 @@ namespace OpenSim.Framework public int simwideArea = 0; public int salePrice = 0; //Unemeplemented. Parcels price. public Parcel.ParcelStatus landStatus = Parcel.ParcelStatus.Leased; - + public uint landFlags = (uint) Parcel.ParcelFlags.AllowFly | (uint) Parcel.ParcelFlags.AllowLandmark | (uint) Parcel.ParcelFlags.AllowAllObjectEntry | (uint) Parcel.ParcelFlags.AllowDeedToGroup | (uint) Parcel.ParcelFlags.AllowTerraform | @@ -133,4 +134,4 @@ namespace OpenSim.Framework return landData; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Login.cs b/OpenSim/Framework/Login.cs index 1da0a2b..5228fe9 100644 --- a/OpenSim/Framework/Login.cs +++ b/OpenSim/Framework/Login.cs @@ -47,4 +47,4 @@ namespace OpenSim.Framework StartPos = new LLVector3(128, 128, 70); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/NeighbourInfo.cs b/OpenSim/Framework/NeighbourInfo.cs index ca98cd1..ddf9df6 100644 --- a/OpenSim/Framework/NeighbourInfo.cs +++ b/OpenSim/Framework/NeighbourInfo.cs @@ -39,4 +39,4 @@ namespace OpenSim.Framework public string sim_ip; public uint sim_port; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index 6f8ff7d..cf1457d 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs @@ -80,8 +80,10 @@ namespace OpenSim.Framework m_defaultHomeLocX = (uint) config.Configs["StandAlone"].GetInt("default_location_x", 1000); m_defaultHomeLocY = (uint) config.Configs["StandAlone"].GetInt("default_location_y", 1000); - HttpListenerPort = (uint) config.Configs["Network"].GetInt("http_listener_port", (int) DefaultHttpListenerPort); - RemotingListenerPort = (uint) config.Configs["Network"].GetInt("remoting_listener_port", (int) RemotingListenerPort); + HttpListenerPort = + (uint) config.Configs["Network"].GetInt("http_listener_port", (int) DefaultHttpListenerPort); + RemotingListenerPort = + (uint) config.Configs["Network"].GetInt("remoting_listener_port", (int) RemotingListenerPort); GridURL = config.Configs["Network"].GetString("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString()); @@ -98,4 +100,4 @@ namespace OpenSim.Framework InventoryConfig.DefaultHttpPort.ToString()); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 98e583e..c29b973 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -26,9 +26,9 @@ * */ +using System; using System.Xml.Serialization; using libsecondlife; -using System; namespace OpenSim.Framework { @@ -91,32 +91,21 @@ namespace OpenSim.Framework public sbyte PathTwist; public sbyte PathTwistBegin; - [XmlIgnore] + [XmlIgnore] public LLObject.TextureEntry Textures { - get - { - return new LLObject.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); - } + get { return new LLObject.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); } - set - { - m_textureEntry = value.ToBytes(); - } + set { m_textureEntry = value.ToBytes(); } } private byte[] m_textureEntry; + public byte[] TextureEntry { - get - { - return m_textureEntry; - } + get { return m_textureEntry; } - set - { - m_textureEntry = value; - } + set { m_textureEntry = value; } } public byte[] ExtraParams; @@ -134,11 +123,11 @@ namespace OpenSim.Framework [XmlIgnore] public HollowShape HollowShape { - get { return (HollowShape)(ProfileCurve & 0xf0); } + get { return (HollowShape) (ProfileCurve & 0xf0); } set { - byte oldValueMasked = (byte)(ProfileCurve & 0x0f); - ProfileCurve = (byte)(oldValueMasked | (byte)value); + byte oldValueMasked = (byte) (ProfileCurve & 0x0f); + ProfileCurve = (byte) (oldValueMasked | (byte) value); } } @@ -147,7 +136,6 @@ namespace OpenSim.Framework get { return Scale; } } - static PrimitiveBaseShape() { diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs index a146778..9472a9e 100644 --- a/OpenSim/Framework/RegionCommsListener.cs +++ b/OpenSim/Framework/RegionCommsListener.cs @@ -44,10 +44,10 @@ namespace OpenSim.Framework public event CloseAgentConnection OnCloseAgentConnection; public event RegionUp OnRegionUp; public event ChildAgentUpdate OnChildAgentUpdate; - - public string debugRegionName=""; - + + public string debugRegionName = ""; + /// <summary> /// @@ -66,7 +66,6 @@ namespace OpenSim.Framework } - public virtual bool TriggerExpectPrim(ulong regionHandle, LLUUID primID, string objData) { if (OnExpectUser != null) @@ -107,7 +106,9 @@ namespace OpenSim.Framework } return false; } - public virtual bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) + + public virtual bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, + bool isPhysical) { if (OnPrimCrossingIntoRegion != null) { @@ -178,4 +179,4 @@ namespace OpenSim.Framework return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index c4557f8..8c25603 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -26,16 +26,11 @@ * */ using System; -using System.Globalization; using System.Net; -using System.Xml; using System.Net.Sockets; -using Nini.Config; +using System.Xml; using libsecondlife; -using OpenSim.Framework.Console; -using OpenSim.Framework; - - +using Nini.Config; namespace OpenSim.Framework { @@ -64,6 +59,7 @@ namespace OpenSim.Framework m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int) port); } + public SimpleRegionInfo(RegionInfo ConvertFrom) { m_regionLocX = ConvertFrom.RegionLocX; @@ -78,16 +74,11 @@ namespace OpenSim.Framework public LLUUID RegionID = LLUUID.Zero; public uint m_remotingPort; + public uint RemotingPort { - get - { - return m_remotingPort; - } - set - { - m_remotingPort = value; - } + get { return m_remotingPort; } + set { m_remotingPort = value; } } public string RemotingAddress; @@ -123,73 +114,47 @@ namespace OpenSim.Framework return new IPEndPoint(ia, m_internalEndPoint.Port); } - set - { - m_externalHostName = value.ToString(); - } + set { m_externalHostName = value.ToString(); } } protected string m_externalHostName; + public string ExternalHostName { - get - { - return m_externalHostName; - } - set - { - m_externalHostName = value; - } + get { return m_externalHostName; } + set { m_externalHostName = value; } } protected IPEndPoint m_internalEndPoint; + public IPEndPoint InternalEndPoint { - get - { - return m_internalEndPoint; - } - set - { - m_internalEndPoint = value; - } + get { return m_internalEndPoint; } + set { m_internalEndPoint = value; } } protected uint? m_regionLocX; + public uint RegionLocX { - get - { - return m_regionLocX.Value; - } - set - { - m_regionLocX = value; - } + get { return m_regionLocX.Value; } + set { m_regionLocX = value; } } protected uint? m_regionLocY; + public uint RegionLocY { - get - { - return m_regionLocY.Value; - } - set - { - m_regionLocY = value; - } + get { return m_regionLocY.Value; } + set { m_regionLocY = value; } } public ulong RegionHandle { - get - { - return Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); - } + get { return Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); } } } - + public class RegionInfo : SimpleRegionInfo { public string RegionName = ""; @@ -206,15 +171,16 @@ namespace OpenSim.Framework // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. private static EstateSettings m_estateSettings; + public EstateSettings EstateSettings { get { - if( m_estateSettings == null ) + if (m_estateSettings == null) { m_estateSettings = new EstateSettings(); } - + return m_estateSettings; } } @@ -223,14 +189,18 @@ namespace OpenSim.Framework public RegionInfo(string description, string filename) { - configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); + configMember = + new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } + public RegionInfo(string description, XmlNode xmlNode) { - configMember = new ConfigurationMember(xmlNode, description, loadConfigurationOptions, handleIncomingConfiguration); + configMember = + new ConfigurationMember(xmlNode, description, loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } + public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) : base(regionLocX, regionLocY, internalEndPoint, externalUri) { @@ -239,6 +209,7 @@ namespace OpenSim.Framework public RegionInfo() { } + public RegionInfo(SearializableRegionInfo ConvertFrom) { m_regionLocX = ConvertFrom.RegionLocX; @@ -249,6 +220,7 @@ namespace OpenSim.Framework RemotingAddress = ConvertFrom.RemotingAddress; RegionID = LLUUID.Zero; } + public RegionInfo(SimpleRegionInfo ConvertFrom) { m_regionLocX = ConvertFrom.RegionLocX; @@ -259,47 +231,49 @@ namespace OpenSim.Framework RemotingAddress = ConvertFrom.RemotingAddress; RegionID = LLUUID.Zero; } + //not in use, should swap to nini though. public void LoadFromNiniSource(IConfigSource source) { - this.LoadFromNiniSource(source, "RegionInfo"); + LoadFromNiniSource(source, "RegionInfo"); } //not in use, should swap to nini though. public void LoadFromNiniSource(IConfigSource source, string sectionName) { string errorMessage = ""; - this.RegionID = new LLUUID(source.Configs[sectionName].GetString("Region_ID", LLUUID.Random().ToString())); - this.RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test"); - this.m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000")); - this.m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000")); + RegionID = new LLUUID(source.Configs[sectionName].GetString("Region_ID", LLUUID.Random().ToString())); + RegionName = source.Configs[sectionName].GetString("sim_name", "OpenSim Test"); + m_regionLocX = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_x", "1000")); + m_regionLocY = Convert.ToUInt32(source.Configs[sectionName].GetString("sim_location_y", "1000")); // this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db"); string ipAddress = source.Configs[sectionName].GetString("internal_ip_address", "0.0.0.0"); IPAddress ipAddressResult; if (IPAddress.TryParse(ipAddress, out ipAddressResult)) { - this.m_internalEndPoint = new IPEndPoint(ipAddressResult, 0); + m_internalEndPoint = new IPEndPoint(ipAddressResult, 0); } else { errorMessage = "needs an IP Address (IPAddress)"; } - this.m_internalEndPoint.Port = source.Configs[sectionName].GetInt("internal_ip_port", (int) NetworkServersInfo.DefaultHttpListenerPort); + m_internalEndPoint.Port = + source.Configs[sectionName].GetInt("internal_ip_port", (int) NetworkServersInfo.DefaultHttpListenerPort); string externalHost = source.Configs[sectionName].GetString("external_host_name", "127.0.0.1"); if (externalHost != "SYSTEMIP") { - this.m_externalHostName = externalHost; + m_externalHostName = externalHost; } else { - this.m_externalHostName = Util.GetLocalHost().ToString(); + m_externalHostName = Util.GetLocalHost().ToString(); } - this.MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test"); - this.MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User"); - this.MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test"); + MasterAvatarFirstName = source.Configs[sectionName].GetString("master_avatar_first", "Test"); + MasterAvatarLastName = source.Configs[sectionName].GetString("master_avatar_last", "User"); + MasterAvatarSandboxPassword = source.Configs[sectionName].GetString("master_avatar_pass", "test"); if (errorMessage != "") { @@ -309,19 +283,45 @@ namespace OpenSim.Framework public void loadConfigurationOptions() { - configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "UUID of Region (Default is recommended, random UUID)", LLUUID.Random().ToString(), true); - configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Region Name", "OpenSim Test", false); - configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (X Axis)", "1000", false); - configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Grid Location (Y Axis)", "1000", false); + configMember.addConfigurationOption("sim_UUID", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "UUID of Region (Default is recommended, random UUID)", + LLUUID.Random().ToString(), true); + configMember.addConfigurationOption("sim_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Region Name", "OpenSim Test", false); + configMember.addConfigurationOption("sim_location_x", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Grid Location (X Axis)", "1000", false); + configMember.addConfigurationOption("sim_location_y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Grid Location (Y Axis)", "1000", false); //configMember.addConfigurationOption("datastore", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Filename for local storage", "OpenSim.db", false); - configMember.addConfigurationOption("internal_ip_address", ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, "Internal IP Address for incoming UDP client connections", "0.0.0.0", false); - configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Internal IP Port for incoming UDP client connections", NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); - configMember.addConfigurationOption("external_host_name", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "External Host Name", "127.0.0.1", false); - configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "Master Avatar UUID", LLUUID.Zero.ToString(), true); - configMember.addConfigurationOption("estate_covanant_uuid", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "Estate Covenant", LLUUID.Zero.ToString(), true); - configMember.addConfigurationOption("master_avatar_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", "Test", false,(ConfigurationOption.ConfigurationOptionShouldBeAsked)shouldMasterAvatarDetailsBeAsked); - configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Name of Master Avatar", "User", false, (ConfigurationOption.ConfigurationOptionShouldBeAsked)shouldMasterAvatarDetailsBeAsked); - configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test", false, (ConfigurationOption.ConfigurationOptionShouldBeAsked)shouldMasterAvatarDetailsBeAsked); + configMember.addConfigurationOption("internal_ip_address", + ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS, + "Internal IP Address for incoming UDP client connections", "0.0.0.0", + false); + configMember.addConfigurationOption("internal_ip_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, + "Internal IP Port for incoming UDP client connections", + NetworkServersInfo.DefaultHttpListenerPort.ToString(), false); + configMember.addConfigurationOption("external_host_name", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "External Host Name", "127.0.0.1", false); + configMember.addConfigurationOption("master_avatar_uuid", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "Master Avatar UUID", LLUUID.Zero.ToString(), true); + configMember.addConfigurationOption("estate_covanant_uuid", + ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "Estate Covenant", + LLUUID.Zero.ToString(), true); + configMember.addConfigurationOption("master_avatar_first", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "First Name of Master Avatar", "Test", false, + (ConfigurationOption.ConfigurationOptionShouldBeAsked) + shouldMasterAvatarDetailsBeAsked); + configMember.addConfigurationOption("master_avatar_last", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Last Name of Master Avatar", "User", false, + (ConfigurationOption.ConfigurationOptionShouldBeAsked) + shouldMasterAvatarDetailsBeAsked); + configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "(Sandbox Mode Only)Password for Master Avatar account", "test", false, + (ConfigurationOption.ConfigurationOptionShouldBeAsked) + shouldMasterAvatarDetailsBeAsked); } public bool shouldMasterAvatarDetailsBeAsked(string configuration_key) @@ -338,58 +338,57 @@ namespace OpenSim.Framework switch (configuration_key) { case "sim_UUID": - this.RegionID = (LLUUID)configuration_result; + RegionID = (LLUUID) configuration_result; break; case "sim_name": - this.RegionName = (string)configuration_result; + RegionName = (string) configuration_result; break; case "sim_location_x": - this.m_regionLocX = (uint)configuration_result; + m_regionLocX = (uint) configuration_result; break; case "sim_location_y": - this.m_regionLocY = (uint)configuration_result; + m_regionLocY = (uint) configuration_result; break; case "datastore": - this.DataStore = (string)configuration_result; + DataStore = (string) configuration_result; break; case "internal_ip_address": - IPAddress address = (IPAddress)configuration_result; - this.m_internalEndPoint = new IPEndPoint(address, 0); + IPAddress address = (IPAddress) configuration_result; + m_internalEndPoint = new IPEndPoint(address, 0); break; case "internal_ip_port": - this.m_internalEndPoint.Port = (int)configuration_result; + m_internalEndPoint.Port = (int) configuration_result; break; case "external_host_name": - if ((string)configuration_result != "SYSTEMIP") + if ((string) configuration_result != "SYSTEMIP") { - this.m_externalHostName = (string)configuration_result; + m_externalHostName = (string) configuration_result; } else { - this.m_externalHostName = Util.GetLocalHost().ToString(); + m_externalHostName = Util.GetLocalHost().ToString(); } break; case "master_avatar_uuid": - this.MasterAvatarAssignedUUID = (LLUUID)configuration_result; + MasterAvatarAssignedUUID = (LLUUID) configuration_result; break; case "estate_covanant_uuid": - this.CovenantID = (LLUUID)configuration_result; + CovenantID = (LLUUID) configuration_result; break; case "master_avatar_first": - this.MasterAvatarFirstName = (string)configuration_result; + MasterAvatarFirstName = (string) configuration_result; break; case "master_avatar_last": - this.MasterAvatarLastName = (string)configuration_result; + MasterAvatarLastName = (string) configuration_result; break; case "master_avatar_pass": - string tempMD5Passwd = (string)configuration_result; - this.MasterAvatarSandboxPassword = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); + string tempMD5Passwd = (string) configuration_result; + MasterAvatarSandboxPassword = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); break; } return true; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs index fb50171..a710f50 100644 --- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs +++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs @@ -25,12 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; -using Nini.Config; -using OpenSim.Framework; using System.IO; +using Nini.Config; namespace OpenSim.Framework.RegionLoader.Filesystem { @@ -67,4 +63,4 @@ namespace OpenSim.Framework.RegionLoader.Filesystem return regionInfos; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs index ec7059a..1625fa6 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs @@ -25,48 +25,46 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Net; using System.IO; +using System.Net; using System.Xml; -using System.Collections.Generic; -using System.Text; using Nini.Config; -using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Framework.RegionLoader.Web { public class RegionLoaderWebServer : IRegionLoader { private IniConfigSource m_configSouce; + public void SetIniConfigSource(IniConfigSource configSource) { m_configSouce = configSource; } + public RegionInfo[] LoadRegions() { if (m_configSouce == null) { - Console.MainLog.Instance.Error("WEBLOADER", "Unable to load configuration source!"); + MainLog.Instance.Error("WEBLOADER", "Unable to load configuration source!"); return null; } else { - IniConfig startupConfig = (IniConfig)m_configSouce.Configs["Startup"]; - string url = startupConfig.GetString("regionload_webserver_url","").Trim(); + IniConfig startupConfig = (IniConfig) m_configSouce.Configs["Startup"]; + string url = startupConfig.GetString("regionload_webserver_url", "").Trim(); if (url == "") { - Console.MainLog.Instance.Error("WEBLOADER", "Unable to load webserver URL - URL was empty."); + MainLog.Instance.Error("WEBLOADER", "Unable to load webserver URL - URL was empty."); return null; } else { - - HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); + HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); webRequest.Timeout = 30000; //30 Second Timeout - Console.MainLog.Instance.Debug("WEBLOADER", "Sending Download Request..."); - HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); - Console.MainLog.Instance.Debug("WEBLOADER", "Downloading Region Information From Remote Server..."); + MainLog.Instance.Debug("WEBLOADER", "Sending Download Request..."); + HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); + MainLog.Instance.Debug("WEBLOADER", "Downloading Region Information From Remote Server..."); StreamReader reader = new StreamReader(webResponse.GetResponseStream()); string xmlSource = ""; string tempStr = reader.ReadLine(); @@ -75,7 +73,9 @@ namespace OpenSim.Framework.RegionLoader.Web xmlSource = xmlSource + tempStr; tempStr = reader.ReadLine(); } - Console.MainLog.Instance.Debug("WEBLOADER", "Done downloading region information from server. Total Bytes: " + xmlSource.Length); + MainLog.Instance.Debug("WEBLOADER", + "Done downloading region information from server. Total Bytes: " + + xmlSource.Length); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlSource); if (xmlDoc.FirstChild.Name == "Regions") @@ -84,8 +84,9 @@ namespace OpenSim.Framework.RegionLoader.Web int i; for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) { - Console.MainLog.Instance.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); - regionInfos[i] = new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i]); + MainLog.Instance.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); + regionInfos[i] = + new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i]); } return regionInfos; @@ -95,4 +96,4 @@ namespace OpenSim.Framework.RegionLoader.Web } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Remoting.cs b/OpenSim/Framework/Remoting.cs index 9cf0d11..ddc1cfb 100644 --- a/OpenSim/Framework/Remoting.cs +++ b/OpenSim/Framework/Remoting.cs @@ -131,4 +131,4 @@ namespace OpenSim.Framework return c; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/SerializableRegionInfo.cs b/OpenSim/Framework/SerializableRegionInfo.cs index 5df22cd..18a3829 100644 --- a/OpenSim/Framework/SerializableRegionInfo.cs +++ b/OpenSim/Framework/SerializableRegionInfo.cs @@ -26,15 +26,10 @@ * */ using System; -using System.Globalization; using System.Net; -using System.Xml; using System.Net.Sockets; using libsecondlife; - - - namespace OpenSim.Framework { [Serializable] @@ -46,7 +41,8 @@ namespace OpenSim.Framework public SearializableRegionInfo() { } - public SearializableRegionInfo(RegionInfo ConvertFrom) + + public SearializableRegionInfo(RegionInfo ConvertFrom) { m_regionLocX = ConvertFrom.RegionLocX; m_regionLocY = ConvertFrom.RegionLocY; @@ -55,9 +51,9 @@ namespace OpenSim.Framework m_remotingPort = ConvertFrom.RemotingPort; RemotingAddress = ConvertFrom.RemotingAddress; } + public SearializableRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) { - m_regionLocX = regionLocX; m_regionLocY = regionLocY; @@ -78,16 +74,11 @@ namespace OpenSim.Framework public Guid RegionID = LLUUID.Zero.UUID; public uint m_remotingPort; + public uint RemotingPort { - get - { - return m_remotingPort; - } - set - { - m_remotingPort = value; - } + get { return m_remotingPort; } + set { m_remotingPort = value; } } public string RemotingAddress; @@ -120,77 +111,49 @@ namespace OpenSim.Framework ia = Adr; break; } - } return new IPEndPoint(ia, m_internalEndPoint.Port); } - set - { - m_externalHostName = value.ToString(); - } + set { m_externalHostName = value.ToString(); } } protected string m_externalHostName; + public string ExternalHostName { - get - { - return m_externalHostName; - } - set - { - m_externalHostName = value; - } + get { return m_externalHostName; } + set { m_externalHostName = value; } } protected IPEndPoint m_internalEndPoint; + public IPEndPoint InternalEndPoint { - get - { - return m_internalEndPoint; - } - set - { - m_internalEndPoint = value; - } + get { return m_internalEndPoint; } + set { m_internalEndPoint = value; } } protected uint? m_regionLocX; + public uint RegionLocX { - get - { - return m_regionLocX.Value; - } - set - { - m_regionLocX = value; - } + get { return m_regionLocX.Value; } + set { m_regionLocX = value; } } protected uint? m_regionLocY; + public uint RegionLocY { - get - { - return m_regionLocY.Value; - } - set - { - m_regionLocY = value; - } + get { return m_regionLocY.Value; } + set { m_regionLocY = value; } } public ulong RegionHandle { - get - { - return Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); - } + get { return Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); } } } - -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index d865ae8..7af1716 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Servers HttpListenerRequest request = context.Request; HttpListenerResponse response = context.Response; - + response.KeepAlive = false; response.SendChunked = false; @@ -192,15 +192,12 @@ namespace OpenSim.Framework.Servers MainLog.Instance.Error("XML", responseString); string[] querystringkeys = request.QueryString.AllKeys; string[] rHeaders = request.Headers.AllKeys; - - - + foreach (string queryname in querystringkeys) { keysvals.Add(queryname, request.QueryString[queryname]); MainLog.Instance.Warn("HTTP", queryname + "=" + request.QueryString[queryname]); - } foreach (string headername in rHeaders) { @@ -218,7 +215,6 @@ namespace OpenSim.Framework.Servers string methodName = xmlRprcRequest.MethodName; if (methodName != null) { - XmlRpcResponse xmlRpcResponse; XmlRpcMethod method; @@ -241,8 +237,8 @@ namespace OpenSim.Framework.Servers } else { - System.Console.WriteLine("Handler not found for http request " +request.RawUrl); - responseString = "Error"; + System.Console.WriteLine("Handler not found for http request " + request.RawUrl); + responseString = "Error"; } } @@ -266,7 +262,8 @@ namespace OpenSim.Framework.Servers response.OutputStream.Close(); } } - public void HandleHTTPRequest(Hashtable keysvals, HttpListenerRequest request, HttpListenerResponse response) + + public void HandleHTTPRequest(Hashtable keysvals, HttpListenerRequest request, HttpListenerResponse response) { // This is a test. There's a workable alternative.. as this way sucks. // We'd like to put this into a text file parhaps that's easily editable. @@ -280,12 +277,14 @@ namespace OpenSim.Framework.Servers // to display the form, or process it. // a better way would be nifty. - if ((string)keysvals["show_login_form"] == "TRUE") + if ((string) keysvals["show_login_form"] == "TRUE") { - string responseString = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; + string responseString = + "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; responseString = responseString + "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; responseString = responseString + "<head>"; - responseString = responseString + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; + responseString = responseString + + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; responseString = responseString + "<meta http-equiv=\"cache-control\" content=\"no-cache\">"; responseString = responseString + "<meta http-equiv=\"Pragma\" content=\"no-cache\">"; responseString = responseString + "<title>Second Life Login</title>"; @@ -299,37 +298,50 @@ namespace OpenSim.Framework.Servers responseString = responseString + "</div>"; responseString = responseString + "<fieldset id=\"firstname\">"; responseString = responseString + "<legend>First Name:</legend>"; - responseString = responseString + "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"" + keysvals["username"] + "\" />"; + responseString = responseString + + "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"" + + keysvals["username"] + "\" />"; responseString = responseString + "</fieldset>"; responseString = responseString + "<fieldset id=\"lastname\">"; responseString = responseString + "<legend>Last Name:</legend>"; - responseString = responseString + "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"" + keysvals["lastname"] + "\" />"; + responseString = responseString + + "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"" + + keysvals["lastname"] + "\" />"; responseString = responseString + "</fieldset>"; responseString = responseString + "<fieldset id=\"password\">"; responseString = responseString + "<legend>Password:</legend>"; responseString = responseString + "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"; responseString = responseString + "<tr>"; - responseString = responseString + "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"" + keysvals["password"] + "\" /></td>"; + responseString = responseString + + "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"" + + keysvals["password"] + "\" /></td>"; responseString = responseString + "</tr>"; responseString = responseString + "<tr>"; - responseString = responseString + "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" value=\"" + keysvals["remember_password"] + "\" checked style=\"margin-left:0px;\"/></td>"; + responseString = responseString + + "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" value=\"" + + keysvals["remember_password"] + "\" checked style=\"margin-left:0px;\"/></td>"; responseString = responseString + "<td><label for=\"remember_password\">Remember password</label></td>"; responseString = responseString + "</tr>"; responseString = responseString + "</table>"; responseString = responseString + "</fieldset>"; responseString = responseString + "<input type=\"hidden\" name=\"show_login_form\" value=\"FALSE\" />"; - responseString = responseString + "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"" + keysvals["grid"] + "\" />"; + responseString = responseString + "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"" + + keysvals["grid"] + "\" />"; responseString = responseString + "<div id=\"submitbtn\">"; responseString = responseString + "<input class=\"input_over\" type=\"submit\" value=\"Connect\" />"; responseString = responseString + "</div>"; - responseString = responseString + "<div id=\"connecting\" style=\"visibility:hidden\"><img src=\"/_img/sl_logo_rotate_black.gif\" align=\"absmiddle\"> Connecting...</div>"; + responseString = responseString + + "<div id=\"connecting\" style=\"visibility:hidden\"><img src=\"/_img/sl_logo_rotate_black.gif\" align=\"absmiddle\"> Connecting...</div>"; responseString = responseString + "<div id=\"helplinks\">"; - responseString = responseString + "<a href=\"http://www.secondlife.com/join/index.php\" target=\"_blank\">Create new account</a> | "; - responseString = responseString + "<a href=\"http://www.secondlife.com/account/request.php\" target=\"_blank\">Forgot password?</a>"; + responseString = responseString + + "<a href=\"http://www.secondlife.com/join/index.php\" target=\"_blank\">Create new account</a> | "; + responseString = responseString + + "<a href=\"http://www.secondlife.com/account/request.php\" target=\"_blank\">Forgot password?</a>"; responseString = responseString + "</div>"; - responseString = responseString + "<div id=\"channelinfo\"> " + keysvals["channel"] + " | " + keysvals["version"] + "=" + keysvals["lang"] + "</div>"; + responseString = responseString + "<div id=\"channelinfo\"> " + keysvals["channel"] + " | " + + keysvals["version"] + "=" + keysvals["lang"] + "</div>"; responseString = responseString + "</form>"; responseString = responseString + "<script language=\"JavaScript\">"; responseString = responseString + "document.getElementById('firstname_input').focus();"; @@ -359,7 +371,7 @@ namespace OpenSim.Framework.Servers } } // show_login_form == "TRUE" else - { + { // show_login_form is present but FALSE // // The idea here is that we're telling the client to log in immediately here using the following information @@ -371,12 +383,14 @@ namespace OpenSim.Framework.Servers // response.StatusCode = 301; - response.RedirectLocation = "secondlife:///app/login?first_name=" + keysvals["username"] + "&last_name=" + keysvals["lastname"] + "&location=home&grid=Other&web_login_key=796f2b2a-0131-41e4-af12-00f60c24c458"; - + response.RedirectLocation = "secondlife:///app/login?first_name=" + keysvals["username"] + "&last_name=" + + keysvals["lastname"] + + "&location=home&grid=Other&web_login_key=796f2b2a-0131-41e4-af12-00f60c24c458"; + response.OutputStream.Close(); } // show_login_form == "FALSE" - } + public void Start() { MainLog.Instance.Verbose("HTTPD", "Starting up HTTP Server"); @@ -422,4 +436,4 @@ namespace OpenSim.Framework.Servers m_streamHandlers.Remove(GetHandlerKey(httpMethod, path)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs index e3a5df3..47b3f24 100644 --- a/OpenSim/Framework/Servers/CheckSumServer.cs +++ b/OpenSim/Framework/Servers/CheckSumServer.cs @@ -124,4 +124,4 @@ namespace OpenSim.Framework.Servers } * } */ -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/RestMethod.cs b/OpenSim/Framework/Servers/RestMethod.cs index 34e2669..ce2239b 100644 --- a/OpenSim/Framework/Servers/RestMethod.cs +++ b/OpenSim/Framework/Servers/RestMethod.cs @@ -28,4 +28,4 @@ namespace OpenSim.Framework.Servers { public delegate string RestMethod(string request, string path, string param); -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs index b1565f1..212361c 100644 --- a/OpenSim/Framework/Servers/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/RestObjectPoster.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Servers public static void BeginPostObject<TRequest>(string verb, string requestUrl, TRequest obj) { - Type type = typeof(TRequest); + Type type = typeof (TRequest); WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; @@ -62,7 +62,7 @@ namespace OpenSim.Framework.Servers writer.Flush(); } - int length = (int)buffer.Length; + int length = (int) buffer.Length; request.ContentLength = length; Stream requestStream = request.GetRequestStream(); @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Servers private static void AsyncCallback(IAsyncResult result) { - WebRequest request = (WebRequest)result.AsyncState; + WebRequest request = (WebRequest) result.AsyncState; using (WebResponse resp = request.EndGetResponse(result)) { } diff --git a/OpenSim/Framework/Servers/RestObjectPosterResponse.cs b/OpenSim/Framework/Servers/RestObjectPosterResponse.cs index 9d1f819..2961e04 100644 --- a/OpenSim/Framework/Servers/RestObjectPosterResponse.cs +++ b/OpenSim/Framework/Servers/RestObjectPosterResponse.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers public void BeginPostObject<TRequest>(string verb, string requestUrl, TRequest obj) { - Type type = typeof(TRequest); + Type type = typeof (TRequest); WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; @@ -66,7 +66,7 @@ namespace OpenSim.Framework.Servers writer.Flush(); } - int length = (int)buffer.Length; + int length = (int) buffer.Length; request.ContentLength = length; Stream requestStream = request.GetRequestStream(); @@ -76,12 +76,12 @@ namespace OpenSim.Framework.Servers private void AsyncCallback(IAsyncResult result) { - WebRequest request = (WebRequest)result.AsyncState; + WebRequest request = (WebRequest) result.AsyncState; using (WebResponse resp = request.EndGetResponse(result)) { TResponse deserial; - XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); - deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); + XmlSerializer deserializer = new XmlSerializer(typeof (TResponse)); + deserial = (TResponse) deserializer.Deserialize(resp.GetResponseStream()); if (deserial != null && ResponseCallback != null) { @@ -90,4 +90,4 @@ namespace OpenSim.Framework.Servers } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs b/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs index 6338531..cfb585b 100644 --- a/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs +++ b/OpenSim/Framework/Servers/SynchronousRestObjectPoster.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Servers { public static TResponse BeginPostObject<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) { - Type type = typeof(TRequest); + Type type = typeof (TRequest); WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Servers writer.Flush(); } - int length = (int)buffer.Length; + int length = (int) buffer.Length; request.ContentLength = length; Stream requestStream = request.GetRequestStream(); @@ -65,12 +65,10 @@ namespace OpenSim.Framework.Servers TResponse deserial = default(TResponse); using (WebResponse resp = request.GetResponse()) { - - XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); - deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); + XmlSerializer deserializer = new XmlSerializer(typeof (TResponse)); + deserial = (TResponse) deserializer.Deserialize(resp.GetResponseStream()); } return deserial; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/XmlRpcMethod.cs b/OpenSim/Framework/Servers/XmlRpcMethod.cs index e4993e3..b156cdd 100644 --- a/OpenSim/Framework/Servers/XmlRpcMethod.cs +++ b/OpenSim/Framework/Servers/XmlRpcMethod.cs @@ -30,4 +30,4 @@ using Nwc.XmlRpc; namespace OpenSim.Framework.Servers { public delegate XmlRpcResponse XmlRpcMethod(XmlRpcRequest request); -} +} \ No newline at end of file diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index 39b1599..7ca2512 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs @@ -76,7 +76,8 @@ namespace OpenSim.Framework configMember.addConfigurationOption("default_inventory_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Inventory Server URI", - "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString() + "/", false); + "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString() + "/", + false); configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); @@ -107,7 +108,7 @@ namespace OpenSim.Framework GridRecvKey = (string) configuration_result; break; case "default_inventory_server": - InventoryUrl = (string)configuration_result; + InventoryUrl = (string) configuration_result; break; case "database_provider": DatabaseProvider = (string) configuration_result; @@ -116,13 +117,13 @@ namespace OpenSim.Framework HttpPort = (uint) configuration_result; break; case "http_ssl": - HttpSSL = (bool)configuration_result; + HttpSSL = (bool) configuration_result; break; case "default_X": - DefaultX = (uint)configuration_result; + DefaultX = (uint) configuration_result; break; case "default_Y": - DefaultY = (uint)configuration_result; + DefaultY = (uint) configuration_result; break; } diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs index 40a3d78..4df1ebd 100644 --- a/OpenSim/Framework/UserProfileData.cs +++ b/OpenSim/Framework/UserProfileData.cs @@ -150,14 +150,13 @@ namespace OpenSim.Framework /// </summary> //public class AvatarPickerAvatar //{ - //public LLUUID AvatarID; - //public string firstName; - //public string lastName; - //public AvatarPickerAvatar() - //{ - //} + //public LLUUID AvatarID; + //public string firstName; + //public string lastName; + //public AvatarPickerAvatar() + //{ + //} //} - /// <summary> /// Information about a users session /// </summary> @@ -224,4 +223,4 @@ namespace OpenSim.Framework /// </summary> public LLVector3 currentPos; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 1c8f273..3654a7d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -46,12 +46,13 @@ namespace OpenSim.Framework private static object XferLock = new object(); private static Dictionary<LLUUID, string> capsURLS = new Dictionary<LLUUID, string>(); - public static double GetDistanceTo(LLVector3 a, LLVector3 b) { - float dx = a.X - b.X; - float dy = a.Y - b.Y; - float dz = a.Z - b.Z; - return Math.Sqrt(dx * dx + dy * dy + dz * dz); - } + public static double GetDistanceTo(LLVector3 a, LLVector3 b) + { + float dx = a.X - b.X; + float dy = a.Y - b.Y; + float dz = a.Z - b.Z; + return Math.Sqrt(dx*dx + dy*dy + dz*dz); + } public static ulong UIntsToLong(uint X, uint Y) { @@ -383,7 +384,7 @@ namespace OpenSim.Framework { return Math.Min(Math.Max(x, min), max); } - + /// <summary> /// Convert an LLUUID to a raw uuid string. Right now this is a string without hyphens. /// </summary> @@ -394,4 +395,4 @@ namespace OpenSim.Framework return lluuid.UUID.ToString("n"); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/sLLVector3.cs b/OpenSim/Framework/sLLVector3.cs index e74378d..2e2c005 100644 --- a/OpenSim/Framework/sLLVector3.cs +++ b/OpenSim/Framework/sLLVector3.cs @@ -29,7 +29,6 @@ using System; using libsecondlife; - namespace OpenSim.Framework { [Serializable] @@ -37,17 +36,17 @@ namespace OpenSim.Framework { public sLLVector3() { - } + public sLLVector3(LLVector3 v) { x = v.X; y = v.Y; z = v.Z; } + public float x; public float y; public float z; } - -} +} \ No newline at end of file diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index c4e8e64..5d3d265 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -242,4 +242,4 @@ namespace OpenSim.Grid.AssetServer { } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs index 6608bd0..d598094 100644 --- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs @@ -60,4 +60,4 @@ using System.Runtime.InteropServices; // [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs index 1f44686..ee44108 100644 --- a/OpenSim/Grid/AssetServer/RestService.cs +++ b/OpenSim/Grid/AssetServer/RestService.cs @@ -45,7 +45,7 @@ namespace OpenSim.Grid.AssetServer public override byte[] Handle(string path, Stream request) { - MainLog.Instance.Verbose("REST", "In Handle"); + MainLog.Instance.Verbose("REST", "In Handle"); string param = GetParam(path); byte[] result = new byte[] {}; try @@ -129,4 +129,4 @@ namespace OpenSim.Grid.AssetServer m_assetProvider = assetProvider; } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index cb9f979..65df708 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -434,8 +434,8 @@ namespace OpenSim.Grid.GridServer } else { - MainLog.Instance.Verbose("DATA", "found " + (string)simData.regionName + " regionHandle = " + - (string)requestData["region_handle"]); + MainLog.Instance.Verbose("DATA", "found " + (string) simData.regionName + " regionHandle = " + + (string) requestData["region_handle"]); responseData["sim_ip"] = Util.GetHostFromDNS(simData.serverIP).ToString(); responseData["sim_port"] = simData.serverPort.ToString(); responseData["http_port"] = simData.httpPort.ToString(); @@ -513,7 +513,7 @@ namespace OpenSim.Grid.GridServer simProfileList.Add(simProfileBlock); } MainLog.Instance.Verbose("MAP", "Fast map " + simProfileList.Count.ToString() + - " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")" ); + " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); } else { @@ -548,7 +548,7 @@ namespace OpenSim.Grid.GridServer } } MainLog.Instance.Verbose("MAP", "Std map " + simProfileList.Count.ToString() + - " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); + " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); } responseData["sim-profiles"] = simProfileList; @@ -713,7 +713,8 @@ namespace OpenSim.Grid.GridServer try { - MainLog.Instance.Verbose("DATA", "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); + MainLog.Instance.Verbose("DATA", + "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); foreach (KeyValuePair<string, IGridData> kvp in _plugins) { try @@ -733,14 +734,14 @@ namespace OpenSim.Grid.GridServer { MainLog.Instance.Warn("grid", "Unable to update region (RestSetSimMethod): Incorrect reservation auth key."); - // Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + "."); + // Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + "."); return "Unable to update region (RestSetSimMethod): Incorrect auth key."; } } catch (Exception e) { MainLog.Instance.Warn("GRID", "getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + - e.ToString()); + e.ToString()); } } return "OK"; @@ -751,4 +752,4 @@ namespace OpenSim.Grid.GridServer } } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs index 5bae6a6..cdd37c4 100644 --- a/OpenSim/Grid/GridServer/Main.cs +++ b/OpenSim/Grid/GridServer/Main.cs @@ -103,7 +103,7 @@ namespace OpenSim.Grid.GridServer public void Startup() { Cfg = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); - //Yeah srsly, that's it. + //Yeah srsly, that's it. if (setuponly) Environment.Exit(0); m_console.Verbose("GRID", "Connecting to Storage Server"); @@ -218,4 +218,4 @@ namespace OpenSim.Grid.GridServer } }*/ } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs index 0399b3b..6f837e6 100644 --- a/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs @@ -60,4 +60,4 @@ using System.Runtime.InteropServices; // [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs index ca2e526..d36a915 100644 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -28,23 +28,22 @@ using System; using System.Collections.Generic; -using System.Text; +using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Console; -using libsecondlife; namespace OpenSim.Grid.InventoryServer { public class GridInventoryService : InventoryServiceBase { public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, - InventoryItemInfo itemCallBack) + InventoryItemInfo itemCallBack) { - } - private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, out List<InventoryItemBase> itemsList) + private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, + out List<InventoryItemBase> itemsList) { List<InventoryFolderBase> rootFolders = RequestFirstLevelFolders(userID); List<InventoryItemBase> allItems = new List<InventoryItemBase>(); @@ -107,10 +106,10 @@ namespace OpenSim.Grid.InventoryServer public InventoryCollection GetUserInventory(Guid rawUserID) { LLUUID userID = new LLUUID(rawUserID); - + // We get enough verbose messages later on for diagnostics //MainLog.Instance.Verbose("INVENTORY", "Request for inventory for " + userID.ToString()); - + InventoryCollection invCollection = new InventoryCollection(); List<InventoryFolderBase> folders; List<InventoryItemBase> allItems; @@ -126,14 +125,14 @@ namespace OpenSim.Grid.InventoryServer public bool CreateUsersInventory(Guid rawUserID) { LLUUID userID = new LLUUID(rawUserID); - + MainLog.Instance.Verbose( "INVENTORY", "Creating new set of inventory folders for " + userID.ToString()); - + CreateNewUserInventory(userID); return true; } - + public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) { @@ -156,30 +155,30 @@ namespace OpenSim.Grid.InventoryServer MainLog.Instance.Verbose( "INVENTORY", "Updating in " + folder.parentID.ToString() - + ", folder " + folder.name); - + + ", folder " + folder.name); + AddNewInventoryFolder(folder.agentID, folder); return true; } public bool MoveInventoryFolder(InventoryFolderBase folder) - { + { MainLog.Instance.Verbose( "INVENTORY", "Moving folder " + folder.folderID - + " to " + folder.parentID.ToString()); - + + " to " + folder.parentID.ToString()); + MoveExistingInventoryFolder(folder); return true; } - public bool AddInventoryItem( InventoryItemBase item) + public bool AddInventoryItem(InventoryItemBase item) { // Right now, this actions act more like an update/insert combination than a simple create. MainLog.Instance.Verbose( - "INVENTORY", + "INVENTORY", "Updating in " + item.parentFolderID.ToString() - + ", item " + item.inventoryName); + + ", item " + item.inventoryName); AddNewInventoryItem(item.avatarID, item); return true; @@ -191,15 +190,15 @@ namespace OpenSim.Grid.InventoryServer MainLog.Instance.Verbose( "INVENTORY", "Deleting in " + item.parentFolderID.ToString() - + ", item " + item.inventoryName); - + + ", item " + item.inventoryName); + DeleteItem(item); } - public bool DeleteInvItem( InventoryItemBase item) + public bool DeleteInvItem(InventoryItemBase item) { DeleteInventoryItem(item.avatarID, item); return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs index 1070bcf..a003ce3 100644 --- a/OpenSim/Grid/InventoryServer/InventoryManager.cs +++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs @@ -25,26 +25,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.IO; -using System.Text; using System.Reflection; -using System.Collections; -using System.Collections.Generic; +using System.Text; using System.Xml; using System.Xml.Serialization; using libsecondlife; - using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; namespace OpenSim.Grid.InventoryServer { - public class InventoryManager { - IInventoryData _databasePlugin; + private IInventoryData _databasePlugin; /// <summary> /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. @@ -55,7 +52,8 @@ namespace OpenSim.Grid.InventoryServer MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + MainLog.Instance.Verbose(OpenInventory_Main.LogName, + "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (!pluginType.IsAbstract) @@ -64,10 +62,12 @@ namespace OpenSim.Grid.InventoryServer if (typeInterface != null) { - IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IInventoryData plug = + (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); _databasePlugin = plug; - MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Added IInventoryData Interface"); + MainLog.Instance.Verbose(OpenInventory_Main.LogName, + "Invenstorage: Added IInventoryData Interface"); break; } @@ -82,8 +82,8 @@ namespace OpenSim.Grid.InventoryServer { FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); XmlReader reader = new XmlTextReader(fs); - XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); - SerializableInventory inventory = (SerializableInventory)x.Deserialize(reader); + XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); + SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader); fs.Close(); fs.Dispose(); return inventory; @@ -93,11 +93,12 @@ namespace OpenSim.Grid.InventoryServer { XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8); writer.Formatting = Formatting.Indented; - XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); + XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); x.Serialize(writer, inventory); } - protected static bool fixupFolder(SerializableInventory.SerializableFolder f, SerializableInventory.SerializableFolder parent) + protected static bool fixupFolder(SerializableInventory.SerializableFolder f, + SerializableInventory.SerializableFolder parent) { bool modified = false; @@ -142,6 +143,7 @@ namespace OpenSim.Grid.InventoryServer { private SerializableInventory _inventory; private InventoryManager _manager; + public GetInventory(InventoryManager manager) : base("GET", "/inventory") { @@ -165,23 +167,24 @@ namespace OpenSim.Grid.InventoryServer private byte[] GetUserInventory(LLUUID userID) { MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString()); - byte[] result = new byte[] { }; + byte[] result = new byte[] {}; InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID); if (fb == null) { - MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", userID.ToString()); + MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", + userID.ToString()); CreateDefaultInventory(userID); } return result; } - override public byte[] Handle(string path, Stream request) + public override byte[] Handle(string path, Stream request) { - byte[] result = new byte[] { }; + byte[] result = new byte[] {}; - string[] parms = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); if (parms.Length > 1) { if (string.Compare(parms[1], "library", true) == 0) @@ -190,7 +193,7 @@ namespace OpenSim.Grid.InventoryServer saveInventoryToStream(_inventory, ms); result = ms.GetBuffer(); - Array.Resize<byte>(ref result, (int)ms.Length); + Array.Resize<byte>(ref result, (int) ms.Length); } else if (string.Compare(parms[1], "user", true) == 0) { @@ -204,4 +207,4 @@ namespace OpenSim.Grid.InventoryServer } } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index df854f9..ce371bf 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -25,29 +25,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; -using System.Collections; using System.Collections.Generic; -using System.Reflection; using System.IO; -using System.Text; - using libsecondlife; - using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; -using InventoryManager = OpenSim.Grid.InventoryServer.InventoryManager; - namespace OpenSim.Grid.InventoryServer { public class OpenInventory_Main : conscmd_callback { - LogBase m_console; - InventoryManager m_inventoryManager; - InventoryConfig m_config; - GridInventoryService m_inventoryService; + private LogBase m_console; + private InventoryManager m_inventoryManager; + private InventoryConfig m_config; + private GridInventoryService m_inventoryService; public const string LogName = "INVENTORY"; @@ -72,20 +66,20 @@ namespace OpenSim.Grid.InventoryServer m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); m_inventoryService = new GridInventoryService(); - // m_inventoryManager = new InventoryManager(); + // m_inventoryManager = new InventoryManager(); m_inventoryService.AddPlugin(m_config.DatabaseProvider); MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); httpServer.AddStreamHandler( new RestDeserialisehandler<Guid, InventoryCollection>("POST", "/GetInventory/", - m_inventoryService.GetUserInventory)); + m_inventoryService.GetUserInventory)); httpServer.AddStreamHandler( new RestDeserialisehandler<Guid, bool>("POST", "/CreateInventory/", - m_inventoryService.CreateUsersInventory)); + m_inventoryService.CreateUsersInventory)); httpServer.AddStreamHandler( new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/", - m_inventoryService.AddInventoryFolder)); + m_inventoryService.AddInventoryFolder)); httpServer.AddStreamHandler( new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/MoveFolder/", @@ -93,16 +87,16 @@ namespace OpenSim.Grid.InventoryServer httpServer.AddStreamHandler( new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/", - m_inventoryService.AddInventoryItem)); + m_inventoryService.AddInventoryItem)); httpServer.AddStreamHandler( new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/", - m_inventoryService.DeleteInvItem)); + m_inventoryService.DeleteInvItem)); httpServer.AddStreamHandler( new RestDeserialisehandler<Guid, List<InventoryFolderBase>>("POST", "/RootFolders/", - m_inventoryService.RequestFirstLevelFolders)); + m_inventoryService.RequestFirstLevelFolders)); - // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); + // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); httpServer.Start(); MainLog.Instance.Notice(LogName, "Started HTTP server"); @@ -137,4 +131,4 @@ namespace OpenSim.Grid.InventoryServer { } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/Application.cs b/OpenSim/Grid/ScriptServer/Application.cs index dd1da66..5076618 100644 --- a/OpenSim/Grid/ScriptServer/Application.cs +++ b/OpenSim/Grid/ScriptServer/Application.cs @@ -52,4 +52,4 @@ namespace OpenSim.Grid.ScriptServer Console.WriteLine(e.ExceptionObject.ToString()); } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs index 87198d1..7d29129 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs @@ -101,4 +101,4 @@ namespace OpenSim.Grid.ScriptServer Regions.Add(new RegionConnectionManager(m_ScriptServerMain, m_log, null)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineInterface.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineInterface.cs index fc6939c..518c198 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineInterface.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineInterface.cs @@ -35,4 +35,4 @@ namespace OpenSim.Grid.ScriptServer void Shutdown(); // void StartScript(string ScriptID, IScriptHost ObjectID); } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs index d02955e..7f39931 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs @@ -121,4 +121,4 @@ namespace OpenSim.Grid.ScriptServer return ret; } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 4806e52..6e3ccb7 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -129,7 +129,8 @@ namespace OpenSim.Grid.UserServer tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); LLUUID userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); - RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); + RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/", + userID.UUID); m_lastCreatedUser = userID; break; } @@ -154,17 +155,23 @@ namespace OpenSim.Grid.UserServer break; case "test-inventory": - // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); - // requester.ReturnResponseVal = TestResponse; - // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); - List<InventoryFolderBase> folders = SynchronousRestObjectPoster.BeginPostObject< LLUUID, List<InventoryFolderBase>>("POST",m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); + // requester.ReturnResponseVal = TestResponse; + // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); + List<InventoryFolderBase> folders = + SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", + m_userManager. + _config. + InventoryUrl + + "RootFolders/", + m_lastCreatedUser); break; } } public void TestResponse(List<InventoryFolderBase> resp) { - System.Console.WriteLine("response got"); + Console.WriteLine("response got"); } /*private void ConfigDB(IGenericConfig configData) @@ -194,4 +201,4 @@ namespace OpenSim.Grid.UserServer { } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 9b9360d..0eb2db1 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -29,16 +29,15 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Net; using System.Threading; -using Nwc.XmlRpc; using libsecondlife; +using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Servers; using OpenSim.Framework.Data; +using OpenSim.Framework.Servers; using OpenSim.Framework.UserManagement; -using InventoryFolder = OpenSim.Framework.InventoryFolder; +using InventoryFolder=OpenSim.Framework.InventoryFolder; namespace OpenSim.Grid.UserServer { @@ -72,8 +71,8 @@ namespace OpenSim.Grid.UserServer // Customise the response //CFK: This is redundant and the next message should always appear. //CFK: MainLog.Instance.Verbose("LOGIN", "Home Location"); - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + - (SimInfo.regionLocY * 256).ToString() + "], " + + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + + (SimInfo.regionLocY*256).ToString() + "], " + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + @@ -106,7 +105,7 @@ namespace OpenSim.Grid.UserServer SimParams["firstname"] = theUser.username; SimParams["lastname"] = theUser.surname; SimParams["agent_id"] = theUser.UUID.ToString(); - SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); + SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); @@ -119,9 +118,9 @@ namespace OpenSim.Grid.UserServer theUser.currentAgent.currentRegion = SimInfo.UUID; theUser.currentAgent.currentHandle = SimInfo.regionHandle; - MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " + - SimInfo.regionLocX + "," + SimInfo.regionLocY); - + MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " + + SimInfo.regionLocX + "," + SimInfo.regionLocY); + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); } @@ -129,17 +128,17 @@ namespace OpenSim.Grid.UserServer { tryDefault = true; } - if(tryDefault) + if (tryDefault) { // Send him to default region instead // Load information from the gridserver - ulong defaultHandle = (((ulong)m_config.DefaultX * 256) << 32) | ((ulong) m_config.DefaultY * 256); - + ulong defaultHandle = (((ulong) m_config.DefaultX*256) << 32) | ((ulong) m_config.DefaultY*256); + MainLog.Instance.Warn( - "LOGIN", + "LOGIN", "Home region not available: sending to default " + defaultHandle.ToString()); - + SimInfo = new RegionProfileData(); try { @@ -149,15 +148,16 @@ namespace OpenSim.Grid.UserServer // Customise the response MainLog.Instance.Verbose("LOGIN", "Home Location"); - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + - (SimInfo.regionLocY * 256).ToString() + "], " + + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + + (SimInfo.regionLocY*256).ToString() + "], " + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; // Destination - MainLog.Instance.Verbose("LOGIN", "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + + MainLog.Instance.Verbose("LOGIN", + "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); response.SimPort = (uint) SimInfo.serverPort; @@ -182,7 +182,7 @@ namespace OpenSim.Grid.UserServer SimParams["firstname"] = theUser.username; SimParams["lastname"] = theUser.surname; SimParams["agent_id"] = theUser.UUID.ToString(); - SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); + SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); @@ -202,35 +202,34 @@ namespace OpenSim.Grid.UserServer MainLog.Instance.Warn("LOGIN", "Default region also not available"); MainLog.Instance.Warn("LOGIN", e.ToString()); } - } } protected override InventoryData CreateInventoryData(LLUUID userID) { - List<InventoryFolderBase> folders + List<InventoryFolderBase> folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); - + // In theory, the user will only ever be missing a root folder in situations where a grid // which didn't previously run a grid wide inventory server is being transitioned to one // which does. if (null == folders | folders.Count == 0) { MainLog.Instance.Warn( - "LOGIN", + "LOGIN", "A root inventory folder for user ID " + userID + " was not found. A new set" + " of empty inventory folders is being created."); - + RestObjectPoster.BeginPostObject<Guid>( m_config.InventoryUrl + "CreateInventory/", userID.UUID); - + // A big delay should be okay here since the recreation of the user's root folders should // only ever happen once. We need to sleep to let the inventory server do its work - // previously 1000ms has been found to be too short. Thread.Sleep(10000); folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( - "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); + "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); } if (folders.Count > 0) @@ -247,8 +246,8 @@ namespace OpenSim.Grid.UserServer TempHash = new Hashtable(); TempHash["name"] = InvFolder.name; TempHash["parent_id"] = InvFolder.parentID.ToString(); - TempHash["version"] = (Int32)InvFolder.version; - TempHash["type_default"] = (Int32)InvFolder.type; + TempHash["version"] = (Int32) InvFolder.version; + TempHash["type_default"] = (Int32) InvFolder.type; TempHash["folder_id"] = InvFolder.folderID.ToString(); AgentInventoryArray.Add(TempHash); } @@ -257,8 +256,8 @@ namespace OpenSim.Grid.UserServer else { MainLog.Instance.Warn("LOGIN", "The root inventory folder could still not be retrieved" + - " for user ID " + userID); - + " for user ID " + userID); + AgentInventory userInventory = new AgentInventory(); userInventory.CreateRootFolder(userID, false); @@ -269,8 +268,8 @@ namespace OpenSim.Grid.UserServer TempHash = new Hashtable(); TempHash["name"] = InvFolder.FolderName; TempHash["parent_id"] = InvFolder.ParentID.ToString(); - TempHash["version"] = (Int32)InvFolder.Version; - TempHash["type_default"] = (Int32)InvFolder.DefaultType; + TempHash["version"] = (Int32) InvFolder.Version; + TempHash["type_default"] = (Int32) InvFolder.DefaultType; TempHash["folder_id"] = InvFolder.FolderID.ToString(); AgentInventoryArray.Add(TempHash); } @@ -279,4 +278,4 @@ namespace OpenSim.Grid.UserServer } } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index be9e6f1..a50419e 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -28,6 +28,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Text.RegularExpressions; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework; @@ -76,8 +77,8 @@ namespace OpenSim.Grid.UserServer XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); // Query Result Information - responseData["queryid"] = (string)queryID.ToString(); - responseData["avcount"] = (string)returnUsers.Count.ToString(); + responseData["queryid"] = (string) queryID.ToString(); + responseData["avcount"] = (string) returnUsers.Count.ToString(); for (int i = 0; i < returnUsers.Count; i++) { @@ -86,9 +87,10 @@ namespace OpenSim.Grid.UserServer responseData["lastname" + i.ToString()] = returnUsers[i].lastName; } response.Value = responseData; - + return response; } + /// <summary> /// Converts a user profile to an XML element which can be returned /// </summary> @@ -135,18 +137,18 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>(); LLUUID queryID = new LLUUID(LLUUID.Zero.ToString()); if (requestData.Contains("avquery") && requestData.Contains("queryid")) { - queryID = new LLUUID((string)requestData["queryid"]); - returnAvatar = GenerateAgentPickerRequestResponse(queryID,(string)requestData["avquery"]); + queryID = new LLUUID((string) requestData["queryid"]); + returnAvatar = GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]); } - Console.WriteLine("[AVATARINFO]: Servicing Avatar Query: " + (string)requestData["avquery"]); - return AvatarPickerListtoXmlRPCResponse(queryID,returnAvatar); + Console.WriteLine("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]); + return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); } public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) @@ -156,16 +158,16 @@ namespace OpenSim.Grid.UserServer UserProfileData userProfile; if (requestData.Contains("avatar_name")) { - string query = (string)requestData["avatar_name"]; + string query = (string) requestData["avatar_name"]; - System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9]"); + Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); string[] querysplit; querysplit = query.Split(' '); if (querysplit.Length == 2) { - userProfile = GetUserProfile(querysplit[0],querysplit[1]); + userProfile = GetUserProfile(querysplit[0], querysplit[1]); if (userProfile == null) { return CreateUnknownUserErrorResponse(); @@ -196,11 +198,11 @@ namespace OpenSim.Grid.UserServer LLUUID guess = new LLUUID(); try { - guess = new LLUUID((string)requestData["avatar_uuid"]); + guess = new LLUUID((string) requestData["avatar_uuid"]); userProfile = GetUserProfile(guess); } - catch (System.FormatException) + catch (FormatException) { return CreateUnknownUserErrorResponse(); } @@ -231,9 +233,9 @@ namespace OpenSim.Grid.UserServer throw new Exception("The method or operation is not implemented."); } - public override UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid) + public override UserProfileData SetupMasterUser(LLUUID uuid) { throw new Exception("The method or operation is not implemented."); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 130199d..cb3bd40 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -77,4 +77,4 @@ namespace OpenSim } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 17c81e1..4f81354 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -26,13 +26,10 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using Mono.Addins; -using Mono.Addins.Description; -[assembly: AddinRoot("OpenSim", "0.4")] +[assembly : AddinRoot("OpenSim", "0.4")] + namespace OpenSim { [TypeExtensionPoint("/OpenSim/Startup")] @@ -41,4 +38,4 @@ namespace OpenSim void Initialise(OpenSimMain openSim); void Close(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index b3daf0c..fa2a989 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -30,6 +30,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Text; +using System.Threading; +using System.Timers; +using libsecondlife; +using Mono.Addins; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -42,9 +46,7 @@ using OpenSim.Region.Environment; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; -using libsecondlife; -using Mono.Addins; -using Mono.Addins.Description; +using Timer=System.Timers.Timer; namespace OpenSim { @@ -86,7 +88,7 @@ namespace OpenSim private string m_assetStorage = "sqlite"; private string m_timedScript = "disabled"; - private System.Timers.Timer m_scriptTimer; + private Timer m_scriptTimer; public ConsoleCommand CreateAccount = null; private bool m_dumpAssetsToFile; @@ -238,7 +240,7 @@ namespace OpenSim m_permissions = startupConfig.GetBoolean("serverside_object_permissions", false); m_storageDll = startupConfig.GetString("storage_plugin", "OpenSim.DataStore.MonoSqlite.dll"); - m_storageConnectionString + m_storageConnectionString = startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3"); m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", ""); @@ -268,7 +270,7 @@ namespace OpenSim if (!m_sandbox) m_SendChildAgentTaskData = false; - + m_networkServersInfo.loadFromConfiguration(m_config); } @@ -327,16 +329,16 @@ namespace OpenSim MainLog.Instance.Verbose("Plugins", "Loading OpenSim application plugins"); foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/Startup")) { - IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); + IApplicationPlugin plugin = (IApplicationPlugin) node.CreateInstance(); plugin.Initialise(this); m_plugins.Add(plugin); } - + // Start UDP servers //for (int i = 0; i < m_udpServers.Count; i++) //{ - // m_udpServers[i].ServerListener(); - // } + // m_udpServers[i].ServerListener(); + // } //Run Startup Commands if (m_startupCommandsFile != "") @@ -353,10 +355,10 @@ namespace OpenSim if (m_timedScript != "disabled") { - m_scriptTimer = new System.Timers.Timer(); + m_scriptTimer = new Timer(); m_scriptTimer.Enabled = true; - m_scriptTimer.Interval = (int)(1200 * 1000); - m_scriptTimer.Elapsed += new System.Timers.ElapsedEventHandler(RunAutoTimerScript); + m_scriptTimer.Interval = (int) (1200*1000); + m_scriptTimer.Elapsed += new ElapsedEventHandler(RunAutoTimerScript); } } @@ -402,11 +404,13 @@ namespace OpenSim SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); if (m_SendChildAgentTaskData) { - MainLog.Instance.Error("WARNING", "Send Child Agent Task Updates is enabled. This is for testing only. It doesn't work on grid mode!"); - System.Threading.Thread.Sleep(12000); + MainLog.Instance.Error("WARNING", + "Send Child Agent Task Updates is enabled. This is for testing only. It doesn't work on grid mode!"); + Thread.Sleep(12000); } return - new Scene(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, + new Scene(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache, + storageManager, m_httpServer, m_moduleLoader, m_dumpAssetsToFile, m_physicalPrim, m_SendChildAgentTaskData); } @@ -440,16 +444,15 @@ namespace OpenSim m_assetCache = new AssetCache(assetServer, m_log); // m_assetCache = new assetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); m_sceneManager.OnRestartSim += handleRestartRegion; - } - public void handleRestartRegion(RegionInfo whichRegion) + public void handleRestartRegion(RegionInfo whichRegion) { MainLog.Instance.Error("MAIN", "Got restart signal from SceneManager"); // Shutting down the UDP server bool foundUDPServer = false; int UDPServerElement = 0; - + for (int i = 0; i < m_udpServers.Count; i++) { if (m_udpServers[i].RegionHandle == whichRegion.RegionHandle) @@ -459,9 +462,9 @@ namespace OpenSim break; } } - if (foundUDPServer) + if (foundUDPServer) { - // m_udpServers[UDPServerElement].Server.End + // m_udpServers[UDPServerElement].Server.End m_udpServers[UDPServerElement].Server.Close(); m_udpServers.RemoveAt(UDPServerElement); } @@ -479,7 +482,7 @@ namespace OpenSim { m_regionData.RemoveAt(RegionHandleElement); } - + CreateRegion(whichRegion); //UDPServer restartingRegion = CreateRegion(whichRegion); //restartingRegion.ServerListener(); @@ -537,7 +540,7 @@ namespace OpenSim { RunCommandScript(m_shutdownCommandsFile); } - + m_log.Verbose("SHUTDOWN", "Closing all threads"); m_log.Verbose("SHUTDOWN", "Killing listener thread"); m_log.Verbose("SHUTDOWN", "Killing clients"); @@ -557,6 +560,7 @@ namespace OpenSim RunCommandScript(m_timedScript); } } + #region Console Commands /// <summary> @@ -679,10 +683,17 @@ namespace OpenSim } if (cmdparams.Length > 2) { - loadOffset.X = (float)Convert.ToDecimal(cmdparams[2]); - if (cmdparams.Length > 3) { loadOffset.Y = (float)Convert.ToDecimal(cmdparams[3]); } - if (cmdparams.Length > 4) { loadOffset.Z = (float)Convert.ToDecimal(cmdparams[4]); } - m_log.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," + loadOffset.Z + ">"); + loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]); + if (cmdparams.Length > 3) + { + loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]); + } + if (cmdparams.Length > 4) + { + loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]); + } + m_log.Error("loadOffsets <X,Y,Z> = <" + loadOffset.X + "," + loadOffset.Y + "," + + loadOffset.Z + ">"); } } m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); @@ -795,12 +806,13 @@ namespace OpenSim if (m_sceneManager.CurrentScene == null) { - MainLog.Instance.Verbose("CONSOLE", - "Currently at Root level. To change region please use 'change-region <regioname>'"); + MainLog.Instance.Verbose("CONSOLE", + "Currently at Root level. To change region please use 'change-region <regioname>'"); } else { - MainLog.Instance.Verbose("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + + MainLog.Instance.Verbose("CONSOLE", + "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + ". To change region please use 'change-region <regioname>'"); } @@ -901,10 +913,13 @@ namespace OpenSim break; case "regions": - m_sceneManager.ForEachScene(delegate(Scene scene) - { - m_log.Error("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + scene.RegionInfo.RegionLocX + " , Region YLoc: " + scene.RegionInfo.RegionLocY); - }); + m_sceneManager.ForEachScene( + delegate(Scene scene) + { + m_log.Error("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + + scene.RegionInfo.RegionLocX + " , Region YLoc: " + + scene.RegionInfo.RegionLocY); + }); break; } } @@ -922,4 +937,4 @@ namespace OpenSim #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/VersionInfo.cs b/OpenSim/Region/Application/VersionInfo.cs index 8d8217f..0f798e4 100644 --- a/OpenSim/Region/Application/VersionInfo.cs +++ b/OpenSim/Region/Application/VersionInfo.cs @@ -33,4 +33,4 @@ namespace OpenSim { public static string Version = "0.4, SVN build "; } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs index 7bfadea..b3af1cc 100644 --- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs +++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs @@ -35,4 +35,4 @@ namespace OpenSim.Region.ClientStack void RemoveClientCircuit(uint circuitcode); void RegisterPacketServer(PacketServer server); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index f29d2f9..b232ed6 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -38,6 +38,7 @@ using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack @@ -71,9 +72,10 @@ namespace OpenSim.Region.ClientStack private readonly uint m_circuitCode; private int m_moneyBalance; - private readonly byte[] m_channelVersion=new byte[] { 0x00} ; // Dummy value needed by libSL + private readonly byte[] m_channelVersion = new byte[] {0x00}; // Dummy value needed by libSL /* protected variables */ + protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients @@ -94,7 +96,7 @@ namespace OpenSim.Region.ClientStack protected const int RESEND_TIMEOUT = 4000; protected const int MAX_SEQUENCE = 0xFFFFFF; protected PacketServer m_networkServer; - + /* public variables */ protected string m_firstName; protected string m_lastName; @@ -103,11 +105,12 @@ namespace OpenSim.Region.ClientStack protected EndPoint m_userEndPoint; /* Properties */ + public LLUUID SecureSessionId { get { return m_secureSessionId; } } - + public IScene Scene { get { return m_scene; } @@ -144,7 +147,7 @@ namespace OpenSim.Region.ClientStack { get { return m_lastName; } } - + /// <summary> /// Full name of the client (first name and last name) /// </summary> @@ -162,10 +165,11 @@ namespace OpenSim.Region.ClientStack { get { return m_moneyBalance; } } - + /* METHODS */ - public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) + public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, + AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) { m_moneyBalance = 1000; @@ -209,7 +213,6 @@ namespace OpenSim.Region.ClientStack private void CloseCleanup() { - m_scene.RemoveClient(AgentId); // Send the STOP packet DisableSimulatorPacket disable = new DisableSimulatorPacket(); @@ -222,9 +225,6 @@ namespace OpenSim.Region.ClientStack Thread.Sleep(2000); - - - // Shut down timers m_ackTimer.Stop(); @@ -243,18 +243,15 @@ namespace OpenSim.Region.ClientStack public void Close(bool ShutdownCircult) { - // Pull Client out of Region MainLog.Instance.Verbose("CLIENT", "Close has been called"); //raiseevent on the packet server to Shutdown the circuit if (ShutdownCircult) OnConnectionClosed(this); - - CloseCleanup(); - + CloseCleanup(); } public void Kick(string message) @@ -262,8 +259,8 @@ namespace OpenSim.Region.ClientStack KickUserPacket kupack = new KickUserPacket(); kupack.UserInfo.AgentID = AgentId; kupack.UserInfo.SessionID = SessionId; - kupack.TargetBlock.TargetIP = (uint)0; - kupack.TargetBlock.TargetPort = (ushort)0; + kupack.TargetBlock.TargetIP = (uint) 0; + kupack.TargetBlock.TargetPort = (ushort) 0; kupack.UserInfo.Reason = Helpers.StringToField(message); OutPacket(kupack, ThrottleOutPacketType.Task); } @@ -340,9 +337,9 @@ namespace OpenSim.Region.ClientStack if (m_debug < 254 && packet.Type == PacketType.ViewerEffect) return; if (m_debug < 253 && ( - packet.Type == PacketType.CompletePingCheck || - packet.Type == PacketType.StartPingCheck - )) + packet.Type == PacketType.CompletePingCheck || + packet.Type == PacketType.StartPingCheck + )) return; if (m_debug < 252 && packet.Type == PacketType.PacketAck) return; @@ -552,7 +549,7 @@ namespace OpenSim.Region.ClientStack public event EstateOwnerMessageRequest OnEstateOwnerMessage; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; - + #region Scene/Avatar to Client /// <summary> @@ -561,7 +558,8 @@ namespace OpenSim.Region.ClientStack /// <param name="regionInfo"></param> public void SendRegionHandshake(RegionInfo regionInfo) { - RegionHandshakePacket handshake = (RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake); + RegionHandshakePacket handshake = + (RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake); handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor; handshake.RegionInfo.IsEstateManager = false; @@ -645,7 +643,7 @@ namespace OpenSim.Region.ClientStack OutPacket(reply, ThrottleOutPacketType.Task); } - + /// <summary> /// /// </summary> @@ -861,7 +859,7 @@ namespace OpenSim.Region.ClientStack public void SendTeleportFailed() { TeleportFailedPacket tpFailed = new TeleportFailedPacket(); - tpFailed.Info.AgentID = this.AgentId; + tpFailed.Info.AgentID = AgentId; tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport"); OutPacket(tpFailed, ThrottleOutPacketType.Task); } @@ -914,8 +912,8 @@ namespace OpenSim.Region.ClientStack /// <param name="items">The items contained in the folder identified by folderID</param> /// <param name="fetchFolders">Do we need to send folder information?</param> /// <param name="fetchItems">Do we need to send item information?</param> - public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items, - List<InventoryFolderBase> folders, + public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items, + List<InventoryFolderBase> folders, bool fetchFolders, bool fetchItems) { // An inventory descendents packet consists of a single agent section and an inventory details @@ -929,14 +927,14 @@ namespace OpenSim.Region.ClientStack // for one example of this kind of thing. So we'll go for a cautious max // items of 20 which gives a packet size of about 11k int MAX_ITEMS_PER_PACKET = 20; - + Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; - + if (fetchItems) { - InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - + InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); + if (items.Count < MAX_ITEMS_PER_PACKET) { descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; @@ -947,7 +945,7 @@ namespace OpenSim.Region.ClientStack descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; } - + // Even if we aren't fetching the folders, we still need to include the folder count // in the total number of descendents. Failure to do so will cause subtle bugs such // as the failure of textures which haven't been expanded in inventory to show up @@ -956,7 +954,7 @@ namespace OpenSim.Region.ClientStack { descend.AgentData.Descendents += folders.Count; } - + int count = 0; int i = 0; foreach (InventoryItemBase item in items) @@ -973,28 +971,31 @@ namespace OpenSim.Region.ClientStack descend.ItemData[i].FolderID = item.parentFolderID; descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); descend.ItemData[i].GroupMask = 0; - descend.ItemData[i].InvType = (sbyte)item.invType; + descend.ItemData[i].InvType = (sbyte) item.invType; descend.ItemData[i].Name = Helpers.StringToField(item.inventoryName); descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions; descend.ItemData[i].OwnerID = item.avatarID; descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions; descend.ItemData[i].SalePrice = 0; descend.ItemData[i].SaleType = 0; - descend.ItemData[i].Type = (sbyte)item.assetType; + descend.ItemData[i].Type = (sbyte) item.assetType; descend.ItemData[i].CRC = Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, descend.ItemData[i].InvType, descend.ItemData[i].Type, - descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice, + descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, + descend.ItemData[i].SalePrice, descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, - descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, descend.ItemData[i].EveryoneMask, - descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); - + descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, + descend.ItemData[i].EveryoneMask, + descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, + descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); + i++; count++; if (i == MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); - + if ((items.Count - count) > 0) { descend = CreateInventoryDescendentsPacket(ownerID, folderID); @@ -1012,7 +1013,7 @@ namespace OpenSim.Region.ClientStack } } } - + if (i < MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); @@ -1023,7 +1024,7 @@ namespace OpenSim.Region.ClientStack if (fetchFolders) { InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - + if (folders.Count < MAX_ITEMS_PER_PACKET) { descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; @@ -1034,14 +1035,14 @@ namespace OpenSim.Region.ClientStack descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; } - + // Not sure if this scenario ever actually occurs, but nonetheless we include the items // count even if we're not sending item data for the same reasons as above. if (!fetchItems) { descend.AgentData.Descendents += items.Count; - } - + } + int i = 0; int count = 0; foreach (InventoryFolderBase folder in folders) @@ -1050,32 +1051,34 @@ namespace OpenSim.Region.ClientStack descend.FolderData[i].FolderID = folder.folderID; descend.FolderData[i].Name = Helpers.StringToField(folder.name); descend.FolderData[i].ParentID = folder.parentID; - descend.FolderData[i].Type = (sbyte)folder.type; + descend.FolderData[i].Type = (sbyte) folder.type; i++; count++; if (i == MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); - + if ((folders.Count - count) > 0) { descend = CreateInventoryDescendentsPacket(ownerID, folderID); if ((folders.Count - count) < MAX_ITEMS_PER_PACKET) { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; + descend.FolderData = + new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; descend.AgentData.Descendents = folders.Count - count; } else { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; + descend.FolderData = + new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; } i = 0; } } } - + if (i < MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); @@ -1204,6 +1207,7 @@ namespace OpenSim.Region.ClientStack sendXfer.DataPacket.Data = data; OutPacket(sendXfer, ThrottleOutPacketType.Task); } + public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket) { OutPacket(replyPacket, ThrottleOutPacketType.Task); @@ -1272,7 +1276,7 @@ namespace OpenSim.Region.ClientStack OutPacket(sound, ThrottleOutPacketType.Task); } - public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) + public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) { SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); viewertime.TimeInfo.SunDirection = sunPos; @@ -1524,12 +1528,13 @@ namespace OpenSim.Region.ClientStack OutPacket(attach, ThrottleOutPacketType.Task); } - + public void SendPrimitiveToClient( ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, - LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction) + LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, + LLQuaternion rotation, byte clickAction) { ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); outPacket.RegionData.RegionHandle = regionHandle; @@ -1572,8 +1577,8 @@ namespace OpenSim.Region.ClientStack public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { - LLVector3 velocity = new LLVector3(0f,0f,0f); - LLVector3 rotationalvelocity = new LLVector3(0f,0f,0f); + LLVector3 velocity = new LLVector3(0f, 0f, 0f); + LLVector3 rotationalvelocity = new LLVector3(0f, 0f, 0f); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; @@ -1582,10 +1587,10 @@ namespace OpenSim.Region.ClientStack OutPacket(terse, ThrottleOutPacketType.Task); } + public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) { - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; @@ -1594,7 +1599,6 @@ namespace OpenSim.Region.ClientStack OutPacket(terse, ThrottleOutPacketType.Task); } - #endregion @@ -1696,7 +1700,9 @@ namespace OpenSim.Region.ClientStack /// <returns></returns> protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, - LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) + LLQuaternion rotation, + LLVector3 velocity, + LLVector3 rotationalvelocity) { uint ID = localID; byte[] bytes = new byte[60]; @@ -1724,16 +1730,16 @@ namespace OpenSim.Region.ClientStack vel.y += 1; vel.z += 1; //vel - velx = (ushort)(32768 * (vel.x)); - vely = (ushort)(32768 * (vel.y)); - velz = (ushort)(32768 * (vel.z)); + velx = (ushort) (32768*(vel.x)); + vely = (ushort) (32768*(vel.y)); + velz = (ushort) (32768*(vel.z)); - bytes[i++] = (byte) (velx % 256); - bytes[i++] = (byte) ((velx >> 8) % 256); - bytes[i++] = (byte) (vely % 256); - bytes[i++] = (byte) ((vely >> 8) % 256); - bytes[i++] = (byte) (velz % 256); - bytes[i++] = (byte) ((velz >> 8) % 256); + bytes[i++] = (byte) (velx%256); + bytes[i++] = (byte) ((velx >> 8)%256); + bytes[i++] = (byte) (vely%256); + bytes[i++] = (byte) ((vely >> 8)%256); + bytes[i++] = (byte) (velz%256); + bytes[i++] = (byte) ((velz >> 8)%256); //accel bytes[i++] = (byte) (ac%256); @@ -1763,21 +1769,21 @@ namespace OpenSim.Region.ClientStack ushort rvelx, rvely, rvelz; Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z); - rvel = rvel / 128.0f; + rvel = rvel/128.0f; rvel.x += 1; rvel.y += 1; rvel.z += 1; //vel - rvelx = (ushort)(32768 * (rvel.x)); - rvely = (ushort)(32768 * (rvel.y)); - rvelz = (ushort)(32768 * (rvel.z)); + rvelx = (ushort) (32768*(rvel.x)); + rvely = (ushort) (32768*(rvel.y)); + rvelz = (ushort) (32768*(rvel.z)); - bytes[i++] = (byte)(rvelx % 256); - bytes[i++] = (byte)((rvelx >> 8) % 256); - bytes[i++] = (byte)(rvely % 256); - bytes[i++] = (byte)((rvely >> 8) % 256); - bytes[i++] = (byte)(rvelz % 256); - bytes[i++] = (byte)((rvelz >> 8) % 256); + bytes[i++] = (byte) (rvelx%256); + bytes[i++] = (byte) ((rvelx >> 8)%256); + bytes[i++] = (byte) (rvely%256); + bytes[i++] = (byte) ((rvely >> 8)%256); + bytes[i++] = (byte) (rvelz%256); + bytes[i++] = (byte) ((rvelz >> 8)%256); dat.Data = bytes; return dat; @@ -1906,7 +1912,7 @@ namespace OpenSim.Region.ClientStack objdata.Sound = LLUUID.Zero; LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); objdata.TextureEntry = ntex.ToBytes(); - + objdata.State = 0; objdata.Data = new byte[0]; @@ -1993,13 +1999,13 @@ namespace OpenSim.Region.ClientStack { MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket) packet; // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); - OpenSim.Region.Environment.Scenes.Scene tScene = (OpenSim.Region.Environment.Scenes.Scene)this.m_scene; + Scene tScene = (Scene) m_scene; for (int i = 0; i < multipleupdate.ObjectData.Length; i++) { // Can't act on Null Data if (multipleupdate.ObjectData[i].Data != null) - { + { LLUUID editobj = tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID; if (editobj != null) { @@ -2024,8 +2030,8 @@ namespace OpenSim.Region.ClientStack OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - #endregion position - #region rotation + #endregion position + #region rotation else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab { @@ -2062,11 +2068,12 @@ namespace OpenSim.Region.ClientStack LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); - OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); + OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, + this); } } - #endregion - #region scale + #endregion + #region scale else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab { @@ -2118,9 +2125,9 @@ namespace OpenSim.Region.ClientStack else { // It's a ghost! tell the client to delete it from view. - simClient.SendKillObject(this.Scene.RegionInfo.RegionHandle, multipleupdate.ObjectData[i].ObjectLocalID); + simClient.SendKillObject(Scene.RegionInfo.RegionHandle, + multipleupdate.ObjectData[i].ObjectLocalID); } - } } return true; @@ -2173,10 +2180,12 @@ namespace OpenSim.Region.ClientStack this.OutPacket(mbReply, ThrottleOutPacketType.Land); */ } + public void SetChildAgentThrottle(byte[] throttles) { m_packetQueue.SetThrottleFromClient(throttles); } + // Previously ClientView.m_packetQueue // A thread safe sequence number allocator. @@ -2198,7 +2207,7 @@ namespace OpenSim.Region.ClientStack } return seq; } - + protected void AddAck(Packet Pack) { lock (m_needAck) @@ -2236,13 +2245,13 @@ namespace OpenSim.Region.ClientStack { Pack.Header.AckList = new uint[m_pendingAcks.Count]; int i = 0; - + foreach (uint ack in m_pendingAcks.Values) { Pack.Header.AckList[i] = ack; i++; } - + m_pendingAcks.Clear(); Pack.Header.AppendedAcks = true; } @@ -2272,22 +2281,22 @@ namespace OpenSim.Region.ClientStack // Actually make the byte array and send it try { - byte[] sendbuffer = Pack.ToBytes(); - if (Pack is RegionHandshakePacket) - { - PacketPool.Instance.ReturnPacket(Pack); - } - - if (Pack.Header.Zerocoded) - { - byte[] ZeroOutBuffer = new byte[4096]; - int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); - } - else - { - m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); - } + byte[] sendbuffer = Pack.ToBytes(); + if (Pack is RegionHandshakePacket) + { + PacketPool.Instance.ReturnPacket(Pack); + } + + if (Pack.Header.Zerocoded) + { + byte[] ZeroOutBuffer = new byte[4096]; + int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); + m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); + } + else + { + m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); + } } catch (Exception e) { @@ -2298,7 +2307,7 @@ namespace OpenSim.Region.ClientStack Close(true); } } - + public virtual void InPacket(Packet NewPack) { // Handle appended ACKs @@ -2314,7 +2323,7 @@ namespace OpenSim.Region.ClientStack } } } - + // Handle PacketAck packets if (NewPack.Type == PacketType.PacketAck) @@ -2353,7 +2362,7 @@ namespace OpenSim.Region.ClientStack item.Packet = NewPack; item.Incoming = false; item.throttleType = throttlePacketType; // Packet throttle type - m_packetQueue.Enqueue(item); + m_packetQueue.Enqueue(item); } # region Low Level Packet Methods @@ -2392,7 +2401,7 @@ namespace OpenSim.Region.ClientStack if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) { MainLog.Instance.Verbose("NETWORK", "Resending " + packet.Type.ToString() + " packet, " + - (now - packet.TickCount) + "ms have passed"); + (now - packet.TickCount) + "ms have passed"); packet.Header.Resent = true; OutPacket(packet, ThrottleOutPacketType.Resend); @@ -2442,6 +2451,7 @@ namespace OpenSim.Region.ClientStack } #endregion + // Previously ClientView.ProcessPackets public bool AddMoney(int debit) @@ -2539,12 +2549,13 @@ namespace OpenSim.Region.ClientStack { if (OnModifyTerrain != null) { - for (int i=0; i < modify.ParcelData.Length; i++) + for (int i = 0; i < modify.ParcelData.Length; i++) { OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, modify.ModifyBlock.Action, modify.ParcelData[i].North, - modify.ParcelData[i].West, modify.ParcelData[i].South, modify.ParcelData[i].East, this); + modify.ParcelData[i].West, modify.ParcelData[i].South, + modify.ParcelData[i].East, this); } } } @@ -2558,7 +2569,7 @@ namespace OpenSim.Region.ClientStack case PacketType.AgentWearablesRequest: if (OnRequestWearables != null) { - OnRequestWearables( ); + OnRequestWearables(); } if (OnRequestAvatarsData != null) { @@ -2575,21 +2586,23 @@ namespace OpenSim.Region.ClientStack case PacketType.AgentIsNowWearing: if (OnAvatarNowWearing != null) { - AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack; + AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket) Pack; AvatarWearingArgs wearingArgs = new AvatarWearingArgs(); for (int i = 0; i < nowWearing.WearableData.Length; i++) { - AvatarWearingArgs.Wearable wearable = new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, nowWearing.WearableData[i].WearableType); + AvatarWearingArgs.Wearable wearable = + new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, + nowWearing.WearableData[i].WearableType); wearingArgs.NowWearing.Add(wearable); } OnAvatarNowWearing(this, wearingArgs); } break; case PacketType.SetAlwaysRun: - SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; + SetAlwaysRunPacket run = (SetAlwaysRunPacket) Pack; if (OnSetAlwaysRun != null) - OnSetAlwaysRun(this,run.AgentData.AlwaysRun); + OnSetAlwaysRun(this, run.AgentData.AlwaysRun); break; case PacketType.CompleteAgentMovement: @@ -2603,7 +2616,8 @@ namespace OpenSim.Region.ClientStack { AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; - OnAgentUpdate(this, agenUpdate); //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); + OnAgentUpdate(this, agenUpdate); + //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); } break; case PacketType.AgentAnimation: @@ -2642,15 +2656,17 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.AvatarPickerRequest: - AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; - AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; - AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; - //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); + AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket) Pack; + AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; + AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; + //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); if (OnAvatarPickerRequest != null) { - OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, Helpers.FieldToUTF8String(querydata.Name)); + OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, + Helpers.FieldToUTF8String(querydata.Name)); } break; + #endregion #region Objects/m_sceneObjects @@ -2675,7 +2691,7 @@ namespace OpenSim.Region.ClientStack break; case PacketType.ObjectDelink: ObjectDelinkPacket delink = (ObjectDelinkPacket) Pack; - + // It appears the prim at index 0 is not always the root prim (for // instance, when one prim of a link set has been edited independently // of the others). Therefore, we'll pass all the ids onto the delink @@ -2683,11 +2699,11 @@ namespace OpenSim.Region.ClientStack List<uint> prims = new List<uint>(); for (int i = 0; i < delink.ObjectData.Length; i++) { - prims.Add(delink.ObjectData[i].ObjectLocalID); + prims.Add(delink.ObjectData[i].ObjectLocalID); } - + if (OnDelinkObjects != null) - { + { OnDelinkObjects(prims); } @@ -2706,7 +2722,8 @@ namespace OpenSim.Region.ClientStack { if (OnUpdatePrimShape != null) { - OnUpdatePrimShape(this.m_agentId, shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); + OnUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID, + shapePacket.ObjectData[i]); } } break; @@ -2714,7 +2731,8 @@ namespace OpenSim.Region.ClientStack ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack; if (OnUpdateExtraParams != null) { - OnUpdateExtraParams(this.m_agentId, extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, + OnUpdateExtraParams(m_agentId, extraPar.ObjectData[0].ObjectLocalID, + extraPar.ObjectData[0].ParamType, extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); } break; @@ -2726,7 +2744,8 @@ namespace OpenSim.Region.ClientStack if (OnObjectDuplicate != null) { OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, - dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, AgentandGroupData.GroupID); + dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, + AgentandGroupData.GroupID); } } @@ -2809,21 +2828,23 @@ namespace OpenSim.Region.ClientStack { if (OnObjectName != null) { - OnObjectName(this, objName.ObjectData[i].LocalID, m_encoding.GetString(objName.ObjectData[i].Name)); + OnObjectName(this, objName.ObjectData[i].LocalID, + m_encoding.GetString(objName.ObjectData[i].Name)); } } break; case PacketType.ObjectPermissions: MainLog.Instance.Warn("CLIENT", "unhandled packet " + PacketType.ObjectPermissions.ToString()); - ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; + ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket) Pack; + + List<ObjectPermissionsPacket.ObjectDataBlock> permChanges = + new List<ObjectPermissionsPacket.ObjectDataBlock>(); - List<ObjectPermissionsPacket.ObjectDataBlock> permChanges = new List<ObjectPermissionsPacket.ObjectDataBlock>(); - for (int i = 0; i < newobjPerms.ObjectData.Length; i++) { permChanges.Add(newobjPerms.ObjectData[i]); } - + // Here's our data, // PermField contains the field the info goes into // PermField determines which mask we're changing @@ -2847,16 +2868,15 @@ namespace OpenSim.Region.ClientStack case PacketType.RequestObjectPropertiesFamily: //This powers the little tooltip that appears when you move your mouse over an object - RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; - + RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket) Pack; + RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; if (OnRequestObjectPropertiesFamily != null) { - OnRequestObjectPropertiesFamily(this, this.m_agentId, packObjBlock.RequestFlags, packObjBlock.ObjectID); - - + OnRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags, + packObjBlock.ObjectID); } break; @@ -2882,7 +2902,7 @@ namespace OpenSim.Region.ClientStack OnRequestTexture(this, args); } - // m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, + // m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, // imageRequest.RequestImage[i].Packet, // imageRequest.RequestImage[i].DiscardLevel); } @@ -2898,10 +2918,11 @@ namespace OpenSim.Region.ClientStack // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); if (OnAssetUploadRequest != null) { - LLUUID temp=libsecondlife.LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); + LLUUID temp = LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); OnAssetUploadRequest(this, temp, request.AssetBlock.TransactionID, request.AssetBlock.Type, - request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, request.AssetBlock.Tempfile); + request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, + request.AssetBlock.Tempfile); } break; case PacketType.RequestXfer: @@ -2938,24 +2959,24 @@ namespace OpenSim.Region.ClientStack case PacketType.UpdateInventoryFolder: if (OnUpdateInventoryFolder != null) { - UpdateInventoryFolderPacket invFolder = (UpdateInventoryFolderPacket)Pack; + UpdateInventoryFolderPacket invFolder = (UpdateInventoryFolderPacket) Pack; for (int i = 0; i < invFolder.FolderData.Length; i++) { OnUpdateInventoryFolder(this, invFolder.FolderData[i].FolderID, - (ushort)invFolder.FolderData[i].Type, - Util.FieldToString(invFolder.FolderData[i].Name), - invFolder.FolderData[i].ParentID); + (ushort) invFolder.FolderData[i].Type, + Util.FieldToString(invFolder.FolderData[i].Name), + invFolder.FolderData[i].ParentID); } } break; case PacketType.MoveInventoryFolder: if (OnMoveInventoryFolder != null) { - MoveInventoryFolderPacket invFolder = (MoveInventoryFolderPacket)Pack; + MoveInventoryFolderPacket invFolder = (MoveInventoryFolderPacket) Pack; for (int i = 0; i < invFolder.InventoryData.Length; i++) { OnMoveInventoryFolder(this, invFolder.InventoryData[i].FolderID, - invFolder.InventoryData[i].ParentID); + invFolder.InventoryData[i].ParentID); } } break; @@ -2997,7 +3018,7 @@ namespace OpenSim.Region.ClientStack case PacketType.PurgeInventoryDescendents: if (OnPurgeInventoryDescendents != null) { - PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; + PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket) Pack; OnPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); } break; @@ -3007,11 +3028,11 @@ namespace OpenSim.Region.ClientStack { for (int i = 0; i < update.InventoryData.Length; i++) { - OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, + OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, update.InventoryData[i].ItemID, - Util.FieldToString(update.InventoryData[i].Name), + Util.FieldToString(update.InventoryData[i].Name), Util.FieldToString(update.InventoryData[i].Description), - update.InventoryData[i].NextOwnerMask); + update.InventoryData[i].NextOwnerMask); } } //Console.WriteLine(Pack.ToString()); @@ -3051,17 +3072,20 @@ namespace OpenSim.Region.ClientStack { foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) { - OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, datablock.OldItemID, datablock.NewFolderID, Util.FieldToString(datablock.NewName)); + OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, + datablock.OldItemID, datablock.NewFolderID, + Util.FieldToString(datablock.NewName)); } } break; case PacketType.MoveInventoryItem: - MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; + MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket) Pack; if (OnMoveInventoryItem != null) { foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) { - OnMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, Util.FieldToString(datablock.NewName)); + OnMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, + Util.FieldToString(datablock.NewName)); } } break; @@ -3115,7 +3139,7 @@ namespace OpenSim.Region.ClientStack case PacketType.MapNameRequest: MapNameRequestPacket map = (MapNameRequestPacket) Pack; string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0, - map.NameData.Name.Length - 1); + map.NameData.Name.Length - 1); if (OnMapNameRequest != null) { OnMapNameRequest(this, mapName); @@ -3202,29 +3226,34 @@ namespace OpenSim.Region.ClientStack break; #region Parcel related packets + case PacketType.ParcelAccessListRequest: - ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; + ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket) Pack; if (OnParcelAccessListRequest != null) { - OnParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, requestPacket.Data.Flags, requestPacket.Data.SequenceID, requestPacket.Data.LocalID,this); + OnParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, + requestPacket.Data.Flags, requestPacket.Data.SequenceID, + requestPacket.Data.LocalID, this); } - break; + break; case PacketType.ParcelAccessListUpdate: - ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; + ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket) Pack; List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>(); foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = block.ID; - entry.Flags = (ParcelManager.AccessList)block.Flags; + entry.Flags = (ParcelManager.AccessList) block.Flags; entry.Time = new DateTime(); entries.Add(entry); } if (OnParcelAccessListUpdateRequest != null) { - OnParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, updatePacket.AgentData.SessionID, updatePacket.Data.Flags, updatePacket.Data.LocalID, entries, this); + OnParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, + updatePacket.AgentData.SessionID, updatePacket.Data.Flags, + updatePacket.Data.LocalID, entries, this); } break; case PacketType.ParcelPropertiesRequest: @@ -3296,28 +3325,30 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.RequestRegionInfo: - RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; - if (OnRegionInfoRequest != null) + RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket) Pack).AgentData; + if (OnRegionInfoRequest != null) { OnRegionInfoRequest(this, mPacket.SessionID); } break; case PacketType.EstateCovenantRequest: // TODO: handle this packet - EstateCovenantRequestPacket.AgentDataBlock epack = ((EstateCovenantRequestPacket)Pack).AgentData; + EstateCovenantRequestPacket.AgentDataBlock epack = + ((EstateCovenantRequestPacket) Pack).AgentData; if (OnEstateCovenantRequest != null) { OnEstateCovenantRequest(this, epack.SessionID); } break; case PacketType.AgentThrottle: - AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; + AgentThrottlePacket atpack = (AgentThrottlePacket) Pack; m_packetQueue.SetThrottleFromClient(atpack.Throttle.Throttles); break; #endregion #region unimplemented handlers + case PacketType.RequestGodlikePowers: RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket) Pack; RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; @@ -3325,16 +3356,17 @@ namespace OpenSim.Region.ClientStack RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; OnRequestGodlikePowers(ablock.AgentID, ablock.SessionID, token, this); - + break; case PacketType.GodKickUser: MainLog.Instance.Warn("CLIENT", "unhandled GodKickUser packet"); - + GodKickUserPacket gkupack = (GodKickUserPacket) Pack; - - if (gkupack.UserInfo.GodSessionID == SessionId && this.AgentId == gkupack.UserInfo.GodID) + + if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) { - OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); + OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, + gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); } else { @@ -3404,7 +3436,7 @@ namespace OpenSim.Region.ClientStack // TODO: handle this packet MainLog.Instance.Warn("CLIENT", "unhandled AgentDataUpdateRequest packet"); break; - + case PacketType.ParcelDwellRequest: // TODO: handle this packet MainLog.Instance.Warn("CLIENT", "unhandled ParcelDwellRequest packet"); @@ -3440,7 +3472,7 @@ namespace OpenSim.Region.ClientStack default: MainLog.Instance.Warn("CLIENT", "unhandled packet " + Pack.ToString()); break; - + #endregion } } @@ -3490,4 +3522,4 @@ namespace OpenSim.Region.ClientStack OutPacket(logReply, ThrottleOutPacketType.Task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs index 4c9295e..1065f63 100644 --- a/OpenSim/Region/ClientStack/PacketQueue.cs +++ b/OpenSim/Region/ClientStack/PacketQueue.cs @@ -27,17 +27,10 @@ */ using System; using System.Collections.Generic; -using System.Net; -using System.Net.Sockets; -using System.Text; using System.Threading; using System.Timers; -using Axiom.Math; -using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack @@ -47,7 +40,7 @@ namespace OpenSim.Region.ClientStack private bool m_enabled = true; private BlockingQueue<QueItem> SendQueue; - + private Queue<QueItem> IncomingPacketQueue; private Queue<QueItem> OutgoingPacketQueue; private Queue<QueItem> ResendOutgoingPacketQueue; @@ -57,7 +50,7 @@ namespace OpenSim.Region.ClientStack private Queue<QueItem> TaskOutgoingPacketQueue; private Queue<QueItem> TextureOutgoingPacketQueue; private Queue<QueItem> AssetOutgoingPacketQueue; - + private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); @@ -82,15 +75,15 @@ namespace OpenSim.Region.ClientStack // private long ThrottleInterval; private Timer throttleTimer; - public PacketQueue() + public PacketQueue() { // While working on this, the BlockingQueue had me fooled for a bit. // The Blocking queue causes the thread to stop until there's something // in it to process. it's an on-purpose threadlock though because // without it, the clientloop will suck up all sim resources. - + SendQueue = new BlockingQueue<QueItem>(); - + IncomingPacketQueue = new Queue<QueItem>(); OutgoingPacketQueue = new Queue<QueItem>(); ResendOutgoingPacketQueue = new Queue<QueItem>(); @@ -100,7 +93,7 @@ namespace OpenSim.Region.ClientStack TaskOutgoingPacketQueue = new Queue<QueItem>(); TextureOutgoingPacketQueue = new Queue<QueItem>(); AssetOutgoingPacketQueue = new Queue<QueItem>(); - + // Set up the throttle classes (min, max, current) in bytes ResendThrottle = new PacketThrottle(5000, 100000, 50000); @@ -114,14 +107,13 @@ namespace OpenSim.Region.ClientStack // Number of bytes allowed to go out per second. (256kbps per client) TotalThrottle = new PacketThrottle(0, 162144, 1536000); - throttleTimer = new Timer((int)(throttletimems/throttleTimeDivisor)); + throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor)); throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed); throttleTimer.Start(); - + // TIMERS needed for this // LastThrottle = DateTime.Now.Ticks; // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); - } /* STANDARD QUEUE MANIPULATION INTERFACES */ @@ -129,44 +121,48 @@ namespace OpenSim.Region.ClientStack public void Enqueue(QueItem item) { - if (!m_enabled) {return;} + if (!m_enabled) + { + return; + } // We could micro lock, but that will tend to actually // probably be worse than just synchronizing on SendQueue - lock (this) { + lock (this) + { switch (item.throttleType) { - case ThrottleOutPacketType.Resend: - ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Texture: - ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Task: - ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Land: - ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Asset: - ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Cloud: - ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Wind: - ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); - break; - - default: - // Acknowledgements and other such stuff should go directly to the blocking Queue - // Throttling them may and likely 'will' be problematic - SendQueue.Enqueue(item); - break; + case ThrottleOutPacketType.Resend: + ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Texture: + ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Task: + ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Land: + ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Asset: + ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Cloud: + ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Wind: + ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); + break; + + default: + // Acknowledgements and other such stuff should go directly to the blocking Queue + // Throttling them may and likely 'will' be problematic + SendQueue.Enqueue(item); + break; } } } - + public QueItem Dequeue() { return SendQueue.Dequeue(); @@ -174,7 +170,8 @@ namespace OpenSim.Region.ClientStack public void Flush() { - lock(this) { + lock (this) + { while (PacketsWaiting()) { //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. @@ -211,7 +208,7 @@ namespace OpenSim.Region.ClientStack } } - public void Close() + public void Close() { m_enabled = false; throttleTimer.Stop(); @@ -242,22 +239,22 @@ namespace OpenSim.Region.ClientStack public void ProcessThrottle() { - // I was considering this.. Will an event fire if the thread it's on is blocked? - + // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long // The General overhead of the UDP protocol gets sent to the queue un-throttled by this // so This'll pick up about around the right time. - + int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. int throttleLoops = 0; - + // We're going to dequeue all of the saved up packets until // we've hit the throttle limit or there's no more packets to send - lock (this) { + lock (this) + { ResetCounters(); // MainLog.Instance.Verbose("THROTTLE", "Entering Throttle"); - while (TotalThrottle.UnderLimit() && PacketsWaiting() && + while (TotalThrottle.UnderLimit() && PacketsWaiting() && (throttleLoops <= MaxThrottleLoops)) { throttleLoops++; @@ -265,7 +262,7 @@ namespace OpenSim.Region.ClientStack if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) { QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); ResendThrottle.Add(qpack.Packet.ToBytes().Length); @@ -273,7 +270,7 @@ namespace OpenSim.Region.ClientStack if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) { QueItem qpack = LandOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); LandThrottle.Add(qpack.Packet.ToBytes().Length); @@ -281,7 +278,7 @@ namespace OpenSim.Region.ClientStack if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) { QueItem qpack = WindOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); WindThrottle.Add(qpack.Packet.ToBytes().Length); @@ -289,7 +286,7 @@ namespace OpenSim.Region.ClientStack if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) { QueItem qpack = CloudOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); CloudThrottle.Add(qpack.Packet.ToBytes().Length); @@ -297,7 +294,7 @@ namespace OpenSim.Region.ClientStack if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0) { QueItem qpack = TaskOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); TaskThrottle.Add(qpack.Packet.ToBytes().Length); @@ -305,7 +302,7 @@ namespace OpenSim.Region.ClientStack if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) { QueItem qpack = TextureOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); TextureThrottle.Add(qpack.Packet.ToBytes().Length); @@ -313,19 +310,18 @@ namespace OpenSim.Region.ClientStack if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) { QueItem qpack = AssetOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); AssetThrottle.Add(qpack.Packet.ToBytes().Length); } } // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets"); - } } - + private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) - { + { // just to change the signature, and that ProcessThrottle // will be used elsewhere possibly ProcessThrottle(); @@ -339,7 +335,7 @@ namespace OpenSim.Region.ClientStack // wait for the timer to fire to put things into the // output queue - if((q.Count == 0) && (throttle.UnderLimit())) + if ((q.Count == 0) && (throttle.UnderLimit())) { Monitor.Enter(this); throttle.Add(item.Packet.ToBytes().Length); @@ -357,31 +353,39 @@ namespace OpenSim.Region.ClientStack private int ScaleThrottle(int value, int curmax, int newmax) { - return (int)(((float)value/(float)curmax) * newmax); + return (int) (((float) value/(float) curmax)*newmax); } + private byte[] GetThrottlesPacked(float multiplier) { int singlefloat = 4; - float tResend = ResendThrottle.Throttle * multiplier; - float tLand = LandThrottle.Throttle * multiplier; - float tWind = WindThrottle.Throttle * multiplier; - float tCloud = CloudThrottle.Throttle * multiplier; - float tTask = TaskThrottle.Throttle * multiplier; - float tTexture = TextureThrottle.Throttle * multiplier; - float tAsset = AssetThrottle.Throttle * multiplier; - - byte[] throttles = new byte[singlefloat * 7]; + float tResend = ResendThrottle.Throttle*multiplier; + float tLand = LandThrottle.Throttle*multiplier; + float tWind = WindThrottle.Throttle*multiplier; + float tCloud = CloudThrottle.Throttle*multiplier; + float tTask = TaskThrottle.Throttle*multiplier; + float tTexture = TextureThrottle.Throttle*multiplier; + float tAsset = AssetThrottle.Throttle*multiplier; + + byte[] throttles = new byte[singlefloat*7]; int i = 0; - Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat * i, singlefloat); + Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat*i, singlefloat); return throttles; } + public void SetThrottleFromClient(byte[] throttle) { int tResend = -1; @@ -401,25 +405,25 @@ namespace OpenSim.Region.ClientStack // it might be smart to do this check more often... if (!BitConverter.IsLittleEndian) for (int i = 0; i < 7; i++) - Array.Reverse(throttle, j + i * singlefloat, singlefloat); - + Array.Reverse(throttle, j + i*singlefloat, singlefloat); + // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_ // bytes // Convert to integer, since.. the full fp space isn't used. - tResend = (int)BitConverter.ToSingle(throttle, j); + tResend = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tLand = (int)BitConverter.ToSingle(throttle, j); + tLand = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tWind = (int)BitConverter.ToSingle(throttle, j); + tWind = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tCloud = (int)BitConverter.ToSingle(throttle, j); + tCloud = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tTask = (int)BitConverter.ToSingle(throttle, j); + tTask = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tTexture = (int)BitConverter.ToSingle(throttle, j); + tTexture = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tAsset = (int)BitConverter.ToSingle(throttle, j); - + tAsset = (int) BitConverter.ToSingle(throttle, j); + tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; /* MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend + @@ -431,13 +435,13 @@ namespace OpenSim.Region.ClientStack " Assetbytes=" + tAsset + " Allbytes=" + tall); */ - + // Total Sanity // Make sure that the client sent sane total values. - + // If the client didn't send acceptable values.... // Scale the clients values down until they are acceptable. - + if (tall <= TotalThrottle.Max) { ResendThrottle.Throttle = tResend; @@ -448,7 +452,7 @@ namespace OpenSim.Region.ClientStack TextureThrottle.Throttle = tTexture; AssetThrottle.Throttle = tAsset; TotalThrottle.Throttle = tall; - } + } else if (tall < 1) { // client is stupid, penalize him by minning everything @@ -478,4 +482,4 @@ namespace OpenSim.Region.ClientStack ResetCounters(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index a232db8..7e01adf 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -68,10 +68,11 @@ namespace OpenSim.Region.ClientStack protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, - PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) + PacketServer packServer, AgentCircuitManager authenSessions, + LLUUID agentId, LLUUID sessionId, uint circuitCode) { return - new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode ); + new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode); } public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, @@ -86,7 +87,8 @@ namespace OpenSim.Region.ClientStack else { newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, - authenticateSessionsClass, useCircuit.CircuitCode.ID, useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code); + authenticateSessionsClass, useCircuit.CircuitCode.ID, + useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code); m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); @@ -123,9 +125,8 @@ namespace OpenSim.Region.ClientStack /// <param name="circuitcode"></param> public virtual void CloseCircuit(uint circuitcode) { - m_networkHandler.RemoveClientCircuit(circuitcode); - + //m_scene.ClientManager.CloseAllAgents(circuitcode); } @@ -135,4 +136,4 @@ namespace OpenSim.Region.ClientStack client.Close(false); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketThrottle.cs b/OpenSim/Region/ClientStack/PacketThrottle.cs index f9a5c09..f56f4f8 100644 --- a/OpenSim/Region/ClientStack/PacketThrottle.cs +++ b/OpenSim/Region/ClientStack/PacketThrottle.cs @@ -25,26 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; -using System.Timers; -using Axiom.Math; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; -using Timer=System.Timers.Timer; - namespace OpenSim.Region.ClientStack { public class PacketThrottle { - private int max; // max allowable throttle private int min; // min allowable throttle private int throttle; // current throttle setting @@ -63,10 +47,10 @@ namespace OpenSim.Region.ClientStack { sent = 0; } - + public bool UnderLimit() { - return (sent < (throttle / divisor)); + return (sent < (throttle/divisor)); } public int Add(int bytes) @@ -78,27 +62,32 @@ namespace OpenSim.Region.ClientStack // Properties public int Max { - get {return max;} + get { return max; } } public int Min { - get {return min;} + get { return min; } } - + public int Throttle { - get {return throttle;} - set + get { return throttle; } + set { - if (value > max) { + if (value > max) + { throttle = max; - } else if (value < min) { + } + else if (value < min) + { throttle = min; - } else { + } + else + { throttle = value; } } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/QueItem.cs b/OpenSim/Region/ClientStack/QueItem.cs index 23b1648..ea0f680 100644 --- a/OpenSim/Region/ClientStack/QueItem.cs +++ b/OpenSim/Region/ClientStack/QueItem.cs @@ -31,14 +31,14 @@ using OpenSim.Framework; namespace OpenSim.Region.ClientStack { - public class QueItem + public class QueItem + { + public QueItem() { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - public ThrottleOutPacketType throttleType; } -} + + public Packet Packet; + public bool Incoming; + public ThrottleOutPacketType throttleType; + } +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index f20b132..e9331e9 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Net; using libsecondlife; -using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; @@ -55,7 +54,7 @@ namespace OpenSim.Region.ClientStack protected CommunicationsManager m_commsManager; protected SceneManager m_sceneManager = new SceneManager(); - + protected StorageManager m_storageManager; protected string m_storageConnectionString; @@ -73,7 +72,7 @@ namespace OpenSim.Region.ClientStack { ClientView.TerrainManager = new TerrainManager(new SecondLife()); - m_storageManager = CreateStorageManager(m_storageConnectionString ); + m_storageManager = CreateStorageManager(m_storageConnectionString); Initialize(); @@ -142,7 +141,7 @@ namespace OpenSim.Region.ClientStack m_log.Verbose("PARCEL", "No master avatar found, using null."); scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; } - + scene.LoadPrimsFromStorage(m_permissions); scene.loadAllLandObjectsFromStorage(); scene.performParcelPrimCountUpdate(); @@ -153,4 +152,4 @@ namespace OpenSim.Region.ClientStack protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 47e0b3c..10435bf 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.Sockets; +using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -44,24 +45,22 @@ namespace OpenSim.Region.ClientStack { } - static readonly PacketPool instance = new PacketPool(); + private static readonly PacketPool instance = new PacketPool(); public static PacketPool Instance { - get - { - return instance; - } + get { return instance; } } private Hashtable pool = new Hashtable(); - public Packet GetPacket(PacketType type) { + public Packet GetPacket(PacketType type) + { Packet packet = null; - lock(pool) + lock (pool) { - if(pool[type] == null || ((Stack) pool[type]).Count == 0) + if (pool[type] == null || ((Stack) pool[type]).Count == 0) { // Creating a new packet if we cannot reuse an old package packet = Packet.BuildPacket(type); @@ -69,30 +68,33 @@ namespace OpenSim.Region.ClientStack else { // Recycle old packages - packet=(Packet) ((Stack) pool[type]).Pop(); + packet = (Packet) ((Stack) pool[type]).Pop(); } } return packet; } - public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer) { + public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer) + { Packet packet = GetPacket(GetType(bytes, packetEnd, zeroBuffer)); int i = 0; packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); return packet; } + public PacketType GetType(byte[] bytes, int packetEnd, byte[] zeroBuffer) { //Function removed from LibSL revision 1540 // We're using it.. so Built it into UDP server for now.. - ushort id; libsecondlife.PacketFrequency freq; + ushort id; + PacketFrequency freq; int i = 0, end = packetEnd; Header header = Header.BuildHeader(bytes, ref i, ref end); if (header.Zerocoded) { - end = libsecondlife.Helpers.ZeroDecode(bytes, end + 1, zeroBuffer) - 1; + end = Helpers.ZeroDecode(bytes, end + 1, zeroBuffer) - 1; bytes = zeroBuffer; } @@ -100,25 +102,30 @@ namespace OpenSim.Region.ClientStack { if (bytes[7] == 0xFF) { - id = (ushort)((bytes[8] << 8) + bytes[9]); freq = libsecondlife.PacketFrequency.Low; + id = (ushort) ((bytes[8] << 8) + bytes[9]); + freq = PacketFrequency.Low; } else { - id = (ushort)bytes[7]; freq = libsecondlife.PacketFrequency.Medium; + id = (ushort) bytes[7]; + freq = PacketFrequency.Medium; } } else { - id = (ushort)bytes[6]; freq = libsecondlife.PacketFrequency.High; + id = (ushort) bytes[6]; + freq = PacketFrequency.High; } return Packet.GetType(id, freq); } - public void ReturnPacket(Packet packet) { - lock(pool) + + public void ReturnPacket(Packet packet) + { + lock (pool) { - PacketType type=packet.Type; + PacketType type = packet.Type; - if(pool[type] == null) + if (pool[type] == null) { pool[type] = new Stack(); } @@ -162,15 +169,11 @@ namespace OpenSim.Region.ClientStack m_packetServer.LocalScene = m_localScene; m_regionHandle = m_localScene.RegionInfo.RegionHandle; } - } public ulong RegionHandle { - get - { - return m_regionHandle; - } + get { return m_regionHandle; } } public UDPServer() @@ -212,30 +215,29 @@ namespace OpenSim.Region.ClientStack case SocketError.AlreadyInProgress: case SocketError.NetworkReset: case SocketError.ConnectionReset: - + try { CloseEndPoint(epSender); } - catch (System.Exception a) + catch (Exception a) { MainLog.Instance.Verbose("UDPSERVER", a.ToString()); } try { - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, + ReceivedData, null); + // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. // so therefore.. we've got to tell the server to BeginReceiveFrom again. // This will happen over and over until we've gone through all packets // sent to and from this particular user. // Stupid I know.. // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. - } catch (SocketException) { - } break; default: @@ -243,13 +245,14 @@ namespace OpenSim.Region.ClientStack { CloseEndPoint(epSender); } - catch (System.Exception) + catch (Exception) { //MainLog.Instance.Verbose("UDPSERVER", a.ToString()); } try { - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, + ReceivedData, null); // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. // so therefore.. we've got to tell the server to BeginReceiveFrom again. @@ -257,17 +260,15 @@ namespace OpenSim.Region.ClientStack // sent to and from this particular user. // Stupid I know.. // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. - } catch (SocketException) { - } - + // Here's some reference code! :D // Shutdown and restart the UDP listener! hehe // Shiny - + //Server.Shutdown(SocketShutdown.Both); //CloseEndPoint(epSender); //ServerListener(); @@ -276,7 +277,7 @@ namespace OpenSim.Region.ClientStack return; } - catch (System.ObjectDisposedException) + catch (ObjectDisposedException) { //MainLog.Instance.Debug("UDPSERVER", e.ToString()); return; @@ -288,7 +289,7 @@ namespace OpenSim.Region.ClientStack { packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer); } - catch(Exception) + catch (Exception) { //MainLog.Instance.Debug("UDPSERVER", e.ToString()); } @@ -311,7 +312,6 @@ namespace OpenSim.Region.ClientStack } else { - // invalid client //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now //m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); @@ -326,9 +326,7 @@ namespace OpenSim.Region.ClientStack uint circuit; if (clientCircuits.TryGetValue(sender, out circuit)) { - m_packetServer.CloseCircuit(circuit); - } } @@ -381,14 +379,11 @@ namespace OpenSim.Region.ClientStack EndPoint sendto = null; if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) { - clientCircuits.Remove(sendto); - - + clientCircuits_reverse.Remove(circuitcode); - } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 937f7c4..575d9d5 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -50,4 +50,4 @@ namespace OpenSim.Region.Communications.Local m_interRegion = interRegionService; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index f6137f7..4dec884 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -29,8 +29,8 @@ using System.Collections; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; namespace OpenSim.Region.Communications.Local { @@ -50,21 +50,17 @@ namespace OpenSim.Region.Communications.Local public string gdebugRegionName { get { return _gdebugRegionName; } - set - { - _gdebugRegionName = value; - } + set { _gdebugRegionName = value; } } + public string _rdebugRegionName = ""; public string rdebugRegionName { get { return _rdebugRegionName; } - set - { - _rdebugRegionName = value; - } + set { _rdebugRegionName = value; } } + public LocalBackEndServices() { } @@ -85,7 +81,8 @@ namespace OpenSim.Region.Communications.Local RegionCommsListener regionHost = new RegionCommsListener(); if (m_regionListeners.ContainsKey(regionInfo.RegionHandle)) { - MainLog.Instance.Error("INTERREGION", "Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up."); + MainLog.Instance.Error("INTERREGION", + "Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up."); m_regionListeners.Remove(regionInfo.RegionHandle); } m_regionListeners.Add(regionInfo.RegionHandle, regionHost); @@ -195,7 +192,7 @@ namespace OpenSim.Region.Communications.Local return mapBlocks; } - + public virtual bool RegionUp(SearializableRegionInfo sregion, ulong regionhandle) { RegionInfo region = new RegionInfo(sregion); @@ -203,7 +200,7 @@ namespace OpenSim.Region.Communications.Local { return m_regionListeners[regionhandle].TriggerRegionUp(region); } - + return false; } @@ -224,7 +221,7 @@ namespace OpenSim.Region.Communications.Local // It never gets called. public virtual Dictionary<string, string> GetGridSettings() { - Dictionary<string,string> returnGridSettings = new Dictionary<string,string>(); + Dictionary<string, string> returnGridSettings = new Dictionary<string, string>(); lock (m_queuedGridSettings) { returnGridSettings = m_queuedGridSettings; @@ -237,7 +234,6 @@ namespace OpenSim.Region.Communications.Local public virtual void SetForcefulBanlistsDisallowed(ulong regionHandle) { m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE"); - } public bool TriggerRegionUp(RegionInfo region, ulong regionhandle) @@ -254,7 +250,7 @@ namespace OpenSim.Region.Communications.Local { if (m_regionListeners.ContainsKey(regionHandle)) { - return m_regionListeners[regionHandle].TriggerChildAgentUpdate(regionHandle,cAgentData); + return m_regionListeners[regionHandle].TriggerChildAgentUpdate(regionHandle, cAgentData); } return false; } @@ -282,7 +278,7 @@ namespace OpenSim.Region.Communications.Local return false; } - public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData) + public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData) { if (m_regionListeners.ContainsKey(regionHandle)) { @@ -291,6 +287,7 @@ namespace OpenSim.Region.Communications.Local } return false; } + /// <summary> /// /// </summary> @@ -308,6 +305,7 @@ namespace OpenSim.Region.Communications.Local } return false; } + public bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { if (m_regionListeners.ContainsKey(regionHandle)) @@ -322,7 +320,7 @@ namespace OpenSim.Region.Communications.Local { if (m_regionListeners.ContainsKey(regionHandle)) { - m_regionListeners[regionHandle].TriggerCloseAgentConnection(regionHandle, agentID); + m_regionListeners[regionHandle].TriggerCloseAgentConnection(regionHandle, agentID); } } @@ -334,6 +332,7 @@ namespace OpenSim.Region.Communications.Local } return false; } + public bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID) { if (m_regionListeners.ContainsKey(regionHandle)) @@ -415,14 +414,15 @@ namespace OpenSim.Region.Communications.Local { if (m_regionListeners.ContainsKey(regionHandle)) { - return m_regionListeners[regionHandle].TriggerExpectPrimCrossing(regionHandle, primID, position, isPhysical); + return + m_regionListeners[regionHandle].TriggerExpectPrimCrossing(regionHandle, primID, position, isPhysical); } return false; } public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) { - // MainLog.Instance.Verbose("INTER", rdebugRegionName + ":Local BackEnd: Other local region is sending child agent our way: " + agentData.firstname + " " + agentData.lastname); + // MainLog.Instance.Verbose("INTER", rdebugRegionName + ":Local BackEnd: Other local region is sending child agent our way: " + agentData.firstname + " " + agentData.lastname); if (m_regionListeners.ContainsKey(regionHandle)) { @@ -435,4 +435,4 @@ namespace OpenSim.Region.Communications.Local return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs index 08bd850..730c40f 100644 --- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs @@ -82,14 +82,14 @@ namespace OpenSim.Region.Communications.Local { DeleteItem(item); } - + /// <summary> /// Send the given inventory folder and its item contents back to the requester. /// </summary> /// <param name="userID"></param> /// <param name="folder"></param> private InventoryFolderImpl RequestInventoryFolder(LLUUID userID, InventoryFolderBase folder, - InventoryFolderInfo folderCallBack, + InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) { InventoryFolderImpl newFolder = new InventoryFolderImpl(folder); @@ -99,9 +99,9 @@ namespace OpenSim.Region.Communications.Local foreach (InventoryItemBase item in items) { itemCallBack(userID, item); - } - + } + return newFolder; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 2c08707..bf5f205 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.Communications.Local if (!authUsers) { //no current user account so make one - MainLog.Instance.Notice("LOGIN", "No user account found so creating a new one."); + MainLog.Instance.Notice("LOGIN", "No user account found so creating a new one."); m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); @@ -93,14 +93,14 @@ namespace OpenSim.Region.Communications.Local if (!authUsers) { //for now we will accept any password in sandbox mode - MainLog.Instance.Notice("LOGIN", "Authorising user (no actual password check)"); - + MainLog.Instance.Notice("LOGIN", "Authorising user (no actual password check)"); + return true; } else { MainLog.Instance.Notice( - "LOGIN", "Authenticating " + profile.username + " " + profile.surname); + "LOGIN", "Authenticating " + profile.username + " " + profile.surname); password = password.Remove(0, 3); //remove $1$ @@ -134,7 +134,7 @@ namespace OpenSim.Region.Communications.Local // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; theUser.currentAgent.currentRegion = reg.RegionID; theUser.currentAgent.currentHandle = reg.RegionHandle; - + LoginResponse.BuddyList buddyList = new LoginResponse.BuddyList(); buddyList.AddNewBuddy(new LoginResponse.BuddyList.BuddyInfo("11111111-1111-0000-0000-000100bba000")); response.BuddList = buddyList; @@ -157,7 +157,7 @@ namespace OpenSim.Region.Communications.Local } else { - MainLog.Instance.Warn("LOGIN", "Not found region " + currentRegion); + MainLog.Instance.Warn("LOGIN", "Not found region " + currentRegion); } } @@ -207,4 +207,4 @@ namespace OpenSim.Region.Communications.Local } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index d8c4b1d..6269565 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -27,6 +27,7 @@ */ using System; +using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.UserManagement; @@ -82,7 +83,7 @@ namespace OpenSim.Region.Communications.Local return profile; } - public override UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid) + public override UserProfileData SetupMasterUser(LLUUID uuid) { UserProfileData data = GetUserProfile(uuid); if (data == null) diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 2754c4e..8d52eeb 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -60,23 +60,17 @@ namespace OpenSim.Region.Communications.OGS1 public string gdebugRegionName { get { return _gdebugRegionName; } - set - { - _gdebugRegionName = value; - - } + set { _gdebugRegionName = value; } } + public string _rdebugRegionName = ""; public string rdebugRegionName { get { return _rdebugRegionName; } - set - { - _rdebugRegionName = value; - - } + set { _rdebugRegionName = value; } } + /// <summary> /// /// </summary> @@ -128,7 +122,7 @@ namespace OpenSim.Region.Communications.OGS1 // Process Response if (GridRespData.ContainsKey("error")) { - string errorstring = (string)GridRespData["error"]; + string errorstring = (string) GridRespData["error"]; MainLog.Instance.Error("Unable to connect to grid: " + errorstring); return null; } @@ -137,14 +131,12 @@ namespace OpenSim.Region.Communications.OGS1 m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); if (GridRespData.ContainsKey("allow_forceful_banlines")) { - - if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") + if ((string) GridRespData["allow_forceful_banlines"] != "TRUE") { //m_localBackend.SetForcefulBanlistsDisallowed(regionInfo.RegionHandle); m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE"); } } - } return m_localBackend.RegisterRegion(regionInfo); } @@ -153,6 +145,7 @@ namespace OpenSim.Region.Communications.OGS1 { return false; } + public virtual Dictionary<string, string> GetGridSettings() { Dictionary<string, string> returnGridSettings = new Dictionary<string, string>(); @@ -161,15 +154,15 @@ namespace OpenSim.Region.Communications.OGS1 foreach (string Dictkey in m_queuedGridSettings.Keys) { returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]); - } - + m_queuedGridSettings.Clear(); } return returnGridSettings; } + /// <summary> /// /// </summary> @@ -223,7 +216,7 @@ namespace OpenSim.Region.Communications.OGS1 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); - Hashtable responseData = (Hashtable)GridResp.Value; + Hashtable responseData = (Hashtable) GridResp.Value; if (responseData.ContainsKey("error")) { @@ -231,29 +224,30 @@ namespace OpenSim.Region.Communications.OGS1 return null; } - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string internalIpStr = (string)responseData["sim_ip"]; + uint regX = Convert.ToUInt32((string) responseData["region_locx"]); + uint regY = Convert.ToUInt32((string) responseData["region_locy"]); + string internalIpStr = (string) responseData["sim_ip"]; uint port = Convert.ToUInt32(responseData["sim_port"]); - string externalUri = (string)responseData["sim_uri"]; + string externalUri = (string) responseData["sim_uri"]; - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); string neighbourExternalUri = externalUri; regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; - regionInfo.RegionID = new LLUUID((string)responseData["region_UUID"]); - regionInfo.RegionName = (string)responseData["region_name"]; + regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); + regionInfo.RegionName = (string) responseData["region_name"]; if (requestData.ContainsKey("regionHandle")) { - m_remoteRegionInfoCache.Add(Convert.ToUInt64((string)requestData["regionHandle"]), regionInfo); + m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo); } return regionInfo; } + /// <summary> /// /// </summary> @@ -283,7 +277,7 @@ namespace OpenSim.Region.Communications.OGS1 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); - Hashtable responseData = (Hashtable)GridResp.Value; + Hashtable responseData = (Hashtable) GridResp.Value; if (responseData.ContainsKey("error")) { @@ -291,27 +285,29 @@ namespace OpenSim.Region.Communications.OGS1 return null; } - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string internalIpStr = (string)responseData["sim_ip"]; + uint regX = Convert.ToUInt32((string) responseData["region_locx"]); + uint regY = Convert.ToUInt32((string) responseData["region_locy"]); + string internalIpStr = (string) responseData["sim_ip"]; uint port = Convert.ToUInt32(responseData["sim_port"]); - string externalUri = (string)responseData["sim_uri"]; + string externalUri = (string) responseData["sim_uri"]; - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); string neighbourExternalUri = externalUri; regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; - regionInfo.RegionID = new LLUUID((string)responseData["region_UUID"]); - regionInfo.RegionName = (string)responseData["region_name"]; + regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); + regionInfo.RegionName = (string) responseData["region_name"]; m_remoteRegionInfoCache.Add(regionHandle, regionInfo); } - catch (System.Net.WebException) + catch (WebException) { - MainLog.Instance.Error("GRID", "Region lookup failed for: " + regionHandle.ToString() + " - Is the GridServer down?"); + MainLog.Instance.Error("GRID", + "Region lookup failed for: " + regionHandle.ToString() + + " - Is the GridServer down?"); return null; } } @@ -462,12 +458,7 @@ namespace OpenSim.Region.Communications.OGS1 return new XmlRpcResponse(); } - - - - - #region m_interRegion Comms /// <summary> @@ -510,8 +501,8 @@ namespace OpenSim.Region.Communications.OGS1 bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof (OGS1InterRegionRemoting), "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); @@ -525,7 +516,10 @@ namespace OpenSim.Region.Communications.OGS1 Console.WriteLine("remoting object not found"); } remObject = null; - MainLog.Instance.Verbose("INTER", gdebugRegionName + ": OGS1 tried to Update Child Agent data on outside region and got " + retValue.ToString()); + MainLog.Instance.Verbose("INTER", + gdebugRegionName + + ": OGS1 tried to Update Child Agent data on outside region and got " + + retValue.ToString()); return retValue; } @@ -534,35 +528,39 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (Exception e) { - MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } - } /// <summary> @@ -571,7 +569,6 @@ namespace OpenSim.Region.Communications.OGS1 /// <param name="regionHandle"></param> /// <param name="agentData"></param> /// <returns></returns> - public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) { RegionInfo regInfo = null; @@ -604,7 +601,10 @@ namespace OpenSim.Region.Communications.OGS1 Console.WriteLine("remoting object not found"); } remObject = null; - MainLog.Instance.Verbose("INTER", gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " + agentData.firstname + " " + agentData.lastname + " and got " + retValue.ToString()); + MainLog.Instance.Verbose("INTER", + gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " + + agentData.firstname + " " + agentData.lastname + " and got " + + retValue.ToString()); return retValue; } @@ -613,31 +613,36 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (Exception e) { - MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -656,7 +661,7 @@ namespace OpenSim.Region.Communications.OGS1 region = new SearializableRegionInfo(RequestNeighbourInfo(region.RegionHandle)); region.RemotingAddress = region.ExternalHostName; region.RemotingPort = NetworkServersInfo.RemotingListenerPort; - if (m_localBackend.RegionUp(region,regionhandle)) + if (m_localBackend.RegionUp(region, regionhandle)) { return true; } @@ -671,9 +676,11 @@ namespace OpenSim.Region.Communications.OGS1 bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof ( + OGS1InterRegionRemoting), + "tcp://" + + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); @@ -703,33 +710,39 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - Is this neighbor up?"); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + + " - Is this neighbor up?"); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - Is this neighbor up?"); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + + " - Is this neighbor up?"); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -737,25 +750,25 @@ namespace OpenSim.Region.Communications.OGS1 { // This line errors with a Null Reference Exception.. Why? @.@ //MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - // ":" + regInfo.RemotingPort + - //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); + // ":" + regInfo.RemotingPort + + //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); MainLog.Instance.Debug(e.ToString()); return false; } } + /// <summary> /// /// </summary> /// <param name="regionHandle"></param> /// <param name="agentData"></param> /// <returns></returns> - public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData) { RegionInfo regInfo = null; try { - if (m_localBackend.InformRegionOfPrimCrossing(regionHandle,primID, objData)) + if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData)) { return true; } @@ -775,7 +788,7 @@ namespace OpenSim.Region.Communications.OGS1 if (remObject != null) { - retValue = remObject.InformRegionOfPrimCrossing(regionHandle,primID.UUID, objData); + retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.UUID, objData); } else { @@ -791,35 +804,41 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (Exception e) { - MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } } + /// <summary> /// /// </summary> @@ -848,7 +867,9 @@ namespace OpenSim.Region.Communications.OGS1 "/InterRegions"); if (remObject != null) { - retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), isFlying); + retValue = + remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), + isFlying); } else { @@ -864,7 +885,8 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -873,6 +895,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool ExpectPrimCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isPhysical) { RegionInfo regInfo = null; @@ -887,14 +910,16 @@ namespace OpenSim.Region.Communications.OGS1 if (regInfo != null) { bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof (OGS1InterRegionRemoting), "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); if (remObject != null) { - retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), isPhysical); + retValue = + remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), + isPhysical); } else { @@ -910,7 +935,8 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -922,7 +948,6 @@ namespace OpenSim.Region.Communications.OGS1 public void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) { - } public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) @@ -934,6 +959,7 @@ namespace OpenSim.Region.Communications.OGS1 { return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId); } + #endregion #region Methods triggered by calls from external instances @@ -961,8 +987,9 @@ namespace OpenSim.Region.Communications.OGS1 public bool TriggerRegionUp(SearializableRegionInfo regionData, ulong regionhandle) { - - MainLog.Instance.Verbose("INTER", gdebugRegionName + "Incoming OGS1 RegionUpReport: " + "(" + regionData.RegionLocX + "," + regionData.RegionLocY + ")"); + MainLog.Instance.Verbose("INTER", + gdebugRegionName + "Incoming OGS1 RegionUpReport: " + "(" + regionData.RegionLocX + + "," + regionData.RegionLocY + ")"); try { @@ -975,6 +1002,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { MainLog.Instance.Verbose("INTER", "Incoming OGS1 Child Agent Data Update"); @@ -988,7 +1016,6 @@ namespace OpenSim.Region.Communications.OGS1 MainLog.Instance.Error("Remoting Error: Unable to connect to adjacent region.\n" + e.ToString()); return false; } - } /// <summary> @@ -1012,6 +1039,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + /// <summary> /// /// </summary> @@ -1031,6 +1059,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isPhysical) { try @@ -1048,4 +1077,4 @@ namespace OpenSim.Region.Communications.OGS1 #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs index 683c471..a0da07e 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs @@ -41,7 +41,7 @@ namespace OpenSim.Region.Communications.OGS1 public delegate bool PrimGroupArrival(ulong regionHandle, LLUUID primID, string objData); - public delegate bool RegionUp (SearializableRegionInfo region, ulong regionhandle); + public delegate bool RegionUp(SearializableRegionInfo region, ulong regionhandle); public delegate bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate childUpdate); @@ -81,7 +81,6 @@ namespace OpenSim.Region.Communications.OGS1 public bool RegionUp(SearializableRegionInfo sregion, ulong regionhandle) { - if (OnRegionUp != null) { return OnRegionUp(sregion, regionhandle); @@ -106,6 +105,7 @@ namespace OpenSim.Region.Communications.OGS1 } return false; } + public bool InformRegionPrim(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { if (OnPrimGroupNear != null) @@ -114,6 +114,7 @@ namespace OpenSim.Region.Communications.OGS1 } return false; } + public bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, string objData) { if (OnPrimGroupArrival != null) @@ -134,7 +135,8 @@ namespace OpenSim.Region.Communications.OGS1 { try { - return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, new AgentCircuitData(agentData)); + return + InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, new AgentCircuitData(agentData)); } catch (RemotingException e) { @@ -142,7 +144,8 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } - public bool RegionUp(SearializableRegionInfo region, ulong regionhandle) + + public bool RegionUp(SearializableRegionInfo region, ulong regionhandle) { try { @@ -155,25 +158,27 @@ namespace OpenSim.Region.Communications.OGS1 } } - public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) + public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { try { - return InterRegionSingleton.Instance.ChildAgentUpdate(regionHandle,cAgentData); + return InterRegionSingleton.Instance.ChildAgentUpdate(regionHandle, cAgentData); } catch (RemotingException e) { Console.WriteLine("Remoting Error: Unable to send Child agent update to remote region.\n" + e.ToString()); return false; } - } public bool ExpectAvatarCrossing(ulong regionHandle, Guid agentID, sLLVector3 position, bool isFlying) { try { - return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, new LLUUID(agentID), new LLVector3(position.x,position.y,position.z), isFlying); + return + InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, new LLUUID(agentID), + new LLVector3(position.x, position.y, position.z), + isFlying); } catch (RemotingException e) { @@ -181,20 +186,24 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool InformRegionPrim(ulong regionHandle, Guid SceneObjectGroupID, sLLVector3 position, bool isPhysical) { try { - return InterRegionSingleton.Instance.InformRegionPrim(regionHandle, new LLUUID(SceneObjectGroupID), new LLVector3(position.x,position.y,position.z), isPhysical); + return + InterRegionSingleton.Instance.InformRegionPrim(regionHandle, new LLUUID(SceneObjectGroupID), + new LLVector3(position.x, position.y, position.z), + isPhysical); } catch (RemotingException e) { Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); return false; } - } - public bool InformRegionOfPrimCrossing(ulong regionHandle,Guid primID, string objData) + + public bool InformRegionOfPrimCrossing(ulong regionHandle, Guid primID, string objData) { try { @@ -206,6 +215,5 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } - } } \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index 0fb083a..0d97074 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -29,10 +29,10 @@ using System; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Servers; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; namespace OpenSim.Region.Communications.OGS1 { @@ -51,7 +51,7 @@ namespace OpenSim.Region.Communications.OGS1 // See IInventoryServices public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) - { + { if (!m_RequestingInventory.ContainsKey(userID)) { InventoryRequest request = new InventoryRequest(userID, folderCallBack, itemCallBack); @@ -72,10 +72,10 @@ namespace OpenSim.Region.Communications.OGS1 try { MainLog.Instance.Verbose( - "INVENTORY", "Requesting inventory from {0}/GetInventory/ for user {1}", + "INVENTORY", "Requesting inventory from {0}/GetInventory/ for user {1}", _inventoryServerUrl, userID); - - RestObjectPosterResponse<InventoryCollection> requester + + RestObjectPosterResponse<InventoryCollection> requester = new RestObjectPosterResponse<InventoryCollection>(); requester.ResponseCallback = InventoryResponse; @@ -96,10 +96,10 @@ namespace OpenSim.Region.Communications.OGS1 LLUUID userID = response.UserID; if (m_RequestingInventory.ContainsKey(userID)) { - MainLog.Instance.Verbose("INVENTORY", - "Received inventory response for user {0} containing {1} folders and {2} items", + MainLog.Instance.Verbose("INVENTORY", + "Received inventory response for user {0} containing {1} folders and {2} items", userID, response.Folders.Count, response.AllItems.Count); - + InventoryFolderImpl rootFolder = null; InventoryRequest request = m_RequestingInventory[userID]; foreach (InventoryFolderBase folder in response.Folders) @@ -133,8 +133,8 @@ namespace OpenSim.Region.Communications.OGS1 else { MainLog.Instance.Warn( - "INVENTORY", - "Received inventory response for {0} for which we do not have a record of requesting!", + "INVENTORY", + "Received inventory response for {0} for which we do not have a record of requesting!", userID); } } @@ -150,7 +150,7 @@ namespace OpenSim.Region.Communications.OGS1 SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>( "POST", _inventoryServerUrl + "/MoveFolder/", folder); } - + public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) { SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>( @@ -188,4 +188,4 @@ namespace OpenSim.Region.Communications.OGS1 } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index c1e6ba6..3a2e138 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -30,6 +30,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Net; +using System.Text.RegularExpressions; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework; @@ -50,7 +51,9 @@ namespace OpenSim.Region.Communications.OGS1 { if (data.Contains("error_type")) { - MainLog.Instance.Warn("GRID", "Error sent by user server when trying to get user profile: (" + data["error_type"] + + MainLog.Instance.Warn("GRID", + "Error sent by user server when trying to get user profile: (" + + data["error_type"] + "): " + data["error_desc"]); return null; } @@ -80,19 +83,19 @@ namespace OpenSim.Region.Communications.OGS1 return userData; } - public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(LLUUID queryID,Hashtable data) + public List<AvatarPickerAvatar> ConvertXMLRPCDataToAvatarPickerList(LLUUID queryID, Hashtable data) { List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); - int pickercount = Convert.ToInt32((string)data["avcount"]); - LLUUID respqueryID = new LLUUID((string)data["queryid"]); + int pickercount = Convert.ToInt32((string) data["avcount"]); + LLUUID respqueryID = new LLUUID((string) data["queryid"]); if (queryID == respqueryID) { for (int i = 0; i < pickercount; i++) { AvatarPickerAvatar apicker = new AvatarPickerAvatar(); - LLUUID avatarID = new LLUUID((string)data["avatarid" + i.ToString()]); - string firstname = (string)data["firstname" + i.ToString()]; - string lastname = (string)data["lastname" + i.ToString()]; + LLUUID avatarID = new LLUUID((string) data["avatarid" + i.ToString()]); + string firstname = (string) data["firstname" + i.ToString()]; + string lastname = (string) data["lastname" + i.ToString()]; apicker.AvatarID = avatarID; apicker.firstName = firstname; apicker.lastName = lastname; @@ -114,18 +117,18 @@ namespace OpenSim.Region.Communications.OGS1 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { List<AvatarPickerAvatar> pickerlist = new List<AvatarPickerAvatar>(); - System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 ]"); + Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]"); try { Hashtable param = new Hashtable(); - param["queryid"] = (string)queryID.ToString(); + param["queryid"] = (string) queryID.ToString(); param["avquery"] = objAlphaNumericPattern.Replace(query, ""); IList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters); XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); - Hashtable respData = (Hashtable)resp.Value; - pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID,respData); + Hashtable respData = (Hashtable) resp.Value; + pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData); } catch (WebException e) { @@ -196,7 +199,7 @@ namespace OpenSim.Region.Communications.OGS1 return profile; } - public UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid) + public UserProfileData SetupMasterUser(LLUUID uuid) { UserProfileData data = GetUserProfile(uuid); if (data == null) @@ -211,4 +214,4 @@ namespace OpenSim.Region.Communications.OGS1 throw new Exception("The method or operation is not implemented."); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 081a8cd..3ca9796 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -334,6 +334,7 @@ namespace OpenSim.Region.Environment } } } + private void estateRestartSim(EstateOwnerMessagePacket packet) { // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. @@ -341,26 +342,25 @@ namespace OpenSim.Region.Environment { float timeSeconds = 0; timeSeconds = BitConverter.ToInt16(block.Parameter, 1); - timeSeconds = (int)((timeSeconds / 100) - 3); + timeSeconds = (int) ((timeSeconds/100) - 3); m_scene.Restart(timeSeconds); - } } + private void EstateChangeCovenant(EstateOwnerMessagePacket packet) { foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) { LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter)); m_regInfo.CovenantID = newCovenantID; - } - } + public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID) { RegionInfoPacket rinfopack = new RegionInfoPacket(); RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock(); - + rinfoblk.BillableFactor = 0; rinfoblk.EstateID = 02; rinfoblk.MaxAgents = 100; @@ -369,20 +369,20 @@ namespace OpenSim.Region.Environment rinfoblk.PricePerMeter = 0; rinfoblk.RedirectGridX = 0; rinfoblk.RedirectGridY = 0; - rinfoblk.RegionFlags = (uint)m_regInfo.EstateSettings.regionFlags; - rinfoblk.SimAccess = (byte)m_regInfo.EstateSettings.simAccess; + rinfoblk.RegionFlags = (uint) m_regInfo.EstateSettings.regionFlags; + rinfoblk.SimAccess = (byte) m_regInfo.EstateSettings.simAccess; rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour; rinfoblk.TerrainLowerLimit = 20; rinfoblk.TerrainRaiseLimit = 20; rinfoblk.UseEstateSun = true; rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight; rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName); - + rinfopack.RegionInfo = rinfoblk; client.OutPacket(rinfopack, ThrottleOutPacketType.Task); - } + public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID) { EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket(); @@ -390,10 +390,12 @@ namespace OpenSim.Region.Environment edata.CovenantID = m_regInfo.CovenantID; edata.CovenantTimestamp = 0; edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID; - edata.EstateName = Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName); + edata.EstateName = + Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName); einfopack.Data = edata; client.OutPacket(einfopack, ThrottleOutPacketType.Task); } + #endregion #region Outgoing Packets @@ -451,4 +453,4 @@ namespace OpenSim.Region.Environment #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs index ee4d8bc..fb83150 100644 --- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs +++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs @@ -27,7 +27,6 @@ */ using libsecondlife; -using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Interfaces diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs index c974616..6aa8f35 100644 --- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs @@ -26,9 +26,9 @@ * */ +using System.Collections.Generic; using libsecondlife; using OpenSim.Region.Environment.Modules; -using System.Collections.Generic; namespace OpenSim.Region.Environment.Interfaces { diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 91aa5ff..78ad428 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -51,10 +52,10 @@ namespace OpenSim.Region.Environment.Interfaces void StoreTerrain(double[,] terrain, LLUUID regionID); double[,] LoadTerrain(LLUUID regionID); - void StoreLandObject(Land Parcel,LLUUID regionUUID); + void StoreLandObject(Land Parcel, LLUUID regionUUID); void RemoveLandObject(LLUUID globalID); - List<Framework.LandData> LoadLandObjects(LLUUID regionUUID); + List<LandData> LoadLandObjects(LLUUID regionUUID); void Shutdown(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 7977c78..ff16319 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -32,7 +32,6 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.LandManagement { @@ -98,7 +97,6 @@ namespace OpenSim.Region.Environment.LandManagement return newLand; } - #endregion #region Packet Request Handling @@ -202,7 +200,7 @@ namespace OpenSim.Region.Environment.LandManagement //Needs later group support LandData newData = landData.Copy(); newData.authBuyerID = packet.ParcelData.AuthBuyerID; - newData.category = (Parcel.ParcelCategory)packet.ParcelData.Category; + newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); newData.groupID = packet.ParcelData.GroupID; newData.landingType = packet.ParcelData.LandingType; @@ -222,8 +220,6 @@ namespace OpenSim.Region.Environment.LandManagement m_scene.LandManager.updateLandObject(landData.localID, newData); sendLandUpdateToAvatarsOverMe(); - - } } @@ -242,13 +238,13 @@ namespace OpenSim.Region.Environment.LandManagement public bool isBannedFromLand(LLUUID avatar) { - if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseBanList) > 0) + if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = avatar; entry.Flags = ParcelManager.AccessList.Ban; entry.Time = new DateTime(); - if (this.landData.parcelAccessList.Contains(entry)) + if (landData.parcelAccessList.Contains(entry)) { //They are banned, so lets send them a notice about this parcel return true; @@ -259,13 +255,13 @@ namespace OpenSim.Region.Environment.LandManagement public bool isRestrictedFromLand(LLUUID avatar) { - if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseAccessList) > 0) + if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = avatar; entry.Flags = ParcelManager.AccessList.Access; entry.Time = new DateTime(); - if (!this.landData.parcelAccessList.Contains(entry)) + if (!landData.parcelAccessList.Contains(entry)) { //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel return true; @@ -310,7 +306,7 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); - listBlock.Flags = (uint)0; + listBlock.Flags = (uint) 0; listBlock.ID = entry.AgentID; listBlock.Time = 0; @@ -322,7 +318,7 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); - listBlock.Flags = (uint)0; + listBlock.Flags = (uint) 0; listBlock.ID = LLUUID.Zero; listBlock.Time = 0; @@ -331,38 +327,37 @@ namespace OpenSim.Region.Environment.LandManagement return list.ToArray(); } - public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, IClientAPI remote_client) + public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, + IClientAPI remote_client) { - ParcelAccessListReplyPacket replyPacket; - if (flags == (uint)ParcelManager.AccessList.Access || flags == (uint)ParcelManager.AccessList.Both) + if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both) { replyPacket = new ParcelAccessListReplyPacket(); replyPacket.Data.AgentID = agentID; - replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Access; - replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access; + replyPacket.Data.LocalID = landData.localID; replyPacket.Data.SequenceID = 0; replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); - remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); } - if (flags == (uint)ParcelManager.AccessList.Ban || flags == (uint)ParcelManager.AccessList.Both) + if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) { replyPacket = new ParcelAccessListReplyPacket(); replyPacket.Data.AgentID = agentID; - replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Ban; - replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban; + replyPacket.Data.LocalID = landData.localID; replyPacket.Data.SequenceID = 0; replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); - remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); } - } - public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) + public void updateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) { LandData newData = landData.Copy(); @@ -370,11 +365,11 @@ namespace OpenSim.Region.Environment.LandManagement { entries.Clear(); } - + List<ParcelManager.ParcelAccessEntry> toRemove = new List<ParcelManager.ParcelAccessEntry>(); foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList) { - if (entry.Flags == (ParcelManager.AccessList)flags) + if (entry.Flags == (ParcelManager.AccessList) flags) { toRemove.Add(entry); } @@ -388,8 +383,8 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); temp.AgentID = entry.AgentID; - temp.Time = new DateTime() ; //Pointless? Yes. - temp.Flags = (ParcelManager.AccessList)flags; + temp.Time = new DateTime(); //Pointless? Yes. + temp.Flags = (ParcelManager.AccessList) flags; if (!newData.parcelAccessList.Contains(temp)) { @@ -398,7 +393,6 @@ namespace OpenSim.Region.Environment.LandManagement } m_scene.LandManager.updateLandObject(landData.localID, newData); - } #endregion @@ -437,7 +431,6 @@ namespace OpenSim.Region.Environment.LandManagement new LLVector3((float) (max_x*4), (float) (max_y*4), (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4))); landData.area = tempArea; - } public void updateLandBitmapByteArray() @@ -650,9 +643,9 @@ namespace OpenSim.Region.Environment.LandManagement { resultLocalIDs.Add(obj.LocalId); } - // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support - // { - // } + // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support + // { + // } else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.OwnerID != remote_client.AgentId) { @@ -732,10 +725,8 @@ namespace OpenSim.Region.Environment.LandManagement num++; } - + pack.Data = dataBlock; - - } remote_client.OutPacket(pack, ThrottleOutPacketType.Task); } diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index ecd458d..772fe2e 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -27,11 +27,13 @@ */ using System; using System.Collections.Generic; +using Axiom.Math; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.LandManagement { @@ -93,7 +95,7 @@ namespace OpenSim.Region.Environment.LandManagement private readonly RegionInfo m_regInfo; public bool allowedForcefulBans = true; - + #endregion #region Constructors @@ -103,14 +105,13 @@ namespace OpenSim.Region.Environment.LandManagement m_scene = scene; m_regInfo = reginfo; landIDList.Initialize(); - scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); - scene.EventManager.OnClientMovement += new EventManager.ClientMovement(this.handleAnyClientMovement); + scene.EventManager.OnAvatarEnteringNewParcel += + new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); + scene.EventManager.OnClientMovement += new EventManager.ClientMovement(handleAnyClientMovement); } - - #endregion - + #region Member Functions #region Land Object From Storage Functions @@ -147,7 +148,6 @@ namespace OpenSim.Region.Environment.LandManagement /// <returns></returns> public Land createBaseLand() { - return new Land(LLUUID.Zero, false, m_scene); } @@ -175,7 +175,7 @@ namespace OpenSim.Region.Environment.LandManagement } } landList[lastLandLocalID].forceUpdateLandInfo(); - m_scene.EventManager.TriggerLandObjectAdded(new_land,m_scene.RegionInfo.RegionID); + m_scene.EventManager.TriggerLandObjectAdded(new_land, m_scene.RegionInfo.RegionID); return new_land; } @@ -207,7 +207,7 @@ namespace OpenSim.Region.Environment.LandManagement if (landList.ContainsKey(local_id)) { landList[local_id].landData = newData.Copy(); - m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); + m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]); } else { @@ -335,7 +335,7 @@ namespace OpenSim.Region.Environment.LandManagement //Now add the new land object Land result = addLandObject(newLand); - updateLandObject(startLandObject.landData.localID,startLandObject.landData); + updateLandObject(startLandObject.landData.localID, startLandObject.landData); result.sendLandUpdateToAvatarsOverMe(); @@ -463,11 +463,11 @@ namespace OpenSim.Region.Environment.LandManagement Land southParcel = null; if (x > 0) { - westParcel = getLandObject((x - 1) * 4, y * 4); + westParcel = getLandObject((x - 1)*4, y*4); } if (y > 0) { - southParcel = getLandObject(x * 4, (y - 1) * 4); + southParcel = getLandObject(x*4, (y - 1)*4); } if (x == 0) @@ -496,14 +496,15 @@ namespace OpenSim.Region.Environment.LandManagement packet = new ParcelOverlayPacket(); packet.ParcelData.Data = byteArray; packet.ParcelData.SequenceID = sequenceID; - remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); sequenceID++; byteArray = new byte[LAND_BLOCKS_PER_PACKET]; } } - catch (System.Exception e) + catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Debug("LAND", "Skipped Land checks because avatar is out of bounds: " + e.Message); + MainLog.Instance.Debug("LAND", + "Skipped Land checks because avatar is out of bounds: " + e.Message); } } } @@ -599,7 +600,6 @@ namespace OpenSim.Region.Environment.LandManagement public List<Land> parcelsNearPoint(LLVector3 position) { - List<Land> parcelsNear = new List<Land>(); int x, y; for (x = -4; x <= 4; x += 4) @@ -617,22 +617,25 @@ namespace OpenSim.Region.Environment.LandManagement } } - return parcelsNear; - + return parcelsNear; } public void sendYouAreBannedNotice(ScenePresence avatar) { if (allowedForcefulBans) { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); - avatar.PhysicsActor.Position = new OpenSim.Region.Physics.Manager.PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, avatar.lastKnownAllowedPosition.z); - avatar.PhysicsActor.Velocity = new OpenSim.Region.Physics.Manager.PhysicsVector(0, 0, 0); + avatar.PhysicsActor.Position = + new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, + avatar.lastKnownAllowedPosition.z); + avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0); } else { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); } } @@ -651,7 +654,8 @@ namespace OpenSim.Region.Environment.LandManagement } else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); } else { @@ -668,7 +672,6 @@ namespace OpenSim.Region.Environment.LandManagement public void sendOutNearestBanLine(IClientAPI avatar) { - List<ScenePresence> avatars = m_scene.GetAvatars(); foreach (ScenePresence presence in avatars) { @@ -679,15 +682,14 @@ namespace OpenSim.Region.Environment.LandManagement { if (checkBan.isBannedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } else if (checkBan.isRestrictedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } - } return; } @@ -696,8 +698,8 @@ namespace OpenSim.Region.Environment.LandManagement public void sendLandUpdate(ScenePresence avatar) { - Land over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), - (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); + Land over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), + (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); if (over != null) { @@ -705,10 +707,10 @@ namespace OpenSim.Region.Environment.LandManagement if (avatar.currentParcelUUID != over.landData.globalID) { avatar.currentParcelUUID = over.landData.globalID; - m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, this.m_scene.RegionInfo.RegionID); + m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, + m_scene.RegionInfo.RegionID); } } - } public void handleSignificantClientMovement(IClientAPI remote_client) @@ -722,16 +724,18 @@ namespace OpenSim.Region.Environment.LandManagement Land parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); if (parcel != null) { - if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) + if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && + clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) { - - handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); //They are going below the safety line! + handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); + //They are going below the safety line! if (!parcel.isBannedFromLand(clientAvatar.UUID)) { clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; } } - else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && parcel.isBannedFromLand(clientAvatar.UUID)) + else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && + parcel.isBannedFromLand(clientAvatar.UUID)) { sendYouAreBannedNotice(clientAvatar); } @@ -739,30 +743,33 @@ namespace OpenSim.Region.Environment.LandManagement } } - public void handleAnyClientMovement(ScenePresence avatar) //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. + public void handleAnyClientMovement(ScenePresence avatar) + //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. { Land over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); if (over != null) { if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) { - avatar.lastKnownAllowedPosition = new Axiom.Math.Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); - - + avatar.lastKnownAllowedPosition = + new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); } } } - public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client) + public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, + int landLocalID, IClientAPI remote_client) { if (landList.ContainsKey(landLocalID)) { - landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID,remote_client); + landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client); } } - public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID,uint flags, int landLocalID, List<libsecondlife.ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client) + public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, + List<ParcelManager.ParcelAccessEntry> entries, + IClientAPI remote_client) { if (landList.ContainsKey(landLocalID)) { @@ -849,4 +856,4 @@ namespace OpenSim.Region.Environment.LandManagement } #endregion -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index b1ab330..fcf0f72 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -220,7 +220,7 @@ namespace OpenSim.Region.Environment { if (pluginType.GetInterface("IRegionModule") != null) { - modules.Add((IRegionModule)Activator.CreateInstance(pluginType)); + modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); } } } diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs index 0b95aee..c31a79b 100644 --- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs @@ -27,11 +27,12 @@ */ using System; -using libsecondlife; using System.Collections.Generic; +using libsecondlife; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -59,9 +60,9 @@ namespace OpenSim.Region.Environment.Modules { m_avatarsAppearance[avatarId] = appearance; } - catch (System.NullReferenceException) + catch (NullReferenceException) { - OpenSim.Framework.Console.MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar"); + MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar"); } return true; } @@ -98,17 +99,17 @@ namespace OpenSim.Region.Environment.Modules public void NewClient(IClientAPI client) { - client.OnAvatarNowWearing += AvatarIsWearing; + client.OnAvatarNowWearing += AvatarIsWearing; } public void RemoveClient(IClientAPI client) { - // client.OnAvatarNowWearing -= AvatarIsWearing; + // client.OnAvatarNowWearing -= AvatarIsWearing; } public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { - IClientAPI clientView = (IClientAPI)sender; + IClientAPI clientView = (IClientAPI) sender; CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId); if (profile != null) { @@ -127,7 +128,7 @@ namespace OpenSim.Region.Environment.Modules { assetId = baseItem.assetID; //temporary dictionary storage. This should be storing to a database - + if (m_avatarsAppearance.ContainsKey(clientView.AgentId)) { AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId]; @@ -158,4 +159,4 @@ namespace OpenSim.Region.Environment.Modules return visualParams; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 069eb3f..d6df978 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -176,10 +176,10 @@ namespace OpenSim.Region.Environment.Modules foreach (Scene s in m_scenes) { s.ForEachScenePresence(delegate(ScenePresence presence) - { - TrySendChatMessage(presence, fromPos, regionPos, - fromAgentID, fromName, e.Type, message); - }); + { + TrySendChatMessage(presence, fromPos, regionPos, + fromAgentID, fromName, e.Type, message); + }); } } } @@ -373,4 +373,4 @@ namespace OpenSim.Region.Environment.Modules m_tcp.Close(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index d47004b..f8798dc 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -27,18 +27,15 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Net; using System.Text; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using System.Collections; -using System.Collections.Generic; using System.Threading; using libsecondlife; using Nini.Config; -using Nwc.XmlRpc; -using OpenSim.Framework.Servers; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; /***************************************************** * @@ -85,120 +82,120 @@ using OpenSim.Framework.Servers; namespace OpenSim.Region.Environment.Modules { - public class ScriptHTTPRequests : IRegionModule, IHttpRequests - { - private Scene m_scene; - private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); - private object HttpListLock = new object(); - private string m_name = "HttpScriptRequests"; - private int httpTimeout = 300; - - // <request id, HttpRequestClass> - private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests; - - public ScriptHTTPRequests() - { - } - - public void Initialise(Scene scene, IConfigSource config) - { - m_scene = scene; - - m_scene.RegisterModuleInterface<IHttpRequests>(this); - - m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>(); - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return m_name; } - } - - public bool IsSharedModule - { - get { return true; } - } - - public LLUUID MakeHttpRequest(string url, string parameters, string body) { - return LLUUID.Zero; - } - - public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body) - { - LLUUID reqID = LLUUID.Random(); - HttpRequestClass htc = new HttpRequestClass(); - - // Parameters are expected in {key, value, ... , key, value} - if( parameters != null ) - { - string[] parms = parameters.ToArray(); - for (int i = 0; i < parms.Length / 2; i += 2) + public class ScriptHTTPRequests : IRegionModule, IHttpRequests + { + private Scene m_scene; + private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); + private object HttpListLock = new object(); + private string m_name = "HttpScriptRequests"; + private int httpTimeout = 300; + + // <request id, HttpRequestClass> + private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests; + + public ScriptHTTPRequests() + { + } + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + + m_scene.RegisterModuleInterface<IHttpRequests>(this); + + m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>(); + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return m_name; } + } + + public bool IsSharedModule + { + get { return true; } + } + + public LLUUID MakeHttpRequest(string url, string parameters, string body) + { + return LLUUID.Zero; + } + + public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body) + { + LLUUID reqID = LLUUID.Random(); + HttpRequestClass htc = new HttpRequestClass(); + + // Parameters are expected in {key, value, ... , key, value} + if (parameters != null) + { + string[] parms = parameters.ToArray(); + for (int i = 0; i < parms.Length/2; i += 2) { - switch( Int32.Parse(parms[i]) ) + switch (Int32.Parse(parms[i])) { case HttpRequestClass.HTTP_METHOD: - htc.httpMethod = parms[i + 1]; - break; + htc.httpMethod = parms[i + 1]; + break; case HttpRequestClass.HTTP_MIMETYPE: - - htc.httpMIMEType = parms[i + 1]; - break; + + htc.httpMIMEType = parms[i + 1]; + break; case HttpRequestClass.HTTP_BODY_MAXLENGTH: - - // TODO implement me - break; + + // TODO implement me + break; case HttpRequestClass.HTTP_VERIFY_CERT: - - // TODO implement me - break; + + // TODO implement me + break; } } - } - - htc.localID = localID; - htc.itemID = itemID; - htc.url = url; - htc.reqID = reqID; - htc.httpTimeout = httpTimeout; - htc.outbound_body = body; - - lock (HttpListLock) - { - m_pendingRequests.Add(reqID, htc); - } - - htc.process(); - - return reqID; - } - - public void StopHttpRequest(uint m_localID, LLUUID m_itemID) - { - lock (HttpListLock) - { - - HttpRequestClass tmpReq; - if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq)) - { - tmpReq.Stop(); - m_pendingRequests.Remove(m_itemID); - } - } - } - - /* + } + + htc.localID = localID; + htc.itemID = itemID; + htc.url = url; + htc.reqID = reqID; + htc.httpTimeout = httpTimeout; + htc.outbound_body = body; + + lock (HttpListLock) + { + m_pendingRequests.Add(reqID, htc); + } + + htc.process(); + + return reqID; + } + + public void StopHttpRequest(uint m_localID, LLUUID m_itemID) + { + lock (HttpListLock) + { + HttpRequestClass tmpReq; + if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq)) + { + tmpReq.Stop(); + m_pendingRequests.Remove(m_itemID); + } + } + } + + /* * TODO * Not sure how important ordering is is here - the next first * one completed in the list is returned, based soley on its list @@ -206,10 +203,11 @@ namespace OpenSim.Region.Environment.Modules * finsihed. I thought about setting up a queue for this, but * it will need some refactoring and this works 'enough' right now */ - public HttpRequestClass GetNextCompletedRequest() - { - lock (HttpListLock) - { + + public HttpRequestClass GetNextCompletedRequest() + { + lock (HttpListLock) + { foreach (LLUUID luid in m_pendingRequests.Keys) { HttpRequestClass tmpReq; @@ -225,18 +223,16 @@ namespace OpenSim.Region.Environment.Modules } } return null; - } - - - } + } + } - // - // HTTP REAQUEST - // This class was originally in LSLLongCmdHandler - // - // TODO: setter/getter methods, maybe pass some in - // constructor - // + // + // HTTP REAQUEST + // This class was originally in LSLLongCmdHandler + // + // TODO: setter/getter methods, maybe pass some in + // constructor + // public class HttpRequestClass { @@ -280,9 +276,9 @@ namespace OpenSim.Region.Environment.Modules * TODO: More work on the response codes. Right now * returning 200 for success or 499 for exception */ + public void SendRequest() { - HttpWebResponse response = null; StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; @@ -292,14 +288,14 @@ namespace OpenSim.Region.Environment.Modules try { request = (HttpWebRequest) - WebRequest.Create(url); + WebRequest.Create(url); request.Method = httpMethod; request.ContentType = httpMIMEType; request.Timeout = httpTimeout; // execute the request response = (HttpWebResponse) - request.GetResponse(); + request.GetResponse(); Stream resStream = response.GetResponseStream(); @@ -317,11 +313,9 @@ namespace OpenSim.Region.Environment.Modules // continue building the string sb.Append(tempString); } - } - while (count > 0); // any more data to read? + } while (count > 0); // any more data to read? response_body = sb.ToString(); - } catch (Exception e) { @@ -333,7 +327,6 @@ namespace OpenSim.Region.Environment.Modules status = 200; finished = true; - } public void Stop() @@ -342,8 +335,9 @@ namespace OpenSim.Region.Environment.Modules { httpThread.Abort(); } - catch (Exception) { } + catch (Exception) + { + } } } - - } \ No newline at end of file +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/SunModule.cs b/OpenSim/Region/Environment/Modules/SunModule.cs index 233c83c..bd6cd63 100644 --- a/OpenSim/Region/Environment/Modules/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/SunModule.cs @@ -28,13 +28,12 @@ using System; using System.Collections.Generic; +using libsecondlife; using Nini.Config; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; using OpenSim.Framework; using OpenSim.Framework.Console; -using libsecondlife; - +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules { @@ -55,17 +54,20 @@ namespace OpenSim.Region.Environment.Modules { m_start = DateTime.Now.Ticks; m_frame = 0; - + // Just in case they don't have the stanzas - try { + try + { m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); - } catch (Exception) { + } + catch (Exception) + { m_day_length = m_real_day; m_frame_mod = m_default_frame; } - - m_dilation = (int)(m_real_day / m_day_length); + + m_dilation = (int) (m_real_day/m_day_length); m_scene = scene; m_log = MainLog.Instance; scene.EventManager.OnFrame += SunUpdate; @@ -94,10 +96,11 @@ namespace OpenSim.Region.Environment.Modules { client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); } - + public void SunUpdate() { - if (m_frame < m_frame_mod) { + if (m_frame < m_frame_mod) + { m_frame++; return; } @@ -115,20 +118,20 @@ namespace OpenSim.Region.Environment.Modules // time when the simulator starts, then run time forward // faster based on time dilation factor. This means that // ticks don't get out of hand - private double HourOfTheDay() + private double HourOfTheDay() { - long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; + long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; DateTime dt = new DateTime(m_start + m_addticks); - return (double)dt.Hour + ((double)dt.Minute / 60.0); + return (double) dt.Hour + ((double) dt.Minute/60.0); } - private LLVector3 SunPos(double hour) + private LLVector3 SunPos(double hour) { // now we have our radian position - double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); + double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); double z = Math.Sin(rad); double x = Math.Cos(rad); - return new LLVector3((float)x, 0f, (float)z); + return new LLVector3((float) x, 0f, (float) z); } // TODO: clear this out. This is here so that I remember to diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 0adace1..813be8d 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -32,6 +32,7 @@ using libsecondlife; using libsecondlife.Packets; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -48,7 +49,8 @@ namespace OpenSim.Region.Environment.Modules private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>(); - private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = new Dictionary<LLUUID, UserTextureDownloadService>(); + private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = + new Dictionary<LLUUID, UserTextureDownloadService>(); private Thread m_thread; @@ -72,7 +74,6 @@ namespace OpenSim.Region.Environment.Modules m_scene = scene; m_scene.EventManager.OnNewClient += NewClient; } - } public void PostInitialise() @@ -115,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules public void TextureRequest(Object sender, TextureRequestArgs e) { - IClientAPI client = (IClientAPI)sender; + IClientAPI client = (IClientAPI) sender; UserTextureDownloadService textureService; if (TryGetUserTextureService(client.AgentId, out textureService)) { @@ -175,7 +176,8 @@ namespace OpenSim.Region.Environment.Modules { if (!m_textureSenders.ContainsKey(e.RequestedAssetID)) { - TextureSender requestHandler = new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); + TextureSender requestHandler = + new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); m_textureSenders.Add(e.RequestedAssetID, requestHandler); m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); } @@ -183,7 +185,8 @@ namespace OpenSim.Region.Environment.Modules { m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber); m_textureSenders[e.RequestedAssetID].counter = 0; - if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && (m_textureSenders[e.RequestedAssetID].Sending ==false)) + if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && + (m_textureSenders[e.RequestedAssetID].Sending == false)) { m_textureSenders[e.RequestedAssetID].Sending = true; m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]); @@ -256,7 +259,7 @@ namespace OpenSim.Region.Environment.Modules { m_asset = asset; NumPackets = CalculateNumPackets(asset.Data.Length); - PacketCounter = (int)StartPacketNumber; + PacketCounter = (int) StartPacketNumber; ImageLoaded = true; } @@ -264,14 +267,15 @@ namespace OpenSim.Region.Environment.Modules { RequestedDiscardLevel = discardLevel; StartPacketNumber = packetNumber; - PacketCounter = (int)StartPacketNumber; + PacketCounter = (int) StartPacketNumber; } public bool SendTexturePacket() { SendPacket(); counter++; - if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))) ) + if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || + ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) { return true; } @@ -290,7 +294,7 @@ namespace OpenSim.Region.Environment.Modules im.Header.Reliable = false; im.ImageID.Packets = 1; im.ImageID.ID = m_asset.FullID; - im.ImageID.Size = (uint)m_asset.Data.Length; + im.ImageID.Size = (uint) m_asset.Data.Length; im.ImageData.Data = m_asset.Data; im.ImageID.Codec = 2; RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); @@ -300,9 +304,9 @@ namespace OpenSim.Region.Environment.Modules { ImageDataPacket im = new ImageDataPacket(); im.Header.Reliable = false; - im.ImageID.Packets = (ushort)(NumPackets); + im.ImageID.Packets = (ushort) (NumPackets); im.ImageID.ID = m_asset.FullID; - im.ImageID.Size = (uint)m_asset.Data.Length; + im.ImageID.Size = (uint) m_asset.Data.Length; im.ImageData.Data = new byte[600]; Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); im.ImageID.Codec = 2; @@ -314,18 +318,20 @@ namespace OpenSim.Region.Environment.Modules { ImagePacketPacket im = new ImagePacketPacket(); im.Header.Reliable = false; - im.ImageID.Packet = (ushort)(PacketCounter); + im.ImageID.Packet = (ushort) (PacketCounter); im.ImageID.ID = m_asset.FullID; - int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); + int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); if (size > 1000) size = 1000; im.ImageData.Data = new byte[size]; try { - Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); + Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); } - catch (System.ArgumentOutOfRangeException) + catch (ArgumentOutOfRangeException) { - OpenSim.Framework.Console.MainLog.Instance.Warn("TEXTURE", "Unable to separate texture into multiple packets: Array bounds failure on asset:" + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); + MainLog.Instance.Warn("TEXTURE", + "Unable to separate texture into multiple packets: Array bounds failure on asset:" + + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); return; } RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); @@ -342,14 +348,12 @@ namespace OpenSim.Region.Environment.Modules { //over 600 bytes so split up file int restData = (length - 600); - int restPackets = ((restData + 999) / 1000); + int restPackets = ((restData + 999)/1000); numPackets = restPackets; } return numPackets; } } - - } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index 0dad998..6b9ae46 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs @@ -135,7 +135,7 @@ namespace OpenSim.Region.Environment.Modules { m_listenerManager.Remove(handle); } - + // This method scans nearby objects and determines if they are listeners, // and if so if this message fits the filter. If it does, then // enqueue the message for delivery to the objects listen event handler. @@ -490,4 +490,4 @@ namespace OpenSim.Region.Environment.Modules return m_id; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs index f13b2bb..481ba3f 100644 --- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs @@ -33,10 +33,10 @@ using System.Threading; using libsecondlife; using Nini.Config; using Nwc.XmlRpc; +using OpenSim.Framework.Console; using OpenSim.Framework.Servers; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Console; /***************************************************** * @@ -116,15 +116,16 @@ namespace OpenSim.Region.Environment.Modules public void PostInitialise() { - if ( IsEnabled() ) + if (IsEnabled()) { m_openChannels = new Dictionary<LLUUID, RPCChannelInfo>(); m_pendingResponse = new Dictionary<LLUUID, RPCRequestInfo>(); // Start http server // Attach xmlrpc handlers - m_log.Verbose("REMOTE_DATA", "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); - BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); + m_log.Verbose("REMOTE_DATA", + "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); + BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort); httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); httpServer.Start(); } diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 53fa08a..76601ec 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -35,13 +35,13 @@ namespace OpenSim.Region.Environment public class PermissionManager { protected Scene m_scene; - + // These are here for testing. They will be taken out - private uint PERM_ALL = (uint)2147483647; - private uint PERM_COPY = (uint)32768; - private uint PERM_MODIFY = (uint)16384; - private uint PERM_MOVE = (uint)524288; - private uint PERM_TRANS = (uint)8192; + private uint PERM_ALL = (uint) 2147483647; + private uint PERM_COPY = (uint) 32768; + private uint PERM_MODIFY = (uint) 16384; + private uint PERM_MOVE = (uint) 524288; + private uint PERM_TRANS = (uint) 8192; // Bypasses the permissions engine (always returns OK) // disable in any production environment // TODO: Change this to false when permissions are a desired default @@ -109,10 +109,11 @@ namespace OpenSim.Region.Environment string reason = "Insufficient permission"; - Land land = this.m_scene.LandManager.getLandObject(position.X, position.Y); + Land land = m_scene.LandManager.getLandObject(position.X, position.Y); if (land == null) return false; - if ((land.landData.landFlags & ((int)Parcel.ParcelFlags.CreateObjects)) == (int)Parcel.ParcelFlags.CreateObjects) + if ((land.landData.landFlags & ((int) Parcel.ParcelFlags.CreateObjects)) == + (int) Parcel.ParcelFlags.CreateObjects) permission = true; //TODO: check for group rights @@ -143,8 +144,6 @@ namespace OpenSim.Region.Environment #region Object Permissions - - public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) { if (!m_scene.Entities.ContainsKey(objID)) @@ -158,7 +157,7 @@ namespace OpenSim.Region.Environment return 0; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objID]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[objID]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -274,7 +273,7 @@ namespace OpenSim.Region.Environment public virtual bool CanEditObjectPosition(LLUUID user, LLUUID obj) { - bool permission = GenericObjectPermission(user,obj); + bool permission = GenericObjectPermission(user, obj); if (!permission) { if (!m_scene.Entities.ContainsKey(obj)) @@ -288,7 +287,7 @@ namespace OpenSim.Region.Environment return false; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -298,6 +297,7 @@ namespace OpenSim.Region.Environment } return permission; } + public virtual bool CanCopyObject(LLUUID user, LLUUID obj) { bool permission = GenericObjectPermission(user, obj); @@ -314,7 +314,7 @@ namespace OpenSim.Region.Environment return false; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -324,6 +324,7 @@ namespace OpenSim.Region.Environment } return permission; } + public virtual bool CanReturnObject(LLUUID user, LLUUID obj) { return GenericObjectPermission(user, obj); @@ -491,4 +492,4 @@ namespace OpenSim.Region.Environment #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs index cffe846..5466865 100644 --- a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs +++ b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs @@ -25,11 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using System.Collections.Generic; using System.Xml; using libsecondlife; -using libsecondlife.Packets; - +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -37,11 +37,11 @@ namespace OpenSim.Region.Environment.Scenes { public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); - + public AvatarAnimations() { } - + public void LoadAnims() { //MainLog.Instance.Verbose("CLIENT", "Loading avatar animations"); @@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Scenes } } } - + // MainLog.Instance.Verbose("CLIENT", "Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); try @@ -68,11 +68,10 @@ namespace OpenSim.Region.Environment.Scenes AnimsNames.Add(kp.Value, kp.Key); } } - catch (System.InvalidOperationException) + catch (InvalidOperationException) { - OpenSim.Framework.Console.MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar"); + MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar"); } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs index 2ec4dbe..1583124 100644 --- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs +++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -26,15 +26,9 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Framework.Communications; -using OpenSim.Region.Environment.Types; namespace OpenSim.Region.Environment.Scenes { @@ -106,8 +100,8 @@ namespace OpenSim.Region.Environment.Scenes // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. // (float)m_visualParams[25] = Height // (float)m_visualParams[125] = LegLength - m_avatarHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))) - + (((float)m_visualParams[125] / 255.0f) / 1.5f); + m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f))) + + (((float) m_visualParams[125]/255.0f)/1.5f); } /// <summary> @@ -144,4 +138,4 @@ namespace OpenSim.Region.Environment.Scenes return textu; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index 4556c63..18799e4 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -145,7 +145,6 @@ namespace OpenSim.Region.Environment.Scenes return (EntityBase) MemberwiseClone(); } - public abstract void SetText(string text, Vector3 color, double alpha); } @@ -161,15 +160,13 @@ namespace OpenSim.Region.Environment.Scenes public EntityIntersection() { - - } + public EntityIntersection(Vector3 _ipoint, float _normal, bool _HitTF) { ipoint = _ipoint; normal = _normal; HitTF = _HitTF; } - } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs index b9d1232..3e87981 100644 --- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs +++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs @@ -27,7 +27,6 @@ */ using libsecondlife; -using libsecondlife.Packets; using OpenSim.Framework; namespace OpenSim.Region.Environment.Scenes diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 0ca3405..4233853 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; @@ -44,10 +43,13 @@ namespace OpenSim.Region.Environment.Scenes public class InnerScene { #region Events + public event PhysicsCrash UnRecoverableError; + #endregion #region Fields + public Dictionary<LLUUID, ScenePresence> ScenePresences; public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; public Dictionary<LLUUID, EntityBase> Entities; @@ -65,6 +67,7 @@ namespace OpenSim.Region.Environment.Scenes internal object m_syncRoot = new object(); public PhysicsScene _PhyScene; + #endregion public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) @@ -79,28 +82,27 @@ namespace OpenSim.Region.Environment.Scenes public PhysicsScene PhysicsScene { - get - { return _PhyScene; } + get { return _PhyScene; } set { // If we're not doing the initial set // Then we've got to remove the previous // event handler - try - { - _PhyScene.OnPhysicsCrash -= physicsBasedCrash; - } - catch (System.NullReferenceException) - { - // This occurs when storing to _PhyScene the first time. - // Is there a better way to check the event handler before - // getting here - // This can be safely ignored. We're setting the first inital - // there are no event handler's registered. - } - + try + { + _PhyScene.OnPhysicsCrash -= physicsBasedCrash; + } + catch (NullReferenceException) + { + // This occurs when storing to _PhyScene the first time. + // Is there a better way to check the event handler before + // getting here + // This can be safely ignored. We're setting the first inital + // there are no event handler's registered. + } + _PhyScene = value; - + _PhyScene.OnPhysicsCrash += physicsBasedCrash; } } @@ -113,6 +115,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Update Methods + internal void UpdatePreparePhysics() { // If we are using a threaded physics engine @@ -141,7 +144,7 @@ namespace OpenSim.Region.Environment.Scenes { lock (m_syncRoot) { - return _PhyScene.Simulate((float)elapsed); + return _PhyScene.Simulate((float) elapsed); } } @@ -151,12 +154,14 @@ namespace OpenSim.Region.Environment.Scenes foreach (EntityBase entity in moveEntities) { - entity.UpdateMovement(); + entity.UpdateMovement(); } } + #endregion #region Entity Methods + public void AddEntityFromStorage(SceneObjectGroup sceneObject) { sceneObject.RegionHandle = m_regInfo.RegionHandle; @@ -181,14 +186,17 @@ namespace OpenSim.Region.Environment.Scenes m_numPrim++; } } + public void AddPhysicalPrim(int number) { m_physicalPrim++; } + public void RemovePhysicalPrim(int number) { m_physicalPrim--; } + public void RemovePrim(uint localID, LLUUID avatar_deleter) { List<EntityBase> EntityList = GetEntities(); @@ -197,9 +205,9 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - if (((SceneObjectGroup)obj).LocalId == localID) + if (((SceneObjectGroup) obj).LocalId == localID) { - m_parentScene.RemoveEntity((SceneObjectGroup)obj); + m_parentScene.RemoveEntity((SceneObjectGroup) obj); m_numPrim--; return; } @@ -253,7 +261,8 @@ namespace OpenSim.Region.Environment.Scenes return newAvatar; } - public void SwapRootChildAgent(bool direction_RC_CR_T_F) + + public void SwapRootChildAgent(bool direction_RC_CR_T_F) { if (direction_RC_CR_T_F) { @@ -266,25 +275,29 @@ namespace OpenSim.Region.Environment.Scenes m_numRootAgents++; } } + public void removeUserCount(bool TypeRCTF) { if (TypeRCTF) { m_numRootAgents--; } - else + else { m_numChildAgents--; } } + public void RemoveAPrimCount() { m_numPrim--; } + public void AddAPrimCount() { m_numPrim++; } + public int GetChildAgentCount() { return m_numChildAgents; @@ -375,8 +388,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(localID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(localID)) + return (SceneObjectGroup) ent; } } return null; @@ -390,8 +403,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(fullID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(fullID)) + return (SceneObjectGroup) ent; } } return null; @@ -406,7 +419,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectGroup reportingG = (SceneObjectGroup)ent; + SceneObjectGroup reportingG = (SceneObjectGroup) ent; EntityIntersection result = reportingG.TestIntersection(hray); if (result.HitTF) { @@ -417,7 +430,6 @@ namespace OpenSim.Region.Environment.Scenes } } } - } return returnResult; } @@ -531,17 +543,16 @@ namespace OpenSim.Region.Environment.Scenes //float distResult = Vector3Distance(avPosition, objPosition); //if (distResult > 512) //{ - //int x = 0; + //int x = 0; //} //if (distResult < presence.DrawDistance) //{ - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); //} - } - else + else { - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); } } } @@ -554,9 +565,11 @@ namespace OpenSim.Region.Environment.Scenes action(presence.ControllingClient); } } + #endregion #region Client Event handlers + /// <summary> /// /// </summary> @@ -583,13 +596,12 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="AgentID"></param> /// <param name="RequestFlags"></param> /// <param name="ObjectID"></param> - public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, LLUUID ObjectID) + public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, + LLUUID ObjectID) { SceneObjectGroup group = GetGroupByPrim(ObjectID); if (group != null) group.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags); - - } /// <summary> @@ -708,10 +720,9 @@ namespace OpenSim.Region.Environment.Scenes { if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) { - group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); + group.UpdatePrimFlags(localID, (ushort) packet.Type, true, packet.ToBytes()); } } - } public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) @@ -763,7 +774,7 @@ namespace OpenSim.Region.Environment.Scenes public void UpdateExtraParam(LLUUID agentID, uint primLocalID, ushort type, bool inUse, byte[] data) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - + if (group != null) { if (PermissionsMngr.CanEditObject(agentID, group.UUID)) @@ -771,7 +782,6 @@ namespace OpenSim.Region.Environment.Scenes group.UpdateExtraParam(primLocalID, type, inUse, data); } } - } /// <summary> @@ -786,7 +796,6 @@ namespace OpenSim.Region.Environment.Scenes { if (PermissionsMngr.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) { - group.UpdateShape(shapeBlock, primLocalID); } } @@ -806,9 +815,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == parentPrim) + if (((SceneObjectGroup) ent).LocalId == parentPrim) { - parenPrim = (SceneObjectGroup)ent; + parenPrim = (SceneObjectGroup) ent; break; } } @@ -823,9 +832,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == childPrims[i]) + if (((SceneObjectGroup) ent).LocalId == childPrims[i]) { - children.Add((SceneObjectGroup)ent); + children.Add((SceneObjectGroup) ent); } } } @@ -857,7 +866,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectGroup obj = (SceneObjectGroup)ent; + SceneObjectGroup obj = (SceneObjectGroup) ent; sceneObjects.Add(obj.LocalId, obj); } } @@ -882,9 +891,9 @@ namespace OpenSim.Region.Environment.Scenes } else { - MainLog.Instance.Verbose("SCENE", - "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", - primIds); + MainLog.Instance.Verbose("SCENE", + "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", + primIds); } } @@ -903,9 +912,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == originalPrim) + if (((SceneObjectGroup) ent).LocalId == originalPrim) { - originPrim = (SceneObjectGroup)ent; + originPrim = (SceneObjectGroup) ent; break; } } @@ -929,7 +938,6 @@ namespace OpenSim.Region.Environment.Scenes { MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); } - } /// <summary> @@ -943,8 +951,11 @@ namespace OpenSim.Region.Environment.Scenes // We don't really need the double floating point precision... // so casting it to a single - return (float)Math.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z)); + return + (float) + Math.Sqrt((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y) + (v1.z - v2.z)*(v1.z - v2.z)); } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 0689177..4c6e1c8 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -26,14 +26,12 @@ * */ -using Axiom.Math; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Region.Physics.Manager; -using System.Collections.Generic; namespace OpenSim.Region.Environment.Scenes { @@ -41,7 +39,7 @@ namespace OpenSim.Region.Environment.Scenes { //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 - + /// <summary> /// Add an inventory item to an avatar's inventory. /// </summary> @@ -57,7 +55,7 @@ namespace OpenSim.Region.Environment.Scenes remoteClient.SendInventoryItemCreateUpdate(item); } } - + /// <summary> /// <see>AddInventoryItem(LLUUID, InventoryItemBase)</see> /// </summary> @@ -71,10 +69,10 @@ namespace OpenSim.Region.Environment.Scenes if (!TryGetAvatar(avatarId, out avatar)) { MainLog.Instance.Error( - "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId); + "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId); return; } - + AddInventoryItem(avatar.ControllingClient, item); } @@ -95,7 +93,9 @@ namespace OpenSim.Region.Environment.Scenes InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); if (item != null) { - AssetBase asset = CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, (sbyte) item.assetType, data); + AssetBase asset = + CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, + (sbyte) item.assetType, data); AssetCache.AddAsset(asset); item.assetID = asset.FullID; @@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes } return LLUUID.Zero; } - + /// <summary> /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, LLUUID, byte[])</see> /// </summary> @@ -132,14 +132,14 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Error( - "AGENTINVENTORY", - "Avatar {0} cannot be found to update its inventory item asset", - avatarId); + "AGENTINVENTORY", + "Avatar {0} cannot be found to update its inventory item asset", + avatarId); } return LLUUID.Zero; - } - + } + /// <summary> /// Capability originating call to update the asset of a script in a prim's (task's) inventory /// </summary> @@ -149,17 +149,17 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="isScriptRunning">Indicates whether the script to update is currently running</param> /// <param name="data"></param> /// <returns>Asset LLUID created</returns> - public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, - LLUUID primId, bool isScriptRunning, byte[] data) + public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, + LLUUID primId, bool isScriptRunning, byte[] data) { // TODO Not currently doing anything with the isScriptRunning bool - + MainLog.Instance.Verbose( "PRIMINVENTORY", "Prim inventory script save functionality not yet implemented." - + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", + + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", remoteClient, itemId, primId, isScriptRunning); - + // TODO // Retrieve client LLUID // Retrieve sog containing primID @@ -170,13 +170,13 @@ namespace OpenSim.Region.Environment.Scenes // Trigger rerunning of script (use TriggerRezScript event, see RezScript) // return new asset id } - + /// <summary> /// <see>CapsUpdateTaskInventoryScriptAsset(IClientAPI, LLUUID, LLUUID, bool, byte[])</see> /// </summary> - private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId, + private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId, LLUUID primId, bool isScriptRunning, byte[] data) - { + { ScenePresence avatar; if (TryGetAvatar(avatarId, out avatar)) @@ -187,10 +187,10 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Error( - "PRIMINVENTORY", - "Avatar {0} cannot be found to update its prim item asset", - avatarId); - } + "PRIMINVENTORY", + "Avatar {0} cannot be found to update its prim item asset", + avatarId); + } } /// <summary> @@ -204,74 +204,75 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="name">The name of the updated item</param> /// <param name="description">The description of the updated item</param> /// <param name="nextOwnerMask">The permissions of the updated item</param> - public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, + public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID itemID, string name, string description, uint nextOwnerMask) - { - CachedUserInfo userInfo + { + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); - + if (userInfo != null && userInfo.RootFolder != null) { InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); if (item != null) - { + { if (LLUUID.Zero == transactionID) { item.inventoryName = name; item.inventoryDescription = description; item.inventoryNextPermissions = nextOwnerMask; - + userInfo.UpdateItem(remoteClient.AgentId, item); } - else - { - AgentAssetTransactions transactions + else + { + AgentAssetTransactions transactions = CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); - + if (transactions != null) { - LLUUID assetID = libsecondlife.LLUUID.Combine(transactionID, remoteClient.SecureSessionId); - AssetBase asset + LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); + AssetBase asset = AssetCache.GetAsset( - assetID, (item.assetType == (int)AssetType.Texture ? true : false)); - + assetID, (item.assetType == (int) AssetType.Texture ? true : false)); + if (asset == null) { asset = transactions.GetTransactionAsset(transactionID); } - + if (asset != null && asset.FullID == assetID) { asset.Name = item.inventoryName; asset.Description = item.inventoryDescription; asset.InvType = (sbyte) item.invType; - asset.Type = (sbyte) item.assetType; + asset.Type = (sbyte) item.assetType; item.assetID = asset.FullID; - + AssetCache.AddAsset(asset); } - + userInfo.UpdateItem(remoteClient.AgentId, item); } } } else - { + { MainLog.Instance.Warn( - "AGENTINVENTORY", - "Item ID " + itemID + " not found for an inventory item update."); + "AGENTINVENTORY", + "Item ID " + itemID + " not found for an inventory item update."); } } else { MainLog.Instance.Warn( "AGENTINVENTORY", - "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); + "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); } } - public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) + public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, + LLUUID newFolderID, string newName) { InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); if (item == null) @@ -308,7 +309,7 @@ namespace OpenSim.Region.Environment.Scenes } asset.Name = (newName.Length == 0) ? item.inventoryName : newName; - + // TODO: preserve current permissions? CreateNewInventoryItem(remoteClient, newFolderID, callbackID, asset, item.inventoryNextPermissions); } @@ -325,12 +326,13 @@ namespace OpenSim.Region.Environment.Scenes return asset; } - public void MoveInventoryItem(IClientAPI remoteClient,LLUUID folderID, LLUUID itemID, int length, string newName) + public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length, + string newName) { MainLog.Instance.Verbose( - "AGENTINVENTORY", + "AGENTINVENTORY", "Moving item for " + remoteClient.AgentId.ToString()); - + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo == null) { @@ -364,8 +366,6 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + itemID.ToString() + ", no root folder"); return; } - - } private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, @@ -406,7 +406,8 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="wearableType"></param> /// <param name="nextOwnerMask"></param> public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, - uint callbackID, string description, string name, sbyte invType, sbyte assetType, + uint callbackID, string description, string name, sbyte invType, + sbyte assetType, byte wearableType, uint nextOwnerMask) { if (transActionID == LLUUID.Zero) @@ -437,8 +438,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(localID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(localID)) + return (SceneObjectGroup) ent; } } return null; @@ -491,13 +492,13 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Warn( - "PRIMINVENTORY", - "Removal of item {0} requested of prim {1} but this prim does not exist", + "PRIMINVENTORY", + "Removal of item {0} requested of prim {1} but this prim does not exist", itemID, localID); - } + } } - + /// <summary> /// Update an item in a prim (task) inventory. /// This method does not handle scripts, <see>RezScript(IClientAPI, LLUUID, unit)</see> @@ -506,7 +507,7 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="itemID"></param> /// <param name="folderID"></param> /// <param name="primLocalID"></param> - public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, + public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint primLocalID) { SceneObjectGroup group = GetGroupByPrim(primLocalID); @@ -515,17 +516,17 @@ namespace OpenSim.Region.Environment.Scenes // TODO Retrieve itemID from client's inventory to pass on //group.AddInventoryItem(rmoteClient, primLocalID, null); MainLog.Instance.Verbose( - "PRIMINVENTORY", + "PRIMINVENTORY", "UpdateTaskInventory called with script {0}, folder {1}, primLocalID {2}, user {3}", itemID, folderID, primLocalID, remoteClient.Name); - } + } else { MainLog.Instance.Warn( - "PRIMINVENTORY", - "Update with script {0} requested of prim {1} for {2} but this prim does not exist", + "PRIMINVENTORY", + "Update with script {0} requested of prim {1} for {2} but this prim does not exist", itemID, primLocalID, remoteClient.Name); - } + } } /// <summary> @@ -551,7 +552,7 @@ namespace OpenSim.Region.Environment.Scenes { isTexture = true; } - + AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture); if (rezAsset != null) @@ -569,18 +570,18 @@ namespace OpenSim.Region.Environment.Scenes // TODO: do we care about the value of this bool? group.AddInventoryItem(remoteClient, localID, item, copyID); group.GetProperites(remoteClient); - + MainLog.Instance.Verbose( - "PRIMINVENTORY", - "Rezzed script {0} (asset {1}) into prim {2} for user {3}", - item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); + "PRIMINVENTORY", + "Rezzed script {0} (asset {1}) into prim {2} for user {3}", + item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); } else { MainLog.Instance.Warn( "PRIMINVENTORY", "Could not rez script {0} into prim {1} for user {2}" - + " because the prim could not be found in the region!", + + " because the prim could not be found in the region!", item.inventoryName, localID, remoteClient.Name); } } @@ -589,7 +590,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn( "PRIMINVENTORY", "Could not rez script {0} into prim {1} for user {2}" - + " because the item asset {3} could not be found!", + + " because the item asset {3} could not be found!", item.inventoryName, localID, item.assetID, remoteClient.Name); } } @@ -638,7 +639,8 @@ namespace OpenSim.Region.Environment.Scenes if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) { string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); - CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { AssetBase asset = CreateAsset( @@ -661,9 +663,10 @@ namespace OpenSim.Region.Environment.Scenes item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; item.inventoryCurrentPermissions = 2147483647; item.inventoryNextPermissions = 2147483647; - item.inventoryEveryOnePermissions = ((SceneObjectGroup)selectedEnt).RootPart.EveryoneMask; - item.inventoryBasePermissions = ((SceneObjectGroup)selectedEnt).RootPart.BaseMask; - item.inventoryCurrentPermissions = ((SceneObjectGroup)selectedEnt).RootPart.OwnerMask; + item.inventoryEveryOnePermissions = + ((SceneObjectGroup) selectedEnt).RootPart.EveryoneMask; + item.inventoryBasePermissions = ((SceneObjectGroup) selectedEnt).RootPart.BaseMask; + item.inventoryCurrentPermissions = ((SceneObjectGroup) selectedEnt).RootPart.OwnerMask; userInfo.AddItem(remoteClient.AgentId, item); remoteClient.SendInventoryItemCreateUpdate(item); @@ -730,20 +733,20 @@ namespace OpenSim.Region.Environment.Scenes //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) //{ - //PrimitiveBaseShape pbs = rootPart.Shape; - //rootPart.PhysActor = PhysicsScene.AddPrimShape( - //rootPart.Name, - //pbs, - //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, - // rootPart.AbsolutePosition.Z), - //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - - // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - - // } + //PrimitiveBaseShape pbs = rootPart.Shape; + //rootPart.PhysActor = PhysicsScene.AddPrimShape( + //rootPart.Name, + //pbs, + //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, + // rootPart.AbsolutePosition.Z), + //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), + //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, + // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); + + // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); + + // } rootPart.ScheduleFullUpdate(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 6a7c266..999b70f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -29,8 +29,6 @@ using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -45,7 +43,8 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="action">The action to be performed</param> /// <param name="north">Distance from the north border where the cursor is located</param> /// <param name="west">Distance from the west border where the cursor is located</param> - public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, float south, float east, + public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + float south, float east, IClientAPI remoteUser) { // Do a permissions check before allowing terraforming. @@ -157,7 +156,7 @@ namespace OpenSim.Region.Environment.Scenes } } } - + public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query) { //EventManager.TriggerAvatarPickerRequest(); @@ -166,13 +165,14 @@ namespace OpenSim.Region.Environment.Scenes AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); - AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; + AvatarPickerReplyPacket.DataBlock[] searchData = + new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); agentData.AgentID = avatarID; agentData.QueryID = RequestID; replyPacket.AgentData = agentData; - byte[] bytes = new byte[AvatarResponses.Count * 32]; + byte[] bytes = new byte[AvatarResponses.Count*32]; int i = 0; foreach (AvatarPickerAvatar item in AvatarResponses) @@ -180,10 +180,9 @@ namespace OpenSim.Region.Environment.Scenes LLUUID translatedIDtem = item.AvatarID; searchData[i] = new AvatarPickerReplyPacket.DataBlock(); searchData[i].AvatarID = translatedIDtem; - searchData[i].FirstName = Helpers.StringToField((string)item.firstName); - searchData[i].LastName = Helpers.StringToField((string)item.lastName); + searchData[i].FirstName = Helpers.StringToField((string) item.firstName); + searchData[i].LastName = Helpers.StringToField((string) item.lastName); i++; - } if (AvatarResponses.Count == 0) { @@ -193,4 +192,4 @@ namespace OpenSim.Region.Environment.Scenes client.SendAvatarPickerReply(replyPacket); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 0144c4c..c0fda61 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -27,27 +27,28 @@ */ using System; using System.Collections.Generic; -using System.IO; -using System.Net; +using System.Drawing; +using System.Drawing.Imaging; using System.Threading; using System.Timers; -using System.Xml; using Axiom.Math; using libsecondlife; +using libsecondlife.Packets; +using OpenJPEGNet; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Region.Environment.LandManagement; using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Scenes.Scripting; -using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Terrain; -using Timer = System.Timers.Timer; +using Caps=OpenSim.Region.Capabilities.Caps; +using Image=System.Drawing.Image; +using Timer=System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { @@ -56,6 +57,7 @@ namespace OpenSim.Region.Environment.Scenes public partial class Scene : SceneBase { #region Fields + protected Timer m_heartbeatTimer = new Timer(); protected Timer m_restartWaitTimer = new Timer(); @@ -88,7 +90,7 @@ namespace OpenSim.Region.Environment.Scenes protected SceneCommunicationService m_sceneGridService; protected SceneXmlLoader m_sceneXmlLoader; - protected Dictionary<LLUUID, OpenSim.Region.Capabilities.Caps> m_capsHandlers = new Dictionary<LLUUID, OpenSim.Region.Capabilities.Caps>(); + protected Dictionary<LLUUID, Caps> m_capsHandlers = new Dictionary<LLUUID, Caps>(); protected BaseHttpServer httpListener; protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>(); @@ -122,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes private int m_update_terrain = 50; private int m_update_land = 1; private int m_update_avatars = 1; + #endregion #region Properties @@ -145,6 +148,7 @@ namespace OpenSim.Region.Environment.Scenes set { m_innerScene.PhysicsScene = value; } get { return (m_innerScene.PhysicsScene); } } + // This gets locked so things stay thread safe. public object SyncRoot { @@ -204,7 +208,8 @@ namespace OpenSim.Region.Environment.Scenes #region Constructors - public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, + public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, + CommunicationsManager commsMan, SceneCommunicationService sceneGridService, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SendTasksToChild) { @@ -230,9 +235,11 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager = new LandManager(this, m_regInfo); //Bind Storage Manager functions to some land manager functions for this scene - EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); - EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); - + EventManager.OnLandObjectAdded += + new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); + EventManager.OnLandObjectRemoved += + new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); + m_estateManager = new EstateManager(this, m_regInfo); m_permissionManager = permissionManager; @@ -258,7 +265,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>(); MainLog.Instance.Verbose("SCENE", "Creating LandMap"); - Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); + Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); ScenePresence.LoadAnims(); @@ -276,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes protected virtual void RegisterDefaultSceneEvents() { m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts; - m_eventManager.OnParcelPrimCountUpdate += this.addPrimsToParcelCounts; + m_eventManager.OnParcelPrimCountUpdate += addPrimsToParcelCounts; m_eventManager.OnPermissionError += SendPermissionAlert; } @@ -295,68 +302,65 @@ namespace OpenSim.Region.Environment.Scenes if (RegionInfo.RegionHandle != otherRegion.RegionHandle) { - for (int i = 0; i < m_neighbours.Count; i++) + for (int i = 0; i < m_neighbours.Count; i++) + { + // The purpose of this loop is to re-update the known neighbors + // when another region comes up on top of another one. + // The latest region in that location ends up in the + // 'known neighbors list' + // Additionally, the commFailTF property gets reset to false. + if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) { - // The purpose of this loop is to re-update the known neighbors - // when another region comes up on top of another one. - // The latest region in that location ends up in the - // 'known neighbors list' - // Additionally, the commFailTF property gets reset to false. - if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) + lock (m_neighbours) { - lock (m_neighbours) - { - m_neighbours[i] = otherRegion; - } + m_neighbours[i] = otherRegion; } } + } - // If the value isn't in the neighbours, add it. - // If the RegionInfo isn't exact but is for the same XY World location, - // then the above loop will fix that. + // If the value isn't in the neighbours, add it. + // If the RegionInfo isn't exact but is for the same XY World location, + // then the above loop will fix that. - if (!(m_neighbours.Contains(otherRegion))) + if (!(m_neighbours.Contains(otherRegion))) + { + lock (m_neighbours) { - lock (m_neighbours) - { - m_neighbours.Add(otherRegion); - } + m_neighbours.Add(otherRegion); } - if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) + } + if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && + (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) { try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - InformClientOfNeighbor(agent, otherRegion); - } - } - - ); + { + // If agent is a root agent. + if (!agent.IsChildAgent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + InformClientOfNeighbor(agent, otherRegion); + } + } + ); } - catch (System.NullReferenceException) + catch (NullReferenceException) { // This means that we're not booted up completely yet. // This shouldn't happen too often anymore. - MainLog.Instance.Error("SCENE", "Couldn't inform client of regionup because we got a null reference exception"); + MainLog.Instance.Error("SCENE", + "Couldn't inform client of regionup because we got a null reference exception"); } } else { - MainLog.Instance.Verbose("INTERGRID", "Got notice about far away Region: " + otherRegion.RegionName.ToString() + - " at (" + otherRegion.RegionLocX.ToString() + ", " + otherRegion.RegionLocY.ToString() + ")" ); + MainLog.Instance.Verbose("INTERGRID", + "Got notice about far away Region: " + otherRegion.RegionName.ToString() + + " at (" + otherRegion.RegionLocX.ToString() + ", " + + otherRegion.RegionLocY.ToString() + ")"); } - - - - } return true; } @@ -379,11 +383,11 @@ namespace OpenSim.Region.Environment.Scenes { // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() m_restartTimer.Interval = 15000; - m_incrementsof15seconds = (int)seconds / 15; + m_incrementsof15seconds = (int) seconds/15; m_RestartTimerCounter = 0; m_restartTimer.AutoReset = true; m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); - MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds / 60) + " minutes"); + MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds/60) + " minutes"); m_restartTimer.Start(); SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes"); } @@ -399,7 +403,8 @@ namespace OpenSim.Region.Environment.Scenes if (m_RestartTimerCounter <= m_incrementsof15seconds) { if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) - SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds"); + SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) + + " seconds"); } else { @@ -432,21 +437,19 @@ namespace OpenSim.Region.Environment.Scenes { try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - InformClientOfNeighbor(agent, region); - } - } - - ); + { + // If agent is a root agent. + if (!agent.IsChildAgent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + InformClientOfNeighbor(agent, region); + } + } + ); } - catch (System.NullReferenceException) + catch (NullReferenceException) { // This means that we're not booted up completely yet. // This shouldn't happen too often anymore. @@ -464,24 +467,22 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn("SCENE", "Closing down the single simulator: " + RegionInfo.RegionName); // Kick all ROOT agents with the message, 'The simulator is going down' ForEachScenePresence(delegate(ScenePresence avatar) - { - if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) - avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); + { + if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) + avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); - if (!avatar.IsChildAgent) - avatar.ControllingClient.Kick("The simulator is going down."); + if (!avatar.IsChildAgent) + avatar.ControllingClient.Kick("The simulator is going down."); - avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task); - }); + avatar.ControllingClient.OutPacket(new DisableSimulatorPacket(), + ThrottleOutPacketType.Task); + }); // Wait here, or the kick messages won't actually get to the agents before the scene terminates. Thread.Sleep(500); // Stop all client threads. - ForEachScenePresence(delegate(ScenePresence avatar) - { - avatar.ControllingClient.Close(true); - }); + ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); }); // Stop updating the scene objects and agents. m_heartbeatTimer.Close(); // close the inner scene @@ -509,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes public void StartTimer() { m_heartbeatTimer.Enabled = true; - m_heartbeatTimer.Interval = (int)(m_timespan * 1000); + m_heartbeatTimer.Interval = (int) (m_timespan*1000); m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); } @@ -555,30 +556,30 @@ namespace OpenSim.Region.Environment.Scenes if (m_frame == Int32.MaxValue) m_frame = 0; - if (m_frame % m_update_physics == 0) + if (m_frame%m_update_physics == 0) m_innerScene.UpdatePreparePhysics(); - if (m_frame % m_update_entitymovement == 0) + if (m_frame%m_update_entitymovement == 0) m_innerScene.UpdateEntityMovement(); - if (m_frame % m_update_physics == 0) + if (m_frame%m_update_physics == 0) physicsFPS = m_innerScene.UpdatePhysics( Math.Max(SinceLastFrame.TotalSeconds, m_timespan) ); - if (m_frame % m_update_entities == 0) + if (m_frame%m_update_entities == 0) m_innerScene.UpdateEntities(); - if (m_frame % m_update_events == 0) + if (m_frame%m_update_events == 0) UpdateEvents(); - if (m_frame % m_update_backup == 0) + if (m_frame%m_update_backup == 0) UpdateStorageBackup(); - if (m_frame % m_update_terrain == 0) + if (m_frame%m_update_terrain == 0) UpdateTerrain(); - if (m_frame % m_update_land == 0) + if (m_frame%m_update_land == 0) UpdateLand(); // if (m_frame%m_update_avatars == 0) @@ -592,7 +593,6 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); m_statsReporter.SetObjects(m_innerScene.GetTotalObjects()); m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects()); - } catch (NotImplementedException) { @@ -606,10 +606,11 @@ namespace OpenSim.Region.Environment.Scenes { updateLock.ReleaseMutex(); - m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds; + m_timedilation = m_timespan/(float) SinceLastFrame.TotalSeconds; m_lastupdate = DateTime.Now; } } + //Updates the time in the viewer. private void UpdateInWorldTime() { @@ -631,7 +632,7 @@ namespace OpenSim.Region.Environment.Scenes } } - private void SendSimStatsPackets(libsecondlife.Packets.SimStatsPacket pack) + private void SendSimStatsPackets(SimStatsPacket pack) { List<ScenePresence> StatSendAgents = GetScenePresences(); foreach (ScenePresence agent in StatSendAgents) @@ -639,11 +640,10 @@ namespace OpenSim.Region.Environment.Scenes if (!agent.IsChildAgent) { agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task); - } } - } + private void UpdateLand() { if (m_LandManager.landPrimCountTainted) @@ -676,7 +676,7 @@ namespace OpenSim.Region.Environment.Scenes { for (int y = 0; y < 16; y++) { - if (Terrain.Tainted(x * 16, y * 16)) + if (Terrain.Tainted(x*16, y*16)) { client.SendLayerData(x, y, terData); } @@ -724,13 +724,17 @@ namespace OpenSim.Region.Environment.Scenes public void ExportWorldMap(string fileName) { - List<MapBlockData> mapBlocks = this.CommsManager.GridService.RequestNeighbourMapBlocks((int)(this.RegionInfo.RegionLocX - 9), (int)(this.RegionInfo.RegionLocY - 9), (int)(this.RegionInfo.RegionLocX + 9), (int)(this.RegionInfo.RegionLocY + 9)); + List<MapBlockData> mapBlocks = + CommsManager.GridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9), + (int) (RegionInfo.RegionLocY - 9), + (int) (RegionInfo.RegionLocX + 9), + (int) (RegionInfo.RegionLocY + 9)); List<AssetBase> textures = new List<AssetBase>(); - List<System.Drawing.Image> bitImages = new List<System.Drawing.Image>(); + List<Image> bitImages = new List<Image>(); foreach (MapBlockData mapBlock in mapBlocks) { - AssetBase texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + AssetBase texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); if (texAsset != null) { @@ -738,7 +742,7 @@ namespace OpenSim.Region.Environment.Scenes } else { - texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); if (texAsset != null) { textures.Add(texAsset); @@ -748,22 +752,22 @@ namespace OpenSim.Region.Environment.Scenes foreach (AssetBase asset in textures) { - System.Drawing.Image image = OpenJPEGNet.OpenJPEG.DecodeToImage(asset.Data); + Image image = OpenJPEG.DecodeToImage(asset.Data); bitImages.Add(image); } - System.Drawing.Bitmap mapTexture = new System.Drawing.Bitmap(2560, 2560); - System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mapTexture); - System.Drawing.SolidBrush sea = new System.Drawing.SolidBrush(System.Drawing.Color.DarkBlue); + Bitmap mapTexture = new Bitmap(2560, 2560); + Graphics g = Graphics.FromImage(mapTexture); + SolidBrush sea = new SolidBrush(Color.DarkBlue); g.FillRectangle(sea, 0, 0, 2560, 2560); for (int i = 0; i < mapBlocks.Count; i++) { - ushort x = (ushort)((mapBlocks[i].X - this.RegionInfo.RegionLocX) + 10); - ushort y = (ushort)((mapBlocks[i].Y - this.RegionInfo.RegionLocY) + 10); - g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); + ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); + ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); + g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128); } - mapTexture.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); + mapTexture.Save(fileName, ImageFormat.Jpeg); } /// <summary> @@ -861,7 +865,7 @@ namespace OpenSim.Region.Environment.Scenes public void loadAllLandObjectsFromStorage() { MainLog.Instance.Verbose("SCENE", "Loading land objects from storage"); - List<Framework.LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); + List<LandData> landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); if (landData.Count == 0) { m_LandManager.NoLandDataFromStorage(); @@ -871,7 +875,7 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager.IncomingLandObjectsFromStorage(landData); } } - + #endregion #region Primitives Methods @@ -889,8 +893,8 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); rootPart.ApplySanePermissions(); - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = PhysicsScene.AddPrimShape( rootPart.Name, rootPart.Shape, @@ -931,9 +935,8 @@ namespace OpenSim.Region.Environment.Scenes if (PermissionsMngr.CanRezObject(ownerID, pos)) { - EntityIntersection rayTracing = null; - ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); + ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID)); if (presence != null) { Vector3 CameraPosition = presence.CameraPosition; @@ -941,14 +944,13 @@ namespace OpenSim.Region.Environment.Scenes float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd); - Vector3 rayDirection = new Vector3(rayEnd.x / raydistance, rayEnd.y / raydistance, rayEnd.z / raydistance); + Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance); Ray rezRay = new Ray(CameraPosition, rayDirection); Vector3 RezDirectionFromCamera = rezRay.Direction; rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); - } if ((rayTracing != null) && (rayTracing.HitTF)) @@ -957,7 +959,8 @@ namespace OpenSim.Region.Environment.Scenes // We will rez the object somewhere close to the prim. Better math needed. This is a Stub //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); Vector3 Newpos = rayTracing.ipoint; - Vector3 NewScale = new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); + Vector3 NewScale = + new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); @@ -965,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); - Quaternion NewRot = LocalRot * ParentRot; + Quaternion NewRot = LocalRot*ParentRot; Vector3 RezPoint = Newpos; @@ -990,8 +993,8 @@ namespace OpenSim.Region.Environment.Scenes //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; } // if not phantom, add to physics - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = PhysicsScene.AddPrimShape( @@ -1007,14 +1010,14 @@ namespace OpenSim.Region.Environment.Scenes } public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, - Tree treeType, bool newTree) + Tree treeType, bool newTree) { PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); treeShape.PathCurve = 16; treeShape.PathEnd = 49900; - treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; + treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree; treeShape.Scale = scale; - treeShape.State = (byte)treeType; + treeShape.State = (byte) treeType; AddNewPrim(LLUUID.Random(), position, rotation, treeShape); } @@ -1135,7 +1138,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest); - client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); + client.OnParcelAccessListUpdateRequest += + new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; @@ -1157,8 +1161,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; client.OnRezScript += RezScript; - - client.OnRequestTaskInventory += RequestTaskInventory; + + client.OnRequestTaskInventory += RequestTaskInventory; client.OnRemoveTaskItem += RemoveTaskInventory; client.OnUpdateTaskInventory += UpdateTaskInventory; @@ -1216,23 +1220,23 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } } - catch (System.NullReferenceException) + catch (NullReferenceException) { // We don't know which count to remove it from // Avatar is already disposed :/ } m_eventManager.TriggerOnRemovePresence(agentID); Broadcast(delegate(IClientAPI client) - { - try - { - client.SendKillObject(avatar.RegionHandle, avatar.LocalId); - } - catch (System.NullReferenceException) { - //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. - } - }); + try + { + client.SendKillObject(avatar.RegionHandle, avatar.LocalId); + } + catch (NullReferenceException) + { + //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. + } + }); ForEachScenePresence( delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); @@ -1251,7 +1255,7 @@ namespace OpenSim.Region.Environment.Scenes { avatar.Close(); } - catch (System.NullReferenceException) + catch (NullReferenceException) { //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. } @@ -1263,19 +1267,22 @@ namespace OpenSim.Region.Environment.Scenes // Remove client agent from profile, so new logins will work CommsManager.UserService.clearUserAgent(agentID); } - public override void CloseAllAgents(uint circuitcode) + + public override void CloseAllAgents(uint circuitcode) { // Called by ClientView to kill all circuit codes ClientManager.CloseAllAgents(circuitcode); - } + public void NotifyMyCoarseLocationChange() { ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); } + #endregion #region Entities + /// <summary> /// /// </summary> @@ -1312,7 +1319,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneGridService.OnCloseAgentConnection += CloseConnection; m_sceneGridService.OnRegionUp += OtherRegionUp; m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - + m_sceneGridService.KillObject = SendKillObject; } @@ -1321,17 +1328,16 @@ namespace OpenSim.Region.Environment.Scenes /// /// </summary> public void UnRegisterReginWithComms() - { - + { m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; m_sceneGridService.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= NewUserConnection; m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; m_sceneGridService.OnCloseAgentConnection -= CloseConnection; - + m_sceneGridService.Close(); } - + /// <summary> /// @@ -1344,18 +1350,19 @@ namespace OpenSim.Region.Environment.Scenes { if (agent.CapsPath != "") { - OpenSim.Region.Capabilities.Caps cap = - new OpenSim.Region.Capabilities.Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, + Caps cap = + new Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, agent.CapsPath, agent.AgentID, m_dumpAssetsToFile); - Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + - "/CAPS/" + agent.CapsPath + "0000/"); + Util.SetCapsURL(agent.AgentID, + "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + + "/CAPS/" + agent.CapsPath + "0000/"); cap.RegisterHandlers(); - + cap.AddNewInventoryItem = AddInventoryItem; cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; - + if (m_capsHandlers.ContainsKey(agent.AgentID)) { //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + @@ -1364,7 +1371,7 @@ namespace OpenSim.Region.Environment.Scenes { m_capsHandlers[agent.AgentID] = cap; } - catch (System.Collections.Generic.KeyNotFoundException) + catch (KeyNotFoundException) { // Fix for a potential race condition. m_capsHandlers.Add(agent.AgentID, cap); @@ -1396,10 +1403,10 @@ namespace OpenSim.Region.Environment.Scenes { m_scenePresences[agentID].MakeRootAgent(position, isFlying); } - catch (System.Exception e) + catch (Exception e) { MainLog.Instance.Verbose("SCENE", "Unable to do Agent Crossing."); - MainLog.Instance.Debug("SCENE",e.ToString()); + MainLog.Instance.Debug("SCENE", e.ToString()); } //m_innerScene.SwapRootChildAgent(false); } @@ -1419,11 +1426,11 @@ namespace OpenSim.Region.Environment.Scenes childAgentUpdate.ChildAgentDataUpdate(cAgentData); // Not Implemented: //TODO: Do we need to pass the message on to one of our neighbors? - } } return true; } + /// <summary> /// Tell a single agent to disconnect from the region. /// </summary> @@ -1445,7 +1452,7 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } // Tell a single agent to disconnect from the region. - libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); + DisableSimulatorPacket disable = new DisableSimulatorPacket(); presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); } } @@ -1511,7 +1518,8 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(remoteClient.AgentId)) { - m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); + m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, + position, lookAt, flags); } } @@ -1551,9 +1559,9 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="mod"></param> public void RegisterModuleInterface<M>(M mod) { - if (!ModuleInterfaces.ContainsKey(typeof(M))) + if (!ModuleInterfaces.ContainsKey(typeof (M))) { - ModuleInterfaces.Add(typeof(M), mod); + ModuleInterfaces.Add(typeof (M), mod); } } @@ -1563,9 +1571,9 @@ namespace OpenSim.Region.Environment.Scenes /// <returns></returns> public T RequestModuleInterface<T>() { - if (ModuleInterfaces.ContainsKey(typeof(T))) + if (ModuleInterfaces.ContainsKey(typeof (T))) { - return (T)ModuleInterfaces[typeof(T)]; + return (T) ModuleInterfaces[typeof (T)]; } else { @@ -1642,7 +1650,7 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); + m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); } } } @@ -1650,6 +1658,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Console Commands + #region Alert Methods private void SendPermissionAlert(LLUUID user, string reason) @@ -1692,7 +1701,8 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="sessionID"></param> /// <param name="token"></param> /// <param name="controllingClient"></param> - public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, IClientAPI controllingClient) + public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, + IClientAPI controllingClient) { // First check that this is the sim owner if (agentID == RegionInfo.MasterAvatarAssignedUUID) @@ -1736,37 +1746,38 @@ namespace OpenSim.Region.Environment.Scenes if (agentID == kickUserID) { ClientManager.ForEachClient(delegate(IClientAPI controller) - { - ScenePresence p = GetScenePresence(controller.AgentId); - bool childagent = !p.Equals(null) && p.IsChildAgent; - if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? { - controller.Kick(Helpers.FieldToUTF8String(reason)); - - if (childagent) + ScenePresence p = GetScenePresence(controller.AgentId); + bool childagent = !p.Equals(null) && p.IsChildAgent; + if (controller.AgentId != godID && !childagent) + // Do we really want to kick the initiator of this madness? { - m_innerScene.removeUserCount(false); + controller.Kick(Helpers.FieldToUTF8String(reason)); + + if (childagent) + { + m_innerScene.removeUserCount(false); + } + else + { + m_innerScene.removeUserCount(true); + } } - else - { - m_innerScene.removeUserCount(true); - } - } - } ); // This is a bit crude. It seems the client will be null before it actually stops the thread // The thread will kill itself eventually :/ // Is there another way to make sure *all* clients get this 'inter region' message? ClientManager.ForEachClient(delegate(IClientAPI controller) - { - ScenePresence p = GetScenePresence(controller.AgentId); - bool childagent = !p.Equals(null) && p.IsChildAgent; - if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? { - controller.Close(true); + ScenePresence p = GetScenePresence(controller.AgentId); + bool childagent = !p.Equals(null) && p.IsChildAgent; + if (controller.AgentId != godID && !childagent) + // Do we really want to kick the initiator of this madness? + { + controller.Close(true); + } } - } ); } else @@ -1799,7 +1810,8 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="agentID"></param> /// <param name="sessionID"></param> /// <param name="permChanges"></param> - public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, List<libsecondlife.Packets.ObjectPermissionsPacket.ObjectDataBlock> permChanges) + public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, + List<ObjectPermissionsPacket.ObjectDataBlock> permChanges) { // Check for spoofing.. since this is permissions we're talking about here! if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) @@ -1879,7 +1891,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); + ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); } } } @@ -1899,7 +1911,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); + SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID); if (part != null) { if (part.Name == cmdparams[0]) @@ -1967,10 +1979,12 @@ namespace OpenSim.Region.Environment.Scenes { m_eventManager.TriggerOnPluginConsole(args); } + public double GetLandHeight(int x, int y) { return Terrain.GetHeight(x, y); } + public LLUUID GetLandOwner(float x, float y) { Land land = LandManager.getLandObject(x, y); @@ -1983,7 +1997,7 @@ namespace OpenSim.Region.Environment.Scenes return land.landData.ownerID; } } - + public LandData GetLandData(float x, float y) { return LandManager.getLandObject(x, y).landData; @@ -2034,6 +2048,7 @@ namespace OpenSim.Region.Environment.Scenes { return m_innerScene.ConvertLocalIDToFullID(localID); } + public void SwapRootAgentCount(bool rootChildChildRootTF) { m_innerScene.SwapRootChildAgent(rootChildChildRootTF); @@ -2108,13 +2123,16 @@ namespace OpenSim.Region.Environment.Scenes // We don't want to try to send messages if there are no avatar. if (!(m_scenePresences.Equals(null))) { - try { - List<ScenePresence> presenceList = GetScenePresences(); + try + { + List<ScenePresence> presenceList = GetScenePresences(); foreach (ScenePresence presence in presenceList) { action(presence); } - } catch (Exception e) { + } + catch (Exception e) + { MainLog.Instance.Verbose("BUG", e.ToString()); } } @@ -2181,4 +2199,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 35d88eb..fe8f8da 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -26,8 +26,6 @@ * */ using System; -using System.Collections.Generic; -using System.Timers; using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -43,8 +41,9 @@ namespace OpenSim.Region.Environment.Scenes public event restart OnRestart; #endregion - + #region Fields + private readonly ClientManager m_clientManager = new ClientManager(); public ClientManager ClientManager @@ -92,8 +91,6 @@ namespace OpenSim.Region.Environment.Scenes /// </summary> public abstract void Update(); - - #endregion #region Terrain Methods @@ -163,8 +160,8 @@ namespace OpenSim.Region.Environment.Scenes public abstract bool OtherRegionUp(RegionInfo thisRegion); - #endregion + #region Shutdown /// <summary> @@ -184,4 +181,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index b184af2..3942397 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -29,11 +29,10 @@ using System; using System.Collections.Generic; using System.Net; -using System.Text; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -52,7 +51,7 @@ namespace OpenSim.Region.Environment.Scenes public event PrimCrossing OnPrimCrossingIntoRegion; public event RegionUp OnRegionUp; public event ChildAgentUpdate OnChildAgentUpdate; - + public KillObjectDelegate KillObject; public string _debugRegionName = ""; @@ -60,10 +59,7 @@ namespace OpenSim.Region.Environment.Scenes public string debugRegionName { get { return _debugRegionName; } - set - { - _debugRegionName = value; - } + set { _debugRegionName = value; } } public SceneCommunicationService(CommunicationsManager commsMan) @@ -90,7 +86,6 @@ namespace OpenSim.Region.Environment.Scenes regionCommsHost.OnCloseAgentConnection += CloseConnection; regionCommsHost.OnRegionUp += newRegionUp; regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - } else { @@ -102,7 +97,6 @@ namespace OpenSim.Region.Environment.Scenes { if (regionCommsHost != null) { - regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; regionCommsHost.OnRegionUp -= newRegionUp; regionCommsHost.OnExpectUser -= NewUserConnection; @@ -115,6 +109,7 @@ namespace OpenSim.Region.Environment.Scenes } #region CommsManager Event handlers + /// <summary> /// /// </summary> @@ -139,6 +134,7 @@ namespace OpenSim.Region.Environment.Scenes } return true; } + protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { if (OnChildAgentUpdate != null) @@ -155,6 +151,7 @@ namespace OpenSim.Region.Environment.Scenes OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); } } + protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { if (OnPrimCrossingIntoRegion != null) @@ -174,12 +171,13 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Inform Client of Neighbours + private delegate void InformClientOfNeighbourDelegate( ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); private void InformClientOfNeighbourCompleted(IAsyncResult iar) { - InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; + InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState; icon.EndInvoke(iar); } @@ -215,8 +213,6 @@ namespace OpenSim.Region.Environment.Scenes //blah.Address = region.RemotingAddress; //blah.Port = region.RemotingPort; - - } /// <summary> @@ -227,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes { List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); - //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); for (int i = 0; i < lstneighbours.Count; i++) { // We don't want to keep sending to regions that consistently fail on comms. @@ -245,7 +241,6 @@ namespace OpenSim.Region.Environment.Scenes { for (int i = 0; i < neighbours.Count; i++) { - AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); agent.BaseFolder = LLUUID.Zero; agent.InventoryFolder = LLUUID.Zero; @@ -259,6 +254,7 @@ namespace OpenSim.Region.Environment.Scenes } } } + /// <summary> /// This informs a single neighboring region about agent "avatar". /// Calls an asynchronous method to do so.. so it doesn't lag the sim. @@ -278,11 +274,12 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle); private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) { - InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate)iar.AsyncState; + InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState; icon.EndInvoke(iar); } @@ -290,7 +287,8 @@ namespace OpenSim.Region.Environment.Scenes private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle) { MainLog.Instance.Notice("INTERGRID", "Starting to inform neighbors that I'm here"); - bool regionAccepted = m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); + bool regionAccepted = + m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); if (regionAccepted) { @@ -301,6 +299,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here"); } } + /// <summary> /// Called by scene when region is initialized (not always when it's listening for agents) /// This is an inter-region message that informs the surrounding neighbors that the sim is up. @@ -317,7 +316,6 @@ namespace OpenSim.Region.Environment.Scenes { for (int i = 0; i < neighbours.Count; i++) { - InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; d.BeginInvoke(region, neighbours[i].RegionHandle, @@ -325,9 +323,10 @@ namespace OpenSim.Region.Environment.Scenes d); } } - + //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); } + public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData); /// <summary> @@ -340,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData) { MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent."); - bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle,cAgentData); + bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); if (regionAccepted) { @@ -351,11 +350,13 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Notice("INTERGRID", "Failed sending a neighbor an update about my agent"); } } + private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) { - SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate)iar.AsyncState; + SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate) iar.AsyncState; icon.EndInvoke(iar); } + public void SendChildAgentDataUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { // This assumes that we know what our neighbors are. @@ -363,9 +364,8 @@ namespace OpenSim.Region.Environment.Scenes d.BeginInvoke(regionHandle, cAgentData, SendChildAgentDataUpdateCompleted, d); - } - + /// <summary> /// Helper function to request neighbors from grid-comms @@ -401,15 +401,13 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="lookAt"></param> /// <param name="flags"></param> public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, - LLVector3 lookAt, uint flags) + LLVector3 lookAt, uint flags) { if (regionHandle == m_regionInfo.RegionHandle) { - avatar.ControllingClient.SendTeleportLocationStart(); avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); avatar.Teleport(position); - } else { @@ -424,20 +422,22 @@ namespace OpenSim.Region.Environment.Scenes agent.child = true; avatar.Close(); m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); - m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); + m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, + position, false); AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); - avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); + avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), + capsPath); avatar.MakeChildAgent(); if (KillObject != null) { KillObject(avatar.LocalId); } - uint newRegionX = (uint)(regionHandle >> 40); - uint newRegionY = (((uint)(regionHandle)) >> 8); - uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); - uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); - if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) + uint newRegionX = (uint) (regionHandle >> 40); + uint newRegionY = (((uint) (regionHandle)) >> 8); + uint oldRegionX = (uint) (m_regionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint) (m_regionInfo.RegionHandle)) >> 8); + if (Util.fast_distance2d((int) (newRegionX - oldRegionX), (int) (newRegionY - oldRegionY)) > 3) { CloseChildAgentConnections(avatar); } @@ -465,7 +465,8 @@ namespace OpenSim.Region.Environment.Scenes { foreach (ulong regionHandle in presence.KnownChildRegions) { - m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, presence.ControllingClient.AgentId); + m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, + presence.ControllingClient.AgentId); presence.RemoveNeighbourRegion(regionHandle); } } @@ -474,6 +475,5 @@ namespace OpenSim.Region.Environment.Scenes { return m_commsProvider.GridService.GetGridSettings(); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 9c8c62b..a6a8fb6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -105,7 +105,7 @@ namespace OpenSim.Region.Environment.Scenes public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID); public event LandObjectAdded OnLandObjectAdded; - + public delegate void LandObjectRemoved(LLUUID globalID); public event LandObjectRemoved OnLandObjectRemoved; @@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes public void TriggerOnClientMovement(ScenePresence avatar) { - if(OnClientMovement != null) + if (OnClientMovement != null) OnClientMovement(avatar); } @@ -223,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes { if (OnSceneGroupMove != null) { - return OnSceneGroupMove(groupID, delta); + return OnSceneGroupMove(groupID, delta); } return true; } @@ -236,13 +236,14 @@ namespace OpenSim.Region.Environment.Scenes } } - public void TriggerLandObjectAdded(Land newParcel,LLUUID regionID) + public void TriggerLandObjectAdded(Land newParcel, LLUUID regionID) { if (OnLandObjectAdded != null) { OnLandObjectAdded(newParcel, regionID); } } + public void TriggerLandObjectRemoved(LLUUID globalID) { if (OnLandObjectRemoved != null) @@ -250,10 +251,11 @@ namespace OpenSim.Region.Environment.Scenes OnLandObjectRemoved(globalID); } } + public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel) { //triggerLandObjectRemoved(localParcelID); - TriggerLandObjectAdded(newParcel,newParcel.m_scene.RegionInfo.RegionID); + TriggerLandObjectAdded(newParcel, newParcel.m_scene.RegionInfo.RegionID); } public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID) diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index e822874..1eac61b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -84,7 +84,6 @@ namespace OpenSim.Region.Environment.Scenes { if (m_localScenes[i].Equals(cscene)) { - m_localScenes[i].Close(); } } @@ -99,7 +98,8 @@ namespace OpenSim.Region.Environment.Scenes public void HandleRestart(RegionInfo rdata) { - MainLog.Instance.Error("SCENEMANAGER", "Got Restart message for region:" + rdata.RegionName +" Sending up to main"); + MainLog.Instance.Error("SCENEMANAGER", + "Got Restart message for region:" + rdata.RegionName + " Sending up to main"); int RegionSceneElement = -1; for (int i = 0; i < m_localScenes.Count; i++) { @@ -127,7 +127,6 @@ namespace OpenSim.Region.Environment.Scenes for (int i = 0; i < m_localScenes.Count; i++) { - if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) { // Inform other regions to tell their avatar about me @@ -223,7 +222,7 @@ namespace OpenSim.Region.Environment.Scenes { ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); }); } - + public void HandleAlertCommandOnCurrentScene(string[] cmdparams) { ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); @@ -423,4 +422,4 @@ namespace OpenSim.Region.Environment.Scenes m_localScenes.ForEach(action); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 20d596a..5b74c9b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Text; using System.Xml; @@ -38,7 +39,6 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Physics.Manager; -using System.Drawing; namespace OpenSim.Region.Environment.Scenes { @@ -74,11 +74,13 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_rootPart.RotationOffset; } } + public LLUUID GroupID { get { return m_rootPart.GroupID; } set { m_rootPart.GroupID = value; } } + /// <summary> /// /// </summary> @@ -242,7 +244,7 @@ namespace OpenSim.Region.Environment.Scenes part.ParentID = 0; part.LinkNum = 0; m_parts.Add(part.UUID, part); - + SetPartAsRoot(part); RegionHandle = regionHandle; @@ -295,7 +297,6 @@ namespace OpenSim.Region.Environment.Scenes sr.Close(); - m_rootPart.LocalID = m_scene.PrimIDAllocate(); m_rootPart.ParentID = 0; m_rootPart.RegionHandle = m_regionHandle; @@ -376,9 +377,10 @@ namespace OpenSim.Region.Environment.Scenes foreach (SceneObjectPart part in m_parts.Values) { - - Vector3 partPosition = new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); - Quaternion parentrotation = new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); + Vector3 partPosition = + new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); + Quaternion parentrotation = + new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); // Telling the prim to raytrace. EntityIntersection inter = part.TestIntersection(hRay, parentrotation); @@ -389,14 +391,11 @@ namespace OpenSim.Region.Environment.Scenes float idist = 256f; - - if (inter.HitTF) { // We need to find the closest prim to return to the testcaller along the ray if (inter.distance < idist) { - idist = inter.distance; returnresult.HitTF = true; returnresult.ipoint = inter.ipoint; @@ -405,15 +404,11 @@ namespace OpenSim.Region.Environment.Scenes returnresult.distance = inter.distance; } } - - } return returnresult; - } - /// <summary> /// /// </summary> @@ -524,7 +519,7 @@ namespace OpenSim.Region.Environment.Scenes /// <returns></returns> public SceneObjectGroup Copy(LLUUID cAgentID, LLUUID cGroupID) { - SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); + SceneObjectGroup dupe = (SceneObjectGroup) MemberwiseClone(); dupe.m_parts = new Dictionary<LLUUID, SceneObjectPart>(); dupe.m_parts.Clear(); //dupe.OwnerID = AgentID; @@ -549,9 +544,8 @@ namespace OpenSim.Region.Environment.Scenes new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z), - dupe.RootPart.PhysActor.IsPhysical); + dupe.RootPart.PhysActor.IsPhysical); dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); - } // Now we've made a copy that replaces this one, we need to // switch the owner to the person who did the copying @@ -559,8 +553,8 @@ namespace OpenSim.Region.Environment.Scenes // So, we have to make a copy of this one, set it in it's place then set the owner on this one SetRootPartOwner(m_rootPart, cAgentID, cGroupID); - - + + m_rootPart.ScheduleFullUpdate(); List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values); @@ -571,7 +565,6 @@ namespace OpenSim.Region.Environment.Scenes dupe.CopyPart(part, OwnerID, GroupID); SetPartOwner(part, cAgentID, cGroupID); part.ScheduleFullUpdate(); - } } dupe.UpdateParentIDs(); @@ -601,7 +594,7 @@ namespace OpenSim.Region.Environment.Scenes part.OwnerID = cAgentID; part.GroupID = cGroupID; - + if (part.OwnerID != cAgentID) { // Apply Next Owner Permissions if we're not bypassing permissions @@ -637,6 +630,7 @@ namespace OpenSim.Region.Environment.Scenes m_parts.Add(part.UUID, part); } } + /// <summary> /// /// </summary> @@ -666,8 +660,8 @@ namespace OpenSim.Region.Environment.Scenes objPropDB.Description = Helpers.StringToField(RootPart.Description); objPropFamilyPack.ObjectData = objPropDB; remoteClient.OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task); - } + public void SetPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) { part.OwnerID = cAgentID; @@ -884,12 +878,12 @@ namespace OpenSim.Region.Environment.Scenes Quaternion parentRot = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); - axPos = parentRot.Inverse() * axPos; + axPos = parentRot.Inverse()*axPos; linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); Quaternion oldRot = new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); - Quaternion newRot = parentRot.Inverse() * oldRot; + Quaternion newRot = parentRot.Inverse()*oldRot; linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); linkPart.ParentID = m_rootPart.LocalID; linkPart.LinkNum = m_parts.Count; @@ -949,7 +943,7 @@ namespace OpenSim.Region.Environment.Scenes linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z); - axPos = parentRot * axPos; + axPos = parentRot*axPos; linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; linkPart.OffsetPosition = new LLVector3(0, 0, 0); @@ -960,7 +954,7 @@ namespace OpenSim.Region.Environment.Scenes linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); - Quaternion newRot = parentRot * oldRot; + Quaternion newRot = parentRot*oldRot; linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); // Add physics information back to delinked part if appropriate @@ -978,7 +972,6 @@ namespace OpenSim.Region.Environment.Scenes linkPart.RotationOffset.Y, linkPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true); - } SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart); @@ -990,8 +983,8 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Verbose("SCENE", - "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", - partID, LocalId); + "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", + partID, LocalId); } } @@ -1008,7 +1001,7 @@ namespace OpenSim.Region.Environment.Scenes m_parts.Add(part.UUID, part); Vector3 axiomOldPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); - axiomOldPos = oldGroupRotation * axiomOldPos; + axiomOldPos = oldGroupRotation*axiomOldPos; axiomOldPos += oldGroupPosition; LLVector3 oldAbsolutePosition = new LLVector3(axiomOldPos.x, axiomOldPos.y, axiomOldPos.z); part.OffsetPosition = oldAbsolutePosition - AbsolutePosition; @@ -1018,15 +1011,15 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.RotationOffset.Z); Vector3 axiomPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); - axiomPos = axiomRootRotation.Inverse() * axiomPos; + axiomPos = axiomRootRotation.Inverse()*axiomPos; part.OffsetPosition = new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z); Quaternion axiomPartRotation = new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z); - axiomPartRotation = oldGroupRotation * axiomPartRotation; - axiomPartRotation = axiomRootRotation.Inverse() * axiomPartRotation; + axiomPartRotation = oldGroupRotation*axiomPartRotation; + axiomPartRotation = axiomRootRotation.Inverse()*axiomPartRotation; part.RotationOffset = new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); } @@ -1056,12 +1049,12 @@ namespace OpenSim.Region.Environment.Scenes proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0].ItemID = LLUUID.Zero; - proper.ObjectData[0].CreationDate = (ulong)m_rootPart.CreationDate; + proper.ObjectData[0].CreationDate = (ulong) m_rootPart.CreationDate; proper.ObjectData[0].CreatorID = m_rootPart.CreatorID; proper.ObjectData[0].FolderID = LLUUID.Zero; proper.ObjectData[0].FromTaskID = LLUUID.Zero; proper.ObjectData[0].GroupID = LLUUID.Zero; - proper.ObjectData[0].InventorySerial = (short)m_rootPart.InventorySerial; + proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; proper.ObjectData[0].ObjectID = UUID; proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; @@ -1155,7 +1148,7 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Warn( - "SCENE", + "SCENE", "Couldn't find part {0} in object group {1} ({2}) to retreive prim inventory", localID, LocalId, UUID); } @@ -1272,10 +1265,8 @@ namespace OpenSim.Region.Environment.Scenes public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF) { SceneObjectPart updatePart = GetChildPart(localID); - updatePart.UpdatePermissions(AgentID,field,localID,mask,addRemTF); + updatePart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); } - - #endregion @@ -1304,9 +1295,8 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); - bool UsePhysics = ((m_rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - } } @@ -1350,11 +1340,10 @@ namespace OpenSim.Region.Environment.Scenes if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { AbsolutePosition = pos; - } //we need to do a terse update even if the move wasn't allowed // so that the position is reset in the client (the object snaps back) - ScheduleGroupForTerseUpdate(); + ScheduleGroupForTerseUpdate(); } /// <summary> @@ -1394,7 +1383,7 @@ namespace OpenSim.Region.Environment.Scenes Quaternion partRotation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); - axDiff = partRotation.Inverse() * axDiff; + axDiff = partRotation.Inverse()*axDiff; diff.X = axDiff.x; diff.Y = axDiff.y; diff.Z = axDiff.z; @@ -1496,14 +1485,14 @@ namespace OpenSim.Region.Environment.Scenes if (prim.UUID != m_rootPart.UUID) { Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z); - axPos = oldParentRot * axPos; - axPos = axRot.Inverse() * axPos; + axPos = oldParentRot*axPos; + axPos = axRot.Inverse()*axPos; prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z); - Quaternion newRot = oldParentRot * primsRot; - newRot = axRot.Inverse() * newRot; + Quaternion newRot = oldParentRot*primsRot; + newRot = axRot.Inverse()*newRot; prim.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); prim.ScheduleTerseUpdate(); } @@ -1736,10 +1725,10 @@ namespace OpenSim.Region.Environment.Scenes public override void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int)(alpha * 0xff), - (int)(color.x * 0xff), - (int)(color.y * 0xff), - (int)(color.z * 0xff)); + Color = Color.FromArgb(0xff - (int) (alpha*0xff), + (int) (color.x*0xff), + (int) (color.y*0xff), + (int) (color.z*0xff)); Text = text; } @@ -1748,4 +1737,4 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.ApplyPhysics(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index f226150..90a975c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Xml; using System.Xml.Serialization; using Axiom.Math; @@ -38,23 +39,26 @@ using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Physics.Manager; -using System.Drawing; namespace OpenSim.Region.Environment.Scenes { public class SceneObjectPart : IScriptHost { - private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer; - private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner; + private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = + LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer; + + private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = + LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | + LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner; + private const uint OBJNEXT_OWNER = 2147483647; - + private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647; private string m_inventoryFileName = ""; private LLUUID m_folderID = LLUUID.Zero; - [XmlIgnore] - public PhysicsActor PhysActor = null; + [XmlIgnore] public PhysicsActor PhysActor = null; protected Dictionary<LLUUID, TaskInventoryItem> TaskInventory = new Dictionary<LLUUID, TaskInventoryItem>(); public LLUUID LastOwnerID; @@ -72,25 +76,20 @@ namespace OpenSim.Region.Environment.Scenes private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); private LLUUID m_SitTargetAvatar = LLUUID.Zero; - - // Main grid has default permissions as follows // public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER; - public uint NextOwnerMask = OBJNEXT_OWNER; + public uint NextOwnerMask = OBJNEXT_OWNER; public uint GroupMask = (uint) LLObject.ObjectFlags.None; public uint EveryoneMask = (uint) LLObject.ObjectFlags.None; public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER; protected byte[] m_particleSystem = new byte[0]; - [XmlIgnore] - public uint TimeStampFull = 0; - [XmlIgnore] - public uint TimeStampTerse = 0; - [XmlIgnore] - public uint TimeStampLastActivity = 0; // Will be used for AutoReturn + [XmlIgnore] public uint TimeStampFull = 0; + [XmlIgnore] public uint TimeStampTerse = 0; + [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn /// <summary> /// Only used internally to schedule client updates @@ -145,16 +144,16 @@ namespace OpenSim.Region.Environment.Scenes public uint ObjectFlags { - get { return (uint)m_flags; } - set { m_flags = (LLObject.ObjectFlags)value; } + get { return (uint) m_flags; } + set { m_flags = (LLObject.ObjectFlags) value; } } protected LLObject.MaterialType m_material = 0; public byte Material { - get { return (byte)m_material; } - set { m_material = (LLObject.MaterialType)value; } + get { return (byte) m_material; } + set { m_material = (LLObject.MaterialType) value; } } protected ulong m_regionHandle; @@ -168,7 +167,6 @@ namespace OpenSim.Region.Environment.Scenes //unkown if this will be kept, added as a way of removing the group position from the group class protected LLVector3 m_groupPosition; - public LLVector3 GroupPosition { @@ -225,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes if (PhysActor != null) { if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 - || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) + || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) { m_rotationOffset.X = PhysActor.Orientation.x; m_rotationOffset.Y = PhysActor.Orientation.y; @@ -281,6 +279,7 @@ namespace OpenSim.Region.Environment.Scenes } set { m_velocity = value; } } + public LLVector3 RotationalVelocity { get @@ -351,6 +350,7 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_sitTargetPosition; } } + public Quaternion SitTargetOrientation { get { return m_sitTargetOrientation; } @@ -383,6 +383,7 @@ namespace OpenSim.Region.Environment.Scenes } private int m_linkNum = 0; + public int LinkNum { get { return m_linkNum; } @@ -390,13 +391,14 @@ namespace OpenSim.Region.Environment.Scenes } private byte m_clickAction = 0; + public byte ClickAction { get { return m_clickAction; } set { m_clickAction = value; - this.ScheduleFullUpdate(); + ScheduleFullUpdate(); } } @@ -423,6 +425,7 @@ namespace OpenSim.Region.Environment.Scenes // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. protected SceneObjectGroup m_parentGroup; + public SceneObjectGroup ParentGroup { get { return m_parentGroup; } @@ -434,7 +437,6 @@ namespace OpenSim.Region.Environment.Scenes set { m_updateFlag = value; } } - #region Constructors /// <summary> @@ -469,18 +471,18 @@ namespace OpenSim.Region.Environment.Scenes m_regionHandle = regionHandle; m_parentGroup = parent; - CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; OwnerID = ownerID; CreatorID = OwnerID; LastOwnerID = LLUUID.Zero; UUID = LLUUID.Random(); - LocalID = (uint)(localID); + LocalID = (uint) (localID); Shape = shape; // Todo: Add More Object Parameter from above! OwnershipCost = 0; - ObjectSaleType = (byte)0; + ObjectSaleType = (byte) 0; SalePrice = 0; - Category = (uint)0; + Category = (uint) 0; LastOwnerID = CreatorID; // End Todo: /// GroupPosition = groupPosition; @@ -495,9 +497,9 @@ namespace OpenSim.Region.Environment.Scenes m_folderID = LLUUID.Random(); m_flags = 0; - m_flags |= LLObject.ObjectFlags.Touch | - LLObject.ObjectFlags.AllowInventoryDrop | - LLObject.ObjectFlags.CreateSelected; + m_flags |= LLObject.ObjectFlags.Touch | + LLObject.ObjectFlags.AllowInventoryDrop | + LLObject.ObjectFlags.CreateSelected; ApplySanePermissions(); @@ -520,18 +522,18 @@ namespace OpenSim.Region.Environment.Scenes { m_regionHandle = regionHandle; m_parentGroup = parent; - TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); + TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); CreationDate = creationDate; OwnerID = ownerID; CreatorID = creatorID; LastOwnerID = lastOwnerID; UUID = LLUUID.Random(); - LocalID = (uint)(localID); + LocalID = (uint) (localID); Shape = shape; OwnershipCost = 0; - ObjectSaleType = (byte)0; + ObjectSaleType = (byte) 0; SalePrice = 0; - Category = (uint)0; + Category = (uint) 0; LastOwnerID = CreatorID; OffsetPosition = position; RotationOffset = rotation; @@ -552,18 +554,18 @@ namespace OpenSim.Region.Environment.Scenes /// <returns></returns> public static SceneObjectPart FromXml(XmlReader xmlReader) { - XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); - SceneObjectPart newobject = (SceneObjectPart)serializer.Deserialize(xmlReader); + XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); + SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); return newobject; } public void ApplyPhysics() { - bool isPhysical = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); - bool isPhantom = ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) != 0); + bool isPhysical = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); + bool isPhantom = ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0); bool usePhysics = isPhysical && !isPhantom; - + if (usePhysics) { PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( @@ -576,101 +578,102 @@ namespace OpenSim.Region.Environment.Scenes RotationOffset.Y, RotationOffset.Z), usePhysics); } - DoPhysicsPropertyUpdate(usePhysics, true); + DoPhysicsPropertyUpdate(usePhysics, true); } + public void ApplyNextOwnerPermissions() { BaseMask = NextOwnerMask; OwnerMask = NextOwnerMask; } + public void ApplySanePermissions() { // These are some flags that The OwnerMask should never have - OwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; - OwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - OwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - OwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - OwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Money; - OwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - OwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - OwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - - + OwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Physics; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Touch; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary; + OwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + OwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + OwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + OwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Money; + OwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + OwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + OwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + + // These are some flags that the next owner mask should never have - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Money; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Physics; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Touch; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Money; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + // These are some flags that the GroupMask should never have - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - GroupMask &= ~(uint)LLObject.ObjectFlags.Physics; - GroupMask &= ~(uint)LLObject.ObjectFlags.Phantom; - GroupMask &= ~(uint)LLObject.ObjectFlags.Scripted; - GroupMask &= ~(uint)LLObject.ObjectFlags.Touch; - GroupMask &= ~(uint)LLObject.ObjectFlags.Temporary; - GroupMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - GroupMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - GroupMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - GroupMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - GroupMask &= ~(uint)LLObject.ObjectFlags.Money; - GroupMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - GroupMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - GroupMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + GroupMask &= ~(uint) LLObject.ObjectFlags.Physics; + GroupMask &= ~(uint) LLObject.ObjectFlags.Phantom; + GroupMask &= ~(uint) LLObject.ObjectFlags.Scripted; + GroupMask &= ~(uint) LLObject.ObjectFlags.Touch; + GroupMask &= ~(uint) LLObject.ObjectFlags.Temporary; + GroupMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + GroupMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + GroupMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + GroupMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + GroupMask &= ~(uint) LLObject.ObjectFlags.Money; + GroupMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + GroupMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + GroupMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + // These are some flags that EveryoneMask should never have - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Physics; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Phantom; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Scripted; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Touch; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Temporary; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Money; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Physics; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Phantom; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Scripted; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Touch; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Temporary; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Money; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; - // These are some flags that ObjectFlags (m_flags) should never have - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove; + // These are some flags that ObjectFlags (m_flags) should never have + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOfficer; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectCopy; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectModify; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove; } /// <summary> @@ -679,13 +682,12 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="xmlWriter"></param> public void ToXml(XmlWriter xmlWriter) { - XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); + XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); serializer.Serialize(xmlWriter, this); } public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot) { - // In this case we're using a sphere with a radius of the largest dimention of the prim // TODO: Change to take shape into account @@ -693,35 +695,34 @@ namespace OpenSim.Region.Environment.Scenes EntityIntersection returnresult = new EntityIntersection(); Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z); - Quaternion qRotation = new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); - + Quaternion qRotation = + new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); - Quaternion worldRotation = (qRotation * parentrot); + Quaternion worldRotation = (qRotation*parentrot); Matrix3 worldRotM = worldRotation.ToRotationMatrix(); - Vector3 rOrigin = iray.Origin; Vector3 rDirection = iray.Direction; // Buidling the first part of the Quadratic equation - Vector3 r2ndDirection = rDirection * rDirection; + Vector3 r2ndDirection = rDirection*rDirection; float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; // Buidling the second part of the Quadratic equation Vector3 tmVal2 = rOrigin - vAbsolutePosition; - Vector3 r2Direction = rDirection * 2.0f; - Vector3 tmVal3 = r2Direction * tmVal2; + Vector3 r2Direction = rDirection*2.0f; + Vector3 tmVal3 = r2Direction*tmVal2; float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z; // Buidling the third part of the Quadratic equation - Vector3 tmVal4 = rOrigin * rOrigin; - Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition; + Vector3 tmVal4 = rOrigin*rOrigin; + Vector3 tmVal5 = vAbsolutePosition*vAbsolutePosition; - Vector3 tmVal6 = vAbsolutePosition * rOrigin; + Vector3 tmVal6 = vAbsolutePosition*rOrigin; // Set Radius to the largest dimention of the prim @@ -735,21 +736,22 @@ namespace OpenSim.Region.Environment.Scenes //radius = radius; - float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - (2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius))); + float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - + (2.0f*(tmVal6.x + tmVal6.y + tmVal6.z + (radius*radius))); // Yuk Quadradrics.. Solve first - float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3); + float rootsqr = (itestPart2*itestPart2) - (4.0f*itestPart1*itestPart3); if (rootsqr < 0.0f) { // No intersection return returnresult; } - float root = ((-itestPart2) - (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); + float root = ((-itestPart2) - (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); if (root < 0.0f) { // perform second quadratic root solution - root = ((-itestPart2) + (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); + root = ((-itestPart2) + (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); // is there any intersection? if (root < 0.0f) @@ -761,7 +763,9 @@ namespace OpenSim.Region.Environment.Scenes // We got an intersection. putting together an EntityIntersection object with the // intersection information - Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root), iray.Origin.y + (iray.Direction.y * root), iray.Origin.z + (iray.Direction.z * root)); + Vector3 ipoint = + new Vector3(iray.Origin.x + (iray.Direction.x*root), iray.Origin.y + (iray.Direction.y*root), + iray.Origin.z + (iray.Direction.z*root)); returnresult.HitTF = true; returnresult.ipoint = ipoint; @@ -775,7 +779,7 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x, iray.Origin.y, iray.Origin.z); LLVector3 distanceConvert2 = new LLVector3(ipoint.x, ipoint.y, ipoint.z); - float distance = (float)Util.GetDistanceTo(distanceConvert1, distanceConvert2); + float distance = (float) Util.GetDistanceTo(distanceConvert1, distanceConvert2); returnresult.distance = distance; @@ -783,7 +787,6 @@ namespace OpenSim.Region.Environment.Scenes } - /// <summary> /// /// </summary> @@ -797,6 +800,7 @@ namespace OpenSim.Region.Environment.Scenes m_sitTargetPosition = offset; m_sitTargetOrientation = orientation; } + public LLVector3 GetSitTargetPositionLL() { return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z); @@ -804,13 +808,17 @@ namespace OpenSim.Region.Environment.Scenes public LLQuaternion GetSitTargetOrientationLL() { - return new LLQuaternion( m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z,m_sitTargetOrientation.w); + return + new LLQuaternion(m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z, + m_sitTargetOrientation.w); } // Utility function so the databases don't have to reference axiom.math public void SetSitTargetLL(LLVector3 offset, LLQuaternion orientation) { - if (!(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) && orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0)) + if ( + !(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) && + orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0)) { m_sitTargetPosition = new Vector3(offset.X, offset.Y, offset.Z); m_sitTargetOrientation = new Quaternion(orientation.W, orientation.X, orientation.Y, orientation.Z); @@ -869,7 +877,7 @@ namespace OpenSim.Region.Environment.Scenes /// <returns></returns> public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID) { - SceneObjectPart dupe = (SceneObjectPart)MemberwiseClone(); + SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone(); dupe.m_shape = m_shape.Copy(); dupe.m_regionHandle = m_regionHandle; dupe.UUID = LLUUID.Random(); @@ -896,7 +904,7 @@ namespace OpenSim.Region.Environment.Scenes byte[] extraP = new byte[Shape.ExtraParams.Length]; Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; - bool UsePhysics = ((dupe.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); dupe.DoPhysicsPropertyUpdate(UsePhysics, true); return dupe; @@ -923,7 +931,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - TimeStampFull = (uint)Util.UnixTimeSinceEpoch(); + TimeStampFull = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 2; } @@ -931,11 +939,10 @@ namespace OpenSim.Region.Environment.Scenes { LLObject.ObjectFlags prevflag = m_flags; //uint objflags = m_flags; - if ((ObjectFlags & (uint)flag) == 0) + if ((ObjectFlags & (uint) flag) == 0) { //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); m_flags |= flag; - } //uint currflag = (uint)m_flags; //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); @@ -945,11 +952,10 @@ namespace OpenSim.Region.Environment.Scenes public void RemFlag(LLObject.ObjectFlags flag) { LLObject.ObjectFlags prevflag = m_flags; - if ((ObjectFlags & (uint)flag) != 0) + if ((ObjectFlags & (uint) flag) != 0) { //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); m_flags &= ~flag; - } //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); //ScheduleFullUpdate(); @@ -966,7 +972,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); + TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 1; } } @@ -1074,7 +1080,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_inventorySerial > 0) { - client.SendTaskInventory(m_uuid, (short)m_inventorySerial, + client.SendTaskInventory(m_uuid, (short) m_inventorySerial, Helpers.StringToField(m_inventoryFileName)); return true; } @@ -1134,7 +1140,7 @@ namespace OpenSim.Region.Environment.Scenes bool IsTemporary = false; bool IsPhantom = false; bool castsShadows = false; - bool wasUsingPhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); //bool IsLocked = false; int i = 0; @@ -1162,7 +1168,6 @@ namespace OpenSim.Region.Environment.Scenes { DoPhysicsPropertyUpdate(usePhysics, false); } - } else { @@ -1174,9 +1179,6 @@ namespace OpenSim.Region.Environment.Scenes } - - - if (IsPhantom) { AddFlag(LLObject.ObjectFlags.Phantom); @@ -1220,19 +1222,18 @@ namespace OpenSim.Region.Environment.Scenes // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); ScheduleFullUpdate(); } + public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) { - if (PhysActor != null) { if (UsePhysics != PhysActor.IsPhysical || isNew) { - if (PhysActor.IsPhysical) { if (!isNew) - this.ParentGroup.m_scene.RemovePhysicalPrim(1); - + ParentGroup.m_scene.RemovePhysicalPrim(1); + PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; } @@ -1244,7 +1245,7 @@ namespace OpenSim.Region.Environment.Scenes //PhysActor = null; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { //PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( //Name, @@ -1256,8 +1257,8 @@ namespace OpenSim.Region.Environment.Scenes //RotationOffset.Y, RotationOffset.Z), UsePhysics); if (UsePhysics) { - this.ParentGroup.m_scene.AddPhysicalPrim(1); - + ParentGroup.m_scene.AddPhysicalPrim(1); + PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds += PhysicsOutOfBounds; } @@ -1271,15 +1272,15 @@ namespace OpenSim.Region.Environment.Scenes { m_shape.ExtraParams = new byte[data.Length + 7]; int i = 0; - uint length = (uint)data.Length; + uint length = (uint) data.Length; m_shape.ExtraParams[i++] = 1; - m_shape.ExtraParams[i++] = (byte)(type % 256); - m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); + m_shape.ExtraParams[i++] = (byte) (type%256); + m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256); - m_shape.ExtraParams[i++] = (byte)(length % 256); - m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); - m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); - m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); + m_shape.ExtraParams[i++] = (byte) (length%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 8)%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 16)%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 24)%256); Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length); ScheduleFullUpdate(); @@ -1305,7 +1306,7 @@ namespace OpenSim.Region.Environment.Scenes { if (PhysActor != null) { - return new LLVector3(PhysActor.CenterOfMass.X,PhysActor.CenterOfMass.Y,PhysActor.CenterOfMass.Z); + return new LLVector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); } else { @@ -1323,7 +1324,7 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="textureEntry"></param> public void UpdateTextureEntry(byte[] textureEntry) { - m_shape.Textures = new LLObject.TextureEntry( textureEntry, 0, textureEntry.Length ); + m_shape.Textures = new LLObject.TextureEntry(textureEntry, 0, textureEntry.Length); ScheduleFullUpdate(); } @@ -1337,20 +1338,20 @@ namespace OpenSim.Region.Environment.Scenes { if (tex.FaceTextures[i] != null) { - tmpcolor = tex.GetFace((uint)i).RGBA; - tmpcolor.A = tmpcolor.A * 255; - tmpcolor.R = tmpcolor.R * 255; - tmpcolor.G = tmpcolor.G * 255; - tmpcolor.B = tmpcolor.B * 255; + tmpcolor = tex.GetFace((uint) i).RGBA; + tmpcolor.A = tmpcolor.A*255; + tmpcolor.R = tmpcolor.R*255; + tmpcolor.G = tmpcolor.G*255; + tmpcolor.B = tmpcolor.B*255; tex.FaceTextures[i].RGBA = tmpcolor; } } tmpcolor = tex.DefaultTexture.RGBA; - tmpcolor.A = tmpcolor.A * 255; - tmpcolor.R = tmpcolor.R * 255; - tmpcolor.G = tmpcolor.G * 255; - tmpcolor.B = tmpcolor.B * 255; - tex.DefaultTexture.RGBA = tmpcolor; + tmpcolor.A = tmpcolor.A*255; + tmpcolor.R = tmpcolor.R*255; + tmpcolor.G = tmpcolor.G*255; + tmpcolor.B = tmpcolor.B*255; + tex.DefaultTexture.RGBA = tmpcolor; UpdateTextureEntry(tex.ToBytes()); } @@ -1416,34 +1417,33 @@ namespace OpenSim.Region.Environment.Scenes // Are we the owner? if (AgentID == OwnerID) { - MainLog.Instance.Verbose("PERMISSIONS", "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + addRemTF.ToString()); - + MainLog.Instance.Verbose("PERMISSIONS", + "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + + addRemTF.ToString()); + //Field 8 = EveryoneMask - if (field == (byte)8) + if (field == (byte) 8) { MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask)); - if (addRemTF == (byte)0) + if (addRemTF == (byte) 0) { //EveryoneMask = (uint)0; EveryoneMask &= ~mask; //EveryoneMask &= ~(uint)57344; - - } else { //EveryoneMask = (uint)0; EveryoneMask |= mask; //EveryoneMask |= (uint)57344; - } //ScheduleFullUpdate(); SendFullUpdateToAllClients(); } //Field 16 = NextownerMask - if (field == (byte)16) + if (field == (byte) 16) { - if (addRemTF == (byte)0) + if (addRemTF == (byte) 0) { NextOwnerMask &= ~mask; } @@ -1453,7 +1453,6 @@ namespace OpenSim.Region.Environment.Scenes } SendFullUpdateToAllClients(); } - } } @@ -1482,7 +1481,8 @@ namespace OpenSim.Region.Environment.Scenes for (int i = 0; i < avatars.Count; i++) { // Ugly reference :( - m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, avatars[i].GenerateClientFlags(this.UUID)); + m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, + avatars[i].GenerateClientFlags(UUID)); } } @@ -1515,19 +1515,19 @@ namespace OpenSim.Region.Environment.Scenes { LLQuaternion lRot; lRot = RotationOffset; - clientFlags &= ~(uint)LLObject.ObjectFlags.CreateSelected; + clientFlags &= ~(uint) LLObject.ObjectFlags.CreateSelected; - if (remoteClient.AgentId == OwnerID) + if (remoteClient.AgentId == OwnerID) { - if ((uint)(m_flags & LLObject.ObjectFlags.CreateSelected) != 0) + if ((uint) (m_flags & LLObject.ObjectFlags.CreateSelected) != 0) { - clientFlags |= (uint)LLObject.ObjectFlags.CreateSelected; + clientFlags |= (uint) LLObject.ObjectFlags.CreateSelected; m_flags &= ~LLObject.ObjectFlags.CreateSelected; } } - byte[] color = new byte[] { m_color.R, m_color.G, m_color.B, m_color.A }; + byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid, OwnerID, m_text, color, ParentID, m_particleSystem, lRot, m_clickAction); @@ -1574,26 +1574,28 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 lPos; lPos = OffsetPosition; LLQuaternion mRot = RotationOffset; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, + RotationalVelocity); } } public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) { LLQuaternion mRot = RotationOffset; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, + RotationalVelocity); //System.Console.WriteLine("RVel:" + RotationalVelocity); } } @@ -1603,13 +1605,16 @@ namespace OpenSim.Region.Environment.Scenes public virtual void UpdateMovement() { } + #region Events + public void PhysicsRequestingTerseUpdate() { ScheduleTerseUpdate(); //SendTerseUpdateToAllClients(); } + #endregion public void PhysicsOutOfBounds(PhysicsVector pos) @@ -1626,10 +1631,10 @@ namespace OpenSim.Region.Environment.Scenes public void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int)(alpha * 0xff), - (int)(color.x * 0xff), - (int)(color.y * 0xff), - (int)(color.z * 0xff)); + Color = Color.FromArgb(0xff - (int) (alpha*0xff), + (int) (color.x*0xff), + (int) (color.y*0xff), + (int) (color.z*0xff)); Text = text; } @@ -1725,7 +1730,6 @@ namespace OpenSim.Region.Environment.Scenes public TaskInventoryItem() { } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 9a937a2..9454de0 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -32,7 +32,6 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Communications; using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; @@ -60,14 +59,14 @@ namespace OpenSim.Region.Environment.Scenes private bool m_setAlwaysRun = false; private Quaternion m_bodyRot; - + public bool IsRestrictedToRegion = false; // Agent moves with a PID controller causing a force to be exerted. private bool m_newForce = false; private bool m_newCoarseLocations = true; private bool m_gotAllObjectsInScene = false; - + // Default AV Height private float m_avHeight = 127.0f; @@ -76,7 +75,7 @@ namespace OpenSim.Region.Environment.Scenes private readonly Vector3[] Dir_Vectors = new Vector3[6]; private LLVector3 lastPhysPos = new LLVector3(); - + // Position of agent's camera in world (region cordinates) protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); @@ -85,17 +84,18 @@ namespace OpenSim.Region.Environment.Scenes protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0); protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0); protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0); - private uint m_AgentControlFlags = (uint)0; + private uint m_AgentControlFlags = (uint) 0; private LLQuaternion m_headrotation = new LLQuaternion(); - private byte m_state = (byte)0; + private byte m_state = (byte) 0; // Agent's Draw distance. protected float m_DrawDistance = 0f; protected AvatarAppearance m_appearance; - private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in - + private readonly List<ulong> m_knownChildRegions = new List<ulong>(); + //neighbouring regions we have enabled a child agent in + /// <summary> /// Implemented Control Flags @@ -172,6 +172,7 @@ namespace OpenSim.Region.Environment.Scenes } protected bool m_allowMovement = true; + public bool AllowMovement { get { return m_allowMovement; } @@ -181,8 +182,8 @@ namespace OpenSim.Region.Environment.Scenes /// <summary> /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager /// </summary> - private readonly IClientAPI m_controllingClient; + protected PhysicsActor m_physicsActor; public IClientAPI ControllingClient @@ -228,6 +229,7 @@ namespace OpenSim.Region.Environment.Scenes m_pos = value; } } + /// <summary> /// Current Velocity of the avatar. /// </summary> @@ -294,6 +296,7 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_knownChildRegions; } } + #endregion #region Constructor(s) @@ -336,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) : this(client, world, reginfo) { - m_appearance = appearance; + m_appearance = appearance; } private void RegisterToEvents() @@ -366,6 +369,7 @@ namespace OpenSim.Region.Environment.Scenes Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge } + #endregion public void QueuePartForUpdate(SceneObjectPart part) @@ -381,7 +385,7 @@ namespace OpenSim.Region.Environment.Scenes public uint GenerateClientFlags(LLUUID ObjectID) { - return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID); + return m_scene.PermissionsMngr.GenerateClientFlags(m_uuid, ObjectID); } public void SendPrimUpdates() @@ -461,6 +465,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Status Methods + /// <summary> /// This turns a child agent, into a root agent /// This is called when an agent teleports into a region, or if an @@ -531,6 +536,7 @@ namespace OpenSim.Region.Environment.Scenes public void StopMovement() { } + public void StopFlying() { // It turns out to get the agent to stop flying, you have to feed it stop flying velocities @@ -560,9 +566,11 @@ namespace OpenSim.Region.Environment.Scenes m_knownChildRegions.Remove(regionHandle); } } + #endregion #region Event Handlers + /// <summary> /// Sets avatar height in the phyiscs plugin /// </summary> @@ -603,7 +611,6 @@ namespace OpenSim.Region.Environment.Scenes /// </summary> public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData) { - //if (m_isChildAgent) //{ // // Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); @@ -639,7 +646,7 @@ namespace OpenSim.Region.Environment.Scenes // The Agent's Draw distance setting m_DrawDistance = agentData.AgentData.Far; - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); } @@ -649,7 +656,7 @@ namespace OpenSim.Region.Environment.Scenes return; } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) + if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { // TODO: This doesn't quite work yet -- probably a parent ID problem // m_parentID = (what should this be?) @@ -672,7 +679,7 @@ namespace OpenSim.Region.Environment.Scenes Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); bool oldflying = PhysicsActor.Flying; - PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + PhysicsActor.Flying = ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); if (PhysicsActor.Flying != oldflying) { update_movementflag = true; @@ -686,23 +693,23 @@ namespace OpenSim.Region.Environment.Scenes if (m_parentID == 0) { - foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) + foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags))) { - if ((flags & (uint)DCF) != 0) + if ((flags & (uint) DCF) != 0) { DCFlagKeyPressed = true; agent_control_v3 += Dir_Vectors[i]; - if ((m_movementflag & (uint)DCF) == 0) + if ((m_movementflag & (uint) DCF) == 0) { - m_movementflag += (byte)(uint)DCF; + m_movementflag += (byte) (uint) DCF; update_movementflag = true; } } else { - if ((m_movementflag & (uint)DCF) != 0) + if ((m_movementflag & (uint) DCF) != 0) { - m_movementflag -= (byte)(uint)DCF; + m_movementflag -= (byte) (uint) DCF; update_movementflag = true; } } @@ -719,8 +726,9 @@ namespace OpenSim.Region.Environment.Scenes if (m_physicsActor.Flying) { // Are the landing controls requirements filled? - bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - + bool controlland = (((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || + ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + // Are the collision requirements fulfilled? bool colliding = (m_physicsActor.IsColliding == true); @@ -748,7 +756,6 @@ namespace OpenSim.Region.Environment.Scenes { if (m_parentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); if (part != null) { @@ -757,7 +764,7 @@ namespace OpenSim.Region.Environment.Scenes part.SetAvatarOnSitTarget(LLUUID.Zero); } - m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); m_parentPosition = new LLVector3(); if (m_physicsActor == null) @@ -778,14 +785,14 @@ namespace OpenSim.Region.Environment.Scenes bool autopilot = true; LLVector3 pos = new LLVector3(); - LLQuaternion sitOrientation = new LLQuaternion(0,0,0,1); + LLQuaternion sitOrientation = new LLQuaternion(0, 0, 0, 1); SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); if (part != null) { // TODO: determine position to sit at based on scene geometry; don't trust offset from client // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - + // Is a sit target available? Vector3 avSitOffSet = part.GetSitTargetPosition(); @@ -793,15 +800,17 @@ namespace OpenSim.Region.Environment.Scenes LLUUID avOnTargetAlready = part.GetAvatarOnSitTarget(); bool SitTargetUnOccupied = (!(avOnTargetAlready != LLUUID.Zero)); - bool SitTargetisSet = (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1)); + bool SitTargetisSet = + (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && + avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1)); if (SitTargetisSet && SitTargetUnOccupied) { part.SetAvatarOnSitTarget(UUID); - offset = new LLVector3(avSitOffSet.x,avSitOffSet.y,avSitOffSet.z); - sitOrientation = new LLQuaternion(avSitOrientation.w,avSitOrientation.x,avSitOrientation.y,avSitOrientation.z); + offset = new LLVector3(avSitOffSet.x, avSitOffSet.y, avSitOffSet.z); + sitOrientation = + new LLQuaternion(avSitOrientation.w, avSitOrientation.x, avSitOrientation.y, avSitOrientation.z); autopilot = false; - } @@ -817,43 +826,37 @@ namespace OpenSim.Region.Environment.Scenes if (autopilot) { - if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) { autopilot = false; - + RemoveFromPhysicalScene(); AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); - } - else + else { - } } else { RemoveFromPhysicalScene(); - - } } // Physactor != null } // part != null - + avatarSitResponse.SitTransform.AutoPilot = autopilot; avatarSitResponse.SitTransform.SitPosition = offset; avatarSitResponse.SitTransform.SitRotation = sitOrientation; remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); - + // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location // It doesn't get to the location until we've moved them there though // which happens in HandleAgentSit :P if (!autopilot) HandleAgentSit(remoteClient, UUID); - } public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) @@ -863,7 +866,6 @@ namespace OpenSim.Region.Environment.Scenes StandUp(); } - SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); @@ -919,7 +921,6 @@ namespace OpenSim.Region.Environment.Scenes // This may seem stupid, but Our Full updates don't send avatar rotation :P // So we're also sending a terse update (which has avatar rotation) SendTerseUpdateToAllClients(); - } /// <summary> @@ -1003,7 +1004,7 @@ namespace OpenSim.Region.Environment.Scenes // We are flying SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); } - else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && + else if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) { // Client is pressing the page down button and moving and is colliding with something @@ -1014,7 +1015,8 @@ namespace OpenSim.Region.Environment.Scenes // Client is moving and falling at a velocity greater then 6 meters per unit SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && + (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { // Client is moving, and colliding and pressing the page up button but isn't flying SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); @@ -1034,7 +1036,7 @@ namespace OpenSim.Region.Environment.Scenes { // Not moving - if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && + if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) { // Client pressing the page down button @@ -1045,7 +1047,8 @@ namespace OpenSim.Region.Environment.Scenes // Not colliding and not flying, and we're falling at high speed SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && + (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { // This is the standing jump SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); @@ -1063,6 +1066,7 @@ namespace OpenSim.Region.Environment.Scenes } } } + /// <summary> /// Adds a new movement /// </summary> @@ -1075,10 +1079,10 @@ namespace OpenSim.Region.Environment.Scenes } m_rotation = rotation; NewForce newVelocity = new NewForce(); - Vector3 direc = rotation * vec; + Vector3 direc = rotation*vec; direc.Normalize(); - direc *= 0.03f * 128f; + direc *= 0.03f*128f; if (m_physicsActor.Flying) { direc *= 4; @@ -1108,7 +1112,6 @@ namespace OpenSim.Region.Environment.Scenes SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); } } - } newVelocity.X = direc.x; @@ -1173,7 +1176,7 @@ namespace OpenSim.Region.Environment.Scenes { LLVector3 pos = m_pos; LLVector3 vel = Velocity; - LLQuaternion rot=new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); + LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); remoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z), rot); } @@ -1213,7 +1216,8 @@ namespace OpenSim.Region.Environment.Scenes public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) { remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, - LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); + LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), + m_parentID); } /// <summary> @@ -1303,10 +1307,8 @@ namespace OpenSim.Region.Environment.Scenes /// <param name="seqs"></param> public void SendAnimPack(LLUUID[] animations, int[] seqs) { - m_scene.Broadcast(delegate(IClientAPI client) - { - client.SendAnimations(animations, seqs, m_controllingClient.AgentId); - }); + m_scene.Broadcast( + delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId); }); } /// <summary> @@ -1320,6 +1322,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Significant Movement Method + /// <summary> /// This checks for a significant movement and sends a courselocationchange update /// </summary> @@ -1349,9 +1352,9 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 vel = Velocity; float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); + pos2.X = pos2.X + (vel.X*timeStep); + pos2.Y = pos2.Y + (vel.Y*timeStep); + pos2.Z = pos2.Z + (vel.Z*timeStep); if ((pos2.X < 0) || (pos2.X > 256)) { @@ -1411,7 +1414,7 @@ namespace OpenSim.Region.Environment.Scenes } LLVector3 vel = m_velocity; - ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); + ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256)); SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); if (neighbourRegion != null) { @@ -1432,6 +1435,7 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + /// <summary> /// This allows the Sim owner the abiility to kick users from their sim currently. /// It tells the client that the agent has permission to do so. @@ -1445,7 +1449,7 @@ namespace OpenSim.Region.Environment.Scenes adb.AgentID = agentID; adb.SessionID = sessionID; // More security - gdb.GodLevel = (byte)100; + gdb.GodLevel = (byte) 100; gdb.Token = token; //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; respondPacket.GrantData = gdb; @@ -1462,7 +1466,8 @@ namespace OpenSim.Region.Environment.Scenes // m_DrawDistance = cAgentData.drawdistance; m_pos = new LLVector3(cAgentData.Position.x, cAgentData.Position.y, cAgentData.Position.z); - m_CameraCenter = new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); + m_CameraCenter = + new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); m_godlevel = cAgentData.godlevel; ControllingClient.SetChildAgentThrottle(cAgentData.throttles); //cAgentData.AVHeight; @@ -1555,6 +1560,7 @@ namespace OpenSim.Region.Environment.Scenes m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; } + // Event called by the physics plugin to tell the avatar about a collision. private void PhysicsCollisionUpdate(EventArgs e) { @@ -1567,4 +1573,4 @@ namespace OpenSim.Region.Environment.Scenes RemoveFromPhysicalScene(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index aeb9c61..8c4a951 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs @@ -28,17 +28,16 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Xml; using System.IO; -using libsecondlife; +using System.Xml; using Axiom.Math; +using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { - public class SceneXmlLoader // can move to a module? + public class SceneXmlLoader // can move to a module? { protected InnerScene m_innerScene; protected RegionInfo m_regInfo; @@ -78,8 +77,9 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); // Apply loadOffsets for load/import and move combinations rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && + m_parentScene.m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( rootPart.Name, @@ -91,7 +91,6 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - } primCount++; } @@ -115,7 +114,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); primCount++; } } @@ -152,8 +151,9 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.AddEntityFromStorage(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && + m_parentScene.m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( rootPart.Name, @@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2()); primCount++; } } @@ -188,6 +188,5 @@ namespace OpenSim.Region.Environment.Scenes stream.Close(); file.Close(); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs index 294a6c9..d781806 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting void Shutdown(); // void StartScript(string ScriptID, IScriptHost ObjectID); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs index d3fdad6..5dbe500 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs @@ -121,4 +121,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting return ret; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index bfdacfe..b183c04 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -27,22 +27,19 @@ */ using System; -using System.Collections.Generic; -using System.Text; using System.Timers; using libsecondlife.Packets; using OpenSim.Framework; -using Timer = System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { public class SimStatsReporter { public delegate void SendStatResult(SimStatsPacket pack); - + public event SendStatResult OnSendStatsResult; - private enum Stats : uint + private enum Stats : uint { TimeDilation = 0, SimFPS = 1, @@ -72,7 +69,7 @@ namespace OpenSim.Region.Environment.Scenes private RegionInfo ReportingRegion; private Timer m_report = new Timer(); - + public SimStatsReporter(RegionInfo regionData) { @@ -93,23 +90,24 @@ namespace OpenSim.Region.Environment.Scenes statpack.Region.RegionY = ReportingRegion.RegionLocY; try { - statpack.Region.RegionFlags = (uint)ReportingRegion.EstateSettings.regionFlags; + statpack.Region.RegionFlags = (uint) ReportingRegion.EstateSettings.regionFlags; } - catch(System.Exception) + catch (Exception) { - statpack.Region.RegionFlags = (uint)0; + statpack.Region.RegionFlags = (uint) 0; } - statpack.Region.ObjectCapacity = (uint)15000; + statpack.Region.ObjectCapacity = (uint) 15000; #region various statistic googly moogly - float simfps = (int)(m_fps * 5); + + float simfps = (int) (m_fps*5); if (simfps > 45) simfps = simfps - (simfps - 45); if (simfps < 0) simfps = 0; - float physfps = (m_pfps / statsUpdatesEveryMS); + float physfps = (m_pfps/statsUpdatesEveryMS); if (physfps > 50) physfps = physfps - (physfps - 50); @@ -120,49 +118,49 @@ namespace OpenSim.Region.Environment.Scenes #endregion sb[0] = new SimStatsPacket.StatBlock(); - sb[0].StatID = (uint)Stats.TimeDilation; + sb[0].StatID = (uint) Stats.TimeDilation; sb[0].StatValue = (m_timeDilation); sb[1] = new SimStatsPacket.StatBlock(); - sb[1].StatID = (uint)Stats.SimFPS; + sb[1].StatID = (uint) Stats.SimFPS; sb[1].StatValue = simfps; sb[2] = new SimStatsPacket.StatBlock(); - sb[2].StatID = (uint)Stats.PhysicsFPS; + sb[2].StatID = (uint) Stats.PhysicsFPS; sb[2].StatValue = physfps; sb[3] = new SimStatsPacket.StatBlock(); - sb[3].StatID = (uint)Stats.AgentUpdates; - sb[3].StatValue = (m_agentUpdates / statsUpdatesEveryMS); + sb[3].StatID = (uint) Stats.AgentUpdates; + sb[3].StatValue = (m_agentUpdates/statsUpdatesEveryMS); sb[4] = new SimStatsPacket.StatBlock(); - sb[4].StatID = (uint)Stats.Agents; + sb[4].StatID = (uint) Stats.Agents; sb[4].StatValue = m_rootAgents; sb[5] = new SimStatsPacket.StatBlock(); - sb[5].StatID = (uint)Stats.ChildAgents; + sb[5].StatID = (uint) Stats.ChildAgents; sb[5].StatValue = m_childAgents; sb[6] = new SimStatsPacket.StatBlock(); - sb[6].StatID = (uint)Stats.TotalPrim; + sb[6].StatID = (uint) Stats.TotalPrim; sb[6].StatValue = m_numPrim; sb[7] = new SimStatsPacket.StatBlock(); - sb[7].StatID = (uint)Stats.ActivePrim; + sb[7].StatID = (uint) Stats.ActivePrim; sb[7].StatValue = m_activePrim; sb[8] = new SimStatsPacket.StatBlock(); - sb[8].StatID = (uint)Stats.InPacketsPerSecond; - sb[8].StatValue = (int)(m_inPacketsPerSecond / statsUpdatesEveryMS); + sb[8].StatID = (uint) Stats.InPacketsPerSecond; + sb[8].StatValue = (int) (m_inPacketsPerSecond/statsUpdatesEveryMS); sb[9] = new SimStatsPacket.StatBlock(); - sb[9].StatID = (uint)Stats.OutPacketsPerSecond; - sb[9].StatValue = (int)(m_outPacketsPerSecond / statsUpdatesEveryMS); + sb[9].StatID = (uint) Stats.OutPacketsPerSecond; + sb[9].StatValue = (int) (m_outPacketsPerSecond/statsUpdatesEveryMS); sb[10] = new SimStatsPacket.StatBlock(); - sb[10].StatID = (uint)Stats.UnAckedBytes; - sb[10].StatValue = (int) (m_unAckedBytes / statsUpdatesEveryMS); - + sb[10].StatID = (uint) Stats.UnAckedBytes; + sb[10].StatValue = (int) (m_unAckedBytes/statsUpdatesEveryMS); + statpack.Stat = sb; if (OnSendStatsResult != null) @@ -181,8 +179,8 @@ namespace OpenSim.Region.Environment.Scenes m_inPacketsPerSecond = 0; m_outPacketsPerSecond = 0; m_unAckedBytes = 0; - } + public void SetTimeDilation(float td) { m_timeDilation = td; @@ -191,47 +189,56 @@ namespace OpenSim.Region.Environment.Scenes if (m_timeDilation < 0) m_timeDilation = 0.0f; - } + public void SetRootAgents(int rootAgents) { m_rootAgents = rootAgents; } + public void SetChildAgents(int childAgents) { m_childAgents = childAgents; } + public void SetObjects(int objects) { m_numPrim = objects; } + public void SetActiveObjects(int objects) { m_activePrim = objects; } + public void AddFPS(int frames) { m_fps += frames; } + public void AddPhysicsFPS(float frames) { m_pfps += frames; } + public void AddAgentUpdates(float numUpdates) { m_agentUpdates += numUpdates; } + public void AddInPackets(int numPackets) { m_inPacketsPerSecond += numPackets; } + public void AddOutPackets(int numPackets) { m_outPacketsPerSecond += numPackets; } + public void AddunAckedBytes(int numBytes) { m_unAckedBytes += numBytes; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs index b3084a2..2d8441e 100644 --- a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs @@ -26,7 +26,6 @@ * */ -using System; using System.IO; using libsecondlife; using OpenSim.Framework; diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index ec93362..3e191b4 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Net; -using System.Text; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; @@ -62,7 +61,7 @@ namespace SimpleApp public event LinkObjects OnLinkObjects; public event DelinkObjects OnDelinkObjects; public event RequestMapBlocks OnRequestMapBlocks; - public event RequestMapName OnMapNameRequest; + public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties; @@ -139,7 +138,7 @@ namespace SimpleApp public event EstateOwnerMessageRequest OnEstateOwnerMessage; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; - + #pragma warning restore 67 @@ -168,7 +167,7 @@ namespace SimpleApp { get { return LLUUID.Zero; } } - + public LLUUID SecureSessionId { get { return LLUUID.Zero; } @@ -185,7 +184,7 @@ namespace SimpleApp { get { return lastName; } } - + public virtual String Name { get { return FirstName + LastName; } @@ -314,7 +313,8 @@ namespace SimpleApp public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, - LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, + LLUUID objectID, LLUUID ownerID, string text, byte[] color, + uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction) { } @@ -323,14 +323,16 @@ namespace SimpleApp LLVector3 position, LLQuaternion rotation) { } + public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, - LLVector3 position, LLQuaternion rotation,LLVector3 velocity, LLVector3 rotationalvelocity) + LLVector3 position, LLQuaternion rotation, LLVector3 velocity, + LLVector3 rotationalvelocity) { } - public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, - List<InventoryItemBase> items, - List<InventoryFolderBase> folders, + public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, + List<InventoryItemBase> items, + List<InventoryFolderBase> folders, bool fetchFolders, bool fetchItems) { @@ -376,9 +378,11 @@ namespace SimpleApp public void SendAgentAlertMessage(string message, bool modal) { } + public void SendSystemAlertMessage(string message) { } + public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { @@ -477,7 +481,6 @@ namespace SimpleApp public void Stop() { - } private uint m_circuitCode; @@ -492,4 +495,4 @@ namespace SimpleApp { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index d5f702d..4c12b3f 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs @@ -41,10 +41,13 @@ namespace SimpleApp { private List<ScenePresence> m_avatars; - public MyWorld(RegionInfo regionInfo, AgentCircuitManager authen, PermissionManager permissionManager, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, + public MyWorld(RegionInfo regionInfo, AgentCircuitManager authen, PermissionManager permissionManager, + CommunicationsManager commsMan, SceneCommunicationService sceneGridService, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, ModuleLoader moduleLoader, bool physicalPrim, bool ChildGetTasks) - : base(regionInfo, authen, permissionManager, commsMan, sceneGridService, assetCach, storeMan, httpServer, moduleLoader, false, true, false) + : base( + regionInfo, authen, permissionManager, commsMan, sceneGridService, assetCach, storeMan, httpServer, + moduleLoader, false, true, false) { m_avatars = new List<ScenePresence>(); } @@ -73,7 +76,7 @@ namespace SimpleApp client.OnCompleteMovementToRegion += delegate() { client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero); }; - + client.SendRegionHandshake(m_regInfo); } } diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 02108d0..d872bf6 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -179,7 +179,8 @@ namespace SimpleApp PermissionManager permissionManager = new PermissionManager(); SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); return - new MyWorld(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, + new MyWorld(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, + m_assetCache, storageManager, m_httpServer, new ModuleLoader(m_log, m_config), true, false); } @@ -214,4 +215,4 @@ namespace SimpleApp app.Run(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs index 89c3743..b625f43 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs @@ -101,4 +101,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp return LoadDotNetScript(csharpProvider, filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs index 09b7f48..a25d027 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs @@ -91,4 +91,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples return ""; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs index 425c3a4..bc5c413 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs @@ -101,4 +101,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JScript return LoadDotNetScript(jscriptProvider, filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs index 7a2a96b..c12fda5 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs @@ -40,4 +40,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs index adf7d66..b152df2 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs @@ -645,4 +645,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs index 500c991..4308a19 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs index 03e0756..d9f5ce1 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs @@ -616,4 +616,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs index 25bc2a8..fb8a16e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs @@ -99,4 +99,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs index 9580159..60cf8d4 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs @@ -33,4 +33,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs index 3634c24..64e9275 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs @@ -129,4 +129,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs index 9a06cad..6e62d5a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs @@ -38,4 +38,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM HeapArea = new Heap(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs index d73fec6..2d3fc47 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs @@ -41,4 +41,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM MethodBuffer = new byte[20000]; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs index bad71c9..f17bf43 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs @@ -30,4 +30,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public class Object { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs index 88d5af0..ff01307 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs index a73ebd0..40bec4c 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs @@ -43,4 +43,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM LocalVariables = new BaseType[20]; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs index 50c9c09..7f3af0e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs @@ -108,4 +108,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM return m_Interpreter.Excute(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs index 00c2d1c..449f715 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs @@ -163,4 +163,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Script.cs b/OpenSim/Region/ExtensionsScriptModule/Script.cs index 3a9edfe..0555277 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Script.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Script.cs @@ -61,4 +61,4 @@ namespace OpenSim.Region.ExtensionsScriptModule //script.logger.Verbose("TESTSCRIPT", "Hello World!"); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs index 4fccef1..af54a4e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs @@ -61,4 +61,4 @@ namespace OpenSim.Region.ExtensionsScriptModule api = new ScriptAPI(world, task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index 1f26d22..d080ab8 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -146,4 +146,4 @@ namespace OpenSim.Region.ExtensionsScriptModule Dictionary<string, IScript> compile(string filename); string FileExt(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs index 919910c..b76fbbf 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 5ac651f..636cf1a 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -106,18 +106,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { return null; } + public override void AddPhysicsActorTaint(PhysicsActor prim) { - } + public override float Simulate(float timeStep) { float fps = 0; @@ -125,8 +126,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { BasicActor actor = _actors[i]; - actor.Position.X += actor.Velocity.X * timeStep; - actor.Position.Y += actor.Velocity.Y * timeStep; + actor.Position.X += actor.Velocity.X*timeStep; + actor.Position.Y += actor.Velocity.Y*timeStep; if (actor.Position.Y < 0) { @@ -146,18 +147,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin actor.Position.X = 255.9F; } - float height = _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 1.0f; + float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f; if (actor.Flying) { - if (actor.Position.Z + (actor.Velocity.Z * timeStep) < - _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 2) + if (actor.Position.Z + (actor.Velocity.Z*timeStep) < + _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2) { actor.Position.Z = height; actor.Velocity.Z = 0; } else { - actor.Position.Z += actor.Velocity.Z * timeStep; + actor.Position.Z += actor.Velocity.Z*timeStep; } } else @@ -204,31 +205,37 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin _position = new PhysicsVector(); _acceleration = new PhysicsVector(); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } @@ -240,16 +247,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get { return _position; } @@ -264,27 +274,29 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } } + public override PhysicsVector Velocity { get { return _velocity; } @@ -321,4 +333,4 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs index 06d4fe3..6b7ce82 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.0.0")] +[assembly : AssemblyVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 5602301..a88299e 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -70,12 +70,11 @@ using XnaDevRu.BulletX; using XnaDevRu.BulletX.Dynamics; using AxiomQuaternion = Axiom.Math.Quaternion; using BoxShape=XnaDevRu.BulletX.BoxShape; -#endregion +#endregion namespace OpenSim.Region.Physics.BulletXPlugin { - /// <summary> /// BulletXConversions are called now BulletXMaths /// This Class converts objects and types for BulletX and give some operations @@ -263,25 +262,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin // Class to detect and debug collisions // Mainly used for debugging purposes - class CollisionDispatcherLocal : CollisionDispatcher + internal class CollisionDispatcherLocal : CollisionDispatcher { - - BulletXScene relatedScene; + private BulletXScene relatedScene; public CollisionDispatcherLocal(BulletXScene s) : base() { - relatedScene=s; + relatedScene = s; } public override bool NeedsCollision(CollisionObject bodyA, CollisionObject bodyB) { RigidBody rb; - BulletXCharacter bxcA=null; + BulletXCharacter bxcA = null; BulletXPrim bxpA = null; Type t = bodyA.GetType(); - if (t==typeof(RigidBody)) { - rb = (RigidBody)bodyA; + if (t == typeof (RigidBody)) + { + rb = (RigidBody) bodyA; relatedScene._characters.TryGetValue(rb, out bxcA); relatedScene._prims.TryGetValue(rb, out bxpA); } @@ -296,9 +295,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin BulletXCharacter bxcB = null; BulletXPrim bxpB = null; t = bodyB.GetType(); - if (t == typeof(RigidBody)) + if (t == typeof (RigidBody)) { - rb = (RigidBody)bodyB; + rb = (RigidBody) bodyB; relatedScene._characters.TryGetValue(rb, out bxcB); relatedScene._prims.TryGetValue(rb, out bxpB); } @@ -310,15 +309,16 @@ namespace OpenSim.Region.Physics.BulletXPlugin else nameB = "null"; - bool needsCollision=base.NeedsCollision(bodyA, bodyB); + bool needsCollision = base.NeedsCollision(bodyA, bodyB); - MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB, needsCollision); + MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB, + needsCollision); return needsCollision; } } - + /// <summary> /// PhysicsScene Class for BulletX /// </summary> @@ -439,7 +439,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation; AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody); } - _characters.Remove(((BulletXCharacter)actor).RigidBody); + _characters.Remove(((BulletXCharacter) actor).RigidBody); } GC.Collect(); } @@ -448,8 +448,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation) { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation, bool isPhysical) { @@ -514,7 +515,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override void AddPhysicsActorTaint(PhysicsActor prim) { - } public override float Simulate(float timeStep) @@ -526,10 +526,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin RemoveForgottenRigidBodies(); //End of remove MoveAllObjects(timeStep); - - - fps = (timeStep * simulationSubSteps); - + + + fps = (timeStep*simulationSubSteps); + ddWorld.StepSimulation(timeStep, simulationSubSteps, timeStep); //Extra Heightmap Validation: BulletX's HeightFieldTerrain somestimes doesn't work so fine. ValidateHeightForAll(); @@ -768,7 +768,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override PhysicsVector Size { get { return _size; } - set { lock (BulletXScene.BulletXLock) { _size = value; } } + set + { + lock (BulletXScene.BulletXLock) + { + _size = value; + } + } } public override PhysicsVector Force @@ -788,10 +794,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override bool SetAlwaysRun @@ -818,9 +821,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } - public override float Mass - { - get { return ActorMass; } + public override float Mass + { + get { return ActorMass; } } public virtual float ActorMass @@ -841,7 +844,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin public Vector3 RigidBodyPosition { - get { return this.rigidBody.CenterOfMassPosition; } + get { return rigidBody.CenterOfMassPosition; } } public override bool IsPhysical @@ -855,6 +858,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin get { return flying; } set { flying = value; } } + public override bool ThrottleUpdates { get { return false; } @@ -889,19 +893,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override bool Kinematic { - get - { - return false; - } - set - { - - } + get { return false; } + set { } } public override void AddForce(PhysicsVector force) { - } public override void SetMomentum(PhysicsVector momentum) @@ -917,31 +914,37 @@ namespace OpenSim.Region.Physics.BulletXPlugin } #region Methods for updating values of RigidBody - internal protected void Translate() + + protected internal void Translate() { - Translate(this._position); + Translate(_position); } - internal protected void Translate(PhysicsVector _newPos) + + protected internal void Translate(PhysicsVector _newPos) { Vector3 _translation; _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; rigidBody.Translate(_translation); } - internal protected void Speed() + + protected internal void Speed() { - Speed(this._velocity); + Speed(_velocity); } - internal protected void Speed(PhysicsVector _newSpeed) + + protected internal void Speed(PhysicsVector _newSpeed) { Vector3 _speed; _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); rigidBody.LinearVelocity = _speed; } - internal protected void ReOrient() + + protected internal void ReOrient() { - ReOrient(this._orientation); + ReOrient(_orientation); } - internal protected void ReOrient(AxiomQuaternion _newOrient) + + protected internal void ReOrient(AxiomQuaternion _newOrient) { Quaternion _newOrientation; _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient); @@ -949,17 +952,21 @@ namespace OpenSim.Region.Physics.BulletXPlugin BulletXMaths.SetRotation(ref _comTransform, _newOrientation); rigidBody.CenterOfMassTransform = _comTransform; } - internal protected void ReSize() + + protected internal void ReSize() { - ReSize(this._size); + ReSize(_size); } - internal protected virtual void ReSize(PhysicsVector _newSize) + + protected internal virtual void ReSize(PhysicsVector _newSize) { } + public virtual void ScheduleTerseUpdate() { base.RequestPhysicsterseUpdate(); } + #endregion } @@ -972,11 +979,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin : this("", parent_scene, pos) { } + public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos) : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(), AxiomQuaternion.Identity) { } + public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation) : base(avName) @@ -1026,45 +1035,54 @@ namespace OpenSim.Region.Physics.BulletXPlugin parent_scene.ddWorld.AddRigidBody(rigidBody); } } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override PhysicsVector Position { get { return base.Position; } set { base.Position = value; } } + public override PhysicsVector Velocity { get { return base.Velocity; } set { base.Velocity = value; } } + public override PhysicsVector Size { get { return base.Size; } set { base.Size = value; } } + public override PhysicsVector Acceleration { get { return base.Acceleration; } } + public override AxiomQuaternion Orientation { get { return base.Orientation; } set { base.Orientation = value; } } + public override bool Flying { get { return base.Flying; } set { base.Flying = value; } } + public override bool IsColliding { get { return base.IsColliding; } set { base.IsColliding = value; } } + public override bool Kinematic { get { return base.Kinematic; } @@ -1075,10 +1093,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin { base.SetAcceleration(accel); } + public override void AddForce(PhysicsVector force) { base.AddForce(force); } + public override void SetMomentum(PhysicsVector momentum) { base.SetMomentum(momentum); @@ -1117,6 +1137,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin } rigidBody.LinearVelocity = vec; } + //This validation is very basic internal override void ValidateHeight(float heighmapPositionValue) { @@ -1131,6 +1152,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); } } + internal override void UpdateKinetics() { _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); @@ -1154,12 +1176,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) - : this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, isPhysical) + : this( + primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, + isPhysical) { } + public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, PhysicsVector size, - PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, + PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) : base(primName) { @@ -1177,27 +1202,28 @@ namespace OpenSim.Region.Physics.BulletXPlugin CreateRigidBody(parent_scene, mesh, pos, size); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override PhysicsVector Position { get { return base.Position; } set { base.Position = value; } } + public override PhysicsVector Velocity { get { return base.Velocity; } set { base.Velocity = value; } } + public override PhysicsVector Size { - get - { - return _size; - } + get { return _size; } set { lock (BulletXScene.BulletXLock) @@ -1207,29 +1233,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Acceleration { get { return base.Acceleration; } } + public override AxiomQuaternion Orientation { get { return base.Orientation; } set { base.Orientation = value; } } + public override float ActorMass { get { //For now all prims are boxes - return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z; + return (_physical ? 1 : 0)*_density*_size.X*_size.Y*_size.Z; } } + public override bool IsPhysical { - get - { - return base.IsPhysical; - } + get { return base.IsPhysical; } set { base.IsPhysical = value; @@ -1238,27 +1265,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin //--- PhysicsPluginManager.PhysicsPluginMessage("Physical - Recreate", true); //--- - ReCreateRigidBody(this._size); + ReCreateRigidBody(_size); } else { //--- PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true); //--- - this.rigidBody.SetMassProps(Mass, new Vector3()); + rigidBody.SetMassProps(Mass, new Vector3()); } } } + public override bool Flying { get { return base.Flying; } set { base.Flying = value; } } + public override bool IsColliding { get { return base.IsColliding; } set { base.IsColliding = value; } } + public override bool Kinematic { get { return base.Kinematic; } @@ -1272,10 +1302,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin _acceleration = accel; } } + public override void AddForce(PhysicsVector force) { base.AddForce(force); } + public override void SetMomentum(PhysicsVector momentum) { base.SetMomentum(momentum); @@ -1296,6 +1328,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); } } + internal override void UpdateKinetics() { if (_physical) //Updates properties. Prim updates its properties physically @@ -1320,7 +1353,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin { m_lastUpdateSent = false; base.ScheduleTerseUpdate(); - } m_prev_position = _position; } @@ -1333,7 +1365,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin } #region Methods for updating values of RigidBody - internal protected void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, PhysicsVector size) + + protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, + PhysicsVector size) { //For RigidBody Constructor. The next values might change float _linearDamping = 0.0f; @@ -1349,27 +1383,31 @@ namespace OpenSim.Region.Physics.BulletXPlugin CollisionShape _collisionShape; if (mesh == null) { - _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f); - } else { + _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size)/2.0f); + } + else + { int iVertexCount = mesh.getVertexList().Count; int[] indices = mesh.getIndexListAsInt(); Vector3[] v3Vertices = new Vector3[iVertexCount]; for (int i = 0; i < iVertexCount; i++) { - PhysicsVector v=mesh.getVertexList()[i]; + PhysicsVector v = mesh.getVertexList()[i]; if (v != null) // Note, null has special meaning. See meshing code for details v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); else - v3Vertices[i] = MonoXnaCompactMaths.Vector3.Zero; + v3Vertices[i] = Vector3.Zero; } TriangleIndexVertexArray triMesh = new TriangleIndexVertexArray(indices, v3Vertices); - _collisionShape = new XnaDevRu.BulletX.TriangleMeshShape(triMesh); + _collisionShape = new TriangleMeshShape(triMesh); } DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); Vector3 _localInertia = new Vector3(); if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 - rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); + rigidBody = + new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, + _friction, _restitution); //rigidBody.ActivationState = ActivationState.DisableDeactivation; //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition Vector3 _vDebugTranslation; @@ -1379,30 +1417,34 @@ namespace OpenSim.Region.Physics.BulletXPlugin parent_scene.ddWorld.AddRigidBody(rigidBody); } } - internal protected void ReCreateRigidBody(PhysicsVector size) + + protected internal void ReCreateRigidBody(PhysicsVector size) { //There is a bug when trying to remove a rigidBody that is colliding with something.. try { - this._parent_scene.ddWorld.RemoveRigidBody(rigidBody); + _parent_scene.ddWorld.RemoveRigidBody(rigidBody); } catch (Exception ex) { - this._parent_scene.BulletXMessage(this._parent_scene.is_ex_message + ex.Message, true); + _parent_scene.BulletXMessage(_parent_scene.is_ex_message + ex.Message, true); rigidBody.ActivationState = ActivationState.DisableSimulation; - this._parent_scene.AddForgottenRigidBody(rigidBody); + _parent_scene.AddForgottenRigidBody(rigidBody); } - CreateRigidBody(this._parent_scene, null, this._position, size); // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler - if (_physical) Speed();//Static objects don't have linear velocity + CreateRigidBody(_parent_scene, null, _position, size); + // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler + if (_physical) Speed(); //Static objects don't have linear velocity ReOrient(); GC.Collect(); } - internal protected override void ReSize(PhysicsVector _newSize) + + protected internal override void ReSize(PhysicsVector _newSize) { //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't //so i have to do it manually. That's recreating rigidbody ReCreateRigidBody(_newSize); } + #endregion } @@ -1486,4 +1528,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin return height; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs index 4f63687..e73c953 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs @@ -34,8 +34,8 @@ */ using System; using System.Collections.Generic; -using System.Text; using MonoXnaCompactMaths; +using XnaDevRu.BulletX; namespace OpenSim.Region.Physics.BulletXPlugin { @@ -52,7 +52,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin private Vector3[] _vertexBase; private int _vertexStride; - public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) + public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, + Vector3[] vertexBase, int vertexStride) { _numTriangles = numTriangleIndices; _triangleIndexBase = triangleIndexBase; @@ -72,25 +73,57 @@ namespace OpenSim.Region.Physics.BulletXPlugin _vertexStride = 24; } - public int TriangleCount { get { return _numTriangles; } set { _numTriangles = value; } } - public int[] TriangleIndexBase { get { return _triangleIndexBase; } set { _triangleIndexBase = value; } } - public int TriangleIndexStride { get { return _triangleIndexStride; } set { _triangleIndexStride = value; } } - public int VertexCount { get { return _numVertices; } set { _numVertices = value; } } - public Vector3[] VertexBase { get { return _vertexBase; } set { _vertexBase = value; } } - public int VertexStride { get { return _vertexStride; } set { _vertexStride = value; } } + public int TriangleCount + { + get { return _numTriangles; } + set { _numTriangles = value; } + } + + public int[] TriangleIndexBase + { + get { return _triangleIndexBase; } + set { _triangleIndexBase = value; } + } + + public int TriangleIndexStride + { + get { return _triangleIndexStride; } + set { _triangleIndexStride = value; } + } + + public int VertexCount + { + get { return _numVertices; } + set { _numVertices = value; } + } + + public Vector3[] VertexBase + { + get { return _vertexBase; } + set { _vertexBase = value; } + } + + public int VertexStride + { + get { return _vertexStride; } + set { _vertexStride = value; } + } } /// <summary> /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays. /// Additional meshes can be added using addIndexedMesh /// </summary> - public class TriangleIndexVertexArray : XnaDevRu.BulletX.StridingMeshInterface + public class TriangleIndexVertexArray : StridingMeshInterface { - List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>(); + private List<IndexedMesh> _indexedMeshes = new List<IndexedMesh>(); - public TriangleIndexVertexArray() { } + public TriangleIndexVertexArray() + { + } - public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) + public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, + int numVertices, Vector3[] vertexBase, int vertexStride) { IndexedMesh mesh = new IndexedMesh(); mesh.TriangleCount = numTriangleIndices; @@ -104,19 +137,23 @@ namespace OpenSim.Region.Physics.BulletXPlugin } public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase) - : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) { } + : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) + { + } public void AddIndexedMesh(IndexedMesh indexedMesh) { _indexedMeshes.Add(indexedMesh); } - public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) + public override void GetLockedVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, + int subpart) { throw new Exception("The method or operation is not implemented."); } - public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, out int numfaces, int subpart) + public override void GetLockedReadOnlyVertexIndexBase(out List<Vector3> verts, out List<int> indicies, + out int numfaces, int subpart) { IndexedMesh m = _indexedMeshes[0]; Vector3[] vertexBase = m.VertexBase; @@ -158,4 +195,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin throw new Exception("The method or operation is not implemented."); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs index 3d95d6d..983a2b9 100644 --- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs index 1648a98..80b3320 100644 --- a/OpenSim/Region/Physics/Manager/IMesher.cs +++ b/OpenSim/Region/Physics/Manager/IMesher.cs @@ -28,8 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; - using OpenSim.Framework; namespace OpenSim.Region.Physics.Manager @@ -39,7 +37,8 @@ namespace OpenSim.Region.Physics.Manager IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size); } - public interface IVertex { + public interface IVertex + { } public interface IMesh @@ -48,7 +47,5 @@ namespace OpenSim.Region.Physics.Manager int[] getIndexListAsInt(); int[] getIndexListAsIntLocked(); float[] getVertexListAsFloatLocked(); - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 5894ab0..d393b62 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -25,10 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using Axiom.Math; -using OpenSim.Framework; using System; using System.Collections.Generic; +using Axiom.Math; +using OpenSim.Framework; namespace OpenSim.Region.Physics.Manager { @@ -37,14 +37,16 @@ namespace OpenSim.Region.Physics.Manager public delegate void VelocityUpdate(PhysicsVector velocity); public delegate void OrientationUpdate(Quaternion orientation); + public enum ActorTypes : int { Unknown = 0, Agent = 1, - Prim = 2, + Prim = 2, Ground = 3 } - public class CollisionEventUpdate : EventArgs + + public class CollisionEventUpdate : EventArgs { // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. @@ -53,52 +55,53 @@ namespace OpenSim.Region.Physics.Manager public bool m_startOrEnd; //public uint m_LocalID; public List<uint> m_objCollisionList; + public CollisionEventUpdate(uint localID, int colliderType, bool startOrEnd, List<uint> objCollisionList) { m_colliderType = colliderType; m_startOrEnd = startOrEnd; m_objCollisionList = objCollisionList; - } - public CollisionEventUpdate(bool startOrEnd){ - m_colliderType = (int)ActorTypes.Unknown; + + public CollisionEventUpdate(bool startOrEnd) + { + m_colliderType = (int) ActorTypes.Unknown; m_startOrEnd = startOrEnd; m_objCollisionList = null; } - public CollisionEventUpdate() { - m_colliderType = (int)ActorTypes.Unknown; + + public CollisionEventUpdate() + { + m_colliderType = (int) ActorTypes.Unknown; m_startOrEnd = false; m_objCollisionList = null; } - public int collidertype{ - get { - return m_colliderType; - } - set { - m_colliderType = value; - } + + public int collidertype + { + get { return m_colliderType; } + set { m_colliderType = value; } } - public bool startOrEnd { - get { - return m_startOrEnd; - } - set { - m_startOrEnd = value; - } + + public bool startOrEnd + { + get { return m_startOrEnd; } + set { m_startOrEnd = value; } } - public void addCollider(uint localID) { + + public void addCollider(uint localID) + { m_objCollisionList.Add(localID); } } - - - public abstract class PhysicsActor - { + { public delegate void RequestTerseUpdate(); + public delegate void CollisionUpdate(EventArgs e); + public delegate void OutOfBounds(PhysicsVector pos); #pragma warning disable 67 @@ -117,10 +120,8 @@ namespace OpenSim.Region.Physics.Manager public abstract PhysicsVector Size { get; set; } - public abstract PrimitiveBaseShape Shape - { - set; - } + public abstract PrimitiveBaseShape Shape { set; } + public virtual void RequestPhysicsterseUpdate() { // Make a temporary copy of the event to avoid possibility of @@ -131,8 +132,8 @@ namespace OpenSim.Region.Physics.Manager { OnRequestTerseUpdate(); } - } + public virtual void RaiseOutOfBounds(PhysicsVector pos) { // Make a temporary copy of the event to avoid possibility of @@ -143,8 +144,8 @@ namespace OpenSim.Region.Physics.Manager { OnOutOfBounds(pos); } - } + public virtual void SendCollisionUpdate(EventArgs e) { CollisionUpdate handler = OnCollisionUpdate; @@ -159,7 +160,7 @@ namespace OpenSim.Region.Physics.Manager public abstract float Mass { get; } - public abstract PhysicsVector Force { get;} + public abstract PhysicsVector Force { get; } public abstract PhysicsVector GeometricCenter { get; } @@ -172,7 +173,7 @@ namespace OpenSim.Region.Physics.Manager public abstract Quaternion Orientation { get; set; } public abstract int PhysicsActorType { get; set; } - public abstract bool IsPhysical {get; set;} + public abstract bool IsPhysical { get; set; } public abstract bool Flying { get; set; } public abstract bool SetAlwaysRun { get; set; } @@ -198,48 +199,54 @@ namespace OpenSim.Region.Physics.Manager get { return PhysicsVector.Zero; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool CollidingGround { - get {return false;} - set {return;} + get { return false; } + set { return; } } - public override bool CollidingObj + + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Size { get { return PhysicsVector.Zero; } set { return; } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } } + public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity @@ -270,6 +277,7 @@ namespace OpenSim.Region.Physics.Manager get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } @@ -281,9 +289,10 @@ namespace OpenSim.Region.Physics.Manager get { return false; } set { return; } } + public override int PhysicsActorType { - get { return (int)ActorTypes.Unknown; } + get { return (int) ActorTypes.Unknown; } set { return; } } @@ -297,14 +306,16 @@ namespace OpenSim.Region.Physics.Manager { return; } + public override PhysicsVector RotationalVelocity { get { return PhysicsVector.Zero; } set { return; } } + public override void SetMomentum(PhysicsVector momentum) { return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index badcc04..a4ac54f 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs @@ -30,7 +30,6 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using OpenSim.Framework.Console; -using Nini.Config; namespace OpenSim.Region.Physics.Manager { @@ -91,7 +90,7 @@ namespace OpenSim.Region.Physics.Manager plugHard = new ZeroMesherPlugin(); _MeshPlugins.Add(plugHard.GetName(), plugHard); MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plugHard.GetName()); - + // And now walk all assemblies (DLLs effectively) and see if they are home // of a plugin that is of interest for us string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); @@ -129,7 +128,7 @@ namespace OpenSim.Region.Physics.Manager if (meshTypeInterface != null) { IMeshingPlugin plug = - (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IMeshingPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); _MeshPlugins.Add(plug.GetName(), plug); MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plug.GetName()); } @@ -155,6 +154,7 @@ namespace OpenSim.Region.Physics.Manager MainLog.Instance.Verbose("PHYSICS", message); } } + //--- } @@ -171,4 +171,4 @@ namespace OpenSim.Region.Physics.Manager string GetName(); IMesher GetMesher(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index c63a66d..37481f1 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -28,7 +28,6 @@ using Axiom.Math; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Manager { @@ -45,6 +44,7 @@ namespace OpenSim.Region.Physics.Manager { get { return new NullPhysicsScene(); } } + public virtual void TriggerPhysicsBasedRestart() { physicsCrash handler = OnPhysicsCrash; @@ -52,9 +52,8 @@ namespace OpenSim.Region.Physics.Manager { OnPhysicsCrash(); } - } - + public abstract void Initialise(IMesher meshmerizer); @@ -68,6 +67,7 @@ namespace OpenSim.Region.Physics.Manager PhysicsVector size, Quaternion rotation); //To be removed public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical); + public abstract void AddPhysicsActorTaint(PhysicsActor prim); public abstract float Simulate(float timeStep); @@ -111,21 +111,24 @@ namespace OpenSim.Region.Physics.Manager return PhysicsActor.Null; } */ + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) //To be removed { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { MainLog.Instance.Verbose("PHYSICS", "NullPhysicsScene : AddPrim({0},{1})", position, size); return PhysicsActor.Null; } + public override void AddPhysicsActorTaint(PhysicsActor prim) { - } + public override float Simulate(float timeStep) { m_workIndicator = (m_workIndicator + 1)%10; @@ -154,4 +157,4 @@ namespace OpenSim.Region.Physics.Manager } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs index be82fca..1f5d0dc 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs @@ -28,7 +28,6 @@ using System; - namespace OpenSim.Region.Physics.Manager { public class PhysicsVector @@ -68,27 +67,27 @@ namespace OpenSim.Region.Physics.Manager public static PhysicsVector cross(PhysicsVector a, PhysicsVector b) { - return new PhysicsVector(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X); + return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X); } public float length() { - return (float)Math.Sqrt(X*X + Y*Y + Z*Z); + return (float) Math.Sqrt(X*X + Y*Y + Z*Z); } - public static PhysicsVector operator / (PhysicsVector v, float f) + public static PhysicsVector operator /(PhysicsVector v, float f) { - return new PhysicsVector(v.X / f, v.Y / f, v.Z / f); + return new PhysicsVector(v.X/f, v.Y/f, v.Z/f); } public static PhysicsVector operator *(PhysicsVector v, float f) { - return new PhysicsVector(v.X * f, v.Y * f, v.Z * f); + return new PhysicsVector(v.X*f, v.Y*f, v.Z*f); } public static PhysicsVector operator *(float f, PhysicsVector v) { - return v * f; + return v*f; } public virtual bool IsIdentical(PhysicsVector v, float tolerance) @@ -101,4 +100,4 @@ namespace OpenSim.Region.Physics.Manager return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs index a88656e..7dae4ac 100644 --- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs +++ b/OpenSim/Region/Physics/Manager/ZeroMesher.cs @@ -27,11 +27,8 @@ */ using System; -using System.Collections.Generic; -using System.Text; using OpenSim.Framework; - /* * This is the zero mesher. * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer. @@ -62,13 +59,11 @@ namespace OpenSim.Region.Physics.Manager } } - public class ZeroMesher: IMesher + public class ZeroMesher : IMesher { - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) { return null; } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs index eecac5a..7ef5b5b 100644 --- a/OpenSim/Region/Physics/Meshing/Extruder.cs +++ b/OpenSim/Region/Physics/Meshing/Extruder.cs @@ -26,24 +26,22 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing { - class Extruder + internal class Extruder { public float startParameter; public float stopParameter; - public Manager.PhysicsVector size; + public PhysicsVector size; public Mesh Extrude(Mesh m) { // Currently only works for iSteps=1; Mesh result = new Mesh(); - Mesh workingPlus = m.Clone(); + Mesh workingPlus = m.Clone(); Mesh workingMinus = m.Clone(); foreach (Vertex v in workingPlus.vertices) @@ -80,14 +78,14 @@ namespace OpenSim.Region.Physics.Meshing for (int i = 0; i < workingPlus.vertices.Count; i++) { int iNext = (i + 1); - + if (workingPlus.vertices[i] == null) // Can't make a simplex here { - iLastNull = i+1; + iLastNull = i + 1; continue; } - if (i == workingPlus.vertices.Count-1) // End of list + if (i == workingPlus.vertices.Count - 1) // End of list { iNext = iLastNull; } @@ -101,11 +99,12 @@ namespace OpenSim.Region.Physics.Meshing tSide = new Triangle(workingPlus.vertices[i], workingMinus.vertices[i], workingPlus.vertices[iNext]); result.Add(tSide); - tSide = new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]); + tSide = + new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]); result.Add(tSide); } return result; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs index be82c32..ac06614 100644 --- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs +++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs @@ -30,9 +30,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; -using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; - using OpenSim.Region.Physics.Meshing; public class Vertex : PhysicsVector, IComparable<Vertex> @@ -54,7 +52,7 @@ public class Vertex : PhysicsVector, IComparable<Vertex> public static Vertex FromAngle(double angle) { - return new Vertex((float)Math.Cos(angle), (float)Math.Sin(angle), 0.0f); + return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f); } @@ -101,6 +99,7 @@ public class Vertex : PhysicsVector, IComparable<Vertex> { return me.CompareTo(other) < 0; } + public String ToRaw() { // Why this stuff with the number formatter? @@ -117,7 +116,6 @@ public class Vertex : PhysicsVector, IComparable<Vertex> return s1; } - } public class Triangle @@ -283,7 +281,7 @@ public class Triangle float l = n.length(); // Normalized "normal" - n = n / l; + n = n/l; return n; } @@ -300,7 +298,7 @@ public class Triangle // debugging purposes public String ToStringRaw() { - String output = v1.ToRaw() + " " + v2.ToRaw() + " " +v3.ToRaw(); + String output = v1.ToRaw() + " " + v2.ToRaw() + " " + v3.ToRaw(); return output; } } \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index 2ebfa1c..9c2667e 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs @@ -26,14 +26,11 @@ * */ + using System; -using System.IO; using System.Collections.Generic; -using System.Text; - +using System.IO; using System.Runtime.InteropServices; - - using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing @@ -66,9 +63,9 @@ namespace OpenSim.Region.Physics.Meshing foreach (Triangle t in triangles) { int iV1, iV2, iV3; - iV1 = this.vertices.IndexOf(t.v1); - iV2 = this.vertices.IndexOf(t.v2); - iV3 = this.vertices.IndexOf(t.v3); + iV1 = vertices.IndexOf(t.v1); + iV2 = vertices.IndexOf(t.v2); + iV3 = vertices.IndexOf(t.v3); Triangle newT = new Triangle(result.vertices[iV1], result.vertices[iV2], result.vertices[iV3]); result.Add(newT); @@ -77,8 +74,7 @@ namespace OpenSim.Region.Physics.Meshing return result; } - - + public void Add(Triangle triangle) { int i; @@ -160,15 +156,15 @@ namespace OpenSim.Region.Physics.Meshing public float[] getVertexListAsFloatLocked() { - float[] result = new float[vertices.Count * 3]; + float[] result = new float[vertices.Count*3]; for (int i = 0; i < vertices.Count; i++) { Vertex v = vertices[i]; if (v == null) continue; - result[3 * i + 0] = v.X; - result[3 * i + 1] = v.Y; - result[3 * i + 2] = v.Z; + result[3*i + 0] = v.X; + result[3*i + 1] = v.Y; + result[3*i + 2] = v.Z; } GCHandle.Alloc(result, GCHandleType.Pinned); return result; @@ -176,13 +172,13 @@ namespace OpenSim.Region.Physics.Meshing public int[] getIndexListAsInt() { - int[] result = new int[triangles.Count * 3]; + int[] result = new int[triangles.Count*3]; for (int i = 0; i < triangles.Count; i++) { Triangle t = triangles[i]; - result[3 * i + 0] = vertices.IndexOf(t.v1); - result[3 * i + 1] = vertices.IndexOf(t.v2); - result[3 * i + 2] = vertices.IndexOf(t.v3); + result[3*i + 0] = vertices.IndexOf(t.v1); + result[3*i + 1] = vertices.IndexOf(t.v2); + result[3*i + 2] = vertices.IndexOf(t.v3); } return result; } @@ -202,7 +198,6 @@ namespace OpenSim.Region.Physics.Meshing foreach (Triangle t in newMesh.triangles) Add(t); - } // Do a linear transformation of mesh. @@ -213,9 +208,9 @@ namespace OpenSim.Region.Physics.Meshing if (v == null) continue; float x, y, z; - x = v.X * matrix[0, 0] + v.Y * matrix[1, 0] + v.Z * matrix[2, 0]; - y = v.X * matrix[0, 1] + v.Y * matrix[1, 1] + v.Z * matrix[2, 1]; - z = v.X * matrix[0, 2] + v.Y * matrix[1, 2] + v.Z * matrix[2, 2]; + x = v.X*matrix[0, 0] + v.Y*matrix[1, 0] + v.Z*matrix[2, 0]; + y = v.X*matrix[0, 1] + v.Y*matrix[1, 1] + v.Z*matrix[2, 1]; + z = v.X*matrix[0, 2] + v.Y*matrix[1, 2] + v.Z*matrix[2, 2]; v.X = x + offset[0]; v.Y = y + offset[1]; v.Z = z + offset[2]; @@ -237,5 +232,4 @@ namespace OpenSim.Region.Physics.Meshing sw.Close(); } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 9c35f81..3217dd8 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -27,18 +27,13 @@ */ using System; -using System.IO; -using System.Globalization; -using System.Diagnostics; using System.Collections.Generic; -using System.Runtime.InteropServices; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing { - public class MeshmerizerPlugin : IMeshingPlugin { public MeshmerizerPlugin() @@ -61,10 +56,11 @@ namespace OpenSim.Region.Physics.Meshing // Setting baseDir to a path will enable the dumping of raw files // raw files can be imported by blender so a visual inspection of the results can be done // const string baseDir = "rawFiles"; - const string baseDir = null; + private const string baseDir = null; - static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, PhysicsVector r2, ref float lambda, ref float mu) - { + private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, + PhysicsVector r2, ref float lambda, ref float mu) + { // p1, p2, points on the straight // r1, r2, directional vectors of the straight. Not necessarily of length 1! // note, that l, m can be scaled such, that the range 0..1 is mapped to the area between two points, @@ -88,9 +84,8 @@ namespace OpenSim.Region.Physics.Meshing float p1y = p1.Y; float p2x = p2.X; float p2y = p2.Y; - lambda = (-p2x * r2y + p1x * r2y + (p2y - p1y) * r2x) / denom; - mu = (-p2x * r1y + p1x * r1y + (p2y - p1y) * r1x) / denom; - + lambda = (-p2x*r2y + p1x*r2y + (p2y - p1y)*r2x)/denom; + mu = (-p2x*r1y + p1x*r1y + (p2y - p1y)*r1x)/denom; } private static List<Triangle> FindInfluencedTriangles(List<Triangle> triangles, Vertex v) @@ -105,8 +100,8 @@ namespace OpenSim.Region.Physics.Meshing } return influenced; } - - + + private static void InsertVertices(List<Vertex> vertices, int usedForSeed, List<Triangle> triangles) { // This is a variant of the delaunay algorithm @@ -126,10 +121,10 @@ namespace OpenSim.Region.Physics.Meshing // do not fulfill this condition with respect to the new triangle // Find the triangles that are influenced by the new vertex - Vertex v=vertices[iCurrentVertex]; + Vertex v = vertices[iCurrentVertex]; if (v == null) - continue; // Null is polygon stop marker. Ignore it - List<Triangle> influencedTriangles=FindInfluencedTriangles(triangles, v); + continue; // Null is polygon stop marker. Ignore it + List<Triangle> influencedTriangles = FindInfluencedTriangles(triangles, v); List<Simplex> simplices = new List<Simplex>(); @@ -177,12 +172,11 @@ namespace OpenSim.Region.Physics.Meshing } } } - } - - static Mesh CreateBoxMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) - // Builds the z (+ and -) surfaces of a box shaped prim + + private static Mesh CreateBoxMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) + // Builds the z (+ and -) surfaces of a box shaped prim { UInt16 hollowFactor = primShape.ProfileHollow; UInt16 profileBegin = primShape.ProfileBegin; @@ -201,7 +195,7 @@ namespace OpenSim.Region.Physics.Meshing Vertex MP = new Vertex(-0.5f, +0.5f, 0.0f); Vertex PP = new Vertex(+0.5f, +0.5f, 0.0f); - Meshing.SimpleHull outerHull = new SimpleHull(); + SimpleHull outerHull = new SimpleHull(); outerHull.AddVertex(MM); outerHull.AddVertex(PM); outerHull.AddVertex(PP); @@ -210,9 +204,10 @@ namespace OpenSim.Region.Physics.Meshing // Deal with cuts now if ((profileBegin != 0) || (profileEnd != 0)) { - double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; // In degree, for easier debugging and understanding - fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y - double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 + double fProfileBeginAngle = profileBegin/50000.0*360.0; + // In degree, for easier debugging and understanding + fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y + double fProfileEndAngle = 360.0 - profileEnd/50000.0*360.0; // Pathend comes as complement to 1.0 fProfileEndAngle -= (90.0 + 45.0); if (fProfileBeginAngle < fProfileEndAngle) fProfileEndAngle -= 360.0; @@ -222,20 +217,23 @@ namespace OpenSim.Region.Physics.Meshing // and we approximate this arc by a polygon chain // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space // So it can easily be subtracted from the outer hull - int iSteps = (int)(((fProfileBeginAngle - fProfileEndAngle) / 45.0) + .5); // how many steps do we need with approximately 45 degree - double dStepWidth=(fProfileBeginAngle-fProfileEndAngle)/iSteps; + int iSteps = (int) (((fProfileBeginAngle - fProfileEndAngle)/45.0) + .5); + // how many steps do we need with approximately 45 degree + double dStepWidth = (fProfileBeginAngle - fProfileEndAngle)/iSteps; Vertex origin = new Vertex(0.0f, 0.0f, 0.0f); // Note the sequence of vertices here. It's important to have the other rotational sense than in outerHull SimpleHull cutHull = new SimpleHull(); cutHull.AddVertex(origin); - for (int i=0; i<iSteps; i++) { - double angle=fProfileBeginAngle-i*dStepWidth; // we count against the angle orientation!!!! - Vertex v = Vertex.FromAngle(angle * Math.PI / 180.0); + for (int i = 0; i < iSteps; i++) + { + double angle = fProfileBeginAngle - i*dStepWidth; // we count against the angle orientation!!!! + Vertex v = Vertex.FromAngle(angle*Math.PI/180.0); cutHull.AddVertex(v); } - Vertex legEnd = Vertex.FromAngle(fProfileEndAngle * Math.PI / 180.0); // Calculated separately to avoid errors + Vertex legEnd = Vertex.FromAngle(fProfileEndAngle*Math.PI/180.0); + // Calculated separately to avoid errors cutHull.AddVertex(legEnd); MainLog.Instance.Debug("Starting cutting of the hollow shape from the prim {1}", 0, primName); @@ -248,10 +246,10 @@ namespace OpenSim.Region.Physics.Meshing if (hollowFactor > 0) { float hollowFactorF = (float) hollowFactor/(float) 50000; - Vertex IMM = new Vertex(-0.5f * hollowFactorF, -0.5f * hollowFactorF, 0.0f); - Vertex IPM = new Vertex(+0.5f * hollowFactorF, -0.5f * hollowFactorF, 0.0f); - Vertex IMP = new Vertex(-0.5f * hollowFactorF, +0.5f * hollowFactorF, 0.0f); - Vertex IPP = new Vertex(+0.5f * hollowFactorF, +0.5f * hollowFactorF, 0.0f); + Vertex IMM = new Vertex(-0.5f*hollowFactorF, -0.5f*hollowFactorF, 0.0f); + Vertex IPM = new Vertex(+0.5f*hollowFactorF, -0.5f*hollowFactorF, 0.0f); + Vertex IMP = new Vertex(-0.5f*hollowFactorF, +0.5f*hollowFactorF, 0.0f); + Vertex IPP = new Vertex(+0.5f*hollowFactorF, +0.5f*hollowFactorF, 0.0f); SimpleHull holeHull = new SimpleHull(); @@ -263,7 +261,6 @@ namespace OpenSim.Region.Physics.Meshing SimpleHull hollowedHull = SimpleHull.SubtractHull(outerHull, holeHull); outerHull = hollowedHull; - } Mesh m = new Mesh(); @@ -286,7 +283,7 @@ namespace OpenSim.Region.Physics.Meshing m.Remove(Seed2); m.Remove(Seed3); m.DumpRaw(baseDir, primName, "Proto seeds removed"); - + m.RemoveTrianglesOutside(outerHull); m.DumpRaw(baseDir, primName, "Proto outsides removed"); @@ -374,7 +371,7 @@ namespace OpenSim.Region.Physics.Meshing switch (primShape.ProfileShape) { case ProfileShape.Square: - mesh=CreateBoxMesh(primName, primShape, size); + mesh = CreateBoxMesh(primName, primShape, size); CalcNormals(mesh); break; default: @@ -389,5 +386,4 @@ namespace OpenSim.Region.Physics.Meshing return mesh; } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/SimpleHull.cs b/OpenSim/Region/Physics/Meshing/SimpleHull.cs index a769053..809f3d5 100644 --- a/OpenSim/Region/Physics/Meshing/SimpleHull.cs +++ b/OpenSim/Region/Physics/Meshing/SimpleHull.cs @@ -28,9 +28,8 @@ using System; using System.Collections.Generic; -using System.Text; - using OpenSim.Framework.Console; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing { @@ -43,17 +42,18 @@ namespace OpenSim.Region.Physics.Meshing // is defined by the hull lies inside or outside the simplex chain public class SimpleHull { - List<Vertex> vertices = new List<Vertex>(); - List<Vertex> holeVertices = new List<Vertex>(); // Only used, when the hull is hollow + private List<Vertex> vertices = new List<Vertex>(); + private List<Vertex> holeVertices = new List<Vertex>(); // Only used, when the hull is hollow // Adds a vertex to the end of the list - public void AddVertex(Vertex v) { + public void AddVertex(Vertex v) + { vertices.Add(v); } - override public String ToString() + public override String ToString() { - String result=""; + String result = ""; foreach (Vertex v in vertices) { result += "b:" + v.ToString() + "\n"; @@ -63,7 +63,8 @@ namespace OpenSim.Region.Physics.Meshing } - public List<Vertex> getVertices() { + public List<Vertex> getVertices() + { List<Vertex> newVertices = new List<Vertex>(); newVertices.AddRange(vertices); @@ -81,27 +82,27 @@ namespace OpenSim.Region.Physics.Meshing result.AddVertex(v.Clone()); } - foreach (Vertex v in this.holeVertices) + foreach (Vertex v in holeVertices) { result.holeVertices.Add(v.Clone()); } - + return result; } public bool IsPointIn(Vertex v1) { - int iCounter=0; - List<Simplex> simplices=buildSimplexList(); + int iCounter = 0; + List<Simplex> simplices = buildSimplexList(); foreach (Simplex s in simplices) { // Send a ray along the positive X-Direction // Note, that this direction must correlate with the "below" interpretation // of handling for the special cases below - Manager.PhysicsVector intersection = s.RayIntersect(v1, new Manager.PhysicsVector(1.0f, 0.0f, 0.0f), true); + PhysicsVector intersection = s.RayIntersect(v1, new PhysicsVector(1.0f, 0.0f, 0.0f), true); if (intersection == null) - continue; // No intersection. Done. More tests to follow otherwise + continue; // No intersection. Done. More tests to follow otherwise // Did we hit the end of a simplex? // Then this can be one of two special cases: @@ -111,19 +112,21 @@ namespace OpenSim.Region.Physics.Meshing // Solution: If the other vertex is "below" the ray, we don't count it // Thus corners pointing down are counted twice, corners pointing up are not counted // borders are counted once - if (intersection.IsIdentical(s.v1, 0.001f)) { + if (intersection.IsIdentical(s.v1, 0.001f)) + { if (s.v2.Y < v1.Y) continue; } // Do this for the other vertex two - if (intersection.IsIdentical(s.v2, 0.001f)) { - if (s.v1.Y<v1.Y) + if (intersection.IsIdentical(s.v2, 0.001f)) + { + if (s.v1.Y < v1.Y) continue; } iCounter++; } - return iCounter % 2 == 1; // Point is inside if the number of intersections is odd + return iCounter%2 == 1; // Point is inside if the number of intersections is odd } public bool containsPointsFrom(SimpleHull otherHull) @@ -138,19 +141,20 @@ namespace OpenSim.Region.Physics.Meshing } - List<Simplex> buildSimplexList() { - + private List<Simplex> buildSimplexList() + { List<Simplex> result = new List<Simplex>(); // Not asserted but assumed: at least three vertices - for (int i=0; i<vertices.Count-1; i++) { - Simplex s=new Simplex(vertices[i], vertices[i+1]); + for (int i = 0; i < vertices.Count - 1; i++) + { + Simplex s = new Simplex(vertices[i], vertices[i + 1]); result.Add(s); } - Simplex s1=new Simplex(vertices[vertices.Count-1], vertices[0]); + Simplex s1 = new Simplex(vertices[vertices.Count - 1], vertices[0]); result.Add(s1); - if (holeVertices.Count==0) + if (holeVertices.Count == 0) return result; // Same here. At least three vertices in hole assumed @@ -159,19 +163,19 @@ namespace OpenSim.Region.Physics.Meshing Simplex s = new Simplex(holeVertices[i], holeVertices[i + 1]); result.Add(s); } - + s1 = new Simplex(holeVertices[holeVertices.Count - 1], holeVertices[0]); result.Add(s1); return result; } - bool InsertVertex(Vertex v, int iAfter) + private bool InsertVertex(Vertex v, int iAfter) { vertices.Insert(iAfter + 1, v); return true; } - Vertex getNextVertex(Vertex currentVertex) + private Vertex getNextVertex(Vertex currentVertex) { int iCurrentIndex; iCurrentIndex = vertices.IndexOf(currentVertex); @@ -185,8 +189,10 @@ namespace OpenSim.Region.Physics.Meshing return vertices[iCurrentIndex]; } - public Vertex FindVertex(Vertex vBase, float tolerance) { - foreach (Vertex v in vertices) { + public Vertex FindVertex(Vertex vBase, float tolerance) + { + foreach (Vertex v in vertices) + { if (v.IsIdentical(vBase, tolerance)) return v; } @@ -196,32 +202,31 @@ namespace OpenSim.Region.Physics.Meshing public void FindIntersection(Simplex s, ref Vertex Intersection, ref Vertex nextVertex) { - Vertex bestIntersection=null; - float distToV1=Single.PositiveInfinity; - Simplex bestIntersectingSimplex=null; + Vertex bestIntersection = null; + float distToV1 = Single.PositiveInfinity; + Simplex bestIntersectingSimplex = null; List<Simplex> simple = buildSimplexList(); foreach (Simplex sTest in simple) { - Manager.PhysicsVector vvTemp = Simplex.Intersect(sTest, s, -.001f, -.001f, 0.999f, .999f); - - Vertex vTemp=null; + PhysicsVector vvTemp = Simplex.Intersect(sTest, s, -.001f, -.001f, 0.999f, .999f); + + Vertex vTemp = null; if (vvTemp != null) vTemp = new Vertex(vvTemp); - if (vTemp!=null) { - - Manager.PhysicsVector diff=(s.v1-vTemp); - float distTemp=diff.length(); + if (vTemp != null) + { + PhysicsVector diff = (s.v1 - vTemp); + float distTemp = diff.length(); - if (bestIntersection==null || distTemp<distToV1) { - bestIntersection=vTemp; - distToV1=distTemp; + if (bestIntersection == null || distTemp < distToV1) + { + bestIntersection = vTemp; + distToV1 = distTemp; bestIntersectingSimplex = sTest; } - } // end if vTemp - } // end foreach Intersection = bestIntersection; @@ -234,7 +239,6 @@ namespace OpenSim.Region.Physics.Meshing public static SimpleHull SubtractHull(SimpleHull baseHull, SimpleHull otherHull) { - SimpleHull baseHullClone = baseHull.Clone(); SimpleHull otherHullClone = otherHull.Clone(); bool intersects = false; @@ -249,15 +253,16 @@ namespace OpenSim.Region.Physics.Meshing // Insert into baseHull for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++) { - int iBaseNext = (iBase + 1) % baseHullClone.vertices.Count; + int iBaseNext = (iBase + 1)%baseHullClone.vertices.Count; Simplex sBase = new Simplex(baseHullClone.vertices[iBase], baseHullClone.vertices[iBaseNext]); for (iOther = 0; iOther < otherHullClone.vertices.Count; iOther++) { - int iOtherNext = (iOther + 1) % otherHullClone.vertices.Count; - Simplex sOther = new Simplex(otherHullClone.vertices[iOther], otherHullClone.vertices[iOtherNext]); + int iOtherNext = (iOther + 1)%otherHullClone.vertices.Count; + Simplex sOther = + new Simplex(otherHullClone.vertices[iOther], otherHullClone.vertices[iOtherNext]); - Manager.PhysicsVector intersect = Simplex.Intersect(sBase, sOther, 0.001f, -.001f, 0.999f, 1.001f); + PhysicsVector intersect = Simplex.Intersect(sBase, sOther, 0.001f, -.001f, 0.999f, 1.001f); if (intersect != null) { Vertex vIntersect = new Vertex(intersect); @@ -278,15 +283,15 @@ namespace OpenSim.Region.Physics.Meshing // Insert into otherHull for (iOther = 0; iOther < otherHullClone.vertices.Count; iOther++) { - int iOtherNext = (iOther + 1) % otherHullClone.vertices.Count; + int iOtherNext = (iOther + 1)%otherHullClone.vertices.Count; Simplex sOther = new Simplex(otherHullClone.vertices[iOther], otherHullClone.vertices[iOtherNext]); for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++) { - int iBaseNext = (iBase + 1) % baseHullClone.vertices.Count; + int iBaseNext = (iBase + 1)%baseHullClone.vertices.Count; Simplex sBase = new Simplex(baseHullClone.vertices[iBase], baseHullClone.vertices[iBaseNext]); - Manager.PhysicsVector intersect = Simplex.Intersect(sBase, sOther, -.001f, 0.001f, 1.001f, 0.999f); + PhysicsVector intersect = Simplex.Intersect(sBase, sOther, -.001f, 0.001f, 1.001f, 0.999f); if (intersect != null) { Vertex vIntersect = new Vertex(intersect); @@ -321,8 +326,8 @@ namespace OpenSim.Region.Physics.Meshing int iBase; for (iBase = 0; iBase < baseHullClone.vertices.Count; iBase++) { - int iBaseNext = (iBase + 1) % baseHullClone.vertices.Count; - Vertex center = new Vertex((baseHullClone.vertices[iBase] + baseHullClone.vertices[iBaseNext]) / 2.0f); + int iBaseNext = (iBase + 1)%baseHullClone.vertices.Count; + Vertex center = new Vertex((baseHullClone.vertices[iBase] + baseHullClone.vertices[iBaseNext])/2.0f); bool isOutside = !otherHullClone.IsPointIn(center); if (isOutside) { @@ -334,7 +339,7 @@ namespace OpenSim.Region.Physics.Meshing if (baseStartVertex == null) // i.e. no simplex fulfilled the "outside" condition. - // In otherwords, subtractHull completely embraces baseHull + // In otherwords, subtractHull completely embraces baseHull { return result; } @@ -369,7 +374,7 @@ namespace OpenSim.Region.Physics.Meshing if (nextVertex != null) // A node that represents an intersection { - V1 = nextVertex; // Needed to find the next vertex on the other hull + V1 = nextVertex; // Needed to find the next vertex on the other hull onBase = !onBase; } @@ -385,7 +390,6 @@ namespace OpenSim.Region.Physics.Meshing MainLog.Instance.Debug("The resulting Hull is:\n{1}", 0, result.ToString()); return result; - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Simplex.cs b/OpenSim/Region/Physics/Meshing/Simplex.cs index 98e693a..8fba2bf 100644 --- a/OpenSim/Region/Physics/Meshing/Simplex.cs +++ b/OpenSim/Region/Physics/Meshing/Simplex.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing @@ -49,7 +47,6 @@ namespace OpenSim.Region.Physics.Meshing public int CompareTo(Simplex other) { - Vertex lv1, lv2, ov1, ov2, temp; lv1 = v1; @@ -92,8 +89,9 @@ namespace OpenSim.Region.Physics.Meshing return 0; } - private static void intersectParameter(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, PhysicsVector r2, ref float lambda, ref float mu) - { + private static void intersectParameter(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, PhysicsVector r2, + ref float lambda, ref float mu) + { // Intersects two straights // p1, p2, points on the straight // r1, r2, directional vectors of the straight. Not necessarily of length 1! @@ -112,27 +110,28 @@ namespace OpenSim.Region.Physics.Meshing float p2x = p2.X; float p2y = p2.Y; - float z1=-p2x * r2y + p1x * r2y + (p2y - p1y) * r2x; - float z2=-p2x * r1y + p1x * r1y + (p2y - p1y) * r1x; + float z1 = -p2x*r2y + p1x*r2y + (p2y - p1y)*r2x; + float z2 = -p2x*r1y + p1x*r1y + (p2y - p1y)*r1x; if (denom == 0.0f) // Means the straights are parallel. Either no intersection or an infinite number of them { - if (z1==0.0f) {// Means they are identical -> many, many intersections + if (z1 == 0.0f) + { +// Means they are identical -> many, many intersections lambda = Single.NaN; mu = Single.NaN; - } else { + } + else + { lambda = Single.PositiveInfinity; mu = Single.PositiveInfinity; } return; - } - - lambda = z1 / denom; - mu = z2 / denom; - + lambda = z1/denom; + mu = z2/denom; } @@ -145,12 +144,12 @@ namespace OpenSim.Region.Physics.Meshing // upperBorder2 : 1.0 // Set these to values near the given parameters (e.g. 0.001 instead of 1 to exclude simplex starts safely, or to -0.001 to include them safely) public static PhysicsVector Intersect( - Simplex s1, - Simplex s2, - float lowerBorder1, - float lowerBorder2, - float upperBorder1, - float upperBorder2) + Simplex s1, + Simplex s2, + float lowerBorder1, + float lowerBorder2, + float upperBorder1, + float upperBorder2) { PhysicsVector firstSimplexDirection = s1.v2 - s1.v1; PhysicsVector secondSimplexDirection = s2.v2 - s2.v1; @@ -181,8 +180,7 @@ namespace OpenSim.Region.Physics.Meshing if (mu > upperBorder2) // outside simplex 2 return null; - return s1.v1 + lambda * firstSimplexDirection; - + return s1.v1 + lambda*firstSimplexDirection; } // Intersects the simplex with a ray. The ray is defined as all p=origin + lambda*direction @@ -212,15 +210,12 @@ namespace OpenSim.Region.Physics.Meshing return null; if (lambda == 1.0 && !bEndsIncluded) - return null; // The end of the simplices are not included + return null; // The end of the simplices are not included if (lambda < 0.0f) // we're before v1; return null; - return this.v1 + lambda * simplexDirection; - + return v1 + lambda*simplexDirection; } - - } } \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs index 1e5713b..1ea5458 100644 --- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 9676db4..a118e7c 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -27,11 +27,9 @@ */ using System; -using System.Collections.Generic; using Axiom.Math; using Ode.NET; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.OdePlugin @@ -87,7 +85,9 @@ namespace OpenSim.Region.Physics.OdePlugin _acceleration = new PhysicsVector(); _parent_scene = parent_scene; - m_StandUpRotation = new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, -0.004689182f, 0.9998941f); + m_StandUpRotation = + new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, + -0.004689182f, 0.9998941f); for (int i = 0; i < 11; i++) { @@ -105,12 +105,9 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetBody(Shell, Body); - - d.BodySetRotation(Body, ref m_StandUpRotation); - //Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero); //d.JointAttach(Amotor, Body, IntPtr.Zero); //d.JointSetAMotorMode(Amotor, dAMotorEuler); @@ -124,45 +121,47 @@ namespace OpenSim.Region.Physics.OdePlugin //d.JointSetAMotorParam(Amotor, 0, -0); //d.JointSetAMotorParam(Amotor, 0x200, -0); //d.JointSetAMotorParam(Amotor, 0x100, -0); - // d.JointSetAMotorParam(Amotor, 0, 0); - // d.JointSetAMotorParam(Amotor, 3, 0); - // d.JointSetAMotorParam(Amotor, 2, 0); - - - + // d.JointSetAMotorParam(Amotor, 0, 0); + // d.JointSetAMotorParam(Amotor, 3, 0); + // d.JointSetAMotorParam(Amotor, 2, 0); } m_name = avName; parent_scene.geom_name_map[Shell] = avName; - parent_scene.actor_name_map[Shell] = (PhysicsActor)this; + parent_scene.actor_name_map[Shell] = (PhysicsActor) this; } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override bool SetAlwaysRun { get { return m_alwaysRun; } set { m_alwaysRun = value; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } set { flying = value; } } + public override bool IsColliding { - get { return m_iscolliding; } set { @@ -193,24 +192,22 @@ namespace OpenSim.Region.Physics.OdePlugin // Equal truecounts and false counts means we're colliding with something. - if (falsecount > 1.2 * truecount) + if (falsecount > 1.2*truecount) { m_iscolliding = false; } else { m_iscolliding = true; - - } if (m_wascolliding != m_iscolliding) { //base.SendCollisionUpdate(new CollisionEventUpdate()); - } m_wascolliding = m_iscolliding; } } + public override bool CollidingGround { get { return m_iscollidingGround; } @@ -243,7 +240,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Equal truecounts and false counts means we're colliding with something. - if (falsecount > 1.2 * truecount) + if (falsecount > 1.2*truecount) { m_iscollidingGround = false; } @@ -258,10 +255,12 @@ namespace OpenSim.Region.Physics.OdePlugin m_wascollidingGround = m_iscollidingGround; } } + public override bool CollidingObj { get { return m_iscollidingObj; } - set { + set + { m_iscollidingObj = value; if (value) m_pidControllerActive = false; @@ -269,10 +268,12 @@ namespace OpenSim.Region.Physics.OdePlugin m_pidControllerActive = true; } } + public void SetPidStatus(bool status) { m_pidControllerActive = status; } + public override PhysicsVector Position { get { return _position; } @@ -285,14 +286,16 @@ namespace OpenSim.Region.Physics.OdePlugin } } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override PhysicsVector Size { - get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } + get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } set { m_pidControllerActive = true; @@ -303,7 +306,7 @@ namespace OpenSim.Region.Physics.OdePlugin float capsuleradius = CAPSULE_RADIUS; capsuleradius = 0.2f; - CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z * 0.43f))); // subtract 43% of the size + CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.43f))); // subtract 43% of the size d.BodyDestroy(Body); d.GeomDestroy(Shell); //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH)); @@ -311,25 +314,27 @@ namespace OpenSim.Region.Physics.OdePlugin d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); Body = d.BodyCreate(_parent_scene.world); d.BodySetMass(Body, ref ShellMass); - d.BodySetPosition(Body, _position.X, _position.Y, _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); + d.BodySetPosition(Body, _position.X, _position.Y, + _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); d.GeomSetBody(Shell, Body); } _parent_scene.geom_name_map[Shell] = m_name; - _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; + _parent_scene.actor_name_map[Shell] = (PhysicsActor) this; } } + public override float Mass { - get { - - float AVvolume = (float)(Math.PI * Math.Pow(CAPSULE_RADIUS, 2) * CAPSULE_LENGTH); - return m_density * AVvolume; + get + { + float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH); + return m_density*AVvolume; } } public override PhysicsVector Force { - get { return new PhysicsVector(_target_velocity.X,_target_velocity.Y,_target_velocity.Z); } + get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); } } public override PhysicsVector CenterOfMass @@ -344,18 +349,17 @@ namespace OpenSim.Region.Physics.OdePlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity { get { return _velocity; } - set { + set + { m_pidControllerActive = true; - _target_velocity = value; } + _target_velocity = value; + } } public override bool Kinematic @@ -390,6 +394,7 @@ namespace OpenSim.Region.Physics.OdePlugin //m_lastUpdateSent = false; } + public void doForce(PhysicsVector force) { if (!collidelock) @@ -413,13 +418,11 @@ namespace OpenSim.Region.Physics.OdePlugin //d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); //m_lastUpdateSent = false; - } - } + public override void SetMomentum(PhysicsVector momentum) { - } public void Move(float timeStep) @@ -442,7 +445,6 @@ namespace OpenSim.Region.Physics.OdePlugin else { movementdivisor = 0.8f; - } // if velocity is zero, use position control; otherwise, velocity control @@ -457,11 +459,11 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_pidControllerActive) { d.Vector3 pos = d.BodyGetPosition(Body); - vec.X = (_target_velocity.X - vel.X) * PID_D + (_zeroPosition.X - pos.X) * PID_P; - vec.Y = (_target_velocity.Y - vel.Y) * PID_D + (_zeroPosition.Y - pos.Y) * PID_P; + vec.X = (_target_velocity.X - vel.X)*PID_D + (_zeroPosition.X - pos.X)*PID_P; + vec.Y = (_target_velocity.Y - vel.Y)*PID_D + (_zeroPosition.Y - pos.Y)*PID_P; if (flying) { - vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100) + (_zeroPosition.Z - pos.Z) * PID_P; + vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100) + (_zeroPosition.Z - pos.Z)*PID_P; } } //PidStatus = true; @@ -472,21 +474,20 @@ namespace OpenSim.Region.Physics.OdePlugin _zeroFlag = false; if (m_iscolliding || flying) { - - vec.X = ((_target_velocity.X / movementdivisor) - vel.X) * PID_D; - vec.Y = ((_target_velocity.Y / movementdivisor) - vel.Y) * PID_D; + vec.X = ((_target_velocity.X/movementdivisor) - vel.X)*PID_D; + vec.Y = ((_target_velocity.Y/movementdivisor) - vel.Y)*PID_D; } if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) { d.Vector3 pos = d.BodyGetPosition(Body); - vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; + vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P; if (_target_velocity.X > 0) { - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D; } if (_target_velocity.Y > 0) { - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D; } } else if (!m_iscolliding && !flying) @@ -494,19 +495,18 @@ namespace OpenSim.Region.Physics.OdePlugin d.Vector3 pos = d.BodyGetPosition(Body); if (_target_velocity.X > 0) { - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D; } if (_target_velocity.Y > 0) { - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D; } - } if (flying) { - vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100); + vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100); } } if (flying) @@ -546,13 +546,12 @@ namespace OpenSim.Region.Physics.OdePlugin int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); //if (primScenAvatarIn == "0") //{ - //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); + //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); //} //else //{ // MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); //} - } } else @@ -586,12 +585,11 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (OdeScene.OdeLock) { - // d.JointDestroy(Amotor); + // d.JointDestroy(Amotor); d.GeomDestroy(Shell); _parent_scene.geom_name_map.Remove(Shell); d.BodyDestroy(Body); } } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 35328b8..5fef47d 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -27,16 +27,13 @@ */ using System; -using System.Collections.Generic; using Axiom.Math; using Ode.NET; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.OdePlugin { - public class OdePrim : PhysicsActor { public PhysicsVector _position; @@ -57,7 +54,7 @@ namespace OpenSim.Region.Physics.OdePlugin private IMesh _mesh; private PrimitiveBaseShape _pbs; private OdeScene _parent_scene; - public IntPtr m_targetSpace = (IntPtr)0; + public IntPtr m_targetSpace = (IntPtr) 0; public IntPtr prim_geom; public IntPtr _triMeshData; private bool iscolliding = false; @@ -65,18 +62,17 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_throttleUpdates = false; private int throttleCounter = 0; public bool outofBounds = false; - private float m_density = 10.000006836f;// Aluminum g/cm3; + private float m_density = 10.000006836f; // Aluminum g/cm3; - public bool _zeroFlag = false; private bool m_lastUpdateSent = false; - public IntPtr Body = (IntPtr)0; + public IntPtr Body = (IntPtr) 0; private String m_primName; private PhysicsVector _target_velocity; public d.Mass pMass; - + private int debugcounter = 0; public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size, @@ -123,7 +119,6 @@ namespace OpenSim.Region.Physics.OdePlugin // linksets *should* be in a space together.. but are not currently if (m_isphysical) m_targetSpace = _parent_scene.space; - } m_primName = primName; @@ -147,25 +142,28 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetQuaternion(prim_geom, ref myrot); - if (m_isphysical && Body == (IntPtr)0) + if (m_isphysical && Body == (IntPtr) 0) { enableBody(); } parent_scene.geom_name_map[prim_geom] = primName; - parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; + parent_scene.actor_name_map[prim_geom] = (PhysicsActor) this; // don't do .add() here; old geoms get recycled with the same hash } } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public void enableBody() { // Sets the geom to a body @@ -185,13 +183,14 @@ namespace OpenSim.Region.Physics.OdePlugin _parent_scene.addActivePrim(this); } + private float CalculateMass() { float volume = 0; - + // No material is passed to the physics engines yet.. soo.. // we're using the m_density constant in the class definition - + float returnMass = 0; @@ -199,17 +198,17 @@ namespace OpenSim.Region.Physics.OdePlugin { case ProfileShape.Square: // Profile Volume - - volume = _size.X * _size.Y * _size.Z; + + volume = _size.X*_size.Y*_size.Z; // If the user has 'hollowed out' // ProfileHollow is one of those 0 to 50000 values :P // we like percentages better.. so turning into a percentage - if (((float)_pbs.ProfileHollow / 50000f) > 0.0) + if (((float) _pbs.ProfileHollow/50000f) > 0.0) { - float hollowAmount = (float)_pbs.ProfileHollow / 50000f; - + float hollowAmount = (float) _pbs.ProfileHollow/50000f; + // calculate the hollow volume by it's shape compared to the prim shape float hollowVolume = 0; switch (_pbs.HollowShape) @@ -217,29 +216,29 @@ namespace OpenSim.Region.Physics.OdePlugin case HollowShape.Square: case HollowShape.Same: // Cube Hollow volume calculation - float hollowsizex = _size.X * hollowAmount; - float hollowsizey = _size.Y * hollowAmount; - float hollowsizez = _size.Z * hollowAmount; - hollowVolume = hollowsizex * hollowsizey * hollowsizez; + float hollowsizex = _size.X*hollowAmount; + float hollowsizey = _size.Y*hollowAmount; + float hollowsizez = _size.Z*hollowAmount; + hollowVolume = hollowsizex*hollowsizey*hollowsizez; break; case HollowShape.Circle: // Hollow shape is a perfect cyllinder in respect to the cube's scale // Cyllinder hollow volume calculation - float hRadius = _size.X / 2; + float hRadius = _size.X/2; float hLength = _size.Z; // pi * r2 * h - hollowVolume = ((float)(Math.PI * Math.Pow(hRadius, 2) * hLength) * hollowAmount); + hollowVolume = ((float) (Math.PI*Math.Pow(hRadius, 2)*hLength)*hollowAmount); break; case HollowShape.Triangle: // Equilateral Triangular Prism volume hollow calculation // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y - float aLength = _size.Y; + float aLength = _size.Y; // 1/2 abh - hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount); + hollowVolume = (float) ((0.5*aLength*_size.X*_size.Z)*hollowAmount); break; default: @@ -247,15 +246,14 @@ namespace OpenSim.Region.Physics.OdePlugin break; } volume = volume - hollowVolume; - } - + break; default: // we don't have all of the volume formulas yet so // use the common volume formula for all - volume = _size.X * _size.Y * _size.Z; + volume = _size.X*_size.Y*_size.Z; break; } @@ -273,70 +271,70 @@ namespace OpenSim.Region.Physics.OdePlugin float PathCutStartAmount = _pbs.ProfileBegin; if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f) { + float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount)/50000f); - float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount) / 50000f); - // Check the return amount for sanity - if (pathCutAmount >= 0.99f) - pathCutAmount=0.99f; + if (pathCutAmount >= 0.99f) + pathCutAmount = 0.99f; - volume = volume - (volume * pathCutAmount); + volume = volume - (volume*pathCutAmount); } - + // Mass = density * volume - returnMass = m_density * volume; + returnMass = m_density*volume; return returnMass; } public void setMass() - { - if (Body != (IntPtr)0) + { + if (Body != (IntPtr) 0) { d.MassSetBoxTotal(out pMass, CalculateMass(), _size.X, _size.Y, _size.Z); d.BodySetMass(Body, ref pMass); } } - public void disableBody() { //this kills the body so things like 'mesh' can re-create it. - if (Body != (IntPtr)0) + if (Body != (IntPtr) 0) { _parent_scene.remActivePrim(this); d.BodyDestroy(Body); - Body = (IntPtr)0; + Body = (IntPtr) 0; } } + public void setMesh(OdeScene parent_scene, IMesh mesh) { //Kill Body so that mesh can re-make the geom - if (IsPhysical && Body != (IntPtr)0) + if (IsPhysical && Body != (IntPtr) 0) { disableBody(); } float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage - int VertexCount = vertexList.GetLength(0) / 3; + int VertexCount = vertexList.GetLength(0)/3; int IndexCount = indexList.GetLength(0); - + _triMeshData = d.GeomTriMeshDataCreate(); - d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3 * sizeof(float), VertexCount, indexList, IndexCount, - 3 * sizeof(int)); + d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3*sizeof (float), VertexCount, indexList, IndexCount, + 3*sizeof (int)); d.GeomTriMeshDataPreprocess(_triMeshData); prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null); - - if (IsPhysical && Body == (IntPtr)0) + + if (IsPhysical && Body == (IntPtr) 0) { // Recreate the body enableBody(); } } + public void ProcessTaints(float timestep) { if (m_taintposition != _position) @@ -357,14 +355,14 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_taintshape) changeshape(timestep); // - } + public void Move(float timestep) { if (m_isphysical) { // This is a fallback.. May no longer be necessary. - if (Body == (IntPtr)0) + if (Body == (IntPtr) 0) enableBody(); //Prim auto disable after 20 frames, ///if you move it, re-enable the prim manually. @@ -382,35 +380,35 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintposition = _position; } + public void rotate(float timestep) { - d.Quaternion myrot = new d.Quaternion(); myrot.W = _orientation.w; myrot.X = _orientation.x; myrot.Y = _orientation.y; myrot.Z = _orientation.z; d.GeomSetQuaternion(prim_geom, ref myrot); - if (m_isphysical && Body != (IntPtr)0) + if (m_isphysical && Body != (IntPtr) 0) { d.BodySetQuaternion(Body, ref myrot); } m_taintrot = _orientation; } + public void changePhysicsStatus(float timestap) { if (m_isphysical == true) { - if (Body == (IntPtr)0) + if (Body == (IntPtr) 0) { enableBody(); } - } else { - if (Body != (IntPtr)0) + if (Body != (IntPtr) 0) { disableBody(); } @@ -419,6 +417,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintPhysics = m_isphysical; } + public void changesize(float timestamp) { string oldname = _parent_scene.geom_name_map[prim_geom]; @@ -429,7 +428,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Cleanup meshing here } //kill body to rebuild - if (IsPhysical && Body != (IntPtr)0) + if (IsPhysical && Body != (IntPtr) 0) { disableBody(); } @@ -442,10 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin // we don't need to do space calculation because the client sends a position update also. // Construction of new prim - if (this._parent_scene.needsMeshing(_pbs)) + if (_parent_scene.needsMeshing(_pbs)) { - - // Don't need to re-enable body.. it's done in SetMesh IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); // createmesh returns null when it's a shape that isn't a cube. @@ -463,8 +460,6 @@ namespace OpenSim.Region.Physics.OdePlugin myrot.Y = _orientation.y; myrot.Z = _orientation.z; d.GeomSetQuaternion(prim_geom, ref myrot); - - } } else @@ -480,7 +475,7 @@ namespace OpenSim.Region.Physics.OdePlugin //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); - if (IsPhysical && Body == (IntPtr)0) + if (IsPhysical && Body == (IntPtr) 0) { // Re creates body on size. // EnableBody also does setMass() @@ -493,12 +488,13 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintsize = _size; } + public void changeshape(float timestamp) { string oldname = _parent_scene.geom_name_map[prim_geom]; // Cleanup of old prim geometry and Bodies - if (IsPhysical && Body != (IntPtr)0) + if (IsPhysical && Body != (IntPtr) 0) { disableBody(); } @@ -509,7 +505,7 @@ namespace OpenSim.Region.Physics.OdePlugin } // Construction of new prim - if (this._parent_scene.needsMeshing(_pbs)) + if (_parent_scene.needsMeshing(_pbs)) { IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); if (mesh != null) @@ -525,7 +521,7 @@ namespace OpenSim.Region.Physics.OdePlugin { prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); } - if (IsPhysical && Body == (IntPtr)0) + if (IsPhysical && Body == (IntPtr) 0) { //re-create new body enableBody(); @@ -544,11 +540,13 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintshape = false; } + public override bool IsPhysical { get { return m_isphysical; } set { m_isphysical = value; } } + public void setPrimForRemoval() { m_taintremove = true; @@ -556,9 +554,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override bool Flying { - get - { - return false; //no flying prims for you + get { return false; //no flying prims for you } set { } } @@ -568,16 +564,19 @@ namespace OpenSim.Region.Physics.OdePlugin get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return m_throttleUpdates; } @@ -588,20 +587,13 @@ namespace OpenSim.Region.Physics.OdePlugin { get { return _position; } - set - { - _position = value; - - } + set { _position = value; } } public override PhysicsVector Size { get { return _size; } - set - { - _size = value; - } + set { _size = value; } } public override float Mass @@ -626,10 +618,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override PrimitiveBaseShape Shape { - set - { - _pbs = value; - } + set { _pbs = value; } } public override PhysicsVector Velocity @@ -639,9 +628,9 @@ namespace OpenSim.Region.Physics.OdePlugin // Averate previous velocity with the new one so // client object interpolation works a 'little' better PhysicsVector returnVelocity = new PhysicsVector(); - returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2; - returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2; - returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2; + returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; + returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2; + returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2; return returnVelocity; } set { _velocity = value; } @@ -656,11 +645,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override Quaternion Orientation { get { return _orientation; } - set - { - _orientation = value; - - } + set { _orientation = value; } } public override PhysicsVector Acceleration @@ -688,7 +673,7 @@ namespace OpenSim.Region.Physics.OdePlugin { // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! - if (Body != (IntPtr)0) + if (Body != (IntPtr) 0) { d.Vector3 vec = d.BodyGetPosition(Body); d.Quaternion ori = d.BodyGetQuaternion(Body); @@ -715,8 +700,6 @@ namespace OpenSim.Region.Physics.OdePlugin // It's a hack and will generate a console message if it fails. - - //IsPhysical = false; base.RaiseOutOfBounds(_position); _velocity.X = 0; @@ -736,7 +719,6 @@ namespace OpenSim.Region.Physics.OdePlugin && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)) { - _zeroFlag = true; } else @@ -746,7 +728,6 @@ namespace OpenSim.Region.Physics.OdePlugin } - if (_zeroFlag) { // Supposedly this is supposed to tell SceneObjectGroup that @@ -811,10 +792,10 @@ namespace OpenSim.Region.Physics.OdePlugin m_rotationalVelocity.Z = 0; _zeroFlag = true; } - } + public override void SetMomentum(PhysicsVector momentum) { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 8bb822e..f2c9b57 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using Axiom.Math; using Ode.NET; using OpenSim.Framework; @@ -99,17 +100,17 @@ namespace OpenSim.Region.Physics.OdePlugin private d.Contact TerrainContact; private d.Contact AvatarMovementprimContact; private d.Contact AvatarMovementTerrainContact; - + private int m_physicsiterations = 10; private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag private PhysicsActor PANull = new NullPhysicsActor(); private float step_time = 0.0f; public IntPtr world; - + public IntPtr space; // split static geometry collision handling into spaces of 30 meters - public IntPtr[,] staticPrimspace = new IntPtr[(int)(300/metersInSpace),(int)(300/metersInSpace)]; - + public IntPtr[,] staticPrimspace = new IntPtr[(int) (300/metersInSpace),(int) (300/metersInSpace)]; + public static Object OdeLock = new Object(); public IMesher mesher; @@ -126,7 +127,7 @@ namespace OpenSim.Region.Physics.OdePlugin contact.surface.soft_erp = 0.005f; contact.surface.soft_cfm = 0.00003f; */ - + contact.surface.mu = 250.0f; contact.surface.bounce = 0.2f; @@ -151,7 +152,7 @@ namespace OpenSim.Region.Physics.OdePlugin contactgroup = d.JointGroupCreate(0); //contactgroup - + d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f); d.WorldSetAutoDisableFlag(world, false); d.WorldSetContactSurfaceLayer(world, 0.001f); @@ -165,10 +166,9 @@ namespace OpenSim.Region.Physics.OdePlugin { for (int j = 0; j < staticPrimspace.GetLength(1); j++) { - staticPrimspace[i,j] = IntPtr.Zero; + staticPrimspace[i, j] = IntPtr.Zero; } } - } public override void Initialise(IMesher meshmerizer) @@ -184,25 +184,25 @@ namespace OpenSim.Region.Physics.OdePlugin private void near(IntPtr space, IntPtr g1, IntPtr g2) { // no lock here! It's invoked from within Simulate(), which is thread-locked - if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2) ) + if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) { // Separating static prim geometry spaces. // We'll be calling near recursivly if one // of them is a space to find all of the // contact points in the space - + d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); //Colliding a space or a geom with a space or a geom. //Collide all geoms in each space.. //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); - } - else + } + else { // Colliding Geom To Geom // This portion of the function 'was' blatantly ripped off from BoxStack.cs - + IntPtr b1 = d.GeomGetBody(g1); IntPtr b2 = d.GeomGetBody(g2); @@ -213,7 +213,7 @@ namespace OpenSim.Region.Physics.OdePlugin return; d.GeomClassID id = d.GeomGetClass(g1); - + String name1 = null; String name2 = null; @@ -228,21 +228,22 @@ namespace OpenSim.Region.Physics.OdePlugin if (id == d.GeomClassID.TriMeshClass) { - // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); + // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); } - + int count = 0; try { count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); } - catch (System.Runtime.InteropServices.SEHException) + catch (SEHException) { - MainLog.Instance.Error("PHYSICS", "The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); + MainLog.Instance.Error("PHYSICS", + "The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); base.TriggerPhysicsBasedRestart(); } - + for (int i = 0; i < count; i++) { IntPtr joint; @@ -263,17 +264,17 @@ namespace OpenSim.Region.Physics.OdePlugin // We only need to test p2 for 'jump crouch purposes' p2.IsColliding = true; - - switch(p1.PhysicsActorType) { - case (int)ActorTypes.Agent: + switch (p1.PhysicsActorType) + { + case (int) ActorTypes.Agent: p2.CollidingObj = true; break; - case (int)ActorTypes.Prim: - if (p2.Velocity.X >0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) + case (int) ActorTypes.Prim: + if (p2.Velocity.X > 0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) p2.CollidingObj = true; break; - case (int)ActorTypes.Unknown: + case (int) ActorTypes.Unknown: p2.CollidingGround = true; break; default: @@ -282,7 +283,9 @@ namespace OpenSim.Region.Physics.OdePlugin } // we don't want prim or avatar to explode + #region InterPenetration Handling - Unintended physics explosions + if (contacts[i].depth >= 0.08f) { if (contacts[i].depth >= 1.00f) @@ -290,30 +293,31 @@ namespace OpenSim.Region.Physics.OdePlugin //MainLog.Instance.Debug("PHYSICS",contacts[i].depth.ToString()); } // If you interpenetrate a prim with an agent - if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Prim) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Prim)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent && + p1.PhysicsActorType == (int) ActorTypes.Prim) || + (p1.PhysicsActorType == (int) ActorTypes.Agent && + p2.PhysicsActorType == (int) ActorTypes.Prim)) { - - if (p2.PhysicsActorType == (int)ActorTypes.Agent) + if (p2.PhysicsActorType == (int) ActorTypes.Agent) { p2.CollidingObj = true; //contacts[i].depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); - OdeCharacter character = (OdeCharacter)p2; + OdeCharacter character = (OdeCharacter) p2; character.SetPidStatus(true); //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); - } else { contacts[i].depth = 0.0000000f; } - if (p1.PhysicsActorType == (int)ActorTypes.Agent) + if (p1.PhysicsActorType == (int) ActorTypes.Agent) { p1.CollidingObj = true; //contacts[i].depth = 0.003f; p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2)); - OdeCharacter character = (OdeCharacter)p2; + OdeCharacter character = (OdeCharacter) p2; character.SetPidStatus(true); } else @@ -322,39 +326,45 @@ namespace OpenSim.Region.Physics.OdePlugin } } // If you interpenetrate a prim with another prim - if (p1.PhysicsActorType == (int)ActorTypes.Prim && p2.PhysicsActorType == (int)ActorTypes.Prim) + if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim) { // Don't collide, one or both prim will explode. contacts[i].depth = -1f; } if (contacts[i].depth >= 1.00f) { - if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Unknown) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Unknown)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent && + p1.PhysicsActorType == (int) ActorTypes.Unknown) || + (p1.PhysicsActorType == (int) ActorTypes.Agent && + p2.PhysicsActorType == (int) ActorTypes.Unknown)) { - - if (p2.PhysicsActorType == (int)ActorTypes.Agent) + if (p2.PhysicsActorType == (int) ActorTypes.Agent) { - OdeCharacter character = (OdeCharacter)p2; - + OdeCharacter character = (OdeCharacter) p2; + //p2.CollidingObj = true; contacts[i].depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); - contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); + contacts[i].pos = + new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), + contacts[i].pos.Y + (p1.Size.Y/2), + contacts[i].pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); - } else { - } - if (p1.PhysicsActorType == (int)ActorTypes.Agent) + if (p1.PhysicsActorType == (int) ActorTypes.Agent) { - OdeCharacter character = (OdeCharacter)p2; + OdeCharacter character = (OdeCharacter) p2; //p2.CollidingObj = true; contacts[i].depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); - contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); + contacts[i].pos = + new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), + contacts[i].pos.Y + (p1.Size.Y/2), + contacts[i].pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); } else @@ -364,18 +374,18 @@ namespace OpenSim.Region.Physics.OdePlugin } } } + #endregion if (contacts[i].depth >= 0f) { if (name1 == "Terrain" || name2 == "Terrain") { - - if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && + (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) { AvatarMovementTerrainContact.geom = contacts[i]; joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); - } else { @@ -385,11 +395,11 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && + (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) { AvatarMovementprimContact.geom = contacts[i]; joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); - } else { @@ -399,7 +409,7 @@ namespace OpenSim.Region.Physics.OdePlugin } d.JointAttach(joint, b1, b2); } - + if (count > 3) { p2.ThrottleUpdates = true; @@ -421,7 +431,7 @@ namespace OpenSim.Region.Physics.OdePlugin } // If the sim is running slow this frame, // don't process collision for prim! - if (timeStep < (m_SkipFramesAtms / 3)) + if (timeStep < (m_SkipFramesAtms/3)) { foreach (OdePrim chr in _activeprims) { @@ -432,16 +442,16 @@ namespace OpenSim.Region.Physics.OdePlugin //foreach (OdePrim ch2 in _prims) /// should be a separate space -- lots of avatars will be N**2 slow //{ - //if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body)) - //{ - // Only test prim that are 0.03 meters away in one direction. - // This should be Optimized! - - //if ((Math.Abs(ch2.Position.X - chr.Position.X) < 0.03) || (Math.Abs(ch2.Position.Y - chr.Position.Y) < 0.03) || (Math.Abs(ch2.Position.X - chr.Position.X) < 0.03)) - //{ - //d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback); - //} - //} + //if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body)) + //{ + // Only test prim that are 0.03 meters away in one direction. + // This should be Optimized! + + //if ((Math.Abs(ch2.Position.X - chr.Position.X) < 0.03) || (Math.Abs(ch2.Position.Y - chr.Position.Y) < 0.03) || (Math.Abs(ch2.Position.X - chr.Position.X) < 0.03)) + //{ + //d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback); + //} + //} //} } } @@ -456,7 +466,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (d.BodyIsEnabled(chr.Body)) { d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback); - } } } @@ -492,7 +501,6 @@ namespace OpenSim.Region.Physics.OdePlugin p.setPrimForRemoval(); AddPhysicsActorTaint(prim); - } } } @@ -519,13 +527,14 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'removeprim from scene':" + + ((OdePrim) prim).m_targetSpace.ToString()); } } } - //If there are no more geometries in the sub-space, we don't need it in the main space anymore if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) { @@ -541,17 +550,18 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'removeprim from scene':" + + ((OdePrim) prim).m_targetSpace.ToString()); } } - } + } } d.GeomDestroy(prim.prim_geom); _prims.Remove(prim); } - } public void resetSpaceArrayItemToZero(IntPtr space) @@ -566,7 +576,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } - public void resetSpaceArrayItemToZero(int arrayitemX,int arrayitemY) + public void resetSpaceArrayItemToZero(int arrayitemX, int arrayitemY) { staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero; } @@ -582,16 +592,17 @@ namespace OpenSim.Region.Physics.OdePlugin // never be called if the prim is physical(active) if (currentspace != space) { - if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr)0) + if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr) 0) { if (d.GeomIsSpace(currentspace)) { - d.SpaceRemove(currentspace, geom); } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + + " Geom:" + geom.ToString()); } } else @@ -599,7 +610,7 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr sGeomIsIn = d.GeomGetSpace(geom); if (!(sGeomIsIn.Equals(null))) { - if (sGeomIsIn != (IntPtr)0) + if (sGeomIsIn != (IntPtr) 0) { if (d.GeomIsSpace(currentspace)) { @@ -607,7 +618,9 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); } } } @@ -617,7 +630,7 @@ namespace OpenSim.Region.Physics.OdePlugin //If there are no more geometries in the sub-space, we don't need it in the main space anymore if (d.SpaceGetNumGeoms(currentspace) == 0) { - if (currentspace != (IntPtr)0) + if (currentspace != (IntPtr) 0) { if (d.GeomIsSpace(currentspace)) { @@ -628,9 +641,10 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + currentspace.ToString() + " Geom:" + geom.ToString()); } - } } } @@ -639,15 +653,16 @@ namespace OpenSim.Region.Physics.OdePlugin // this is a physical object that got disabled. ;.; if (d.SpaceQuery(currentspace, geom)) { - if (currentspace != (IntPtr)0) + if (currentspace != (IntPtr) 0) if (d.GeomIsSpace(currentspace)) { d.SpaceRemove(currentspace, geom); } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); - + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + currentspace.ToString() + " Geom:" + geom.ToString()); } } else @@ -655,7 +670,7 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr sGeomIsIn = d.GeomGetSpace(geom); if (!(sGeomIsIn.Equals(null))) { - if (sGeomIsIn != (IntPtr)0) + if (sGeomIsIn != (IntPtr) 0) { if (d.GeomIsSpace(sGeomIsIn)) { @@ -663,14 +678,16 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); } } } } } - + // The routines in the Position and Size sections do the 'inserting' into the space, // so all we have to do is make sure that the space that we're putting the prim into // is in the 'main' space. @@ -679,17 +696,18 @@ namespace OpenSim.Region.Physics.OdePlugin if (newspace == IntPtr.Zero) { - newspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]); + newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); d.HashSpaceSetLevels(newspace, -4, 66); } - + return newspace; } - public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) { + public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) + { // creating a new space for prim and inserting it into main space. staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); - d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX,iprimspaceArrItemY]); + d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; } @@ -697,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin { int[] xyspace = calculateSpaceArrayItemFromPos(pos); //MainLog.Instance.Verbose("Physics", "Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); - IntPtr locationbasedspace = staticPrimspace[xyspace[0],xyspace[1]]; + IntPtr locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]]; //locationbasedspace = space; return locationbasedspace; @@ -706,17 +724,17 @@ namespace OpenSim.Region.Physics.OdePlugin public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) { int[] returnint = new int[2]; - - returnint[0] = (int)(pos.X / metersInSpace); - - if (returnint[0] > ((int)(259f / metersInSpace))) - returnint[0] = ((int)(259f / metersInSpace)); + + returnint[0] = (int) (pos.X/metersInSpace); + + if (returnint[0] > ((int) (259f/metersInSpace))) + returnint[0] = ((int) (259f/metersInSpace)); if (returnint[0] < 0) returnint[0] = 0; - returnint[1] = (int)(pos.Y / metersInSpace); - if (returnint[0] > ((int)(259f / metersInSpace))) - returnint[0] = ((int)(259f / metersInSpace)); + returnint[1] = (int) (pos.Y/metersInSpace); + if (returnint[0] > ((int) (259f/metersInSpace))) + returnint[0] = ((int) (259f/metersInSpace)); if (returnint[0] < 0) returnint[0] = 0; @@ -726,7 +744,6 @@ namespace OpenSim.Region.Physics.OdePlugin private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) { - PhysicsVector pos = new PhysicsVector(); pos.X = position.X; pos.Y = position.Y; @@ -741,21 +758,21 @@ namespace OpenSim.Region.Physics.OdePlugin rot.y = rotation.y; rot.z = rotation.z; - + int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); IntPtr targetspace = calculateSpaceForGeom(pos); if (targetspace == IntPtr.Zero) - targetspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]); + targetspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); OdePrim newPrim; lock (OdeLock) { newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical); - + _prims.Add(newPrim); } - + return newPrim; } @@ -763,16 +780,14 @@ namespace OpenSim.Region.Physics.OdePlugin { // adds active prim.. (ones that should be iterated over in collisions_optimized - _activeprims.Add(activatePrim); - + _activeprims.Add(activatePrim); } + public void remActivePrim(OdePrim deactivatePrim) { - - _activeprims.Remove(deactivatePrim); - - + _activeprims.Remove(deactivatePrim); } + public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount) { /* String name1 = null; @@ -818,7 +833,7 @@ namespace OpenSim.Region.Physics.OdePlugin return 1; } - + public bool needsMeshing(PrimitiveBaseShape pbs) { if (pbs.ProfileHollow != 0) @@ -833,7 +848,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) //To be removed { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, @@ -848,12 +863,12 @@ namespace OpenSim.Region.Physics.OdePlugin /// support simple box & hollow box now; later, more shapes if (needsMeshing(pbs)) { - mesh = mesher.CreateMesh(primName, pbs, size); + mesh = mesher.CreateMesh(primName, pbs, size); } - + break; } - + result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); @@ -864,10 +879,9 @@ namespace OpenSim.Region.Physics.OdePlugin { if (prim is OdePrim) { - OdePrim taintedprim = ((OdePrim)prim); + OdePrim taintedprim = ((OdePrim) prim); if (!(_taintedPrim.Contains(taintedprim))) _taintedPrim.Add(taintedprim); - } } @@ -877,19 +891,18 @@ namespace OpenSim.Region.Physics.OdePlugin step_time += timeStep; - - // If We're loaded down by something else, - // or debugging with the Visual Studio project on pause - // skip a few frames to catch up gracefully. - // without shooting the physicsactors all over the place - + + // If We're loaded down by something else, + // or debugging with the Visual Studio project on pause + // skip a few frames to catch up gracefully. + // without shooting the physicsactors all over the place if (step_time >= m_SkipFramesAtms) { // Instead of trying to catch up, it'll do one physics frame only step_time = ODE_STEPSIZE; - this.m_physicsiterations = 5; + m_physicsiterations = 5; } else { @@ -897,35 +910,36 @@ namespace OpenSim.Region.Physics.OdePlugin } lock (OdeLock) { - // Process 10 frames if the sim is running normal.. - // process 5 frames if the sim is running slow - try{ + // Process 10 frames if the sim is running normal.. + // process 5 frames if the sim is running slow + try + { d.WorldSetQuickStepNumIterations(world, m_physicsiterations); } - catch (System.StackOverflowException) + catch (StackOverflowException) { - MainLog.Instance.Error("PHYSICS", "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); + MainLog.Instance.Error("PHYSICS", + "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); base.TriggerPhysicsBasedRestart(); } int i = 0; - - + + // Figure out the Frames Per Second we're going at. - - fps = (((step_time / ODE_STEPSIZE * m_physicsiterations)*2)* 10); - + + fps = (((step_time/ODE_STEPSIZE*m_physicsiterations)*2)*10); + while (step_time > 0.0f) { - foreach (OdeCharacter actor in _characters) { - actor.Move(timeStep); - actor.collidelock = true; + actor.Move(timeStep); + actor.collidelock = true; } - + collision_optimized(timeStep); d.WorldQuickStep(world, ODE_STEPSIZE); d.JointGroupEmpty(contactgroup); @@ -933,7 +947,7 @@ namespace OpenSim.Region.Physics.OdePlugin { actor.collidelock = false; } - + step_time -= ODE_STEPSIZE; i++; } @@ -941,7 +955,6 @@ namespace OpenSim.Region.Physics.OdePlugin foreach (OdeCharacter actor in _characters) { actor.UpdatePositionAndVelocity(); - } bool processedtaints = false; foreach (OdePrim prim in _taintedPrim) @@ -963,7 +976,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag)) { actor.UpdatePositionAndVelocity(); - } } } @@ -984,25 +996,25 @@ namespace OpenSim.Region.Physics.OdePlugin public float[] ResizeTerrain512(float[] heightMap) { float[] returnarr = new float[262144]; - float[,] resultarr = new float[m_regionWidth, m_regionHeight]; + float[,] resultarr = new float[m_regionWidth,m_regionHeight]; // Filling out the array into it's multi-dimentional components for (int y = 0; y < m_regionHeight; y++) { for (int x = 0; x < m_regionWidth; x++) { - resultarr[y,x] = heightMap[y * m_regionWidth + x]; + resultarr[y, x] = heightMap[y*m_regionWidth + x]; } } // Resize using interpolation - + // This particular way is quick but it only works on a multiple of the original // The idea behind this method can be described with the following diagrams // second pass and third pass happen in the same loop really.. just separated // them to show what this does. - + // First Pass // ResultArr: // 1,1,1,1,1,1 @@ -1054,12 +1066,12 @@ namespace OpenSim.Region.Physics.OdePlugin // 4th # // on single loop. - float[,] resultarr2 = new float[512, 512]; + float[,] resultarr2 = new float[512,512]; for (int y = 0; y < m_regionHeight; y++) { for (int x = 0; x < m_regionWidth; x++) { - resultarr2[y*2,x*2] = resultarr[y,x]; + resultarr2[y*2, x*2] = resultarr[y, x]; if (y < m_regionHeight) { @@ -1067,16 +1079,17 @@ namespace OpenSim.Region.Physics.OdePlugin { if (x + 1 < m_regionWidth) { - resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x+1] + resultarr[y+1, x+1])/4); + resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] + + resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); } else { - resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x]) / 2); + resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x])/2); } } else { - resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; + resultarr2[(y*2) + 1, x*2] = resultarr[y, x]; } } if (x < m_regionWidth) @@ -1085,31 +1098,32 @@ namespace OpenSim.Region.Physics.OdePlugin { if (y + 1 < m_regionHeight) { - resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); + resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + + resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); } else { - resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1]) / 2); + resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1])/2); } } else { - resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x]; + resultarr2[y*2, (x*2) + 1] = resultarr[y, x]; } } if (x < m_regionWidth && y < m_regionHeight) { if ((x + 1 < m_regionWidth) && (y + 1 < m_regionHeight)) { - resultarr2[(y * 2) + 1, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); + resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + + resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); } else { - resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x]; + resultarr2[(y*2) + 1, (x*2) + 1] = resultarr[y, x]; } } } - } //Flatten out the array int i = 0; @@ -1119,7 +1133,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (resultarr2[y, x] <= 0) returnarr[i] = 0.0000001f; - else + else returnarr[i] = resultarr2[y, x]; i++; @@ -1127,8 +1141,8 @@ namespace OpenSim.Region.Physics.OdePlugin } return returnarr; - } + public override void SetTerrain(float[] heightMap) { // this._heightmap[i] = (double)heightMap[i]; @@ -1137,8 +1151,8 @@ namespace OpenSim.Region.Physics.OdePlugin const uint heightmapWidth = m_regionWidth + 2; const uint heightmapHeight = m_regionHeight + 2; - const uint heightmapWidthSamples = 2 * m_regionWidth + 2; - const uint heightmapHeightSamples = 2 * m_regionHeight + 2; + const uint heightmapWidthSamples = 2*m_regionWidth + 2; + const uint heightmapHeightSamples = 2*m_regionHeight + 2; const float scale = 1.0f; const float offset = 0.0f; const float thickness = 2.0f; @@ -1166,7 +1180,8 @@ namespace OpenSim.Region.Physics.OdePlugin } IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, - (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale, offset, thickness, wrap); + (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale, + offset, thickness, wrap); d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); LandGeom = d.CreateHeightfield(space, HeightmapData, 1); geom_name_map[LandGeom] = "Terrain"; @@ -1193,7 +1208,4 @@ namespace OpenSim.Region.Physics.OdePlugin { } } - - - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs index da9f587..3bb71d4 100644 --- a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 26310f9..1bc3490 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Collections.Generic; using System; +using System.Collections.Generic; using Axiom.Math; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; @@ -114,10 +114,10 @@ namespace OpenSim.Region.Physics.POSPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { POSPrim prim = new POSPrim(); @@ -136,18 +136,20 @@ namespace OpenSim.Region.Physics.POSPlugin " sizeX: " + p.Size.X * 0.5 + 0.5); */ - Vector3 rotatedPos = p.Orientation.Inverse() * new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y, c.Position.Z - p.Position.Z); - Vector3 avatarSize = p.Orientation.Inverse() * new Vector3(c.Size.X, c.Size.Y, c.Size.Z); + Vector3 rotatedPos = p.Orientation.Inverse()* + new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y, + c.Position.Z - p.Position.Z); + Vector3 avatarSize = p.Orientation.Inverse()*new Vector3(c.Size.X, c.Size.Y, c.Size.Z); - if (Math.Abs(rotatedPos.x) >= (p.Size.X * 0.5 + Math.Abs(avatarSize.x))) + if (Math.Abs(rotatedPos.x) >= (p.Size.X*0.5 + Math.Abs(avatarSize.x))) { return false; } - if (Math.Abs(rotatedPos.y) >= (p.Size.Y * 0.5 + Math.Abs(avatarSize.y))) + if (Math.Abs(rotatedPos.y) >= (p.Size.Y*0.5 + Math.Abs(avatarSize.y))) { return false; } - if (Math.Abs(rotatedPos.z) >= (p.Size.Z * 0.5 + Math.Abs(avatarSize.z))) + if (Math.Abs(rotatedPos.z) >= (p.Size.Z*0.5 + Math.Abs(avatarSize.z))) { return false; } @@ -182,12 +184,12 @@ namespace OpenSim.Region.Physics.POSPlugin if (!character.Flying) { - character._target_velocity.Z += gravity * timeStep; + character._target_velocity.Z += gravity*timeStep; } bool forcedZ = false; - character.Position.X += character._target_velocity.X * timeStep; - character.Position.Y += character._target_velocity.Y * timeStep; + character.Position.X += character._target_velocity.X*timeStep; + character.Position.Y += character._target_velocity.Y*timeStep; if (character.Position.Y < 0) { @@ -207,15 +209,15 @@ namespace OpenSim.Region.Physics.POSPlugin character.Position.X = 255.9F; } - float terrainheight = _heightMap[(int)character.Position.Y * 256 + (int)character.Position.X]; - if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) + float terrainheight = _heightMap[(int) character.Position.Y*256 + (int) character.Position.X]; + if (character.Position.Z + (character._target_velocity.Z*timeStep) < terrainheight + 2) { character.Position.Z = terrainheight + 1.0f; forcedZ = true; } else { - character.Position.Z += character._target_velocity.Z * timeStep; + character.Position.Z += character._target_velocity.Z*timeStep; } /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- @@ -224,21 +226,21 @@ namespace OpenSim.Region.Physics.POSPlugin if (check_all_prims(character)) { - character.Position.Z = oldposZ; // first try Z axis + character.Position.Z = oldposZ; // first try Z axis if (check_all_prims(character)) { - character.Position.Z = oldposZ + 0.4f; // try harder + character.Position.Z = oldposZ + 0.4f; // try harder if (check_all_prims(character)) { character.Position.X = oldposX; character.Position.Y = oldposY; character.Position.Z = oldposZ; - character.Position.X = character.Position.X + (character._target_velocity.X * timeStep); + character.Position.X = character.Position.X + (character._target_velocity.X*timeStep); if (check_all_prims(character)) { character.Position.X = oldposX; } - character.Position.Y = character.Position.Y + (character._target_velocity.Y * timeStep); + character.Position.Y = character.Position.Y + (character._target_velocity.Y*timeStep); if (check_all_prims(character)) { character.Position.Y = oldposY; @@ -253,7 +255,7 @@ namespace OpenSim.Region.Physics.POSPlugin { forcedZ = true; } - } + } if (character.Position.Y < 0) { @@ -273,8 +275,8 @@ namespace OpenSim.Region.Physics.POSPlugin character.Position.X = 255.9F; } - character._velocity.X = (character.Position.X - oldposX) / timeStep; - character._velocity.Y = (character.Position.Y - oldposY) / timeStep; + character._velocity.X = (character.Position.X - oldposX)/timeStep; + character._velocity.Y = (character.Position.Y - oldposY)/timeStep; if (forcedZ) { @@ -284,7 +286,7 @@ namespace OpenSim.Region.Physics.POSPlugin } else { - character._velocity.Z = (character.Position.Z - oldposZ) / timeStep; + character._velocity.Z = (character.Position.Z - oldposZ)/timeStep; } } return fps; @@ -326,31 +328,37 @@ namespace OpenSim.Region.Physics.POSPlugin _position = new PhysicsVector(); _acceleration = new PhysicsVector(); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } @@ -362,16 +370,19 @@ namespace OpenSim.Region.Physics.POSPlugin get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get { return _position; } @@ -383,18 +394,22 @@ namespace OpenSim.Region.Physics.POSPlugin get { return new PhysicsVector(0.5f, 0.5f, 1.0f); } set { } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } @@ -402,10 +417,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity @@ -461,41 +473,49 @@ namespace OpenSim.Region.Physics.POSPlugin _position = new PhysicsVector(); _acceleration = new PhysicsVector(); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool IsColliding { get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get { return _position; } @@ -530,10 +550,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity @@ -571,6 +588,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override void SetMomentum(PhysicsVector momentum) { } + public override bool Flying { get { return false; } @@ -583,4 +601,4 @@ namespace OpenSim.Region.Physics.POSPlugin set { return; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs index 8e6d2a6..36cb952 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 8525e75..20bf358 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -128,17 +128,19 @@ namespace OpenSim.Region.Physics.PhysXPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) //To be removed { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { return AddPrim(position, size, rotation); } + public override void AddPhysicsActorTaint(PhysicsActor prim) { - } + public override float Simulate(float timeStep) { float fps = 0f; @@ -209,51 +211,61 @@ namespace OpenSim.Region.Physics.PhysXPlugin _acceleration = new PhysicsVector(); _character = character; } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } set { flying = value; } } + public override bool IsColliding { get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override PhysicsVector Position { get { return _position; } @@ -273,22 +285,27 @@ namespace OpenSim.Region.Physics.PhysXPlugin get { return PhysicsVector.Zero; } set { } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } } + public override PhysicsVector Velocity { get { return _velocity; } @@ -345,23 +362,21 @@ namespace OpenSim.Region.Physics.PhysXPlugin gravityAccel = 0; } } + public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } + } + + public void UpdatePosition() + { + Vec3 vec = _character.Position; + _position.X = vec.X; + _position.Y = vec.Y; + _position.Z = vec.Z; } - - public void UpdatePosition() - { - Vec3 vec = this._character.Position; - this._position.X = vec.X; - this._position.Y = vec.Y; - this._position.Z = vec.Z; - } - } - + } + public class PhysXPrim : PhysicsActor { @@ -376,55 +391,62 @@ namespace OpenSim.Region.Physics.PhysXPlugin _acceleration = new PhysicsVector(); _prim = prim; } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool Flying { get { return false; //no flying prims for you } set { } } + public override bool IsColliding { - get - { - return false; - } + get { return false; } set { } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get @@ -449,75 +471,52 @@ namespace OpenSim.Region.Physics.PhysXPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity { - get - { - return _velocity; - } - set - { - _velocity = value; - } + get { return _velocity; } + set { _velocity = value; } } - + public override bool Kinematic { - get - { - return this._prim.Kinematic; - } - set - { - this._prim.Kinematic = value; - } + get { return _prim.Kinematic; } + set { _prim.Kinematic = value; } } - + public override Quaternion Orientation { get { Quaternion res = new Quaternion(); - PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); + PhysXWrapper.Quaternion quat = _prim.GetOrientation(); res.w = quat.W; res.x = quat.X; res.y = quat.Y; res.z = quat.Z; return res; } - set - { - - } + set { } } - + public override PhysicsVector Acceleration { - get - { - return _acceleration; - } - + get { return _acceleration; } } - public void SetAcceleration (PhysicsVector accel) + + public void SetAcceleration(PhysicsVector accel) { - this._acceleration = accel; + _acceleration = accel; } - + public override void AddForce(PhysicsVector force) { - } - + public override void SetMomentum(PhysicsVector momentum) { - } public override PhysicsVector Size @@ -545,6 +544,5 @@ namespace OpenSim.Region.Physics.PhysXPlugin { get { return PhysicsVector.Zero; } } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 6ba7018..9c595ed 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -634,4 +634,4 @@ namespace OpenSim.Region.ScriptEngine.Common //OpenSim functions string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index 3a0b8ed..232baf8 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (!(o is Vector3)) return false; - Vector3 vector = (Vector3)o; + Vector3 vector = (Vector3) o; return (x == vector.x && x == vector.x && z == vector.z); } @@ -88,11 +88,12 @@ namespace OpenSim.Region.ScriptEngine.Common #endregion #region Vector & Vector Math + // Vector-Vector Math public static Vector3 operator +(Vector3 lhs, Vector3 rhs) { return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); - } + } public static Vector3 operator -(Vector3 lhs, Vector3 rhs) { @@ -101,51 +102,53 @@ namespace OpenSim.Region.ScriptEngine.Common public static Vector3 operator *(Vector3 lhs, Vector3 rhs) { - return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); + return new Vector3(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z); } public static Vector3 operator %(Vector3 v1, Vector3 v2) { //Cross product Vector3 tv; - tv.x = (v1.y * v2.z) - (v1.z * v2.y); - tv.y = (v1.z * v2.x) - (v1.x * v2.z); - tv.z = (v1.x * v2.y) - (v1.y * v2.x); + tv.x = (v1.y*v2.z) - (v1.z*v2.y); + tv.y = (v1.z*v2.x) - (v1.x*v2.z); + tv.z = (v1.x*v2.y) - (v1.y*v2.x); return tv; } #endregion - + #region Vector & Float Math + // Vector-Float and Float-Vector Math public static Vector3 operator *(Vector3 vec, float val) { - return new Vector3(vec.x * val, vec.y * val, vec.z * val); + return new Vector3(vec.x*val, vec.y*val, vec.z*val); } public static Vector3 operator *(float val, Vector3 vec) { - return new Vector3(vec.x * val, vec.y * val, vec.z * val); + return new Vector3(vec.x*val, vec.y*val, vec.z*val); } public static Vector3 operator /(Vector3 v, float f) { - v.x = v.x / f; - v.y = v.y / f; - v.z = v.z / f; + v.x = v.x/f; + v.y = v.y/f; + v.z = v.z/f; return v; } #endregion #region Vector & Rotation Math + // Vector-Rotation Math public static Vector3 operator *(Vector3 v, Quaternion r) { Quaternion vq = new Quaternion(v.x, v.y, v.z, 0); Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s); - Quaternion result = (r * vq) * nq; + Quaternion result = (r*vq)*nq; return new Vector3(result.x, result.y, result.z); } @@ -157,38 +160,41 @@ namespace OpenSim.Region.ScriptEngine.Common Quaternion vq = new Quaternion(vec.x, vec.y, vec.z, 0); Quaternion nq = new Quaternion(-quat.x, -quat.y, -quat.z, quat.s); - Quaternion result = (quat * vq) * nq; + Quaternion result = (quat*vq)*nq; return new Vector3(result.x, result.y, result.z); } + #endregion #region Static Helper Functions + public static double Dot(Vector3 v1, Vector3 v2) { - return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); + return (v1.x*v2.x) + (v1.y*v2.y) + (v1.z*v2.z); } public static Vector3 Cross(Vector3 v1, Vector3 v2) { return new Vector3 - ( - v1.y * v2.z - v1.z * v2.y, - v1.z * v2.x - v1.x * v2.z, - v1.x * v2.y - v1.y * v2.x - ); + ( + v1.y*v2.z - v1.z*v2.y, + v1.z*v2.x - v1.x*v2.z, + v1.x*v2.y - v1.y*v2.x + ); } public static float Mag(Vector3 v) { - return (float)Math.Sqrt(v.x * v.y + v.y * v.y + v.z * v.z); + return (float) Math.Sqrt(v.x*v.y + v.y*v.y + v.z*v.z); } public static Vector3 Norm(Vector3 vector) { float mag = Mag(vector); - return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); + return new Vector3(vector.x/mag, vector.y/mag, vector.z/mag); } + #endregion } @@ -227,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (!(o is Quaternion)) return false; - Quaternion quaternion = (Quaternion)o; + Quaternion quaternion = (Quaternion) o; return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; } @@ -253,10 +259,10 @@ namespace OpenSim.Region.ScriptEngine.Common public static Quaternion operator *(Quaternion a, Quaternion b) { Quaternion c; - c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y; - c.y = a.s * b.y + a.y * b.s + a.z * b.x - a.x * b.z; - c.z = a.s * b.z + a.z * b.s + a.x * b.y - a.y * b.x; - c.s = a.s * b.s - a.x * b.x - a.y * b.y - a.z * b.z; + c.x = a.s*b.x + a.x*b.s + a.y*b.z - a.z*b.y; + c.y = a.s*b.y + a.y*b.s + a.z*b.x - a.x*b.z; + c.z = a.s*b.z + a.z*b.s + a.x*b.y - a.y*b.x; + c.s = a.s*b.s - a.x*b.x - a.y*b.y - a.z*b.z; return c; } } @@ -324,7 +330,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (start >= m_data.Length) { - return this.GetSublist(0, end); + return GetSublist(0, end); } if (end >= m_data.Length) { @@ -334,7 +340,7 @@ namespace OpenSim.Region.ScriptEngine.Common //ret = new object[m_data.Length - Math.Abs(end - start + 1)]; //Array.Copy(m_data, 0, ret, m_data.Length - start, end + 1); //Array.Copy(m_data, start, ret, 0, m_data.Length - start); - return this.GetSublist(0, end) + this.GetSublist(start, this.Data.Length - 1); + return GetSublist(0, end) + GetSublist(start, Data.Length - 1); //return new list(ret); } } @@ -379,4 +385,4 @@ namespace OpenSim.Region.ScriptEngine.Common } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs index e5f7220..4594ad8 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs @@ -52,4 +52,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index c81e6bd..0623cc5 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -39,7 +39,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); private CSharpCodeProvider codeProvider = new CSharpCodeProvider(); private static UInt64 scriptCompileCounter = 0; - private static int instanceID = new Random().Next(0, int.MaxValue); // Implemented due to peer preassure --- will cause garbage in ScriptEngines folder ;) + + private static int instanceID = new Random().Next(0, int.MaxValue); + // Implemented due to peer preassure --- will cause garbage in ScriptEngines folder ;) + //private ICodeCompiler icc = codeProvider.CreateCompiler(); public string CompileFromFile(string LSOFileName) { @@ -83,7 +86,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { // Output assembly name scriptCompileCounter++; - string OutFile = Path.Combine("ScriptEngines", "DotNetScript_" + instanceID.ToString() + "_" + scriptCompileCounter.ToString() + ".dll"); + string OutFile = + Path.Combine("ScriptEngines", + "DotNetScript_" + instanceID.ToString() + "_" + scriptCompileCounter.ToString() + ".dll"); try { File.Delete(OutFile); diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 4063647..8e37798 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -316,8 +316,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL quotes.Clear(); - + return Return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index a9297fd..2796b64 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -1638,7 +1638,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end) { - return m_LSL_Functions.llListReplaceList(dest,src,start,end); + return m_LSL_Functions.llListReplaceList(dest, src, start, end); } public void llLoadURL(string avatar_id, string message, string url) @@ -2025,7 +2025,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public const int REMOTE_DATA_CHANNEL = 1; public const int REMOTE_DATA_REQUEST = 2; public const int REMOTE_DATA_REPLY = 3; - + public const int PRIM_MATERIAL = 2; public const int PRIM_PHYSICS = 3; public const int PRIM_TEMP_ON_REZ = 4; @@ -2041,7 +2041,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public const int PRIM_FLEXIBLE = 21; public const int PRIM_TEXGEN = 22; public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake - public const int PRIM_POINT_LIGHT = 23; // Huh? + public const int PRIM_POINT_LIGHT = 23; // Huh? public const int PRIM_TEXGEN_DEFAULT = 0; public const int PRIM_TEXGEN_PLANAR = 1; public const int PRIM_TYPE_BOX = 0; @@ -2122,4 +2122,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public vector ZERO_VECTOR = new vector(0, 0, 0); public rotation ZERO_ROTATION = new rotation(0, 0, 0, 0); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index bc47241..d5a31fb 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -28,13 +28,11 @@ using System; using System.Collections.Generic; -using System.Collections; using System.Runtime.Remoting.Lifetime; using System.Text; using System.Threading; using Axiom.Math; using libsecondlife; -using libsecondlife.StructuredData; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs index 161cedf..8dfd908 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs @@ -217,4 +217,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs index 890335b..2d0d69d 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs @@ -184,9 +184,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { #if DEBUG m_ScriptEngine.Log.Debug("ScriptEngine", "Executing event:\r\n" - + "QIS.localID: " + QIS.localID - + ", QIS.itemID: " + QIS.itemID - + ", QIS.functionName: " + QIS.functionName); + + "QIS.localID: " + QIS.localID + + ", QIS.itemID: " + QIS.itemID + + ", QIS.functionName: " + QIS.functionName); #endif m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.functionName, QIS.param); @@ -197,14 +197,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine string text = "Error executing script function \"" + QIS.functionName + "\":\r\n"; //if (e.InnerException != null) //{ - // Send inner exception - text += e.InnerException.Message.ToString(); + // Send inner exception + text += e.InnerException.Message.ToString(); //} //else //{ - text += "\r\n"; - // Send normal - text += e.Message.ToString(); + text += "\r\n"; + // Send normal + text += e.Message.ToString(); //} try { @@ -222,7 +222,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //else //{ // T oconsole - m_ScriptEngine.Log.Error("ScriptEngine", "Unable to send text in-world:\r\n" + text); + m_ScriptEngine.Log.Error("ScriptEngine", + "Unable to send text in-world:\r\n" + text); } } finally @@ -338,4 +339,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index fdd7260..e403385 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs @@ -202,17 +202,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public void CheckHttpRequests() { - IHttpRequests iHttpReq = + IHttpRequests iHttpReq = m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); HttpRequestClass httpInfo = null; - if( iHttpReq != null ) + if (iHttpReq != null) httpInfo = iHttpReq.GetNextCompletedRequest(); - while ( httpInfo != null ) + while (httpInfo != null) { - //Console.WriteLine("PICKED HTTP REQ:" + httpInfo.response_body + httpInfo.status); // Deliver data to prim's remote_data handler @@ -221,7 +220,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // only returns the byte for HTTP_BODY_TRUNCATED, which is not // implemented here yet anyway. Should be fixed if/when maxsize // is supported - + object[] resobj = new object[] { httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body @@ -254,7 +253,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //Deliver data to prim's remote_data handler object[] resobj = new object[] { - 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), + 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", + rInfo.GetIntValue(), rInfo.GetStrVal() }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( @@ -284,4 +284,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index c1c792c..82049f7 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -121,4 +121,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 6b83dff..e211902 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -224,7 +224,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine #region Start/Stop/Reset script - Object startStopLock = new Object(); + private Object startStopLock = new Object(); /// <summary> /// Fetches, loads and hooks up a script to an objects events @@ -261,7 +261,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } // Create a new instance of the compiler (reuse) - Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); + private Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); + private void _StartScript(uint localID, LLUUID itemID, string Script) { lock (startStopLock) @@ -316,7 +317,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine CompiledScript.Start(LSLB); // Fire the first start-event - m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { }); + m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] {}); } catch (Exception e) { @@ -327,12 +328,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine string text = "Error compiling script:\r\n" + e.Message.ToString(); if (text.Length > 1500) text = text.Substring(0, 1500); - World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, + m_host.Name, m_host.UUID); } catch (Exception e2) { m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString()); - m_scriptEngine.Log.Error("ScriptEngine", "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); + m_scriptEngine.Log.Error("ScriptEngine", + "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); } } } @@ -342,39 +345,39 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { lock (startStopLock) { - // Stop script - Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); + // Stop script + Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); - // Stop long command on script - m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID); + // Stop long command on script + m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID); - LSL_BaseClass LSLBC = GetScript(localID, itemID); - if (LSLBC == null) - return; + LSL_BaseClass LSLBC = GetScript(localID, itemID); + if (LSLBC == null) + return; - // TEMP: First serialize it - //GetSerializedScript(localID, itemID); + // TEMP: First serialize it + //GetSerializedScript(localID, itemID); - try - { - // Get AppDomain - AppDomain ad = LSLBC.Exec.GetAppDomain(); - // Tell script not to accept new requests - GetScript(localID, itemID).Exec.StopScript(); - // Remove from internal structure - RemoveScript(localID, itemID); - // Tell AppDomain that we have stopped script - m_scriptEngine.m_AppDomainManager.StopScript(ad); - } - catch (Exception e) - { - Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + - ": " + e.ToString()); + try + { + // Get AppDomain + AppDomain ad = LSLBC.Exec.GetAppDomain(); + // Tell script not to accept new requests + GetScript(localID, itemID).Exec.StopScript(); + // Remove from internal structure + RemoveScript(localID, itemID); + // Tell AppDomain that we have stopped script + m_scriptEngine.m_AppDomainManager.StopScript(ad); + } + catch (Exception e) + { + Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + + ": " + e.ToString()); + } } } - } private string ProcessYield(string FileName) { @@ -435,4 +438,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs index 60aeb83..5818583 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs @@ -33,8 +33,8 @@ using System.Data.SqlClient; using System.IO; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Data; using OpenSim.Framework.Console; +using OpenSim.Framework.Data; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -62,7 +62,9 @@ namespace OpenSim.DataStore.MSSQL string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string connectionString = "Data Source=" + settingDataSource + ";Initial Catalog=" + settingInitialCatalog + ";Persist Security Info=" + settingPersistSecurityInfo + ";User ID=" + settingUserId + ";Password=" + settingPassword + ";"; + string connectionString = "Data Source=" + settingDataSource + ";Initial Catalog=" + settingInitialCatalog + + ";Persist Security Info=" + settingPersistSecurityInfo + ";User ID=" + + settingUserId + ";Password=" + settingPassword + ";"; ds = new DataSet(); @@ -85,11 +87,12 @@ namespace OpenSim.DataStore.MSSQL // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); TestTables(conn); - lock(ds) { + lock (ds) + { ds.Tables.Add(createPrimTable()); setupPrimCommands(primDa, conn); primDa.Fill(ds.Tables["prims"]); - + ds.Tables.Add(createShapeTable()); setupShapeCommands(shapeDa, conn); @@ -122,7 +125,8 @@ namespace OpenSim.DataStore.MSSQL public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) { - lock (ds) { + lock (ds) + { foreach (SceneObjectPart prim in obj.Children.Values) { MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); @@ -140,11 +144,12 @@ namespace OpenSim.DataStore.MSSQL DataTable shapes = ds.Tables["primshapes"]; string selectExp = "SceneGroupID = '" + obj.ToString() + "'"; - lock (ds) { + lock (ds) + { DataRow[] primRows = prims.Select(selectExp); foreach (DataRow row in primRows) { - LLUUID uuid = new LLUUID((string)row["UUID"]); + LLUUID uuid = new LLUUID((string) row["UUID"]); DataRow shapeRow = shapes.Rows.Find(uuid); if (shapeRow != null) { @@ -153,7 +158,7 @@ namespace OpenSim.DataStore.MSSQL row.Delete(); } } - + Commit(); } @@ -169,16 +174,18 @@ namespace OpenSim.DataStore.MSSQL string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'"; string orderByParent = "ParentID ASC"; - lock (ds) { + lock (ds) + { DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); - MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); - + MainLog.Instance.Verbose("DATASTORE", + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); + foreach (DataRow primRow in primsForRegion) { try { - string uuid = (string)primRow["UUID"]; - string objID = (string)primRow["SceneGroupID"]; + string uuid = (string) primRow["UUID"]; + string objID = (string) primRow["SceneGroupID"]; if (uuid == objID) //is new SceneObjectGroup ? { SceneObjectGroup group = new SceneObjectGroup(); @@ -190,12 +197,13 @@ namespace OpenSim.DataStore.MSSQL } else { - MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape"); + MainLog.Instance.Notice( + "No shape found for prim in storage, so setting default box shape"); prim.Shape = BoxShape.Default; - } + } group.AddPart(prim); group.RootPart = prim; - + createdObjects.Add(group.UUID, group); retvals.Add(group); } @@ -209,7 +217,8 @@ namespace OpenSim.DataStore.MSSQL } else { - MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape"); + MainLog.Instance.Notice( + "No shape found for prim in storage, so setting default box shape"); prim.Shape = BoxShape.Default; } createdObjects[new LLUUID(objID)].AddPart(prim); @@ -249,7 +258,7 @@ namespace OpenSim.DataStore.MSSQL public double[,] LoadTerrain(LLUUID regionID) { - double[,] terret = new double[256, 256]; + double[,] terret = new double[256,256]; terret.Initialize(); DataTable terrain = ds.Tables["terrain"]; @@ -264,16 +273,16 @@ namespace OpenSim.DataStore.MSSQL { DataRow row = rows[0]; - byte[] heightmap = (byte[])row["Heightfield"]; + byte[] heightmap = (byte[]) row["Heightfield"]; for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { - terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8); + terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); } } - rev = (int)row["Revision"]; + rev = (int) row["Revision"]; } else { @@ -290,22 +299,21 @@ namespace OpenSim.DataStore.MSSQL public void RemoveLandObject(LLUUID globalID) { - } public void StoreLandObject(Land parcel, LLUUID regionUUID) { - } - public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID) + public List<LandData> LoadLandObjects(LLUUID regionUUID) { return new List<LandData>(); } public void Commit() { - lock (ds) { + lock (ds) + { primDa.Update(ds, "prims"); shapeDa.Update(ds, "primshapes"); terrainDa.Update(ds, "terrain"); @@ -326,7 +334,7 @@ namespace OpenSim.DataStore.MSSQL * **********************************************************************/ - private void createCol(DataTable dt, string name, System.Type type) + private void createCol(DataTable dt, string name, Type type) { DataColumn col = new DataColumn(name, type); dt.Columns.Add(col); @@ -336,9 +344,9 @@ namespace OpenSim.DataStore.MSSQL { DataTable terrain = new DataTable("terrain"); - createCol(terrain, "RegionUUID", typeof(String)); - createCol(terrain, "Revision", typeof(Int32)); - createCol(terrain, "Heightfield", typeof(Byte[])); + createCol(terrain, "RegionUUID", typeof (String)); + createCol(terrain, "Revision", typeof (Int32)); + createCol(terrain, "Heightfield", typeof (Byte[])); return terrain; } @@ -347,62 +355,62 @@ namespace OpenSim.DataStore.MSSQL { DataTable prims = new DataTable("prims"); - createCol(prims, "UUID", typeof(System.String)); - createCol(prims, "RegionUUID", typeof(System.String)); - createCol(prims, "ParentID", typeof(System.Int32)); - createCol(prims, "CreationDate", typeof(System.Int32)); - createCol(prims, "Name", typeof(System.String)); - createCol(prims, "SceneGroupID", typeof(System.String)); + createCol(prims, "UUID", typeof (String)); + createCol(prims, "RegionUUID", typeof (String)); + createCol(prims, "ParentID", typeof (Int32)); + createCol(prims, "CreationDate", typeof (Int32)); + createCol(prims, "Name", typeof (String)); + createCol(prims, "SceneGroupID", typeof (String)); // various text fields - createCol(prims, "Text", typeof(System.String)); - createCol(prims, "Description", typeof(System.String)); - createCol(prims, "SitName", typeof(System.String)); - createCol(prims, "TouchName", typeof(System.String)); + createCol(prims, "Text", typeof (String)); + createCol(prims, "Description", typeof (String)); + createCol(prims, "SitName", typeof (String)); + createCol(prims, "TouchName", typeof (String)); // permissions - createCol(prims, "ObjectFlags", typeof(System.Int32)); - createCol(prims, "CreatorID", typeof(System.String)); - createCol(prims, "OwnerID", typeof(System.String)); - createCol(prims, "GroupID", typeof(System.String)); - createCol(prims, "LastOwnerID", typeof(System.String)); - createCol(prims, "OwnerMask", typeof(System.Int32)); - createCol(prims, "NextOwnerMask", typeof(System.Int32)); - createCol(prims, "GroupMask", typeof(System.Int32)); - createCol(prims, "EveryoneMask", typeof(System.Int32)); - createCol(prims, "BaseMask", typeof(System.Int32)); + createCol(prims, "ObjectFlags", typeof (Int32)); + createCol(prims, "CreatorID", typeof (String)); + createCol(prims, "OwnerID", typeof (String)); + createCol(prims, "GroupID", typeof (String)); + createCol(prims, "LastOwnerID", typeof (String)); + createCol(prims, "OwnerMask", typeof (Int32)); + createCol(prims, "NextOwnerMask", typeof (Int32)); + createCol(prims, "GroupMask", typeof (Int32)); + createCol(prims, "EveryoneMask", typeof (Int32)); + createCol(prims, "BaseMask", typeof (Int32)); // vectors - createCol(prims, "PositionX", typeof(System.Double)); - createCol(prims, "PositionY", typeof(System.Double)); - createCol(prims, "PositionZ", typeof(System.Double)); - createCol(prims, "GroupPositionX", typeof(System.Double)); - createCol(prims, "GroupPositionY", typeof(System.Double)); - createCol(prims, "GroupPositionZ", typeof(System.Double)); - createCol(prims, "VelocityX", typeof(System.Double)); - createCol(prims, "VelocityY", typeof(System.Double)); - createCol(prims, "VelocityZ", typeof(System.Double)); - createCol(prims, "AngularVelocityX", typeof(System.Double)); - createCol(prims, "AngularVelocityY", typeof(System.Double)); - createCol(prims, "AngularVelocityZ", typeof(System.Double)); - createCol(prims, "AccelerationX", typeof(System.Double)); - createCol(prims, "AccelerationY", typeof(System.Double)); - createCol(prims, "AccelerationZ", typeof(System.Double)); + createCol(prims, "PositionX", typeof (Double)); + createCol(prims, "PositionY", typeof (Double)); + createCol(prims, "PositionZ", typeof (Double)); + createCol(prims, "GroupPositionX", typeof (Double)); + createCol(prims, "GroupPositionY", typeof (Double)); + createCol(prims, "GroupPositionZ", typeof (Double)); + createCol(prims, "VelocityX", typeof (Double)); + createCol(prims, "VelocityY", typeof (Double)); + createCol(prims, "VelocityZ", typeof (Double)); + createCol(prims, "AngularVelocityX", typeof (Double)); + createCol(prims, "AngularVelocityY", typeof (Double)); + createCol(prims, "AngularVelocityZ", typeof (Double)); + createCol(prims, "AccelerationX", typeof (Double)); + createCol(prims, "AccelerationY", typeof (Double)); + createCol(prims, "AccelerationZ", typeof (Double)); // quaternions - createCol(prims, "RotationX", typeof(System.Double)); - createCol(prims, "RotationY", typeof(System.Double)); - createCol(prims, "RotationZ", typeof(System.Double)); - createCol(prims, "RotationW", typeof(System.Double)); + createCol(prims, "RotationX", typeof (Double)); + createCol(prims, "RotationY", typeof (Double)); + createCol(prims, "RotationZ", typeof (Double)); + createCol(prims, "RotationW", typeof (Double)); // sit target - createCol(prims, "SitTargetOffsetX", typeof(System.Double)); - createCol(prims, "SitTargetOffsetY", typeof(System.Double)); - createCol(prims, "SitTargetOffsetZ", typeof(System.Double)); + createCol(prims, "SitTargetOffsetX", typeof (Double)); + createCol(prims, "SitTargetOffsetY", typeof (Double)); + createCol(prims, "SitTargetOffsetZ", typeof (Double)); - createCol(prims, "SitTargetOrientW", typeof(System.Double)); - createCol(prims, "SitTargetOrientX", typeof(System.Double)); - createCol(prims, "SitTargetOrientY", typeof(System.Double)); - createCol(prims, "SitTargetOrientZ", typeof(System.Double)); + createCol(prims, "SitTargetOrientW", typeof (Double)); + createCol(prims, "SitTargetOrientX", typeof (Double)); + createCol(prims, "SitTargetOrientY", typeof (Double)); + createCol(prims, "SitTargetOrientZ", typeof (Double)); // Add in contraints - prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; + prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; return prims; } @@ -410,40 +418,40 @@ namespace OpenSim.DataStore.MSSQL private DataTable createShapeTable() { DataTable shapes = new DataTable("primshapes"); - createCol(shapes, "UUID", typeof(System.String)); + createCol(shapes, "UUID", typeof (String)); // shape is an enum - createCol(shapes, "Shape", typeof(System.Int32)); + createCol(shapes, "Shape", typeof (Int32)); // vectors - createCol(shapes, "ScaleX", typeof(System.Double)); - createCol(shapes, "ScaleY", typeof(System.Double)); - createCol(shapes, "ScaleZ", typeof(System.Double)); + createCol(shapes, "ScaleX", typeof (Double)); + createCol(shapes, "ScaleY", typeof (Double)); + createCol(shapes, "ScaleZ", typeof (Double)); // paths - createCol(shapes, "PCode", typeof(System.Int32)); - createCol(shapes, "PathBegin", typeof(System.Int32)); - createCol(shapes, "PathEnd", typeof(System.Int32)); - createCol(shapes, "PathScaleX", typeof(System.Int32)); - createCol(shapes, "PathScaleY", typeof(System.Int32)); - createCol(shapes, "PathShearX", typeof(System.Int32)); - createCol(shapes, "PathShearY", typeof(System.Int32)); - createCol(shapes, "PathSkew", typeof(System.Int32)); - createCol(shapes, "PathCurve", typeof(System.Int32)); - createCol(shapes, "PathRadiusOffset", typeof(System.Int32)); - createCol(shapes, "PathRevolutions", typeof(System.Int32)); - createCol(shapes, "PathTaperX", typeof(System.Int32)); - createCol(shapes, "PathTaperY", typeof(System.Int32)); - createCol(shapes, "PathTwist", typeof(System.Int32)); - createCol(shapes, "PathTwistBegin", typeof(System.Int32)); + createCol(shapes, "PCode", typeof (Int32)); + createCol(shapes, "PathBegin", typeof (Int32)); + createCol(shapes, "PathEnd", typeof (Int32)); + createCol(shapes, "PathScaleX", typeof (Int32)); + createCol(shapes, "PathScaleY", typeof (Int32)); + createCol(shapes, "PathShearX", typeof (Int32)); + createCol(shapes, "PathShearY", typeof (Int32)); + createCol(shapes, "PathSkew", typeof (Int32)); + createCol(shapes, "PathCurve", typeof (Int32)); + createCol(shapes, "PathRadiusOffset", typeof (Int32)); + createCol(shapes, "PathRevolutions", typeof (Int32)); + createCol(shapes, "PathTaperX", typeof (Int32)); + createCol(shapes, "PathTaperY", typeof (Int32)); + createCol(shapes, "PathTwist", typeof (Int32)); + createCol(shapes, "PathTwistBegin", typeof (Int32)); // profile - createCol(shapes, "ProfileBegin", typeof(System.Int32)); - createCol(shapes, "ProfileEnd", typeof(System.Int32)); - createCol(shapes, "ProfileCurve", typeof(System.Int32)); - createCol(shapes, "ProfileHollow", typeof(System.Int32)); + createCol(shapes, "ProfileBegin", typeof (Int32)); + createCol(shapes, "ProfileEnd", typeof (Int32)); + createCol(shapes, "ProfileCurve", typeof (Int32)); + createCol(shapes, "ProfileHollow", typeof (Int32)); // text TODO: this isn't right, but I'm not sure the right // way to specify this as a blob atm - createCol(shapes, "Texture", typeof(System.Byte[])); - createCol(shapes, "ExtraParams", typeof(System.Byte[])); + createCol(shapes, "Texture", typeof (Byte[])); + createCol(shapes, "ExtraParams", typeof (Byte[])); - shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; + shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; return shapes; } @@ -462,23 +470,23 @@ namespace OpenSim.DataStore.MSSQL // interesting has to be done to actually get these values // back out. Not enough time to figure it out yet. SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new LLUUID((String)row["UUID"]); + prim.UUID = new LLUUID((String) row["UUID"]); // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. prim.ParentID = Convert.ToUInt32(row["ParentID"]); prim.CreationDate = Convert.ToInt32(row["CreationDate"]); - prim.Name = (String)row["Name"]; + prim.Name = (String) row["Name"]; // various text fields - prim.Text = (String)row["Text"]; - prim.Description = (String)row["Description"]; - prim.SitName = (String)row["SitName"]; - prim.TouchName = (String)row["TouchName"]; + prim.Text = (String) row["Text"]; + prim.Description = (String) row["Description"]; + prim.SitName = (String) row["SitName"]; + prim.TouchName = (String) row["TouchName"]; // permissions prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorID = new LLUUID((String)row["CreatorID"]); - prim.OwnerID = new LLUUID((String)row["OwnerID"]); - prim.GroupID = new LLUUID((String)row["GroupID"]); - prim.LastOwnerID = new LLUUID((String)row["LastOwnerID"]); + prim.CreatorID = new LLUUID((String) row["CreatorID"]); + prim.OwnerID = new LLUUID((String) row["OwnerID"]); + prim.GroupID = new LLUUID((String) row["GroupID"]); + prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); @@ -521,15 +529,19 @@ namespace OpenSim.DataStore.MSSQL try { prim.SetSitTargetLL(new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( - Convert.ToSingle(row["SitTargetOrientX"]), - Convert.ToSingle(row["SitTargetOrientY"]), - Convert.ToSingle(row["SitTargetOrientZ"]), - Convert.ToSingle(row["SitTargetOrientW"]))); + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"]))); } - catch (System.InvalidCastException) + catch (InvalidCastException) { // Database table was created before we got here and now has null values :P } @@ -598,11 +610,10 @@ namespace OpenSim.DataStore.MSSQL row["SitTargetOrientY"] = sitTargetOrient.Y; row["SitTargetOrientZ"] = sitTargetOrient.Z; } - catch (System.Exception) + catch (Exception) { // TODO: Add Sit Target Rows! } - } private PrimitiveBaseShape buildShape(DataRow row) @@ -634,14 +645,14 @@ namespace OpenSim.DataStore.MSSQL s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - + // text TODO: this isn't right] = but I'm not sure the right // way to specify this as a blob atm - byte[] textureEntry = (byte[])row["Texture"]; + byte[] textureEntry = (byte[]) row["Texture"]; s.TextureEntry = textureEntry; - - s.ExtraParams = (byte[])row["ExtraParams"]; + + s.ExtraParams = (byte[]) row["ExtraParams"]; // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); // string texture = encoding.GetString((Byte[])row["Texture"]); // if (!texture.StartsWith("<")) @@ -774,7 +785,7 @@ namespace OpenSim.DataStore.MSSQL sql += ") values (@"; sql += String.Join(", @", cols); sql += ")"; - SqlCommand cmd = new SqlCommand(sql); + SqlCommand cmd = new SqlCommand(sql); // this provides the binding for all our parameters, so // much less code than it used to be foreach (DataColumn col in dt.Columns) @@ -791,14 +802,15 @@ namespace OpenSim.DataStore.MSSQL foreach (DataColumn col in dt.Columns) { if (subsql.Length > 0) - { // a map function would rock so much here + { + // a map function would rock so much here subsql += ", "; } subsql += col.ColumnName + "= @" + col.ColumnName; } sql += subsql; sql += " where " + pk; - SqlCommand cmd = new SqlCommand(sql); + SqlCommand cmd = new SqlCommand(sql); // this provides the binding for all our parameters, so // much less code than it used to be @@ -817,7 +829,8 @@ namespace OpenSim.DataStore.MSSQL foreach (DataColumn col in dt.Columns) { if (subsql.Length > 0) - { // a map function would rock so much here + { + // a map function would rock so much here subsql += ",\n"; } subsql += col.ColumnName + " " + SqlType(col.DataType); @@ -828,7 +841,7 @@ namespace OpenSim.DataStore.MSSQL } sql += subsql; sql += ")"; - + return sql; } @@ -837,7 +850,7 @@ namespace OpenSim.DataStore.MSSQL row["RegionUUID"] = regionUUID; row["Revision"] = rev; - MemoryStream str = new MemoryStream(65536 * sizeof(double)); + MemoryStream str = new MemoryStream(65536*sizeof (double)); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions @@ -868,7 +881,7 @@ namespace OpenSim.DataStore.MSSQL /// for us. ///</summary> ///<returns>a built Sql parameter</returns> - private SqlParameter createSqlParameter(string name, System.Type type) + private SqlParameter createSqlParameter(string name, Type type) { SqlParameter param = new SqlParameter(); param.ParameterName = "@" + name; @@ -887,7 +900,7 @@ namespace OpenSim.DataStore.MSSQL da.UpdateCommand.Connection = conn; SqlCommand delete = new SqlCommand("delete from prims where UUID = @UUID"); - delete.Parameters.Add(createSqlParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqlParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -901,7 +914,7 @@ namespace OpenSim.DataStore.MSSQL da.UpdateCommand.Connection = conn; SqlCommand delete = new SqlCommand("delete from primshapes where UUID = @UUID"); - delete.Parameters.Add(createSqlParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqlParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -957,14 +970,13 @@ namespace OpenSim.DataStore.MSSQL private bool TestTables(SqlConnection conn) { - SqlCommand primSelectCmd = new SqlCommand(primSelect, conn); SqlDataAdapter pDa = new SqlDataAdapter(primSelectCmd); SqlCommand shapeSelectCmd = new SqlCommand(shapeSelect, conn); SqlDataAdapter sDa = new SqlDataAdapter(shapeSelectCmd); SqlCommand terrainSelectCmd = new SqlCommand(terrainSelect, conn); SqlDataAdapter tDa = new SqlDataAdapter(terrainSelectCmd); - + DataSet tmpDS = new DataSet(); try { @@ -978,7 +990,7 @@ namespace OpenSim.DataStore.MSSQL InitDB(conn); } - try + try { if (tmpDS.Tables == null || tmpDS.Tables.Count == 0) { @@ -986,11 +998,10 @@ namespace OpenSim.DataStore.MSSQL sDa.Fill(tmpDS, "primshapes"); tDa.Fill(tmpDS, "terrain"); } - } catch (SqlException e) { - MainLog.Instance.Verbose("DATASTORE", e.ToString()); + MainLog.Instance.Verbose("DATASTORE", e.ToString()); } foreach (DataColumn col in createPrimTable().Columns) @@ -1028,19 +1039,19 @@ namespace OpenSim.DataStore.MSSQL private DbType dbtypeFromType(Type type) { - if (type == typeof(System.String)) + if (type == typeof (String)) { return DbType.String; } - else if (type == typeof(System.Int32)) + else if (type == typeof (Int32)) { return DbType.Int32; } - else if (type == typeof(System.Double)) + else if (type == typeof (Double)) { return DbType.Double; } - else if (type == typeof(System.Byte[])) + else if (type == typeof (Byte[])) { return DbType.Binary; } @@ -1054,19 +1065,19 @@ namespace OpenSim.DataStore.MSSQL // slightly differently. private string SqlType(Type type) { - if (type == typeof(System.String)) + if (type == typeof (String)) { return "varchar(255)"; } - else if (type == typeof(System.Int32)) + else if (type == typeof (Int32)) { return "integer"; } - else if (type == typeof(System.Double)) + else if (type == typeof (Double)) { return "float"; } - else if (type == typeof(System.Byte[])) + else if (type == typeof (Byte[])) { return "image"; } diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index c885310..065d37d 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs @@ -59,7 +59,7 @@ namespace OpenSim.DataStore.MonoSqlite private SqliteConnection m_conn; private String m_connectionString; - + private bool persistPrimInventories; /*********************************************************************** @@ -71,7 +71,7 @@ namespace OpenSim.DataStore.MonoSqlite // see IRegionDataStore public void Initialise(string connectionString, bool persistPrimInventories) { - m_connectionString = connectionString; + m_connectionString = connectionString; this.persistPrimInventories = persistPrimInventories; ds = new DataSet(); @@ -182,20 +182,20 @@ namespace OpenSim.DataStore.MonoSqlite { foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); } else if (Stopped(prim)) { - MainLog.Instance.Verbose("DATASTORE", "Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); + MainLog.Instance.Verbose("DATASTORE", + "Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); } else { // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); - } } } @@ -307,18 +307,19 @@ namespace OpenSim.DataStore.MonoSqlite public void StoreTerrain(double[,] ter, LLUUID regionID) { - lock (ds) { + lock (ds) + { int revision = Util.UnixTimeSinceEpoch(); - + // the following is an work around for .NET. The perf // issues associated with it aren't as bad as you think. SqliteConnection conn = new SqliteConnection(m_connectionString); conn.Open(); MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + - " values(:RegionUUID, :Revision, :Heightfield)"; + " values(:RegionUUID, :Revision, :Heightfield)"; - using(SqliteCommand cmd = new SqliteCommand(sql, conn)) + using (SqliteCommand cmd = new SqliteCommand(sql, conn)) { cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); @@ -333,7 +334,10 @@ namespace OpenSim.DataStore.MonoSqlite // revisions in the database, as this old // implementation is a DOS attack waiting to happen. - using(SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision", conn)) + using ( + SqliteCommand cmd = + new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision", + conn)) { cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); @@ -345,21 +349,22 @@ namespace OpenSim.DataStore.MonoSqlite public double[,] LoadTerrain(LLUUID regionID) { - lock (ds) { + lock (ds) + { double[,] terret = new double[256,256]; terret.Initialize(); // the following is an work around for .NET. The perf // issues associated with it aren't as bad as you think. SqliteConnection conn = new SqliteConnection(m_connectionString); conn.Open(); - String sql = "select RegionUUID, Revision, Heightfield from terrain" + - " where RegionUUID=:RegionUUID order by Revision desc"; - - + String sql = "select RegionUUID, Revision, Heightfield from terrain" + + " where RegionUUID=:RegionUUID order by Revision desc"; + + using (SqliteCommand cmd = new SqliteCommand(sql, conn)) { cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); - + using (IDataReader row = cmd.ExecuteReader()) { int rev = 0; @@ -374,7 +379,7 @@ namespace OpenSim.DataStore.MonoSqlite terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); } } - rev = (int)row["Revision"]; + rev = (int) row["Revision"]; } else { @@ -382,7 +387,7 @@ namespace OpenSim.DataStore.MonoSqlite conn.Close(); return null; } - + MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); } } @@ -434,7 +439,8 @@ namespace OpenSim.DataStore.MonoSqlite fillLandRow(landRow, parcel.landData, regionUUID); } - using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", conn)) + using ( + SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", conn)) { cmd.Parameters.Add(new SqliteParameter(":LandUUID", Util.ToRawUuidString(parcel.landData.globalID))); cmd.ExecuteNonQuery(); @@ -447,16 +453,15 @@ namespace OpenSim.DataStore.MonoSqlite landaccesslist.Rows.Add(newAccessRow); } conn.Close(); - } Commit(); } - public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID) + public List<LandData> LoadLandObjects(LLUUID regionUUID) { List<LandData> landDataForRegion = new List<LandData>(); - lock(ds) + lock (ds) { DataTable land = ds.Tables["land"]; DataTable landaccesslist = ds.Tables["landaccesslist"]; @@ -570,14 +575,14 @@ namespace OpenSim.DataStore.MonoSqlite createCol(prims, "RotationW", typeof (Double)); // sit target - createCol(prims, "SitTargetOffsetX", typeof(Double)); - createCol(prims, "SitTargetOffsetY", typeof(Double)); - createCol(prims, "SitTargetOffsetZ", typeof(Double)); + createCol(prims, "SitTargetOffsetX", typeof (Double)); + createCol(prims, "SitTargetOffsetY", typeof (Double)); + createCol(prims, "SitTargetOffsetZ", typeof (Double)); - createCol(prims, "SitTargetOrientW", typeof(Double)); - createCol(prims, "SitTargetOrientX", typeof(Double)); - createCol(prims, "SitTargetOrientY", typeof(Double)); - createCol(prims, "SitTargetOrientZ", typeof(Double)); + createCol(prims, "SitTargetOrientW", typeof (Double)); + createCol(prims, "SitTargetOrientX", typeof (Double)); + createCol(prims, "SitTargetOrientY", typeof (Double)); + createCol(prims, "SitTargetOrientZ", typeof (Double)); // Add in contraints prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; @@ -621,11 +626,11 @@ namespace OpenSim.DataStore.MonoSqlite createCol(shapes, "Texture", typeof (Byte[])); createCol(shapes, "ExtraParams", typeof (Byte[])); - shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; + shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; return shapes; } - + private DataTable createItemsTable() { DataTable items = new DataTable("primitems"); @@ -635,10 +640,10 @@ namespace OpenSim.DataStore.MonoSqlite createCol(items, "assetID", typeof (String)); createCol(items, "assetType", typeof (Int32)); createCol(items, "parentFolderID", typeof (String)); - + createCol(items, "name", typeof (String)); createCol(items, "description", typeof (String)); - + createCol(items, "creationDate", typeof (Int64)); createCol(items, "creatorID", typeof (String)); createCol(items, "ownerID", typeof (String)); @@ -651,50 +656,50 @@ namespace OpenSim.DataStore.MonoSqlite createCol(items, "everyonePermissions", typeof (Int32)); createCol(items, "groupPermissions", typeof (Int32)); - items.PrimaryKey = new DataColumn[] { items.Columns["UUID"] }; - + items.PrimaryKey = new DataColumn[] {items.Columns["UUID"]}; + return items; - } + } private DataTable createLandTable() { DataTable land = new DataTable("land"); - createCol(land, "UUID", typeof(String)); - createCol(land, "RegionUUID", typeof(String)); - createCol(land, "LocalLandID", typeof(UInt32)); + createCol(land, "UUID", typeof (String)); + createCol(land, "RegionUUID", typeof (String)); + createCol(land, "LocalLandID", typeof (UInt32)); // Bitmap is a byte[512] - createCol(land, "Bitmap", typeof(Byte[])); - - createCol(land, "Name", typeof(String)); - createCol(land, "Desc", typeof(String)); - createCol(land, "OwnerUUID", typeof(String)); - createCol(land, "IsGroupOwned", typeof(Boolean)); - createCol(land, "Area", typeof(Int32)); - createCol(land, "AuctionID", typeof(Int32)); //Unemplemented - createCol(land, "Category", typeof(Int32)); //Enum libsecondlife.Parcel.ParcelCategory - createCol(land, "ClaimDate", typeof(Int32)); - createCol(land, "ClaimPrice", typeof(Int32)); - createCol(land, "GroupUUID", typeof(string)); - createCol(land, "SalePrice", typeof(Int32)); - createCol(land, "LandStatus", typeof(Int32)); //Enum. libsecondlife.Parcel.ParcelStatus - createCol(land, "LandFlags", typeof(UInt32)); - createCol(land, "LandingType", typeof(Byte)); - createCol(land, "MediaAutoScale", typeof(Byte)); - createCol(land, "MediaTextureUUID", typeof(String)); - createCol(land, "MediaURL", typeof(String)); - createCol(land, "MusicURL", typeof(String)); - createCol(land, "PassHours", typeof(Double)); - createCol(land, "PassPrice", typeof(UInt32)); - createCol(land, "SnapshotUUID", typeof(String)); - createCol(land, "UserLocationX", typeof(Double)); - createCol(land, "UserLocationY", typeof(Double)); - createCol(land, "UserLocationZ", typeof(Double)); - createCol(land, "UserLookAtX", typeof(Double)); - createCol(land, "UserLookAtY", typeof(Double)); - createCol(land, "UserLookAtZ", typeof(Double)); - - land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; + createCol(land, "Bitmap", typeof (Byte[])); + + createCol(land, "Name", typeof (String)); + createCol(land, "Desc", typeof (String)); + createCol(land, "OwnerUUID", typeof (String)); + createCol(land, "IsGroupOwned", typeof (Boolean)); + createCol(land, "Area", typeof (Int32)); + createCol(land, "AuctionID", typeof (Int32)); //Unemplemented + createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory + createCol(land, "ClaimDate", typeof (Int32)); + createCol(land, "ClaimPrice", typeof (Int32)); + createCol(land, "GroupUUID", typeof (string)); + createCol(land, "SalePrice", typeof (Int32)); + createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus + createCol(land, "LandFlags", typeof (UInt32)); + createCol(land, "LandingType", typeof (Byte)); + createCol(land, "MediaAutoScale", typeof (Byte)); + createCol(land, "MediaTextureUUID", typeof (String)); + createCol(land, "MediaURL", typeof (String)); + createCol(land, "MusicURL", typeof (String)); + createCol(land, "PassHours", typeof (Double)); + createCol(land, "PassPrice", typeof (UInt32)); + createCol(land, "SnapshotUUID", typeof (String)); + createCol(land, "UserLocationX", typeof (Double)); + createCol(land, "UserLocationY", typeof (Double)); + createCol(land, "UserLocationZ", typeof (Double)); + createCol(land, "UserLookAtX", typeof (Double)); + createCol(land, "UserLookAtY", typeof (Double)); + createCol(land, "UserLookAtZ", typeof (Double)); + + land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; return land; } @@ -702,9 +707,9 @@ namespace OpenSim.DataStore.MonoSqlite private DataTable createLandAccessListTable() { DataTable landaccess = new DataTable("landaccesslist"); - createCol(landaccess, "LandUUID", typeof(String)); - createCol(landaccess, "AccessUUID", typeof(String)); - createCol(landaccess, "Flags", typeof(UInt32)); + createCol(landaccess, "LandUUID", typeof (String)); + createCol(landaccess, "AccessUUID", typeof (String)); + createCol(landaccess, "Flags", typeof (UInt32)); return landaccess; } @@ -782,35 +787,43 @@ namespace OpenSim.DataStore.MonoSqlite try { prim.SetSitTargetLL(new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( - Convert.ToSingle(row["SitTargetOrientX"]), - Convert.ToSingle(row["SitTargetOrientY"]), - Convert.ToSingle(row["SitTargetOrientZ"]), - Convert.ToSingle(row["SitTargetOrientW"]))); + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"]))); } - catch (System.InvalidCastException) + catch (InvalidCastException) { // Database table was created before we got here and now has null values :P m_conn.Open(); - SqliteCommand cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetX float NOT NULL default 0;", m_conn); + SqliteCommand cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetX float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetY float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetY float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetZ float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetZ float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientW float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientW float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientX float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientX float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientY float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientY float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientZ float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientZ float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - - - } return prim; @@ -820,36 +833,42 @@ namespace OpenSim.DataStore.MonoSqlite { LandData newData = new LandData(); - newData.globalID = new LLUUID((String)row["UUID"]); - newData.localID= Convert.ToInt32(row["LocalLandID"]); + newData.globalID = new LLUUID((String) row["UUID"]); + newData.localID = Convert.ToInt32(row["LocalLandID"]); // Bitmap is a byte[512] newData.landBitmapByteArray = (Byte[]) row["Bitmap"]; - newData.landName= (String) row["Name"]; - newData.landDesc= (String) row["Desc"]; - newData.ownerID= (String) row["OwnerUUID"]; - newData.isGroupOwned= (Boolean) row["IsGroupOwned"]; - newData.area= Convert.ToInt32(row["Area"]); + newData.landName = (String) row["Name"]; + newData.landDesc = (String) row["Desc"]; + newData.ownerID = (String) row["OwnerUUID"]; + newData.isGroupOwned = (Boolean) row["IsGroupOwned"]; + newData.area = Convert.ToInt32(row["Area"]); newData.auctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented - newData.category= (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); //Enum libsecondlife.Parcel.ParcelCategory - newData.claimDate= Convert.ToInt32(row["ClaimDate"]); - newData.claimPrice= Convert.ToInt32(row["ClaimPrice"]); - newData.groupID= new LLUUID((String)row["GroupUUID"]); + newData.category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); + //Enum libsecondlife.Parcel.ParcelCategory + newData.claimDate = Convert.ToInt32(row["ClaimDate"]); + newData.claimPrice = Convert.ToInt32(row["ClaimPrice"]); + newData.groupID = new LLUUID((String) row["GroupUUID"]); newData.salePrice = Convert.ToInt32(row["SalePrice"]); - newData.landStatus= (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus - newData.landFlags= Convert.ToUInt32(row["LandFlags"]); - newData.landingType= (Byte) row["LandingType"]; - newData.mediaAutoScale= (Byte) row["MediaAutoScale"]; - newData.mediaID= new LLUUID((String)row["MediaTextureUUID"]); - newData.mediaURL= (String) row["MediaURL"]; - newData.musicURL= (String) row["MusicURL"]; - newData.passHours= Convert.ToSingle(row["PassHours"]); - newData.passPrice= Convert.ToInt32(row["PassPrice"]); - newData.snapshotID= (String) row["SnapshotUUID"]; - - newData.userLocation = new LLVector3(Convert.ToSingle(row["UserLocationX"]),Convert.ToSingle(row["UserLocationY"]), Convert.ToSingle(row["UserLocationZ"])); - newData.userLookAt = new LLVector3(Convert.ToSingle(row["UserLookAtX"]),Convert.ToSingle(row["UserLookAtY"]), Convert.ToSingle(row["UserLookAtZ"])); + newData.landStatus = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); + //Enum. libsecondlife.Parcel.ParcelStatus + newData.landFlags = Convert.ToUInt32(row["LandFlags"]); + newData.landingType = (Byte) row["LandingType"]; + newData.mediaAutoScale = (Byte) row["MediaAutoScale"]; + newData.mediaID = new LLUUID((String) row["MediaTextureUUID"]); + newData.mediaURL = (String) row["MediaURL"]; + newData.musicURL = (String) row["MusicURL"]; + newData.passHours = Convert.ToSingle(row["PassHours"]); + newData.passPrice = Convert.ToInt32(row["PassPrice"]); + newData.snapshotID = (String) row["SnapshotUUID"]; + + newData.userLocation = + new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.userLookAt = + new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); newData.parcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); return newData; @@ -858,13 +877,13 @@ namespace OpenSim.DataStore.MonoSqlite private ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new LLUUID((string)row["AccessUUID"]); - entry.Flags = (ParcelManager.AccessList)row["Flags"]; + entry.AgentID = new LLUUID((string) row["AccessUUID"]); + entry.Flags = (ParcelManager.AccessList) row["Flags"]; entry.Time = new DateTime(); return entry; } - private Array serializeTerrain(double[,] val) + private Array serializeTerrain(double[,] val) { MemoryStream str = new MemoryStream(65536*sizeof (double)); BinaryWriter bw = new BinaryWriter(str); @@ -900,7 +919,8 @@ namespace OpenSim.DataStore.MonoSqlite row["ParentID"] = prim.ParentID; row["CreationDate"] = prim.CreationDate; row["Name"] = prim.Name; - row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); // the UUID of the root part for this SceneObjectGroup + row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); + // the UUID of the root part for this SceneObjectGroup // various text fields row["Text"] = prim.Text; row["Description"] = prim.Description; @@ -1028,10 +1048,10 @@ namespace OpenSim.DataStore.MonoSqlite s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); // text TODO: this isn't right] = but I'm not sure the right // way to specify this as a blob atm - - byte[] textureEntry = (byte[])row["Texture"]; + + byte[] textureEntry = (byte[]) row["Texture"]; s.TextureEntry = textureEntry; - + s.ExtraParams = (byte[]) row["ExtraParams"]; // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); @@ -1278,6 +1298,7 @@ namespace OpenSim.DataStore.MonoSqlite da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); da.InsertCommand.Connection = conn; } + private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) { da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); @@ -1331,7 +1352,7 @@ namespace OpenSim.DataStore.MonoSqlite { MainLog.Instance.Warn("SQLITE", "Shapes Table Already Exists"); } - + if (persistPrimInventories) { try @@ -1341,7 +1362,7 @@ namespace OpenSim.DataStore.MonoSqlite catch (SqliteSyntaxException) { MainLog.Instance.Warn("SQLITE", "Primitives Inventory Table Already Exists"); - } + } } try @@ -1377,32 +1398,31 @@ namespace OpenSim.DataStore.MonoSqlite { SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd); - + SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn); SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd); - + SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, conn); SqliteDataAdapter iDa = new SqliteDataAdapter(itemsSelectCmd); - + SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, conn); SqliteDataAdapter tDa = new SqliteDataAdapter(terrainSelectCmd); - + SqliteCommand landSelectCmd = new SqliteCommand(landSelect, conn); SqliteDataAdapter lDa = new SqliteDataAdapter(landSelectCmd); - + SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, conn); SqliteDataAdapter lalDa = new SqliteDataAdapter(landAccessListSelectCmd); DataSet tmpDS = new DataSet(); try { - pDa.Fill(tmpDS, "prims"); sDa.Fill(tmpDS, "primshapes"); - + if (persistPrimInventories) iDa.Fill(tmpDS, "primitems"); - + tDa.Fill(tmpDS, "terrain"); lDa.Fill(tmpDS, "land"); lalDa.Fill(tmpDS, "landaccesslist"); @@ -1415,13 +1435,13 @@ namespace OpenSim.DataStore.MonoSqlite pDa.Fill(tmpDS, "prims"); sDa.Fill(tmpDS, "primshapes"); - + if (persistPrimInventories) iDa.Fill(tmpDS, "primitems"); - + tDa.Fill(tmpDS, "terrain"); lDa.Fill(tmpDS, "land"); - lalDa.Fill(tmpDS,"landaccesslist"); + lalDa.Fill(tmpDS, "landaccesslist"); foreach (DataColumn col in createPrimTable().Columns) { @@ -1431,7 +1451,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + foreach (DataColumn col in createShapeTable().Columns) { if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) @@ -1440,9 +1460,9 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + // TODO Not restoring prim inventories quite yet - + foreach (DataColumn col in createTerrainTable().Columns) { if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) @@ -1451,7 +1471,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + foreach (DataColumn col in createLandTable().Columns) { if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) @@ -1460,7 +1480,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + foreach (DataColumn col in createLandAccessListTable().Columns) { if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) @@ -1469,7 +1489,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + return true; } @@ -1526,7 +1546,7 @@ namespace OpenSim.DataStore.MonoSqlite else if (type == typeof (Int64)) { return "integer"; - } + } else if (type == typeof (Double)) { return "float"; @@ -1541,4 +1561,4 @@ namespace OpenSim.DataStore.MonoSqlite } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs index da05018..035c3ba 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -71,9 +72,9 @@ namespace OpenSim.DataStore.NullStorage { } - public List<Framework.LandData> LoadLandObjects(LLUUID regionUUID) + public List<LandData> LoadLandObjects(LLUUID regionUUID) { - return new List<Framework.LandData>(); + return new List<LandData>(); } public void Shutdown() diff --git a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs index 3c0facb..3195140 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index e89ff62..2405e86 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs @@ -159,12 +159,13 @@ namespace OpenSim.Region.Terrain /// <param name="action">The action to be performed</param> /// <param name="north">Distance from the north border where the cursor is located</param> /// <param name="west">Distance from the west border where the cursor is located</param> - public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, float south, float east, + public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + float south, float east, IClientAPI remoteUser) { // Shiny. double size = (double) (1 << brushsize); - + /* Okay, so here's the deal * This has to handle both when a user draws on the terrain *and* when a user selects * a selection of AABB on terrain and applies whatever routine the client requests @@ -189,8 +190,8 @@ namespace OpenSim.Region.Terrain * Again, libTerrain is yx instead of xy.. so, it's reflected in the function calls * */ - - + + switch (action) { case 0: @@ -199,7 +200,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - FlattenTerrain(y, x, size, (double)seconds / 5.0); + FlattenTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -210,7 +211,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - RaiseTerrain(y, x, size, (double)seconds / 5.0); + RaiseTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -221,7 +222,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - LowerTerrain(y, x, size, (double)seconds / 5.0); + LowerTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -235,13 +236,13 @@ namespace OpenSim.Region.Terrain // //for (float x = south; x <= north; x++) //{ - //for (float y = west; y <= east; y++) - //{ - //SmoothTerrain(y, x , size, (double)seconds / 5.0); - //} + //for (float y = west; y <= east; y++) + //{ + //SmoothTerrain(y, x , size, (double)seconds / 5.0); + //} //} - SmoothTerrain(west, north, size, (double)seconds / 5.0); + SmoothTerrain(west, north, size, (double) seconds/5.0); break; case 4: @@ -250,7 +251,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - NoiseTerrain(y, x, size, (double)seconds / 5.0); + NoiseTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -261,7 +262,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - RevertTerrain(y, x, size, (double)seconds / 5.0); + RevertTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -1351,16 +1352,16 @@ namespace OpenSim.Region.Terrain } Channel copy = heightmap.Copy(); - for (int y = 0; y <copy.h; y++) + for (int y = 0; y < copy.h; y++) { for (int x = 0; x < copy.w; x++) { // 512 is the largest possible height before colours clamp int colorindex = (int) (Math.Max(Math.Min(1.0, copy.Get(x, y)/512.0), 0.0)*(pallete - 1)); - bmp.SetPixel(x, copy.h-y-1, colours[colorindex]); + bmp.SetPixel(x, copy.h - y - 1, colours[colorindex]); } } return bmp; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs index 4daa4b4..c56e29e 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs @@ -122,4 +122,4 @@ namespace OpenSim.Region.Terrain LoadFilter(compiler, filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs index 3aa321c..b761f1e 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs @@ -83,4 +83,4 @@ namespace libTerrain gd.DrawString(txt, new Font(font, (float) size), new SolidBrush(Color.White), area, sf); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs index 9c7ab35..a7f7246 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs @@ -57,4 +57,4 @@ namespace libTerrain diff = new int[(int) (w/16),(int) (h/16)]; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs index 083d2f5..8bc4a04 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs @@ -280,4 +280,4 @@ namespace libTerrain return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs index b4784f0..df34eeb 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs @@ -143,4 +143,4 @@ namespace libTerrain Blend(flat, temp); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs index 5517c52..9a8b8f5 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs @@ -134,4 +134,4 @@ namespace libTerrain } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs index fa3840f..3d51583 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs @@ -73,4 +73,4 @@ namespace libTerrain bit.Save(filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs index 549fe0b..992377f 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs @@ -140,4 +140,4 @@ namespace libTerrain Normalise(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs index 3ac1ed7..6cdf7ce 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs @@ -58,4 +58,4 @@ namespace libTerrain Normalise(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs index 9e86aaf..000bfcc 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs @@ -279,4 +279,4 @@ namespace libTerrain Normalise(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs index 80e10ba..0bce1b2 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs @@ -51,4 +51,4 @@ namespace libTerrain } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs index 330e7f5..414f844 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs @@ -154,4 +154,4 @@ namespace libTerrain Normalise(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs index dc53343..e188486 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs @@ -209,4 +209,4 @@ namespace libTerrain Normalise(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs index 7727344..8f9f14b 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs @@ -69,4 +69,4 @@ namespace libTerrain } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs index 41f6ece..4ff8e78 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs @@ -356,4 +356,4 @@ namespace libTerrain return this; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs index 3560a80..8e8d30f 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs @@ -209,4 +209,4 @@ namespace libTerrain SaveImage("testimg/output.png"); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs index 35f5288..abb620a 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs @@ -142,4 +142,4 @@ namespace libTerrain } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs index f14cea7..896c354 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs @@ -304,4 +304,4 @@ namespace libTerrain nsBufferToDoubles(ref dens, N, ref map); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs index 6767bb9..5be239f 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs @@ -105,4 +105,4 @@ namespace libTerrain return this; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs index 2ffa231..a946b09 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs @@ -134,4 +134,4 @@ namespace libTerrain return coord; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs index 0cca110..6de16ff 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs @@ -237,4 +237,4 @@ namespace libTerrain return A; } } -} +} \ No newline at end of file diff --git a/OpenSim/Tools/Export/OpenSimExport.cs b/OpenSim/Tools/Export/OpenSimExport.cs index b0764ff..4a5ba5d 100644 --- a/OpenSim/Tools/Export/OpenSimExport.cs +++ b/OpenSim/Tools/Export/OpenSimExport.cs @@ -27,15 +27,11 @@ */ using System; using System.IO; -using System.Reflection; using Nini.Config; -using OpenSim; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment; using OpenSim.Region.Environment.Scenes; -using Mono.Addins; -using Mono.Addins.Description; namespace OpenSim.Tools.Export { @@ -43,7 +39,7 @@ namespace OpenSim.Tools.Export { public IniConfigSource config; public StorageManager sman; - + public OpenSimExport(IniConfigSource config) { this.config = config; @@ -53,13 +49,13 @@ namespace OpenSim.Tools.Export // TODO: this really sucks, but given the way we do // logging in OpenSim, we need to establish a log up front - + MainLog.Instance = CreateLog(); - this.sman = new StorageManager( - startup.GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll"), - startup.GetString("storage_connection_string","") - ); + sman = new StorageManager( + startup.GetString("storage_plugin", "OpenSim.DataStore.NullStorage.dll"), + startup.GetString("storage_connection_string", "") + ); } public static void Main(string[] args) @@ -67,10 +63,10 @@ namespace OpenSim.Tools.Export OpenSimExport export = new OpenSimExport(InitConfig(args)); RegionInfo reg = new RegionInfo("Sara Jane", "Regions/1000-1000.xml"); - System.Console.WriteLine("This application does nothing useful yet: " + reg.RegionID); + Console.WriteLine("This application does nothing useful yet: " + reg.RegionID); foreach (SceneObjectGroup group in export.sman.DataStore.LoadObjects(reg.RegionID)) { - System.Console.WriteLine("{0} -> {1}", reg.RegionID, group.UUID); + Console.WriteLine("{0} -> {1}", reg.RegionID, group.UUID); } } @@ -83,25 +79,25 @@ namespace OpenSim.Tools.Export return new LogBase((Path.Combine(Util.logDir(), "export.log")), "Export", null, true); } - + private static IniConfigSource InitConfig(string[] args) { - System.Console.WriteLine("Good"); + Console.WriteLine("Good"); ArgvConfigSource configSource = new ArgvConfigSource(args); configSource.AddSwitch("Startup", "inifile"); IConfig startupConfig = configSource.Configs["Startup"]; string iniFilePath = startupConfig.GetString("inifile", "OpenSim.ini"); - System.Console.WriteLine(iniFilePath); + Console.WriteLine(iniFilePath); IniConfigSource config = new IniConfigSource(); //check for .INI file (either default or name passed in command line) - if(! File.Exists(iniFilePath)) + if (! File.Exists(iniFilePath)) { iniFilePath = Path.Combine(Util.configDir(), iniFilePath); } - - if(File.Exists(iniFilePath)) + + if (File.Exists(iniFilePath)) { config.Merge(new IniConfigSource(iniFilePath)); config.Merge(configSource); @@ -109,8 +105,8 @@ namespace OpenSim.Tools.Export else { // no default config files, so set default values, and save it - System.Console.WriteLine("We didn't find a config!"); - config.Merge(OpenSim.OpenSimMain.DefaultConfig()); + Console.WriteLine("We didn't find a config!"); + config.Merge(OpenSimMain.DefaultConfig()); config.Merge(configSource); } -- cgit v1.1