From 67e12b95ea7b68f4904a7484d77ecfd787d16d0c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 30 Oct 2007 09:05:31 +0000 Subject: * Optimized usings * Shortened type references * Removed redundant 'this' qualifier --- OpenSim/Framework/Communications/CAPSService.cs | 6 +- .../Framework/Communications/Cache/AssetCache.cs | 207 +- .../Framework/Communications/Cache/AssetServer.cs | 24 +- .../Communications/Cache/AssetServerBase.cs | 26 +- .../Cache/AssetTransactionManager.cs | 37 +- .../Communications/Cache/AssetTransactions.cs | 199 +- .../Communications/Cache/CachedUserInfo.cs | 37 +- .../Communications/Cache/GridAssetClient.cs | 21 +- .../Communications/Cache/InventoryFolder.cs | 41 +- .../Communications/Cache/LibraryRootFolder.cs | 82 +- .../Communications/Cache/SQLAssetServer.cs | 21 +- .../Communications/Cache/UserProfileCache.cs | 72 +- .../Framework/Communications/Capabilities/Caps.cs | 136 +- .../Communications/Capabilities/LLSDArray.cs | 3 +- .../Capabilities/LLSDAssetUploadComplete.cs | 3 +- .../Capabilities/LLSDAssetUploadRequest.cs | 5 +- .../Capabilities/LLSDAssetUploadResponse.cs | 7 +- .../Communications/Capabilities/LLSDCapEvent.cs | 3 +- .../Communications/Capabilities/LLSDCapsDetails.cs | 12 +- .../Communications/Capabilities/LLSDEmpty.cs | 3 +- .../Communications/Capabilities/LLSDHelpers.cs | 32 +- .../Communications/Capabilities/LLSDItemUpdate.cs | 5 +- .../Communications/Capabilities/LLSDMapLayer.cs | 3 +- .../Capabilities/LLSDMapLayerResponse.cs | 3 +- .../Communications/Capabilities/LLSDMapRequest.cs | 3 +- .../Communications/Capabilities/LLSDMethod.cs | 6 +- .../Capabilities/LLSDStreamHandler.cs | 19 +- .../Communications/Capabilities/LLSDTest.cs | 3 +- .../Communications/Capabilities/LLSDType.cs | 10 +- .../Communications/CommunicationsManager.cs | 20 +- OpenSim/Framework/Communications/IGridServices.cs | 6 +- .../Communications/IInterRegionCommunications.cs | 3 +- .../Framework/Communications/IInventoryServices.cs | 6 +- .../Communications/InventoryServiceBase.cs | 19 +- OpenSim/Framework/Communications/LoginResponse.cs | 594 ++---- OpenSim/Framework/Communications/LoginService.cs | 53 +- .../Communications/Properties/AssemblyInfo.cs | 31 +- .../RestClient/GenericAsyncResult.cs | 37 +- .../Communications/RestClient/RestClient.cs | 64 +- .../Framework/Communications/UserManagerBase.cs | 49 +- .../Configuration/HTTP/HTTPConfiguration.cs | 26 +- .../Configuration/HTTP/RemoteConfigSettings.cs | 20 +- .../Configuration/XML/XmlConfiguration.cs | 16 +- OpenSim/Framework/Console/AssemblyInfo.cs | 22 +- OpenSim/Framework/Console/ConsoleCallbacksBase.cs | 4 +- OpenSim/Framework/Console/LogBase.cs | 31 +- OpenSim/Framework/Console/MainLog.cs | 11 +- OpenSim/Framework/Data.DB4o/DB4oGridData.cs | 17 +- OpenSim/Framework/Data.DB4o/DB4oManager.cs | 21 +- OpenSim/Framework/Data.DB4o/DB4oUserData.cs | 24 +- .../Framework/Data.DB4o/Properties/AssemblyInfo.cs | 31 +- OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs | 4 +- OpenSim/Framework/Data.MSSQL/MSSQLManager.cs | 68 +- .../Data.MSSQL/Properties/AssemblyInfo.cs | 31 +- OpenSim/Framework/Data.MySQL/MySQLAssetData.cs | 43 +- OpenSim/Framework/Data.MySQL/MySQLGridData.cs | 21 +- OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 117 +- OpenSim/Framework/Data.MySQL/MySQLLogData.cs | 13 +- OpenSim/Framework/Data.MySQL/MySQLManager.cs | 329 +-- OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 52 +- .../Data.MySQL/Properties/AssemblyInfo.cs | 31 +- .../Data.SQLite/Properties/AssemblyInfo.cs | 31 +- OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | 125 +- OpenSim/Framework/Data.SQLite/SQLiteBase.cs | 102 +- OpenSim/Framework/Data.SQLite/SQLiteGridData.cs | 2 +- .../Framework/Data.SQLite/SQLiteInventoryStore.cs | 189 +- OpenSim/Framework/Data.SQLite/SQLiteManager.cs | 132 +- OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 261 +-- OpenSim/Framework/Data/GridData.cs | 3 +- OpenSim/Framework/Data/ILogData.cs | 7 +- OpenSim/Framework/Data/IniConfig.cs | 22 +- OpenSim/Framework/Data/Properties/AssemblyInfo.cs | 31 +- OpenSim/Framework/Data/RegionProfileData.cs | 63 +- OpenSim/Framework/Data/ReservationData.cs | 4 +- OpenSim/Framework/General/ACL.cs | 22 +- OpenSim/Framework/General/AgentCircuitManager.cs | 35 +- OpenSim/Framework/General/AgentCiruitData.cs | 11 +- OpenSim/Framework/General/AgentInventory.cs | 71 +- OpenSim/Framework/General/AgentWearable.cs | 5 +- OpenSim/Framework/General/AssetBase.cs | 3 +- OpenSim/Framework/General/AssetConfig.cs | 26 +- OpenSim/Framework/General/AssetLandmark.cs | 16 +- OpenSim/Framework/General/AssetStorage.cs | 29 +- OpenSim/Framework/General/AuthenticateResponse.cs | 6 +- OpenSim/Framework/General/BlockingQueue.cs | 2 +- OpenSim/Framework/General/ClientManager.cs | 22 +- OpenSim/Framework/General/ConfigurationMember.cs | 110 +- OpenSim/Framework/General/ConfigurationOption.cs | 10 +- OpenSim/Framework/General/Culture.cs | 16 +- OpenSim/Framework/General/EstateSettings.cs | 428 ++-- OpenSim/Framework/General/GridConfig.cs | 73 +- OpenSim/Framework/General/IAssetProvider.cs | 8 +- OpenSim/Framework/General/IAssetServer.cs | 4 +- OpenSim/Framework/General/IClientAPI.cs | 179 +- OpenSim/Framework/General/IGenericConfig.cs | 2 +- OpenSim/Framework/General/IPlugin.cs | 6 +- OpenSim/Framework/General/IRegionCommsListener.cs | 7 +- OpenSim/Framework/General/IScene.cs | 10 +- OpenSim/Framework/General/IUserData.cs | 3 +- OpenSim/Framework/General/IUserService.cs | 1 - OpenSim/Framework/General/InventoryItemBase.cs | 19 +- OpenSim/Framework/General/LandData.cs | 169 +- OpenSim/Framework/General/Login.cs | 4 +- OpenSim/Framework/General/MapBlockData.cs | 3 +- OpenSim/Framework/General/NeighbourInfo.cs | 2 +- OpenSim/Framework/General/NetworkServersInfo.cs | 22 +- OpenSim/Framework/General/PrimitiveBaseShape.cs | 42 +- .../Framework/General/Properties/AssemblyInfo.cs | 31 +- OpenSim/Framework/General/RegionCommsListener.cs | 16 +- OpenSim/Framework/General/RegionHandle.cs | 33 +- OpenSim/Framework/General/RegionInfo.cs | 187 +- OpenSim/Framework/General/Remoting.cs | 9 +- OpenSim/Framework/General/UUID.cs | 6 +- OpenSim/Framework/General/UserConfig.cs | 43 +- OpenSim/Framework/General/UserProfileData.cs | 31 +- OpenSim/Framework/General/Util.cs | 61 +- OpenSim/Framework/Servers/BaseHttpServer.cs | 34 +- OpenSim/Framework/Servers/BaseStreamHandler.cs | 21 +- OpenSim/Framework/Servers/BinaryStreamHandler.cs | 17 +- OpenSim/Framework/Servers/CheckSumServer.cs | 4 +- OpenSim/Framework/Servers/IStreamHandler.cs | 13 +- OpenSim/Framework/Servers/RestMethod.cs | 4 +- OpenSim/Framework/Servers/RestStreamHandler.cs | 14 +- OpenSim/Framework/Servers/UDPServerBase.cs | 11 +- OpenSim/Framework/Servers/XmlRpcMethod.cs | 4 +- OpenSim/Grid/AssetServer/Main.cs | 27 +- .../Grid/AssetServer/Properties/AssemblyInfo.cs | 29 +- OpenSim/Grid/AssetServer/RestService.cs | 44 +- OpenSim/Grid/GridServer/GridManager.cs | 274 +-- OpenSim/Grid/GridServer/Main.cs | 37 +- OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs | 31 +- OpenSim/Grid/ScriptEngine/Common/Executor.cs | 88 +- OpenSim/Grid/ScriptEngine/Common/IScript.cs | 6 +- .../Common/LSL_BuiltIn_Commands_Interface.cs | 15 +- OpenSim/Grid/ScriptEngine/Common/LSL_Types.cs | 26 +- .../ScriptEngine/Common/Properties/AssemblyInfo.cs | 31 +- .../ScriptEngine/DotNetEngine/AppDomainManager.cs | 48 +- OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs | 16 +- .../DotNetEngine/Compiler/LSL/Compiler.cs | 38 +- .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 82 +- .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 2173 ++++++++++++++++---- .../DotNetEngine/Compiler/LSO/Common.cs | 27 +- .../DotNetEngine/Compiler/LSO/Engine.cs | 149 +- .../Compiler/LSO/IL_common_functions.cs | 25 +- .../DotNetEngine/Compiler/LSO/LSL_BaseClass.cs | 20 +- .../Compiler/LSO/LSL_BaseClass_OPCODES.cs | 186 +- .../DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs | 6 +- .../Compiler/LSO/LSL_OPCODE_IL_processor.cs | 135 +- .../DotNetEngine/Compiler/LSO/LSO_Enums.cs | 11 +- .../DotNetEngine/Compiler/LSO/LSO_Parser.cs | 208 +- .../DotNetEngine/Compiler/LSO/LSO_Struct.cs | 20 +- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 2095 ++++++++++++++----- .../Grid/ScriptEngine/DotNetEngine/EventManager.cs | 173 +- .../ScriptEngine/DotNetEngine/EventQueueManager.cs | 64 +- .../ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs | 74 +- .../DotNetEngine/Properties/AssemblyInfo.cs | 31 +- .../Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs | 33 +- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 103 +- .../TempDotNetMicroThreadingCodeInjector.cs | 22 +- OpenSim/Grid/ScriptServer/Application.cs | 17 +- .../Grid/ScriptServer/Properties/AssemblyInfo.cs | 31 +- .../ScriptServer/ScriptServer/Region/RegionBase.cs | 214 +- .../ScriptServer/Region/RegionConnectionManager.cs | 12 +- .../ScriptServer/ScriptServer/RegionCommManager.cs | 12 +- .../ScriptEngineManager/ScriptEngineLoader.cs | 3 +- .../ScriptServer/ScriptEnginesManager.cs | 9 +- OpenSim/Grid/ScriptServer/ScriptServerMain.cs | 14 +- OpenSim/Grid/UserServer/Main.cs | 27 +- OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs | 31 +- OpenSim/Grid/UserServer/UserLoginService.cs | 39 +- OpenSim/Grid/UserServer/UserManager.cs | 17 +- OpenSim/Region/Application/Application.cs | 17 +- OpenSim/Region/Application/OpenSimController.cs | 68 +- OpenSim/Region/Application/OpenSimMain.cs | 68 +- OpenSim/Region/Application/VersionInfo.cs | 2 +- .../ClientStack/ClientStackNetworkHandler.cs | 6 +- OpenSim/Region/ClientStack/ClientView.API.cs | 538 ++--- .../ClientStack/ClientView.PacketHandlers.cs | 89 +- .../Region/ClientStack/ClientView.PacketQueue.cs | 39 +- .../ClientStack/ClientView.ProcessPackets.cs | 270 ++- OpenSim/Region/ClientStack/ClientView.cs | 86 +- OpenSim/Region/ClientStack/PacketServer.cs | 33 +- .../Region/ClientStack/RegionApplicationBase.cs | 25 +- OpenSim/Region/ClientStack/UDPServer.cs | 60 +- .../Communications/Local/CommunicationsLocal.cs | 20 +- .../Communications/Local/LocalBackEndServices.cs | 63 +- .../Communications/Local/LocalInventoryService.cs | 21 +- .../Communications/Local/LocalLoginService.cs | 49 +- .../Communications/Local/LocalUserServices.cs | 8 +- .../Local/Properties/AssemblyInfo.cs | 31 +- .../Communications/OGS1/CommunicationsOGS1.cs | 8 +- .../Region/Communications/OGS1/OGS1GridServices.cs | 104 +- .../Communications/OGS1/OGS1InterSimComms.cs | 18 +- .../Communications/OGS1/OGS1InventoryService.cs | 17 +- .../Region/Communications/OGS1/OGS1UserServices.cs | 63 +- .../Communications/OGS1/Properties/AssemblyInfo.cs | 31 +- OpenSim/Region/Environment/EstateManager.cs | 28 +- .../Environment/Interfaces/IAvatarFactory.cs | 5 +- .../Interfaces/IDynamicTextureManager.cs | 2 +- .../Region/Environment/Interfaces/IHttpRequests.cs | 2 +- .../Region/Environment/Interfaces/IRegionModule.cs | 4 +- OpenSim/Region/Environment/Interfaces/ISimChat.cs | 7 +- OpenSim/Region/Environment/Interfaces/ITerrain.cs | 3 +- .../Region/Environment/Interfaces/IWorldComm.cs | 2 +- OpenSim/Region/Environment/Interfaces/IXMLRPC.cs | 2 +- OpenSim/Region/Environment/Interfaces/IXfer.cs | 2 +- OpenSim/Region/Environment/LandManagement/Land.cs | 3 +- .../Environment/LandManagement/LandManager.cs | 1 - OpenSim/Region/Environment/ModuleLoader.cs | 19 +- .../Environment/Modules/AssetDownloadModule.cs | 7 +- .../Environment/Modules/AvatarFactoryModule.cs | 11 +- .../Environment/Modules/AvatarProfilesModule.cs | 7 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 266 +-- .../Environment/Modules/DynamicTextureModule.cs | 6 +- OpenSim/Region/Environment/Modules/EmailModule.cs | 2 +- .../Region/Environment/Modules/FriendsModule.cs | 4 +- OpenSim/Region/Environment/Modules/GroupsModule.cs | 4 +- .../Environment/Modules/InstantMessageModule.cs | 30 +- .../Region/Environment/Modules/InventoryModule.cs | 4 +- .../Environment/Modules/LoadImageURLModule.cs | 33 +- .../Environment/Modules/ScriptsHttpRequests.cs | 2 +- .../Region/Environment/Modules/TeleportModule.cs | 2 +- .../Environment/Modules/TextureDownloadModule.cs | 49 +- .../Region/Environment/Modules/WorldCommModule.cs | 146 +- OpenSim/Region/Environment/Modules/XMLRPCModule.cs | 65 +- OpenSim/Region/Environment/Modules/XferModule.cs | 7 +- OpenSim/Region/Environment/PermissionManager.cs | 3 +- OpenSim/Region/Environment/Scenes/EntityBase.cs | 2 +- .../Environment/Scenes/IScenePresenceBody.cs | 3 +- .../Region/Environment/Scenes/Scene.Inventory.cs | 9 +- .../Environment/Scenes/Scene.PacketHandlers.cs | 22 +- OpenSim/Region/Environment/Scenes/Scene.cs | 197 +- OpenSim/Region/Environment/Scenes/SceneBase.cs | 4 +- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 5 +- OpenSim/Region/Environment/Scenes/SceneManager.cs | 86 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 44 +- .../Region/Environment/Scenes/SceneObjectPart.cs | 23 +- .../Environment/Scenes/ScenePresence.Animations.cs | 2 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 83 +- .../Environment/Scenes/Scripting/IScriptHost.cs | 2 +- .../Environment/Scenes/Scripting/NullScriptHost.cs | 2 +- OpenSim/Region/Environment/StorageManager.cs | 2 +- .../Region/Environment/Types/BasicQuadTreeNode.cs | 45 +- OpenSim/Region/Environment/Types/UpdateQueue.cs | 2 +- OpenSim/Region/Examples/SimpleApp/ComplexObject.cs | 65 +- .../Region/Examples/SimpleApp/CpuCounterObject.cs | 25 +- .../Region/Examples/SimpleApp/FileSystemObject.cs | 14 +- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 286 ++- OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 32 +- OpenSim/Region/Examples/SimpleApp/Program.cs | 87 +- .../Examples/SimpleApp/Properties/AssemblyInfo.cs | 31 +- .../Engines/CSharp/CSharpScriptEngine.cs | 13 +- .../Engines/CSharp/Examples/ExportRegionToLSL.cs | 16 +- .../Engines/JScript/JScriptEngine.cs | 5 +- .../Engines/JVMEngine/JVM/ClassInstance.cs | 5 +- .../Engines/JVMEngine/JVM/ClassRecord.cs | 222 +- .../Engines/JVMEngine/JVM/Heap.cs | 5 +- .../Engines/JVMEngine/JVM/Interpreter.Logic.cs | 454 ++-- .../Engines/JVMEngine/JVM/Interpreter.Methods.cs | 44 +- .../Engines/JVMEngine/JVM/Interpreter.Return.cs | 6 +- .../Engines/JVMEngine/JVM/Interpreter.cs | 63 +- .../Engines/JVMEngine/JVM/MainMemory.cs | 8 +- .../Engines/JVMEngine/JVM/MethodMemory.cs | 4 +- .../Engines/JVMEngine/JVM/Object.cs | 6 +- .../Engines/JVMEngine/JVM/OpCodes.cs | 6 +- .../Engines/JVMEngine/JVM/Stack.cs | 4 +- .../Engines/JVMEngine/JVM/StackFrame.cs | 5 +- .../Engines/JVMEngine/JVM/Thread.cs | 32 +- .../Engines/JVMEngine/JavaEngine.cs | 6 +- .../Engines/JVMEngine/OpenSimJVM.cs | 55 +- .../Engines/JVMEngine/Types/ArrayReference.cs | 8 +- .../Engines/JVMEngine/Types/ObjectReference.cs | 7 +- .../Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs | 7 +- .../Engines/JVMEngine/Types/PrimitiveTypes/Char.cs | 7 +- .../JVMEngine/Types/PrimitiveTypes/Float.cs | 8 +- .../Engines/JVMEngine/Types/PrimitiveTypes/Int.cs | 8 +- OpenSim/Region/ExtensionsScriptModule/Script.cs | 8 +- OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs | 11 +- .../Region/ExtensionsScriptModule/ScriptInfo.cs | 7 +- .../ExtensionsScriptModule/ScriptInterpretedAPI.cs | 52 +- .../ScriptInterpretedEvents.cs | 9 +- .../Region/ExtensionsScriptModule/ScriptManager.cs | 26 +- .../Physics/BasicPhysicsPlugin/AssemblyInfo.cs | 22 +- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 106 +- .../Region/Physics/BulletXPlugin/AssemblyInfo.cs | 24 +- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 589 +++--- OpenSim/Region/Physics/Manager/AssemblyInfo.cs | 22 +- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 110 +- .../Region/Physics/Manager/PhysicsPluginManager.cs | 143 +- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 26 +- OpenSim/Region/Physics/Manager/PhysicsVector.cs | 5 +- OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs | 22 +- .../Physics/OdePlugin/Meshing/HelperTypes.cs | 72 +- .../Physics/OdePlugin/Meshing/Meshmerizer.cs | 256 ++- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 274 +-- OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs | 22 +- OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 643 +++--- OpenSim/Region/ScriptEngine/Common/Executor.cs | 88 +- OpenSim/Region/ScriptEngine/Common/IScript.cs | 6 +- .../Common/LSL_BuiltIn_Commands_Interface.cs | 15 +- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 26 +- .../ScriptEngine/Common/Properties/AssemblyInfo.cs | 31 +- .../ScriptEngine/DotNetEngine/AppDomainManager.cs | 48 +- OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs | 16 +- .../DotNetEngine/Compiler/LSL/Compiler.cs | 38 +- .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 82 +- .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 2173 ++++++++++++++++---- .../DotNetEngine/Compiler/LSO/Common.cs | 27 +- .../DotNetEngine/Compiler/LSO/Engine.cs | 149 +- .../Compiler/LSO/IL_common_functions.cs | 25 +- .../DotNetEngine/Compiler/LSO/LSL_BaseClass.cs | 20 +- .../Compiler/LSO/LSL_BaseClass_OPCODES.cs | 186 +- .../DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs | 6 +- .../Compiler/LSO/LSL_OPCODE_IL_processor.cs | 135 +- .../DotNetEngine/Compiler/LSO/LSO_Enums.cs | 11 +- .../DotNetEngine/Compiler/LSO/LSO_Parser.cs | 208 +- .../DotNetEngine/Compiler/LSO/LSO_Struct.cs | 20 +- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 2020 +++++++++++++----- .../ScriptEngine/DotNetEngine/EventManager.cs | 173 +- .../ScriptEngine/DotNetEngine/EventQueueManager.cs | 64 +- .../ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs | 74 +- .../DotNetEngine/Properties/AssemblyInfo.cs | 31 +- .../ScriptEngine/DotNetEngine/ScriptEngine.cs | 33 +- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 101 +- .../TempDotNetMicroThreadingCodeInjector.cs | 20 +- .../MonoSqliteDataStore.cs | 289 +-- .../OpenSim.DataStore.NullStorage/NullDataStore.cs | 19 +- .../Properties/AssemblyInfo.cs | 31 +- .../Properties/AssemblyInfo.cs | 31 +- .../Region/Terrain.BasicTerrain/TerrainEngine.cs | 169 +- .../Region/Terrain.BasicTerrain/TerrainFilter.cs | 8 +- .../libTerrainBSD/Bitmap/Bitmap.cs | 20 +- .../libTerrainBSD/Channel/Channel.cs | 18 +- .../libTerrainBSD/Channel/Common.cs | 33 +- .../libTerrainBSD/Channel/Editing/Flatten.cs | 29 +- .../libTerrainBSD/Channel/Editing/Raise.cs | 14 +- .../libTerrainBSD/Channel/File.cs | 15 +- .../libTerrainBSD/Channel/Generators/Fracture.cs | 10 +- .../libTerrainBSD/Channel/Generators/Gradient.cs | 5 - .../Channel/Generators/HillPlanter.cs | 77 +- .../libTerrainBSD/Channel/Generators/Noise.cs | 4 +- .../libTerrainBSD/Channel/Generators/Spiral.cs | 47 +- .../libTerrainBSD/Channel/Generators/Voronoi.cs | 35 +- .../libTerrainBSD/Channel/Generators/Worms.cs | 14 +- .../libTerrainBSD/Channel/Grid.cs | 42 +- .../Channel/Manipulators/AerobicErosion.cs | 23 +- .../Channel/Manipulators/HydraulicErosion.cs | 19 +- .../Channel/Manipulators/NavierStokes.cs | 100 +- .../Channel/Manipulators/ThermalWeathering.cs | 18 +- .../libTerrainBSD/Channel/Neighbours.cs | 10 +- .../libTerrainBSD/Channel/Operators.cs | 9 +- .../libTerrainBSD/Tools/Point2D.cs | 6 +- .../libTerrainBSD/Tools/Tools.cs | 31 +- 353 files changed, 15777 insertions(+), 10656 deletions(-) diff --git a/OpenSim/Framework/Communications/CAPSService.cs b/OpenSim/Framework/Communications/CAPSService.cs index b60ef02..40f4006 100644 --- a/OpenSim/Framework/Communications/CAPSService.cs +++ b/OpenSim/Framework/Communications/CAPSService.cs @@ -37,17 +37,17 @@ namespace OpenSim.Framework.Communications public CAPSService(BaseHttpServer httpServer) { m_server = httpServer; - this.AddCapsSeedHandler("/CapsSeed/", CapsRequest); + AddCapsSeedHandler("/CapsSeed/", CapsRequest); } private void AddCapsSeedHandler(string path, RestMethod restMethod) { - m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); + m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod)); } public string CapsRequest(string request, string path, string param) { - System.Console.WriteLine("new caps request " + request +" from path "+ path); + System.Console.WriteLine("new caps request " + request + " from path " + path); return ""; } } diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index 39e2887..ca2fc35 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -29,12 +29,9 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Threading; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications.Cache @@ -51,18 +48,22 @@ namespace OpenSim.Framework.Communications.Cache public Dictionary Assets; public Dictionary Textures; - public List AssetRequests = new List(); //assets ready to be sent to viewers + public List AssetRequests = new List(); //assets ready to be sent to viewers public List TextureRequests = new List(); //textures ready to be sent - public Dictionary RequestedAssets = new Dictionary(); //Assets requested from the asset server - public Dictionary RequestedTextures = new Dictionary(); //Textures requested from the asset server + public Dictionary RequestedAssets = new Dictionary(); + //Assets requested from the asset server + + public Dictionary RequestedTextures = new Dictionary(); + //Textures requested from the asset server public Dictionary SendingTextures = new Dictionary(); private BlockingQueue QueueTextures = new BlockingQueue(); private Dictionary> AvatarRecievedTextures = new Dictionary>(); - private Dictionary> TimesTextureSent = new Dictionary>(); + private Dictionary> TimesTextureSent = + new Dictionary>(); public Dictionary RequestLists = new Dictionary(); @@ -76,19 +77,18 @@ namespace OpenSim.Framework.Communications.Cache /// public AssetCache(IAssetServer assetServer) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSTORAGE","Creating Asset cache"); + MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); _assetServer = assetServer; _assetServer.SetReceiver(this); Assets = new Dictionary(); Textures = new Dictionary(); - this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - this._assetCacheThread.IsBackground = true; - this._assetCacheThread.Start(); - - this.TextureSenderThread = new Thread(new ThreadStart(this.ProcessTextureSenders)); - this.TextureSenderThread.IsBackground = true; - this.TextureSenderThread.Start(); + _assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + _assetCacheThread.IsBackground = true; + _assetCacheThread.Start(); + TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); + TextureSenderThread.IsBackground = true; + TextureSenderThread.Start(); } /// @@ -100,8 +100,8 @@ namespace OpenSim.Framework.Communications.Cache { try { - this.ProcessAssetQueue(); - this.ProcessTextureQueue(); + ProcessAssetQueue(); + ProcessTextureQueue(); Thread.Sleep(500); } catch (Exception e) @@ -115,13 +115,13 @@ namespace OpenSim.Framework.Communications.Cache public AssetBase GetAsset(LLUUID assetID) { AssetBase asset = null; - if (this.Textures.ContainsKey(assetID)) + if (Textures.ContainsKey(assetID)) { - asset = this.Textures[assetID]; + asset = Textures[assetID]; } - else if (this.Assets.ContainsKey(assetID)) + else if (Assets.ContainsKey(assetID)) { - asset = this.Assets[assetID]; + asset = Assets[assetID]; } return asset; } @@ -129,13 +129,13 @@ namespace OpenSim.Framework.Communications.Cache public void GetAsset(LLUUID assetID, AssetRequestCallback callback) { AssetBase asset = null; - if (this.Textures.ContainsKey(assetID)) + if (Textures.ContainsKey(assetID)) { - asset = this.Textures[assetID]; + asset = Textures[assetID]; } - else if (this.Assets.ContainsKey(assetID)) + else if (Assets.ContainsKey(assetID)) { - asset = this.Assets[assetID]; + asset = Assets[assetID]; } if (asset != null) @@ -145,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache else { NewAssetRequest req = new NewAssetRequest(assetID, callback); - if (this.RequestLists.ContainsKey(assetID)) + if (RequestLists.ContainsKey(assetID)) { lock (RequestLists) { @@ -161,7 +161,7 @@ namespace OpenSim.Framework.Communications.Cache RequestLists.Add(assetID, reqList); } } - this._assetServer.FetchAsset(assetID, false); + _assetServer.FetchAsset(assetID, false); } } @@ -171,22 +171,23 @@ namespace OpenSim.Framework.Communications.Cache AssetBase asset = GetAsset(assetID); if (asset == null) { - this._assetServer.FetchAsset(assetID, isTexture); + _assetServer.FetchAsset(assetID, isTexture); } return asset; } public void AddAsset(AssetBase asset) { - //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); if (asset.Type == 0) { //Console.WriteLine("which is a texture"); if (!Textures.ContainsKey(asset.FullID)) - { //texture + { + //texture TextureImage textur = new TextureImage(asset); Textures.Add(textur.FullID, textur); - if(!asset.Temporary) + if (!asset.Temporary) _assetServer.StoreAndCommitAsset(asset); } else @@ -219,49 +220,47 @@ namespace OpenSim.Framework.Communications.Cache /// private void ProcessTextureQueue() { - if (this.TextureRequests.Count == 0) + if (TextureRequests.Count == 0) { //no requests waiting return; } int num; - num = this.TextureRequests.Count; + num = TextureRequests.Count; AssetRequest req; for (int i = 0; i < num; i++) { - req = (AssetRequest)this.TextureRequests[i]; - if (!this.SendingTextures.ContainsKey(req.ImageInfo.FullID)) + req = (AssetRequest) TextureRequests[i]; + if (!SendingTextures.ContainsKey(req.ImageInfo.FullID)) { //Console.WriteLine("new texture to send"); TextureSender sender = new TextureSender(req); //sender.OnComplete += this.TextureSent; - this.SendingTextures.Add(req.ImageInfo.FullID, sender); - this.QueueTextures.Enqueue(sender); + SendingTextures.Add(req.ImageInfo.FullID, sender); + QueueTextures.Enqueue(sender); } - } - this.TextureRequests.Clear(); + TextureRequests.Clear(); } public void ProcessTextureSenders() { while (true) { - TextureSender sender = this.QueueTextures.Dequeue(); - + TextureSender sender = QueueTextures.Dequeue(); + bool finished = sender.SendTexture(); if (finished) { - this.TextureSent(sender); + TextureSent(sender); } else { // Console.WriteLine("readding texture"); - this.QueueTextures.Enqueue(sender); + QueueTextures.Enqueue(sender); } - } } @@ -271,16 +270,16 @@ namespace OpenSim.Framework.Communications.Cache /// public void TextureSent(TextureSender sender) { - if (this.SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) + if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) { - this.SendingTextures.Remove(sender.request.ImageInfo.FullID); + SendingTextures.Remove(sender.request.ImageInfo.FullID); // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } public void AssetReceived(AssetBase asset, bool IsTexture) { - if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server + if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server { //check if it is a texture or not //then add to the correct cache list @@ -292,48 +291,48 @@ namespace OpenSim.Framework.Communications.Cache //Console.WriteLine("asset recieved from asset server"); TextureImage image = new TextureImage(asset); - if (!this.Textures.ContainsKey(image.FullID)) + if (!Textures.ContainsKey(image.FullID)) { - this.Textures.Add(image.FullID, image); - if (this.RequestedTextures.ContainsKey(image.FullID)) + Textures.Add(image.FullID, image); + if (RequestedTextures.ContainsKey(image.FullID)) { - AssetRequest req = this.RequestedTextures[image.FullID]; + AssetRequest req = RequestedTextures[image.FullID]; req.ImageInfo = image; if (image.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int)(image.Data.Length - 600) / 1000; + req.NumPackets = 1 + (int) (image.Data.Length - 600)/1000; } else { req.NumPackets = 1; } - this.RequestedTextures.Remove(image.FullID); - this.TextureRequests.Add(req); + RequestedTextures.Remove(image.FullID); + TextureRequests.Add(req); } } } else { AssetInfo assetInf = new AssetInfo(asset); - if (!this.Assets.ContainsKey(assetInf.FullID)) + if (!Assets.ContainsKey(assetInf.FullID)) { - this.Assets.Add(assetInf.FullID, assetInf); - if (this.RequestedAssets.ContainsKey(assetInf.FullID)) + Assets.Add(assetInf.FullID, assetInf); + if (RequestedAssets.ContainsKey(assetInf.FullID)) { - AssetRequest req = this.RequestedAssets[assetInf.FullID]; + AssetRequest req = RequestedAssets[assetInf.FullID]; req.AssetInf = assetInf; if (assetInf.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; + req.NumPackets = 1 + (int) (assetInf.Data.Length - 600 + 999)/1000; } else { req.NumPackets = 1; } - this.RequestedAssets.Remove(assetInf.FullID); - this.AssetRequests.Add(req); + RequestedAssets.Remove(assetInf.FullID); + AssetRequests.Add(req); } } } @@ -345,7 +344,7 @@ namespace OpenSim.Framework.Communications.Cache { req.Callback(asset.FullID, asset); } - + lock (RequestLists) { RequestLists.Remove(asset.FullID); @@ -373,6 +372,7 @@ namespace OpenSim.Framework.Communications.Cache } #region Assets + /// /// /// @@ -396,11 +396,11 @@ namespace OpenSim.Framework.Communications.Cache } //check to see if asset is in local cache, if not we need to request it from asset server. //Console.WriteLine("asset request " + requestID); - if (!this.Assets.ContainsKey(requestID)) + if (!Assets.ContainsKey(requestID)) { //not found asset // so request from asset server - if (!this.RequestedAssets.ContainsKey(requestID)) + if (!RequestedAssets.ContainsKey(requestID)) { AssetRequest request = new AssetRequest(); request.RequestUser = userInfo; @@ -408,13 +408,13 @@ namespace OpenSim.Framework.Communications.Cache request.TransferRequestID = transferRequest.TransferInfo.TransferID; request.AssetRequestSource = source; request.Params = transferRequest.TransferInfo.Params; - this.RequestedAssets.Add(requestID, request); - this._assetServer.FetchAsset(requestID, false); + RequestedAssets.Add(requestID, request); + _assetServer.FetchAsset(requestID, false); } return; } //it is in our cache - AssetInfo asset = this.Assets[requestID]; + AssetInfo asset = Assets[requestID]; //work out how many packets it should be sent in // and add to the AssetRequests list @@ -429,14 +429,14 @@ namespace OpenSim.Framework.Communications.Cache if (asset.Data.LongLength > 600) { //over 600 bytes so split up file - req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; + req.NumPackets = 1 + (int) (asset.Data.Length - 600 + 999)/1000; } else { req.NumPackets = 1; } - this.AssetRequests.Add(req); + AssetRequests.Add(req); } /// @@ -444,17 +444,17 @@ namespace OpenSim.Framework.Communications.Cache /// private void ProcessAssetQueue() { - if (this.AssetRequests.Count == 0) + if (AssetRequests.Count == 0) { //no requests waiting return; } int num; - if (this.AssetRequests.Count < 5) + if (AssetRequests.Count < 5) { //lower than 5 so do all of them - num = this.AssetRequests.Count; + num = AssetRequests.Count; } else { @@ -463,7 +463,7 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req; for (int i = 0; i < num; i++) { - req = (AssetRequest)this.AssetRequests[i]; + req = (AssetRequest) AssetRequests[i]; //Console.WriteLine("sending asset " + req.RequestAssetID); TransferInfoPacket Transfer = new TransferInfoPacket(); Transfer.TransferInfo.ChannelType = 2; @@ -473,7 +473,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) @@ -483,7 +483,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); @@ -533,19 +533,19 @@ namespace OpenSim.Framework.Communications.Cache req.RequestUser.OutPacket(TransferPacket); } } - } //remove requests that have been completed for (int i = 0; i < num; i++) { - this.AssetRequests.RemoveAt(0); + AssetRequests.RemoveAt(0); } - } + #endregion #region Textures + /// /// /// @@ -553,21 +553,21 @@ namespace OpenSim.Framework.Communications.Cache /// public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) { - // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); + // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); //check to see if texture is in local cache, if not request from asset server - if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) + if (!AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) { - this.AvatarRecievedTextures.Add(userInfo.AgentId, new List()); + AvatarRecievedTextures.Add(userInfo.AgentId, new List()); } /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) { //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); return; }*/ - - if (!this.Textures.ContainsKey(imageID)) + + if (!Textures.ContainsKey(imageID)) { - if (!this.RequestedTextures.ContainsKey(imageID)) + if (!RequestedTextures.ContainsKey(imageID)) { //not is cache so request from asset server AssetRequest request = new AssetRequest(); @@ -575,14 +575,14 @@ namespace OpenSim.Framework.Communications.Cache request.RequestAssetID = imageID; request.IsTextureRequest = true; request.DiscardLevel = discard; - this.RequestedTextures.Add(imageID, request); - this._assetServer.FetchAsset(imageID, true); + RequestedTextures.Add(imageID, request); + _assetServer.FetchAsset(imageID, true); } return; } - // System.Console.WriteLine("texture already in cache"); - TextureImage imag = this.Textures[imageID]; + // System.Console.WriteLine("texture already in cache"); + TextureImage imag = Textures[imageID]; AssetRequest req = new AssetRequest(); req.RequestUser = userInfo; req.RequestAssetID = imageID; @@ -594,7 +594,7 @@ namespace OpenSim.Framework.Communications.Cache { //Console.WriteLine("{0}", imag.Data.LongLength); //over 600 bytes so split up file - req.NumPackets = 2 + (int)(imag.Data.Length - 601) / 1000; + req.NumPackets = 2 + (int) (imag.Data.Length - 601)/1000; //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); } else @@ -603,12 +603,11 @@ namespace OpenSim.Framework.Communications.Cache } if (packetNumber != 0) { - req.PacketCounter = (int)packetNumber; + req.PacketCounter = (int) packetNumber; } - this.TextureRequests.Add(req); + TextureRequests.Add(req); } - #endregion public class AssetRequest @@ -630,7 +629,6 @@ namespace OpenSim.Framework.Communications.Cache public AssetRequest() { - } } @@ -638,7 +636,6 @@ namespace OpenSim.Framework.Communications.Cache { public AssetInfo() { - } public AssetInfo(AssetBase aBase) @@ -656,7 +653,6 @@ namespace OpenSim.Framework.Communications.Cache { public TextureImage() { - } public TextureImage(AssetBase aBase) @@ -678,7 +674,6 @@ namespace OpenSim.Framework.Communications.Cache public TextureSender(AssetRequest req) { request = req; - } public bool SendTexture() @@ -686,7 +681,8 @@ namespace OpenSim.Framework.Communications.Cache SendPacket(); counter++; - if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | (request.DiscardLevel == -1)) + if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1) | + (request.DiscardLevel == -1)) { return true; } @@ -707,7 +703,7 @@ namespace OpenSim.Framework.Communications.Cache im.Header.Reliable = false; im.ImageID.Packets = 1; im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + im.ImageID.Size = (uint) req.ImageInfo.Data.Length; im.ImageData.Data = req.ImageInfo.Data; im.ImageID.Codec = 2; req.RequestUser.OutPacket(im); @@ -721,9 +717,9 @@ namespace OpenSim.Framework.Communications.Cache //more than one packet so split file up ImageDataPacket im = new ImageDataPacket(); im.Header.Reliable = false; - im.ImageID.Packets = (ushort)(req.NumPackets); + im.ImageID.Packets = (ushort) (req.NumPackets); im.ImageID.ID = req.ImageInfo.FullID; - im.ImageID.Size = (uint)req.ImageInfo.Data.Length; + im.ImageID.Size = (uint) req.ImageInfo.Data.Length; im.ImageData.Data = new byte[600]; Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); im.ImageID.Codec = 2; @@ -742,19 +738,18 @@ namespace OpenSim.Framework.Communications.Cache //more than one packet so split file up ImagePacketPacket im = new ImagePacketPacket(); im.Header.Reliable = false; - im.ImageID.Packet = (ushort)(req.PacketCounter); + im.ImageID.Packet = (ushort) (req.PacketCounter); im.ImageID.ID = req.ImageInfo.FullID; - int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter - 1)); + int size = req.ImageInfo.Data.Length - 600 - (1000*(req.PacketCounter - 1)); if (size > 1000) size = 1000; //Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size); im.ImageData.Data = new byte[size]; - Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter - 1)), im.ImageData.Data, 0, size); + Array.Copy(req.ImageInfo.Data, 600 + (1000*(req.PacketCounter - 1)), im.ImageData.Data, 0, size); req.RequestUser.OutPacket(im); req.PacketCounter++; //req.ImageInfo.last_used = time; //System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID); } - } private void SaveAssetToFile(string filename, byte[] data) @@ -789,7 +784,5 @@ namespace OpenSim.Framework.Communications.Cache AssetID = assetID; Callback = callback; } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/AssetServer.cs b/OpenSim/Framework/Communications/Cache/AssetServer.cs index c927571..fa421c7 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServer.cs @@ -25,18 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; using System.IO; -using System.Threading; using Db4objects.Db4o; using Db4objects.Db4o.Query; using libsecondlife; -using Nini.Config; -using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -50,7 +43,7 @@ namespace OpenSim.Framework.Communications.Cache yapfile = File.Exists(Path.Combine(Util.dataDir(), "regionassets.yap")); db = Db4oFactory.OpenFile(Path.Combine(Util.dataDir(), "regionassets.yap")); - MainLog.Instance.Verbose("ASSETS","Db4 Asset database creation"); + MainLog.Instance.Verbose("ASSETS", "Db4 Asset database creation"); if (!yapfile) { @@ -68,29 +61,29 @@ namespace OpenSim.Framework.Communications.Cache db.Commit(); } - override public void Close() + public override void Close() { base.Close(); if (db != null) { - MainLog.Instance.Verbose("ASSETSERVER","Closing local asset server database"); + MainLog.Instance.Verbose("ASSETSERVER", "Closing local asset server database"); db.Close(); } } - override protected void RunRequests() + protected override void RunRequests() { while (true) { byte[] idata = null; bool found = false; AssetStorage foundAsset = null; - ARequest req = this._assetRequests.Dequeue(); + ARequest req = _assetRequests.Dequeue(); IObjectSet result = db.Query(new AssetUUIDQuery(req.AssetID)); if (result.Count > 0) { - foundAsset = (AssetStorage)result.Next(); + foundAsset = (AssetStorage) result.Next(); found = true; } @@ -110,12 +103,10 @@ namespace OpenSim.Framework.Communications.Cache //asset.FullID = ; _receiver.AssetNotFound(req.AssetID); } - } - } - override protected void StoreAsset(AssetBase asset) + protected override void StoreAsset(AssetBase asset) { AssetStorage store = new AssetStorage(); store.Data = asset.Data; @@ -148,6 +139,7 @@ namespace OpenSim.Framework.Communications.Cache { _findID = find; } + public bool Match(AssetStorage asset) { return (asset.UUID == _findID); diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 0771a20..7109910 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -5,8 +5,6 @@ using System.Threading; using libsecondlife; using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -36,13 +34,12 @@ namespace OpenSim.Framework.Communications.Cache public AssetServerBase() { + MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); + _assetRequests = new BlockingQueue(); - OpenSim.Framework.Console.MainLog.Instance.Verbose("ASSETSERVER","Starting asset storage system"); - this._assetRequests = new BlockingQueue(); - - this._localAssetServerThread = new Thread(RunRequests); - this._localAssetServerThread.IsBackground = true; - this._localAssetServerThread.Start(); + _localAssetServerThread = new Thread(RunRequests); + _localAssetServerThread.IsBackground = true; + _localAssetServerThread.Start(); } public void LoadAsset(AssetBase info, bool image, string filename) @@ -57,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); byte[] idata = new byte[numBytes]; BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); + idata = br.ReadBytes((int) numBytes); br.Close(); fStream.Close(); info.Data = idata; @@ -66,7 +63,7 @@ namespace OpenSim.Framework.Communications.Cache public void SetReceiver(IAssetReceiver receiver) { - this._receiver = receiver; + _receiver = receiver; } public void FetchAsset(LLUUID assetID, bool isTexture) @@ -74,7 +71,7 @@ namespace OpenSim.Framework.Communications.Cache ARequest req = new ARequest(); req.AssetID = assetID; req.IsTexture = isTexture; - this._assetRequests.Enqueue(req); + _assetRequests.Enqueue(req); } public void UpdateAsset(AssetBase asset) @@ -102,7 +99,6 @@ namespace OpenSim.Framework.Communications.Cache public void SetServerInfo(string ServerUrl, string ServerKey) { - } public virtual List GetDefaultAssets() @@ -175,8 +171,8 @@ namespace OpenSim.Framework.Communications.Cache // System.Console.WriteLine("loading asset into database"); string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); string fileName = source.Configs[i].GetString("fileName", ""); AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); @@ -189,4 +185,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 d622e02..55b255a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs @@ -25,15 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections; using System.Collections.Generic; -using System.Text; -using System.IO; using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Framework.Data; namespace OpenSim.Framework.Communications.Cache { @@ -41,7 +34,10 @@ namespace OpenSim.Framework.Communications.Cache { // Fields public CommunicationsManager CommsManager; - public Dictionary AgentTransactions = new Dictionary(); + + public Dictionary AgentTransactions = + new Dictionary(); + private bool m_dumpAssetsToFile; public AssetTransactionManager(CommunicationsManager commsManager, bool dumpAssetsToFile) @@ -53,10 +49,10 @@ namespace OpenSim.Framework.Communications.Cache // Methods public AgentAssetTransactions AddUser(LLUUID userID) { - if (!this.AgentTransactions.ContainsKey(userID)) + if (!AgentTransactions.ContainsKey(userID)) { AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); - this.AgentTransactions.Add(userID, transactions); + AgentTransactions.Add(userID, transactions); return transactions; } return null; @@ -64,27 +60,30 @@ namespace OpenSim.Framework.Communications.Cache public AgentAssetTransactions GetUserTransActions(LLUUID userID) { - if (this.AgentTransactions.ContainsKey(userID)) + if (AgentTransactions.ContainsKey(userID)) { - return this.AgentTransactions[userID]; + return AgentTransactions[userID]; } return null; } - public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId); if (transactions != null) { - transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, + name, invType, type, wearableType, nextOwnerMask); } - } - public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) + public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, + byte[] data, bool storeLocal) { // Console.WriteLine("asset upload of " + assetID); - AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId); if (transactions != null) { AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); @@ -97,7 +96,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) { - AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId); + AgentAssetTransactions transactions = GetUserTransActions(remoteClient.AgentId); if (transactions != null) { transactions.HandleXfer(xferID, packetID, data); diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index e78f4f7..6b08fc9 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs @@ -26,17 +26,12 @@ * */ using System; -using System.Collections; using System.Collections.Generic; -using System.Text; using System.IO; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Region.Capabilities; using OpenSim.Framework.Servers; +using OpenSim.Region.Capabilities; namespace OpenSim.Framework.Communications.Cache { @@ -53,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache // Methods public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager, bool dumpAssetsToFile) { - this.UserID = agentID; + UserID = agentID; Manager = manager; m_dumpAssetsToFile = dumpAssetsToFile; } @@ -61,24 +56,24 @@ namespace OpenSim.Framework.Communications.Cache public AssetCapsUploader RequestCapsUploader() { AssetCapsUploader uploader = new AssetCapsUploader(); - this.CapsUploaders.Add(uploader); + CapsUploaders.Add(uploader); return uploader; } public NoteCardCapsUpdate RequestNoteCardUpdater() { NoteCardCapsUpdate update = new NoteCardCapsUpdate(); - this.NotecardUpdaters.Add(update); + NotecardUpdaters.Add(update); return update; } public AssetXferUploader RequestXferUploader(LLUUID transactionID) { - if (!this.XferUploaders.ContainsKey(transactionID)) + if (!XferUploaders.ContainsKey(transactionID)) { AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); - this.XferUploaders.Add(transactionID, uploader); + XferUploaders.Add(transactionID, uploader); return uploader; } return null; @@ -86,7 +81,7 @@ namespace OpenSim.Framework.Communications.Cache public void HandleXfer(ulong xferID, uint packetID, byte[] data) { - foreach (AssetXferUploader uploader in this.XferUploaders.Values) + foreach (AssetXferUploader uploader in XferUploaders.Values) { if (uploader.XferID == xferID) { @@ -96,17 +91,21 @@ namespace OpenSim.Framework.Communications.Cache } } - public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - if (this.XferUploaders.ContainsKey(transactionID)) + if (XferUploaders.ContainsKey(transactionID)) { - this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); + XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, + callbackID, description, name, invType, type, + wearableType, nextOwnerMask); } } public AssetBase GetTransactionAsset(LLUUID transactionID) { - if (this.XferUploaders.ContainsKey(transactionID)) + if (XferUploaders.ContainsKey(transactionID)) { return XferUploaders[transactionID].GetAssetData(); } @@ -130,15 +129,16 @@ namespace OpenSim.Framework.Communications.Cache public event UpLoadedAsset OnUpLoad; // Methods - public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) + public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, + LLUUID folderID, string path, BaseHttpServer httpServer, bool dumpImageToFile) { - this.m_assetName = assetName; - this.m_assetDescription = assetDescription; - this.m_folderID = folderID; - this.newAssetID = assetID; - this.inventoryItemID = inventoryItem; - this.uploaderPath = path; - this.httpListener = httpServer; + m_assetName = assetName; + m_assetDescription = assetDescription; + m_folderID = folderID; + newAssetID = assetID; + inventoryItemID = inventoryItem; + uploaderPath = path; + httpListener = httpServer; m_dumpImageToFile = dumpImageToFile; } @@ -156,18 +156,18 @@ namespace OpenSim.Framework.Communications.Cache LLUUID inventoryItemID = this.inventoryItemID; string text = ""; LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_asset = newAssetID.ToStringHyphenated(); complete.new_inventory_item = inventoryItemID; complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); - this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.m_dumpImageToFile) + httpListener.RemoveStreamHandler("POST", uploaderPath); + if (m_dumpImageToFile) { - this.SaveImageToFile(this.m_assetName + ".jp2", data); + SaveImageToFile(m_assetName + ".jp2", data); } - if (this.OnUpLoad != null) + if (OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , ""); + OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", ""); } return text; } @@ -196,90 +196,91 @@ namespace OpenSim.Framework.Communications.Cache public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) { - this.m_userTransactions = transactions; + m_userTransactions = transactions; m_dumpAssetToFile = dumpAssetToFile; } // Methods public void HandleXferPacket(ulong xferID, uint packetID, byte[] data) { - if (this.XferID == xferID) + if (XferID == xferID) { - if (this.Asset.Data.Length > 1) + if (Asset.Data.Length > 1) { - byte[] destinationArray = new byte[this.Asset.Data.Length + data.Length]; - Array.Copy(this.Asset.Data, 0, destinationArray, 0, this.Asset.Data.Length); - Array.Copy(data, 0, destinationArray, this.Asset.Data.Length, data.Length); - this.Asset.Data = destinationArray; + byte[] destinationArray = new byte[Asset.Data.Length + data.Length]; + Array.Copy(Asset.Data, 0, destinationArray, 0, Asset.Data.Length); + Array.Copy(data, 0, destinationArray, Asset.Data.Length, data.Length); + Asset.Data = destinationArray; } else { byte[] buffer2 = new byte[data.Length - 4]; Array.Copy(data, 4, buffer2, 0, data.Length - 4); - this.Asset.Data = buffer2; + Asset.Data = buffer2; } ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket(); newPack.XferID.ID = xferID; newPack.XferID.Packet = packetID; - this.ourClient.OutPacket(newPack); + ourClient.OutPacket(newPack); if ((packetID & 0x80000000) != 0) { - this.SendCompleteMessage(); + SendCompleteMessage(); } } } - public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal) + public void Initialise(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, + bool storeLocal) { - this.ourClient = remoteClient; - this.Asset = new AssetBase(); - this.Asset.FullID = assetID; - this.Asset.InvType = type; - this.Asset.Type = type; - this.Asset.Data = data; - this.Asset.Name = "blank"; - this.Asset.Description = "empty"; - this.TransactionID = transaction; - this.m_storeLocal = storeLocal; - if (this.Asset.Data.Length > 2) + ourClient = remoteClient; + Asset = new AssetBase(); + Asset.FullID = assetID; + Asset.InvType = type; + Asset.Type = type; + Asset.Data = data; + Asset.Name = "blank"; + Asset.Description = "empty"; + TransactionID = transaction; + m_storeLocal = storeLocal; + if (Asset.Data.Length > 2) { - this.SendCompleteMessage(); + SendCompleteMessage(); } else { - this.ReqestStartXfer(); + ReqestStartXfer(); } } protected void ReqestStartXfer() { - this.UploadComplete = false; - this.XferID = Util.GetNextXferID(); + UploadComplete = false; + XferID = Util.GetNextXferID(); RequestXferPacket newPack = new RequestXferPacket(); - newPack.XferID.ID = this.XferID; - newPack.XferID.VFileType = this.Asset.Type; - newPack.XferID.VFileID = this.Asset.FullID; + newPack.XferID.ID = XferID; + newPack.XferID.VFileType = Asset.Type; + newPack.XferID.VFileID = Asset.FullID; newPack.XferID.FilePath = 0; newPack.XferID.Filename = new byte[0]; - this.ourClient.OutPacket(newPack); + ourClient.OutPacket(newPack); } protected void SendCompleteMessage() { - this.UploadComplete = true; + UploadComplete = true; AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); - newPack.AssetBlock.Type = this.Asset.Type; + newPack.AssetBlock.Type = Asset.Type; newPack.AssetBlock.Success = true; - newPack.AssetBlock.UUID = this.Asset.FullID; - this.ourClient.OutPacket(newPack); - this.m_finished = true; + newPack.AssetBlock.UUID = Asset.FullID; + ourClient.OutPacket(newPack); + m_finished = true; if (m_createItem) { DoCreateItem(); } else if (m_storeLocal) { - this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); + m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); } // Console.WriteLine("upload complete "+ this.TransactionID); @@ -287,8 +288,10 @@ namespace OpenSim.Framework.Communications.Cache if (m_dumpAssetToFile) { DateTime now = DateTime.Now; - string filename = String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type ); - SaveAssetToFile(filename, this.Asset.Data); + string filename = + String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}", now.Year, now.Month, now.Day, + now.Hour, now.Minute, now.Second, Asset.Name, Asset.Type); + SaveAssetToFile(filename, Asset.Data); } } @@ -301,20 +304,22 @@ namespace OpenSim.Framework.Communications.Cache fs.Close(); } - public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) + public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, + uint callbackID, string description, string name, sbyte invType, + sbyte type, byte wearableType, uint nextOwnerMask) { - if (this.TransactionID == transactionID) + if (TransactionID == transactionID) { - this.InventFolder = folderID; - this.m_name = name; - this.m_description = description; + InventFolder = folderID; + m_name = name; + m_description = description; this.type = type; this.invType = invType; - this.nextPerm = nextOwnerMask; - this.Asset.Name = name; - this.Asset.Description = description; - this.Asset.Type = type; - this.Asset.InvType = invType; + nextPerm = nextOwnerMask; + Asset.Name = name; + Asset.Description = description; + Asset.Type = type; + Asset.InvType = invType; m_createItem = true; if (m_finished) { @@ -326,22 +331,23 @@ namespace OpenSim.Framework.Communications.Cache private void DoCreateItem() { //really need to fix this call, if lbsa71 saw this he would die. - this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); - CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); + m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset); + CachedUserInfo userInfo = + m_userTransactions.Manager.CommsManager.UserProfileCache.GetUserDetails(ourClient.AgentId); if (userInfo != null) { InventoryItemBase item = new InventoryItemBase(); - item.avatarID = this.ourClient.AgentId; + item.avatarID = ourClient.AgentId; item.creatorsID = ourClient.AgentId; item.inventoryID = LLUUID.Random(); item.assetID = Asset.FullID; - item.inventoryDescription = this.m_description; + item.inventoryDescription = m_description; item.inventoryName = m_name; item.assetType = type; - item.invType = this.invType; - item.parentFolderID = this.InventFolder; + item.invType = invType; + item.parentFolderID = InventFolder; item.inventoryCurrentPermissions = 2147483647; - item.inventoryNextPermissions = this.nextPerm; + item.inventoryNextPermissions = nextPerm; userInfo.AddItem(ourClient.AgentId, item); ourClient.SendInventoryItemUpdate(item); @@ -350,14 +356,13 @@ namespace OpenSim.Framework.Communications.Cache public void UpdateInventoryItem(LLUUID itemID) { - } public AssetBase GetAssetData() { if (m_finished) { - return this.Asset; + return Asset; } return null; } @@ -379,10 +384,10 @@ namespace OpenSim.Framework.Communications.Cache // Methods public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer) { - this.inventoryItemID = inventoryItem; - this.uploaderPath = path; - this.httpListener = httpServer; - this.newAssetID = LLUUID.Random(); + inventoryItemID = inventoryItem; + uploaderPath = path; + httpListener = httpServer; + newAssetID = LLUUID.Random(); } private void SaveImageToFile(string filename, byte[] data) @@ -399,18 +404,18 @@ namespace OpenSim.Framework.Communications.Cache LLUUID inventoryItemID = this.inventoryItemID; string text = ""; LLSDAssetUploadComplete complete = new LLSDAssetUploadComplete(); - complete.new_asset = this.newAssetID.ToStringHyphenated(); + complete.new_asset = newAssetID.ToStringHyphenated(); complete.new_inventory_item = inventoryItemID; complete.state = "complete"; text = LLSDHelpers.SerialiseLLSDReply(complete); - this.httpListener.RemoveStreamHandler("POST", this.uploaderPath); - if (this.SaveImages) + httpListener.RemoveStreamHandler("POST", uploaderPath); + if (SaveImages) { - this.SaveImageToFile(this.m_assetName + "notecard.txt", data); + SaveImageToFile(m_assetName + "notecard.txt", data); } - if (this.OnUpLoad != null) + if (OnUpLoad != null) { - this.OnUpLoad(this.m_assetName, "description", this.newAssetID, inventoryItemID, LLUUID.Zero, data, "" , "" ); + OnUpLoad(m_assetName, "description", newAssetID, inventoryItemID, LLUUID.Zero, data, "", ""); } return text; } diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 2d639d6..8fbc3fd 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -26,7 +26,6 @@ * */ using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -45,22 +44,22 @@ namespace OpenSim.Framework.Communications.Cache // Methods public void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo) { - if (userID == this.UserProfile.UUID) + if (userID == UserProfile.UUID) { - if (this.RootFolder == null) + if (RootFolder == null) { if (folderInfo.parentID == LLUUID.Zero) { - this.RootFolder = folderInfo; + RootFolder = folderInfo; } } - else if (this.RootFolder.folderID == folderInfo.parentID) + else if (RootFolder.folderID == folderInfo.parentID) { - this.RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); + RootFolder.SubFolders.Add(folderInfo.folderID, folderInfo); } else { - InventoryFolderImpl folder = this.RootFolder.HasSubFolder(folderInfo.parentID); + InventoryFolderImpl folder = RootFolder.HasSubFolder(folderInfo.parentID); if (folder != null) { folder.SubFolders.Add(folderInfo.folderID, folderInfo); @@ -71,18 +70,18 @@ namespace OpenSim.Framework.Communications.Cache public void ItemReceive(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { - if (itemInfo.parentFolderID == this.RootFolder.folderID) + if (itemInfo.parentFolderID == RootFolder.folderID) { - this.RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); + RootFolder.Items.Add(itemInfo.inventoryID, itemInfo); } else { - InventoryFolderImpl folder = this.RootFolder.HasSubFolder(itemInfo.parentFolderID); + InventoryFolderImpl folder = RootFolder.HasSubFolder(itemInfo.parentFolderID); if (folder != null) { - folder.Items.Add(itemInfo.inventoryID, itemInfo); + folder.Items.Add(itemInfo.inventoryID, itemInfo); } } } @@ -90,30 +89,30 @@ namespace OpenSim.Framework.Communications.Cache public void AddItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { - this.ItemReceive(userID, itemInfo); - this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + ItemReceive(userID, itemInfo); + m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } public void UpdateItem(LLUUID userID, InventoryItemBase itemInfo) { - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { - this.m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); + m_parentCommsManager.InventoryService.AddNewInventoryItem(userID, itemInfo); } } public bool DeleteItem(LLUUID userID, InventoryItemBase item) { bool result = false; - if ((userID == this.UserProfile.UUID) && (this.RootFolder != null)) + if ((userID == UserProfile.UUID) && (RootFolder != null)) { result = RootFolder.DeleteItem(item.inventoryID); if (result) { - this.m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); + m_parentCommsManager.InventoryService.DeleteInventoryItem(userID, item); } } return result; diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs index 4904293..74a1ef4 100644 --- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs +++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs @@ -25,19 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; +using System.Collections.Generic; using System.IO; -using System.Threading; -using System.Reflection; using System.Xml.Serialization; - using libsecondlife; - -using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Framework.Communications; namespace OpenSim.Framework.Communications.Cache { @@ -63,7 +57,6 @@ namespace OpenSim.Framework.Communications.Cache Stream s = null; try { - MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString()); RestClient rc = new RestClient(_assetServerUrl); @@ -77,8 +70,8 @@ namespace OpenSim.Framework.Communications.Cache if (s.Length > 0) { - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - AssetBase asset = (AssetBase)xs.Deserialize(s); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); + AssetBase asset = (AssetBase) xs.Deserialize(s); _receiver.AssetReceived(asset, isTexture); } @@ -106,7 +99,7 @@ namespace OpenSim.Framework.Communications.Cache { MemoryStream s = new MemoryStream(); - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); xs.Serialize(s, asset); RestClient rc = new RestClient(_assetServerUrl); rc.AddResourcePath("assets"); @@ -129,7 +122,7 @@ namespace OpenSim.Framework.Communications.Cache throw new Exception("The method or operation is not implemented."); } - public System.Collections.Generic.List GetDefaultAssets() + public List GetDefaultAssets() { throw new Exception("The method or operation is not implemented."); } @@ -156,4 +149,4 @@ namespace OpenSim.Framework.Communications.Cache #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs index 0905af8..3495e55 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolder.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolder.cs @@ -25,14 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections; using System.Collections.Generic; -using System.Text; -using System.IO; using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -44,17 +38,16 @@ namespace OpenSim.Framework.Communications.Cache public InventoryFolderImpl(InventoryFolderBase folderbase) { - this.agentID = folderbase.agentID; - this.folderID = folderbase.folderID; - this.name = folderbase.name; - this.parentID = folderbase.parentID; - this.type = folderbase.type; - this.version = folderbase.version; + agentID = folderbase.agentID; + folderID = folderbase.folderID; + name = folderbase.name; + parentID = folderbase.parentID; + type = folderbase.type; + version = folderbase.version; } public InventoryFolderImpl() { - } // Methods @@ -65,19 +58,19 @@ namespace OpenSim.Framework.Communications.Cache subFold.folderID = folderID; subFold.type = (short) type; subFold.parentID = this.folderID; - subFold.agentID = this.agentID; - this.SubFolders.Add(subFold.folderID, subFold); + subFold.agentID = agentID; + SubFolders.Add(subFold.folderID, subFold); return subFold; } public InventoryItemBase HasItem(LLUUID itemID) { InventoryItemBase base2 = null; - if (this.Items.ContainsKey(itemID)) + if (Items.ContainsKey(itemID)) { - return this.Items[itemID]; + return Items[itemID]; } - foreach (InventoryFolderImpl folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in SubFolders.Values) { base2 = folder.HasItem(itemID); if (base2 != null) @@ -91,12 +84,12 @@ namespace OpenSim.Framework.Communications.Cache public bool DeleteItem(LLUUID itemID) { bool found = false; - if (this.Items.ContainsKey(itemID)) + if (Items.ContainsKey(itemID)) { Items.Remove(itemID); return true; } - foreach (InventoryFolderImpl folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in SubFolders.Values) { found = folder.DeleteItem(itemID); if (found == true) @@ -111,13 +104,13 @@ namespace OpenSim.Framework.Communications.Cache public InventoryFolderImpl HasSubFolder(LLUUID folderID) { InventoryFolderImpl returnFolder = null; - if (this.SubFolders.ContainsKey(folderID)) + if (SubFolders.ContainsKey(folderID)) { - returnFolder = this.SubFolders[folderID]; + returnFolder = SubFolders[folderID]; } else { - foreach (InventoryFolderImpl folder in this.SubFolders.Values) + foreach (InventoryFolderImpl folder in SubFolders.Values) { returnFolder = folder.HasSubFolder(folderID); if (returnFolder != null) @@ -132,7 +125,7 @@ namespace OpenSim.Framework.Communications.Cache public List RequestListOfItems() { List itemList = new List(); - foreach (InventoryItemBase item in this.Items.Values) + foreach (InventoryItemBase item in Items.Values) { itemList.Add(item); } diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 60f9b6b..765c42e 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs @@ -26,12 +26,8 @@ * */ -using System; using System.IO; -using System.Collections.Generic; -using System.Text; using libsecondlife; -using OpenSim.Framework; using Nini.Config; namespace OpenSim.Framework.Communications.Cache @@ -40,43 +36,42 @@ namespace OpenSim.Framework.Communications.Cache /// Basically a hack to give us a Inventory library while we don't have a inventory server /// once the server is fully implemented then should read the data from that /// - public class LibraryRootFolder : Cache.InventoryFolderImpl + public class LibraryRootFolder : InventoryFolderImpl { private LLUUID libOwner = new LLUUID("11111111-1111-0000-0000-000100bba000"); - private Cache.InventoryFolderImpl m_textureFolder; + private InventoryFolderImpl m_textureFolder; public LibraryRootFolder() { - this.agentID = libOwner; - this.folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); - this.name = "OpenSim Library"; - this.parentID = LLUUID.Zero; - this.type = (short)-1; - this.version = (ushort)1; - - Cache.InventoryFolderImpl folderInfo = new InventoryFolderImpl(); + agentID = libOwner; + folderID = new LLUUID("00000112-000f-0000-0000-000100bba000"); + name = "OpenSim Library"; + parentID = LLUUID.Zero; + type = (short) -1; + version = (ushort) 1; + + InventoryFolderImpl folderInfo = new InventoryFolderImpl(); folderInfo.agentID = libOwner; folderInfo.folderID = new LLUUID("00000112-000f-0000-0000-000100bba001"); folderInfo.name = "Texture Library"; - folderInfo.parentID = this.folderID; + folderInfo.parentID = folderID; folderInfo.type = -1; folderInfo.version = 1; - this.SubFolders.Add(folderInfo.folderID, folderInfo); - this.m_textureFolder = folderInfo; + SubFolders.Add(folderInfo.folderID, folderInfo); + m_textureFolder = folderInfo; - this.CreateLibraryItems(); + CreateLibraryItems(); string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); if (File.Exists(filePath)) { XmlConfigSource source = new XmlConfigSource(filePath); - this.ReadItemsFromFile(source); + ReadItemsFromFile(source); } } private void CreateLibraryItems() { - InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; @@ -90,7 +85,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -105,7 +100,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -120,7 +115,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -135,7 +130,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -150,7 +145,7 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryEveryOnePermissions = 0x7FFFFFFF; item.inventoryCurrentPermissions = 0x7FFFFFFF; item.inventoryNextPermissions = 0x7FFFFFFF; - this.m_textureFolder.Items.Add(item.inventoryID, item); + m_textureFolder.Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -161,10 +156,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Shape"; item.assetType = 13; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); + Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -175,10 +170,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Skin"; item.assetType = 13; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); + Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -189,10 +184,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Shirt"; item.assetType = 5; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); + Items.Add(item.inventoryID, item); item = new InventoryItemBase(); item.avatarID = libOwner; @@ -203,11 +198,10 @@ namespace OpenSim.Framework.Communications.Cache item.inventoryName = "Default Pants"; item.assetType = 5; item.invType = 18; - item.parentFolderID = this.folderID; + item.parentFolderID = folderID; item.inventoryCurrentPermissions = 0; item.inventoryNextPermissions = 0; - this.Items.Add(item.inventoryID, item); - + Items.Add(item.inventoryID, item); } private void ReadItemsFromFile(IConfigSource source) @@ -217,28 +211,28 @@ namespace OpenSim.Framework.Communications.Cache InventoryItemBase item = new InventoryItemBase(); item.avatarID = libOwner; item.creatorsID = libOwner; - item.inventoryID = new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated())); + item.inventoryID = + new LLUUID(source.Configs[i].GetString("inventoryID", LLUUID.Random().ToStringHyphenated())); item.assetID = new LLUUID(source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated())); item.inventoryDescription = source.Configs[i].GetString("description", ""); 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 = this.m_textureFolder.folderID; - this.m_textureFolder.Items.Add(item.inventoryID, item); + item.parentFolderID = m_textureFolder.folderID; + m_textureFolder.Items.Add(item.inventoryID, item); } else { - item.parentFolderID = this.folderID; - this.Items.Add(item.inventoryID, item); + item.parentFolderID = folderID; + Items.Add(item.inventoryID, item); } } } - } } \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs index 0953e19..b4f29db 100644 --- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs +++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs @@ -26,14 +26,8 @@ * */ using System; -using System.IO; -using System.Threading; using System.Reflection; -using libsecondlife; -using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Communications.Cache { @@ -62,11 +56,14 @@ namespace OpenSim.Framework.Communications.Cache if (typeInterface != null) { - IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IAssetProvider plug = + (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); m_assetProviderPlugin = plug; m_assetProviderPlugin.Initialise(); - MainLog.Instance.Verbose("AssetStorage","Added " + m_assetProviderPlugin.Name + " " + m_assetProviderPlugin.Version); + MainLog.Instance.Verbose("AssetStorage", + "Added " + m_assetProviderPlugin.Name + " " + + m_assetProviderPlugin.Version); } typeInterface = null; @@ -84,13 +81,13 @@ namespace OpenSim.Framework.Communications.Cache m_assetProviderPlugin.CommitAssets(); } - override protected void RunRequests() + protected override void RunRequests() { while (true) { - ARequest req = this._assetRequests.Dequeue(); + ARequest req = _assetRequests.Dequeue(); - //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); + //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); AssetBase asset = null; lock (syncLock) @@ -105,9 +102,7 @@ namespace OpenSim.Framework.Communications.Cache { _receiver.AssetNotFound(req.AssetID); } - } - } protected override void StoreAsset(AssetBase asset) diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs index 8105556..fe943b0 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCache.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCache.cs @@ -25,16 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections; using System.Collections.Generic; -using System.Text; -using System.IO; using libsecondlife; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; - namespace OpenSim.Framework.Communications.Cache { @@ -49,7 +41,7 @@ namespace OpenSim.Framework.Communications.Cache // Methods public UserProfileCache(CommunicationsManager parent) { - this.m_parent = parent; + m_parent = parent; } /// @@ -62,14 +54,14 @@ namespace OpenSim.Framework.Communications.Cache // Potential fix - Multithreading issue. lock (UserProfiles) { - if (!this.UserProfiles.ContainsKey(userID)) + if (!UserProfiles.ContainsKey(userID)) { - CachedUserInfo userInfo = new CachedUserInfo(this.m_parent); - userInfo.UserProfile = this.RequestUserProfileForUser(userID); + CachedUserInfo userInfo = new CachedUserInfo(m_parent); + userInfo.UserProfile = RequestUserProfileForUser(userID); if (userInfo.UserProfile != null) { - this.RequestInventoryForUser(userID, userInfo); - this.UserProfiles.Add(userID, userInfo); + RequestInventoryForUser(userID, userInfo); + UserProfiles.Add(userID, userInfo); } else { @@ -91,26 +83,28 @@ namespace OpenSim.Framework.Communications.Cache public CachedUserInfo GetUserDetails(LLUUID userID) { - if (this.UserProfiles.ContainsKey(userID)) + if (UserProfiles.ContainsKey(userID)) { - return this.UserProfiles[userID]; + return UserProfiles[userID]; } return null; } - public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID) + public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, + string folderName, LLUUID parentID) { - if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + if (UserProfiles.ContainsKey(remoteClient.AgentId)) { - if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) + if (UserProfiles[remoteClient.AgentId].RootFolder != null) { - CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + CachedUserInfo info = UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == parentID) { - InventoryFolderImpl createdFolder = info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); + InventoryFolderImpl createdFolder = + info.RootFolder.CreateNewSubFolder(folderID, folderName, folderType); if (createdFolder != null) { - this.m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); + m_parent.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdFolder); } } else @@ -125,27 +119,30 @@ namespace OpenSim.Framework.Communications.Cache } } - public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) + public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, + bool fetchFolders, bool fetchItems, int sortOrder) { - InventoryFolderImpl fold = null; - if (folderID == libraryRoot.folderID ) + InventoryFolderImpl fold = null; + if (folderID == libraryRoot.folderID) { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, + libraryRoot.RequestListOfItems()); } - else if (( fold = libraryRoot.HasSubFolder(folderID)) != null) + else if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems()); } - else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + else if (UserProfiles.ContainsKey(remoteClient.AgentId)) { - if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) + if (UserProfiles[remoteClient.AgentId].RootFolder != null) { - CachedUserInfo info = this.UserProfiles[remoteClient.AgentId]; + CachedUserInfo info = UserProfiles[remoteClient.AgentId]; if (info.RootFolder.folderID == folderID) { if (fetchItems) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, info.RootFolder.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, + info.RootFolder.RequestListOfItems()); } } else @@ -153,7 +150,8 @@ namespace OpenSim.Framework.Communications.Cache InventoryFolderImpl folder = info.RootFolder.HasSubFolder(folderID); if ((folder != null) && fetchItems) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, folder.RequestListOfItems()); + remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, + folder.RequestListOfItems()); } } } @@ -166,11 +164,11 @@ namespace OpenSim.Framework.Communications.Cache { //Console.WriteLine("request info for library item"); } - else if (this.UserProfiles.ContainsKey(remoteClient.AgentId)) + else if (UserProfiles.ContainsKey(remoteClient.AgentId)) { - if (this.UserProfiles[remoteClient.AgentId].RootFolder != null) + if (UserProfiles[remoteClient.AgentId].RootFolder != null) { - InventoryItemBase item = this.UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); + InventoryItemBase item = UserProfiles[remoteClient.AgentId].RootFolder.HasItem(itemID); if (item != null) { remoteClient.SendInventoryItemDetails(ownerID, item); @@ -185,7 +183,7 @@ namespace OpenSim.Framework.Communications.Cache /// private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo) { - this.m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); + m_parent.InventoryService.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive); } /// @@ -194,7 +192,7 @@ namespace OpenSim.Framework.Communications.Cache /// private UserProfileData RequestUserProfileForUser(LLUUID userID) { - return this.m_parent.UserService.GetUserProfile(userID); + return m_parent.UserService.GetUserProfile(userID); } /// diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index a114b64..23dfcc6 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -28,18 +28,23 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; using System.IO; using libsecondlife; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; using OpenSim.Framework.Servers; -using OpenSim.Framework; namespace OpenSim.Region.Capabilities { - public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType); + public delegate void UpLoadedAsset( + 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 NewInventoryItem(LLUUID userID, InventoryItemBase item); + public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data); public class Caps @@ -62,7 +67,8 @@ namespace OpenSim.Region.Capabilities public ItemUpdatedCallback ItemUpdatedCall = null; private bool m_dumpAssetsToFile; - public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) + public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, + LLUUID agent, bool dumpAssetsToFile) { assetCache = assetCach; m_capsObjectPath = capsPath; @@ -78,12 +84,17 @@ namespace OpenSim.Region.Capabilities /// public void RegisterHandlers() { - OpenSim.Framework.Console.MainLog.Instance.Verbose("CAPS","Registering CAPS handlers"); + MainLog.Instance.Verbose("CAPS", "Registering CAPS handlers"); string capsBase = "/CAPS/" + m_capsObjectPath; try { - httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer)); - httpListener.AddStreamHandler(new LLSDStreamhandler("POST", capsBase + m_newInventory, this.NewAgentInventoryRequest)); + httpListener.AddStreamHandler( + new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, + GetMapLayer)); + httpListener.AddStreamHandler( + new LLSDStreamhandler("POST", + capsBase + m_newInventory, + NewAgentInventoryRequest)); AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); //AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture); @@ -103,7 +114,7 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } - + /// /// /// @@ -113,8 +124,8 @@ namespace OpenSim.Region.Capabilities /// public string CapsRequest(string request, string path, string param) { - // Console.WriteLine("caps request " + request); - string result = LLSDHelpers.SerialiseLLSDReply(this.GetCapabilities()); + // Console.WriteLine("caps request " + request); + string result = LLSDHelpers.SerialiseLLSDReply(GetCapabilities()); return result; } @@ -125,9 +136,10 @@ namespace OpenSim.Region.Capabilities protected LLSDCapsDetails GetCapabilities() { LLSDCapsDetails caps = new LLSDCapsDetails(); - string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath; + 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; @@ -142,7 +154,7 @@ namespace OpenSim.Region.Capabilities public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) { LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(this.GetLLSDMapLayerResponse()); + mapResponse.LayerData.Array.Add(GetLLSDMapLayerResponse()); return mapResponse; } @@ -174,6 +186,7 @@ namespace OpenSim.Region.Capabilities } #region EventQueue (Currently not enabled) + /// /// /// @@ -184,10 +197,10 @@ namespace OpenSim.Region.Capabilities public string ProcessEventQueue(string request, string path, string param) { string res = ""; - - if (this.CapsEventQueue.Count > 0) + + if (CapsEventQueue.Count > 0) { - lock (this.CapsEventQueue) + lock (CapsEventQueue) { string item = CapsEventQueue.Dequeue(); res = item; @@ -195,7 +208,7 @@ namespace OpenSim.Region.Capabilities } else { - res = this.CreateEmptyEventResponse(); + res = CreateEmptyEventResponse(); } return res; } @@ -214,8 +227,8 @@ namespace OpenSim.Region.Capabilities eventItem.events.Array.Add(new LLSDEmpty()); string res = LLSDHelpers.SerialiseLLSDReply(eventItem); eventQueueCount++; - - this.CapsEventQueue.Enqueue(res); + + CapsEventQueue.Enqueue(res); return res; } @@ -232,6 +245,7 @@ namespace OpenSim.Region.Capabilities eventQueueCount++; return res; } + #endregion /// @@ -243,24 +257,27 @@ namespace OpenSim.Region.Capabilities /// public string NoteCardAgentInventory(string request, string path, string param) { - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request)); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(Helpers.StringToField(request)); LLSDItemUpdate llsdRequest = new LLSDItemUpdate(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); - + string capsBase = "/CAPS/" + m_capsObjectPath; LLUUID newInvItem = llsdRequest.item_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile ); - uploader.OnUpLoad += this.ItemUpdated; + ItemUpdater uploader = + new ItemUpdater(newInvItem, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); + uploader.OnUpLoad += ItemUpdated; - httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; + httpListener.AddStreamHandler( + new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); + string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; - + return LLSDHelpers.SerialiseLLSDReply(uploadResponse); } @@ -272,7 +289,7 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest) { //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); - + string assetName = llsdRequest.name; string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_capsObjectPath; @@ -281,14 +298,18 @@ namespace OpenSim.Region.Capabilities LLUUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, this.httpListener, m_dumpAssetsToFile); - httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); - string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath; + AssetUploader uploader = + new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + llsdRequest.asset_type, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile); + httpListener.AddStreamHandler( + new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps)); + string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + + uploaderPath; LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse(); uploadResponse.uploader = uploaderURL; uploadResponse.state = "upload"; - uploader.OnUpLoad += this.UploadCompleteHandler; + uploader.OnUpLoad += UploadCompleteHandler; return uploadResponse; } @@ -298,7 +319,9 @@ namespace OpenSim.Region.Capabilities /// /// /// - public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, string assetType) + public void UploadCompleteHandler(string assetName, string assetDescription, LLUUID assetID, + LLUUID inventoryItem, LLUUID parentFolder, byte[] data, string inventoryType, + string assetType) { sbyte assType = 0; sbyte inType = 0; @@ -319,14 +342,14 @@ namespace OpenSim.Region.Capabilities asset.FullID = assetID; asset.Type = assType; asset.InvType = inType; - asset.Name = assetName; + asset.Name = assetName; asset.Data = data; - this.assetCache.AddAsset(asset); + assetCache.AddAsset(asset); InventoryItemBase item = new InventoryItemBase(); item.avatarID = agentID; item.creatorsID = agentID; - item.inventoryID = inventoryItem; + item.inventoryID = inventoryItem; item.assetID = asset.FullID; item.inventoryDescription = assetDescription; item.inventoryName = assetName; @@ -340,14 +363,13 @@ namespace OpenSim.Region.Capabilities { AddNewInventoryItem(agentID, item); } - } public LLUUID ItemUpdated(LLUUID itemID, byte[] data) { if (ItemUpdatedCall != null) { - return ItemUpdatedCall(this.agentID, itemID, data); + return ItemUpdatedCall(agentID, itemID, data); } return LLUUID.Zero; } @@ -359,7 +381,7 @@ namespace OpenSim.Region.Capabilities private string uploaderPath = ""; private LLUUID newAssetID; private LLUUID inventoryItemID; - private LLUUID parentFolder; + private LLUUID parentFolder; private BaseHttpServer httpListener; private bool m_dumpAssetsToFile; private string m_assetName = ""; @@ -368,7 +390,9 @@ namespace OpenSim.Region.Capabilities private string m_invType = ""; private string m_assetType = ""; - public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolderID, string invType, string assetType, string path, BaseHttpServer httpServer, bool dumpAssetsToFile) + public AssetUploader(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, + LLUUID parentFolderID, string invType, string assetType, string path, + BaseHttpServer httpServer, bool dumpAssetsToFile) { m_assetName = assetName; m_assetDes = description; @@ -391,7 +415,7 @@ namespace OpenSim.Region.Capabilities /// public string uploaderCaps(byte[] data, string path, string param) { - LLUUID inv = this.inventoryItemID; + LLUUID inv = inventoryItemID; string res = ""; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); uploadComplete.new_asset = newAssetID.ToStringHyphenated(); @@ -399,29 +423,29 @@ namespace OpenSim.Region.Capabilities uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - + httpListener.RemoveStreamHandler("POST", uploaderPath); - if (this.m_dumpAssetsToFile) + if (m_dumpAssetsToFile) { - this.SaveAssetToFile(m_assetName + ".jp2", data); + SaveAssetToFile(m_assetName + ".jp2", data); } if (OnUpLoad != null) { OnUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); } - + return res; } private void SaveAssetToFile(string filename, byte[] data) { - FileStream fs = File.Create(filename); - BinaryWriter bw = new BinaryWriter(fs); - bw.Write(data); - bw.Close(); - fs.Close(); + FileStream fs = File.Create(filename); + BinaryWriter bw = new BinaryWriter(fs); + bw.Write(data); + bw.Close(); + fs.Close(); } } @@ -434,7 +458,7 @@ namespace OpenSim.Region.Capabilities private BaseHttpServer httpListener; private bool m_dumpAssetToFile; - public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) + public ItemUpdater(LLUUID inventoryItem, string path, BaseHttpServer httpServer, bool dumpAssetToFile) { m_dumpAssetToFile = dumpAssetToFile; @@ -452,7 +476,7 @@ namespace OpenSim.Region.Capabilities /// public string uploaderCaps(byte[] data, string path, string param) { - LLUUID inv = this.inventoryItemID; + LLUUID inv = inventoryItemID; string res = ""; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); LLUUID assetID = LLUUID.Zero; @@ -461,7 +485,7 @@ namespace OpenSim.Region.Capabilities { assetID = OnUpLoad(inv, data); } - + uploadComplete.new_asset = assetID.ToStringHyphenated(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; @@ -470,9 +494,9 @@ namespace OpenSim.Region.Capabilities httpListener.RemoveStreamHandler("POST", uploaderPath); - if (this.m_dumpAssetToFile) + if (m_dumpAssetToFile) { - this.SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); + SaveAssetToFile("updateditem" + Util.RandomClass.Next(1, 1000) + ".dat", data); } return res; @@ -488,6 +512,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 2af5a4a..2ed7750 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDArray.cs @@ -36,7 +36,6 @@ namespace OpenSim.Region.Capabilities public LLSDArray() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs index e65e741..d054386 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadComplete.cs @@ -39,7 +39,6 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadComplete() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs index 3a2fe20..7fed27a 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadRequest.cs @@ -26,9 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; namespace OpenSim.Region.Capabilities @@ -46,4 +43,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs index c7a9ee6..3ad618d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDAssetUploadResponse.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Capabilities { [LLSDMap] @@ -40,7 +36,6 @@ namespace OpenSim.Region.Capabilities public LLSDAssetUploadResponse() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs index d1894d4..06afac4 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapEvent.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDCapEvent() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs index 3184792..35caa15 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDCapsDetails.cs @@ -34,18 +34,14 @@ namespace OpenSim.Region.Capabilities public string MapLayer = ""; public string NewFileAgentInventory = ""; //public string EventQueueGet = ""; - // public string RequestTextureDownload = ""; - // public string ChatSessionRequest = ""; + // public string RequestTextureDownload = ""; + // public string ChatSessionRequest = ""; public string UpdateNotecardAgentInventory = ""; public string UpdateScriptAgentInventory = ""; - // public string ParcelVoiceInfoRequest = ""; + // public string ParcelVoiceInfoRequest = ""; public LLSDCapsDetails() { - } } -} - - - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs index 0169d3c..69c525c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDEmpty.cs @@ -32,7 +32,6 @@ namespace OpenSim.Region.Capabilities { public LLSDEmpty() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs index 8a2215f..8252a63 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDHelpers.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.Capabilities public static void SerializeLLSDType(XmlTextWriter writer, object obj) { Type myType = obj.GetType(); - LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); + LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); if (llsdattributes.Length > 0) { switch (llsdattributes[0].ObjectType) @@ -62,7 +62,8 @@ namespace OpenSim.Region.Capabilities for (int i = 0; i < fields.Length; i++) { object fieldValue = fields[i].GetValue(obj); - LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false); + LLSDType[] fieldAttributes = + (LLSDType[]) fieldValue.GetType().GetCustomAttributes(typeof (LLSDType), false); if (fieldAttributes.Length > 0) { writer.WriteStartElement(String.Empty, "key", String.Empty); @@ -83,7 +84,7 @@ namespace OpenSim.Region.Capabilities case "ARRAY": // LLSDArray arrayObject = obj as LLSDArray; // ArrayList a = arrayObject.Array; - ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj); + ArrayList a = (ArrayList) obj.GetType().GetField("Array").GetValue(obj); if (a != null) { writer.WriteStartElement(String.Empty, "array", String.Empty); @@ -105,7 +106,7 @@ namespace OpenSim.Region.Capabilities public static object DeserialiseLLSDMap(Hashtable llsd, object obj) { Type myType = obj.GetType(); - LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false); + LLSDType[] llsdattributes = (LLSDType[]) myType.GetCustomAttributes(typeof (LLSDType), false); if (llsdattributes.Length > 0) { switch (llsdattributes[0].ObjectType) @@ -114,7 +115,7 @@ namespace OpenSim.Region.Capabilities IDictionaryEnumerator enumerator = llsd.GetEnumerator(); while (enumerator.MoveNext()) { - FieldInfo field = myType.GetField((string)enumerator.Key); + FieldInfo field = myType.GetField((string) enumerator.Key); if (field != null) { if (enumerator.Value is Hashtable) @@ -142,23 +143,4 @@ namespace OpenSim.Region.Capabilities return obj; } } - - - - - - - - - - - - - - - - - - - -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs index 57fc9e8..3842058 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDItemUpdate.cs @@ -26,9 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; namespace OpenSim.Region.Capabilities @@ -42,4 +39,4 @@ namespace OpenSim.Region.Capabilities { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs index 6d17bff..683e479 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayer.cs @@ -40,7 +40,6 @@ namespace OpenSim.Region.Capabilities public LLSDMapLayer() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs index 7900290..1945a6c 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapLayerResponse.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDMapLayerResponse() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs index 5fa08c9..935f81d 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMapRequest.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDMapRequest() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs index 67253ee..6bd47e1 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethod.cs @@ -26,11 +26,7 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.Capabilities { public delegate TResponse LLSDMethod(TRequest request); -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs index 894b276..08e9563 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDStreamHandler.cs @@ -26,13 +26,11 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Servers; -using System.IO; using System.Collections; +using System.IO; +using System.Text; using libsecondlife; +using OpenSim.Framework.Servers; namespace OpenSim.Region.Capabilities { @@ -42,11 +40,11 @@ namespace OpenSim.Region.Capabilities private LLSDMethod m_method; public LLSDStreamhandler(string httpMethod, string path, LLSDMethod method) - : base(httpMethod, path ) + : base(httpMethod, path) { m_method = method; } - + public override byte[] Handle(string path, Stream request) { //Encoding encoding = Encoding.UTF8; @@ -55,16 +53,15 @@ namespace OpenSim.Region.Capabilities //string requestBody = streamReader.ReadToEnd(); //streamReader.Close(); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request ); + Hashtable hash = (Hashtable) LLSD.LLSDDeserialize(request); TRequest llsdRequest = new TRequest(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); TResponse response = m_method(llsdRequest); Encoding encoding = new UTF8Encoding(false); - - return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) ); + return encoding.GetBytes(LLSDHelpers.SerialiseLLSDReply(response)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs index f70fa11..c2a6054 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDTest.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.Capabilities public LLSDTest() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs index 6af7f39..a90ae03 100644 --- a/OpenSim/Framework/Communications/Capabilities/LLSDType.cs +++ b/OpenSim/Framework/Communications/Capabilities/LLSDType.cs @@ -37,23 +37,19 @@ namespace OpenSim.Region.Capabilities public LLSDType(string type) { myType = type; - } public string ObjectType { - get - { - return myType; - } + get { return myType; } } } [AttributeUsage(AttributeTargets.Class)] public class LLSDMap : LLSDType { - public LLSDMap() : base( "MAP" ) + public LLSDMap() : base("MAP") { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index d8d198b..77c7261 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -28,69 +28,77 @@ using System; using libsecondlife; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Framework.Console; namespace OpenSim.Framework.Communications { public class CommunicationsManager { protected IUserService m_userService; + public IUserService UserService { get { return m_userService; } } protected IGridServices m_gridService; + public IGridServices GridService { get { return m_gridService; } } protected IInventoryServices m_inventoryService; + public IInventoryServices InventoryService { get { return m_inventoryService; } } protected IInterRegionCommunications m_interRegion; + public IInterRegionCommunications InterRegion { get { return m_interRegion; } } protected UserProfileCache m_userProfileCache; + public UserProfileCache UserProfileCache { get { return m_userProfileCache; } } protected AssetTransactionManager m_transactionsManager; + public AssetTransactionManager TransactionsManager { get { return m_transactionsManager; } } protected AssetCache m_assetCache; + public AssetCache AssetCache { get { return m_assetCache; } } protected NetworkServersInfo m_networkServersInfo; + public NetworkServersInfo NetworkServersInfo { get { return m_networkServersInfo; } } - public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, bool dumpAssetsToFile) + public CommunicationsManager(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, + bool dumpAssetsToFile) { m_networkServersInfo = serversInfo; m_assetCache = assetCache; m_userProfileCache = new UserProfileCache(this); - m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile ); + m_transactionsManager = new AssetTransactionManager(this, dumpAssetsToFile); } public void doCreate(string[] cmmdParams) @@ -106,7 +114,6 @@ namespace OpenSim.Framework.Communications if (cmmdParams.Length < 2) { - firstName = MainLog.Instance.CmdPrompt("First name", "Default"); lastName = MainLog.Instance.CmdPrompt("Last name", "User"); password = MainLog.Instance.PasswdPrompt("Password"); @@ -120,7 +127,6 @@ namespace OpenSim.Framework.Communications password = cmmdParams[3]; regX = Convert.ToUInt32(cmmdParams[4]); regY = Convert.ToUInt32(cmmdParams[5]); - } AddUser(firstName, lastName, password, regX, regY); @@ -140,7 +146,7 @@ namespace OpenSim.Framework.Communications } else { - this.m_inventoryService.CreateNewUserInventory(userProf.UUID); + m_inventoryService.CreateNewUserInventory(userProf.UUID); System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName); return userProf.UUID; } diff --git a/OpenSim/Framework/Communications/IGridServices.cs b/OpenSim/Framework/Communications/IGridServices.cs index ccbb729..ce6205f 100644 --- a/OpenSim/Framework/Communications/IGridServices.cs +++ b/OpenSim/Framework/Communications/IGridServices.cs @@ -27,10 +27,6 @@ */ using System.Collections.Generic; -using System.Net; -using libsecondlife; - -using OpenSim.Framework; namespace OpenSim.Framework.Communications { @@ -41,4 +37,4 @@ namespace OpenSim.Framework.Communications RegionInfo RequestNeighbourInfo(ulong regionHandle); List 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 244747d..d4fb54b 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -26,7 +26,6 @@ * */ using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { @@ -36,4 +35,4 @@ namespace OpenSim.Framework.Communications bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); bool AcknowledgeAgentCrossed(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 e7758c4..fc301c2 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs @@ -26,16 +26,14 @@ * */ -using System; using System.Collections.Generic; -using System.Text; using libsecondlife; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { public delegate void InventoryFolderInfo(LLUUID userID, InventoryFolderImpl folderInfo); + public delegate void InventoryItemInfo(LLUUID userID, InventoryItemBase itemInfo); public interface IInventoryServices @@ -53,4 +51,4 @@ namespace OpenSim.Framework.Communications /// List RequestFirstLevelFolders(LLUUID userID); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index 05183be..effe132 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs @@ -30,10 +30,8 @@ using System; using System.Collections.Generic; using System.Reflection; using libsecondlife; -using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework; namespace OpenSim.Framework.Communications { @@ -67,10 +65,10 @@ 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(); - this.m_plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose("INVENTORY","Added IInventoryData Interface"); + m_plugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose("INVENTORY", "Added IInventoryData Interface"); } } } @@ -168,7 +166,7 @@ namespace OpenSim.Framework.Communications { foreach (InventoryFolderBase folder in inventory.Folders.Values) { - this.AddFolder(folder); + AddFolder(folder); } } @@ -176,7 +174,7 @@ namespace OpenSim.Framework.Communications { UsersInventory inven = new UsersInventory(); inven.CreateNewInventorySet(user); - this.AddNewInventorySet(inven); + AddNewInventorySet(inven); } public class UsersInventory @@ -186,7 +184,6 @@ namespace OpenSim.Framework.Communications public UsersInventory() { - } public virtual void CreateNewInventorySet(LLUUID user) @@ -231,9 +228,11 @@ namespace OpenSim.Framework.Communications } } - public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); + public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, + InventoryItemInfo itemCallBack); + public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); 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 38bc016..4d1c35a 100644 --- a/OpenSim/Framework/Communications/LoginResponse.cs +++ b/OpenSim/Framework/Communications/LoginResponse.cs @@ -34,12 +34,10 @@ using OpenSim.Framework.Console; namespace OpenSim.Framework.UserManagement { - /// /// A temp class to handle login response. /// Should make use of UserProfileManager where possible. /// - public class LoginResponse { private Hashtable loginFlagsHash; @@ -103,211 +101,222 @@ namespace OpenSim.Framework.UserManagement public LoginResponse() { - this.loginFlags = new ArrayList(); - this.globalTextures = new ArrayList(); - this.eventCategories = new ArrayList(); - this.uiConfig = new ArrayList(); - this.classifiedCategories = new ArrayList(); + loginFlags = new ArrayList(); + globalTextures = new ArrayList(); + eventCategories = new ArrayList(); + uiConfig = new ArrayList(); + classifiedCategories = new ArrayList(); - this.loginError = new Hashtable(); - this.uiConfigHash = new Hashtable(); + loginError = new Hashtable(); + uiConfigHash = new Hashtable(); - this.defaultXmlRpcResponse = new XmlRpcResponse(); - this.userProfile = new UserInfo(); - this.inventoryRoot = new ArrayList(); - this.initialOutfit = new ArrayList(); - this.agentInventory = new ArrayList(); - this.inventoryLibrary = new ArrayList(); - this.inventoryLibraryOwner = new ArrayList(); + defaultXmlRpcResponse = new XmlRpcResponse(); + userProfile = new UserInfo(); + inventoryRoot = new ArrayList(); + initialOutfit = new ArrayList(); + agentInventory = new ArrayList(); + inventoryLibrary = new ArrayList(); + inventoryLibraryOwner = new ArrayList(); - this.xmlRpcResponse = new XmlRpcResponse(); - this.defaultXmlRpcResponse = new XmlRpcResponse(); + xmlRpcResponse = new XmlRpcResponse(); + defaultXmlRpcResponse = new XmlRpcResponse(); - this.SetDefaultValues(); + SetDefaultValues(); } // LoginServer public void SetDefaultValues() { - this.DST = "N"; - this.StipendSinceLogin = "N"; - this.Gendered = "Y"; - this.EverLoggedIn = "Y"; - this.login = "false"; - this.firstname = "Test"; - this.lastname = "User"; - this.agentAccess = "M"; - this.startLocation = "last"; - this.allowFirstLife = "Y"; - - this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; - this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; - - this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; - this.ErrorReason = "key"; - this.welcomeMessage = "Welcome to OpenSim!"; - this.seedCapability = ""; - this.home = "{'region_handle':[r" + (1000 * 256).ToString() + ",r" + (1000 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}"; - this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; - this.RegionX = (uint)255232; - this.RegionY = (uint)254976; - - // Classifieds; - this.AddClassifiedCategory((Int32)1, "Shopping"); - this.AddClassifiedCategory((Int32)2, "Land Rental"); - this.AddClassifiedCategory((Int32)3, "Property Rental"); - this.AddClassifiedCategory((Int32)4, "Special Attraction"); - this.AddClassifiedCategory((Int32)5, "New Products"); - this.AddClassifiedCategory((Int32)6, "Employment"); - this.AddClassifiedCategory((Int32)7, "Wanted"); - this.AddClassifiedCategory((Int32)8, "Service"); - this.AddClassifiedCategory((Int32)9, "Personal"); - - - this.SessionID = LLUUID.Random(); - this.SecureSessionID = LLUUID.Random(); - this.AgentID = LLUUID.Random(); - - Hashtable InitialOutfitHash = new Hashtable(); - InitialOutfitHash["folder_name"] = "Nightclub Female"; - InitialOutfitHash["gender"] = "female"; - this.initialOutfit.Add(InitialOutfitHash); - - + DST = "N"; + StipendSinceLogin = "N"; + Gendered = "Y"; + EverLoggedIn = "Y"; + login = "false"; + firstname = "Test"; + lastname = "User"; + agentAccess = "M"; + startLocation = "last"; + allowFirstLife = "Y"; + + SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; + CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; + + ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; + ErrorReason = "key"; + welcomeMessage = "Welcome to OpenSim!"; + seedCapability = ""; + home = "{'region_handle':[r" + (1000*256).ToString() + ",r" + (1000*256).ToString() + "], 'position':[r" + + userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + + userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + + userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; + lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; + RegionX = (uint) 255232; + RegionY = (uint) 254976; + + // Classifieds; + AddClassifiedCategory((Int32) 1, "Shopping"); + AddClassifiedCategory((Int32) 2, "Land Rental"); + AddClassifiedCategory((Int32) 3, "Property Rental"); + AddClassifiedCategory((Int32) 4, "Special Attraction"); + AddClassifiedCategory((Int32) 5, "New Products"); + AddClassifiedCategory((Int32) 6, "Employment"); + AddClassifiedCategory((Int32) 7, "Wanted"); + AddClassifiedCategory((Int32) 8, "Service"); + AddClassifiedCategory((Int32) 9, "Personal"); + + + SessionID = LLUUID.Random(); + SecureSessionID = LLUUID.Random(); + AgentID = LLUUID.Random(); + + Hashtable InitialOutfitHash = new Hashtable(); + InitialOutfitHash["folder_name"] = "Nightclub Female"; + InitialOutfitHash["gender"] = "female"; + initialOutfit.Add(InitialOutfitHash); } // SetDefaultValues #region Login Failure Methods + public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) { // Overwrite any default values; - this.xmlRpcResponse = new XmlRpcResponse(); + xmlRpcResponse = new XmlRpcResponse(); // Ensure Login Failed message/reason; - this.ErrorMessage = message; - this.ErrorReason = reason; - - this.loginError["reason"] = this.ErrorReason; - this.loginError["message"] = this.ErrorMessage; - this.loginError["login"] = login; - this.xmlRpcResponse.Value = this.loginError; - return (this.xmlRpcResponse); + ErrorMessage = message; + ErrorReason = reason; + + loginError["reason"] = ErrorReason; + loginError["message"] = ErrorMessage; + loginError["login"] = login; + xmlRpcResponse.Value = loginError; + return (xmlRpcResponse); } // GenerateResponse public XmlRpcResponse CreateFailedResponse() { - return (this.CreateLoginFailedResponse()); + return (CreateLoginFailedResponse()); } // CreateErrorConnectingToGridResponse() public XmlRpcResponse CreateLoginFailedResponse() { - return (this.GenerateFailureResponse("key", "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", "false")); + return + (GenerateFailureResponse("key", + "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", + "false")); } // LoginFailedResponse public XmlRpcResponse CreateAlreadyLoggedInResponse() { - return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false")); + return + (GenerateFailureResponse("presence", + "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", + "false")); } // CreateAlreadyLoggedInResponse() public XmlRpcResponse CreateDeadRegionResponse() { - return (this.GenerateFailureResponse("key", "The region you are attempting to log into is not responding. Please select another region and try again.", "false")); + return + (GenerateFailureResponse("key", + "The region you are attempting to log into is not responding. Please select another region and try again.", + "false")); } - public XmlRpcResponse CreateGridErrorResponse() + public XmlRpcResponse CreateGridErrorResponse() { - return (this.GenerateFailureResponse("key", "Error connecting to grid. Could not percieve credentials from login XML.", "false")); + return + (GenerateFailureResponse("key", + "Error connecting to grid. Could not percieve credentials from login XML.", + "false")); } - + #endregion public XmlRpcResponse ToXmlRpcResponse() { try { - Hashtable responseData = new Hashtable(); - this.loginFlagsHash = new Hashtable(); - this.loginFlagsHash["daylight_savings"] = this.DST; - this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin; - this.loginFlagsHash["gendered"] = this.Gendered; - this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn; - this.loginFlags.Add(this.loginFlagsHash); - - responseData["first_name"] = this.Firstname; - responseData["last_name"] = this.Lastname; - responseData["agent_access"] = this.agentAccess; - - this.globalTexturesHash = new Hashtable(); - this.globalTexturesHash["sun_texture_id"] = this.SunTexture; - this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture; - this.globalTexturesHash["moon_texture_id"] = this.MoonTexture; - this.globalTextures.Add(this.globalTexturesHash); - // this.eventCategories.Add(this.eventCategoriesHash); - - this.AddToUIConfig("allow_first_life", this.allowFirstLife); - this.uiConfig.Add(this.uiConfigHash); - - responseData["sim_port"] =(Int32) this.SimPort; - responseData["sim_ip"] = this.SimAddress; - - responseData["agent_id"] = this.AgentID.ToStringHyphenated(); - responseData["session_id"] = this.SessionID.ToStringHyphenated(); - responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated(); - responseData["circuit_code"] = this.CircuitCode; - responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - responseData["login-flags"] = this.loginFlags; - responseData["global-textures"] = this.globalTextures; - responseData["seed_capability"] = this.seedCapability; - - responseData["event_categories"] = this.eventCategories; + loginFlagsHash = new Hashtable(); + loginFlagsHash["daylight_savings"] = DST; + loginFlagsHash["stipend_since_login"] = StipendSinceLogin; + loginFlagsHash["gendered"] = Gendered; + loginFlagsHash["ever_logged_in"] = EverLoggedIn; + loginFlags.Add(loginFlagsHash); + + responseData["first_name"] = Firstname; + responseData["last_name"] = Lastname; + responseData["agent_access"] = agentAccess; + + globalTexturesHash = new Hashtable(); + globalTexturesHash["sun_texture_id"] = SunTexture; + globalTexturesHash["cloud_texture_id"] = CloudTexture; + globalTexturesHash["moon_texture_id"] = MoonTexture; + globalTextures.Add(globalTexturesHash); + // this.eventCategories.Add(this.eventCategoriesHash); + + AddToUIConfig("allow_first_life", allowFirstLife); + uiConfig.Add(uiConfigHash); + + responseData["sim_port"] = (Int32) SimPort; + responseData["sim_ip"] = SimAddress; + + responseData["agent_id"] = AgentID.ToStringHyphenated(); + responseData["session_id"] = SessionID.ToStringHyphenated(); + responseData["secure_session_id"] = SecureSessionID.ToStringHyphenated(); + responseData["circuit_code"] = CircuitCode; + responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + responseData["login-flags"] = loginFlags; + responseData["global-textures"] = globalTextures; + responseData["seed_capability"] = seedCapability; + + responseData["event_categories"] = eventCategories; responseData["event_notifications"] = new ArrayList(); // todo - responseData["classified_categories"] = this.classifiedCategories; - responseData["ui-config"] = this.uiConfig; + responseData["classified_categories"] = classifiedCategories; + responseData["ui-config"] = uiConfig; - responseData["inventory-skeleton"] = this.agentInventory; - responseData["inventory-skel-lib"] = this.inventoryLibrary; - responseData["inventory-root"] = this.inventoryRoot; + responseData["inventory-skeleton"] = agentInventory; + responseData["inventory-skel-lib"] = inventoryLibrary; + responseData["inventory-root"] = inventoryRoot; responseData["gestures"] = new ArrayList(); // todo - responseData["inventory-lib-owner"] = this.inventoryLibraryOwner; - responseData["initial-outfit"] = this.initialOutfit; - responseData["start_location"] = this.startLocation; - responseData["seed_capability"] = this.seedCapability; - responseData["home"] = this.home; - responseData["look_at"] = this.lookAt; - responseData["message"] = this.welcomeMessage; - responseData["region_x"] = (Int32)this.RegionX * 256; - responseData["region_y"] = (Int32)this.RegionY * 256; + responseData["inventory-lib-owner"] = inventoryLibraryOwner; + responseData["initial-outfit"] = initialOutfit; + responseData["start_location"] = startLocation; + responseData["seed_capability"] = seedCapability; + responseData["home"] = home; + responseData["look_at"] = lookAt; + responseData["message"] = welcomeMessage; + responseData["region_x"] = (Int32) RegionX*256; + responseData["region_y"] = (Int32) RegionY*256; //responseData["inventory-lib-root"] = new ArrayList(); // todo //responseData["buddy-list"] = new ArrayList(); // todo responseData["login"] = "true"; - this.xmlRpcResponse.Value = responseData; + xmlRpcResponse.Value = responseData; - return (this.xmlRpcResponse); + return (xmlRpcResponse); } catch (Exception e) { MainLog.Instance.Warn( "CLIENT", "LoginResponse: Error creating XML-RPC Response: " + e.Message - ); - return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); - + ); + return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); } - } // ToXmlRpcResponse public void SetEventCategories(string category, string value) { - // this.eventCategoriesHash[category] = value; + // this.eventCategoriesHash[category] = value; //TODO } // SetEventCategories public void AddToUIConfig(string itemName, string item) { - this.uiConfigHash[itemName] = item; + uiConfigHash[itemName] = item; } // SetUIConfig public void AddClassifiedCategory(Int32 ID, string categoryName) @@ -315,372 +324,193 @@ namespace OpenSim.Framework.UserManagement Hashtable hash = new Hashtable(); hash["category_name"] = categoryName; hash["category_id"] = ID; - this.classifiedCategories.Add(hash); + classifiedCategories.Add(hash); // this.classifiedCategoriesHash.Clear(); } // SetClassifiedCategory #region Properties + public string Login { - get - { - return this.login; - } - set - { - this.login = value; - } + get { return login; } + set { login = value; } } // Login public string DST { - get - { - return this.dst; - } - set - { - this.dst = value; - } + get { return dst; } + set { dst = value; } } // DST public string StipendSinceLogin { - get - { - return this.stipendSinceLogin; - } - set - { - this.stipendSinceLogin = value; - } + get { return stipendSinceLogin; } + set { stipendSinceLogin = value; } } // StipendSinceLogin public string Gendered { - get - { - return this.gendered; - } - set - { - this.gendered = value; - } + get { return gendered; } + set { gendered = value; } } // Gendered public string EverLoggedIn { - get - { - return this.everLoggedIn; - } - set - { - this.everLoggedIn = value; - } + get { return everLoggedIn; } + set { everLoggedIn = value; } } // EverLoggedIn public int SimPort { - get - { - return this.simPort; - } - set - { - this.simPort = value; - } + get { return simPort; } + set { simPort = value; } } // SimPort public string SimAddress { - get - { - return this.simAddress; - } - set - { - this.simAddress = value; - } + get { return simAddress; } + set { simAddress = value; } } // SimAddress public LLUUID AgentID { - get - { - return this.agentID; - } - set - { - this.agentID = value; - } + get { return agentID; } + set { agentID = value; } } // AgentID public LLUUID SessionID { - get - { - return this.sessionID; - } - set - { - this.sessionID = value; - } + get { return sessionID; } + set { sessionID = value; } } // SessionID public LLUUID SecureSessionID { - get - { - return this.secureSessionID; - } - set - { - this.secureSessionID = value; - } + get { return secureSessionID; } + set { secureSessionID = value; } } // SecureSessionID public Int32 CircuitCode { - get - { - return this.circuitCode; - } - set - { - this.circuitCode = value; - } + get { return circuitCode; } + set { circuitCode = value; } } // CircuitCode public uint RegionX { - get - { - return this.regionX; - } - set - { - this.regionX = value; - } + get { return regionX; } + set { regionX = value; } } // RegionX public uint RegionY { - get - { - return this.regionY; - } - set - { - this.regionY = value; - } + get { return regionY; } + set { regionY = value; } } // RegionY public string SunTexture { - get - { - return this.sunTexture; - } - set - { - this.sunTexture = value; - } + get { return sunTexture; } + set { sunTexture = value; } } // SunTexture public string CloudTexture { - get - { - return this.cloudTexture; - } - set - { - this.cloudTexture = value; - } + get { return cloudTexture; } + set { cloudTexture = value; } } // CloudTexture public string MoonTexture { - get - { - return this.moonTexture; - } - set - { - this.moonTexture = value; - } + get { return moonTexture; } + set { moonTexture = value; } } // MoonTexture public string Firstname { - get - { - return this.firstname; - } - set - { - this.firstname = value; - } + get { return firstname; } + set { firstname = value; } } // Firstname public string Lastname { - get - { - return this.lastname; - } - set - { - this.lastname = value; - } + get { return lastname; } + set { lastname = value; } } // Lastname public string AgentAccess { - get - { - return this.agentAccess; - } - set - { - this.agentAccess = value; - } + get { return agentAccess; } + set { agentAccess = value; } } public string StartLocation { - get - { - return this.startLocation; - } - set - { - this.startLocation = value; - } + get { return startLocation; } + set { startLocation = value; } } // StartLocation public string LookAt { - get - { - return this.lookAt; - } - set - { - this.lookAt = value; - } + get { return lookAt; } + set { lookAt = value; } } public string SeedCapability { - get - { - return this.seedCapability; - } - set - { - this.seedCapability = value; - } + get { return seedCapability; } + set { seedCapability = value; } } // SeedCapability public string ErrorReason { - get - { - return this.errorReason; - } - set - { - this.errorReason = value; - } + get { return errorReason; } + set { errorReason = value; } } // ErrorReason public string ErrorMessage { - get - { - return this.errorMessage; - } - set - { - this.errorMessage = value; - } + get { return errorMessage; } + set { errorMessage = value; } } // ErrorMessage public ArrayList InventoryRoot { - get - { - return this.inventoryRoot; - } - set - { - this.inventoryRoot = value; - } + get { return inventoryRoot; } + set { inventoryRoot = value; } } public ArrayList InventorySkeleton { - get - { - return this.agentInventory; - } - set - { - this.agentInventory = value; - } + get { return agentInventory; } + set { agentInventory = value; } } public ArrayList InventoryLibrary { - get - { - return this.inventoryLibrary; - } - set - { - this.inventoryLibrary = value; - } + get { return inventoryLibrary; } + set { inventoryLibrary = value; } } public ArrayList InventoryLibraryOwner { - get - { - return this.inventoryLibraryOwner; - } - set - { - this.inventoryLibraryOwner = value; - } + get { return inventoryLibraryOwner; } + set { inventoryLibraryOwner = value; } } public string Home { - get - { - return this.home; - } - set - { - this.home = value; - } + get { return home; } + set { home = value; } } public string Message { - get - { - return this.welcomeMessage; - } - set - { - this.welcomeMessage = value; - } + get { return welcomeMessage; } + set { welcomeMessage = value; } } - #endregion + #endregion public class UserInfo { @@ -691,6 +521,4 @@ namespace OpenSim.Framework.UserManagement public LLVector3 homelookat; } } -} - - +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 66b91e1..497cc5d 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -28,16 +28,10 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework.Console; -using OpenSim.Framework; -using InventoryFolder = OpenSim.Framework.InventoryFolder; - namespace OpenSim.Framework.UserManagement { public class LoginService @@ -61,12 +55,12 @@ namespace OpenSim.Framework.UserManagement /// The response to send public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) { - - MainLog.Instance.Verbose("LOGIN","Attempting login now..."); + 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")); + bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && + requestData.Contains("passwd")); bool GoodLogin = false; UserProfileData userProfile; @@ -74,9 +68,9 @@ 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) @@ -110,7 +104,7 @@ namespace OpenSim.Framework.UserManagement LLUUID agentID = userProfile.UUID; // Inventory Library Section - InventoryData inventData = this.CreateInventoryData(agentID); + InventoryData inventData = CreateInventoryData(agentID); ArrayList AgentInventoryArray = inventData.InventoryArray; Hashtable InventoryRootHash = new Hashtable(); @@ -120,7 +114,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; @@ -129,20 +123,20 @@ namespace OpenSim.Framework.UserManagement logResponse.SecureSessionID = userProfile.currentAgent.secureSessionID.ToStringHyphenated(); logResponse.InventoryRoot = InventoryRoot; logResponse.InventorySkeleton = AgentInventoryArray; - logResponse.InventoryLibrary = this.GetInventoryLibrary(); - logResponse.InventoryLibraryOwner = this.GetLibraryOwner(); - logResponse.CircuitCode = (Int32)circode; + logResponse.InventoryLibrary = GetInventoryLibrary(); + logResponse.InventoryLibraryOwner = GetLibraryOwner(); + logResponse.CircuitCode = (Int32) circode; //logResponse.RegionX = 0; //overwritten //logResponse.RegionY = 0; //overwritten - logResponse.Home = "!!null temporary value {home}!!"; // Overwritten + logResponse.Home = "!!null temporary value {home}!!"; // Overwritten //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; //logResponse.SimAddress = "127.0.0.1"; //overwritten //logResponse.SimPort = 0; //overwritten - logResponse.Message = this.GetMessage(); + logResponse.Message = GetMessage(); try { - this.CustomiseResponse(logResponse, userProfile); + CustomiseResponse(logResponse, userProfile); } catch (Exception e) { @@ -152,7 +146,6 @@ namespace OpenSim.Framework.UserManagement } CommitAgent(ref userProfile); return logResponse.ToXmlRpcResponse(); - } catch (Exception E) @@ -162,7 +155,6 @@ namespace OpenSim.Framework.UserManagement //} } return response; - } /// @@ -174,7 +166,7 @@ namespace OpenSim.Framework.UserManagement { } - /// + /// /// Saves a target agent to the database /// /// The users profile @@ -194,8 +186,7 @@ namespace OpenSim.Framework.UserManagement /// Authenticated? public virtual bool AuthenticateUser(UserProfileData profile, string password) { - - MainLog.Instance.Verbose("LOGIN","Authenticating " + profile.username + " " + profile.surname); + MainLog.Instance.Verbose("LOGIN", "Authenticating " + profile.username + " " + profile.surname); password = password.Remove(0, 3); //remove $1$ @@ -211,7 +202,7 @@ namespace OpenSim.Framework.UserManagement /// public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { - this.m_userManager.CreateAgent(profile, request); + m_userManager.CreateAgent(profile, request); } /// @@ -222,7 +213,7 @@ namespace OpenSim.Framework.UserManagement /// public virtual UserProfileData GetTheUser(string firstname, string lastname) { - return this.m_userManager.GetUserProfile(firstname, lastname); + return m_userManager.GetUserProfile(firstname, lastname); } /// @@ -286,8 +277,8 @@ namespace OpenSim.Framework.UserManagement TempHash = new Hashtable(); TempHash["name"] = InvFolder.FolderName; TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - 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.ToStringHyphenated(); AgentInventoryArray.Add(TempHash); } @@ -307,4 +298,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 43fce84..a812ac9 100644 --- a/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Communications/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -27,25 +27,29 @@ */ 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("OpenGrid.Framework.Communications")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenGrid.Framework.Communications")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenGrid.Framework.Communications")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenGrid.Framework.Communications")] +[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("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] + +[assembly : Guid("13e7c396-78a9-4a5c-baf2-6f980ea75d95")] // Version information for an assembly consists of the following four values: // @@ -56,5 +60,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs index c821fa4..72d8f65 100644 --- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs +++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading; namespace OpenSim.Framework.Communications { internal class SimpleAsyncResult : IAsyncResult { - private readonly AsyncCallback m_callback; /// @@ -36,7 +33,6 @@ namespace OpenSim.Framework.Communications m_completedSynchronously = 1; } - #region IAsyncResult Members public object AsyncState @@ -45,7 +41,6 @@ namespace OpenSim.Framework.Communications } - public WaitHandle AsyncWaitHandle { get @@ -82,19 +77,18 @@ namespace OpenSim.Framework.Communications get { return Thread.VolatileRead(ref m_completed) == 1; } } - #endregion - #region class Methods + internal void SetAsCompleted(bool completedSynchronously) { m_completed = 1; - if(completedSynchronously) + if (completedSynchronously) m_completedSynchronously = 1; else m_completedSynchronously = 0; - + SignalCompletion(); } @@ -112,9 +106,9 @@ namespace OpenSim.Framework.Communications private void SignalCompletion() { - if(m_waitHandle != null) m_waitHandle.Set(); + if (m_waitHandle != null) m_waitHandle.Set(); - if(m_callback != null) m_callback(this); + if (m_callback != null) m_callback(this); } public void EndInvoke() @@ -125,14 +119,14 @@ namespace OpenSim.Framework.Communications // If the operation isn't done, wait for it AsyncWaitHandle.WaitOne(); AsyncWaitHandle.Close(); - m_waitHandle = null; // Allow early GC + m_waitHandle = null; // Allow early GC } // Operation is done: if an exception occured, throw it if (m_exception != null) throw m_exception; - } + } - #endregion + #endregion } internal class AsyncResult : SimpleAsyncResult @@ -140,10 +134,12 @@ namespace OpenSim.Framework.Communications private T m_result = default(T); public AsyncResult(AsyncCallback asyncCallback, Object state) : - base(asyncCallback, state) { } + base(asyncCallback, state) + { + } - public void SetAsCompleted(T result, bool completedSynchronously) + public void SetAsCompleted(T result, bool completedSynchronously) { // Save the asynchronous operation's result m_result = result; @@ -153,11 +149,10 @@ namespace OpenSim.Framework.Communications base.SetAsCompleted(completedSynchronously); } - new public T EndInvoke() + public new T EndInvoke() { - base.EndInvoke(); - return m_result; + base.EndInvoke(); + return m_result; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs index 392669f..ac3a287 100644 --- a/OpenSim/Framework/Communications/RestClient/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs @@ -1,12 +1,10 @@ using System; +using System.Collections.Generic; using System.IO; using System.Net; -using System.Web; using System.Text; -using System.Collections.Generic; using System.Threading; - -using OpenSim.Framework.Console; +using System.Web; namespace OpenSim.Framework.Communications { @@ -29,9 +27,10 @@ namespace OpenSim.Framework.Communications /// public class RestClient { + private string realuri; - string realuri; #region member variables + /// /// The base Uri of the web-service e.g. http://www.google.com /// @@ -60,7 +59,7 @@ namespace OpenSim.Framework.Communications /// /// MemoryStream representing the resultiong resource /// - Stream _resource; + private Stream _resource; /// /// WebRequest object, held as a member variable @@ -80,12 +79,12 @@ namespace OpenSim.Framework.Communications /// /// Default time out period /// - const int DefaultTimeout = 10 * 1000; // 10 seconds timeout + private const int DefaultTimeout = 10*1000; // 10 seconds timeout /// /// Default Buffer size of a block requested from the web-server /// - const int BufferSize = 4096; // Read blocks of 4 KB. + private const int BufferSize = 4096; // Read blocks of 4 KB. /// @@ -97,6 +96,7 @@ namespace OpenSim.Framework.Communications #endregion member variables #region constructors + /// /// Instantiate a new RestClient /// @@ -111,7 +111,8 @@ namespace OpenSim.Framework.Communications _lock = new object(); } - object _lock; + private object _lock; + #endregion constructors /// @@ -120,8 +121,8 @@ namespace OpenSim.Framework.Communications /// path entry public void AddResourcePath(string element) { - if(isSlashed(element)) - _pathElements.Add(element.Substring(0, element.Length-1)); + if (isSlashed(element)) + _pathElements.Add(element.Substring(0, element.Length - 1)); else _pathElements.Add(element); } @@ -178,7 +179,7 @@ namespace OpenSim.Framework.Communications /// Build a Uri based on the intial Url, path elements and parameters /// /// fully constructed Uri - Uri buildUri() + private Uri buildUri() { StringBuilder sb = new StringBuilder(); sb.Append(_url); @@ -196,7 +197,8 @@ namespace OpenSim.Framework.Communications { sb.Append("?"); firstElement = false; - } else + } + else sb.Append("&"); sb.Append(kv.Key); @@ -209,7 +211,9 @@ namespace OpenSim.Framework.Communications realuri = sb.ToString(); return new Uri(sb.ToString()); } + #region Async communications with server + /// /// Async method, invoked when a block of data has been received from the service /// @@ -218,13 +222,14 @@ namespace OpenSim.Framework.Communications { try { - Stream s = (Stream)ar.AsyncState; + Stream s = (Stream) ar.AsyncState; int read = s.EndRead(ar); if (read > 0) { _resource.Write(_readbuf, 0, read); - IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + IAsyncResult asynchronousResult = + s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); // TODO! Implement timeout, without killing the server //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); @@ -251,12 +256,13 @@ namespace OpenSim.Framework.Communications try { // grab response - WebRequest wr = (WebRequest)ar.AsyncState; - _response = (HttpWebResponse)wr.EndGetResponse(ar); + WebRequest wr = (WebRequest) ar.AsyncState; + _response = (HttpWebResponse) wr.EndGetResponse(ar); // get response stream, and setup async reading Stream s = _response.GetResponseStream(); - IAsyncResult asynchronousResult = s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); + IAsyncResult asynchronousResult = + s.BeginRead(_readbuf, 0, BufferSize, new AsyncCallback(StreamIsReadyDelegate), s); // TODO! Implement timeout, without killing the server // wait until completed, or we timed out @@ -281,6 +287,7 @@ namespace OpenSim.Framework.Communications } } } + #endregion Async communications with server /// @@ -290,17 +297,17 @@ namespace OpenSim.Framework.Communications { lock (_lock) { - _request = (HttpWebRequest)WebRequest.Create(buildUri()); + _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; _request.Timeout = 200000; _asyncException = null; // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); - _response = (HttpWebResponse)_request.GetResponse(); + _response = (HttpWebResponse) _request.GetResponse(); Stream src = _response.GetResponseStream(); int length = src.Read(_readbuf, 0, BufferSize); - while(length > 0) + while (length > 0) { _resource.Write(_readbuf, 0, length); length = src.Read(_readbuf, 0, BufferSize); @@ -329,7 +336,7 @@ namespace OpenSim.Framework.Communications public Stream Request(Stream src) { - _request = (HttpWebRequest)WebRequest.Create(buildUri()); + _request = (HttpWebRequest) WebRequest.Create(buildUri()); _request.KeepAlive = false; _request.ContentType = "application/xml"; _request.Timeout = 900000; @@ -340,13 +347,13 @@ namespace OpenSim.Framework.Communications src.Seek(0, SeekOrigin.Begin); Stream dst = _request.GetRequestStream(); byte[] buf = new byte[1024]; - int length = src.Read(buf,0, 1024); + int length = src.Read(buf, 0, 1024); while (length > 0) { dst.Write(buf, 0, length); length = src.Read(buf, 0, 1024); } - _response = (HttpWebResponse)_request.GetResponse(); + _response = (HttpWebResponse) _request.GetResponse(); // IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); @@ -357,8 +364,8 @@ namespace OpenSim.Framework.Communications return null; } - #region Async Invocation + public IAsyncResult BeginRequest(AsyncCallback callback, object state) { /// @@ -371,7 +378,7 @@ namespace OpenSim.Framework.Communications public Stream EndRequest(IAsyncResult asyncResult) { - AsyncResult ar = (AsyncResult)asyncResult; + AsyncResult ar = (AsyncResult) asyncResult; // Wait for operation to complete, then return result or // throw exception @@ -381,7 +388,7 @@ namespace OpenSim.Framework.Communications private void RequestHelper(Object asyncResult) { // We know that it's really an AsyncResult object - AsyncResult ar = (AsyncResult)asyncResult; + AsyncResult ar = (AsyncResult) asyncResult; try { // Perform the operation; if sucessful set the result @@ -394,6 +401,7 @@ namespace OpenSim.Framework.Communications ar.HandleException(e, false); } } + #endregion Async Invocation } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 006c8ee..cdc3baf 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -33,18 +33,15 @@ using System.Reflection; using System.Security.Cryptography; using libsecondlife; using Nwc.XmlRpc; -using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Data; using OpenSim.Framework.Interfaces; - namespace OpenSim.Framework.UserManagement { public abstract class UserManagerBase : IUserService { public UserConfig _config; - Dictionary _plugins = new Dictionary(); + private Dictionary _plugins = new Dictionary(); /// /// Adds a new user server plugin - user servers will be requested in the order they were loaded. @@ -78,11 +75,12 @@ namespace OpenSim.Framework.UserManagement public void AddPlugin(IUserData plug) { plug.Initialise(); - this._plugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose( "Userstorage: Added IUserData Interface"); + _plugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose("Userstorage: Added IUserData Interface"); } #region Get UserProfile + /// /// Loads a user profile from a database by UUID /// @@ -100,7 +98,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -126,7 +124,7 @@ namespace OpenSim.Framework.UserManagement catch (Exception e) { System.Console.WriteLine("EEK!"); - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -145,7 +143,7 @@ namespace OpenSim.Framework.UserManagement { try { - UserProfileData profile = plugin.Value.GetUserByName(fname,lname); + UserProfileData profile = plugin.Value.GetUserByName(fname, lname); profile.currentAgent = getUserAgent(profile.UUID); @@ -153,7 +151,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -170,20 +168,24 @@ namespace OpenSim.Framework.UserManagement { foreach (KeyValuePair plugin in _plugins) { - try { + try + { plugin.Value.UpdateUserProfile(data); return true; - } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); + } + catch (Exception e) + { + MainLog.Instance.Verbose("Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); } } - + return false; } #endregion #region Get UserAgent + /// /// Loads a user agent by uuid (not called directly) /// @@ -199,7 +201,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -221,7 +223,7 @@ namespace OpenSim.Framework.UserManagement } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -249,11 +251,11 @@ namespace OpenSim.Framework.UserManagement { try { - return plugin.Value.GetAgentByName(fname,lname); + return plugin.Value.GetAgentByName(fname, lname); } catch (Exception e) { - MainLog.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + MainLog.Instance.Verbose("Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); } } @@ -263,6 +265,7 @@ namespace OpenSim.Framework.UserManagement #endregion #region CreateAgent + /// /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB /// @@ -270,7 +273,7 @@ namespace OpenSim.Framework.UserManagement /// The users loginrequest public void CreateAgent(UserProfileData profile, XmlRpcRequest request) { - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; UserAgentData agent = new UserAgentData(); @@ -297,7 +300,7 @@ namespace OpenSim.Framework.UserManagement // If user specified additional start, use that if (requestData.ContainsKey("start")) { - string startLoc = ((string)requestData["start"]).Trim(); + string startLoc = ((string) requestData["start"]).Trim(); if (!(startLoc == "last" || startLoc == "home")) { // Format: uri:Ahern&162&213&34 @@ -312,7 +315,6 @@ namespace OpenSim.Framework.UserManagement } catch (Exception) { - } } } @@ -323,7 +325,7 @@ namespace OpenSim.Framework.UserManagement // Current location agent.regionID = new LLUUID(); // Fill in later - agent.currentRegion = new LLUUID(); // Fill in later + agent.currentRegion = new LLUUID(); // Fill in later profile.currentAgent = agent; } @@ -364,7 +366,6 @@ namespace OpenSim.Framework.UserManagement try { plugin.Value.AddNewUserProfile(user); - } catch (Exception e) { @@ -376,4 +377,4 @@ namespace OpenSim.Framework.UserManagement public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs index efe6ebb..0d48683 100644 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs @@ -26,21 +26,18 @@ * */ -using System; -using System.Collections.Generic; -using System.Net; using System.IO; +using System.Net; using System.Text; - -using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Configuration.HTTP { public class HTTPConfiguration : IGenericConfig { - RemoteConfigSettings remoteConfigSettings; + private RemoteConfigSettings remoteConfigSettings; - XmlConfiguration xmlConfig; + private XmlConfiguration xmlConfig; private string configFileName = ""; @@ -62,8 +59,9 @@ namespace OpenSim.Framework.Configuration.HTTP StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.remoteConfigSettings.baseConfigURL + this.configFileName); - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + HttpWebRequest request = + (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName); + HttpWebResponse response = (HttpWebResponse) request.GetResponse(); Stream resStream = response.GetResponseStream(); @@ -78,13 +76,14 @@ namespace OpenSim.Framework.Configuration.HTTP tempString = Encoding.ASCII.GetString(buf, 0, count); sb.Append(tempString); } - } - while (count > 0); + } while (count > 0); LoadDataFromString(sb.ToString()); } catch (WebException) { - Console.MainLog.Instance.Warn("Unable to connect to remote configuration file (" + remoteConfigSettings.baseConfigURL + configFileName + "). Creating local file instead."); + MainLog.Instance.Warn("Unable to connect to remote configuration file (" + + remoteConfigSettings.baseConfigURL + configFileName + + "). Creating local file instead."); xmlConfig.SetFileName(configFileName); xmlConfig.LoadData(); } @@ -93,7 +92,6 @@ namespace OpenSim.Framework.Configuration.HTTP public void LoadDataFromString(string data) { xmlConfig.LoadDataFromString(data); - } public string GetAttribute(string attributeName) @@ -114,4 +112,4 @@ namespace OpenSim.Framework.Configuration.HTTP { } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs index 3ac03bb..332066c 100644 --- a/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs +++ b/OpenSim/Framework/Configuration/HTTP/RemoteConfigSettings.cs @@ -26,12 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - -using OpenSim.Framework; - namespace OpenSim.Framework.Configuration.HTTP { public class RemoteConfigSettings @@ -39,24 +33,30 @@ namespace OpenSim.Framework.Configuration.HTTP private ConfigurationMember configMember; public string baseConfigURL = ""; + public RemoteConfigSettings(string filename) { - configMember = new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, handleIncomingConfiguration); + configMember = + new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions, + handleIncomingConfiguration); configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll"); configMember.performConfigurationRetrieve(); } public void loadConfigurationOptions() { - configMember.addConfigurationOption("base_config_url", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "URL Containing Configuration Files", "http://localhost/", false); + configMember.addConfigurationOption("base_config_url", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "URL Containing Configuration Files", "http://localhost/", false); } + public bool handleIncomingConfiguration(string configuration_key, object configuration_result) { if (configuration_key == "base_config_url") { - baseConfigURL = (string)configuration_result; + baseConfigURL = (string) configuration_result; } return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs index 52db852..152dec5 100644 --- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs +++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs @@ -25,12 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.IO; using System.Xml; -using OpenSim.Framework; - namespace OpenSim.Framework.Configuration { public class XmlConfiguration : IGenericConfig @@ -56,6 +55,7 @@ namespace OpenSim.Framework.Configuration if (configNode.Name != "Config") throw new Exception("Error: Invalid .xml File. first child should be "); } + public void LoadData() { lock (this) @@ -81,7 +81,7 @@ namespace OpenSim.Framework.Configuration if (createdFile) { - this.Commit(); + Commit(); } } } @@ -93,12 +93,13 @@ namespace OpenSim.Framework.Configuration LoadDataToClass(); } + public string GetAttribute(string attributeName) { string result = null; if (configNode.Attributes[attributeName] != null) { - result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value; + result = ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value; } return result; } @@ -107,7 +108,7 @@ namespace OpenSim.Framework.Configuration { if (configNode.Attributes[attributeName] != null) { - ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; + ((XmlAttribute) configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue; } else { @@ -124,7 +125,7 @@ namespace OpenSim.Framework.Configuration if (!Directory.Exists(Util.configDir())) { Directory.CreateDirectory(Util.configDir()); - } + } doc.Save(fileName); } @@ -134,6 +135,5 @@ namespace OpenSim.Framework.Configuration rootNode = null; doc = null; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index 7e7c77a..bfad5b7 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs @@ -27,24 +27,26 @@ */ using System.Reflection; using System.Runtime.InteropServices; + // Information about this assembly is defined by the following // attributes. // // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("ServerConsole")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ServerConsole")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly : AssemblyTitle("ServerConsole")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("ServerConsole")] +[assembly : AssemblyCopyright("")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. -[assembly: ComVisible(false)] + +[assembly : ComVisible(false)] // The assembly version has following format : // @@ -53,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 e079202..8eea702 100644 --- a/OpenSim/Framework/Console/ConsoleCallbacksBase.cs +++ b/OpenSim/Framework/Console/ConsoleCallbacksBase.cs @@ -26,10 +26,10 @@ * */ namespace OpenSim.Framework.Console -{ +{ public interface conscmd_callback { 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 c976e2c..6651e5d 100644 --- a/OpenSim/Framework/Console/LogBase.cs +++ b/OpenSim/Framework/Console/LogBase.cs @@ -26,10 +26,10 @@ * */ using System; +using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Net; -using System.Diagnostics; -using System.Collections.Generic; namespace OpenSim.Framework.Console { @@ -48,7 +48,7 @@ namespace OpenSim.Framework.Console { private object m_syncRoot = new object(); - StreamWriter Log; + private StreamWriter Log; public conscmd_callback cmdparser; public string componentname; private bool m_verbose; @@ -57,7 +57,7 @@ namespace OpenSim.Framework.Console { this.componentname = componentname; this.cmdparser = cmdparser; - this.m_verbose = verbose; + m_verbose = verbose; System.Console.WriteLine("Creating new local console"); if (String.IsNullOrEmpty(LogFile)) @@ -87,8 +87,8 @@ namespace OpenSim.Framework.Console /// an ansii color private ConsoleColor DeriveColor(string input) { - int colIdx = (input.ToUpper().GetHashCode() % 6) + 9; - return (ConsoleColor)colIdx; + int colIdx = (input.ToUpper().GetHashCode()%6) + 9; + return (ConsoleColor) colIdx; } /// @@ -236,7 +236,7 @@ namespace OpenSim.Framework.Console { lock (m_syncRoot) { - string now = System.DateTime.Now.ToString("[MM-dd hh:mm:ss] "); + string now = DateTime.Now.ToString("[MM-dd hh:mm:ss] "); Log.Write(now); Log.WriteLine(format, args); Log.Flush(); @@ -306,7 +306,7 @@ namespace OpenSim.Framework.Console public int Read() { int TempInt = System.Console.Read(); - Log.Write((char)TempInt); + Log.Write((char) TempInt); return TempInt; } @@ -359,7 +359,7 @@ namespace OpenSim.Framework.Console { // FIXME: Needs to be better abstracted Log.WriteLine(prompt); - this.Notice(prompt); + Notice(prompt); ConsoleColor oldfg = System.Console.ForegroundColor; System.Console.ForegroundColor = System.Console.BackgroundColor; string temp = System.Console.ReadLine(); @@ -370,8 +370,8 @@ namespace OpenSim.Framework.Console // Displays a command prompt and waits for the user to enter a string, then returns that string public string CmdPrompt(string prompt) { - this.Notice(String.Format("{0}: ", prompt)); - return this.ReadLine(); + Notice(String.Format("{0}: ", prompt)); + return ReadLine(); } // Displays a command prompt and returns a default value if the user simply presses enter @@ -423,8 +423,7 @@ namespace OpenSim.Framework.Console public void MainLogPrompt() { - - string tempstr = this.CmdPrompt(this.componentname + "# "); + string tempstr = CmdPrompt(componentname + "# "); MainLogRunCommand(tempstr); } @@ -436,7 +435,7 @@ namespace OpenSim.Framework.Console Array.Reverse(tempstrarray); Array.Resize(ref tempstrarray, tempstrarray.Length - 1); Array.Reverse(tempstrarray); - string[] cmdparams = (string[])tempstrarray; + string[] cmdparams = (string[]) tempstrarray; try { RunCmd(cmd, cmdparams); @@ -454,7 +453,7 @@ namespace OpenSim.Framework.Console string result = String.Empty; string stacktrace = Environment.StackTrace; - List lines = new List(stacktrace.Split(new string[] { "at " }, StringSplitOptions.None)); + List lines = new List(stacktrace.Split(new string[] {"at "}, StringSplitOptions.None)); if (lines.Count > 4) { @@ -481,4 +480,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 5c1a257..adf566c 100644 --- a/OpenSim/Framework/Console/MainLog.cs +++ b/OpenSim/Framework/Console/MainLog.cs @@ -27,15 +27,14 @@ */ namespace OpenSim.Framework.Console { - public class MainLog { - + public class MainLog + { private static LogBase instance; - - public static LogBase Instance + + public static LogBase Instance { get { return instance; } 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 bc7225a..a96d9bd 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs @@ -34,18 +34,19 @@ namespace OpenSim.Framework.Data.DB4o /// /// A grid server storage mechanism employing the DB4o database system /// - class DB4oGridData : IGridData + internal class DB4oGridData : IGridData { /// /// The database manager object /// - DB4oGridManager manager; + private DB4oGridManager manager; /// /// Called when the plugin is first loaded (as constructors are not called) /// - public void Initialise() { - manager = new DB4oGridManager("gridserver.yap"); + public void Initialise() + { + manager = new DB4oGridManager("gridserver.yap"); } /// @@ -93,7 +94,8 @@ namespace OpenSim.Framework.Data.DB4o if (manager.simProfiles.ContainsKey(uuid)) return manager.simProfiles[uuid]; } - throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count); + throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + + "). Total Registered Regions: " + manager.simProfiles.Count); } /// @@ -123,7 +125,8 @@ namespace OpenSim.Framework.Data.DB4o /// The location the region is logging into (unused in Db4o) /// The shared secret /// Authenticated? - public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { + public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) + { if (manager.simProfiles[uuid].regionRecvKey == key) return true; return false; @@ -160,4 +163,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 9e8a03f..033413a 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oManager.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs @@ -29,23 +29,23 @@ using System; using System.Collections.Generic; using Db4objects.Db4o; using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework.Data.DB4o { /// /// A Database manager for Db4o /// - class DB4oGridManager + internal class DB4oGridManager { /// /// A list of the current regions connected (in-memory cache) /// public Dictionary simProfiles = new Dictionary(); + /// /// Database File Name /// - string dbfl; + private string dbfl; /// /// Creates a new grid storage manager @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Data.DB4o dbfl = db4odb; IObjectContainer database; database = Db4oFactory.OpenFile(dbfl); - IObjectSet result = database.Get(typeof(RegionProfileData)); + IObjectSet result = database.Get(typeof (RegionProfileData)); // Loads the file into the in-memory cache foreach (RegionProfileData row in result) { @@ -94,23 +94,22 @@ namespace OpenSim.Framework.Data.DB4o return false; } } - - } /// /// A manager for the DB4o database (user profiles) /// - class DB4oUserManager + internal class DB4oUserManager { /// /// A list of the user profiles (in memory cache) /// public Dictionary userProfiles = new Dictionary(); + /// /// Database filename /// - string dbfl; + private string dbfl; /// /// Initialises a new DB manager @@ -122,7 +121,7 @@ namespace OpenSim.Framework.Data.DB4o IObjectContainer database; database = Db4oFactory.OpenFile(dbfl); // Load to cache - IObjectSet result = database.Get(typeof(UserProfileData)); + IObjectSet result = database.Get(typeof (UserProfileData)); foreach (UserProfileData row in result) { if (userProfiles.ContainsKey(row.UUID)) @@ -144,7 +143,7 @@ namespace OpenSim.Framework.Data.DB4o /// The profile to update /// true on success, false on fail to persist to db public bool UpdateRecord(UserProfileData record) - { + { if (userProfiles.ContainsKey(record.UUID)) { userProfiles[record.UUID] = record; @@ -168,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 b00fd02..c7113bf 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs @@ -28,8 +28,6 @@ using System; using System.IO; using libsecondlife; -using OpenSim.Framework; -using OpenSim.Framework; namespace OpenSim.Framework.Data.DB4o { @@ -41,14 +39,14 @@ namespace OpenSim.Framework.Data.DB4o /// /// The database manager /// - DB4oUserManager manager; + private DB4oUserManager manager; /// /// Artificial constructor called upon plugin load /// public void Initialise() { - manager = new DB4oUserManager(Path.Combine(Util.dataDir(),"userprofiles.yap")); + manager = new DB4oUserManager(Path.Combine(Util.dataDir(), "userprofiles.yap")); } /// @@ -58,7 +56,7 @@ namespace OpenSim.Framework.Data.DB4o /// A user profile public UserProfileData GetUserByUUID(LLUUID uuid) { - if(manager.userProfiles.ContainsKey(uuid)) + if (manager.userProfiles.ContainsKey(uuid)) return manager.userProfiles[uuid]; return null; } @@ -95,7 +93,7 @@ namespace OpenSim.Framework.Data.DB4o /// The users account ID /// A matching users profile public UserAgentData GetAgentByUUID(LLUUID uuid) - { + { try { return GetUserByUUID(uuid).currentAgent; @@ -126,7 +124,7 @@ namespace OpenSim.Framework.Data.DB4o { try { - return GetUserByName(fname,lname).currentAgent; + return GetUserByName(fname, lname).currentAgent; } catch (Exception) { @@ -149,7 +147,7 @@ namespace OpenSim.Framework.Data.DB4o Console.WriteLine(e.ToString()); } } - + /// /// Creates a new user profile /// @@ -157,15 +155,17 @@ namespace OpenSim.Framework.Data.DB4o /// True on success, false on error public bool UpdateUserProfile(UserProfileData user) { - try { + try + { return manager.UpdateRecord(user); - } catch (Exception e) { + } + catch (Exception e) + { Console.WriteLine(e.ToString()); return false; } } - /// /// Creates a new user agent @@ -219,4 +219,4 @@ namespace OpenSim.Framework.Data.DB4o return "0.1"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs index 52d09fa..6183b6e 100644 --- a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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.Framework.Data.DB4o")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Framework.Data.DB4o")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Framework.Data.DB4o")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Framework.Data.DB4o")] +[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("57991e15-79da-41b7-aa06-2e6b49165a63")] + +[assembly : Guid("57991e15-79da-41b7-aa06-2e6b49165a63")] // Version information for an assembly consists of the following four values: // @@ -29,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Framework/Data.MSSQL/MSSQLGridData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs index e628882..1946790 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLGridData.cs @@ -185,10 +185,10 @@ namespace OpenSim.Framework.Data.MSSQL byte[] hash = HashProvider.ComputeHash(stream); return false; } + public ReservationData GetReservationAtPoint(uint x, uint y) { return null; } } - -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs index 77d29f7..c0b2edf 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLManager.cs @@ -36,12 +36,12 @@ namespace OpenSim.Framework.Data.MSSQL /// /// A management class for the MS SQL Storage Engine /// - class MSSqlManager + internal class MSSqlManager { /// /// The database connection object /// - IDbConnection dbcon; + private IDbConnection dbcon; /// /// Initialises and creates a new Sql connection and maintains it. @@ -55,7 +55,8 @@ namespace OpenSim.Framework.Data.MSSQL { try { - string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; + string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + + ";Password=" + password + ";Pooling=" + cpooling + ";"; dbcon = new SqlConnection(connectionString); dbcon.Open(); @@ -83,14 +84,14 @@ namespace OpenSim.Framework.Data.MSSQL /// A Sql DB Command public IDbCommand Query(string sql, Dictionary parameters) { - SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand(); + SqlCommand dbcommand = (SqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - return (IDbCommand)dbcommand; + return (IDbCommand) dbcommand; } /// @@ -105,42 +106,42 @@ namespace OpenSim.Framework.Data.MSSQL if (reader.Read()) { // Region Main - regionprofile.regionHandle = (ulong)reader["regionHandle"]; - regionprofile.regionName = (string)reader["regionName"]; - regionprofile.UUID = new LLUUID((string)reader["uuid"]); + regionprofile.regionHandle = (ulong) reader["regionHandle"]; + 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.serverPort = (uint)reader["serverPort"]; - regionprofile.serverURI = (string)reader["serverURI"]; + regionprofile.serverIP = (string) reader["serverIP"]; + regionprofile.serverPort = (uint) reader["serverPort"]; + regionprofile.serverURI = (string) reader["serverURI"]; // Location - regionprofile.regionLocX = (uint)((int)reader["locX"]); - regionprofile.regionLocY = (uint)((int)reader["locY"]); - regionprofile.regionLocZ = (uint)((int)reader["locZ"]); + regionprofile.regionLocX = (uint) ((int) reader["locX"]); + regionprofile.regionLocY = (uint) ((int) reader["locY"]); + regionprofile.regionLocZ = (uint) ((int) reader["locZ"]); // Neighbours - 0 = No Override - regionprofile.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; - regionprofile.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; - regionprofile.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; - regionprofile.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; + regionprofile.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"]; + regionprofile.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"]; + regionprofile.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"]; + regionprofile.regionNorthOverrideHandle = (ulong) 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"]; } else { @@ -156,12 +157,15 @@ namespace OpenSim.Framework.Data.MSSQL /// Successful? public bool insertRow(RegionProfileData profile) { - string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; - sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; + string sql = + "REPLACE INTO regions VALUES (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) VALUES "; sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; - sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; + sql += + "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; Dictionary parameters = new Dictionary(); @@ -208,4 +212,4 @@ namespace OpenSim.Framework.Data.MSSQL return returnval; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs index eeac06c..6846ecf 100644 --- a/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.MSSQL/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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.Framework.Data.MSSQL")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Framework.Data.MSSQL")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Framework.Data.MSSQL")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Framework.Data.MSSQL")] +[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("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")] + +[assembly : Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")] // Version information for an assembly consists of the following four values: // @@ -29,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs index bf895c0..055cd92 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs @@ -28,18 +28,17 @@ using System; using System.Collections.Generic; -using MySql.Data.MySqlClient; - +using System.Data; using libsecondlife; +using MySql.Data.MySqlClient; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework.Data.MySQL { - class MySQLAssetData : IAssetProvider + internal class MySQLAssetData : IAssetProvider { - MySQLManager _dbConnection; + private MySQLManager _dbConnection; + #region IAssetProvider Members private void UpgradeAssetsTable(string oldVersion) @@ -58,14 +57,12 @@ namespace OpenSim.Framework.Data.MySQL /// private void TestTables() { - Dictionary tableList = new Dictionary(); tableList["assets"] = null; _dbConnection.GetTableVersion(tableList); UpgradeAssetsTable(tableList["assets"]); - } public AssetBase FetchAsset(LLUUID assetID) @@ -73,21 +70,24 @@ namespace OpenSim.Framework.Data.MySQL AssetBase asset = null; lock (_dbConnection) { - MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); + MySqlCommand cmd = + new MySqlCommand( + "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", + _dbConnection.Connection); MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); p.Value = assetID.GetBytes(); - using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow)) + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { 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"]; } } } @@ -96,8 +96,11 @@ namespace OpenSim.Framework.Data.MySQL public void CreateAsset(AssetBase asset) { - MySqlCommand cmd = new MySqlCommand("REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", _dbConnection.Connection); + MySqlCommand cmd = + new MySqlCommand( + "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)", + _dbConnection.Connection); MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); p.Value = asset.FullID.GetBytes(); cmd.Parameters.AddWithValue("?name", asset.Name); @@ -148,7 +151,7 @@ namespace OpenSim.Framework.Data.MySQL public string Version { - get { return _dbConnection.getVersion(); } + get { return _dbConnection.getVersion(); } } public string Name @@ -158,4 +161,4 @@ namespace OpenSim.Framework.Data.MySQL #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs index 9876ab1..fdfc61c 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLGridData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLGridData.cs @@ -25,13 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.Collections.Generic; using System.Data; using System.Security.Cryptography; using System.Text; using libsecondlife; - using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.MySQL @@ -59,7 +59,9 @@ namespace OpenSim.Framework.Data.MySQL string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); } /// @@ -108,7 +110,10 @@ namespace OpenSim.Framework.Data.MySQL param["?xmax"] = xmax.ToString(); param["?ymax"] = ymax.ToString(); - IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param); + IDbCommand result = + database.Query( + "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", + param); IDataReader reader = result.ExecuteReader(); RegionProfileData row; @@ -123,7 +128,6 @@ namespace OpenSim.Framework.Data.MySQL result.Dispose(); return rows.ToArray(); - } } catch (Exception e) @@ -266,7 +270,10 @@ namespace OpenSim.Framework.Data.MySQL Dictionary param = new Dictionary(); param["?x"] = x.ToString(); param["?y"] = y.ToString(); - IDbCommand result = database.Query("SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", param); + IDbCommand result = + database.Query( + "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", + param); IDataReader reader = result.ExecuteReader(); ReservationData row = database.readReservationRow(reader); @@ -284,6 +291,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 ded584e..f303a6b 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs @@ -26,13 +26,10 @@ * */ using System; -using System.IO; -using System.Data; using System.Collections.Generic; using libsecondlife; -using OpenSim.Framework; -using OpenSim.Framework.Console; using MySql.Data.MySqlClient; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.MySQL { @@ -59,7 +56,9 @@ namespace OpenSim.Framework.Data.MySQL string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); TestTables(database.Connection); } @@ -99,7 +98,6 @@ namespace OpenSim.Framework.Data.MySQL private void TestTables(MySqlConnection conn) { - Dictionary tableList = new Dictionary(); tableList["inventoryfolders"] = null; @@ -110,6 +108,7 @@ namespace OpenSim.Framework.Data.MySQL UpgradeFoldersTable(tableList["inventoryfolders"]); UpgradeItemsTable(tableList["inventoryitems"]); } + #endregion /// @@ -151,11 +150,13 @@ namespace OpenSim.Framework.Data.MySQL { List items = new List(); - MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", database.Connection); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", + database.Connection); result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); MySqlDataReader reader = result.ExecuteReader(); - while(reader.Read()) + while (reader.Read()) items.Add(readInventoryItem(reader)); reader.Close(); @@ -183,13 +184,16 @@ namespace OpenSim.Framework.Data.MySQL { lock (database) { - MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); MySqlDataReader reader = result.ExecuteReader(); List items = new List(); - while(reader.Read()) + while (reader.Read()) items.Add(readInventoryFolder(reader)); @@ -218,17 +222,21 @@ namespace OpenSim.Framework.Data.MySQL { lock (database) { - MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", database.Connection); + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); result.Parameters.AddWithValue("?uuid", user.ToStringHyphenated()); result.Parameters.AddWithValue("?zero", LLUUID.Zero.ToStringHyphenated()); MySqlDataReader reader = result.ExecuteReader(); List items = new List(); - while(reader.Read()) + while (reader.Read()) items.Add(readInventoryFolder(reader)); - InventoryFolderBase rootFolder = items[0]; //should only be one folder with parent set to zero (the root one). + InventoryFolderBase rootFolder = items[0]; + //should only be one folder with parent set to zero (the root one). reader.Close(); result.Dispose(); @@ -254,13 +262,15 @@ namespace OpenSim.Framework.Data.MySQL { lock (database) { - MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", database.Connection); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", + database.Connection); result.Parameters.AddWithValue("?uuid", parentID.ToStringHyphenated()); MySqlDataReader reader = result.ExecuteReader(); List items = new List(); - - while(reader.Read()) + + while (reader.Read()) items.Add(readInventoryFolder(reader)); reader.Close(); @@ -288,19 +298,19 @@ namespace OpenSim.Framework.Data.MySQL { 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.inventoryNextPermissions = (uint)reader["inventoryNextPermissions"]; - item.inventoryCurrentPermissions = (uint)reader["inventoryCurrentPermissions"]; - item.invType = (int)reader["invType"]; - item.creatorsID = new LLUUID((string)reader["creatorID"]); - item.inventoryBasePermissions = (uint)reader["inventoryBasePermissions"]; - item.inventoryEveryOnePermissions = (uint)reader["inventoryEveryOnePermissions"]; + 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 = (uint) reader["inventoryNextPermissions"]; + item.inventoryCurrentPermissions = (uint) reader["inventoryCurrentPermissions"]; + item.invType = (int) reader["invType"]; + item.creatorsID = new LLUUID((string) reader["creatorID"]); + item.inventoryBasePermissions = (uint) reader["inventoryBasePermissions"]; + item.inventoryEveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"]; return item; } catch (MySqlException e) @@ -324,12 +334,13 @@ namespace OpenSim.Framework.Data.MySQL { Dictionary param = new Dictionary(); - MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); result.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); MySqlDataReader reader = result.ExecuteReader(); InventoryItemBase item = null; - if(reader.Read()) + if (reader.Read()) item = readInventoryItem(reader); reader.Close(); @@ -356,12 +367,12 @@ namespace OpenSim.Framework.Data.MySQL 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) @@ -384,7 +395,8 @@ namespace OpenSim.Framework.Data.MySQL { lock (database) { - MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); result.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); MySqlDataReader reader = result.ExecuteReader(); @@ -410,8 +422,10 @@ namespace OpenSim.Framework.Data.MySQL /// The inventory item public void addInventoryItem(InventoryItemBase item) { - string sql = "REPLACE INTO inventoryitems (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)"; + string sql = + "REPLACE INTO inventoryitems (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 { @@ -424,7 +438,8 @@ namespace OpenSim.Framework.Data.MySQL result.Parameters.AddWithValue("?inventoryName", item.inventoryName); result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription); result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString()); - result.Parameters.AddWithValue("?inventoryCurrentPermissions", item.inventoryCurrentPermissions.ToString()); + result.Parameters.AddWithValue("?inventoryCurrentPermissions", + item.inventoryCurrentPermissions.ToString()); result.Parameters.AddWithValue("?invType", item.invType); result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToStringHyphenated()); result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions); @@ -455,7 +470,8 @@ namespace OpenSim.Framework.Data.MySQL { try { - MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryitems WHERE inventoryID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", itemID.ToStringHyphenated()); cmd.ExecuteNonQuery(); } @@ -472,7 +488,8 @@ namespace OpenSim.Framework.Data.MySQL /// Folder to create public void addInventoryFolder(InventoryFolderBase folder) { - string sql = "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; + string sql = + "REPLACE INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES "; sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version)"; MySqlCommand cmd = new MySqlCommand(sql, database.Connection); @@ -480,9 +497,9 @@ namespace OpenSim.Framework.Data.MySQL cmd.Parameters.AddWithValue("?agentID", folder.agentID.ToStringHyphenated()); cmd.Parameters.AddWithValue("?parentFolderID", folder.parentID.ToStringHyphenated()); cmd.Parameters.AddWithValue("?folderName", folder.name); - cmd.Parameters.AddWithValue("?type", (short)folder.type); + cmd.Parameters.AddWithValue("?type", (short) folder.type); cmd.Parameters.AddWithValue("?version", folder.version); - + try { cmd.ExecuteNonQuery(); @@ -515,7 +532,7 @@ namespace OpenSim.Framework.Data.MySQL foreach (InventoryFolderBase f in subfolderList) folders.Add(f); } - + /// /// Returns all child folders in the hierarchy from the parent folder and down /// @@ -536,7 +553,8 @@ namespace OpenSim.Framework.Data.MySQL { try { - MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); cmd.ExecuteNonQuery(); } @@ -551,7 +569,8 @@ namespace OpenSim.Framework.Data.MySQL { try { - MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); cmd.Parameters.AddWithValue("?uuid", folderID.ToStringHyphenated()); cmd.ExecuteNonQuery(); } @@ -586,4 +605,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 bfb4b48..e8775a1 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLLogData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLLogData.cs @@ -25,14 +25,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; - namespace OpenSim.Framework.Data.MySQL { /// /// An interface to the log database for MySQL /// - class MySQLLogData : ILogData + internal class MySQLLogData : ILogData { /// /// The database manager @@ -52,7 +50,9 @@ namespace OpenSim.Framework.Data.MySQL string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); } /// @@ -64,7 +64,8 @@ namespace OpenSim.Framework.Data.MySQL /// The arguments passed to the method /// How critical is this? /// The message to log - 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 { @@ -102,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 8fcf68b..778da06 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs @@ -25,16 +25,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; -using System.IO; +using System.Collections.Generic; using System.Data; +using System.IO; using System.Reflection; -using System.Collections.Generic; using libsecondlife; - using MySql.Data.MySqlClient; - -using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.MySQL @@ -42,16 +40,17 @@ namespace OpenSim.Framework.Data.MySQL /// /// A MySQL Database manager /// - class MySQLManager + internal class MySQLManager { /// /// The database connection object /// - MySqlConnection dbcon; + private MySqlConnection dbcon; + /// /// Connection string for ADO.net /// - string connectionString; + private string connectionString; /// /// Initialises and creates a new MySQL connection and maintains it. @@ -61,11 +60,13 @@ namespace OpenSim.Framework.Data.MySQL /// The username logging into the database /// The password for the user logging in /// Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'. - public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) + public MySQLManager(string hostname, string database, string username, string password, string cpooling, + string port) { try { - connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; + connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; dbcon = new MySqlConnection(connectionString); dbcon.Open(); @@ -123,15 +124,17 @@ namespace OpenSim.Framework.Data.MySQL /// A string containing the DB provider 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); } - + /// /// Extract a named string resource from the embedded resources /// @@ -139,7 +142,7 @@ namespace OpenSim.Framework.Data.MySQL /// string contained within the embedded resource private string getResourceString(string name) { - Assembly assem = this.GetType().Assembly; + Assembly assem = GetType().Assembly; string[] names = assem.GetManifestResourceNames(); foreach (string s in names) @@ -173,7 +176,10 @@ namespace OpenSim.Framework.Data.MySQL { lock (dbcon) { - MySqlCommand tablesCmd = new MySqlCommand("SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", dbcon); + MySqlCommand tablesCmd = + new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", + dbcon); tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); using (MySqlDataReader tables = tablesCmd.ExecuteReader()) { @@ -181,9 +187,9 @@ namespace OpenSim.Framework.Data.MySQL { try { - string tableName = (string)tables["TABLE_NAME"]; - string comment = (string)tables["TABLE_COMMENT"]; - if(tableList.ContainsKey(tableName)) + string tableName = (string) tables["TABLE_NAME"]; + string comment = (string) tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) tableList[tableName] = comment; } catch (Exception e) @@ -198,7 +204,7 @@ namespace OpenSim.Framework.Data.MySQL // at some time this code should be cleaned up - + /// /// Runs a query with protection against SQL Injection by using parameterised input. /// @@ -209,14 +215,14 @@ namespace OpenSim.Framework.Data.MySQL { try { - MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); + MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - return (IDbCommand)dbcommand; + return (IDbCommand) dbcommand; } catch { @@ -227,7 +233,9 @@ namespace OpenSim.Framework.Data.MySQL { dbcon.Close(); } - catch { } + catch + { + } // Try reopen it try @@ -243,14 +251,14 @@ namespace OpenSim.Framework.Data.MySQL // Run the query again try { - MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); + MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - return (IDbCommand)dbcommand; + return (IDbCommand) dbcommand; } catch (Exception e) { @@ -275,20 +283,20 @@ namespace OpenSim.Framework.Data.MySQL { // Region Main retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); - retval.regionName = (string)reader["regionName"]; - retval.UUID = new LLUUID((string)reader["uuid"]); + retval.regionName = (string) reader["regionName"]; + retval.UUID = new LLUUID((string) reader["uuid"]); // Secrets - retval.regionRecvKey = (string)reader["regionRecvKey"]; - retval.regionSecret = (string)reader["regionSecret"]; - retval.regionSendKey = (string)reader["regionSendKey"]; + retval.regionRecvKey = (string) reader["regionRecvKey"]; + retval.regionSecret = (string) reader["regionSecret"]; + retval.regionSendKey = (string) reader["regionSendKey"]; // Region Server - retval.regionDataURI = (string)reader["regionDataURI"]; + retval.regionDataURI = (string) reader["regionDataURI"]; retval.regionOnline = false; // Needs to be pinged before this can be set. - retval.serverIP = (string)reader["serverIP"]; - retval.serverPort = (uint)reader["serverPort"]; - retval.serverURI = (string)reader["serverURI"]; + retval.serverIP = (string) reader["serverIP"]; + retval.serverPort = (uint) reader["serverPort"]; + retval.serverURI = (string) reader["serverURI"]; retval.httpPort = Convert.ToUInt32(reader["serverHttpPort"].ToString()); retval.remotingPort = Convert.ToUInt32(reader["serverRemotingPort"].ToString()); @@ -304,14 +312,14 @@ namespace OpenSim.Framework.Data.MySQL retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); // Assets - retval.regionAssetURI = (string)reader["regionAssetURI"]; - retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; - retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; + retval.regionAssetURI = (string) reader["regionAssetURI"]; + retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; + retval.regionAssetSendKey = (string) reader["regionAssetSendKey"]; // Userserver - retval.regionUserURI = (string)reader["regionUserURI"]; - retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; - retval.regionUserSendKey = (string)reader["regionUserSendKey"]; + retval.regionUserURI = (string) reader["regionUserURI"]; + retval.regionUserRecvKey = (string) reader["regionUserRecvKey"]; + retval.regionUserSendKey = (string) reader["regionUserSendKey"]; // World Map Addition string tempRegionMap = reader["regionMapTexture"].ToString(); @@ -341,17 +349,16 @@ namespace OpenSim.Framework.Data.MySQL ReservationData retval = new ReservationData(); if (reader.Read()) { - retval.gridRecvKey = (string)reader["gridRecvKey"]; - retval.gridSendKey = (string)reader["gridSendKey"]; - retval.reservationCompany = (string)reader["resCompany"]; + retval.gridRecvKey = (string) reader["gridRecvKey"]; + retval.gridSendKey = (string) reader["gridSendKey"]; + retval.reservationCompany = (string) reader["resCompany"]; retval.reservationMaxX = Convert.ToInt32(reader["resXMax"].ToString()); retval.reservationMaxY = Convert.ToInt32(reader["resYMax"].ToString()); retval.reservationMinX = Convert.ToInt32(reader["resXMin"].ToString()); retval.reservationMinY = Convert.ToInt32(reader["resYMin"].ToString()); - retval.reservationName = (string)reader["resName"]; + retval.reservationName = (string) reader["resName"]; retval.status = Convert.ToInt32(reader["status"].ToString()) == 1; - retval.userUUID = new LLUUID((string)reader["userUUID"]); - + retval.userUUID = new LLUUID((string) reader["userUUID"]); } else { @@ -359,6 +366,7 @@ namespace OpenSim.Framework.Data.MySQL } return retval; } + /// /// Reads an agent row from a database reader /// @@ -371,12 +379,12 @@ namespace OpenSim.Framework.Data.MySQL 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()); @@ -385,9 +393,9 @@ namespace OpenSim.Framework.Data.MySQL 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 { @@ -407,12 +415,12 @@ namespace OpenSim.Framework.Data.MySQL 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( @@ -427,18 +435,17 @@ namespace OpenSim.Framework.Data.MySQL 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 { @@ -448,7 +455,6 @@ namespace OpenSim.Framework.Data.MySQL } - /// /// Inserts a new row into the log database /// @@ -459,7 +465,8 @@ namespace OpenSim.Framework.Data.MySQL /// How critical is this? /// Extra message info /// Saved successfully? - 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)"; @@ -493,89 +500,97 @@ namespace OpenSim.Framework.Data.MySQL } - /// - /// Creates a new user and inserts it into the database - /// - /// User ID - /// First part of the login - /// Second part of the login - /// A salted hash of the users password - /// The salt used for the password hash - /// A regionHandle of the users home region - /// Home region position vector - /// Home region position vector - /// Home region position vector - /// Home region 'look at' vector - /// Home region 'look at' vector - /// Home region 'look at' vector - /// Account created (unix timestamp) - /// Last login (unix timestamp) - /// Users inventory URI - /// Users asset URI - /// I can do mask - /// I want to do mask - /// Profile text - /// Firstlife text - /// UUID for profile image - /// UUID for firstlife image - /// Success? - 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) - { - string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; - 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 += "?profileFirstText, ?profileImage, ?profileFirstImage)"; - - Dictionary parameters = new Dictionary(); - parameters["?UUID"] = uuid.ToStringHyphenated(); - parameters["?username"] = username.ToString(); - parameters["?lastname"] = lastname.ToString(); - parameters["?passwordHash"] = passwordHash.ToString(); - parameters["?passwordSalt"] = passwordSalt.ToString(); - parameters["?homeRegion"] = homeRegion.ToString(); - parameters["?homeLocationX"] = homeLocX.ToString(); - parameters["?homeLocationY"] = homeLocY.ToString(); - parameters["?homeLocationZ"] = homeLocZ.ToString(); - parameters["?homeLookAtX"] = homeLookAtX.ToString(); - parameters["?homeLookAtY"] = homeLookAtY.ToString(); - parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); - parameters["?created"] = created.ToString(); - parameters["?lastLogin"] = lastlogin.ToString(); - parameters["?userInventoryURI"] = ""; - parameters["?userAssetURI"] = ""; - parameters["?profileCanDoMask"] = "0"; - parameters["?profileWantDoMask"] = "0"; - parameters["?profileAboutText"] = ""; - parameters["?profileFirstText"] = ""; - parameters["?profileImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); - parameters["?profileFirstImage"] = libsecondlife.LLUUID.Zero.ToStringHyphenated(); - - bool returnval = false; - - try - { - IDbCommand result = Query(sql, parameters); - - if (result.ExecuteNonQuery() == 1) - returnval = true; - - result.Dispose(); - } - catch (Exception e) - { - MainLog.Instance.Error(e.ToString()); - return false; - } - - return returnval; - } + /// + /// Creates a new user and inserts it into the database + /// + /// User ID + /// First part of the login + /// Second part of the login + /// A salted hash of the users password + /// The salt used for the password hash + /// A regionHandle of the users home region + /// Home region position vector + /// Home region position vector + /// Home region position vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Account created (unix timestamp) + /// Last login (unix timestamp) + /// Users inventory URI + /// Users asset URI + /// I can do mask + /// I want to do mask + /// Profile text + /// Firstlife text + /// UUID for profile image + /// UUID for firstlife image + /// Success? + 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 (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; + 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 += "?profileFirstText, ?profileImage, ?profileFirstImage)"; + + Dictionary parameters = new Dictionary(); + parameters["?UUID"] = uuid.ToStringHyphenated(); + parameters["?username"] = username.ToString(); + parameters["?lastname"] = lastname.ToString(); + parameters["?passwordHash"] = passwordHash.ToString(); + parameters["?passwordSalt"] = passwordSalt.ToString(); + parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeLocationX"] = homeLocX.ToString(); + parameters["?homeLocationY"] = homeLocY.ToString(); + parameters["?homeLocationZ"] = homeLocZ.ToString(); + parameters["?homeLookAtX"] = homeLookAtX.ToString(); + parameters["?homeLookAtY"] = homeLookAtY.ToString(); + parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); + parameters["?created"] = created.ToString(); + parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?userInventoryURI"] = ""; + parameters["?userAssetURI"] = ""; + parameters["?profileCanDoMask"] = "0"; + parameters["?profileWantDoMask"] = "0"; + parameters["?profileAboutText"] = ""; + parameters["?profileFirstText"] = ""; + parameters["?profileImage"] = LLUUID.Zero.ToStringHyphenated(); + parameters["?profileFirstImage"] = LLUUID.Zero.ToStringHyphenated(); + + bool returnval = false; + + try + { + IDbCommand result = Query(sql, parameters); + + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } + catch (Exception e) + { + MainLog.Instance.Error(e.ToString()); + return false; + } + + return returnval; + } /// @@ -585,13 +600,18 @@ namespace OpenSim.Framework.Data.MySQL /// Success? public bool insertRegion(RegionProfileData regiondata) { - string sql = "REPLACE 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 = + "REPLACE 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 parameters = new Dictionary(); @@ -626,7 +646,6 @@ namespace OpenSim.Framework.Data.MySQL try { - IDbCommand result = Query(sql, parameters); //Console.WriteLine(result.CommandText); @@ -646,4 +665,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 27c9cf6..8846650 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Data; using libsecondlife; -using OpenSim.Framework; using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.MySQL @@ -37,7 +36,7 @@ namespace OpenSim.Framework.Data.MySQL /// /// A database interface class to a user profile storage system /// - class MySQLUserData : IUserData + internal class MySQLUserData : IUserData { /// /// Database manager for MySQL @@ -59,7 +58,9 @@ namespace OpenSim.Framework.Data.MySQL string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); - database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); + database = + new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, + settingPort); } /// @@ -88,11 +89,12 @@ namespace OpenSim.Framework.Data.MySQL 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(); @@ -201,21 +203,25 @@ namespace OpenSim.Framework.Data.MySQL /// The user profile to create 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()); + } } /// @@ -226,8 +232,8 @@ namespace OpenSim.Framework.Data.MySQL { // Do nothing. } - - + + public bool UpdateUserProfile(UserProfileData user) { return true; @@ -277,4 +283,4 @@ namespace OpenSim.Framework.Data.MySQL return "0.1"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs index 46c0ae0..7024bfa 100644 --- a/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.MySQL/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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.Framework.Data.MySQL")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Framework.Data.MySQL")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Framework.Data.MySQL")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Framework.Data.MySQL")] +[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("e49826b2-dcef-41be-a5bd-596733fa3304")] + +[assembly : Guid("e49826b2-dcef-41be-a5bd-596733fa3304")] // Version information for an assembly consists of the following four values: // @@ -29,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Framework/Data.SQLite/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs index 75bb53d..6693c98 100644 --- a/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.SQLite/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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.Framework.Data.SQLite")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Framework.Data.SQLite")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Framework.Data.SQLite")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Framework.Data.SQLite")] +[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("6113d5ce-4547-49f4-9236-0dcc503457b1")] + +[assembly : Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")] // Version information for an assembly consists of the following four values: // @@ -29,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.4.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly : AssemblyVersion("0.4.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs index a85ab4d..4187078 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs @@ -26,15 +26,11 @@ * */ using System; -using System.IO; -using libsecondlife; -using OpenSim.Framework; using System.Data; -using System.Data.SqlTypes; +using System.Reflection; +using libsecondlife; using Mono.Data.SqliteClient; using OpenSim.Framework.Console; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; namespace OpenSim.Framework.Data.SQLite { @@ -46,11 +42,11 @@ namespace OpenSim.Framework.Data.SQLite /// /// The database manager /// - /// /// Artificial constructor called upon plugin load /// private const string assetSelect = "select * from assets"; + private DataSet ds; private SqliteDataAdapter da; @@ -58,13 +54,14 @@ namespace OpenSim.Framework.Data.SQLite { SqliteConnection conn = new SqliteConnection("URI=file:" + dbfile + ",version=3"); TestTables(conn); - + ds = new DataSet(); da = new SqliteDataAdapter(new SqliteCommand(assetSelect, conn)); - lock (ds) { + lock (ds) + { ds.Tables.Add(createAssetsTable()); - + setupAssetCommands(da, conn); try { @@ -75,11 +72,11 @@ namespace OpenSim.Framework.Data.SQLite MainLog.Instance.Verbose("AssetStorage", "Caught fill error on asset table"); } } - + return; } - public AssetBase FetchAsset(LLUUID uuid) + public AssetBase FetchAsset(LLUUID uuid) { AssetBase asset = new AssetBase(); DataRow row = ds.Tables["assets"].Rows.Find(uuid); @@ -92,27 +89,28 @@ namespace OpenSim.Framework.Data.SQLite return null; } } - - public void CreateAsset(AssetBase asset) + + public void CreateAsset(AssetBase asset) { // no difference for now UpdateAsset(asset); } - - public void UpdateAsset(AssetBase asset) + + public void UpdateAsset(AssetBase asset) { LogAssetLoad(asset); DataTable assets = ds.Tables["assets"]; - lock(ds) { + lock (ds) + { DataRow row = assets.Rows.Find(asset.FullID); - if (row == null) + if (row == null) { row = assets.NewRow(); fillAssetRow(row, asset); assets.Rows.Add(row); } - else + else { fillAssetRow(row, asset); } @@ -124,9 +122,10 @@ namespace OpenSim.Framework.Data.SQLite string temporary = asset.Temporary ? "Temporary" : "Stored"; string local = asset.Local ? "Local" : "Remote"; - MainLog.Instance.Verbose("ASSETSTORAGE", - string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)", - asset.FullID, asset.Name, asset.Description, asset.Type, asset.InvType, temporary, local, asset.Data.Length) ); + MainLog.Instance.Verbose("ASSETSTORAGE", + string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)", + asset.FullID, asset.Name, asset.Description, asset.Type, + asset.InvType, temporary, local, asset.Data.Length)); } public bool ExistsAsset(LLUUID uuid) @@ -137,23 +136,26 @@ namespace OpenSim.Framework.Data.SQLite public void DeleteAsset(LLUUID uuid) { - lock (ds) { + lock (ds) + { DataRow row = ds.Tables["assets"].Rows.Find(uuid); - if (row != null) { + if (row != null) + { row.Delete(); } } } - + public void CommitAssets() // force a sync to the database { MainLog.Instance.Verbose("AssetStorage", "Attempting commit"); - lock (ds) { + lock (ds) + { da.Update(ds, "assets"); ds.AcceptChanges(); } } - + /*********************************************************************** * * Database Definition Functions @@ -161,24 +163,24 @@ namespace OpenSim.Framework.Data.SQLite * This should be db agnostic as we define them in ADO.NET terms * **********************************************************************/ - + private DataTable createAssetsTable() { DataTable assets = new DataTable("assets"); - createCol(assets, "UUID", typeof(System.String)); - createCol(assets, "Name", typeof(System.String)); - createCol(assets, "Description", typeof(System.String)); - createCol(assets, "Type", typeof(System.Int32)); - createCol(assets, "InvType", typeof(System.Int32)); - createCol(assets, "Local", typeof(System.Boolean)); - createCol(assets, "Temporary", typeof(System.Boolean)); - createCol(assets, "Data", typeof(System.Byte[])); + createCol(assets, "UUID", typeof (String)); + createCol(assets, "Name", typeof (String)); + createCol(assets, "Description", typeof (String)); + createCol(assets, "Type", typeof (Int32)); + createCol(assets, "InvType", typeof (Int32)); + createCol(assets, "Local", typeof (Boolean)); + createCol(assets, "Temporary", typeof (Boolean)); + createCol(assets, "Data", typeof (Byte[])); // Add in contraints - assets.PrimaryKey = new DataColumn[] { assets.Columns["UUID"] }; + assets.PrimaryKey = new DataColumn[] {assets.Columns["UUID"]}; return assets; } - + /*********************************************************************** * * Convert between ADO.NET <=> OpenSim Objects @@ -193,19 +195,19 @@ namespace OpenSim.Framework.Data.SQLite // interesting has to be done to actually get these values // back out. Not enough time to figure it out yet. AssetBase asset = new AssetBase(); - - asset.FullID = new LLUUID((String)row["UUID"]); - asset.Name = (String)row["Name"]; - asset.Description = (String)row["Description"]; + + asset.FullID = new LLUUID((String) row["UUID"]); + asset.Name = (String) row["Name"]; + asset.Description = (String) row["Description"]; asset.Type = Convert.ToSByte(row["Type"]); asset.InvType = Convert.ToSByte(row["InvType"]); asset.Local = Convert.ToBoolean(row["Local"]); asset.Temporary = Convert.ToBoolean(row["Temporary"]); - asset.Data = (byte[])row["Data"]; + asset.Data = (byte[]) row["Data"]; return asset; } - + private void fillAssetRow(DataRow row, AssetBase asset) { row["UUID"] = asset.FullID; @@ -225,8 +227,10 @@ namespace OpenSim.Framework.Data.SQLite row["Data"] = asset.Data; // ADO.NET doesn't handle NULL very well - foreach (DataColumn col in ds.Tables["assets"].Columns) { - if (row[col] == null) { + foreach (DataColumn col in ds.Tables["assets"].Columns) + { + if (row[col] == null) + { row[col] = ""; } } @@ -250,18 +254,18 @@ namespace OpenSim.Framework.Data.SQLite da.UpdateCommand.Connection = conn; SqliteCommand delete = new SqliteCommand("delete from assets where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } - + private void InitDB(SqliteConnection conn) { string createAssets = defineTable(createAssetsTable()); SqliteCommand pcmd = new SqliteCommand(createAssets, conn); conn.Open(); pcmd.ExecuteNonQuery(); - conn.Close(); + conn.Close(); } private bool TestTables(SqliteConnection conn) @@ -269,9 +273,12 @@ namespace OpenSim.Framework.Data.SQLite SqliteCommand cmd = new SqliteCommand(assetSelect, conn); SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); DataSet tmpDS = new DataSet(); - try { + try + { pDa.Fill(tmpDS, "assets"); - } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { + } + catch (SqliteSyntaxException) + { MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); InitDB(conn); } @@ -279,14 +286,18 @@ namespace OpenSim.Framework.Data.SQLite } #region IPlugin interface - public string Version { + + public string Version + { get { - 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); } } @@ -295,9 +306,11 @@ namespace OpenSim.Framework.Data.SQLite Initialise("AssetStorage.db", ""); } - public string Name { + public string Name + { get { return "SQLite Asset storage engine"; } } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs b/OpenSim/Framework/Data.SQLite/SQLiteBase.cs index 4f237fd..157b4e6 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteBase.cs @@ -26,13 +26,8 @@ * */ using System; -using System.IO; -using libsecondlife; -using OpenSim.Framework; using System.Data; -using System.Data.SqlTypes; using Mono.Data.SqliteClient; -using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.SQLite { @@ -48,8 +43,8 @@ namespace OpenSim.Framework.Data.SQLite * This should be db agnostic as we define them in ADO.NET terms * **********************************************************************/ - - 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); @@ -77,7 +72,8 @@ namespace OpenSim.Framework.Data.SQLite * generate these strings instead of typing them out. */ string[] cols = new string[dt.Columns.Count]; - for (int i = 0; i < dt.Columns.Count; i++) { + for (int i = 0; i < dt.Columns.Count; i++) + { DataColumn col = dt.Columns[i]; cols[i] = col.ColumnName; } @@ -92,7 +88,7 @@ namespace OpenSim.Framework.Data.SQLite // this provides the binding for all our parameters, so // much less code than it used to be - foreach (DataColumn col in dt.Columns) + foreach (DataColumn col in dt.Columns) { cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); } @@ -106,7 +102,8 @@ namespace OpenSim.Framework.Data.SQLite 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; @@ -118,7 +115,7 @@ namespace OpenSim.Framework.Data.SQLite // this provides the binding for all our parameters, so // much less code than it used to be - foreach (DataColumn col in dt.Columns) + foreach (DataColumn col in dt.Columns) { cmd.Parameters.Add(createSqliteParameter(col.ColumnName, col.DataType)); } @@ -133,11 +130,12 @@ namespace OpenSim.Framework.Data.SQLite 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 + " " + sqliteType(col.DataType); - if(col == dt.PrimaryKey[0]) + if (col == dt.PrimaryKey[0]) { subsql += " primary key"; } @@ -167,7 +165,7 @@ namespace OpenSim.Framework.Data.SQLite /// for us. /// ///a built sqlite parameter - protected static SqliteParameter createSqliteParameter(string name, System.Type type) + protected static SqliteParameter createSqliteParameter(string name, Type type) { SqliteParameter param = new SqliteParameter(); param.ParameterName = ":" + name; @@ -182,53 +180,87 @@ namespace OpenSim.Framework.Data.SQLite * Type conversion functions * **********************************************************************/ - + protected static 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.UInt32)) { + } + else if (type == typeof (UInt32)) + { return DbType.UInt32; - } else if (type == typeof(System.Int64)) { + } + else if (type == typeof (Int64)) + { return DbType.Int64; - } else if (type == typeof(System.UInt64)) { + } + else if (type == typeof (UInt64)) + { return DbType.UInt64; - } else if (type == typeof(System.Double)) { + } + else if (type == typeof (Double)) + { return DbType.Double; - } else if (type == typeof(System.Boolean)) { + } + else if (type == typeof (Boolean)) + { return DbType.Boolean; - } else if (type == typeof(System.Byte[])) { + } + else if (type == typeof (Byte[])) + { return DbType.Binary; - } else { + } + else + { return DbType.String; } } - + // this is something we'll need to implement for each db // slightly differently. protected static string sqliteType(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.UInt32)) { + } + else if (type == typeof (UInt32)) + { return "integer"; - } else if (type == typeof(System.Int64)) { + } + else if (type == typeof (Int64)) + { return "varchar(255)"; - } else if (type == typeof(System.UInt64)) { + } + else if (type == typeof (UInt64)) + { return "varchar(255)"; - } else if (type == typeof(System.Double)) { + } + else if (type == typeof (Double)) + { return "float"; - } else if (type == typeof(System.Boolean)) { + } + else if (type == typeof (Boolean)) + { return "integer"; - } else if (type == typeof(System.Byte[])) { + } + else if (type == typeof (Byte[])) + { return "blob"; - } else { + } + else + { return "string"; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs index 2fc80b4..8f3e8aa 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteGridData.cs @@ -192,4 +192,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 82a8434..5e95878 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs @@ -28,22 +28,14 @@ using System; using System.Collections.Generic; -using System.Text; +using System.Data; using System.Reflection; - -using OpenSim.Framework.Console; -using OpenSim.Framework; -using OpenSim.Framework; using libsecondlife; - -using System.Data; -using System.Data.SqlTypes; - using Mono.Data.SqliteClient; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.SQLite { - public class SQLiteInventoryStore : SQLiteBase, IInventoryData { private const string invItemsSelect = "select * from inventoryitems"; @@ -96,14 +88,14 @@ namespace OpenSim.Framework.Data.SQLite public InventoryItemBase buildItem(DataRow row) { InventoryItemBase item = new InventoryItemBase(); - item.inventoryID = new LLUUID((string)row["UUID"]); - item.assetID = new LLUUID((string)row["assetID"]); + item.inventoryID = new LLUUID((string) row["UUID"]); + item.assetID = new LLUUID((string) row["assetID"]); item.assetType = Convert.ToInt32(row["assetType"]); item.invType = Convert.ToInt32(row["invType"]); - item.parentFolderID = new LLUUID((string)row["parentFolderID"]); - item.avatarID = new LLUUID((string)row["avatarID"]); - item.creatorsID = new LLUUID((string)row["creatorsID"]); - item.inventoryName =(string) row["inventoryName"]; + item.parentFolderID = new LLUUID((string) row["parentFolderID"]); + item.avatarID = new LLUUID((string) row["avatarID"]); + item.creatorsID = new LLUUID((string) row["creatorsID"]); + item.inventoryName = (string) row["inventoryName"]; item.inventoryDescription = (string) row["inventoryDescription"]; item.inventoryNextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]); @@ -147,7 +139,7 @@ namespace OpenSim.Framework.Data.SQLite fillFolderRow(inventoryRow, folder); } - this.invFoldersDa.Update(ds, "inventoryfolders"); + invFoldersDa.Update(ds, "inventoryfolders"); } private void addItem(InventoryItemBase item) @@ -165,7 +157,7 @@ namespace OpenSim.Framework.Data.SQLite { fillItemRow(inventoryRow, item); } - this.invItemsDa.Update(ds, "inventoryitems"); + invItemsDa.Update(ds, "inventoryitems"); } public void Shutdown() @@ -195,12 +187,14 @@ namespace OpenSim.Framework.Data.SQLite /// A string containing the plugin version 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); } /// @@ -306,7 +300,7 @@ namespace OpenSim.Framework.Data.SQLite List folders = new List(); getInventoryFolders(ref folders, parentID); - for(int i=0; iA class containing folder information public InventoryFolderBase getInventoryFolder(LLUUID folder) { - - // TODO: Deep voodoo here. If you enable this code then - // multi region breaks. No idea why, but I figured it was - // better to leave multi region at this point. It does mean - // that you don't get to see system textures why creating - // clothes and the like. :( - - DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder); - if (row != null) { + // TODO: Deep voodoo here. If you enable this code then + // multi region breaks. No idea why, but I figured it was + // better to leave multi region at this point. It does mean + // that you don't get to see system textures why creating + // clothes and the like. :( + + DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder); + if (row != null) + { return buildFolder(row); - } else { + } + else + { return null; - } + } } /// @@ -355,7 +354,7 @@ namespace OpenSim.Framework.Data.SQLite /// The item to be created public void addInventoryItem(InventoryItemBase item) { - this.addItem(item); + addItem(item); } /// @@ -364,7 +363,7 @@ namespace OpenSim.Framework.Data.SQLite /// The updated item public void updateInventoryItem(InventoryItemBase item) { - this.addItem(item); + addItem(item); } /// @@ -376,12 +375,12 @@ namespace OpenSim.Framework.Data.SQLite DataTable inventoryItemTable = ds.Tables["inventoryitems"]; DataRow inventoryRow = inventoryItemTable.Rows.Find(itemID); - if (inventoryRow != null) - { - inventoryRow.Delete(); - } + if (inventoryRow != null) + { + inventoryRow.Delete(); + } - this.invItemsDa.Update(ds, "inventoryitems"); + invItemsDa.Update(ds, "inventoryitems"); } @@ -394,7 +393,7 @@ namespace OpenSim.Framework.Data.SQLite { List items = getInventoryInFolder(folderId); - foreach(InventoryItemBase i in items) + foreach (InventoryItemBase i in items) deleteInventoryItem(i.inventoryID); } @@ -404,7 +403,7 @@ namespace OpenSim.Framework.Data.SQLite /// The inventory folder public void addInventoryFolder(InventoryFolderBase folder) { - this.addFolder(folder); + addFolder(folder); } /// @@ -413,7 +412,7 @@ namespace OpenSim.Framework.Data.SQLite /// The inventory folder public void updateInventoryFolder(InventoryFolderBase folder) { - this.addFolder(folder); + addFolder(folder); } @@ -427,7 +426,7 @@ namespace OpenSim.Framework.Data.SQLite public void deleteInventoryFolder(LLUUID folderID) { List subFolders = getFolderHierarchy(folderID); - + DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; DataRow inventoryRow; @@ -450,7 +449,7 @@ namespace OpenSim.Framework.Data.SQLite inventoryRow.Delete(); } - this.invFoldersDa.Update(ds, "inventoryfolders"); + invFoldersDa.Update(ds, "inventoryfolders"); } /*********************************************************************** @@ -458,43 +457,43 @@ namespace OpenSim.Framework.Data.SQLite * Data Table definitions * **********************************************************************/ - + private static DataTable createInventoryItemsTable() { DataTable inv = new DataTable("inventoryitems"); - - createCol(inv, "UUID", typeof(System.String)); //inventoryID - createCol(inv, "assetID", typeof(System.String)); - createCol(inv, "assetType", typeof(System.Int32)); - createCol(inv, "invType", typeof(System.Int32)); - createCol(inv, "parentFolderID", typeof(System.String)); - createCol(inv, "avatarID", typeof(System.String)); - createCol(inv, "creatorsID", typeof(System.String)); - - createCol(inv, "inventoryName", typeof(System.String)); - createCol(inv, "inventoryDescription", typeof(System.String)); + + createCol(inv, "UUID", typeof (String)); //inventoryID + createCol(inv, "assetID", typeof (String)); + createCol(inv, "assetType", typeof (Int32)); + createCol(inv, "invType", typeof (Int32)); + createCol(inv, "parentFolderID", typeof (String)); + createCol(inv, "avatarID", typeof (String)); + createCol(inv, "creatorsID", typeof (String)); + + createCol(inv, "inventoryName", typeof (String)); + createCol(inv, "inventoryDescription", typeof (String)); // permissions - createCol(inv, "inventoryNextPermissions", typeof(System.Int32)); - createCol(inv, "inventoryCurrentPermissions", typeof(System.Int32)); - createCol(inv, "inventoryBasePermissions", typeof(System.Int32)); - createCol(inv, "inventoryEveryOnePermissions", typeof(System.Int32)); - - inv.PrimaryKey = new DataColumn[] { inv.Columns["UUID"] }; + createCol(inv, "inventoryNextPermissions", typeof (Int32)); + createCol(inv, "inventoryCurrentPermissions", typeof (Int32)); + createCol(inv, "inventoryBasePermissions", typeof (Int32)); + createCol(inv, "inventoryEveryOnePermissions", typeof (Int32)); + + inv.PrimaryKey = new DataColumn[] {inv.Columns["UUID"]}; return inv; } - + private DataTable createInventoryFoldersTable() { DataTable fol = new DataTable("inventoryfolders"); - - createCol(fol, "UUID", typeof(System.String)); //folderID - createCol(fol, "name", typeof(System.String)); - createCol(fol, "agentID", typeof(System.String)); - createCol(fol, "parentID", typeof(System.String)); - createCol(fol, "type", typeof(System.Int32)); - createCol(fol, "version", typeof(System.Int32)); - - fol.PrimaryKey = new DataColumn[] { fol.Columns["UUID"] }; + + createCol(fol, "UUID", typeof (String)); //folderID + createCol(fol, "name", typeof (String)); + createCol(fol, "agentID", typeof (String)); + createCol(fol, "parentID", typeof (String)); + createCol(fol, "type", typeof (Int32)); + createCol(fol, "version", typeof (Int32)); + + fol.PrimaryKey = new DataColumn[] {fol.Columns["UUID"]}; return fol; } @@ -507,7 +506,7 @@ namespace OpenSim.Framework.Data.SQLite da.UpdateCommand.Connection = conn; SqliteCommand delete = new SqliteCommand("delete from inventoryitems where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -521,7 +520,7 @@ namespace OpenSim.Framework.Data.SQLite da.UpdateCommand.Connection = conn; SqliteCommand delete = new SqliteCommand("delete from inventoryfolders where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -529,10 +528,10 @@ namespace OpenSim.Framework.Data.SQLite private InventoryFolderBase buildFolder(DataRow row) { InventoryFolderBase folder = new InventoryFolderBase(); - folder.folderID = new LLUUID((string)row["UUID"]); - folder.name = (string)row["name"]; - folder.agentID = new LLUUID((string)row["agentID"]); - folder.parentID = new LLUUID((string)row["parentID"]); + folder.folderID = new LLUUID((string) row["UUID"]); + folder.name = (string) row["name"]; + folder.agentID = new LLUUID((string) row["agentID"]); + folder.parentID = new LLUUID((string) row["parentID"]); folder.type = Convert.ToInt16(row["type"]); folder.version = Convert.ToUInt16(row["version"]); return folder; @@ -554,17 +553,18 @@ namespace OpenSim.Framework.Data.SQLite * Test and Initialization code * **********************************************************************/ + private void InitDB(SqliteConnection conn) { string createInventoryItems = defineTable(createInventoryItemsTable()); string createInventoryFolders = defineTable(createInventoryFoldersTable()); - + SqliteCommand pcmd = new SqliteCommand(createInventoryItems, conn); SqliteCommand scmd = new SqliteCommand(createInventoryFolders, conn); conn.Open(); pcmd.ExecuteNonQuery(); scmd.ExecuteNonQuery(); - conn.Close(); + conn.Close(); } private bool TestTables(SqliteConnection conn) @@ -575,10 +575,13 @@ namespace OpenSim.Framework.Data.SQLite SqliteDataAdapter sDa = new SqliteDataAdapter(invFoldersSelectCmd); DataSet tmpDS = new DataSet(); - try { + try + { pDa.Fill(tmpDS, "inventoryitems"); sDa.Fill(tmpDS, "inventoryfolders"); - } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { + } + catch (SqliteSyntaxException) + { MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); InitDB(conn); } @@ -586,14 +589,18 @@ namespace OpenSim.Framework.Data.SQLite pDa.Fill(tmpDS, "inventoryitems"); sDa.Fill(tmpDS, "inventoryfolders"); - foreach (DataColumn col in createInventoryItemsTable().Columns) { - if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName) ) { + foreach (DataColumn col in createInventoryItemsTable().Columns) + { + if (! tmpDS.Tables["inventoryitems"].Columns.Contains(col.ColumnName)) + { MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); return false; } } - foreach (DataColumn col in createInventoryFoldersTable().Columns) { - if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName) ) { + foreach (DataColumn col in createInventoryFoldersTable().Columns) + { + if (! tmpDS.Tables["inventoryfolders"].Columns.Contains(col.ColumnName)) + { MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); return false; } @@ -601,8 +608,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 5954fba..e102da3 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs @@ -30,13 +30,14 @@ using System.Collections.Generic; using System.Data; using System.Data.SQLite; using libsecondlife; +using Mono.Data.SqliteClient; using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.SQLite { - class SQLiteManager : SQLiteBase + internal class SQLiteManager : SQLiteBase { - IDbConnection dbcon; + private IDbConnection dbcon; /// /// Initialises and creates a new SQLite connection and maintains it. @@ -78,15 +79,15 @@ namespace OpenSim.Framework.Data.SQLite /// A SQLite DB Command public IDbCommand Query(string sql, Dictionary parameters) { - SQLiteCommand dbcommand = (SQLiteCommand)dbcon.CreateCommand(); + SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { - SQLiteParameter paramx = new SQLiteParameter(param.Key,param.Value); + SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value); dbcommand.Parameters.Add(paramx); } - return (IDbCommand)dbcommand; + return (IDbCommand) dbcommand; } private bool TestTables(SQLiteConnection conn) @@ -98,7 +99,7 @@ namespace OpenSim.Framework.Data.SQLite { pDa.Fill(tmpDS, "regions"); } - catch (Mono.Data.SqliteClient.SqliteSyntaxException) + catch (SqliteSyntaxException) { MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); InitDB(conn); @@ -110,39 +111,39 @@ namespace OpenSim.Framework.Data.SQLite { DataTable regions = new DataTable("regions"); - createCol(regions, "regionHandle", typeof(ulong)); - createCol(regions, "regionName", typeof(System.String)); - createCol(regions, "uuid", typeof(System.String)); - - createCol(regions, "regionRecvKey", typeof(System.String)); - createCol(regions, "regionSecret", typeof(System.String)); - createCol(regions, "regionSendKey", typeof(System.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, "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, "regionAssetURI", typeof(System.String)); - createCol(regions, "regionAssetRecvKey", typeof(System.String)); - createCol(regions, "regionAssetSendKey", typeof(System.String)); - - createCol(regions, "regionUserURI", typeof(System.String)); - createCol(regions, "regionUserRecvKey", typeof(System.String)); - createCol(regions, "regionUserSendKey", typeof(System.String)); + createCol(regions, "regionHandle", typeof (ulong)); + createCol(regions, "regionName", typeof (String)); + createCol(regions, "uuid", typeof (String)); + + createCol(regions, "regionRecvKey", typeof (String)); + createCol(regions, "regionSecret", typeof (String)); + createCol(regions, "regionSendKey", typeof (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, "eastOverrideHandle", typeof (ulong)); + createCol(regions, "westOverrideHandle", typeof (ulong)); + createCol(regions, "southOverrideHandle", typeof (ulong)); + createCol(regions, "northOverrideHandle", typeof (ulong)); + + createCol(regions, "regionAssetURI", typeof (String)); + createCol(regions, "regionAssetRecvKey", typeof (String)); + createCol(regions, "regionAssetSendKey", typeof (String)); + + createCol(regions, "regionUserURI", typeof (String)); + createCol(regions, "regionUserRecvKey", typeof (String)); + createCol(regions, "regionUserSendKey", typeof (String)); // Add in contraints - regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] }; + regions.PrimaryKey = new DataColumn[] {regions.Columns["UUID"]}; return regions; } @@ -168,42 +169,42 @@ namespace OpenSim.Framework.Data.SQLite if (reader.Read()) { // Region Main - retval.regionHandle = (ulong)reader["regionHandle"]; - retval.regionName = (string)reader["regionName"]; - retval.UUID = new LLUUID((string)reader["uuid"]); + retval.regionHandle = (ulong) reader["regionHandle"]; + retval.regionName = (string) reader["regionName"]; + retval.UUID = new LLUUID((string) reader["uuid"]); // Secrets - retval.regionRecvKey = (string)reader["regionRecvKey"]; - retval.regionSecret = (string)reader["regionSecret"]; - retval.regionSendKey = (string)reader["regionSendKey"]; + retval.regionRecvKey = (string) reader["regionRecvKey"]; + retval.regionSecret = (string) reader["regionSecret"]; + retval.regionSendKey = (string) reader["regionSendKey"]; // Region Server - retval.regionDataURI = (string)reader["regionDataURI"]; + retval.regionDataURI = (string) reader["regionDataURI"]; retval.regionOnline = false; // Needs to be pinged before this can be set. - retval.serverIP = (string)reader["serverIP"]; - retval.serverPort = (uint)reader["serverPort"]; - retval.serverURI = (string)reader["serverURI"]; + retval.serverIP = (string) reader["serverIP"]; + retval.serverPort = (uint) reader["serverPort"]; + retval.serverURI = (string) reader["serverURI"]; // Location - retval.regionLocX = (uint)((int)reader["locX"]); - retval.regionLocY = (uint)((int)reader["locY"]); - retval.regionLocZ = (uint)((int)reader["locZ"]); + retval.regionLocX = (uint) ((int) reader["locX"]); + retval.regionLocY = (uint) ((int) reader["locY"]); + retval.regionLocZ = (uint) ((int) reader["locZ"]); // Neighbours - 0 = No Override - retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; - retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; - retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; - retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; + retval.regionEastOverrideHandle = (ulong) reader["eastOverrideHandle"]; + retval.regionWestOverrideHandle = (ulong) reader["westOverrideHandle"]; + retval.regionSouthOverrideHandle = (ulong) reader["southOverrideHandle"]; + retval.regionNorthOverrideHandle = (ulong) reader["northOverrideHandle"]; // Assets - retval.regionAssetURI = (string)reader["regionAssetURI"]; - retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; - retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; + retval.regionAssetURI = (string) reader["regionAssetURI"]; + retval.regionAssetRecvKey = (string) reader["regionAssetRecvKey"]; + retval.regionAssetSendKey = (string) reader["regionAssetSendKey"]; // Userserver - retval.regionUserURI = (string)reader["regionUserURI"]; - retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; - retval.regionUserSendKey = (string)reader["regionUserSendKey"]; + retval.regionUserURI = (string) reader["regionUserURI"]; + retval.regionUserRecvKey = (string) reader["regionUserRecvKey"]; + retval.regionUserSendKey = (string) reader["regionUserSendKey"]; } else { @@ -219,12 +220,15 @@ namespace OpenSim.Framework.Data.SQLite /// Success? public bool insertRow(RegionProfileData profile) { - string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; - sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; + string sql = + "REPLACE INTO regions VALUES (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) VALUES "; sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; - sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; + sql += + "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; Dictionary parameters = new Dictionary(); @@ -271,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 37a8be5..d7a6b39 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs @@ -26,12 +26,8 @@ * */ using System; -using System.IO; -using libsecondlife; -using OpenSim.Framework; -using OpenSim.Framework; using System.Data; -using System.Data.SqlTypes; +using libsecondlife; using Mono.Data.SqliteClient; using OpenSim.Framework.Console; @@ -45,30 +41,31 @@ namespace OpenSim.Framework.Data.SQLite /// /// The database manager /// - /// /// Artificial constructor called upon plugin load /// private const string userSelect = "select * from users"; + private DataSet ds; private SqliteDataAdapter da; - + public void Initialise() { SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); TestTables(conn); - + ds = new DataSet(); da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); - lock (ds) { + lock (ds) + { ds.Tables.Add(createUsersTable()); ds.Tables.Add(createUserAgentsTable()); - + setupUserCommands(da, conn); da.Fill(ds.Tables["users"]); } - + return; } @@ -79,16 +76,21 @@ namespace OpenSim.Framework.Data.SQLite /// A user profile public UserProfileData GetUserByUUID(LLUUID uuid) { - lock (ds) { + lock (ds) + { DataRow row = ds.Tables["users"].Rows.Find(uuid); - if(row != null) { + if (row != null) + { UserProfileData user = buildUserProfile(row); row = ds.Tables["useragents"].Rows.Find(uuid); - if(row != null) { + if (row != null) + { user.currentAgent = buildUserAgent(row); } return user; - } else { + } + else + { return null; } } @@ -113,16 +115,21 @@ namespace OpenSim.Framework.Data.SQLite public UserProfileData GetUserByName(string fname, string lname) { string select = "surname = '" + lname + "' and username = '" + fname + "'"; - lock (ds) { + lock (ds) + { DataRow[] rows = ds.Tables["users"].Select(select); - if(rows.Length > 0) { + if (rows.Length > 0) + { UserProfileData user = buildUserProfile(rows[0]); DataRow row = ds.Tables["useragents"].Rows.Find(user.UUID); - if(row != null) { + if (row != null) + { user.currentAgent = buildUserAgent(row); } return user; - } else { + } + else + { return null; } } @@ -134,7 +141,7 @@ namespace OpenSim.Framework.Data.SQLite /// The users account ID /// A matching users profile public UserAgentData GetAgentByUUID(LLUUID uuid) - { + { try { return GetUserByUUID(uuid).currentAgent; @@ -165,7 +172,7 @@ namespace OpenSim.Framework.Data.SQLite { try { - return GetUserByName(fname,lname).currentAgent; + return GetUserByName(fname, lname).currentAgent; } catch (Exception) { @@ -180,8 +187,9 @@ namespace OpenSim.Framework.Data.SQLite public void AddNewUserProfile(UserProfileData user) { DataTable users = ds.Tables["users"]; - lock (ds) { - DataRow row = users.Rows.Find(user.UUID); + lock (ds) + { + DataRow row = users.Rows.Find(user.UUID); if (row == null) { row = users.NewRow(); @@ -192,10 +200,11 @@ namespace OpenSim.Framework.Data.SQLite { fillUserRow(row, user); } - - if(user.currentAgent != null) { + + if (user.currentAgent != null) + { DataTable ua = ds.Tables["useragents"]; - row = ua.Rows.Find(user.UUID); + row = ua.Rows.Find(user.UUID); if (row == null) { row = ua.NewRow(); @@ -207,12 +216,13 @@ namespace OpenSim.Framework.Data.SQLite fillUserAgentRow(row, user.currentAgent); } } - MainLog.Instance.Verbose("SQLITE", "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); + MainLog.Instance.Verbose("SQLITE", + "Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored"); // save changes off to disk da.Update(ds, "users"); } } - + /// /// Creates a new user profile /// @@ -220,10 +230,13 @@ namespace OpenSim.Framework.Data.SQLite /// True on success, false on error public bool UpdateUserProfile(UserProfileData user) { - try { + try + { AddNewUserProfile(user); return true; - } catch (Exception) { + } + catch (Exception) + { return false; } } @@ -279,51 +292,51 @@ namespace OpenSim.Framework.Data.SQLite { return "0.1"; } - + /*********************************************************************** * * DataTable creation * **********************************************************************/ - /*********************************************************************** + /*********************************************************************** * * Database Definition Functions * * This should be db agnostic as we define them in ADO.NET terms * **********************************************************************/ - + private DataTable createUsersTable() { DataTable users = new DataTable("users"); - createCol(users, "UUID", typeof(System.String)); - createCol(users, "username", typeof(System.String)); - createCol(users, "surname", typeof(System.String)); - createCol(users, "passwordHash", typeof(System.String)); - createCol(users, "passwordSalt", typeof(System.String)); - - createCol(users, "homeRegionX", typeof(System.Int32)); - createCol(users, "homeRegionY", typeof(System.Int32)); - createCol(users, "homeLocationX", typeof(System.Double)); - createCol(users, "homeLocationY", typeof(System.Double)); - createCol(users, "homeLocationZ", typeof(System.Double)); - createCol(users, "homeLookAtX", typeof(System.Double)); - createCol(users, "homeLookAtY", typeof(System.Double)); - createCol(users, "homeLookAtZ", typeof(System.Double)); - createCol(users, "created", typeof(System.Int32)); - createCol(users, "lastLogin", typeof(System.Int32)); - createCol(users, "rootInventoryFolderID", typeof(System.String)); - createCol(users, "userInventoryURI", typeof(System.String)); - createCol(users, "userAssetURI", typeof(System.String)); - createCol(users, "profileCanDoMask", typeof(System.Int32)); - createCol(users, "profileWantDoMask", typeof(System.Int32)); - createCol(users, "profileAboutText", typeof(System.String)); - createCol(users, "profileFirstText", typeof(System.String)); - createCol(users, "profileImage", typeof(System.String)); - createCol(users, "profileFirstImage", typeof(System.String)); + createCol(users, "UUID", typeof (String)); + createCol(users, "username", typeof (String)); + createCol(users, "surname", typeof (String)); + createCol(users, "passwordHash", typeof (String)); + createCol(users, "passwordSalt", typeof (String)); + + createCol(users, "homeRegionX", typeof (Int32)); + createCol(users, "homeRegionY", typeof (Int32)); + createCol(users, "homeLocationX", typeof (Double)); + createCol(users, "homeLocationY", typeof (Double)); + createCol(users, "homeLocationZ", typeof (Double)); + createCol(users, "homeLookAtX", typeof (Double)); + createCol(users, "homeLookAtY", typeof (Double)); + createCol(users, "homeLookAtZ", typeof (Double)); + createCol(users, "created", typeof (Int32)); + createCol(users, "lastLogin", typeof (Int32)); + createCol(users, "rootInventoryFolderID", typeof (String)); + createCol(users, "userInventoryURI", typeof (String)); + createCol(users, "userAssetURI", typeof (String)); + createCol(users, "profileCanDoMask", typeof (Int32)); + createCol(users, "profileWantDoMask", typeof (Int32)); + createCol(users, "profileAboutText", typeof (String)); + createCol(users, "profileFirstText", typeof (String)); + createCol(users, "profileImage", typeof (String)); + createCol(users, "profileFirstImage", typeof (String)); // Add in contraints - users.PrimaryKey = new DataColumn[] { users.Columns["UUID"] }; + users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]}; return users; } @@ -331,27 +344,27 @@ namespace OpenSim.Framework.Data.SQLite { DataTable ua = new DataTable("useragents"); // this is the UUID of the user - createCol(ua, "UUID", typeof(System.String)); - createCol(ua, "agentIP", typeof(System.String)); - createCol(ua, "agentPort", typeof(System.Int32)); - createCol(ua, "agentOnline", typeof(System.Boolean)); - createCol(ua, "sessionID", typeof(System.String)); - createCol(ua, "secureSessionID", typeof(System.String)); - createCol(ua, "regionID", typeof(System.String)); - createCol(ua, "loginTime", typeof(System.Int32)); - createCol(ua, "logoutTime", typeof(System.Int32)); - createCol(ua, "currentRegion", typeof(System.String)); - createCol(ua, "currentHandle", typeof(System.Int32)); + createCol(ua, "UUID", typeof (String)); + createCol(ua, "agentIP", typeof (String)); + createCol(ua, "agentPort", typeof (Int32)); + createCol(ua, "agentOnline", typeof (Boolean)); + createCol(ua, "sessionID", typeof (String)); + createCol(ua, "secureSessionID", typeof (String)); + createCol(ua, "regionID", typeof (String)); + createCol(ua, "loginTime", typeof (Int32)); + createCol(ua, "logoutTime", typeof (Int32)); + createCol(ua, "currentRegion", typeof (String)); + createCol(ua, "currentHandle", typeof (Int32)); // vectors - createCol(ua, "currentPosX", typeof(System.Double)); - createCol(ua, "currentPosY", typeof(System.Double)); - createCol(ua, "currentPosZ", typeof(System.Double)); + createCol(ua, "currentPosX", typeof (Double)); + createCol(ua, "currentPosY", typeof (Double)); + createCol(ua, "currentPosZ", typeof (Double)); // constraints - ua.PrimaryKey = new DataColumn[] { ua.Columns["UUID"] }; + ua.PrimaryKey = new DataColumn[] {ua.Columns["UUID"]}; return ua; } - + /*********************************************************************** * * Convert between ADO.NET <=> OpenSim Objects @@ -366,35 +379,35 @@ namespace OpenSim.Framework.Data.SQLite // interesting has to be done to actually get these values // back out. Not enough time to figure it out yet. UserProfileData user = new UserProfileData(); - user.UUID = new LLUUID((String)row["UUID"]); - user.username = (String)row["username"]; - user.surname = (String)row["surname"]; - user.passwordHash = (String)row["passwordHash"]; - user.passwordSalt = (String)row["passwordSalt"]; + user.UUID = new LLUUID((String) row["UUID"]); + user.username = (String) row["username"]; + user.surname = (String) row["surname"]; + user.passwordHash = (String) row["passwordHash"]; + user.passwordSalt = (String) row["passwordSalt"]; user.homeRegionX = Convert.ToUInt32(row["homeRegionX"]); user.homeRegionY = Convert.ToUInt32(row["homeRegionY"]); user.homeLocation = new LLVector3( - Convert.ToSingle(row["homeLocationX"]), - Convert.ToSingle(row["homeLocationY"]), - Convert.ToSingle(row["homeLocationZ"]) - ); + Convert.ToSingle(row["homeLocationX"]), + Convert.ToSingle(row["homeLocationY"]), + Convert.ToSingle(row["homeLocationZ"]) + ); user.homeLookAt = new LLVector3( - Convert.ToSingle(row["homeLookAtX"]), - Convert.ToSingle(row["homeLookAtY"]), - Convert.ToSingle(row["homeLookAtZ"]) - ); + Convert.ToSingle(row["homeLookAtX"]), + Convert.ToSingle(row["homeLookAtY"]), + Convert.ToSingle(row["homeLookAtZ"]) + ); user.created = Convert.ToInt32(row["created"]); user.lastLogin = Convert.ToInt32(row["lastLogin"]); - user.rootInventoryFolderID = new LLUUID((String)row["rootInventoryFolderID"]); - user.userInventoryURI = (String)row["userInventoryURI"]; - user.userAssetURI = (String)row["userAssetURI"]; + user.rootInventoryFolderID = new LLUUID((String) row["rootInventoryFolderID"]); + user.userInventoryURI = (String) row["userInventoryURI"]; + user.userAssetURI = (String) row["userAssetURI"]; user.profileCanDoMask = Convert.ToUInt32(row["profileCanDoMask"]); user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]); - user.profileAboutText = (String)row["profileAboutText"]; - user.profileFirstText = (String)row["profileFirstText"]; - user.profileImage = new LLUUID((String)row["profileImage"]); - user.profileFirstImage = new LLUUID((String)row["profileFirstImage"]); + user.profileAboutText = (String) row["profileAboutText"]; + user.profileFirstText = (String) row["profileFirstText"]; + user.profileImage = new LLUUID((String) row["profileImage"]); + user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]); return user; } @@ -405,8 +418,8 @@ namespace OpenSim.Framework.Data.SQLite row["surname"] = user.surname; row["passwordHash"] = user.passwordHash; row["passwordSalt"] = user.passwordSalt; - - + + row["homeRegionX"] = user.homeRegionX; row["homeRegionY"] = user.homeRegionY; row["homeLocationX"] = user.homeLocation.X; @@ -427,10 +440,12 @@ namespace OpenSim.Framework.Data.SQLite row["profileFirstText"] = user.profileFirstText; row["profileImage"] = user.profileImage; row["profileFirstImage"] = user.profileFirstImage; - + // ADO.NET doesn't handle NULL very well - foreach (DataColumn col in ds.Tables["users"].Columns) { - if (row[col] == null) { + foreach (DataColumn col in ds.Tables["users"].Columns) + { + if (row[col] == null) + { row[col] = ""; } } @@ -439,33 +454,33 @@ namespace OpenSim.Framework.Data.SQLite private UserAgentData buildUserAgent(DataRow row) { UserAgentData ua = new UserAgentData(); - - ua.UUID = new LLUUID((String)row["UUID"]); - ua.agentIP = (String)row["agentIP"]; + + ua.UUID = new LLUUID((String) row["UUID"]); + ua.agentIP = (String) row["agentIP"]; ua.agentPort = Convert.ToUInt32(row["agentPort"]); ua.agentOnline = Convert.ToBoolean(row["agentOnline"]); - ua.sessionID = new LLUUID((String)row["sessionID"]); - ua.secureSessionID = new LLUUID((String)row["secureSessionID"]); - ua.regionID = new LLUUID((String)row["regionID"]); + ua.sessionID = new LLUUID((String) row["sessionID"]); + ua.secureSessionID = new LLUUID((String) row["secureSessionID"]); + ua.regionID = new LLUUID((String) row["regionID"]); ua.loginTime = Convert.ToInt32(row["loginTime"]); ua.logoutTime = Convert.ToInt32(row["logoutTime"]); - ua.currentRegion = new LLUUID((String)row["currentRegion"]); + ua.currentRegion = new LLUUID((String) row["currentRegion"]); ua.currentHandle = Convert.ToUInt32(row["currentHandle"]); ua.currentPos = new LLVector3( - Convert.ToSingle(row["currentPosX"]), - Convert.ToSingle(row["currentPosY"]), - Convert.ToSingle(row["currentPosZ"]) - ); + Convert.ToSingle(row["currentPosX"]), + Convert.ToSingle(row["currentPosY"]), + Convert.ToSingle(row["currentPosZ"]) + ); return ua; } private void fillUserAgentRow(DataRow row, UserAgentData ua) { row["UUID"] = ua.UUID; - row["agentIP"] = ua.agentIP; - row["agentPort"] = ua.agentPort; - row["agentOnline"] = ua.agentOnline; - row["sessionID"] = ua.sessionID; + row["agentIP"] = ua.agentIP; + row["agentPort"] = ua.agentPort; + row["agentOnline"] = ua.agentOnline; + row["sessionID"] = ua.sessionID; row["secureSessionID"] = ua.secureSessionID; row["regionID"] = ua.regionID; row["loginTime"] = ua.loginTime; @@ -496,18 +511,18 @@ namespace OpenSim.Framework.Data.SQLite da.UpdateCommand.Connection = conn; SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } - + private void InitDB(SqliteConnection conn) { string createUsers = defineTable(createUsersTable()); SqliteCommand pcmd = new SqliteCommand(createUsers, conn); conn.Open(); pcmd.ExecuteNonQuery(); - conn.Close(); + conn.Close(); } private bool TestTables(SqliteConnection conn) @@ -515,14 +530,16 @@ namespace OpenSim.Framework.Data.SQLite SqliteCommand cmd = new SqliteCommand(userSelect, conn); SqliteDataAdapter pDa = new SqliteDataAdapter(cmd); DataSet tmpDS = new DataSet(); - try { + try + { pDa.Fill(tmpDS, "users"); - } catch (Mono.Data.SqliteClient.SqliteSyntaxException) { + } + catch (SqliteSyntaxException) + { MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); InitDB(conn); } return true; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs index 2a5b8f6..b3b6ed7 100644 --- a/OpenSim/Framework/Data/GridData.cs +++ b/OpenSim/Framework/Data/GridData.cs @@ -106,6 +106,5 @@ namespace OpenSim.Framework.Data DataResponse AddProfile(RegionProfileData profile); 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 b222a28..373d8e1 100644 --- a/OpenSim/Framework/Data/ILogData.cs +++ b/OpenSim/Framework/Data/ILogData.cs @@ -63,7 +63,9 @@ namespace OpenSim.Framework.Data /// public interface ILogData { - void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,string logMessage); + void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority, + string logMessage); + /// /// Initialises the interface /// @@ -86,5 +88,4 @@ namespace OpenSim.Framework.Data /// A string containing the plugin version string getVersion(); } - -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/IniConfig.cs b/OpenSim/Framework/Data/IniConfig.cs index f0f63b4..048b491 100644 --- a/OpenSim/Framework/Data/IniConfig.cs +++ b/OpenSim/Framework/Data/IniConfig.cs @@ -27,6 +27,7 @@ */ using System.IO; using System.Text.RegularExpressions; + /* Taken from public code listing at by Alex Pinsker http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html @@ -52,7 +53,8 @@ namespace OpenSim.Framework.Data RegexOptions.Compiled | RegexOptions.CultureInvariant); } - static private Regex _iniKeyValuePatternRegex; + + private static Regex _iniKeyValuePatternRegex; public IniFile(string iniFileName) { @@ -62,7 +64,7 @@ namespace OpenSim.Framework.Data public string ParseFileReadValue(string key) { using (StreamReader reader = - new StreamReader(_iniFileName)) + new StreamReader(_iniFileName)) { do { @@ -72,18 +74,16 @@ namespace OpenSim.Framework.Data if (match.Success) { string currentKey = - match.Groups["Key"].Value as string; + match.Groups["Key"].Value as string; if (currentKey != null && - currentKey.Trim().CompareTo(key) == 0) + currentKey.Trim().CompareTo(key) == 0) { string value = - match.Groups["Value"].Value as string; + match.Groups["Value"].Value as string; return value; } } - - } - while (reader.Peek() != -1); + } while (reader.Peek() != -1); } return null; } @@ -91,6 +91,8 @@ namespace OpenSim.Framework.Data public string IniFileName { get { return _iniFileName; } - } private string _iniFileName; + } + + private string _iniFileName; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs index 556d589..51050d1 100644 --- a/OpenSim/Framework/Data/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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.Framework.Data")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Framework.Data")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Framework.Data")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Framework.Data")] +[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("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")] + +[assembly : Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")] // Version information for an assembly consists of the following four values: // @@ -29,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Framework/Data/RegionProfileData.cs b/OpenSim/Framework/Data/RegionProfileData.cs index 5e5dac6..ab8771a 100644 --- a/OpenSim/Framework/Data/RegionProfileData.cs +++ b/OpenSim/Framework/Data/RegionProfileData.cs @@ -25,11 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; -using Nwc.XmlRpc; using System; using System.Collections; +using libsecondlife; +using Nwc.XmlRpc; namespace OpenSim.Framework.Data { @@ -57,6 +57,7 @@ namespace OpenSim.Framework.Data /// Coordinates of the region /// public uint regionLocX; + public uint regionLocY; public uint regionLocZ; // Reserved (round-robin, layers, etc) @@ -65,6 +66,7 @@ namespace OpenSim.Framework.Data /// /// Not very secure, needs improvement. public string regionSendKey = ""; + public string regionRecvKey = ""; public string regionSecret = ""; @@ -77,6 +79,7 @@ namespace OpenSim.Framework.Data /// Information about the server that the region is currently hosted on /// public string serverIP = ""; + public uint serverPort; public string serverURI = ""; @@ -88,6 +91,7 @@ namespace OpenSim.Framework.Data /// Set of optional overrides. Can be used to create non-eulicidean spaces. /// public ulong regionNorthOverrideHandle; + public ulong regionSouthOverrideHandle; public ulong regionEastOverrideHandle; public ulong regionWestOverrideHandle; @@ -102,6 +106,7 @@ namespace OpenSim.Framework.Data /// Region Asset Details /// public string regionAssetURI = ""; + public string regionAssetSendKey = ""; public string regionAssetRecvKey = ""; @@ -109,6 +114,7 @@ namespace OpenSim.Framework.Data /// Region Userserver Details /// public string regionUserURI = ""; + public string regionUserSendKey = ""; public string regionUserRecvKey = ""; @@ -124,7 +130,8 @@ namespace OpenSim.Framework.Data /// /// /// - public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey) + public RegionProfileData RequestSimProfileData(LLUUID region_uuid, string gridserver_url, + string gridserver_sendkey, string gridserver_recvkey) { Hashtable requestData = new Hashtable(); requestData["region_uuid"] = region_uuid.UUID.ToString(); @@ -134,7 +141,7 @@ namespace OpenSim.Framework.Data XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); - Hashtable responseData = (Hashtable)GridResp.Value; + Hashtable responseData = (Hashtable) GridResp.Value; if (responseData.ContainsKey("error")) { @@ -142,21 +149,23 @@ namespace OpenSim.Framework.Data } RegionProfileData simData = new RegionProfileData(); - simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); - simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); - simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256)); - simData.serverIP = (string)responseData["sim_ip"]; - simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); - simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); - simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); + simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX*256), (simData.regionLocY*256)); + simData.serverIP = (string) responseData["sim_ip"]; + simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); + simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); + simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/"; simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; - simData.UUID = new LLUUID((string)responseData["region_UUID"]); - simData.regionName = (string)responseData["region_name"]; + simData.UUID = new LLUUID((string) responseData["region_UUID"]); + simData.regionName = (string) responseData["region_name"]; - return simData; + return simData; } - public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, string gridserver_sendkey, string gridserver_recvkey) + + public RegionProfileData RequestSimProfileData(ulong region_handle, string gridserver_url, + string gridserver_sendkey, string gridserver_recvkey) { Hashtable requestData = new Hashtable(); requestData["region_handle"] = region_handle.ToString(); @@ -166,7 +175,7 @@ namespace OpenSim.Framework.Data XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcResponse GridResp = GridReq.Send(gridserver_url, 3000); - Hashtable responseData = (Hashtable)GridResp.Value; + Hashtable responseData = (Hashtable) GridResp.Value; if (responseData.ContainsKey("error")) { @@ -174,19 +183,19 @@ namespace OpenSim.Framework.Data } RegionProfileData simData = new RegionProfileData(); - simData.regionLocX = Convert.ToUInt32((string)responseData["region_locx"]); - simData.regionLocY = Convert.ToUInt32((string)responseData["region_locy"]); - simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX * 256), (simData.regionLocY * 256)); - simData.serverIP = (string)responseData["sim_ip"]; - simData.serverPort = Convert.ToUInt32((string)responseData["sim_port"]); - simData.httpPort = Convert.ToUInt32((string)responseData["http_port"]); - simData.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + simData.regionLocX = Convert.ToUInt32((string) responseData["region_locx"]); + simData.regionLocY = Convert.ToUInt32((string) responseData["region_locy"]); + simData.regionHandle = Helpers.UIntsToLong((simData.regionLocX*256), (simData.regionLocY*256)); + simData.serverIP = (string) responseData["sim_ip"]; + simData.serverPort = Convert.ToUInt32((string) responseData["sim_port"]); + simData.httpPort = Convert.ToUInt32((string) responseData["http_port"]); + simData.remotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); simData.httpServerURI = "http://" + simData.serverIP + ":" + simData.httpPort.ToString() + "/"; simData.serverURI = "http://" + simData.serverIP + ":" + simData.serverPort.ToString() + "/"; - simData.UUID = new LLUUID((string)responseData["region_UUID"]); - simData.regionName = (string)responseData["region_name"]; + simData.UUID = new LLUUID((string) responseData["region_UUID"]); + simData.regionName = (string) responseData["region_name"]; - return simData; + return simData; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Data/ReservationData.cs b/OpenSim/Framework/Data/ReservationData.cs index 1e606ee..06adf04 100644 --- a/OpenSim/Framework/Data/ReservationData.cs +++ b/OpenSim/Framework/Data/ReservationData.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Data public int reservationMinY = 0; public int reservationMaxX = 65536; public int reservationMaxY = 65536; - + public string reservationName = ""; public string reservationCompany = ""; public bool status = true; @@ -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/General/ACL.cs b/OpenSim/Framework/General/ACL.cs index 348f0ae..0e9df19 100644 --- a/OpenSim/Framework/General/ACL.cs +++ b/OpenSim/Framework/General/ACL.cs @@ -27,7 +27,6 @@ */ using System; using System.Collections.Generic; -using System.Text; namespace OpenSim.Framework { @@ -37,15 +36,15 @@ namespace OpenSim.Framework // permissions rather than just the first. Deny permissions will // override all others. - #region ACL Core Class + /// /// Access Control List Engine /// public class ACL { - Dictionary Roles = new Dictionary(); - Dictionary Resources = new Dictionary(); + private Dictionary Roles = new Dictionary(); + private Dictionary Resources = new Dictionary(); public ACL AddRole(Role role) { @@ -114,9 +113,11 @@ namespace OpenSim.Framework return this; } } + #endregion #region Exceptions + /// /// Thrown when an ACL attempts to add a duplicate role. /// @@ -139,6 +140,7 @@ namespace OpenSim.Framework return "This ACL already contains a role called '" + m_role.Name + "'."; } } + #endregion #region Roles and Resources @@ -146,7 +148,12 @@ namespace OpenSim.Framework /// /// Does this Role have permission to access a specified Resource? /// - public enum Permission { Deny, None, Allow }; + public enum Permission + { + Deny, + None, + Allow + } ; /// /// A role class, for use with Users or Groups @@ -227,7 +234,7 @@ namespace OpenSim.Framework #region Tests - class ACLTester + internal class ACLTester { public ACLTester() { @@ -249,9 +256,8 @@ namespace OpenSim.Framework acl.GrantPermission("Guests", "CanBuild"); acl.HasPermission("JoeGuest", "CanBuild"); - } } #endregion -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AgentCircuitManager.cs b/OpenSim/Framework/General/AgentCircuitManager.cs index 578cc67..3658feb 100644 --- a/OpenSim/Framework/General/AgentCircuitManager.cs +++ b/OpenSim/Framework/General/AgentCircuitManager.cs @@ -27,8 +27,6 @@ */ using System.Collections.Generic; using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework { @@ -38,15 +36,14 @@ namespace OpenSim.Framework public AgentCircuitManager() { - } public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) { AgentCircuitData validcircuit = null; - if (this.AgentCircuits.ContainsKey(circuitcode)) + if (AgentCircuits.ContainsKey(circuitcode)) { - validcircuit = this.AgentCircuits[circuitcode]; + validcircuit = AgentCircuits[circuitcode]; } AuthenticateResponse user = new AuthenticateResponse(); if (validcircuit == null) @@ -79,50 +76,50 @@ namespace OpenSim.Framework public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData) { - if (this.AgentCircuits.ContainsKey(circuitCode)) + if (AgentCircuits.ContainsKey(circuitCode)) { - this.AgentCircuits[circuitCode] = agentData; + AgentCircuits[circuitCode] = agentData; } else { - this.AgentCircuits.Add(circuitCode, agentData); + AgentCircuits.Add(circuitCode, agentData); } } public LLVector3 GetPosition(uint circuitCode) { LLVector3 vec = new LLVector3(); - if (this.AgentCircuits.ContainsKey(circuitCode)) + if (AgentCircuits.ContainsKey(circuitCode)) { - vec = this.AgentCircuits[circuitCode].startpos; + vec = AgentCircuits[circuitCode].startpos; } return vec; } public void UpdateAgentData(AgentCircuitData agentData) { - if (this.AgentCircuits.ContainsKey((uint)agentData.circuitcode)) + if (AgentCircuits.ContainsKey((uint) agentData.circuitcode)) { - this.AgentCircuits[(uint)agentData.circuitcode].firstname = agentData.firstname; - this.AgentCircuits[(uint)agentData.circuitcode].lastname = agentData.lastname; - this.AgentCircuits[(uint)agentData.circuitcode].startpos = agentData.startpos; - // Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); + AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; + AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; + AgentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; + // Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); } } public void UpdateAgentChildStatus(uint circuitcode, bool childstatus) { - if (this.AgentCircuits.ContainsKey(circuitcode)) + if (AgentCircuits.ContainsKey(circuitcode)) { - this.AgentCircuits[circuitcode].child = childstatus; + AgentCircuits[circuitcode].child = childstatus; } } public bool GetAgentChildStatus(uint circuitcode) { - if (this.AgentCircuits.ContainsKey(circuitcode)) + if (AgentCircuits.ContainsKey(circuitcode)) { - return this.AgentCircuits[circuitcode].child; + return AgentCircuits[circuitcode].child; } return false; } diff --git a/OpenSim/Framework/General/AgentCiruitData.cs b/OpenSim/Framework/General/AgentCiruitData.cs index 0924d36..95cac60 100644 --- a/OpenSim/Framework/General/AgentCiruitData.cs +++ b/OpenSim/Framework/General/AgentCiruitData.cs @@ -25,15 +25,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; using System; +using libsecondlife; namespace OpenSim.Framework { [Serializable] public class AgentCircuitData { - public AgentCircuitData() { } + public AgentCircuitData() + { + } + public LLUUID AgentID; public LLUUID SessionID; public LLUUID SecureSessionID; @@ -44,6 +47,6 @@ namespace OpenSim.Framework public bool child; public LLUUID InventoryFolder; public LLUUID BaseFolder; - public string CapsPath = ""; + public string CapsPath = ""; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AgentInventory.cs b/OpenSim/Framework/General/AgentInventory.cs index cf110cb..7a1174a 100644 --- a/OpenSim/Framework/General/AgentInventory.cs +++ b/OpenSim/Framework/General/AgentInventory.cs @@ -28,8 +28,6 @@ using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework; - namespace OpenSim.Framework { @@ -39,7 +37,7 @@ namespace OpenSim.Framework public Dictionary InventoryFolders; public Dictionary InventoryItems; public InventoryFolder InventoryRoot; - public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server + public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server public LLUUID AgentID; public AvatarWearable[] Wearables; @@ -47,12 +45,12 @@ namespace OpenSim.Framework { InventoryFolders = new Dictionary(); InventoryItems = new Dictionary(); - this.Initialise(); + Initialise(); } public virtual void Initialise() { - Wearables = new AvatarWearable[13]; + Wearables = new AvatarWearable[13]; for (int i = 0; i < 13; i++) { Wearables[i] = new AvatarWearable(); @@ -63,27 +61,27 @@ namespace OpenSim.Framework { InventoryFolder Folder = new InventoryFolder(); Folder.FolderID = folderID; - Folder.OwnerID = this.AgentID; + Folder.OwnerID = AgentID; Folder.DefaultType = type; - this.InventoryFolders.Add(Folder.FolderID, Folder); + InventoryFolders.Add(Folder.FolderID, Folder); return (true); } public void CreateRootFolder(LLUUID newAgentID, bool createTextures) { - this.AgentID = newAgentID; + AgentID = newAgentID; InventoryRoot = new InventoryFolder(); InventoryRoot.FolderID = LLUUID.Random(); InventoryRoot.ParentID = new LLUUID(); InventoryRoot.Version = 1; InventoryRoot.DefaultType = 8; - InventoryRoot.OwnerID = this.AgentID; + InventoryRoot.OwnerID = AgentID; InventoryRoot.FolderName = "My Inventory"; InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); - InventoryRoot.OwnerID = this.AgentID; + InventoryRoot.OwnerID = AgentID; if (createTextures) { - this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID); + CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID); } } @@ -91,32 +89,32 @@ namespace OpenSim.Framework { InventoryFolder Folder = new InventoryFolder(); Folder.FolderID = folderID; - Folder.OwnerID = this.AgentID; + Folder.OwnerID = AgentID; Folder.DefaultType = type; Folder.FolderName = folderName; - this.InventoryFolders.Add(Folder.FolderID, Folder); + InventoryFolders.Add(Folder.FolderID, Folder); return (true); } public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID) { - if (!this.InventoryFolders.ContainsKey(folderID)) + if (!InventoryFolders.ContainsKey(folderID)) { System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory"); InventoryFolder Folder = new InventoryFolder(); Folder.FolderID = folderID; - Folder.OwnerID = this.AgentID; + Folder.OwnerID = AgentID; Folder.DefaultType = type; Folder.FolderName = folderName; Folder.ParentID = parentID; - this.InventoryFolders.Add(Folder.FolderID, Folder); + InventoryFolders.Add(Folder.FolderID, Folder); } return (true); } public bool HasFolder(LLUUID folderID) { - if (this.InventoryFolders.ContainsKey(folderID)) + if (InventoryFolders.ContainsKey(folderID)) { return true; } @@ -125,7 +123,7 @@ namespace OpenSim.Framework public LLUUID GetFolderID(string folderName) { - foreach (InventoryFolder inv in this.InventoryFolders.Values) + foreach (InventoryFolder inv in InventoryFolders.Values) { if (inv.FolderName == folderName) { @@ -137,11 +135,12 @@ namespace OpenSim.Framework public bool UpdateItemAsset(LLUUID itemID, AssetBase asset) { - if(this.InventoryItems.ContainsKey(itemID)) + if (InventoryItems.ContainsKey(itemID)) { - InventoryItem Item = this.InventoryItems[itemID]; + InventoryItem Item = InventoryItems[itemID]; Item.AssetID = asset.FullID; - System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated()); + System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + + " so it now is set to asset " + asset.FullID.ToStringHyphenated()); //TODO need to update the rest of the info } return true; @@ -150,10 +149,10 @@ namespace OpenSim.Framework public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) { System.Console.WriteLine("updating inventory item details"); - if (this.InventoryItems.ContainsKey(itemID)) + if (InventoryItems.ContainsKey(itemID)) { - System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name)); - InventoryItem Item = this.InventoryItems[itemID]; + System.Console.WriteLine("changing name to " + Util.FieldToString(packet.Name)); + InventoryItem Item = InventoryItems[itemID]; Item.Name = Util.FieldToString(packet.Name); System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated()); //TODO need to update the rest of the info @@ -163,7 +162,7 @@ namespace OpenSim.Framework public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) { - if (this.InventoryFolders.ContainsKey(folderID)) + if (InventoryFolders.ContainsKey(folderID)) { LLUUID NewItemID = LLUUID.Random(); @@ -176,7 +175,7 @@ namespace OpenSim.Framework Item.Name = asset.Name; Item.Description = asset.Description; Item.InvType = asset.InvType; - this.InventoryItems.Add(Item.ItemID, Item); + InventoryItems.Add(Item.ItemID, Item); InventoryFolder Folder = InventoryFolders[Item.FolderID]; Folder.Items.Add(Item); return (Item.ItemID); @@ -190,10 +189,10 @@ namespace OpenSim.Framework public bool DeleteFromInventory(LLUUID itemID) { bool res = false; - if (this.InventoryItems.ContainsKey(itemID)) + if (InventoryItems.ContainsKey(itemID)) { - InventoryItem item = this.InventoryItems[itemID]; - this.InventoryItems.Remove(itemID); + InventoryItem item = InventoryItems[itemID]; + InventoryItems.Remove(itemID); foreach (InventoryFolder fold in InventoryFolders.Values) { if (fold.Items.Contains(item)) @@ -203,7 +202,6 @@ namespace OpenSim.Framework } } res = true; - } return res; } @@ -225,7 +223,6 @@ namespace OpenSim.Framework Items = new List(); //Subfolders = new List(); } - } public class InventoryItem @@ -237,12 +234,12 @@ namespace OpenSim.Framework public LLUUID CreatorID; public sbyte InvType; public sbyte Type; - public string Name =""; + public string Name = ""; public string Description; public InventoryItem() { - this.CreatorID = LLUUID.Zero; + CreatorID = LLUUID.Zero; } public string ExportString() @@ -251,11 +248,11 @@ namespace OpenSim.Framework string result = ""; result += "\tinv_object\t0\n\t{\n"; result += "\t\tobj_id\t%s\n"; - result += "\t\tparent_id\t"+ ItemID.ToString() +"\n"; - result += "\t\ttype\t"+ typ +"\n"; - result += "\t\tname\t" + Name+"|\n"; + result += "\t\tparent_id\t" + ItemID.ToString() + "\n"; + result += "\t\ttype\t" + typ + "\n"; + result += "\t\tname\t" + Name + "|\n"; result += "\t}\n"; return result; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AgentWearable.cs b/OpenSim/Framework/General/AgentWearable.cs index af8a630..c2d4db3 100644 --- a/OpenSim/Framework/General/AgentWearable.cs +++ b/OpenSim/Framework/General/AgentWearable.cs @@ -36,10 +36,9 @@ namespace OpenSim.Framework public AvatarWearable() { - } - public AvatarWearable( LLUUID itemId, LLUUID assetId ) + public AvatarWearable(LLUUID itemId, LLUUID assetId) { AssetID = assetId; ItemID = itemId; @@ -69,4 +68,4 @@ namespace OpenSim.Framework } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AssetBase.cs b/OpenSim/Framework/General/AssetBase.cs index 9c69eb8..f0367f0 100644 --- a/OpenSim/Framework/General/AssetBase.cs +++ b/OpenSim/Framework/General/AssetBase.cs @@ -44,7 +44,6 @@ namespace OpenSim.Framework public AssetBase() { - } public AssetBase(LLUUID assetId, string name) @@ -53,4 +52,4 @@ namespace OpenSim.Framework Name = name; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AssetConfig.cs b/OpenSim/Framework/General/AssetConfig.cs index 457369d..81cf899 100644 --- a/OpenSim/Framework/General/AssetConfig.cs +++ b/OpenSim/Framework/General/AssetConfig.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Framework { /// @@ -48,18 +44,22 @@ namespace OpenSim.Framework public AssetConfig(string description, string filename) { - configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration); + configMember = + new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } public void loadConfigurationOptions() { - configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS", false); - - configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); + configMember.addConfigurationOption("default_startup_message", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Default Startup Message", "Welcome to OGS", false); - configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false); + configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); + configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Http Listener port", DefaultHttpPort.ToString(), false); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -67,17 +67,17 @@ namespace OpenSim.Framework switch (configuration_key) { case "default_startup_message": - this.DefaultStartupMsg = (string)configuration_result; + DefaultStartupMsg = (string) configuration_result; break; case "database_provider": - this.DatabaseProvider = (string)configuration_result; + DatabaseProvider = (string) configuration_result; break; case "http_port": - HttpPort = (uint)configuration_result; + HttpPort = (uint) configuration_result; break; } return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AssetLandmark.cs b/OpenSim/Framework/General/AssetLandmark.cs index 9f05531..a62a85b 100644 --- a/OpenSim/Framework/General/AssetLandmark.cs +++ b/OpenSim/Framework/General/AssetLandmark.cs @@ -38,22 +38,22 @@ namespace OpenSim.Framework public AssetLandmark(AssetBase a) { - this.Data = a.Data; - this.FullID = a.FullID; - this.Type = a.Type; - this.InvType = a.InvType; - this.Name = a.Name; - this.Description = a.Description; + Data = a.Data; + FullID = a.FullID; + Type = a.Type; + InvType = a.InvType; + Name = a.Name; + Description = a.Description; InternData(); } private void InternData() { - string temp = Encoding.UTF8.GetString(Data).Trim(); + string temp = Encoding.UTF8.GetString(Data).Trim(); string[] parts = temp.Split('\n'); int.TryParse(parts[0].Substring(17, 1), out Version); LLUUID.TryParse(parts[1].Substring(10, 36), out RegionID); LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out Position); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AssetStorage.cs b/OpenSim/Framework/General/AssetStorage.cs index e3193ed..b39ceeb 100644 --- a/OpenSim/Framework/General/AssetStorage.cs +++ b/OpenSim/Framework/General/AssetStorage.cs @@ -29,19 +29,20 @@ using libsecondlife; namespace OpenSim.Framework { - public class AssetStorage - { + public class AssetStorage + { + public AssetStorage() + { + } - public AssetStorage() { - } + public AssetStorage(LLUUID assetUUID) + { + UUID = assetUUID; + } - public AssetStorage(LLUUID assetUUID) { - UUID=assetUUID; - } - - public byte[] Data; - public sbyte Type; - public string Name; - public LLUUID UUID; - } -} + public byte[] Data; + public sbyte Type; + public string Name; + public LLUUID UUID; + } +} \ No newline at end of file diff --git a/OpenSim/Framework/General/AuthenticateResponse.cs b/OpenSim/Framework/General/AuthenticateResponse.cs index 25bb0dd..0bf356e 100644 --- a/OpenSim/Framework/General/AuthenticateResponse.cs +++ b/OpenSim/Framework/General/AuthenticateResponse.cs @@ -25,8 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using OpenSim.Framework; - namespace OpenSim.Framework { public class AuthenticateResponse @@ -36,8 +34,6 @@ namespace OpenSim.Framework public AuthenticateResponse() { - } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/BlockingQueue.cs b/OpenSim/Framework/General/BlockingQueue.cs index 2d59db4..006fbc8 100644 --- a/OpenSim/Framework/General/BlockingQueue.cs +++ b/OpenSim/Framework/General/BlockingQueue.cs @@ -55,4 +55,4 @@ namespace OpenSim.Framework } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs index c3b3d94..e34c051 100644 --- a/OpenSim/Framework/General/ClientManager.cs +++ b/OpenSim/Framework/General/ClientManager.cs @@ -26,16 +26,14 @@ * */ -using System; using System.Collections.Generic; -using System.Text; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; using libsecondlife; +using libsecondlife.Packets; namespace OpenSim.Framework { public delegate void ForEachClientDelegate(IClientAPI client); + public class ClientManager { private Dictionary m_clients; @@ -63,7 +61,7 @@ namespace OpenSim.Framework m_clients.Add(id, client); } - public void InPacket(uint circuitCode, libsecondlife.Packets.Packet packet) + public void InPacket(uint circuitCode, Packet packet) { IClientAPI client; @@ -83,10 +81,10 @@ namespace OpenSim.Framework } } - public void CloseAllCircuits( LLUUID agentId ) + public void CloseAllCircuits(LLUUID agentId) { uint[] circuits = GetAllCircuits(agentId); - foreach (uint circuit in circuits ) + foreach (uint circuit in circuits) { IClientAPI client; if (m_clients.TryGetValue(circuit, out client)) @@ -94,7 +92,7 @@ namespace OpenSim.Framework Remove(circuit); client.Close(); } - } + } } private uint[] GetAllCircuits(LLUUID agentId) @@ -103,16 +101,16 @@ namespace OpenSim.Framework foreach (KeyValuePair pair in m_clients) { - if( pair.Value.AgentId == agentId ) + if (pair.Value.AgentId == agentId) { - circuits.Add( pair.Key ); + circuits.Add(pair.Key); } } return circuits.ToArray(); } - + public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock) { ViewerEffectPacket packet = new ViewerEffectPacket(); @@ -134,4 +132,4 @@ namespace OpenSim.Framework return m_clients.TryGetValue(circuitId, out user); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/ConfigurationMember.cs b/OpenSim/Framework/General/ConfigurationMember.cs index c71982a..5883d73 100644 --- a/OpenSim/Framework/General/ConfigurationMember.cs +++ b/OpenSim/Framework/General/ConfigurationMember.cs @@ -27,22 +27,19 @@ */ 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 libsecondlife; - using OpenSim.Framework.Console; -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 configurationOptions = new List(); @@ -53,22 +50,26 @@ namespace OpenSim.Framework private ConfigurationOptionResult resultFunction; private IGenericConfig configurationPlugin = null; + /// /// This is the default configuration DLL loaded /// 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 void setConfigurationFilename(string filename) { configurationFilename = filename; } + public void setConfigurationDescription(string desc) { configurationDescription = desc; @@ -83,7 +84,11 @@ namespace OpenSim.Framework { configurationPluginFilename = dll_filename; } - 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; @@ -92,7 +97,8 @@ namespace OpenSim.Framework configOption.configurationType = configuration_type; configOption.configurationUseDefaultNoPrompt = use_default_no_prompt; - if ((configuration_key != "" && configuration_question != "") || (configuration_key != "" && use_default_no_prompt)) + if ((configuration_key != "" && configuration_question != "") || + (configuration_key != "" && use_default_no_prompt)) { if (!configurationOptions.Contains(configOption)) { @@ -101,32 +107,37 @@ namespace OpenSim.Framework } else { - MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")"); + MainLog.Instance.Notice( + "Required fields for adding a configuration option is invalid. Will not add this option (" + + configuration_key + ")"); } } 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("Calling Configuration Load Function..."); - this.loadFunction(); + loadFunction(); - if(configurationOptions.Count <= 0) + if (configurationOptions.Count <= 0) { - MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration."); + MainLog.Instance.Error("No configuration options were specified for '" + configurationOptions + + "'. Refusing to continue configuration."); return; } @@ -157,7 +168,6 @@ namespace OpenSim.Framework bool ignoreNextFromConfig = false; while (convertSuccess == false) { - string console_result = ""; string attribute = null; if (useFile) @@ -180,16 +190,20 @@ namespace OpenSim.Framework } else { - 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 { @@ -252,7 +266,6 @@ namespace OpenSim.Framework { convertSuccess = true; return_result = intResult; - } errorMessage = "a signed 32 bit integer (int)"; break; @@ -307,7 +320,6 @@ namespace OpenSim.Framework { convertSuccess = true; return_result = uintResult; - } errorMessage = "an unsigned 32 bit integer (uint)"; break; @@ -322,7 +334,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; @@ -331,7 +345,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; @@ -348,9 +364,10 @@ namespace OpenSim.Framework } - 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; } @@ -359,19 +376,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(); @@ -393,7 +418,8 @@ namespace OpenSim.Framework if (typeInterface != null) { - plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug = + (IGenericConfig) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); } } } @@ -405,10 +431,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/General/ConfigurationOption.cs b/OpenSim/Framework/General/ConfigurationOption.cs index 792e697..5a8fd08 100644 --- a/OpenSim/Framework/General/ConfigurationOption.cs +++ b/OpenSim/Framework/General/ConfigurationOption.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Framework { public class ConfigurationOption @@ -40,7 +36,7 @@ namespace OpenSim.Framework TYPE_STRING_NOT_EMPTY, TYPE_UINT16, TYPE_UINT32, - TYPE_UINT64, + TYPE_UINT64, TYPE_INT16, TYPE_INT32, TYPE_INT64, @@ -52,7 +48,7 @@ namespace OpenSim.Framework TYPE_LLVECTOR3, TYPE_FLOAT, TYPE_DOUBLE - }; + } ; public string configurationKey = ""; public string configurationQuestion = ""; @@ -61,4 +57,4 @@ namespace OpenSim.Framework public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING; public bool configurationUseDefaultNoPrompt = false; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/Culture.cs b/OpenSim/Framework/General/Culture.cs index 54eae7c..f8cadfe 100644 --- a/OpenSim/Framework/General/Culture.cs +++ b/OpenSim/Framework/General/Culture.cs @@ -27,31 +27,23 @@ */ using System; -using System.Collections.Generic; using System.Globalization; -using System.Text; using System.Threading; namespace OpenSim.Framework { public class Culture { - private static readonly CultureInfo m_cultureInfo = new System.Globalization.CultureInfo("en-US", true); + private static readonly CultureInfo m_cultureInfo = new CultureInfo("en-US", true); public static NumberFormatInfo NumberFormatInfo { - get - { - return m_cultureInfo.NumberFormat; - } + get { return m_cultureInfo.NumberFormat; } } public static IFormatProvider FormatProvider { - get - { - return m_cultureInfo; - } + get { return m_cultureInfo; } } public static void SetCurrentCulture() @@ -59,4 +51,4 @@ namespace OpenSim.Framework Thread.CurrentThread.CurrentCulture = m_cultureInfo; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/EstateSettings.cs b/OpenSim/Framework/General/EstateSettings.cs index 3e99424..c70b6ca 100644 --- a/OpenSim/Framework/General/EstateSettings.cs +++ b/OpenSim/Framework/General/EstateSettings.cs @@ -25,24 +25,20 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using System.IO; using libsecondlife; -using OpenSim.Framework; -using System.Globalization; namespace OpenSim.Framework { public class EstateSettings { - //Settings to this island private float m_billableFactor; + public float billableFactor { - get - { - return m_billableFactor; - } + get { return m_billableFactor; } set { m_billableFactor = value; @@ -52,12 +48,10 @@ namespace OpenSim.Framework private uint m_estateID; + public uint estateID { - get - { - return m_estateID; - } + get { return m_estateID; } set { m_estateID = value; @@ -67,12 +61,10 @@ namespace OpenSim.Framework private uint m_parentEstateID; + public uint parentEstateID { - get - { - return m_parentEstateID; - } + get { return m_parentEstateID; } set { m_parentEstateID = value; @@ -81,12 +73,10 @@ namespace OpenSim.Framework } private byte m_maxAgents; + public byte maxAgents { - get - { - return m_maxAgents; - } + get { return m_maxAgents; } set { m_maxAgents = value; @@ -95,12 +85,10 @@ namespace OpenSim.Framework } private float m_objectBonusFactor; + public float objectBonusFactor { - get - { - return m_objectBonusFactor; - } + get { return m_objectBonusFactor; } set { m_objectBonusFactor = value; @@ -109,12 +97,10 @@ namespace OpenSim.Framework } private int m_redirectGridX; + public int redirectGridX { - get - { - return m_redirectGridX; - } + get { return m_redirectGridX; } set { m_redirectGridX = value; @@ -123,12 +109,10 @@ namespace OpenSim.Framework } private int m_redirectGridY; + public int redirectGridY { - get - { - return m_redirectGridY; - } + get { return m_redirectGridY; } set { m_redirectGridY = value; @@ -137,12 +121,10 @@ namespace OpenSim.Framework } private Simulator.RegionFlags m_regionFlags; + public Simulator.RegionFlags regionFlags { - get - { - return m_regionFlags; - } + get { return m_regionFlags; } set { m_regionFlags = value; @@ -152,12 +134,10 @@ namespace OpenSim.Framework private Simulator.SimAccess m_simAccess; + public Simulator.SimAccess simAccess { - get - { - return m_simAccess; - } + get { return m_simAccess; } set { m_simAccess = value; @@ -166,12 +146,10 @@ namespace OpenSim.Framework } private float m_sunHour; + public float sunHour { - get - { - return m_sunHour; - } + get { return m_sunHour; } set { m_sunHour = value; @@ -180,12 +158,10 @@ namespace OpenSim.Framework } private float m_terrainRaiseLimit; + public float terrainRaiseLimit { - get - { - return m_terrainRaiseLimit; - } + get { return m_terrainRaiseLimit; } set { m_terrainRaiseLimit = value; @@ -194,12 +170,10 @@ namespace OpenSim.Framework } private float m_terrainLowerLimit; + public float terrainLowerLimit { - get - { - return m_terrainLowerLimit; - } + get { return m_terrainLowerLimit; } set { m_terrainLowerLimit = value; @@ -208,12 +182,10 @@ namespace OpenSim.Framework } private bool m_useFixedSun; + public bool useFixedSun { - get - { - return m_useFixedSun; - } + get { return m_useFixedSun; } set { m_useFixedSun = value; @@ -223,12 +195,10 @@ namespace OpenSim.Framework private int m_pricePerMeter; + public int pricePerMeter { - get - { - return m_pricePerMeter; - } + get { return m_pricePerMeter; } set { m_pricePerMeter = value; @@ -238,12 +208,10 @@ namespace OpenSim.Framework private ushort m_regionWaterHeight; + public ushort regionWaterHeight { - get - { - return m_regionWaterHeight; - } + get { return m_regionWaterHeight; } set { m_regionWaterHeight = value; @@ -253,12 +221,10 @@ namespace OpenSim.Framework private bool m_regionAllowTerraform; + public bool regionAllowTerraform { - get - { - return m_regionAllowTerraform; - } + get { return m_regionAllowTerraform; } set { m_regionAllowTerraform = value; @@ -266,16 +232,14 @@ namespace OpenSim.Framework } } - + // Region Information // Low resolution 'base' textures. No longer used. private LLUUID m_terrainBase0; + public LLUUID terrainBase0 { - get - { - return m_terrainBase0; - } + get { return m_terrainBase0; } set { m_terrainBase0 = value; @@ -284,12 +248,10 @@ namespace OpenSim.Framework } private LLUUID m_terrainBase1; + public LLUUID terrainBase1 { - get - { - return m_terrainBase1; - } + get { return m_terrainBase1; } set { m_terrainBase1 = value; @@ -298,12 +260,10 @@ namespace OpenSim.Framework } private LLUUID m_terrainBase2; + public LLUUID terrainBase2 { - get - { - return m_terrainBase2; - } + get { return m_terrainBase2; } set { m_terrainBase2 = value; @@ -312,12 +272,10 @@ namespace OpenSim.Framework } private LLUUID m_terrainBase3; + public LLUUID terrainBase3 { - get - { - return m_terrainBase3; - } + get { return m_terrainBase3; } set { m_terrainBase3 = value; @@ -328,53 +286,46 @@ namespace OpenSim.Framework // Higher resolution terrain textures private LLUUID m_terrainDetail0; + public LLUUID terrainDetail0 { - get - { - return m_terrainDetail0; - } + get { return m_terrainDetail0; } set { - m_terrainDetail0 = value; configMember.forceSetConfigurationOption("terrain_detail_0", m_terrainDetail0.ToString()); } } private LLUUID m_terrainDetail1; + public LLUUID terrainDetail1 { - get - { - return m_terrainDetail1; - } + get { return m_terrainDetail1; } set { m_terrainDetail1 = value; configMember.forceSetConfigurationOption("terrain_detail_1", m_terrainDetail1.ToString()); } } + private LLUUID m_terrainDetail2; + public LLUUID terrainDetail2 { - get - { - return m_terrainDetail2; - } + get { return m_terrainDetail2; } set { m_terrainDetail2 = value; configMember.forceSetConfigurationOption("terrain_detail_2", m_terrainDetail2.ToString()); } } + private LLUUID m_terrainDetail3; + public LLUUID terrainDetail3 { - get - { - return m_terrainDetail3; - } + get { return m_terrainDetail3; } set { m_terrainDetail3 = value; @@ -384,12 +335,10 @@ namespace OpenSim.Framework // First quad - each point is bilinearly interpolated at each meter of terrain private float m_terrainStartHeight0; + public float terrainStartHeight0 { - get - { - return m_terrainStartHeight0; - } + get { return m_terrainStartHeight0; } set { m_terrainStartHeight0 = value; @@ -399,12 +348,10 @@ namespace OpenSim.Framework private float m_terrainStartHeight1; + public float terrainStartHeight1 { - get - { - return m_terrainStartHeight1; - } + get { return m_terrainStartHeight1; } set { m_terrainStartHeight1 = value; @@ -413,12 +360,10 @@ namespace OpenSim.Framework } private float m_terrainStartHeight2; + public float terrainStartHeight2 { - get - { - return m_terrainStartHeight2; - } + get { return m_terrainStartHeight2; } set { m_terrainStartHeight2 = value; @@ -427,28 +372,25 @@ namespace OpenSim.Framework } private float m_terrainStartHeight3; + public float terrainStartHeight3 { - get - { - return m_terrainStartHeight3; - } + get { return m_terrainStartHeight3; } set { m_terrainStartHeight3 = value; configMember.forceSetConfigurationOption("terrain_start_height_3", m_terrainStartHeight3.ToString()); } } + // Second quad - also bilinearly interpolated. // Terrain texturing is done that: // 0..3 (0 = base0, 3 = base3) = (terrain[x,y] - start[x,y]) / range[x,y] private float m_terrainHeightRange0; + public float terrainHeightRange0 { - get - { - return m_terrainHeightRange0; - } + get { return m_terrainHeightRange0; } set { m_terrainHeightRange0 = value; @@ -457,12 +399,10 @@ namespace OpenSim.Framework } private float m_terrainHeightRange1; + public float terrainHeightRange1 { - get - { - return m_terrainHeightRange1; - } + get { return m_terrainHeightRange1; } set { m_terrainHeightRange1 = value; @@ -471,12 +411,10 @@ namespace OpenSim.Framework } private float m_terrainHeightRange2; + public float terrainHeightRange2 { - get - { - return m_terrainHeightRange2; - } + get { return m_terrainHeightRange2; } set { m_terrainHeightRange2 = value; @@ -485,26 +423,23 @@ namespace OpenSim.Framework } private float m_terrainHeightRange3; + public float terrainHeightRange3 { - get - { - return m_terrainHeightRange3; - } + get { return m_terrainHeightRange3; } set { m_terrainHeightRange3 = value; configMember.forceSetConfigurationOption("terrain_height_range_3", m_terrainHeightRange3.ToString()); } } + // Terrain Default (Must be in F32 Format!) private string m_terrainFile; + public string terrainFile { - get - { - return m_terrainFile; - } + get { return m_terrainFile; } set { m_terrainFile = value; @@ -513,12 +448,10 @@ namespace OpenSim.Framework } private double m_terrainMultiplier; + public double terrainMultiplier { - get - { - return m_terrainMultiplier; - } + get { return m_terrainMultiplier; } set { m_terrainMultiplier = value; @@ -527,12 +460,10 @@ namespace OpenSim.Framework } private float m_waterHeight; + public float waterHeight { - get - { - return m_waterHeight; - } + get { return m_waterHeight; } set { m_waterHeight = value; @@ -541,73 +472,112 @@ namespace OpenSim.Framework } private LLUUID m_terrainImageID; + public LLUUID terrainImageID { - get - { - return m_terrainImageID; - } + get { return m_terrainImageID; } set { m_terrainImageID = value; configMember.forceSetConfigurationOption("terrain_image_id", m_terrainImageID.ToString()); } } + private ConfigurationMember configMember; + public EstateSettings() { // Temporary hack to prevent multiple loadings. if (configMember == null) { - configMember = new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", this.loadConfigurationOptions, this.handleIncomingConfiguration); + configMember = + new ConfigurationMember(Path.Combine(Util.configDir(), "estate_settings.xml"), "ESTATE SETTINGS", + loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } } public void loadConfigurationOptions() { - configMember.addConfigurationOption("billable_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "","0.0",true); - configMember.addConfigurationOption("estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "","0",true); - configMember.addConfigurationOption("parent_estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", "0", true); - configMember.addConfigurationOption("max_agents", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, "", "40", true); - - configMember.addConfigurationOption("object_bonus_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "1.0", true); - configMember.addConfigurationOption("redirect_grid_x", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "", "0", true); - configMember.addConfigurationOption("redirect_grid_y", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "", "0", true); - configMember.addConfigurationOption("region_flags", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", "0", true); - configMember.addConfigurationOption("sim_access", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, "", "21", true); - configMember.addConfigurationOption("sun_hour", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "0", true); - configMember.addConfigurationOption("terrain_raise_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "0", true); - configMember.addConfigurationOption("terrain_lower_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "0", true); - configMember.addConfigurationOption("use_fixed_sun", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "", "false", true); - configMember.addConfigurationOption("price_per_meter", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", "1", true); - configMember.addConfigurationOption("region_water_height", ConfigurationOption.ConfigurationTypes.TYPE_UINT16, "", "20", true); - configMember.addConfigurationOption("region_allow_terraform", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "", "true", true); - - configMember.addConfigurationOption("terrain_base_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "b8d3965a-ad78-bf43-699b-bff8eca6c975", true); - configMember.addConfigurationOption("terrain_base_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "abb783e6-3e93-26c0-248a-247666855da3", true); - configMember.addConfigurationOption("terrain_base_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "179cdabd-398a-9b6b-1391-4dc333ba321f", true); - configMember.addConfigurationOption("terrain_base_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "beb169c7-11ea-fff2-efe5-0f24dc881df2", true); - - configMember.addConfigurationOption("terrain_detail_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("terrain_detail_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("terrain_detail_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true); - configMember.addConfigurationOption("terrain_detail_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true); - - configMember.addConfigurationOption("terrain_start_height_0", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); - configMember.addConfigurationOption("terrain_start_height_1", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); - configMember.addConfigurationOption("terrain_start_height_2", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); - configMember.addConfigurationOption("terrain_start_height_3", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); - - configMember.addConfigurationOption("terrain_height_range_0", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); - configMember.addConfigurationOption("terrain_height_range_1", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); - configMember.addConfigurationOption("terrain_height_range_2", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); - configMember.addConfigurationOption("terrain_height_range_3", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); - - configMember.addConfigurationOption("terrain_file", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "", "default.r32", true); - configMember.addConfigurationOption("terrain_multiplier", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); - configMember.addConfigurationOption("water_height", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, "", "20.0", true); - configMember.addConfigurationOption("terrain_image_id", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", "00000000-0000-0000-0000-000000000000", true); + configMember.addConfigurationOption("billable_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", + "0.0", true); + configMember.addConfigurationOption("estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", "0", + true); + configMember.addConfigurationOption("parent_estate_id", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "", "0", true); + configMember.addConfigurationOption("max_agents", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, "", "40", + true); + + configMember.addConfigurationOption("object_bonus_factor", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, + "", "1.0", true); + configMember.addConfigurationOption("redirect_grid_x", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "", + "0", true); + configMember.addConfigurationOption("redirect_grid_y", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "", + "0", true); + configMember.addConfigurationOption("region_flags", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "", + "0", true); + configMember.addConfigurationOption("sim_access", ConfigurationOption.ConfigurationTypes.TYPE_BYTE, "", "21", + true); + configMember.addConfigurationOption("sun_hour", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "0", + true); + configMember.addConfigurationOption("terrain_raise_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, + "", "0", true); + configMember.addConfigurationOption("terrain_lower_limit", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, + "", "0", true); + configMember.addConfigurationOption("use_fixed_sun", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "", + "false", true); + configMember.addConfigurationOption("price_per_meter", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "", "1", true); + configMember.addConfigurationOption("region_water_height", + ConfigurationOption.ConfigurationTypes.TYPE_UINT16, "", "20", true); + configMember.addConfigurationOption("region_allow_terraform", + ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "", "true", true); + + configMember.addConfigurationOption("terrain_base_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", + "b8d3965a-ad78-bf43-699b-bff8eca6c975", true); + configMember.addConfigurationOption("terrain_base_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", + "abb783e6-3e93-26c0-248a-247666855da3", true); + configMember.addConfigurationOption("terrain_base_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", + "179cdabd-398a-9b6b-1391-4dc333ba321f", true); + configMember.addConfigurationOption("terrain_base_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, "", + "beb169c7-11ea-fff2-efe5-0f24dc881df2", true); + + configMember.addConfigurationOption("terrain_detail_0", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "", "00000000-0000-0000-0000-000000000000", true); + configMember.addConfigurationOption("terrain_detail_1", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "", "00000000-0000-0000-0000-000000000000", true); + configMember.addConfigurationOption("terrain_detail_2", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "", "00000000-0000-0000-0000-000000000000", true); + configMember.addConfigurationOption("terrain_detail_3", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "", "00000000-0000-0000-0000-000000000000", true); + + configMember.addConfigurationOption("terrain_start_height_0", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); + configMember.addConfigurationOption("terrain_start_height_1", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); + configMember.addConfigurationOption("terrain_start_height_2", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); + configMember.addConfigurationOption("terrain_start_height_3", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "10.0", true); + + configMember.addConfigurationOption("terrain_height_range_0", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); + configMember.addConfigurationOption("terrain_height_range_1", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); + configMember.addConfigurationOption("terrain_height_range_2", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); + configMember.addConfigurationOption("terrain_height_range_3", + ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, "", "60.0", true); + + configMember.addConfigurationOption("terrain_file", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "", + "default.r32", true); + configMember.addConfigurationOption("terrain_multiplier", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT, + "", "60.0", true); + configMember.addConfigurationOption("water_height", ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE, "", + "20.0", true); + configMember.addConfigurationOption("terrain_image_id", ConfigurationOption.ConfigurationTypes.TYPE_LLUUID, + "", "00000000-0000-0000-0000-000000000000", true); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -615,123 +585,123 @@ namespace OpenSim.Framework switch (configuration_key) { case "billable_factor": - this.m_billableFactor = (float)configuration_result; + m_billableFactor = (float) configuration_result; break; case "estate_id": - this.m_estateID = (uint)configuration_result; + m_estateID = (uint) configuration_result; break; case "parent_estate_id": - this.m_parentEstateID = (uint)configuration_result; + m_parentEstateID = (uint) configuration_result; break; case "max_agents": - this.m_maxAgents = (byte)configuration_result; + m_maxAgents = (byte) configuration_result; break; case "object_bonus_factor": - this.m_objectBonusFactor = (float)configuration_result; + m_objectBonusFactor = (float) configuration_result; break; case "redirect_grid_x": - this.m_redirectGridX = (int)configuration_result; + m_redirectGridX = (int) configuration_result; break; case "redirect_grid_y": - this.m_redirectGridY = (int)configuration_result; + m_redirectGridY = (int) configuration_result; break; case "region_flags": - this.m_regionFlags = (Simulator.RegionFlags)((uint)configuration_result); + m_regionFlags = (Simulator.RegionFlags) ((uint) configuration_result); break; case "sim_access": - this.m_simAccess = (Simulator.SimAccess)((byte)configuration_result); + m_simAccess = (Simulator.SimAccess) ((byte) configuration_result); break; case "sun_hour": - this.m_sunHour = (float)configuration_result; + m_sunHour = (float) configuration_result; break; case "terrain_raise_limit": - this.m_terrainRaiseLimit = (float)configuration_result; + m_terrainRaiseLimit = (float) configuration_result; break; case "terrain_lower_limit": - this.m_terrainLowerLimit = (float)configuration_result; + m_terrainLowerLimit = (float) configuration_result; break; case "use_fixed_sun": - this.m_useFixedSun = (bool)configuration_result; + m_useFixedSun = (bool) configuration_result; break; case "price_per_meter": - this.m_pricePerMeter = System.Convert.ToInt32(configuration_result); + m_pricePerMeter = Convert.ToInt32(configuration_result); break; case "region_water_height": - this.m_regionWaterHeight = (ushort)configuration_result; + m_regionWaterHeight = (ushort) configuration_result; break; case "region_allow_terraform": - this.m_regionAllowTerraform = (bool)configuration_result; + m_regionAllowTerraform = (bool) configuration_result; break; case "terrain_base_0": - this.m_terrainBase0 = (LLUUID)configuration_result; + m_terrainBase0 = (LLUUID) configuration_result; break; case "terrain_base_1": - this.m_terrainBase1 = (LLUUID)configuration_result; + m_terrainBase1 = (LLUUID) configuration_result; break; case "terrain_base_2": - this.m_terrainBase2 = (LLUUID)configuration_result; + m_terrainBase2 = (LLUUID) configuration_result; break; case "terrain_base_3": - this.m_terrainBase3 = (LLUUID)configuration_result; + m_terrainBase3 = (LLUUID) configuration_result; break; case "terrain_detail_0": - this.m_terrainDetail0 = (LLUUID)configuration_result; + m_terrainDetail0 = (LLUUID) configuration_result; break; case "terrain_detail_1": - this.m_terrainDetail1 = (LLUUID)configuration_result; + m_terrainDetail1 = (LLUUID) configuration_result; break; case "terrain_detail_2": - this.m_terrainDetail2 = (LLUUID)configuration_result; + m_terrainDetail2 = (LLUUID) configuration_result; break; case "terrain_detail_3": - this.m_terrainDetail3 = (LLUUID)configuration_result; + m_terrainDetail3 = (LLUUID) configuration_result; break; case "terrain_start_height_0": - this.m_terrainStartHeight0 = (float)configuration_result; + m_terrainStartHeight0 = (float) configuration_result; break; case "terrain_start_height_1": - this.m_terrainStartHeight1 = (float)configuration_result; + m_terrainStartHeight1 = (float) configuration_result; break; case "terrain_start_height_2": - this.m_terrainStartHeight2 = (float)configuration_result; + m_terrainStartHeight2 = (float) configuration_result; break; case "terrain_start_height_3": - this.m_terrainStartHeight3 = (float)configuration_result; + m_terrainStartHeight3 = (float) configuration_result; break; case "terrain_height_range_0": - this.m_terrainHeightRange0 = (float)configuration_result; + m_terrainHeightRange0 = (float) configuration_result; break; case "terrain_height_range_1": - this.m_terrainHeightRange1 = (float)configuration_result; + m_terrainHeightRange1 = (float) configuration_result; break; case "terrain_height_range_2": - this.m_terrainHeightRange2 = (float)configuration_result; + m_terrainHeightRange2 = (float) configuration_result; break; case "terrain_height_range_3": - this.m_terrainHeightRange3 = (float)configuration_result; + m_terrainHeightRange3 = (float) configuration_result; break; case "terrain_file": - this.m_terrainFile = (string)configuration_result; + m_terrainFile = (string) configuration_result; break; case "terrain_multiplier": - this.m_terrainMultiplier = System.Convert.ToDouble(configuration_result); + m_terrainMultiplier = Convert.ToDouble(configuration_result); break; case "water_height": double tmpVal = (double) configuration_result; - this.m_waterHeight = (float) tmpVal; + m_waterHeight = (float) tmpVal; break; case "terrain_image_id": - this.m_terrainImageID = (LLUUID)configuration_result; + m_terrainImageID = (LLUUID) configuration_result; break; } return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/GridConfig.cs b/OpenSim/Framework/General/GridConfig.cs index 64ce3b1..66d6c3a 100644 --- a/OpenSim/Framework/General/GridConfig.cs +++ b/OpenSim/Framework/General/GridConfig.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Framework { public class GridConfig @@ -50,30 +46,49 @@ namespace OpenSim.Framework public static uint DefaultHttpPort = 8001; public uint HttpPort = DefaultHttpPort; - + private ConfigurationMember configMember; + public GridConfig(string description, string filename) { - configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration); + configMember = + new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } public void loadConfigurationOptions() { - configMember.addConfigurationOption("grid_owner", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "OGS Grid Owner", "OGS development team", false); - configMember.addConfigurationOption("default_asset_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Asset Server URI", "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString() + "/", false); - configMember.addConfigurationOption("asset_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to asset server", "null", false); - configMember.addConfigurationOption("asset_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from asset server", "null", false); + configMember.addConfigurationOption("grid_owner", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "OGS Grid Owner", "OGS development team", false); + configMember.addConfigurationOption("default_asset_server", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Default Asset Server URI", + "http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString() + "/", + false); + configMember.addConfigurationOption("asset_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to send to asset server", "null", false); + configMember.addConfigurationOption("asset_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to expect from asset server", "null", false); - configMember.addConfigurationOption("default_user_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default User Server URI", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/", false); - configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false); - configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false); + configMember.addConfigurationOption("default_user_server", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Default User Server URI", + "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/", false); + configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to send to user server", "null", false); + configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to expect from user server", "null", false); - configMember.addConfigurationOption("sim_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to a simulator", "null", false); - configMember.addConfigurationOption("sim_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from a simulator", "null", false); - configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); + configMember.addConfigurationOption("sim_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to send to a simulator", "null", false); + configMember.addConfigurationOption("sim_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to expect from a simulator", "null", false); + configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); - configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false); + configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Http Listener port", DefaultHttpPort.ToString(), false); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -81,41 +96,41 @@ namespace OpenSim.Framework switch (configuration_key) { case "grid_owner": - this.GridOwner = (string)configuration_result; + GridOwner = (string) configuration_result; break; case "default_asset_server": - this.DefaultAssetServer = (string)configuration_result; + DefaultAssetServer = (string) configuration_result; break; case "asset_send_key": - this.AssetSendKey = (string)configuration_result; + AssetSendKey = (string) configuration_result; break; case "asset_recv_key": - this.AssetRecvKey = (string)configuration_result; + AssetRecvKey = (string) configuration_result; break; case "default_user_server": - this.DefaultUserServer = (string)configuration_result; + DefaultUserServer = (string) configuration_result; break; case "user_send_key": - this.UserSendKey = (string)configuration_result; + UserSendKey = (string) configuration_result; break; case "user_recv_key": - this.UserRecvKey = (string)configuration_result; + UserRecvKey = (string) configuration_result; break; case "sim_send_key": - this.SimSendKey = (string)configuration_result; + SimSendKey = (string) configuration_result; break; case "sim_recv_key": - this.SimRecvKey = (string)configuration_result; + SimRecvKey = (string) configuration_result; break; case "database_provider": - this.DatabaseProvider = (string)configuration_result; + DatabaseProvider = (string) configuration_result; break; case "http_port": - HttpPort = (uint)configuration_result; + HttpPort = (uint) configuration_result; break; } return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IAssetProvider.cs b/OpenSim/Framework/General/IAssetProvider.cs index 42dbf1f..f452822 100644 --- a/OpenSim/Framework/General/IAssetProvider.cs +++ b/OpenSim/Framework/General/IAssetProvider.cs @@ -26,15 +26,11 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework; using libsecondlife; namespace OpenSim.Framework { - public interface IAssetProvider : IPlugin + public interface IAssetProvider : IPlugin { AssetBase FetchAsset(LLUUID uuid); void CreateAsset(AssetBase asset); @@ -42,4 +38,4 @@ namespace OpenSim.Framework bool ExistsAsset(LLUUID uuid); void CommitAssets(); // force a sync to the database } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IAssetServer.cs b/OpenSim/Framework/General/IAssetServer.cs index ae86c8c..f4cb533 100644 --- a/OpenSim/Framework/General/IAssetServer.cs +++ b/OpenSim/Framework/General/IAssetServer.cs @@ -28,14 +28,12 @@ using System; using System.Collections.Generic; using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework { /// /// Description of IAssetServer. /// - public interface IAssetServer { void SetReceiver(IAssetReceiver receiver); @@ -68,4 +66,4 @@ namespace OpenSim.Framework public LLUUID AssetID; public bool IsTexture; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IClientAPI.cs b/OpenSim/Framework/General/IClientAPI.cs index 8c81eae..c7ec514 100644 --- a/OpenSim/Framework/General/IClientAPI.cs +++ b/OpenSim/Framework/General/IClientAPI.cs @@ -30,31 +30,28 @@ using System.Collections.Generic; using System.Net; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework; namespace OpenSim.Framework { // Base Args Interface public interface IEventArgs { - IScene Scene - { - get; - set; - } + IScene Scene { get; set; } - IClientAPI Sender - { - get; - set; - } + IClientAPI Sender { get; set; } } public delegate void ViewerEffectEventHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock); public delegate void ChatFromViewer(Object sender, ChatFromViewerArgs e); - public enum ChatTypeEnum { Whisper = 0, Say = 1, Shout = 2, Broadcast = 0xFF }; + public enum ChatTypeEnum + { + Whisper = 0, + Say = 1, + Shout = 2, + Broadcast = 0xFF + } ; /// /// ChatFromViewer Arguments @@ -163,68 +160,127 @@ namespace OpenSim.Framework public delegate void TextureRequest(Object sender, TextureRequestArgs e); - public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list + public delegate void ImprovedInstantMessage( + LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, + string fromAgentName, string message, byte dialog); // Cut down from full list 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, IClientAPI remoteClient); + + public delegate void ModifyTerrain( + float height, float seconds, byte size, byte action, float north, float west, IClientAPI remoteClient); + public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam); + public delegate void StartAnim(IClientAPI remoteClient, LLUUID animID, int seq); + public delegate void LinkObjects(uint parent, List children); + public delegate void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY); - public delegate void TeleportLocationRequest(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags); + + public delegate void TeleportLocationRequest( + IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags); + public delegate void DisconnectUser(); + public delegate void RequestAvatarProperties(IClientAPI remoteClient, LLUUID avatarID); public delegate void GenericCall(IClientAPI remoteClient); + public delegate void GenericCall2(); - public delegate void GenericCall3(Packet packet); // really don't want to be passing packets in these events, so this is very temporary. + + public delegate void GenericCall3(Packet packet); + + // really don't want to be passing packets in these events, so this is very temporary. public delegate void GenericCall4(Packet packet, IClientAPI remoteClient); + public delegate void GenericCall5(IClientAPI remoteClient, bool status); + public delegate void GenericCall6(LLUUID uid); + public delegate void GenericCall7(uint localID, string message); public delegate void UpdateShape(uint localID, ObjectShapePacket.ObjectDataBlock shapeBlock); + public delegate void ObjectExtraParams(uint localID, ushort type, bool inUse, byte[] data); + public delegate void ObjectSelect(uint localID, IClientAPI remoteClient); + public delegate void ObjectDeselect(uint localID, IClientAPI remoteClient); + public delegate void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient); + public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient); + public delegate void UpdateVector(uint localID, LLVector3 pos, IClientAPI remoteClient); + public delegate void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient); + public delegate void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient); - public delegate void UpdatePrimGroupRotation(uint localID,LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient); + + public delegate void UpdatePrimGroupRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient); + public delegate void ObjectDuplicate(uint localID, LLVector3 offset, uint dupeFlags); + public delegate void StatusChange(bool status); + public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status); + public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); + public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID); + public delegate void AgentSit(IClientAPI remoteClient, LLUUID agentID); + public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient); - 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); + 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); + public delegate void ParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client); + public delegate void ParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client); + public delegate void ParcelPropertiesUpdateRequest(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client); + public delegate void ParcelSelectObjects(int land_local_id, int request_type, IClientAPI remote_client); + public delegate void ParcelObjectOwnerRequest(int local_id, IClientAPI remote_client); + public delegate void EstateOwnerMessageRequest(EstateOwnerMessagePacket packet, IClientAPI remote_client); public delegate void UUIDNameRequest(LLUUID id, IClientAPI remote_client); public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape); - public delegate void CreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); - public delegate void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask); - public delegate void FetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); + public delegate void CreateInventoryFolder( + IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID); + + public delegate void CreateNewInventoryItem( + IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, uint callbackID, string description, string name, + sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask); + + public delegate void FetchInventoryDescendents( + IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); + public delegate void FetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID); + public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID); - public delegate void UpdateInventoryItemTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID); + + public delegate void UpdateInventoryItemTransaction( + IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID); + public delegate void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID); + public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID); + 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); + public delegate void UDPAssetUploadRequest( + IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data, bool storeLocal); + 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 interface IClientAPI @@ -298,37 +354,17 @@ namespace OpenSim.Framework event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; event EstateOwnerMessageRequest OnEstateOwnerMessage; - LLVector3 StartPos - { - get; - set; - } + LLVector3 StartPos { get; set; } - LLUUID AgentId - { - get; - } + LLUUID AgentId { get; } - LLUUID SessionId - { - get; - } + LLUUID SessionId { get; } - string FirstName - { - get; - } + string FirstName { get; } - string LastName - { - get; - } + string LastName { get; } - uint CircuitCode - { - get; - set; - } + uint CircuitCode { get; set; } void OutPacket(Packet newPack); void SendWearables(AvatarWearable[] wearables); @@ -339,28 +375,46 @@ namespace OpenSim.Framework void SendRegionHandshake(RegionInfo regionInfo); void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID); void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID); - void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, LLUUID imSessionID, string fromName, byte dialog, uint timeStamp); + + void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, + LLUUID imSessionID, string fromName, byte dialog, uint timeStamp); + void SendLayerData(float[] map); void SendLayerData(int px, int py, float[] map); void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look); - void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint ); + void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint); AgentCircuitData RequestClientInfo(); - void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL ); + + void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint, + string capsURL); + void SendMapBlock(List mapBlocks); void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags); - void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL); + + void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, + uint flags, string capsURL); + void SendTeleportCancel(); void SendTeleportLocationStart(); void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance); - void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID); - void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation); + void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, + LLVector3 Pos, byte[] textureEntry, uint parentID); + + void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, + LLVector3 velocity, LLQuaternion rotation); + void SendCoarseLocationUpdate(List CoarseLocations); void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint); - void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID, byte[] particleSystem, LLQuaternion rotation); - void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation); - + + void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, + LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, + uint parentID, byte[] particleSystem, LLQuaternion rotation); + + void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, + LLQuaternion rotation); + void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items); void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item); void SendInventoryItemUpdate(InventoryItemBase Item); @@ -375,10 +429,13 @@ namespace OpenSim.Framework 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 ); + bool AddMoney(int debit); void SendViewerTime(int phase); - void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID); + + void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, + uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID); + void SetDebug(int newDebug); void InPacket(Packet NewPack); void Close(); @@ -387,4 +444,4 @@ namespace OpenSim.Framework event Action OnConnectionClosed; void SendLogoutPacket(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IGenericConfig.cs b/OpenSim/Framework/General/IGenericConfig.cs index 8d45d47..0c9ee1e 100644 --- a/OpenSim/Framework/General/IGenericConfig.cs +++ b/OpenSim/Framework/General/IGenericConfig.cs @@ -37,4 +37,4 @@ namespace OpenSim.Framework void Commit(); void Close(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IPlugin.cs b/OpenSim/Framework/General/IPlugin.cs index 6926ef4..cc835da 100644 --- a/OpenSim/Framework/General/IPlugin.cs +++ b/OpenSim/Framework/General/IPlugin.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Framework { /// @@ -54,4 +50,4 @@ namespace OpenSim.Framework /// void Initialise(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IRegionCommsListener.cs b/OpenSim/Framework/General/IRegionCommsListener.cs index 9ac9988..1a24469 100644 --- a/OpenSim/Framework/General/IRegionCommsListener.cs +++ b/OpenSim/Framework/General/IRegionCommsListener.cs @@ -27,14 +27,15 @@ */ using System.Collections.Generic; using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; namespace OpenSim.Framework { public delegate void ExpectUserDelegate(ulong regionHandle, AgentCircuitData agent); + public delegate void UpdateNeighbours(List neighbours); + public delegate void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); + public delegate void AcknowledgeAgentCross(ulong regionHandle, LLUUID agentID); public interface IRegionCommsListener @@ -45,4 +46,4 @@ namespace OpenSim.Framework event AcknowledgeAgentCross OnAcknowledgeAgentCrossed; event UpdateNeighbours OnNeighboursUpdate; } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IScene.cs b/OpenSim/Framework/General/IScene.cs index 9f03a04..cf5ee93 100644 --- a/OpenSim/Framework/General/IScene.cs +++ b/OpenSim/Framework/General/IScene.cs @@ -26,7 +26,6 @@ * */ using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework { @@ -34,14 +33,11 @@ namespace OpenSim.Framework { void AddNewClient(IClientAPI client, bool child); void RemoveClient(LLUUID agentID); - + RegionInfo RegionInfo { get; } object SyncRoot { get; } uint NextLocalId { get; } - ClientManager ClientManager - { - get; - } + ClientManager ClientManager { get; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IUserData.cs b/OpenSim/Framework/General/IUserData.cs index e1e9c99..b955ef1 100644 --- a/OpenSim/Framework/General/IUserData.cs +++ b/OpenSim/Framework/General/IUserData.cs @@ -26,7 +26,6 @@ * */ using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework { @@ -132,4 +131,4 @@ namespace OpenSim.Framework /// void Initialise(); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/IUserService.cs b/OpenSim/Framework/General/IUserService.cs index 400c12b..bf1c7e8 100644 --- a/OpenSim/Framework/General/IUserService.cs +++ b/OpenSim/Framework/General/IUserService.cs @@ -26,7 +26,6 @@ * */ using libsecondlife; -using OpenSim.Framework; namespace OpenSim.Framework.Interfaces { diff --git a/OpenSim/Framework/General/InventoryItemBase.cs b/OpenSim/Framework/General/InventoryItemBase.cs index 27124d9..45700ae 100644 --- a/OpenSim/Framework/General/InventoryItemBase.cs +++ b/OpenSim/Framework/General/InventoryItemBase.cs @@ -39,50 +39,62 @@ namespace OpenSim.Framework /// A UUID containing the ID for the inventory item itself /// public LLUUID inventoryID; + /// /// The UUID of the associated asset on the asset server /// public LLUUID assetID; + /// /// This is an enumerated value determining the type of asset (eg Notecard, Sound, Object, etc) /// public int assetType; + /// /// The type of inventory item. (Can be slightly different to the asset type /// public int invType; + /// /// The folder this item is contained in /// public LLUUID parentFolderID; + /// /// The owner of this inventory item /// public LLUUID avatarID; + /// /// The creator of this item /// public LLUUID creatorsID; + /// /// The name of the inventory item (must be less than 64 characters) /// public string inventoryName; + /// /// The description of the inventory item (must be less than 64 characters) /// public string inventoryDescription; + /// /// A mask containing the permissions for the next owner (cannot be enforced) /// public uint inventoryNextPermissions; + /// /// A mask containing permissions for the current owner (cannot be enforced) /// public uint inventoryCurrentPermissions; + /// /// /// public uint inventoryBasePermissions; + /// /// /// @@ -98,22 +110,27 @@ namespace OpenSim.Framework /// The name of the folder (64 characters or less) /// public string name; + /// /// The agent who's inventory this is contained by /// public LLUUID agentID; + /// /// The folder this folder is contained in /// public LLUUID parentID; + /// /// The UUID for this folder /// public LLUUID folderID; + /// /// Tyep of Items normally stored in this folder /// public short type; + /// /// /// @@ -225,4 +242,4 @@ namespace OpenSim.Framework /// The id of the folder void deleteInventoryFolder(LLUUID folder); } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/LandData.cs b/OpenSim/Framework/General/LandData.cs index 414b613..cab71a9 100644 --- a/OpenSim/Framework/General/LandData.cs +++ b/OpenSim/Framework/General/LandData.cs @@ -29,92 +29,95 @@ using libsecondlife; namespace OpenSim.Framework { - - public class LandData - { - public byte[] landBitmapByteArray = new byte[512]; - public string landName = "Your Parcel"; - public string landDesc = ""; - public LLUUID ownerID = new LLUUID(); - public bool isGroupOwned = false; - public LLVector3 AABBMin = new LLVector3(); - public LLVector3 AABBMax = new LLVector3(); - public int area = 0; - public uint auctionID = 0; //Unemplemented. If set to 0, not being auctioned - public LLUUID authBuyerID = new LLUUID(); //Unemplemented. Authorized Buyer's UUID - public Parcel.ParcelCategory category = new Parcel.ParcelCategory(); //Unemplemented. Parcel's chosen category - public int claimDate = 0; //Unemplemented - public int claimPrice = 0; //Unemplemented - public LLUUID groupID = new LLUUID(); //Unemplemented - public int groupPrims = 0; - public int otherPrims = 0; - public int ownerPrims = 0; - public int selectedPrims = 0; - public int simwidePrims = 0; - 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 | (uint)Parcel.ParcelFlags.CreateObjects | (uint)Parcel.ParcelFlags.AllowOtherScripts | (uint)Parcel.ParcelFlags.SoundLocal ; - public byte landingType = 0; - public byte mediaAutoScale = 0; - public LLUUID mediaID = LLUUID.Zero; - public int localID = 0; - public LLUUID globalID = new LLUUID(); + public class LandData + { + public byte[] landBitmapByteArray = new byte[512]; + public string landName = "Your Parcel"; + public string landDesc = ""; + public LLUUID ownerID = new LLUUID(); + public bool isGroupOwned = false; + public LLVector3 AABBMin = new LLVector3(); + public LLVector3 AABBMax = new LLVector3(); + public int area = 0; + public uint auctionID = 0; //Unemplemented. If set to 0, not being auctioned + public LLUUID authBuyerID = new LLUUID(); //Unemplemented. Authorized Buyer's UUID + public Parcel.ParcelCategory category = new Parcel.ParcelCategory(); //Unemplemented. Parcel's chosen category + public int claimDate = 0; //Unemplemented + public int claimPrice = 0; //Unemplemented + public LLUUID groupID = new LLUUID(); //Unemplemented + public int groupPrims = 0; + public int otherPrims = 0; + public int ownerPrims = 0; + public int selectedPrims = 0; + public int simwidePrims = 0; + 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 | + (uint) Parcel.ParcelFlags.CreateObjects | (uint) Parcel.ParcelFlags.AllowOtherScripts | + (uint) Parcel.ParcelFlags.SoundLocal; + + public byte landingType = 0; + public byte mediaAutoScale = 0; + public LLUUID mediaID = LLUUID.Zero; + public int localID = 0; + public LLUUID globalID = new LLUUID(); - public string mediaURL = ""; - public string musicURL = ""; - public float passHours = 0; - public int passPrice = 0; - public LLUUID snapshotID = LLUUID.Zero; - public LLVector3 userLocation = new LLVector3(); - public LLVector3 userLookAt = new LLVector3(); + public string mediaURL = ""; + public string musicURL = ""; + public float passHours = 0; + public int passPrice = 0; + public LLUUID snapshotID = LLUUID.Zero; + public LLVector3 userLocation = new LLVector3(); + public LLVector3 userLookAt = new LLVector3(); - public LandData() - { - globalID = LLUUID.Random(); - } + public LandData() + { + globalID = LLUUID.Random(); + } - public LandData Copy() - { - LandData landData = new LandData(); + public LandData Copy() + { + LandData landData = new LandData(); - landData.AABBMax = this.AABBMax; - landData.AABBMin = this.AABBMin; - landData.area = this.area; - landData.auctionID = this.auctionID; - landData.authBuyerID = this.authBuyerID; - landData.category = this.category; - landData.claimDate = this.claimDate; - landData.claimPrice = this.claimPrice; - landData.globalID = this.globalID; - landData.groupID = this.groupID; - landData.groupPrims = this.groupPrims; - landData.otherPrims = this.otherPrims; - landData.ownerPrims = this.ownerPrims; - landData.selectedPrims = this.selectedPrims; - landData.isGroupOwned = this.isGroupOwned; - landData.localID = this.localID; - landData.landingType = this.landingType; - landData.mediaAutoScale = this.mediaAutoScale; - landData.mediaID = this.mediaID; - landData.mediaURL = this.mediaURL; - landData.musicURL = this.musicURL; - landData.ownerID = this.ownerID; - landData.landBitmapByteArray = (byte[])this.landBitmapByteArray.Clone(); - landData.landDesc = this.landDesc; - landData.landFlags = this.landFlags; - landData.landName = this.landName; - landData.landStatus = this.landStatus; - landData.passHours = this.passHours; - landData.passPrice = this.passPrice; - landData.salePrice = this.salePrice; - landData.snapshotID = this.snapshotID; - landData.userLocation = this.userLocation; - landData.userLookAt = this.userLookAt; + landData.AABBMax = AABBMax; + landData.AABBMin = AABBMin; + landData.area = area; + landData.auctionID = auctionID; + landData.authBuyerID = authBuyerID; + landData.category = category; + landData.claimDate = claimDate; + landData.claimPrice = claimPrice; + landData.globalID = globalID; + landData.groupID = groupID; + landData.groupPrims = groupPrims; + landData.otherPrims = otherPrims; + landData.ownerPrims = ownerPrims; + landData.selectedPrims = selectedPrims; + landData.isGroupOwned = isGroupOwned; + landData.localID = localID; + landData.landingType = landingType; + landData.mediaAutoScale = mediaAutoScale; + landData.mediaID = mediaID; + landData.mediaURL = mediaURL; + landData.musicURL = musicURL; + landData.ownerID = ownerID; + landData.landBitmapByteArray = (byte[]) landBitmapByteArray.Clone(); + landData.landDesc = landDesc; + landData.landFlags = landFlags; + landData.landName = landName; + landData.landStatus = landStatus; + landData.passHours = passHours; + landData.passPrice = passPrice; + landData.salePrice = salePrice; + landData.snapshotID = snapshotID; + landData.userLocation = userLocation; + landData.userLookAt = userLookAt; - return landData; - - } + return landData; } - -} + } +} \ No newline at end of file diff --git a/OpenSim/Framework/General/Login.cs b/OpenSim/Framework/General/Login.cs index a55fd57..d9a5ab2 100644 --- a/OpenSim/Framework/General/Login.cs +++ b/OpenSim/Framework/General/Login.cs @@ -39,7 +39,7 @@ namespace OpenSim.Framework public LLUUID InventoryFolder; public LLUUID BaseFolder; public uint CircuitCode; - public string CapsPath =""; + public string CapsPath = ""; public LLVector3 StartPos; public Login() @@ -47,4 +47,4 @@ namespace OpenSim.Framework StartPos = new LLVector3(128, 128, 70); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/MapBlockData.cs b/OpenSim/Framework/General/MapBlockData.cs index eafd65d..d794015 100644 --- a/OpenSim/Framework/General/MapBlockData.cs +++ b/OpenSim/Framework/General/MapBlockData.cs @@ -45,7 +45,6 @@ namespace OpenSim.Framework public MapBlockData() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/NeighbourInfo.cs b/OpenSim/Framework/General/NeighbourInfo.cs index 771b844..457f7d0 100644 --- a/OpenSim/Framework/General/NeighbourInfo.cs +++ b/OpenSim/Framework/General/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/General/NetworkServersInfo.cs b/OpenSim/Framework/General/NetworkServersInfo.cs index 358e496..98d489e 100644 --- a/OpenSim/Framework/General/NetworkServersInfo.cs +++ b/OpenSim/Framework/General/NetworkServersInfo.cs @@ -25,12 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using Nini.Config; + namespace OpenSim.Framework { public class NetworkServersInfo @@ -63,12 +60,14 @@ namespace OpenSim.Framework } private uint? m_defaultHomeLocX; + public uint DefaultHomeLocX { get { return m_defaultHomeLocX.Value; } } private uint? m_defaultHomeLocY; + public uint DefaultHomeLocY { get { return m_defaultHomeLocY.Value; } @@ -76,19 +75,22 @@ namespace OpenSim.Framework public void loadFromConfiguration(IConfigSource config) { - m_defaultHomeLocX = (uint)config.Configs["StandAlone"].GetInt("default_location_x", 1000); - m_defaultHomeLocY = (uint)config.Configs["StandAlone"].GetInt("default_location_y", 1000); + m_defaultHomeLocX = (uint) config.Configs["StandAlone"].GetInt("default_location_x", 1000); + m_defaultHomeLocY = (uint) config.Configs["StandAlone"].GetInt("default_location_y", 1000); HttpListenerPort = config.Configs["Network"].GetInt("http_listener_port", DefaultHttpListenerPort); RemotingListenerPort = config.Configs["Network"].GetInt("remoting_listener_port", RemotingListenerPort); - GridURL = config.Configs["Network"].GetString("grid_server_url", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString()); + GridURL = + config.Configs["Network"].GetString("grid_server_url", + "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString()); GridSendKey = config.Configs["Network"].GetString("grid_send_key", "null"); GridRecvKey = config.Configs["Network"].GetString("grid_recv_key", "null"); - UserURL = config.Configs["Network"].GetString("user_server_url", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); + UserURL = + config.Configs["Network"].GetString("user_server_url", + "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString()); UserSendKey = config.Configs["Network"].GetString("user_send_key", "null"); UserRecvKey = config.Configs["Network"].GetString("user_recv_key", "null"); AssetURL = config.Configs["Network"].GetString("asset_server_url", AssetURL); - } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/PrimitiveBaseShape.cs b/OpenSim/Framework/General/PrimitiveBaseShape.cs index 1799fb8..2123ecb 100644 --- a/OpenSim/Framework/General/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/General/PrimitiveBaseShape.cs @@ -28,7 +28,6 @@ using System.Xml.Serialization; using libsecondlife; -using libsecondlife.Packets; namespace OpenSim.Framework { @@ -93,47 +92,39 @@ namespace OpenSim.Framework public ProfileShape ProfileShape { - get - { - return (ProfileShape)(ProfileCurve & 0xf); - } + get { return (ProfileShape) (ProfileCurve & 0xf); } set { - byte oldValueMasked = (byte)(ProfileCurve & 0xf0); - ProfileCurve = (byte)(oldValueMasked | (byte)value); + byte oldValueMasked = (byte) (ProfileCurve & 0xf0); + ProfileCurve = (byte) (oldValueMasked | (byte) value); } } [XmlIgnore] public HollowShape HollowShape { - get - { - return (HollowShape)(ProfileHollow & 0xf0); - } + get { return (HollowShape) (ProfileHollow & 0xf0); } set { - byte oldValueMasked = (byte)(ProfileHollow & 0xf0); - ProfileHollow = (byte)(oldValueMasked | (byte)value); + byte oldValueMasked = (byte) (ProfileHollow & 0xf0); + ProfileHollow = (byte) (oldValueMasked | (byte) value); } } public LLVector3 PrimScale { - get - { - return this.Scale; - } + get { return Scale; } } static PrimitiveBaseShape() { - m_defaultTextureEntry = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")).ToBytes(); + m_defaultTextureEntry = + new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")).ToBytes(); } public PrimitiveBaseShape() { - PCode = (byte)PCodeEnum.Primitive; + PCode = (byte) PCodeEnum.Primitive; ExtraParams = new byte[1]; TextureEntry = m_defaultTextureEntry; } @@ -141,12 +132,11 @@ namespace OpenSim.Framework //void returns need to change of course public virtual void GetMesh() { - } public PrimitiveBaseShape Copy() { - return (PrimitiveBaseShape)this.MemberwiseClone(); + return (PrimitiveBaseShape) MemberwiseClone(); } } @@ -155,7 +145,6 @@ namespace OpenSim.Framework public GenericShape() : base() { - } } @@ -164,7 +153,7 @@ namespace OpenSim.Framework public BoxShape() : base() { - PathCurve = (byte)Extrusion.Straight; + PathCurve = (byte) Extrusion.Straight; ProfileShape = ProfileShape.Square; PathScaleX = 100; PathScaleY = 100; @@ -193,12 +182,13 @@ namespace OpenSim.Framework } } } + public class CylinderShape : PrimitiveBaseShape { public CylinderShape() : base() { - PathCurve = (byte)Extrusion.Straight; + PathCurve = (byte) Extrusion.Straight; ProfileShape = ProfileShape.Circle; PathScaleX = 100; PathScaleY = 100; @@ -218,7 +208,7 @@ namespace OpenSim.Framework private void SetRadius(float radius) { - Scale.X = Scale.Y = radius * 2f; + Scale.X = Scale.Y = radius*2f; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/Properties/AssemblyInfo.cs b/OpenSim/Framework/General/Properties/AssemblyInfo.cs index 655cffc..b3206a7 100644 --- a/OpenSim/Framework/General/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/General/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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.FrameWork")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.FrameWork")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.FrameWork")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.FrameWork")] +[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("a08e20c7-f191-4137-b1f0-9291408fa521")] + +[assembly : Guid("a08e20c7-f191-4137-b1f0-9291408fa521")] // Version information for an assembly consists of the following four values: // @@ -27,5 +31,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Framework/General/RegionCommsListener.cs b/OpenSim/Framework/General/RegionCommsListener.cs index caa4af7..ee0d503 100644 --- a/OpenSim/Framework/General/RegionCommsListener.cs +++ b/OpenSim/Framework/General/RegionCommsListener.cs @@ -25,15 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using System.Collections.Generic; +using libsecondlife; namespace OpenSim.Framework { - public class RegionCommsListener :IRegionCommsListener + public class RegionCommsListener : IRegionCommsListener { public event ExpectUserDelegate OnExpectUser; public event GenericCall2 OnExpectChildAgent; @@ -46,11 +44,10 @@ namespace OpenSim.Framework /// /// /// - public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) + public virtual bool TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) { - if(OnExpectUser != null) + if (OnExpectUser != null) { - OnExpectUser(regionHandle, agent); return true; } @@ -58,7 +55,8 @@ namespace OpenSim.Framework return false; } - public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) + public virtual bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, + bool isFlying) { if (OnAvatarCrossingIntoRegion != null) { @@ -111,4 +109,4 @@ namespace OpenSim.Framework return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/RegionHandle.cs b/OpenSim/Framework/General/RegionHandle.cs index d800e57..807a17c 100644 --- a/OpenSim/Framework/General/RegionHandle.cs +++ b/OpenSim/Framework/General/RegionHandle.cs @@ -28,13 +28,14 @@ using System; using System.Net; +using System.Net.Sockets; namespace OpenSim.Framework { /// /// A class for manipulating RegionHandle coordinates /// - class RegionHandle + internal class RegionHandle { private UInt64 handle; @@ -48,28 +49,28 @@ namespace OpenSim.Framework { IPAddress addr = IPAddress.Parse(ip); - if (addr.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork) + if (addr.AddressFamily != AddressFamily.InterNetwork) throw new Exception("Bad RegionHandle Parameter - must be an IPv4 address"); uint baseHandle = BitConverter.ToUInt32(addr.GetAddressBytes(), 0); // Split the IP address in half - short a = (short)((baseHandle << 16) & 0xFFFF); - short b = (short)((baseHandle << 0) & 0xFFFF); + short a = (short) ((baseHandle << 16) & 0xFFFF); + short b = (short) ((baseHandle << 0) & 0xFFFF); // Raise the bounds a little - uint nx = (uint)x; - uint ny = (uint)y; + uint nx = (uint) x; + uint ny = (uint) y; // Multiply grid coords to get region coords nx *= 256; ny *= 256; // Stuff the IP address in too - nx = (uint)a << 16; - ny = (uint)b << 16; + nx = (uint) a << 16; + ny = (uint) b << 16; - handle = ((UInt64)nx << 32) | (uint)ny; + handle = ((UInt64) nx << 32) | (uint) ny; } /// @@ -79,7 +80,7 @@ namespace OpenSim.Framework /// Grid Y Coordinate public RegionHandle(uint x, uint y) { - handle = ((x * 256) << 32) | (y * 256); + handle = ((x*256) << 32) | (y*256); } /// @@ -118,10 +119,10 @@ namespace OpenSim.Framework /// Grid Server IP Address public IPAddress getGridIP() { - uint a = (uint)((handle >> 16) & 0xFFFF); - uint b = (uint)((handle >> 48) & 0xFFFF); + uint a = (uint) ((handle >> 16) & 0xFFFF); + uint b = (uint) ((handle >> 48) & 0xFFFF); - return new IPAddress((long)(a << 16) | (long)b); + return new IPAddress((long) (a << 16) | (long) b); } /// @@ -130,7 +131,7 @@ namespace OpenSim.Framework /// X Coordinate public uint getGridX() { - uint x = (uint)((handle >> 32) & 0xFFFF); + uint x = (uint) ((handle >> 32) & 0xFFFF); return x; } @@ -141,9 +142,9 @@ namespace OpenSim.Framework /// Y Coordinate public uint getGridY() { - uint y = (uint)((handle >> 0) & 0xFFFF); + uint y = (uint) ((handle >> 0) & 0xFFFF); return y; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/RegionInfo.cs b/OpenSim/Framework/General/RegionInfo.cs index 32f0c76..c14afd2 100644 --- a/OpenSim/Framework/General/RegionInfo.cs +++ b/OpenSim/Framework/General/RegionInfo.cs @@ -26,14 +26,10 @@ * */ using System; -using System.Globalization; using System.Net; using System.Net.Sockets; -using Nini.Config; using libsecondlife; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; +using Nini.Config; namespace OpenSim.Framework { @@ -45,7 +41,6 @@ namespace OpenSim.Framework public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) { - m_regionLocX = regionLocX; m_regionLocY = regionLocY; @@ -55,7 +50,6 @@ namespace OpenSim.Framework public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, int port) { - m_regionLocX = regionLocX; m_regionLocY = regionLocY; @@ -67,16 +61,11 @@ namespace OpenSim.Framework public LLUUID RegionID = new LLUUID(); private 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; @@ -109,76 +98,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)); } } } @@ -196,80 +158,81 @@ 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; } - } public ConfigurationMember configMember; + public RegionInfo(string description, string filename) { - configMember = new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); + configMember = + new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } public RegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri) : base(regionLocX, regionLocY, internalEndPoint, externalUri) { - - } public RegionInfo() { - } //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().ToStringHyphenated())); - 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")); - this.DataStore = source.Configs[sectionName].GetString("datastore", "OpenSim.db"); + RegionID = + new LLUUID(source.Configs[sectionName].GetString("Region_ID", LLUUID.Random().ToStringHyphenated())); + 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")); + 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", NetworkServersInfo.DefaultHttpListenerPort); + m_internalEndPoint.Port = + source.Configs[sectionName].GetInt("internal_ip_port", 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 != "") { @@ -279,17 +242,36 @@ 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("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_first", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "First Name of Master Avatar", "Test", false); - configMember.addConfigurationOption("master_avatar_last", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Last Name of Master Avatar", "User", false); - configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "(Sandbox Mode Only)Password for Master Avatar account", "test", 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_first", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "First Name of Master Avatar", "Test", false); + configMember.addConfigurationOption("master_avatar_last", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Last Name of Master Avatar", "User", false); + configMember.addConfigurationOption("master_avatar_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "(Sandbox Mode Only)Password for Master Avatar account", "test", false); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -297,51 +279,50 @@ 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_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/General/Remoting.cs b/OpenSim/Framework/General/Remoting.cs index 330c078..667ae69 100644 --- a/OpenSim/Framework/General/Remoting.cs +++ b/OpenSim/Framework/General/Remoting.cs @@ -41,7 +41,7 @@ namespace OpenSim.Framework /// When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[]. /// Both hosts should be performing these operations for this to be effective. /// - class RemoteDigest + internal class RemoteDigest { private byte[] currentHash; private byte[] secret; @@ -58,7 +58,7 @@ namespace OpenSim.Framework public RemoteDigest(string sharedSecret, byte[] salt, string challenge) { SHA512 = new SHA512Managed(); - Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret,salt); + Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret, salt); secret = RFC2898.GetBytes(512); ASCIIEncoding ASCII = new ASCIIEncoding(); @@ -108,7 +108,7 @@ namespace OpenSim.Framework byte[] bytes = new byte[64]; RNG.GetBytes(bytes); - StringBuilder sb = new StringBuilder(bytes.Length * 2); + StringBuilder sb = new StringBuilder(bytes.Length*2); foreach (byte b in bytes) { sb.AppendFormat("{0:x2}", b); @@ -130,6 +130,5 @@ namespace OpenSim.Framework Buffer.BlockCopy(b, 0, c, a.Length, b.Length); return c; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/UUID.cs b/OpenSim/Framework/General/UUID.cs index 4327f40..f27cd6c 100644 --- a/OpenSim/Framework/General/UUID.cs +++ b/OpenSim/Framework/General/UUID.cs @@ -31,7 +31,7 @@ using libsecondlife; namespace OpenSim.Framework { - class UUID + internal class UUID { public LLUUID llUUID; @@ -73,7 +73,7 @@ namespace OpenSim.Framework n = BitConverter.GetBytes(fourth); n.CopyTo(uuid, 12); - llUUID = new LLUUID(uuid,0); + llUUID = new LLUUID(uuid, 0); } public override string ToString() @@ -152,4 +152,4 @@ namespace OpenSim.Framework return !a.Equals(b); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/UserConfig.cs b/OpenSim/Framework/General/UserConfig.cs index 3d79fc9..9abe61f 100644 --- a/OpenSim/Framework/General/UserConfig.cs +++ b/OpenSim/Framework/General/UserConfig.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Framework { /// @@ -51,21 +47,30 @@ namespace OpenSim.Framework public UserConfig(string description, string filename) { - configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration); + configMember = + new ConfigurationMember(filename, description, loadConfigurationOptions, handleIncomingConfiguration); configMember.performConfigurationRetrieve(); } public void loadConfigurationOptions() { - configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS", false); - - configMember.addConfigurationOption("default_grid_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Grid Server URI", "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString() + "/", false); - configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null", false); - configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false); - configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); + configMember.addConfigurationOption("default_startup_message", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Default Startup Message", "Welcome to OGS", false); - configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, "Http Listener port", DefaultHttpPort.ToString(), false); + configMember.addConfigurationOption("default_grid_server", + ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, + "Default Grid Server URI", + "http://127.0.0.1:" + GridConfig.DefaultHttpPort.ToString() + "/", false); + configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to send to grid server", "null", false); + configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "Key to expect from grid server", "null", false); + configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); + configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, + "Http Listener port", DefaultHttpPort.ToString(), false); } public bool handleIncomingConfiguration(string configuration_key, object configuration_result) @@ -73,26 +78,26 @@ namespace OpenSim.Framework switch (configuration_key) { case "default_startup_message": - this.DefaultStartupMsg = (string)configuration_result; + DefaultStartupMsg = (string) configuration_result; break; case "default_grid_server": - this.GridServerURL = (string)configuration_result; + GridServerURL = (string) configuration_result; break; case "grid_send_key": - this.GridSendKey = (string)configuration_result; + GridSendKey = (string) configuration_result; break; case "grid_recv_key": - this.GridRecvKey = (string)configuration_result; + GridRecvKey = (string) configuration_result; break; case "database_provider": - this.DatabaseProvider = (string)configuration_result; + DatabaseProvider = (string) configuration_result; break; case "http_port": - HttpPort = (uint)configuration_result; + HttpPort = (uint) configuration_result; break; } return true; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/General/UserProfileData.cs b/OpenSim/Framework/General/UserProfileData.cs index 444d811..ed70246 100644 --- a/OpenSim/Framework/General/UserProfileData.cs +++ b/OpenSim/Framework/General/UserProfileData.cs @@ -44,6 +44,7 @@ namespace OpenSim.Framework /// The first component of a users account name /// public string username; + /// /// The second component of a users account name /// @@ -54,6 +55,7 @@ namespace OpenSim.Framework /// /// This is double MD5'd because the client sends an unsalted MD5 to the loginserver public string passwordHash; + /// /// The salt used for the users hash, should be 32 bytes or longer /// @@ -64,18 +66,22 @@ namespace OpenSim.Framework /// public ulong homeRegion { - get { return Helpers.UIntsToLong((homeRegionX * 256), (homeRegionY * 256)); } - set { - homeRegionX = (uint)(value >> 40); - homeRegionY = (((uint)(value)) >> 8); + get { return Helpers.UIntsToLong((homeRegionX*256), (homeRegionY*256)); } + set + { + homeRegionX = (uint) (value >> 40); + homeRegionY = (((uint) (value)) >> 8); } } + public uint homeRegionX; public uint homeRegionY; + /// /// The coordinates inside the region of the home location /// public LLVector3 homeLocation; + /// /// Where the user will be looking when they rez. /// @@ -85,6 +91,7 @@ namespace OpenSim.Framework /// A UNIX Timestamp (seconds since epoch) for the users creation /// public int created; + /// /// A UNIX Timestamp for the users last login date / time /// @@ -96,6 +103,7 @@ namespace OpenSim.Framework /// A URI to the users inventory server, used for foreigners and large grids /// public string userInventoryURI = String.Empty; + /// /// A URI to the users asset server, used for foreigners and large grids. /// @@ -105,6 +113,7 @@ namespace OpenSim.Framework /// A uint mask containing the "I can do" fields of the users profile /// public uint profileCanDoMask; + /// /// A uint mask containing the "I want to do" part of the users profile /// @@ -114,6 +123,7 @@ namespace OpenSim.Framework /// The about text listed in a users profile. /// public string profileAboutText = String.Empty; + /// /// The first life about text listed in a users profile /// @@ -123,10 +133,12 @@ namespace OpenSim.Framework /// The profile image for an avatar stored on the asset server /// public LLUUID profileImage; + /// /// The profile image for the users first life tab /// public LLUUID profileFirstImage; + /// /// The users last registered agent (filled in on the user server) /// @@ -142,47 +154,58 @@ namespace OpenSim.Framework /// The UUID of the users avatar (not the agent!) /// public LLUUID UUID; + /// /// The IP address of the user /// public string agentIP = String.Empty; + /// /// The port of the user /// public uint agentPort; + /// /// Is the user online? /// public bool agentOnline; + /// /// The session ID for the user (also the agent ID) /// public LLUUID sessionID; + /// /// The "secure" session ID for the user /// /// Not very secure. Dont rely on it for anything more than Linden Lab does. public LLUUID secureSessionID; + /// /// The region the user logged into initially /// public LLUUID regionID; + /// /// A unix timestamp from when the user logged in /// public int loginTime; + /// /// When this agent expired and logged out, 0 if still online /// public int logoutTime; + /// /// Current region the user is logged into /// public LLUUID currentRegion; + /// /// Region handle of the current region the user is in /// public ulong currentHandle; + /// /// The position of the user within the region /// diff --git a/OpenSim/Framework/General/Util.cs b/OpenSim/Framework/General/Util.cs index e3b156d..c731561 100644 --- a/OpenSim/Framework/General/Util.cs +++ b/OpenSim/Framework/General/Util.cs @@ -25,14 +25,16 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.Collections.Generic; +using System.Data; using System.IO; -using System.Security.Cryptography; using System.Net; +using System.Net.Sockets; +using System.Security.Cryptography; using System.Text; using libsecondlife; - using Nini.Config; namespace OpenSim.Framework @@ -52,16 +54,13 @@ namespace OpenSim.Framework public static Random RandomClass { - get - { - return randomClass; - } + get { return randomClass; } } public static uint GetNextXferID() { uint id = 0; - lock(XferLock) + lock (XferLock) { id = nextXferID; nextXferID++; @@ -71,25 +70,24 @@ namespace OpenSim.Framework public Util() { - } public static string GetFileName(string file) { // Return just the filename on UNIX platforms // TODO: this should be customisable with a prefix, but that's something to do later. - if (System.Environment.OSVersion.Platform == PlatformID.Unix) + if (Environment.OSVersion.Platform == PlatformID.Unix) { return file; } // Return %APPDATA%/OpenSim/file for 2K/XP/NT/2K3/VISTA // TODO: Switch this to System.Enviroment.SpecialFolders.ApplicationData - if (System.Environment.OSVersion.Platform == PlatformID.Win32NT) + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { - if (!System.IO.Directory.Exists("%APPDATA%\\OpenSim\\")) + if (!Directory.Exists("%APPDATA%\\OpenSim\\")) { - System.IO.Directory.CreateDirectory("%APPDATA%\\OpenSim"); + Directory.CreateDirectory("%APPDATA%\\OpenSim"); } return "%APPDATA%\\OpenSim\\" + file; @@ -103,23 +101,23 @@ namespace OpenSim.Framework public static bool IsEnvironmentSupported(ref string reason) { // Must have .NET 2.0 (Generics / libsl) - if (System.Environment.Version.Major < 2) + if (Environment.Version.Major < 2) { reason = ".NET 1.0/1.1 lacks components that is used by OpenSim"; return false; } // Windows 95/98/ME are unsupported - if (System.Environment.OSVersion.Platform == PlatformID.Win32Windows && - System.Environment.OSVersion.Platform != PlatformID.Win32NT) + if (Environment.OSVersion.Platform == PlatformID.Win32Windows && + Environment.OSVersion.Platform != PlatformID.Win32NT) { reason = "Windows 95/98/ME will not run OpenSim"; return false; } // Windows 2000 / Pre-SP2 XP - if (System.Environment.OSVersion.Version.Major == 5 && ( - System.Environment.OSVersion.Version.Minor == 0)) + if (Environment.OSVersion.Version.Major == 5 && ( + Environment.OSVersion.Version.Minor == 0)) { reason = "Please update to Windows XP Service Pack 2 or Server2003"; return false; @@ -131,7 +129,7 @@ namespace OpenSim.Framework public static int UnixTimeSinceEpoch() { TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); - int timestamp = (int)t.TotalSeconds; + int timestamp = (int) t.TotalSeconds; return timestamp; } @@ -155,10 +153,10 @@ namespace OpenSim.Framework public static int fast_distance2d(int x, int y) { - x = System.Math.Abs(x); - y = System.Math.Abs(y); + x = Math.Abs(x); + y = Math.Abs(y); - int min = System.Math.Min(x, y); + int min = Math.Min(x, y); return (x + y - (min >> 1) - (min >> 2) + (min >> 4)); } @@ -233,7 +231,7 @@ namespace OpenSim.Framework for (int j = 0; j < 16 && (i + j) < bytes.Length; j++) { if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E) - output.Append((char)bytes[i + j]); + output.Append((char) bytes[i + j]); else output.Append("."); } @@ -250,7 +248,6 @@ namespace OpenSim.Framework /// An IP address, or null public static IPAddress GetHostFromDNS(string dnsAddress) { - // Is it already a valid IP? No need to look it up. IPAddress ipa; if (IPAddress.TryParse(dnsAddress, out ipa)) @@ -261,7 +258,7 @@ namespace OpenSim.Framework foreach (IPAddress host in hosts) { - if (host.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + if (host.AddressFamily == AddressFamily.InterNetwork) { return host; } @@ -281,7 +278,7 @@ namespace OpenSim.Framework foreach (IPAddress host in hosts) { - if (!IPAddress.IsLoopback(host) && host.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork) { return host; } @@ -302,7 +299,7 @@ namespace OpenSim.Framework string temp; // string personal=(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); // temp = Path.Combine(personal,".OpenSim"); - temp="."; + temp = "."; return temp; } @@ -349,9 +346,9 @@ namespace OpenSim.Framework } // Nini (config) related Methods - public static IConfigSource ConvertDataRowToXMLConfig(System.Data.DataRow row, string fileName) + public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName) { - if(!File.Exists(fileName)) + if (!File.Exists(fileName)) { //create new file } @@ -362,13 +359,13 @@ namespace OpenSim.Framework return config; } - public static void AddDataRowToConfig(IConfigSource config, System.Data.DataRow row) + public static void AddDataRowToConfig(IConfigSource config, DataRow row) { - config.Configs.Add((string)row[0]); + config.Configs.Add((string) row[0]); for (int i = 0; i < row.Table.Columns.Count; i++) { - config.Configs[(string)row[0]].Set(row.Table.Columns[i].ColumnName, row[i]); + config.Configs[(string) row[0]].Set(row.Table.Columns[i].ColumnName, row[i]); } } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 179a651..52d2a2c 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -31,11 +31,10 @@ using System.Collections.Generic; using System.IO; using System.Net; using System.Text; -using System.Text.RegularExpressions; using System.Threading; +using System.Xml; using Nwc.XmlRpc; using OpenSim.Framework.Console; -using System.Xml; namespace OpenSim.Framework.Servers { @@ -50,7 +49,7 @@ namespace OpenSim.Framework.Servers public int Port { - get { return m_port; } + get { return m_port; } } public BaseHttpServer(int port) @@ -58,11 +57,11 @@ namespace OpenSim.Framework.Servers m_port = port; } - public void AddStreamHandler( IStreamHandler handler) + public void AddStreamHandler(IStreamHandler handler) { string httpMethod = handler.HttpMethod; string path = handler.Path; - + string handlerKey = GetHandlerKey(httpMethod, path); m_streamHandlers.Add(handlerKey, handler); } @@ -74,9 +73,9 @@ namespace OpenSim.Framework.Servers public bool AddXmlRPCHandler(string method, XmlRpcMethod handler) { - if (!this.m_rpcHandlers.ContainsKey(method)) + if (!m_rpcHandlers.ContainsKey(method)) { - this.m_rpcHandlers.Add(method, handler); + m_rpcHandlers.Add(method, handler); return true; } @@ -87,7 +86,7 @@ namespace OpenSim.Framework.Servers public virtual void HandleRequest(Object stateinfo) { - HttpListenerContext context = (HttpListenerContext)stateinfo; + HttpListenerContext context = (HttpListenerContext) stateinfo; HttpListenerRequest request = context.Request; HttpListenerResponse response = context.Response; @@ -96,11 +95,11 @@ namespace OpenSim.Framework.Servers response.SendChunked = false; string path = request.RawUrl; - string handlerKey = GetHandlerKey( request.HttpMethod, path ); + string handlerKey = GetHandlerKey(request.HttpMethod, path); IStreamHandler streamHandler; - if (TryGetStreamHandler( handlerKey, out streamHandler)) + if (TryGetStreamHandler(handlerKey, out streamHandler)) { byte[] buffer = streamHandler.Handle(path, request.InputStream); request.InputStream.Close(); @@ -159,11 +158,11 @@ namespace OpenSim.Framework.Servers try { - xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); + xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody); } - catch ( XmlException e ) - { - responseString = String.Format( "XmlException:\n{0}",e.Message ); + catch (XmlException e) + { + responseString = String.Format("XmlException:\n{0}", e.Message); } if (xmlRprcRequest != null) @@ -173,7 +172,7 @@ namespace OpenSim.Framework.Servers XmlRpcResponse xmlRpcResponse; XmlRpcMethod method; - if (this.m_rpcHandlers.TryGetValue(methodName, out method)) + if (m_rpcHandlers.TryGetValue(methodName, out method)) { xmlRpcResponse = method(xmlRprcRequest); } @@ -181,7 +180,8 @@ namespace OpenSim.Framework.Servers { xmlRpcResponse = new XmlRpcResponse(); Hashtable unknownMethodError = new Hashtable(); - unknownMethodError["reason"] = "XmlRequest"; ; + unknownMethodError["reason"] = "XmlRequest"; + ; unknownMethodError["message"] = "Unknown Rpc Request [" + methodName + "]"; unknownMethodError["login"] = "false"; xmlRpcResponse.Value = unknownMethodError; @@ -249,4 +249,4 @@ namespace OpenSim.Framework.Servers m_streamHandlers.Remove(GetHandlerKey(httpMethod, path)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/BaseStreamHandler.cs b/OpenSim/Framework/Servers/BaseStreamHandler.cs index 4b609c3..cd99183 100644 --- a/OpenSim/Framework/Servers/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/BaseStreamHandler.cs @@ -26,37 +26,36 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using System.IO; namespace OpenSim.Framework.Servers { public abstract class BaseStreamHandler : IStreamHandler { - virtual public string ContentType + public virtual string ContentType { get { return "application/xml"; } } private string m_httpMethod; - virtual public string HttpMethod + + public virtual string HttpMethod { get { return m_httpMethod; } } private string m_path; - virtual public string Path + + public virtual string Path { get { return m_path; } } - - protected string GetParam( string path ) + + protected string GetParam(string path) { - return path.Substring( m_path.Length ); + return path.Substring(m_path.Length); } - + public abstract byte[] Handle(string path, Stream request); protected BaseStreamHandler(string httpMethod, string path) @@ -65,4 +64,4 @@ namespace OpenSim.Framework.Servers m_path = path; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/BinaryStreamHandler.cs index 4cc6fc7..65fa3c9 100644 --- a/OpenSim/Framework/Servers/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/BinaryStreamHandler.cs @@ -26,10 +26,8 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using System.IO; +using System.Text; namespace OpenSim.Framework.Servers { @@ -37,14 +35,14 @@ namespace OpenSim.Framework.Servers public class BinaryStreamHandler : BaseStreamHandler { - BinaryMethod m_method; + private BinaryMethod m_method; - override public byte[] Handle(string path, Stream request) + public override byte[] Handle(string path, Stream request) { byte[] data = ReadFully(request); string param = GetParam(path); string responseString = m_method(data, path, param); - + return Encoding.UTF8.GetBytes(responseString); } @@ -67,11 +65,10 @@ namespace OpenSim.Framework.Servers { return ms.ToArray(); } - + ms.Write(buffer, 0, read); } - } + } } } - -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs index 62e5ea0..ef4c0ee 100644 --- a/OpenSim/Framework/Servers/CheckSumServer.cs +++ b/OpenSim/Framework/Servers/CheckSumServer.cs @@ -26,7 +26,8 @@ * */ namespace OpenSim.Framework.Servers -{/* +{ + /* public class CheckSumServer : UDPServerBase { //protected ConsoleBase m_log; @@ -123,5 +124,4 @@ namespace OpenSim.Framework.Servers } * } */ - } \ No newline at end of file diff --git a/OpenSim/Framework/Servers/IStreamHandler.cs b/OpenSim/Framework/Servers/IStreamHandler.cs index d97b37f..d674172 100644 --- a/OpenSim/Framework/Servers/IStreamHandler.cs +++ b/OpenSim/Framework/Servers/IStreamHandler.cs @@ -26,9 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using System.IO; namespace OpenSim.Framework.Servers @@ -36,15 +33,15 @@ namespace OpenSim.Framework.Servers public interface IStreamHandler { // Handle request stream, return byte array - byte[] Handle(string path, Stream request ); - + byte[] Handle(string path, Stream request); + // Return response content type string ContentType { get; } - + // Return required http method - string HttpMethod { get;} + string HttpMethod { get; } // Return path string Path { get; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/RestMethod.cs b/OpenSim/Framework/Servers/RestMethod.cs index 80c6451..83f9e71 100644 --- a/OpenSim/Framework/Servers/RestMethod.cs +++ b/OpenSim/Framework/Servers/RestMethod.cs @@ -27,5 +27,5 @@ */ namespace OpenSim.Framework.Servers { - public delegate string RestMethod( string request, string path, string param ); -} + public delegate string RestMethod(string request, string path, string param); +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs index 1b1876e..0450387 100644 --- a/OpenSim/Framework/Servers/RestStreamHandler.cs +++ b/OpenSim/Framework/Servers/RestStreamHandler.cs @@ -26,18 +26,16 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using System.IO; +using System.Text; namespace OpenSim.Framework.Servers { public class RestStreamHandler : BaseStreamHandler { - RestMethod m_restMethod; + private RestMethod m_restMethod; - override public byte[] Handle(string path, Stream request ) + public override byte[] Handle(string path, Stream request) { Encoding encoding = Encoding.UTF8; StreamReader streamReader = new StreamReader(request, encoding); @@ -46,14 +44,14 @@ namespace OpenSim.Framework.Servers streamReader.Close(); string param = GetParam(path); - string responseString = m_restMethod(requestBody, path, param ); + string responseString = m_restMethod(requestBody, path, param); return Encoding.UTF8.GetBytes(responseString); } - public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path ) + public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base(httpMethod, path) { m_restMethod = restMethod; } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/UDPServerBase.cs b/OpenSim/Framework/Servers/UDPServerBase.cs index 8fc32ff..017168f 100644 --- a/OpenSim/Framework/Servers/UDPServerBase.cs +++ b/OpenSim/Framework/Servers/UDPServerBase.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework.Servers protected virtual void OnReceivedData(IAsyncResult result) { ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - epSender = (EndPoint)ipeSender; + epSender = (EndPoint) ipeSender; Packet packet = null; int numBytes = Server.EndReceiveFrom(result, ref epSender); int packetEnd = numBytes - 1; @@ -67,21 +67,18 @@ namespace OpenSim.Framework.Servers public virtual void ServerListener() { - ServerIncoming = new IPEndPoint(IPAddress.Parse("0.0.0.0"), listenPort); Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Server.Bind(ServerIncoming); ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - epSender = (EndPoint)ipeSender; - ReceivedData = new AsyncCallback(this.OnReceivedData); + epSender = (EndPoint) ipeSender; + ReceivedData = new AsyncCallback(OnReceivedData); Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); } public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) { - } } -} - +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/XmlRpcMethod.cs b/OpenSim/Framework/Servers/XmlRpcMethod.cs index ef14cf6..c3817ca 100644 --- a/OpenSim/Framework/Servers/XmlRpcMethod.cs +++ b/OpenSim/Framework/Servers/XmlRpcMethod.cs @@ -29,5 +29,5 @@ using Nwc.XmlRpc; namespace OpenSim.Framework.Servers { - public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request ); -} + public delegate XmlRpcResponse XmlRpcMethod(XmlRpcRequest request); +} \ No newline at end of file diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs index e7e5d27..61427fa 100644 --- a/OpenSim/Grid/AssetServer/Main.cs +++ b/OpenSim/Grid/AssetServer/Main.cs @@ -29,17 +29,10 @@ using System; using System.IO; using System.Reflection; - using libsecondlife; using Nini.Config; - -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Servers; -using OpenSim.Framework; using OpenSim.Framework.Servers; namespace OpenSim.Grid.AssetServer @@ -79,11 +72,12 @@ namespace OpenSim.Grid.AssetServer private OpenAsset_Main() { - if(!Directory.Exists(Util.logDir())) + if (!Directory.Exists(Util.logDir())) { Directory.CreateDirectory(Util.logDir()); } - m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-AssetServer-console.log")), "OpenAsset", this, true); + m_console = + new LogBase((Path.Combine(Util.logDir(), "opengrid-AssetServer-console.log")), "OpenAsset", this, true); MainLog.Instance = m_console; } @@ -96,9 +90,9 @@ namespace OpenSim.Grid.AssetServer m_console.Verbose("ASSET", "Loading default asset set.."); LoadDefaultAssets(); - + m_console.Verbose("ASSET", "Starting HTTP process"); - BaseHttpServer httpServer = new BaseHttpServer((int)m_config.HttpPort); + BaseHttpServer httpServer = new BaseHttpServer((int) m_config.HttpPort); httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider)); httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider)); @@ -125,7 +119,8 @@ namespace OpenSim.Grid.AssetServer if (typeInterface != null) { - IAssetProvider plug = (IAssetProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IAssetProvider plug = + (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); assetPlugin = plug; assetPlugin.Initialise(); @@ -174,7 +169,7 @@ namespace OpenSim.Grid.AssetServer FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); byte[] idata = new byte[numBytes]; BinaryReader br = new BinaryReader(fStream); - idata = br.ReadBytes((int)numBytes); + idata = br.ReadBytes((int) numBytes); br.Close(); fStream.Close(); info.Data = idata; @@ -213,8 +208,8 @@ namespace OpenSim.Grid.AssetServer { string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte)source.Configs[i].GetInt("inventoryType", 0); + sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); string fileName = source.Configs[i].GetString("fileName", ""); AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); @@ -247,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 63213f6..87a7f67 100644 --- a/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/AssetServer/Properties/AssemblyInfo.cs @@ -27,25 +27,29 @@ */ 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("OGS-AssetServer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OGS-AssetServer")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OGS-AssetServer")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OGS-AssetServer")] +[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("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] + +[assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] // Version information for an assembly consists of the following four values: // @@ -54,5 +58,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Grid/AssetServer/RestService.cs b/OpenSim/Grid/AssetServer/RestService.cs index 6993019..0cad643 100644 --- a/OpenSim/Grid/AssetServer/RestService.cs +++ b/OpenSim/Grid/AssetServer/RestService.cs @@ -1,29 +1,27 @@ using System; using System.IO; +using System.Text; using System.Xml; using System.Xml.Serialization; -using System.Text; - using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; namespace OpenSim.Grid.AssetServer { public class GetAssetStreamHandler : BaseStreamHandler { - OpenAsset_Main m_assetManager; - IAssetProvider m_assetProvider; + private OpenAsset_Main m_assetManager; + private IAssetProvider m_assetProvider; - override public byte[] Handle(string path, Stream request) + public override byte[] Handle(string path, Stream request) { string param = GetParam(path); - byte[] result = new byte[] { }; - try { - - string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries); + byte[] result = new byte[] {}; + try + { + string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); if (p.Length > 0) { @@ -42,7 +40,7 @@ namespace OpenSim.Grid.AssetServer { MainLog.Instance.Debug("REST", "GET:/asset found {0}, {1}", assetID, asset.Name); - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); MemoryStream ms = new MemoryStream(); XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8); xw.Formatting = Formatting.Indented; @@ -53,7 +51,7 @@ namespace OpenSim.Grid.AssetServer StreamReader sr = new StreamReader(ms); result = ms.GetBuffer(); - Array.Resize(ref result, (int)ms.Length); + Array.Resize(ref result, (int) ms.Length); } else { @@ -69,7 +67,7 @@ namespace OpenSim.Grid.AssetServer } public GetAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) - : base("GET", "/assets" ) + : base("GET", "/assets") { m_assetManager = assetManager; m_assetProvider = assetProvider; @@ -78,25 +76,25 @@ namespace OpenSim.Grid.AssetServer public class PostAssetStreamHandler : BaseStreamHandler { - OpenAsset_Main m_assetManager; - IAssetProvider m_assetProvider; + private OpenAsset_Main m_assetManager; + private IAssetProvider m_assetProvider; - override public byte[] Handle(string path, Stream request) + public override byte[] Handle(string path, Stream request) { string param = GetParam(path); - + LLUUID assetId; - if(param.Length > 0) + if (param.Length > 0) LLUUID.TryParse(param, out assetId); byte[] txBuffer = new byte[4096]; - XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); - AssetBase asset = (AssetBase)xs.Deserialize(request); + XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); + AssetBase asset = (AssetBase) xs.Deserialize(request); MainLog.Instance.Verbose("REST", "StoreAndCommitAsset {0}", asset.FullID); m_assetProvider.CreateAsset(asset); - return new byte[] { }; + return new byte[] {}; } public PostAssetStreamHandler(OpenAsset_Main assetManager, IAssetProvider assetProvider) @@ -106,4 +104,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 8ac7d6a..0d966dd 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs @@ -25,27 +25,24 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; using System.Collections; using System.Collections.Generic; -using System.Net; using System.Reflection; using System.Xml; using libsecondlife; using Nwc.XmlRpc; +using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Framework.Data; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; - -using OpenSim.Framework; namespace OpenSim.Grid.GridServer { - class GridManager + internal class GridManager { - Dictionary _plugins = new Dictionary(); - Dictionary _logplugins = new Dictionary(); + private Dictionary _plugins = new Dictionary(); + private Dictionary _logplugins = new Dictionary(); public GridConfig config; @@ -54,13 +51,13 @@ namespace OpenSim.Grid.GridServer /// /// The filename to the grid server plugin DLL public void AddPlugin(string FileName) - { + { MainLog.Instance.Verbose("Storage: Attempting to load " + FileName); - Assembly pluginAssembly = Assembly.LoadFrom(FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); MainLog.Instance.Verbose("Storage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); - foreach (Type pluginType in pluginAssembly.GetTypes()) - { + foreach (Type pluginType in pluginAssembly.GetTypes()) + { if (!pluginType.IsAbstract) { // Regions go here @@ -68,9 +65,10 @@ namespace OpenSim.Grid.GridServer if (typeInterface != null) { - IGridData plug = (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + IGridData plug = + (IGridData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); - this._plugins.Add(plug.getName(), plug); + _plugins.Add(plug.getName(), plug); MainLog.Instance.Verbose("Storage: Added IGridData Interface"); } @@ -81,17 +79,18 @@ namespace OpenSim.Grid.GridServer if (typeInterface != null) { - ILogData plug = (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + ILogData plug = + (ILogData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); - this._logplugins.Add(plug.getName(), plug); - MainLog.Instance.Verbose( "Storage: Added ILogData Interface"); + _logplugins.Add(plug.getName(), plug); + MainLog.Instance.Verbose("Storage: Added ILogData Interface"); } typeInterface = null; } - } - - pluginAssembly = null; + } + + pluginAssembly = null; } /// @@ -124,7 +123,8 @@ namespace OpenSim.Grid.GridServer /// A SimProfileData for the region public RegionProfileData getRegion(LLUUID uuid) { - foreach(KeyValuePair kvp in _plugins) { + foreach (KeyValuePair kvp in _plugins) + { try { return kvp.Value.GetProfileByLLUUID(uuid); @@ -182,7 +182,6 @@ namespace OpenSim.Grid.GridServer } - /// /// Returns a XML String containing a list of the neighbouring regions /// @@ -193,11 +192,18 @@ namespace OpenSim.Grid.GridServer string response = ""; RegionProfileData central_region = getRegion(reqhandle); RegionProfileData neighbour; - for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) + for (int x = -1; x < 2; x++) + for (int y = -1; y < 2; y++) { - if (getRegion(Util.UIntsToLong((uint)((central_region.regionLocX + x) * 256), (uint)(central_region.regionLocY + y) * 256)) != null) + if ( + getRegion( + Util.UIntsToLong((uint) ((central_region.regionLocX + x)*256), + (uint) (central_region.regionLocY + y)*256)) != null) { - neighbour = getRegion(Util.UIntsToLong((uint)((central_region.regionLocX + x) * 256), (uint)(central_region.regionLocY + y) * 256)); + neighbour = + getRegion( + Util.UIntsToLong((uint) ((central_region.regionLocX + x)*256), + (uint) (central_region.regionLocY + y)*256)); response += ""; response += "" + neighbour.serverIP + ""; response += "" + neighbour.serverPort.ToString() + ""; @@ -205,7 +211,6 @@ namespace OpenSim.Grid.GridServer response += "" + neighbour.regionLocY.ToString() + ""; response += "" + neighbour.regionHandle.ToString() + ""; response += ""; - } } return response; @@ -218,23 +223,21 @@ namespace OpenSim.Grid.GridServer /// Startup parameters public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request) { - XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); response.Value = responseData; RegionProfileData TheSim = null; - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; string myword; if (requestData.ContainsKey("UUID")) { - TheSim = getRegion(new LLUUID((string)requestData["UUID"])); - + TheSim = getRegion(new LLUUID((string) requestData["UUID"])); + // logToDB((new LLUUID((string)requestData["UUID"])).ToStringHyphenated(),"XmlRpcSimulatorLoginMethod","", 5,"Region attempting login with UUID."); } else if (requestData.ContainsKey("region_handle")) { - // TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"])); // logToDB((string)requestData["region_handle"], "XmlRpcSimulatorLoginMethod", "", 5, "Region attempting login with regionHandle."); } @@ -254,65 +257,68 @@ namespace OpenSim.Grid.GridServer myword = "connection"; } - TheSim = new RegionProfileData(); + TheSim = new RegionProfileData(); - TheSim.regionRecvKey = config.SimRecvKey; - TheSim.regionSendKey = config.SimSendKey; - TheSim.regionSecret = config.SimRecvKey; - TheSim.regionDataURI = ""; - TheSim.regionAssetURI = config.DefaultAssetServer; - TheSim.regionAssetRecvKey = config.AssetRecvKey; - TheSim.regionAssetSendKey = config.AssetSendKey; - TheSim.regionUserURI = config.DefaultUserServer; - TheSim.regionUserSendKey = config.UserSendKey; - TheSim.regionUserRecvKey = config.UserRecvKey; - - TheSim.serverIP = (string)requestData["sim_ip"]; - TheSim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); - TheSim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); - TheSim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]); - TheSim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]); - TheSim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); - TheSim.regionLocZ = 0; - TheSim.regionMapTextureID = new LLUUID((string)requestData["map-image-id"]); - - TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256)); - TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; - System.Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + TheSim.serverURI); - TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/"; - - - TheSim.regionName = (string)requestData["sim_name"]; - TheSim.UUID = new LLUUID((string)requestData["UUID"]); + TheSim.regionRecvKey = config.SimRecvKey; + TheSim.regionSendKey = config.SimSendKey; + TheSim.regionSecret = config.SimRecvKey; + TheSim.regionDataURI = ""; + TheSim.regionAssetURI = config.DefaultAssetServer; + TheSim.regionAssetRecvKey = config.AssetRecvKey; + TheSim.regionAssetSendKey = config.AssetSendKey; + TheSim.regionUserURI = config.DefaultUserServer; + TheSim.regionUserSendKey = config.UserSendKey; + TheSim.regionUserRecvKey = config.UserRecvKey; - foreach (KeyValuePair kvp in _plugins) + TheSim.serverIP = (string) requestData["sim_ip"]; + TheSim.serverPort = Convert.ToUInt32((string) requestData["sim_port"]); + TheSim.httpPort = Convert.ToUInt32((string) requestData["http_port"]); + TheSim.remotingPort = Convert.ToUInt32((string) requestData["remoting_port"]); + TheSim.regionLocX = Convert.ToUInt32((string) requestData["region_locx"]); + TheSim.regionLocY = Convert.ToUInt32((string) requestData["region_locy"]); + TheSim.regionLocZ = 0; + TheSim.regionMapTextureID = new LLUUID((string) requestData["map-image-id"]); + + TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256)); + TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/"; + Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + + TheSim.serverURI); + TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/"; + + + TheSim.regionName = (string) requestData["sim_name"]; + TheSim.UUID = new LLUUID((string) requestData["UUID"]); + + foreach (KeyValuePair kvp in _plugins) + { + try { - try - { - DataResponse insertResponse = kvp.Value.AddProfile(TheSim); - switch(insertResponse) - { - case DataResponse.RESPONSE_OK: - OpenSim.Framework.Console.MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName); - break; - case DataResponse.RESPONSE_ERROR: - OpenSim.Framework.Console.MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName); - break; - case DataResponse.RESPONSE_INVALIDCREDENTIALS: - OpenSim.Framework.Console.MainLog.Instance.Warn("storage", "New sim creation failed (Invalid Credentials): " + TheSim.regionName); - break; - case DataResponse.RESPONSE_AUTHREQUIRED: - OpenSim.Framework.Console.MainLog.Instance.Warn("storage", "New sim creation failed (Authentication Required): " + TheSim.regionName); - break; - } - - } - catch (Exception e) + DataResponse insertResponse = kvp.Value.AddProfile(TheSim); + switch (insertResponse) { - OpenSim.Framework.Console.MainLog.Instance.Warn("storage", "Unable to add region " + TheSim.UUID.ToStringHyphenated() + " via " + kvp.Key); - OpenSim.Framework.Console.MainLog.Instance.Warn("storage", e.ToString()); + case DataResponse.RESPONSE_OK: + MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName); + break; + case DataResponse.RESPONSE_ERROR: + MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName); + break; + case DataResponse.RESPONSE_INVALIDCREDENTIALS: + MainLog.Instance.Warn("storage", + "New sim creation failed (Invalid Credentials): " + TheSim.regionName); + break; + case DataResponse.RESPONSE_AUTHREQUIRED: + MainLog.Instance.Warn("storage", + "New sim creation failed (Authentication Required): " + + TheSim.regionName); + break; } - + } + catch (Exception e) + { + MainLog.Instance.Warn("storage", + "Unable to add region " + TheSim.UUID.ToStringHyphenated() + " via " + kvp.Key); + MainLog.Instance.Warn("storage", e.ToString()); + } if (getRegion(TheSim.regionHandle) == null) @@ -321,7 +327,7 @@ namespace OpenSim.Grid.GridServer return response; } } - + ArrayList SimNeighboursData = new ArrayList(); @@ -332,7 +338,9 @@ namespace OpenSim.Grid.GridServer if (fastMode) { - Dictionary neighbours = getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, TheSim.regionLocY + 1); + Dictionary neighbours = + getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, + TheSim.regionLocY + 1); foreach (KeyValuePair aSim in neighbours) { @@ -349,11 +357,18 @@ namespace OpenSim.Grid.GridServer } else { - for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) + for (int x = -1; x < 2; x++) + for (int y = -1; y < 2; y++) { - if (getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)) != null) + if ( + getRegion( + Helpers.UIntsToLong((uint) ((TheSim.regionLocX + x)*256), + (uint) (TheSim.regionLocY + y)*256)) != null) { - neighbour = getRegion(Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256), (uint)(TheSim.regionLocY + y) * 256)); + neighbour = + getRegion( + Helpers.UIntsToLong((uint) ((TheSim.regionLocX + x)*256), + (uint) (TheSim.regionLocY + y)*256)); NeighbourBlock = new Hashtable(); NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); @@ -386,24 +401,24 @@ namespace OpenSim.Grid.GridServer // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap) responseData["data_uri"] = TheSim.regionDataURI; - - return response; + + return response; } public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request) { - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; Hashtable responseData = new Hashtable(); RegionProfileData simData = null; if (requestData.ContainsKey("region_UUID")) { - simData = getRegion(new LLUUID((string)requestData["region_UUID"])); + simData = getRegion(new LLUUID((string) requestData["region_UUID"])); } else if (requestData.ContainsKey("region_handle")) { - Console.WriteLine("requesting data for region " + (string)requestData["region_handle"]); - simData = getRegion(Convert.ToUInt64((string)requestData["region_handle"])); + Console.WriteLine("requesting data for region " + (string) requestData["region_handle"]); + simData = getRegion(Convert.ToUInt64((string) requestData["region_handle"])); } if (simData == null) @@ -419,7 +434,7 @@ namespace OpenSim.Grid.GridServer responseData["sim_port"] = simData.serverPort.ToString(); responseData["http_port"] = simData.httpPort.ToString(); responseData["remoting_port"] = simData.remotingPort.ToString(); - responseData["region_locx"] = simData.regionLocX.ToString() ; + responseData["region_locx"] = simData.regionLocX.ToString(); responseData["region_locy"] = simData.regionLocY.ToString(); responseData["region_UUID"] = simData.UUID.UUID.ToString(); responseData["region_name"] = simData.regionName; @@ -432,24 +447,24 @@ namespace OpenSim.Grid.GridServer public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request) { - int xmin=980, ymin=980, xmax=1020, ymax=1020; + int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020; - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; if (requestData.ContainsKey("xmin")) { - xmin = (Int32)requestData["xmin"]; + xmin = (Int32) requestData["xmin"]; } if (requestData.ContainsKey("ymin")) { - ymin = (Int32)requestData["ymin"]; + ymin = (Int32) requestData["ymin"]; } if (requestData.ContainsKey("xmax")) { - xmax = (Int32)requestData["xmax"]; + xmax = (Int32) requestData["xmax"]; } if (requestData.ContainsKey("ymax")) { - ymax = (Int32)requestData["ymax"]; + ymax = (Int32) requestData["ymax"]; } XmlRpcResponse response = new XmlRpcResponse(); @@ -461,14 +476,16 @@ namespace OpenSim.Grid.GridServer if (fastMode) { - Dictionary neighbours = getRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax); + Dictionary neighbours = + getRegions((uint) xmin, (uint) ymin, (uint) xmax, (uint) ymax); foreach (KeyValuePair aSim in neighbours) { Hashtable simProfileBlock = new Hashtable(); simProfileBlock["x"] = aSim.Value.regionLocX.ToString(); simProfileBlock["y"] = aSim.Value.regionLocY.ToString(); - System.Console.WriteLine("send neighbour info for " + aSim.Value.regionLocX.ToString() + " , " + aSim.Value.regionLocY.ToString()); + Console.WriteLine("send neighbour info for " + aSim.Value.regionLocX.ToString() + " , " + + aSim.Value.regionLocY.ToString()); simProfileBlock["name"] = aSim.Value.regionName; simProfileBlock["access"] = 21; simProfileBlock["region-flags"] = 512; @@ -486,16 +503,17 @@ namespace OpenSim.Grid.GridServer simProfileList.Add(simProfileBlock); } - MainLog.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + " region(s) in range via FastMode"); + MainLog.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + + " region(s) in range via FastMode"); } else { RegionProfileData simProfile; - for (int x = xmin; x < xmax+1; x++) + for (int x = xmin; x < xmax + 1; x++) { - for (int y = ymin; y < ymax+1; y++) + for (int y = ymin; y < ymax + 1; y++) { - ulong regHandle = Helpers.UIntsToLong((uint)(x * 256), (uint)(y * 256)); + ulong regHandle = Helpers.UIntsToLong((uint) (x*256), (uint) (y*256)); simProfile = getRegion(regHandle); if (simProfile != null) { @@ -520,7 +538,8 @@ namespace OpenSim.Grid.GridServer } } } - MainLog.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + " region(s) in range via Standard Mode"); + MainLog.Instance.Verbose("World map request processed, returned " + simProfileList.Count.ToString() + + " region(s) in range via Standard Mode"); } responseData["sim-profiles"] = simProfileList; @@ -529,7 +548,6 @@ namespace OpenSim.Grid.GridServer } - /// /// Performs a REST Get Operation /// @@ -654,13 +672,13 @@ namespace OpenSim.Grid.GridServer break; case "region_locx": - TheSim.regionLocX = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); - TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256)); + TheSim.regionLocX = Convert.ToUInt32((string) simnode.ChildNodes[i].InnerText); + TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256)); break; case "region_locy": - TheSim.regionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); - TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256)); + TheSim.regionLocY = Convert.ToUInt32((string) simnode.ChildNodes[i].InnerText); + TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256)); break; } } @@ -670,7 +688,10 @@ namespace OpenSim.Grid.GridServer bool requirePublic = false; bool requireValid = true; - if (requirePublic && (TheSim.serverIP.StartsWith("172.16") || TheSim.serverIP.StartsWith("192.168") || TheSim.serverIP.StartsWith("10.") || TheSim.serverIP.StartsWith("0.") || TheSim.serverIP.StartsWith("255."))) + if (requirePublic && + (TheSim.serverIP.StartsWith("172.16") || TheSim.serverIP.StartsWith("192.168") || + TheSim.serverIP.StartsWith("10.") || TheSim.serverIP.StartsWith("0.") || + TheSim.serverIP.StartsWith("255."))) { return "ERROR! Servers must register with public addresses."; } @@ -680,7 +701,7 @@ namespace OpenSim.Grid.GridServer return "ERROR! 0.*.*.* Addresses are invalid, please check your server config and try again"; } - + try { MainLog.Instance.Verbose("Updating / adding via " + _plugins.Count + " storage provider(s) registered."); @@ -689,22 +710,28 @@ namespace OpenSim.Grid.GridServer try { //Check reservations - ReservationData reserveData = kvp.Value.GetReservationAtPoint(TheSim.regionLocX, TheSim.regionLocY); - if ((reserveData != null && reserveData.gridRecvKey == TheSim.regionRecvKey) || (reserveData == null && authkeynode.InnerText != TheSim.regionRecvKey)) + ReservationData reserveData = + kvp.Value.GetReservationAtPoint(TheSim.regionLocX, TheSim.regionLocY); + if ((reserveData != null && reserveData.gridRecvKey == TheSim.regionRecvKey) || + (reserveData == null && authkeynode.InnerText != TheSim.regionRecvKey)) { kvp.Value.AddProfile(TheSim); MainLog.Instance.Verbose("grid", "New sim added to grid (" + TheSim.regionName + ")"); - logToDB(TheSim.UUID.ToStringHyphenated(), "RestSetSimMethod", "", 5, "Region successfully updated and connected to grid."); + logToDB(TheSim.UUID.ToStringHyphenated(), "RestSetSimMethod", "", 5, + "Region successfully updated and connected to grid."); } else { - MainLog.Instance.Warn("grid", "Unable to update region (RestSetSimMethod): Incorrect reservation auth key.");// Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + "."); + MainLog.Instance.Warn("grid", + "Unable to update region (RestSetSimMethod): Incorrect reservation auth key."); + // Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + "."); return "Unable to update region (RestSetSimMethod): Incorrect auth key."; } } catch (Exception e) { - MainLog.Instance.Verbose("getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + e.ToString()); + MainLog.Instance.Verbose("getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + + e.ToString()); } } return "OK"; @@ -714,6 +741,5 @@ namespace OpenSim.Grid.GridServer return "ERROR! Could not save to database! (" + e.ToString() + ")"; } } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs index ae1e244..9b1892d 100644 --- a/OpenSim/Grid/GridServer/Main.cs +++ b/OpenSim/Grid/GridServer/Main.cs @@ -28,16 +28,10 @@ using System; using System.IO; -using System.Reflection; -using System.Threading; using System.Timers; +using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Framework; - -using Timer=System.Timers.Timer; namespace OpenSim.Grid.GridServer { @@ -90,10 +84,9 @@ namespace OpenSim.Grid.GridServer { Directory.CreateDirectory(Util.logDir()); } - m_console = new LogBase((Path.Combine(Util.logDir(),"opengrid-gridserver-console.log")), "OpenGrid", this, true); + m_console = + new LogBase((Path.Combine(Util.logDir(), "opengrid-gridserver-console.log")), "OpenGrid", this, true); MainLog.Instance = m_console; - - } public void managercallback(string cmd) @@ -109,28 +102,28 @@ namespace OpenSim.Grid.GridServer public void Startup() { - - this.Cfg = new GridConfig("GRID SERVER",(Path.Combine(Util.configDir(),"GridServer_Config.xml"))); //Yeah srsly, that's it. + Cfg = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); + //Yeah srsly, that's it. if (setuponly) Environment.Exit(0); - m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server"); + m_console.Verbose("Main.cs:Startup() - Connecting to Storage Server"); m_gridManager = new GridManager(); m_gridManager.AddPlugin(Cfg.DatabaseProvider); // Made of win m_gridManager.config = Cfg; - m_console.Verbose( "Main.cs:Startup() - Starting HTTP process"); - BaseHttpServer httpServer = new BaseHttpServer((int)Cfg.HttpPort); + m_console.Verbose("Main.cs:Startup() - Starting HTTP process"); + BaseHttpServer httpServer = new BaseHttpServer((int) Cfg.HttpPort); //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback); httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcSimulatorLoginMethod); httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod); httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod); - httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod )); - httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod )); + httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod)); + httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod)); - httpServer.AddStreamHandler( new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod )); - httpServer.AddStreamHandler( new RestStreamHandler("POST","/regions/", m_gridManager.RestSetRegionMethod )); + httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod)); + httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod)); //httpServer.AddRestHandler("GET", "/sims/", m_gridManager.RestGetSimMethod); //httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod); @@ -139,9 +132,9 @@ namespace OpenSim.Grid.GridServer httpServer.Start(); - m_console.Verbose( "Main.cs:Startup() - Starting sim status checker"); + m_console.Verbose("Main.cs:Startup() - Starting sim status checker"); - Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. + Timer simCheckTimer = new Timer(3600000*3); // 3 Hours between updates. simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); simCheckTimer.Enabled = true; } @@ -225,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 5059199..d46be9e 100644 --- a/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/GridServer/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -27,25 +27,29 @@ */ 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("OGS-GridServer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OGS-GridServer")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OGS-GridServer")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OGS-GridServer")] +[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("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] + +[assembly : Guid("b541b244-3d1d-4625-9003-bc2a3a6a39a4")] // Version information for an assembly consists of the following four values: // @@ -54,5 +58,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Grid/ScriptEngine/Common/Executor.cs b/OpenSim/Grid/ScriptEngine/Common/Executor.cs index 0732cbc..495c267 100644 --- a/OpenSim/Grid/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Grid/ScriptEngine/Common/Executor.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; using System.Reflection; using System.Runtime.Remoting.Lifetime; @@ -53,7 +52,7 @@ namespace OpenSim.Grid.ScriptEngine.Common { //Console.WriteLine("Executor: InitializeLifetimeService()"); // return null; - ILease lease = (ILease)base.InitializeLifetimeService(); + ILease lease = (ILease) base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { @@ -75,56 +74,56 @@ namespace OpenSim.Grid.ScriptEngine.Common // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! //try //{ - if (m_Running == false) - { - // Script is inactive, do not execute! - return; - } + if (m_Running == false) + { + // Script is inactive, do not execute! + return; + } - string EventName = m_Script.State() + "_event_" + FunctionName; + string EventName = m_Script.State() + "_event_" + FunctionName; - //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); + //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); - //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); + //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); - if (Events.ContainsKey(EventName) == false) + if (Events.ContainsKey(EventName) == false) + { + // Not found, create + Type type = m_Script.GetType(); + try { - // Not found, create - Type type = m_Script.GetType(); - try - { - MethodInfo mi = type.GetMethod(EventName); - Events.Add(EventName, mi); - } - catch - { - // Event name not found, cache it as not found - Events.Add(EventName, null); - } + MethodInfo mi = type.GetMethod(EventName); + Events.Add(EventName, mi); } - - // Get event - MethodInfo ev = null; - Events.TryGetValue(EventName, out ev); - - if (ev == null) // No event by that name! + catch { - //Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); - return; + // Event name not found, cache it as not found + Events.Add(EventName, null); } + } + + // Get event + MethodInfo ev = null; + Events.TryGetValue(EventName, out ev); + + if (ev == null) // No event by that name! + { + //Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); + return; + } - // Found - //try - //{ - // Invoke it - ev.Invoke(m_Script, args); + // Found + //try + //{ + // Invoke it + ev.Invoke(m_Script, args); - //} - //catch (Exception e) - //{ - // // TODO: Send to correct place - // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); - //} + //} + //catch (Exception e) + //{ + // // TODO: Send to correct place + // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); + //} //} @@ -136,8 +135,5 @@ namespace OpenSim.Grid.ScriptEngine.Common { m_Running = false; } - - } - -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/Common/IScript.cs b/OpenSim/Grid/ScriptEngine/Common/IScript.cs index 7d51c50..eb8205b 100644 --- a/OpenSim/Grid/ScriptEngine/Common/IScript.cs +++ b/OpenSim/Grid/ScriptEngine/Common/IScript.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Grid.ScriptEngine.Common { public interface IScript @@ -37,4 +33,4 @@ namespace OpenSim.Grid.ScriptEngine.Common string State(); Executor Exec { get; } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 7bd6f43..9630d6e 100644 --- a/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Grid/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -26,15 +26,12 @@ * */ /* Original code: Tedd Hansen */ -using System; using System.Collections.Generic; -using System.Text; namespace OpenSim.Grid.ScriptEngine.Common { public interface LSL_BuiltIn_Commands_Interface { - string State(); double llSin(double f); @@ -404,7 +401,9 @@ namespace OpenSim.Grid.ScriptEngine.Common //wiki: llSetTextureAnim(integer mode, integer face, integer sizex, integer sizey, double start, double length, double rate) void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate); //wiki: llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west) - void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west); + void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, + LSL_Types.Vector3 bottom_south_west); + //wiki: llEjectFromLand(key pest) void llEjectFromLand(string pest); void llParseString2List(); @@ -437,7 +436,7 @@ namespace OpenSim.Grid.ScriptEngine.Common //wiki: double llGetRegionFPS() double llGetRegionFPS(); //wiki: llParticleSystem(List rules - void llParticleSystem(List rules); + void llParticleSystem(List rules); //wiki: llGroundRepel(double height, integer water, double tau) void llGroundRepel(double height, int water, double tau); void llGiveInventoryList(); @@ -548,7 +547,9 @@ namespace OpenSim.Grid.ScriptEngine.Common //wiki: list llParseStringKeepNulls( string src, list separators, list spacers ) List llParseStringKeepNulls(string src, List seperators, List spacers); //wiki: llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, integer param) - void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param); + void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, + LSL_Types.Quaternion rot, int param); + //wiki: integer llGetObjectPermMask(integer mask) int llGetObjectPermMask(int mask); //wiki: llSetObjectPermMask(integer mask, integer value) @@ -632,4 +633,4 @@ namespace OpenSim.Grid.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/Grid/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Grid/ScriptEngine/Common/LSL_Types.cs index 02f9e9a..d10a5ef 100644 --- a/OpenSim/Grid/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Grid/ScriptEngine/Common/LSL_Types.cs @@ -41,11 +41,12 @@ namespace OpenSim.Grid.ScriptEngine.Common public double Z; public Vector3(Vector3 vector) - { - X = (float)vector.X; - Y = (float)vector.Y; - Z = (float)vector.Z; - } + { + X = (float) vector.X; + Y = (float) vector.Y; + Z = (float) vector.Z; + } + public Vector3(double x, double y, double z) { X = x; @@ -53,6 +54,7 @@ namespace OpenSim.Grid.ScriptEngine.Common Z = z; } } + [Serializable] public struct Quaternion { @@ -62,12 +64,13 @@ namespace OpenSim.Grid.ScriptEngine.Common public double R; public Quaternion(Quaternion Quat) - { - X = (float)Quat.X; - Y = (float)Quat.Y; - Z = (float)Quat.Z; - R = (float)Quat.R; + { + X = (float) Quat.X; + Y = (float) Quat.Y; + Z = (float) Quat.Z; + R = (float) Quat.R; } + public Quaternion(double x, double y, double z, double r) { X = x; @@ -75,7 +78,6 @@ namespace OpenSim.Grid.ScriptEngine.Common Z = z; R = r; } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/Common/Properties/AssemblyInfo.cs b/OpenSim/Grid/ScriptEngine/Common/Properties/AssemblyInfo.cs index 44a4f29..1d5911b 100644 --- a/OpenSim/Grid/ScriptEngine/Common/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/ScriptEngine/Common/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.Grid.ScriptEngine.Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Grid.ScriptEngine.Common")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Grid.ScriptEngine.Common")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Grid.ScriptEngine.Common")] +[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("0bf07c53-ae51-487f-a907-e9b30c251602")] + +[assembly : Guid("0bf07c53-ae51-487f-a907-e9b30c251602")] // Version information for an assembly consists of the following four values: // @@ -29,5 +31,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs index e5478ae..e6c1678 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/AppDomainManager.cs @@ -27,27 +27,22 @@ */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.Reflection; -using System.Threading; -using System.Runtime.Remoting; -using System.IO; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL; -using OpenSim.Region.ScriptEngine.Common; -using libsecondlife; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { public class AppDomainManager { private int maxScriptsPerAppDomain = 1; + /// /// Internal list of all AppDomains /// private List appDomains = new List(); + /// /// Structure to keep track of data around AppDomain /// @@ -57,19 +52,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// The AppDomain itself /// public AppDomain CurrentAppDomain; + /// /// Number of scripts loaded into AppDomain /// public int ScriptsLoaded; + /// /// Number of dead scripts /// public int ScriptsWaitingUnload; } + /// /// Current AppDomain /// private AppDomainStructure currentAD; + private object getLock = new object(); // Mutex private object freeLock = new object(); // Mutex @@ -94,22 +93,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine { // Add it to AppDomains list and empty current appDomains.Add(currentAD); - currentAD = null; + currentAD = null; } // No current if (currentAD == null) { // Create a new current AppDomain currentAD = new AppDomainStructure(); - currentAD.CurrentAppDomain = PrepareNewAppDomain(); + currentAD.CurrentAppDomain = PrepareNewAppDomain(); } - Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded); + Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded); return currentAD; } // lock } private int AppDomainNameCount; + /// /// Create and prepare a new AppDomain for scripts /// @@ -130,12 +130,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads); - Console.WriteLine("Loading: " + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); + Console.WriteLine("Loading: " + + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll")); // Return the new AppDomain return AD; - } /// @@ -146,7 +146,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine lock (freeLock) { // Go through all - foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains)) + foreach (AppDomainStructure ads in new ArrayList(appDomains)) { // Don't process current AppDomain if (ads.CurrentAppDomain != currentAD.CurrentAppDomain) @@ -164,23 +164,25 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Unload AppDomain.Unload(ads.CurrentAppDomain); #if DEBUG - Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) + " bytes of memory"); + Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) + + " bytes of memory"); #endif } } } // foreach } // lock } - - public OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadScript(string FileName) + public LSL_BaseClass LoadScript(string FileName) { // Find next available AppDomain to put it in AppDomainStructure FreeAppDomain = GetFreeAppDomain(); - + Console.WriteLine("Loading into AppDomain: " + FileName); - LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); + LSL_BaseClass mbrt = + (LSL_BaseClass) + FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); //Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); FreeAppDomain.ScriptsLoaded++; @@ -207,7 +209,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } // Lopp through all AppDomains - foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains)) + foreach (AppDomainStructure ads in new ArrayList(appDomains)) { if (ads.CurrentAppDomain == ad) { @@ -219,10 +221,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } // lock UnloadAppDomains(); // Outsite lock, has its own GetLock - - } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs index af5c675..3ded7bf 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Common.cs @@ -26,34 +26,30 @@ * */ /* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Grid.ScriptEngine.DotNetEngine { public static class Common { - static public bool debug = true; - static public ScriptEngine mySE; + public static bool debug = true; + public static ScriptEngine mySE; //public delegate void SendToDebugEventDelegate(string Message); //public delegate void SendToLogEventDelegate(string Message); //static public event SendToDebugEventDelegate SendToDebugEvent; //static public event SendToLogEventDelegate SendToLogEvent; - static public void SendToDebug(string Message) + public static void SendToDebug(string Message) { //if (Debug == true) mySE.Log.Verbose("ScriptEngine", "Debug: " + Message); //SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } - static public void SendToLog(string Message) + + public static void SendToLog(string Message) { //if (Debug == true) mySE.Log.Verbose("ScriptEngine", "LOG: " + Message); //SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } } - -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index bb3d12a..4be8a0b 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -27,16 +27,13 @@ */ using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using Microsoft.CSharp; using System.CodeDom.Compiler; +using System.IO; using System.Reflection; +using Microsoft.CSharp; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL { - public class Compiler { private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); @@ -45,7 +42,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL //private ICodeCompiler icc = codeProvider.CreateCompiler(); public string CompileFromFile(string LSOFileName) { - switch (System.IO.Path.GetExtension(LSOFileName).ToLower()) + switch (Path.GetExtension(LSOFileName).ToLower()) { case ".txt": case ".lsl": @@ -58,6 +55,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL throw new Exception("Unknown script type."); } } + /// /// Converts script from LSL to CS and calls CompileFromCSText /// @@ -67,13 +65,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL { if (Script.Substring(0, 4).ToLower() == "//c#") { - return CompileFromCSText( Script ); + return CompileFromCSText(Script); } else { return CompileFromCSText(LSL_Converter.Convert(Script)); } } + /// /// Compile CS script to .Net assembly (.dll) /// @@ -81,14 +80,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL /// Filename to .dll assembly public string CompileFromCSText(string Script) { - - // Output assembly name scriptCompileCounter++; string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll"); try { - System.IO.File.Delete(OutFile); + File.Delete(OutFile); } catch (Exception e) { @@ -99,12 +96,15 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL // DEBUG - write source to disk try { - File.WriteAllText(Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script); + File.WriteAllText( + Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script); + } + catch + { } - catch { } // Do actual compile - System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); + CompilerParameters parameters = new CompilerParameters(); parameters.IncludeDebugInformation = true; // Add all available assemblies foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) @@ -114,11 +114,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL } string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); - string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location); + string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location); //Console.WriteLine("Assembly location: " + rootPath); parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll")); parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Grid.ScriptEngine.DotNetEngine.dll")); - + //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment"); parameters.GenerateExecutable = false; parameters.OutputAssembly = OutFile; @@ -129,13 +129,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL // TODO: Return errors to user somehow if (results.Errors.Count > 0) { - string errtext = ""; foreach (CompilerError CompErr in results.Errors) { errtext += "Line number " + (CompErr.Line - 1) + - ", Error Number: " + CompErr.ErrorNumber + - ", '" + CompErr.ErrorText + "'\r\n"; + ", Error Number: " + CompErr.ErrorNumber + + ", '" + CompErr.ErrorText + "'\r\n"; } throw new Exception(errtext); } @@ -143,6 +142,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL return OutFile; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 32188d2..9046db3 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -26,9 +26,7 @@ * */ -using System; using System.Collections.Generic; -using System.Text; using System.Text.RegularExpressions; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL @@ -51,9 +49,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL dataTypes.Add("rotation", "LSL_Types.Quaternion"); dataTypes.Add("list", "list"); dataTypes.Add("null", "null"); - } - + public string Convert(string Script) { string Return = ""; @@ -81,7 +78,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL int quote_replaced_count = 0; for (int p = 0; p < Script.Length; p++) { - C = Script.Substring(p, 1); while (true) { @@ -99,10 +95,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL if (quote == "") { // We didn't replace quote, probably because of empty string? - _Script += quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); + _Script += quote_replacement_string + + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); } // We just left a quote - quotes.Add(quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote); + quotes.Add( + quote_replacement_string + + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote); quote = ""; } break; @@ -112,7 +111,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL { // We are not inside a quote quote_replaced = false; - } else { @@ -120,7 +118,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL if (!quote_replaced) { // Replace quote - _Script += quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); + _Script += quote_replacement_string + + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); quote_replaced = true; } quote += C; @@ -141,7 +140,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL // - // // PROCESS STATES // Remove state definitions and add state names to start of each event within state @@ -170,7 +168,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL if (ilevel == 1 && lastlevel == 0) { // 0 => 1: Get last - Match m = Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Match m = + Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); in_state = false; if (m.Success) @@ -179,7 +179,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL in_state = true; current_statename = m.Groups[1].Captures[0].Value; //Console.WriteLine("Current statename: " + current_statename); - cache = Regex.Replace(cache, @"(?(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){", "${s1}${s2}", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + cache = + Regex.Replace(cache, + @"(?(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){", + "${s1}${s2}", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); } ret += cache; cache = ""; @@ -196,7 +200,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL // void dataserver(key query_id, string data) { //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); //Console.WriteLine("Replacing using statename: " + current_statename); - cache = Regex.Replace(cache, @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1public " + current_statename + "_event_$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + cache = + Regex.Replace(cache, + @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", + @"$1public " + current_statename + "_event_$2", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); } ret += cache; @@ -216,32 +224,48 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL ret = ""; - foreach (string key in dataTypes.Keys) { string val; dataTypes.TryGetValue(key, out val); // Replace CAST - (integer) with (int) - Script = Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")", RegexOptions.Compiled | RegexOptions.Multiline); + Script = + Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")", + RegexOptions.Compiled | RegexOptions.Multiline); // Replace return types and function variables - integer a() and f(integer a, integer a) - Script = Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)", @"$1$2" + val + "$3", RegexOptions.Compiled | RegexOptions.Multiline); + Script = + Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)", @"$1$2" + val + "$3", + RegexOptions.Compiled | RegexOptions.Multiline); } // Add "void" in front of functions that needs it - Script = Regex.Replace(Script, @"^(\s*public\s+)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, + @"^(\s*public\s+)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", + @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // Replace and - Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); - Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Vector3($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Vector3($1)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // Replace List []'s - Script = Regex.Replace(Script, @"\[([^\]]*)\]", @"List.Parse($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"\[([^\]]*)\]", @"List.Parse($1)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // Replace (string) to .ToString() // - Script = Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.ToString()", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); - Script = Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.Parse($2)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.ToString()", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.Parse($2)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // REPLACE BACK QUOTES @@ -256,7 +280,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL // Add namespace, class name and inheritance Return = "" + - "using OpenSim.Region.ScriptEngine.Common;"; + "using OpenSim.Region.ScriptEngine.Common;"; //"using System; " + //"using System.Collections.Generic; " + //"using System.Text; " + @@ -278,17 +302,15 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL Return += "" + - "namespace SecondLife { "; - Return += "" + - //"[Serializable] " + - "public class Script : OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { "; + "namespace SecondLife { "; + Return += "" + + //"[Serializable] " + + "public class Script : OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { "; Return += @"public Script() { } "; Return += Script; Return += "} }\r\n"; return Return; } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index a5fe7f1..1f5e6da 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -28,476 +28,1788 @@ using System; using System.Collections.Generic; -using System.Text; -using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler; -using OpenSim.Region.ScriptEngine.Common; -using System.Threading; -using System.Reflection; using System.Runtime.Remoting.Lifetime; +using System.Threading; +using OpenSim.Region.ScriptEngine.Common; using integer = System.Int32; using key = System.String; using vector = OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3; using rotation = OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion; -namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL -{ - //[Serializable] - public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript - { +namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL +{ + //[Serializable] + public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript + { + // Object never expires + public override Object InitializeLifetimeService() + { + //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()"); + // return null; + ILease lease = (ILease) base.InitializeLifetimeService(); + + if (lease.CurrentState == LeaseState.Initial) + { + lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); + //lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); + //lease.RenewOnCallTime = TimeSpan.FromSeconds(2); + } + return lease; + } + + + private Executor m_Exec; + + public Executor Exec + { + get + { + if (m_Exec == null) + m_Exec = new Executor(this); + return m_Exec; + } + } + + public LSL_BuiltIn_Commands_Interface m_LSL_Functions; + public string SourceCode = ""; + + public LSL_BaseClass() + { + } + + public string State() + { + return m_LSL_Functions.State(); + } + + + public void Start(LSL_BuiltIn_Commands_Interface LSL_Functions) + { + m_LSL_Functions = LSL_Functions; + + //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called."); + + // Get this AppDomain's settings and display some of them. + AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation; + Console.WriteLine("AppName={0}, AppBase={1}, ConfigFile={2}", + ads.ApplicationName, + ads.ApplicationBase, + ads.ConfigurationFile + ); + + // Display the name of the calling AppDomain and the name + // of the second domain. + // NOTE: The application's thread has transitioned between + // AppDomains. + Console.WriteLine("Calling to '{0}'.", + Thread.GetDomain().FriendlyName + ); + + return; + } + + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + // They are only forwarders to LSL_BuiltIn_Commands.cs + // + public double llSin(double f) + { + return m_LSL_Functions.llSin(f); + } + + public double llCos(double f) + { + return m_LSL_Functions.llCos(f); + } + + public double llTan(double f) + { + return m_LSL_Functions.llTan(f); + } + + public double llAtan2(double x, double y) + { + return m_LSL_Functions.llAtan2(x, y); + } + + public double llSqrt(double f) + { + return m_LSL_Functions.llSqrt(f); + } + + public double llPow(double fbase, double fexponent) + { + return m_LSL_Functions.llPow(fbase, fexponent); + } + + public int llAbs(int i) + { + return m_LSL_Functions.llAbs(i); + } + + public double llFabs(double f) + { + return m_LSL_Functions.llFabs(f); + } + + public double llFrand(double mag) + { + return m_LSL_Functions.llFrand(mag); + } + + public int llFloor(double f) + { + return m_LSL_Functions.llFloor(f); + } + + public int llCeil(double f) + { + return m_LSL_Functions.llCeil(f); + } + + public int llRound(double f) + { + return m_LSL_Functions.llRound(f); + } + + public double llVecMag(vector v) + { + return m_LSL_Functions.llVecMag(v); + } + + public vector llVecNorm(vector v) + { + return m_LSL_Functions.llVecNorm(v); + } + + public double llVecDist(vector a, vector b) + { + return m_LSL_Functions.llVecDist(a, b); + } + + public vector llRot2Euler(rotation r) + { + return m_LSL_Functions.llRot2Euler(r); + } + + public rotation llEuler2Rot(vector v) + { + return m_LSL_Functions.llEuler2Rot(v); + } + + public rotation llAxes2Rot(vector fwd, vector left, vector up) + { + return m_LSL_Functions.llAxes2Rot(fwd, left, up); + } + + public vector llRot2Fwd(rotation r) + { + return m_LSL_Functions.llRot2Fwd(r); + } + + public vector llRot2Left(rotation r) + { + return m_LSL_Functions.llRot2Left(r); + } + + public vector llRot2Up(rotation r) + { + return m_LSL_Functions.llRot2Up(r); + } + + public rotation llRotBetween(vector start, vector end) + { + return m_LSL_Functions.llRotBetween(start, end); + } + + public void llWhisper(int channelID, string text) + { + m_LSL_Functions.llWhisper(channelID, text); + } + + public void llSay(int channelID, string text) + { + m_LSL_Functions.llSay(channelID, text); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llShout(int channelID, string text) + { + m_LSL_Functions.llShout(channelID, text); + } + + public int llListen(int channelID, string name, string ID, string msg) + { + return m_LSL_Functions.llListen(channelID, name, ID, msg); + } + + public void llListenControl(int number, int active) + { + m_LSL_Functions.llListenControl(number, active); + } + + public void llListenRemove(int number) + { + m_LSL_Functions.llListenRemove(number); + } + + public void llSensor(string name, string id, int type, double range, double arc) + { + m_LSL_Functions.llSensor(name, id, type, range, arc); + } + + public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) + { + m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate); + } + + public void llSensorRemove() + { + m_LSL_Functions.llSensorRemove(); + } + + public string llDetectedName(int number) + { + return m_LSL_Functions.llDetectedName(number); + } + + public string llDetectedKey(int number) + { + return m_LSL_Functions.llDetectedKey(number); + } + + public string llDetectedOwner(int number) + { + return m_LSL_Functions.llDetectedOwner(number); + } + + public int llDetectedType(int number) + { + return m_LSL_Functions.llDetectedType(number); + } + + public vector llDetectedPos(int number) + { + return m_LSL_Functions.llDetectedPos(number); + } + + public vector llDetectedVel(int number) + { + return m_LSL_Functions.llDetectedVel(number); + } + + public vector llDetectedGrab(int number) + { + return m_LSL_Functions.llDetectedGrab(number); + } + + public rotation llDetectedRot(int number) + { + return m_LSL_Functions.llDetectedRot(number); + } + + public int llDetectedGroup(int number) + { + return m_LSL_Functions.llDetectedGroup(number); + } + + public int llDetectedLinkNumber(int number) + { + return m_LSL_Functions.llDetectedLinkNumber(number); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llDie() + { + m_LSL_Functions.llDie(); + } + + public double llGround(vector offset) + { + return m_LSL_Functions.llGround(offset); + } + + public double llCloud(vector offset) + { + return m_LSL_Functions.llCloud(offset); + } + + public vector llWind(vector offset) + { + return m_LSL_Functions.llWind(offset); + } + + public void llSetStatus(int status, int value) + { + m_LSL_Functions.llSetStatus(status, value); + } + + public int llGetStatus(int status) + { + return m_LSL_Functions.llGetStatus(status); + } + + public void llSetScale(vector scale) + { + m_LSL_Functions.llSetScale(scale); + } + + public vector llGetScale() + { + return m_LSL_Functions.llGetScale(); + } + + public void llSetColor(vector color, int face) + { + m_LSL_Functions.llSetColor(color, face); + } + + public double llGetAlpha(int face) + { + return m_LSL_Functions.llGetAlpha(face); + } + + public void llSetAlpha(double alpha, int face) + { + m_LSL_Functions.llSetAlpha(alpha, face); + } + + public vector llGetColor(int face) + { + return m_LSL_Functions.llGetColor(face); + } + + public void llSetTexture(string texture, int face) + { + m_LSL_Functions.llSetTexture(texture, face); + } + + public void llScaleTexture(double u, double v, int face) + { + m_LSL_Functions.llScaleTexture(u, v, face); + } + + public void llOffsetTexture(double u, double v, int face) + { + m_LSL_Functions.llOffsetTexture(u, v, face); + } + + public void llRotateTexture(double rotation, int face) + { + m_LSL_Functions.llRotateTexture(rotation, face); + } + + public string llGetTexture(int face) + { + return m_LSL_Functions.llGetTexture(face); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llSetPos(vector pos) + { + m_LSL_Functions.llSetPos(pos); + } + + public vector llGetPos() + { + return m_LSL_Functions.llGetPos(); + } + + public vector llGetLocalPos() + { + return m_LSL_Functions.llGetLocalPos(); + } + + public void llSetRot(rotation rot) + { + m_LSL_Functions.llSetRot(rot); + } + + public rotation llGetRot() + { + return m_LSL_Functions.llGetRot(); + } + + public rotation llGetLocalRot() + { + return m_LSL_Functions.llGetLocalRot(); + } + + public void llSetForce(vector force, int local) + { + m_LSL_Functions.llSetForce(force, local); + } + + public vector llGetForce() + { + return m_LSL_Functions.llGetForce(); + } + + public int llTarget(vector position, double range) + { + return m_LSL_Functions.llTarget(position, range); + } + + public void llTargetRemove(int number) + { + m_LSL_Functions.llTargetRemove(number); + } + + public int llRotTarget(rotation rot, double error) + { + return m_LSL_Functions.llRotTarget(rot, error); + } + + public void llRotTargetRemove(int number) + { + m_LSL_Functions.llRotTargetRemove(number); + } + + public void llMoveToTarget(vector target, double tau) + { + m_LSL_Functions.llMoveToTarget(target, tau); + } + + public void llStopMoveToTarget() + { + m_LSL_Functions.llStopMoveToTarget(); + } + + public void llApplyImpulse(vector force, int local) + { + m_LSL_Functions.llApplyImpulse(force, local); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llApplyRotationalImpulse(vector force, int local) + { + m_LSL_Functions.llApplyRotationalImpulse(force, local); + } + + public void llSetTorque(vector torque, int local) + { + m_LSL_Functions.llSetTorque(torque, local); + } + + public vector llGetTorque() + { + return m_LSL_Functions.llGetTorque(); + } + + public void llSetForceAndTorque(vector force, vector torque, int local) + { + m_LSL_Functions.llSetForceAndTorque(force, torque, local); + } + + public vector llGetVel() + { + return m_LSL_Functions.llGetVel(); + } + + public vector llGetAccel() + { + return m_LSL_Functions.llGetAccel(); + } + + public vector llGetOmega() + { + return m_LSL_Functions.llGetOmega(); + } + + public double llGetTimeOfDay() + { + return m_LSL_Functions.llGetTimeOfDay(); + } + + public double llGetWallclock() + { + return m_LSL_Functions.llGetWallclock(); + } + + public double llGetTime() + { + return m_LSL_Functions.llGetTime(); + } + + public void llResetTime() + { + m_LSL_Functions.llResetTime(); + } + + public double llGetAndResetTime() + { + return m_LSL_Functions.llGetAndResetTime(); + } + + public void llSound() + { + m_LSL_Functions.llSound(); + } + + public void llPlaySound(string sound, double volume) + { + m_LSL_Functions.llPlaySound(sound, volume); + } + + public void llLoopSound(string sound, double volume) + { + m_LSL_Functions.llLoopSound(sound, volume); + } + + public void llLoopSoundMaster(string sound, double volume) + { + m_LSL_Functions.llLoopSoundMaster(sound, volume); + } + + public void llLoopSoundSlave(string sound, double volume) + { + m_LSL_Functions.llLoopSoundSlave(sound, volume); + } + + public void llPlaySoundSlave(string sound, double volume) + { + m_LSL_Functions.llPlaySoundSlave(sound, volume); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llTriggerSound(string sound, double volume) + { + m_LSL_Functions.llTriggerSound(sound, volume); + } + + public void llStopSound() + { + m_LSL_Functions.llStopSound(); + } + + public void llPreloadSound(string sound) + { + m_LSL_Functions.llPreloadSound(sound); + } + + public string llGetSubString(string src, int start, int end) + { + return m_LSL_Functions.llGetSubString(src, start, end); + } + + public string llDeleteSubString(string src, int start, int end) + { + return m_LSL_Functions.llDeleteSubString(src, start, end); + } + + public string llInsertString(string dst, int position, string src) + { + return m_LSL_Functions.llInsertString(dst, position, src); + } + + public string llToUpper(string source) + { + return m_LSL_Functions.llToUpper(source); + } + + public string llToLower(string source) + { + return m_LSL_Functions.llToLower(source); + } + + public int llGiveMoney(string destination, int amount) + { + return m_LSL_Functions.llGiveMoney(destination, amount); + } + + public void llMakeExplosion() + { + m_LSL_Functions.llMakeExplosion(); + } + + public void llMakeFountain() + { + m_LSL_Functions.llMakeFountain(); + } + + public void llMakeSmoke() + { + m_LSL_Functions.llMakeSmoke(); + } + + public void llMakeFire() + { + m_LSL_Functions.llMakeFire(); + } + + public void llRezObject(string inventory, vector pos, rotation rot, int param) + { + m_LSL_Functions.llRezObject(inventory, pos, rot, param); + } + + public void llLookAt(vector target, double strength, double damping) + { + m_LSL_Functions.llLookAt(target, strength, damping); + } + + public void llStopLookAt() + { + m_LSL_Functions.llStopLookAt(); + } + + public void llSetTimerEvent(double sec) + { + m_LSL_Functions.llSetTimerEvent(sec); + } + + public void llSleep(double sec) + { + m_LSL_Functions.llSleep(sec); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public double llGetMass() + { + return m_LSL_Functions.llGetMass(); + } + + public void llCollisionFilter(string name, string id, int accept) + { + m_LSL_Functions.llCollisionFilter(name, id, accept); + } + + public void llTakeControls(int controls, int accept, int pass_on) + { + m_LSL_Functions.llTakeControls(controls, accept, pass_on); + } + + public void llReleaseControls() + { + m_LSL_Functions.llReleaseControls(); + } + + public void llAttachToAvatar(int attachment) + { + m_LSL_Functions.llAttachToAvatar(attachment); + } + + public void llDetachFromAvatar() + { + m_LSL_Functions.llDetachFromAvatar(); + } + + public void llTakeCamera() + { + m_LSL_Functions.llTakeCamera(); + } + + public void llReleaseCamera() + { + m_LSL_Functions.llReleaseCamera(); + } + + public string llGetOwner() + { + return m_LSL_Functions.llGetOwner(); + } + + public void llInstantMessage(string user, string message) + { + m_LSL_Functions.llInstantMessage(user, message); + } + + public void llEmail(string address, string subject, string message) + { + m_LSL_Functions.llEmail(address, subject, message); + } + + public void llGetNextEmail(string address, string subject) + { + m_LSL_Functions.llGetNextEmail(address, subject); + } + + public string llGetKey() + { + return m_LSL_Functions.llGetKey(); + } + + public void llSetBuoyancy(double buoyancy) + { + m_LSL_Functions.llSetBuoyancy(buoyancy); + } + + public void llSetHoverHeight(double height, int water, double tau) + { + m_LSL_Functions.llSetHoverHeight(height, water, tau); + } + + public void llStopHover() + { + m_LSL_Functions.llStopHover(); + } + + public void llMinEventDelay(double delay) + { + m_LSL_Functions.llMinEventDelay(delay); + } + + public void llSoundPreload() + { + m_LSL_Functions.llSoundPreload(); + } + + public void llRotLookAt(rotation target, double strength, double damping) + { + m_LSL_Functions.llRotLookAt(target, strength, damping); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public int llStringLength(string str) + { + return m_LSL_Functions.llStringLength(str); + } + + public void llStartAnimation(string anim) + { + m_LSL_Functions.llStartAnimation(anim); + } + + public void llStopAnimation(string anim) + { + m_LSL_Functions.llStopAnimation(anim); + } + + public void llPointAt() + { + m_LSL_Functions.llPointAt(); + } + + public void llStopPointAt() + { + m_LSL_Functions.llStopPointAt(); + } + + public void llTargetOmega(vector axis, double spinrate, double gain) + { + m_LSL_Functions.llTargetOmega(axis, spinrate, gain); + } + + public int llGetStartParameter() + { + return m_LSL_Functions.llGetStartParameter(); + } + + public void llGodLikeRezObject(string inventory, vector pos) + { + m_LSL_Functions.llGodLikeRezObject(inventory, pos); + } + + public void llRequestPermissions(string agent, int perm) + { + m_LSL_Functions.llRequestPermissions(agent, perm); + } + + public string llGetPermissionsKey() + { + return m_LSL_Functions.llGetPermissionsKey(); + } + + public int llGetPermissions() + { + return m_LSL_Functions.llGetPermissions(); + } + + public int llGetLinkNumber() + { + return m_LSL_Functions.llGetLinkNumber(); + } + + public void llSetLinkColor(int linknumber, vector color, int face) + { + m_LSL_Functions.llSetLinkColor(linknumber, color, face); + } + + public void llCreateLink(string target, int parent) + { + m_LSL_Functions.llCreateLink(target, parent); + } + + public void llBreakLink(int linknum) + { + m_LSL_Functions.llBreakLink(linknum); + } + + public void llBreakAllLinks() + { + m_LSL_Functions.llBreakAllLinks(); + } + + public string llGetLinkKey(int linknum) + { + return m_LSL_Functions.llGetLinkKey(linknum); + } + + public void llGetLinkName(int linknum) + { + m_LSL_Functions.llGetLinkName(linknum); + } + + public int llGetInventoryNumber(int type) + { + return m_LSL_Functions.llGetInventoryNumber(type); + } + + public string llGetInventoryName(int type, int number) + { + return m_LSL_Functions.llGetInventoryName(type, number); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llSetScriptState(string name, int run) + { + m_LSL_Functions.llSetScriptState(name, run); + } + + public double llGetEnergy() + { + return m_LSL_Functions.llGetEnergy(); + } + + public void llGiveInventory(string destination, string inventory) + { + m_LSL_Functions.llGiveInventory(destination, inventory); + } + + public void llRemoveInventory(string item) + { + m_LSL_Functions.llRemoveInventory(item); + } + + public void llSetText(string text, vector color, double alpha) + { + m_LSL_Functions.llSetText(text, color, alpha); + } + + public double llWater(vector offset) + { + return m_LSL_Functions.llWater(offset); + } + + public void llPassTouches(int pass) + { + m_LSL_Functions.llPassTouches(pass); + } + + public string llRequestAgentData(string id, int data) + { + return m_LSL_Functions.llRequestAgentData(id, data); + } + + public string llRequestInventoryData(string name) + { + return m_LSL_Functions.llRequestInventoryData(name); + } + + public void llSetDamage(double damage) + { + m_LSL_Functions.llSetDamage(damage); + } + + public void llTeleportAgentHome(string agent) + { + m_LSL_Functions.llTeleportAgentHome(agent); + } + + public void llModifyLand(int action, int brush) + { + m_LSL_Functions.llModifyLand(action, brush); + } + + public void llCollisionSound(string impact_sound, double impact_volume) + { + m_LSL_Functions.llCollisionSound(impact_sound, impact_volume); + } + + public void llCollisionSprite(string impact_sprite) + { + m_LSL_Functions.llCollisionSprite(impact_sprite); + } + + public string llGetAnimation(string id) + { + return m_LSL_Functions.llGetAnimation(id); + } + + public void llResetScript() + { + m_LSL_Functions.llResetScript(); + } + + public void llMessageLinked(int linknum, int num, string str, string id) + { + m_LSL_Functions.llMessageLinked(linknum, num, str, id); + } + + public void llPushObject(string target, vector impulse, vector ang_impulse, int local) + { + m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local); + } + + public void llPassCollisions(int pass) + { + m_LSL_Functions.llPassCollisions(pass); + } + + public string llGetScriptName() + { + return m_LSL_Functions.llGetScriptName(); + } + + public int llGetNumberOfSides() + { + return m_LSL_Functions.llGetNumberOfSides(); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public rotation llAxisAngle2Rot(vector axis, double angle) + { + return m_LSL_Functions.llAxisAngle2Rot(axis, angle); + } + + public vector llRot2Axis(rotation rot) + { + return m_LSL_Functions.llRot2Axis(rot); + } + + public void llRot2Angle() + { + m_LSL_Functions.llRot2Angle(); + } + + public double llAcos(double val) + { + return m_LSL_Functions.llAcos(val); + } + + public double llAsin(double val) + { + return m_LSL_Functions.llAsin(val); + } + + public double llAngleBetween(rotation a, rotation b) + { + return m_LSL_Functions.llAngleBetween(a, b); + } + + public string llGetInventoryKey(string name) + { + return m_LSL_Functions.llGetInventoryKey(name); + } + + public void llAllowInventoryDrop(int add) + { + m_LSL_Functions.llAllowInventoryDrop(add); + } + + public vector llGetSunDirection() + { + return m_LSL_Functions.llGetSunDirection(); + } + + public vector llGetTextureOffset(int face) + { + return m_LSL_Functions.llGetTextureOffset(face); + } + + public vector llGetTextureScale(int side) + { + return m_LSL_Functions.llGetTextureScale(side); + } + + public double llGetTextureRot(int side) + { + return m_LSL_Functions.llGetTextureRot(side); + } + + public int llSubStringIndex(string source, string pattern) + { + return m_LSL_Functions.llSubStringIndex(source, pattern); + } + + public string llGetOwnerKey(string id) + { + return m_LSL_Functions.llGetOwnerKey(id); + } + + public vector llGetCenterOfMass() + { + return m_LSL_Functions.llGetCenterOfMass(); + } + + public List llListSort(List src, int stride, int ascending) + { + return m_LSL_Functions.llListSort(src, stride, ascending); + } + + public int llGetListLength(List src) + { + return m_LSL_Functions.llGetListLength(src); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public int llList2Integer(List src, int index) + { + return m_LSL_Functions.llList2Integer(src, index); + } + + public double llList2double(List src, int index) + { + return m_LSL_Functions.llList2double(src, index); + } + + public string llList2String(List src, int index) + { + return m_LSL_Functions.llList2String(src, index); + } + + public string llList2Key(List src, int index) + { + return m_LSL_Functions.llList2Key(src, index); + } + + public vector llList2Vector(List src, int index) + { + return m_LSL_Functions.llList2Vector(src, index); + } + + public rotation llList2Rot(List src, int index) + { + return m_LSL_Functions.llList2Rot(src, index); + } + + public List llList2List(List src, int start, int end) + { + return m_LSL_Functions.llList2List(src, start, end); + } + + public List llDeleteSubList(List src, int start, int end) + { + return m_LSL_Functions.llDeleteSubList(src, start, end); + } + + public int llGetListEntryType(List src, int index) + { + return m_LSL_Functions.llGetListEntryType(src, index); + } + + public string llList2CSV(List src) + { + return m_LSL_Functions.llList2CSV(src); + } + + public List llCSV2List(string src) + { + return m_LSL_Functions.llCSV2List(src); + } + + public List llListRandomize(List src, int stride) + { + return m_LSL_Functions.llListRandomize(src, stride); + } + + public List llList2ListStrided(List src, int start, int end, int stride) + { + return m_LSL_Functions.llList2ListStrided(src, start, end, stride); + } + + public vector llGetRegionCorner() + { + return m_LSL_Functions.llGetRegionCorner(); + } + + public List llListInsertList(List dest, List src, int start) + { + return m_LSL_Functions.llListInsertList(dest, src, start); + } + + public int llListFindList(List src, List test) + { + return m_LSL_Functions.llListFindList(src, test); + } + + public string llGetObjectName() + { + return m_LSL_Functions.llGetObjectName(); + } + + public void llSetObjectName(string name) + { + m_LSL_Functions.llSetObjectName(name); + } + + public string llGetDate() + { + return m_LSL_Functions.llGetDate(); + } + + public int llEdgeOfWorld(vector pos, vector dir) + { + return m_LSL_Functions.llEdgeOfWorld(pos, dir); + } + + public int llGetAgentInfo(string id) + { + return m_LSL_Functions.llGetAgentInfo(id); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llAdjustSoundVolume(double volume) + { + m_LSL_Functions.llAdjustSoundVolume(volume); + } + + public void llSetSoundQueueing(int queue) + { + m_LSL_Functions.llSetSoundQueueing(queue); + } + + public void llSetSoundRadius(double radius) + { + m_LSL_Functions.llSetSoundRadius(radius); + } + + public string llKey2Name(string id) + { + return m_LSL_Functions.llKey2Name(id); + } + + public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) + { + m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate); + } + + public void llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west) + { + m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west); + } + + public void llEjectFromLand(string pest) + { + m_LSL_Functions.llEjectFromLand(pest); + } + + public void llParseString2List() + { + m_LSL_Functions.llParseString2List(); + } + + public int llOverMyLand(string id) + { + return m_LSL_Functions.llOverMyLand(id); + } + + public string llGetLandOwnerAt(vector pos) + { + return m_LSL_Functions.llGetLandOwnerAt(pos); + } + + public string llGetNotecardLine(string name, int line) + { + return m_LSL_Functions.llGetNotecardLine(name, line); + } + + public vector llGetAgentSize(string id) + { + return m_LSL_Functions.llGetAgentSize(id); + } + + public int llSameGroup(string agent) + { + return m_LSL_Functions.llSameGroup(agent); + } + + public void llUnSit(string id) + { + m_LSL_Functions.llUnSit(id); + } + + public vector llGroundSlope(vector offset) + { + return m_LSL_Functions.llGroundSlope(offset); + } + + public vector llGroundNormal(vector offset) + { + return m_LSL_Functions.llGroundNormal(offset); + } + + public vector llGroundContour(vector offset) + { + return m_LSL_Functions.llGroundContour(offset); + } + + public int llGetAttached() + { + return m_LSL_Functions.llGetAttached(); + } + + public int llGetFreeMemory() + { + return m_LSL_Functions.llGetFreeMemory(); + } + + public string llGetRegionName() + { + return m_LSL_Functions.llGetRegionName(); + } + + public double llGetRegionTimeDilation() + { + return m_LSL_Functions.llGetRegionTimeDilation(); + } + + public double llGetRegionFPS() + { + return m_LSL_Functions.llGetRegionFPS(); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llParticleSystem(List rules) + { + m_LSL_Functions.llParticleSystem(rules); + } + + public void llGroundRepel(double height, int water, double tau) + { + m_LSL_Functions.llGroundRepel(height, water, tau); + } + + public void llGiveInventoryList() + { + m_LSL_Functions.llGiveInventoryList(); + } + + public void llSetVehicleType(int type) + { + m_LSL_Functions.llSetVehicleType(type); + } + + public void llSetVehicledoubleParam(int param, double value) + { + m_LSL_Functions.llSetVehicledoubleParam(param, value); + } + + public void llSetVehicleVectorParam(int param, vector vec) + { + m_LSL_Functions.llSetVehicleVectorParam(param, vec); + } + + public void llSetVehicleRotationParam(int param, rotation rot) + { + m_LSL_Functions.llSetVehicleRotationParam(param, rot); + } + + public void llSetVehicleFlags(int flags) + { + m_LSL_Functions.llSetVehicleFlags(flags); + } + + public void llRemoveVehicleFlags(int flags) + { + m_LSL_Functions.llRemoveVehicleFlags(flags); + } + + public void llSitTarget(vector offset, rotation rot) + { + m_LSL_Functions.llSitTarget(offset, rot); + } + + public string llAvatarOnSitTarget() + { + return m_LSL_Functions.llAvatarOnSitTarget(); + } + + public void llAddToLandPassList(string avatar, double hours) + { + m_LSL_Functions.llAddToLandPassList(avatar, hours); + } + + public void llSetTouchText(string text) + { + m_LSL_Functions.llSetTouchText(text); + } + + public void llSetSitText(string text) + { + m_LSL_Functions.llSetSitText(text); + } + + public void llSetCameraEyeOffset(vector offset) + { + m_LSL_Functions.llSetCameraEyeOffset(offset); + } + + public void llSetCameraAtOffset(vector offset) + { + m_LSL_Functions.llSetCameraAtOffset(offset); + } + + public void llDumpList2String() + { + m_LSL_Functions.llDumpList2String(); + } + + public void llScriptDanger(vector pos) + { + m_LSL_Functions.llScriptDanger(pos); + } + + public void llDialog(string avatar, string message, List buttons, int chat_channel) + { + m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); + } + + public void llVolumeDetect(int detect) + { + m_LSL_Functions.llVolumeDetect(detect); + } + + public void llResetOtherScript(string name) + { + m_LSL_Functions.llResetOtherScript(name); + } + + public int llGetScriptState(string name) + { + return m_LSL_Functions.llGetScriptState(name); + } + + public void llRemoteLoadScript() + { + m_LSL_Functions.llRemoteLoadScript(); + } + + public void llSetRemoteScriptAccessPin(int pin) + { + m_LSL_Functions.llSetRemoteScriptAccessPin(pin); + } + + public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) + { + m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llOpenRemoteDataChannel() + { + m_LSL_Functions.llOpenRemoteDataChannel(); + } + + public string llSendRemoteData(string channel, string dest, int idata, string sdata) + { + return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); + } + + public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) + { + m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata); + } + + public void llCloseRemoteDataChannel(string channel) + { + m_LSL_Functions.llCloseRemoteDataChannel(channel); + } + + public string llMD5String(string src, int nonce) + { + return m_LSL_Functions.llMD5String(src, nonce); + } + + public void llSetPrimitiveParams(List rules) + { + m_LSL_Functions.llSetPrimitiveParams(rules); + } + + public string llStringToBase64(string str) + { + return m_LSL_Functions.llStringToBase64(str); + } + + public string llBase64ToString(string str) + { + return m_LSL_Functions.llBase64ToString(str); + } + + public void llXorBase64Strings() + { + m_LSL_Functions.llXorBase64Strings(); + } + + public void llRemoteDataSetRegion() + { + m_LSL_Functions.llRemoteDataSetRegion(); + } + + public double llLog10(double val) + { + return m_LSL_Functions.llLog10(val); + } - // Object never expires - public override Object InitializeLifetimeService() + public double llLog(double val) { - //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()"); - // return null; - ILease lease = (ILease)base.InitializeLifetimeService(); + return m_LSL_Functions.llLog(val); + } - if (lease.CurrentState == LeaseState.Initial) - { - lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); - //lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); - //lease.RenewOnCallTime = TimeSpan.FromSeconds(2); - } - return lease; + public List llGetAnimationList(string id) + { + return m_LSL_Functions.llGetAnimationList(id); } + public void llSetParcelMusicURL(string url) + { + m_LSL_Functions.llSetParcelMusicURL(url); + } - private Executor m_Exec; - public Executor Exec + public vector llGetRootPosition() { - get - { - if (m_Exec == null) - m_Exec = new Executor(this); - return m_Exec; - } + return m_LSL_Functions.llGetRootPosition(); } - public LSL_BuiltIn_Commands_Interface m_LSL_Functions; - public string SourceCode = ""; + public rotation llGetRootRotation() + { + return m_LSL_Functions.llGetRootRotation(); + } - public LSL_BaseClass() + public string llGetObjectDesc() { + return m_LSL_Functions.llGetObjectDesc(); } - public string State() + + public void llSetObjectDesc(string desc) { - return m_LSL_Functions.State(); + m_LSL_Functions.llSetObjectDesc(desc); } + public string llGetCreator() + { + return m_LSL_Functions.llGetCreator(); + } - public void Start(LSL_BuiltIn_Commands_Interface LSL_Functions) + public string llGetTimestamp() { - m_LSL_Functions = LSL_Functions; + return m_LSL_Functions.llGetTimestamp(); + } - //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called."); + public void llSetLinkAlpha(int linknumber, double alpha, int face) + { + m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face); + } - // Get this AppDomain's settings and display some of them. - AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation; - Console.WriteLine("AppName={0}, AppBase={1}, ConfigFile={2}", - ads.ApplicationName, - ads.ApplicationBase, - ads.ConfigurationFile - ); + public int llGetNumberOfPrims() + { + return m_LSL_Functions.llGetNumberOfPrims(); + } - // Display the name of the calling AppDomain and the name - // of the second domain. - // NOTE: The application's thread has transitioned between - // AppDomains. - Console.WriteLine("Calling to '{0}'.", - Thread.GetDomain().FriendlyName - ); + public string llGetNumberOfNotecardLines(string name) + { + return m_LSL_Functions.llGetNumberOfNotecardLines(name); + } - return; + public List llGetBoundingBox(string obj) + { + return m_LSL_Functions.llGetBoundingBox(obj); } + public vector llGetGeometricCenter() + { + return m_LSL_Functions.llGetGeometricCenter(); + } + public void llGetPrimitiveParams() + { + m_LSL_Functions.llGetPrimitiveParams(); + } // // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs // - // They are only forwarders to LSL_BuiltIn_Commands.cs - // - public double llSin(double f) { return m_LSL_Functions.llSin(f); } - public double llCos(double f) { return m_LSL_Functions.llCos(f); } - public double llTan(double f) { return m_LSL_Functions.llTan(f); } - public double llAtan2(double x, double y) { return m_LSL_Functions.llAtan2(x, y); } - public double llSqrt(double f) { return m_LSL_Functions.llSqrt(f); } - public double llPow(double fbase, double fexponent) { return m_LSL_Functions.llPow(fbase, fexponent); } - public int llAbs(int i) { return m_LSL_Functions.llAbs(i); } - public double llFabs(double f) { return m_LSL_Functions.llFabs(f); } - public double llFrand(double mag) { return m_LSL_Functions.llFrand(mag); } - public int llFloor(double f) { return m_LSL_Functions.llFloor(f); } - public int llCeil(double f) { return m_LSL_Functions.llCeil(f); } - public int llRound(double f) { return m_LSL_Functions.llRound(f); } - public double llVecMag(LSL_Types.Vector3 v) { return m_LSL_Functions.llVecMag(v); } - public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) { return m_LSL_Functions.llVecNorm(v); } - public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) { return m_LSL_Functions.llVecDist(a, b); } - public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Euler(r); } - public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) { return m_LSL_Functions.llEuler2Rot(v); } - public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return m_LSL_Functions.llAxes2Rot(fwd, left, up); } - public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Fwd(r); } - public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Left(r); } - public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Up(r); } - public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) { return m_LSL_Functions.llRotBetween(start, end); } - public void llWhisper(int channelID, string text) { m_LSL_Functions.llWhisper(channelID, text); } - public void llSay(int channelID, string text) { m_LSL_Functions.llSay(channelID, text); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llShout(int channelID, string text) { m_LSL_Functions.llShout(channelID, text); } - public int llListen(int channelID, string name, string ID, string msg) { return m_LSL_Functions.llListen(channelID, name, ID, msg); } - public void llListenControl(int number, int active) { m_LSL_Functions.llListenControl(number, active); } - public void llListenRemove(int number) { m_LSL_Functions.llListenRemove(number); } - public void llSensor(string name, string id, int type, double range, double arc) { m_LSL_Functions.llSensor(name, id, type, range, arc); } - public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate); } - public void llSensorRemove() { m_LSL_Functions.llSensorRemove(); } - public string llDetectedName(int number) { return m_LSL_Functions.llDetectedName(number); } - public string llDetectedKey(int number) { return m_LSL_Functions.llDetectedKey(number); } - public string llDetectedOwner(int number) { return m_LSL_Functions.llDetectedOwner(number); } - public int llDetectedType(int number) { return m_LSL_Functions.llDetectedType(number); } - public LSL_Types.Vector3 llDetectedPos(int number) { return m_LSL_Functions.llDetectedPos(number); } - public LSL_Types.Vector3 llDetectedVel(int number) { return m_LSL_Functions.llDetectedVel(number); } - public LSL_Types.Vector3 llDetectedGrab(int number) { return m_LSL_Functions.llDetectedGrab(number); } - public LSL_Types.Quaternion llDetectedRot(int number) { return m_LSL_Functions.llDetectedRot(number); } - public int llDetectedGroup(int number) { return m_LSL_Functions.llDetectedGroup(number); } - public int llDetectedLinkNumber(int number) { return m_LSL_Functions.llDetectedLinkNumber(number); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llDie() { m_LSL_Functions.llDie(); } - public double llGround(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGround(offset); } - public double llCloud(LSL_Types.Vector3 offset) { return m_LSL_Functions.llCloud(offset); } - public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) { return m_LSL_Functions.llWind(offset); } - public void llSetStatus(int status, int value) { m_LSL_Functions.llSetStatus(status, value); } - public int llGetStatus(int status) { return m_LSL_Functions.llGetStatus(status); } - public void llSetScale(LSL_Types.Vector3 scale) { m_LSL_Functions.llSetScale(scale); } - public LSL_Types.Vector3 llGetScale() { return m_LSL_Functions.llGetScale(); } - public void llSetColor(LSL_Types.Vector3 color, int face) { m_LSL_Functions.llSetColor(color, face); } - public double llGetAlpha(int face) { return m_LSL_Functions.llGetAlpha(face); } - public void llSetAlpha(double alpha, int face) { m_LSL_Functions.llSetAlpha(alpha, face); } - public LSL_Types.Vector3 llGetColor(int face) { return m_LSL_Functions.llGetColor(face); } - public void llSetTexture(string texture, int face) { m_LSL_Functions.llSetTexture(texture, face); } - public void llScaleTexture(double u, double v, int face) { m_LSL_Functions.llScaleTexture(u, v, face); } - public void llOffsetTexture(double u, double v, int face) { m_LSL_Functions.llOffsetTexture(u, v, face); } - public void llRotateTexture(double rotation, int face) { m_LSL_Functions.llRotateTexture(rotation, face); } - public string llGetTexture(int face) { return m_LSL_Functions.llGetTexture(face); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llSetPos(LSL_Types.Vector3 pos) { m_LSL_Functions.llSetPos(pos); } - public LSL_Types.Vector3 llGetPos() { return m_LSL_Functions.llGetPos(); } - public LSL_Types.Vector3 llGetLocalPos() { return m_LSL_Functions.llGetLocalPos(); } - public void llSetRot(LSL_Types.Quaternion rot) { m_LSL_Functions.llSetRot(rot); } - public LSL_Types.Quaternion llGetRot() { return m_LSL_Functions.llGetRot(); } - public LSL_Types.Quaternion llGetLocalRot() { return m_LSL_Functions.llGetLocalRot(); } - public void llSetForce(LSL_Types.Vector3 force, int local) { m_LSL_Functions.llSetForce(force, local); } - public LSL_Types.Vector3 llGetForce() { return m_LSL_Functions.llGetForce(); } - public int llTarget(LSL_Types.Vector3 position, double range) { return m_LSL_Functions.llTarget(position, range); } - public void llTargetRemove(int number) { m_LSL_Functions.llTargetRemove(number); } - public int llRotTarget(LSL_Types.Quaternion rot, double error) { return m_LSL_Functions.llRotTarget(rot, error); } - public void llRotTargetRemove(int number) { m_LSL_Functions.llRotTargetRemove(number); } - public void llMoveToTarget(LSL_Types.Vector3 target, double tau) { m_LSL_Functions.llMoveToTarget(target, tau); } - public void llStopMoveToTarget() { m_LSL_Functions.llStopMoveToTarget(); } - public void llApplyImpulse(LSL_Types.Vector3 force, int local) { m_LSL_Functions.llApplyImpulse(force, local); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) { m_LSL_Functions.llApplyRotationalImpulse(force, local); } - public void llSetTorque(LSL_Types.Vector3 torque, int local) { m_LSL_Functions.llSetTorque(torque, local); } - public LSL_Types.Vector3 llGetTorque() { return m_LSL_Functions.llGetTorque(); } - public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) { m_LSL_Functions.llSetForceAndTorque(force, torque, local); } - public LSL_Types.Vector3 llGetVel() { return m_LSL_Functions.llGetVel(); } - public LSL_Types.Vector3 llGetAccel() { return m_LSL_Functions.llGetAccel(); } - public LSL_Types.Vector3 llGetOmega() { return m_LSL_Functions.llGetOmega(); } - public double llGetTimeOfDay() { return m_LSL_Functions.llGetTimeOfDay(); } - public double llGetWallclock() { return m_LSL_Functions.llGetWallclock(); } - public double llGetTime() { return m_LSL_Functions.llGetTime(); } - public void llResetTime() { m_LSL_Functions.llResetTime(); } - public double llGetAndResetTime() { return m_LSL_Functions.llGetAndResetTime(); } - public void llSound() { m_LSL_Functions.llSound(); } - public void llPlaySound(string sound, double volume) { m_LSL_Functions.llPlaySound(sound, volume); } - public void llLoopSound(string sound, double volume) { m_LSL_Functions.llLoopSound(sound, volume); } - public void llLoopSoundMaster(string sound, double volume) { m_LSL_Functions.llLoopSoundMaster(sound, volume); } - public void llLoopSoundSlave(string sound, double volume) { m_LSL_Functions.llLoopSoundSlave(sound, volume); } - public void llPlaySoundSlave(string sound, double volume) { m_LSL_Functions.llPlaySoundSlave(sound, volume); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llTriggerSound(string sound, double volume) { m_LSL_Functions.llTriggerSound(sound, volume); } - public void llStopSound() { m_LSL_Functions.llStopSound(); } - public void llPreloadSound(string sound) { m_LSL_Functions.llPreloadSound(sound); } - public string llGetSubString(string src, int start, int end) { return m_LSL_Functions.llGetSubString(src, start, end); } - public string llDeleteSubString(string src, int start, int end) { return m_LSL_Functions.llDeleteSubString(src, start, end); } - public string llInsertString(string dst, int position, string src) { return m_LSL_Functions.llInsertString(dst, position, src); } - public string llToUpper(string source) { return m_LSL_Functions.llToUpper(source); } - public string llToLower(string source) { return m_LSL_Functions.llToLower(source); } - public int llGiveMoney(string destination, int amount) { return m_LSL_Functions.llGiveMoney(destination, amount); } - public void llMakeExplosion() { m_LSL_Functions.llMakeExplosion(); } - public void llMakeFountain() { m_LSL_Functions.llMakeFountain(); } - public void llMakeSmoke() { m_LSL_Functions.llMakeSmoke(); } - public void llMakeFire() { m_LSL_Functions.llMakeFire(); } - public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { m_LSL_Functions.llRezObject(inventory, pos, rot, param); } - public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { m_LSL_Functions.llLookAt(target, strength, damping); } - public void llStopLookAt() { m_LSL_Functions.llStopLookAt(); } - public void llSetTimerEvent(double sec) { m_LSL_Functions.llSetTimerEvent(sec); } - public void llSleep(double sec) { m_LSL_Functions.llSleep(sec); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public double llGetMass() { return m_LSL_Functions.llGetMass(); } - public void llCollisionFilter(string name, string id, int accept) { m_LSL_Functions.llCollisionFilter(name, id, accept); } - public void llTakeControls(int controls, int accept, int pass_on) { m_LSL_Functions.llTakeControls(controls, accept, pass_on); } - public void llReleaseControls() { m_LSL_Functions.llReleaseControls(); } - public void llAttachToAvatar(int attachment) { m_LSL_Functions.llAttachToAvatar(attachment); } - public void llDetachFromAvatar() { m_LSL_Functions.llDetachFromAvatar(); } - public void llTakeCamera() { m_LSL_Functions.llTakeCamera(); } - public void llReleaseCamera() { m_LSL_Functions.llReleaseCamera(); } - public string llGetOwner() { return m_LSL_Functions.llGetOwner(); } - public void llInstantMessage(string user, string message) { m_LSL_Functions.llInstantMessage(user, message); } - public void llEmail(string address, string subject, string message) { m_LSL_Functions.llEmail(address, subject, message); } - public void llGetNextEmail(string address, string subject) { m_LSL_Functions.llGetNextEmail(address, subject); } - public string llGetKey() { return m_LSL_Functions.llGetKey(); } - public void llSetBuoyancy(double buoyancy) { m_LSL_Functions.llSetBuoyancy(buoyancy); } - public void llSetHoverHeight(double height, int water, double tau) { m_LSL_Functions.llSetHoverHeight(height, water, tau); } - public void llStopHover() { m_LSL_Functions.llStopHover(); } - public void llMinEventDelay(double delay) { m_LSL_Functions.llMinEventDelay(delay); } - public void llSoundPreload() { m_LSL_Functions.llSoundPreload(); } - public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) { m_LSL_Functions.llRotLookAt(target, strength, damping); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public int llStringLength(string str) { return m_LSL_Functions.llStringLength(str); } - public void llStartAnimation(string anim) { m_LSL_Functions.llStartAnimation(anim); } - public void llStopAnimation(string anim) { m_LSL_Functions.llStopAnimation(anim); } - public void llPointAt() { m_LSL_Functions.llPointAt(); } - public void llStopPointAt() { m_LSL_Functions.llStopPointAt(); } - public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) { m_LSL_Functions.llTargetOmega(axis, spinrate, gain); } - public int llGetStartParameter() { return m_LSL_Functions.llGetStartParameter(); } - public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) { m_LSL_Functions.llGodLikeRezObject(inventory, pos); } - public void llRequestPermissions(string agent, int perm) { m_LSL_Functions.llRequestPermissions(agent, perm); } - public string llGetPermissionsKey() { return m_LSL_Functions.llGetPermissionsKey(); } - public int llGetPermissions() { return m_LSL_Functions.llGetPermissions(); } - public int llGetLinkNumber() { return m_LSL_Functions.llGetLinkNumber(); } - public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) { m_LSL_Functions.llSetLinkColor(linknumber, color, face); } - public void llCreateLink(string target, int parent) { m_LSL_Functions.llCreateLink(target, parent); } - public void llBreakLink(int linknum) { m_LSL_Functions.llBreakLink(linknum); } - public void llBreakAllLinks() { m_LSL_Functions.llBreakAllLinks(); } - public string llGetLinkKey(int linknum) { return m_LSL_Functions.llGetLinkKey(linknum); } - public void llGetLinkName(int linknum) { m_LSL_Functions.llGetLinkName(linknum); } - public int llGetInventoryNumber(int type) { return m_LSL_Functions.llGetInventoryNumber(type); } - public string llGetInventoryName(int type, int number) { return m_LSL_Functions.llGetInventoryName(type, number); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llSetScriptState(string name, int run) { m_LSL_Functions.llSetScriptState(name, run); } - public double llGetEnergy() { return m_LSL_Functions.llGetEnergy(); } - public void llGiveInventory(string destination, string inventory) { m_LSL_Functions.llGiveInventory(destination, inventory); } - public void llRemoveInventory(string item) { m_LSL_Functions.llRemoveInventory(item); } - public void llSetText(string text, LSL_Types.Vector3 color, double alpha) { m_LSL_Functions.llSetText(text, color, alpha); } - public double llWater(LSL_Types.Vector3 offset) { return m_LSL_Functions.llWater(offset); } - public void llPassTouches(int pass) { m_LSL_Functions.llPassTouches(pass); } - public string llRequestAgentData(string id, int data) { return m_LSL_Functions.llRequestAgentData(id, data); } - public string llRequestInventoryData(string name) { return m_LSL_Functions.llRequestInventoryData(name); } - public void llSetDamage(double damage) { m_LSL_Functions.llSetDamage(damage); } - public void llTeleportAgentHome(string agent) { m_LSL_Functions.llTeleportAgentHome(agent); } - public void llModifyLand(int action, int brush) { m_LSL_Functions.llModifyLand(action, brush); } - public void llCollisionSound(string impact_sound, double impact_volume) { m_LSL_Functions.llCollisionSound(impact_sound, impact_volume); } - public void llCollisionSprite(string impact_sprite) { m_LSL_Functions.llCollisionSprite(impact_sprite); } - public string llGetAnimation(string id) { return m_LSL_Functions.llGetAnimation(id); } - public void llResetScript() { m_LSL_Functions.llResetScript(); } - public void llMessageLinked(int linknum, int num, string str, string id) { m_LSL_Functions.llMessageLinked(linknum, num, str, id); } - public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local); } - public void llPassCollisions(int pass) { m_LSL_Functions.llPassCollisions(pass); } - public string llGetScriptName() { return m_LSL_Functions.llGetScriptName(); } - public int llGetNumberOfSides() { return m_LSL_Functions.llGetNumberOfSides(); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { return m_LSL_Functions.llAxisAngle2Rot(axis, angle); } - public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) { return m_LSL_Functions.llRot2Axis(rot); } - public void llRot2Angle() { m_LSL_Functions.llRot2Angle(); } - public double llAcos(double val) { return m_LSL_Functions.llAcos(val); } - public double llAsin(double val) { return m_LSL_Functions.llAsin(val); } - public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) { return m_LSL_Functions.llAngleBetween(a, b); } - public string llGetInventoryKey(string name) { return m_LSL_Functions.llGetInventoryKey(name); } - public void llAllowInventoryDrop(int add) { m_LSL_Functions.llAllowInventoryDrop(add); } - public LSL_Types.Vector3 llGetSunDirection() { return m_LSL_Functions.llGetSunDirection(); } - public LSL_Types.Vector3 llGetTextureOffset(int face) { return m_LSL_Functions.llGetTextureOffset(face); } - public LSL_Types.Vector3 llGetTextureScale(int side) { return m_LSL_Functions.llGetTextureScale(side); } - public double llGetTextureRot(int side) { return m_LSL_Functions.llGetTextureRot(side); } - public int llSubStringIndex(string source, string pattern) { return m_LSL_Functions.llSubStringIndex(source, pattern); } - public string llGetOwnerKey(string id) { return m_LSL_Functions.llGetOwnerKey(id); } - public LSL_Types.Vector3 llGetCenterOfMass() { return m_LSL_Functions.llGetCenterOfMass(); } - public List llListSort(List src, int stride, int ascending) { return m_LSL_Functions.llListSort(src, stride, ascending); } - public int llGetListLength(List src) { return m_LSL_Functions.llGetListLength(src); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public int llList2Integer(List src, int index) { return m_LSL_Functions.llList2Integer(src, index); } - public double llList2double(List src, int index) { return m_LSL_Functions.llList2double(src, index); } - public string llList2String(List src, int index) { return m_LSL_Functions.llList2String(src, index); } - public string llList2Key(List src, int index) { return m_LSL_Functions.llList2Key(src, index); } - public LSL_Types.Vector3 llList2Vector(List src, int index) { return m_LSL_Functions.llList2Vector(src, index); } - public LSL_Types.Quaternion llList2Rot(List src, int index) { return m_LSL_Functions.llList2Rot(src, index); } - public List llList2List(List src, int start, int end) { return m_LSL_Functions.llList2List(src, start, end); } - public List llDeleteSubList(List src, int start, int end) { return m_LSL_Functions.llDeleteSubList(src, start, end); } - public int llGetListEntryType(List src, int index) { return m_LSL_Functions.llGetListEntryType(src, index); } - public string llList2CSV(List src) { return m_LSL_Functions.llList2CSV(src); } - public List llCSV2List(string src) { return m_LSL_Functions.llCSV2List(src); } - public List llListRandomize(List src, int stride) { return m_LSL_Functions.llListRandomize(src, stride); } - public List llList2ListStrided(List src, int start, int end, int stride) { return m_LSL_Functions.llList2ListStrided(src, start, end, stride); } - public LSL_Types.Vector3 llGetRegionCorner() { return m_LSL_Functions.llGetRegionCorner(); } - public List llListInsertList(List dest, List src, int start) { return m_LSL_Functions.llListInsertList(dest, src, start); } - public int llListFindList(List src, List test) { return m_LSL_Functions.llListFindList(src, test); } - public string llGetObjectName() { return m_LSL_Functions.llGetObjectName(); } - public void llSetObjectName(string name) { m_LSL_Functions.llSetObjectName(name); } - public string llGetDate() { return m_LSL_Functions.llGetDate(); } - public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) { return m_LSL_Functions.llEdgeOfWorld(pos, dir); } - public int llGetAgentInfo(string id) { return m_LSL_Functions.llGetAgentInfo(id); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llAdjustSoundVolume(double volume) { m_LSL_Functions.llAdjustSoundVolume(volume); } - public void llSetSoundQueueing(int queue) { m_LSL_Functions.llSetSoundQueueing(queue); } - public void llSetSoundRadius(double radius) { m_LSL_Functions.llSetSoundRadius(radius); } - public string llKey2Name(string id) { return m_LSL_Functions.llKey2Name(id); } - public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate); } - public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west) { m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west); } - public void llEjectFromLand(string pest) { m_LSL_Functions.llEjectFromLand(pest); } - public void llParseString2List() { m_LSL_Functions.llParseString2List(); } - public int llOverMyLand(string id) { return m_LSL_Functions.llOverMyLand(id); } - public string llGetLandOwnerAt(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetLandOwnerAt(pos); } - public string llGetNotecardLine(string name, int line) { return m_LSL_Functions.llGetNotecardLine(name, line); } - public LSL_Types.Vector3 llGetAgentSize(string id) { return m_LSL_Functions.llGetAgentSize(id); } - public int llSameGroup(string agent) { return m_LSL_Functions.llSameGroup(agent); } - public void llUnSit(string id) { m_LSL_Functions.llUnSit(id); } - public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGroundSlope(offset); } - public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGroundNormal(offset); } - public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGroundContour(offset); } - public int llGetAttached() { return m_LSL_Functions.llGetAttached(); } - public int llGetFreeMemory() { return m_LSL_Functions.llGetFreeMemory(); } - public string llGetRegionName() { return m_LSL_Functions.llGetRegionName(); } - public double llGetRegionTimeDilation() { return m_LSL_Functions.llGetRegionTimeDilation(); } - public double llGetRegionFPS() { return m_LSL_Functions.llGetRegionFPS(); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llParticleSystem(List rules) { m_LSL_Functions.llParticleSystem(rules); } - public void llGroundRepel(double height, int water, double tau) { m_LSL_Functions.llGroundRepel(height, water, tau); } - public void llGiveInventoryList() { m_LSL_Functions.llGiveInventoryList(); } - public void llSetVehicleType(int type) { m_LSL_Functions.llSetVehicleType(type); } - public void llSetVehicledoubleParam(int param, double value) { m_LSL_Functions.llSetVehicledoubleParam(param, value); } - public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) { m_LSL_Functions.llSetVehicleVectorParam(param, vec); } - public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) { m_LSL_Functions.llSetVehicleRotationParam(param, rot); } - public void llSetVehicleFlags(int flags) { m_LSL_Functions.llSetVehicleFlags(flags); } - public void llRemoveVehicleFlags(int flags) { m_LSL_Functions.llRemoveVehicleFlags(flags); } - public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) { m_LSL_Functions.llSitTarget(offset, rot); } - public string llAvatarOnSitTarget() { return m_LSL_Functions.llAvatarOnSitTarget(); } - public void llAddToLandPassList(string avatar, double hours) { m_LSL_Functions.llAddToLandPassList(avatar, hours); } - public void llSetTouchText(string text) { m_LSL_Functions.llSetTouchText(text); } - public void llSetSitText(string text) { m_LSL_Functions.llSetSitText(text); } - public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) { m_LSL_Functions.llSetCameraEyeOffset(offset); } - public void llSetCameraAtOffset(LSL_Types.Vector3 offset) { m_LSL_Functions.llSetCameraAtOffset(offset); } - public void llDumpList2String() { m_LSL_Functions.llDumpList2String(); } - public void llScriptDanger(LSL_Types.Vector3 pos) { m_LSL_Functions.llScriptDanger(pos); } - public void llDialog(string avatar, string message, List buttons, int chat_channel) { m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); } - public void llVolumeDetect(int detect) { m_LSL_Functions.llVolumeDetect(detect); } - public void llResetOtherScript(string name) { m_LSL_Functions.llResetOtherScript(name); } - public int llGetScriptState(string name) { return m_LSL_Functions.llGetScriptState(name); } - public void llRemoteLoadScript() { m_LSL_Functions.llRemoteLoadScript(); } - public void llSetRemoteScriptAccessPin(int pin) { m_LSL_Functions.llSetRemoteScriptAccessPin(pin); } - public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llOpenRemoteDataChannel() { m_LSL_Functions.llOpenRemoteDataChannel(); } - public string llSendRemoteData(string channel, string dest, int idata, string sdata) { return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); } - public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) { m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata); } - public void llCloseRemoteDataChannel(string channel) { m_LSL_Functions.llCloseRemoteDataChannel(channel); } - public string llMD5String(string src, int nonce) { return m_LSL_Functions.llMD5String(src, nonce); } - public void llSetPrimitiveParams(List rules) { m_LSL_Functions.llSetPrimitiveParams(rules); } - public string llStringToBase64(string str) { return m_LSL_Functions.llStringToBase64(str); } - public string llBase64ToString(string str) { return m_LSL_Functions.llBase64ToString(str); } - public void llXorBase64Strings() { m_LSL_Functions.llXorBase64Strings(); } - public void llRemoteDataSetRegion() { m_LSL_Functions.llRemoteDataSetRegion(); } - public double llLog10(double val) { return m_LSL_Functions.llLog10(val); } - public double llLog(double val) { return m_LSL_Functions.llLog(val); } - public List llGetAnimationList(string id) { return m_LSL_Functions.llGetAnimationList(id); } - public void llSetParcelMusicURL(string url) { m_LSL_Functions.llSetParcelMusicURL(url); } - public LSL_Types.Vector3 llGetRootPosition() { return m_LSL_Functions.llGetRootPosition(); } - public LSL_Types.Quaternion llGetRootRotation() { return m_LSL_Functions.llGetRootRotation(); } - public string llGetObjectDesc() { return m_LSL_Functions.llGetObjectDesc(); } - public void llSetObjectDesc(string desc) { m_LSL_Functions.llSetObjectDesc(desc); } - public string llGetCreator() { return m_LSL_Functions.llGetCreator(); } - public string llGetTimestamp() { return m_LSL_Functions.llGetTimestamp(); } - public void llSetLinkAlpha(int linknumber, double alpha, int face) { m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face); } - public int llGetNumberOfPrims() { return m_LSL_Functions.llGetNumberOfPrims(); } - public string llGetNumberOfNotecardLines(string name) { return m_LSL_Functions.llGetNumberOfNotecardLines(name); } - public List llGetBoundingBox(string obj) { return m_LSL_Functions.llGetBoundingBox(obj); } - public LSL_Types.Vector3 llGetGeometricCenter() { return m_LSL_Functions.llGetGeometricCenter(); } - public void llGetPrimitiveParams() { m_LSL_Functions.llGetPrimitiveParams(); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public string llIntegerToBase64(int number) { return m_LSL_Functions.llIntegerToBase64(number); } - public int llBase64ToInteger(string str) { return m_LSL_Functions.llBase64ToInteger(str); } - public double llGetGMTclock() { return m_LSL_Functions.llGetGMTclock(); } - public string llGetSimulatorHostname() { return m_LSL_Functions.llGetSimulatorHostname(); } - public void llSetLocalRot(LSL_Types.Quaternion rot) { m_LSL_Functions.llSetLocalRot(rot); } - public List llParseStringKeepNulls(string src, List seperators, List spacers) { return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers); } - public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param) { m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param); } - public int llGetObjectPermMask(int mask) { return m_LSL_Functions.llGetObjectPermMask(mask); } - public void llSetObjectPermMask(int mask, int value) { m_LSL_Functions.llSetObjectPermMask(mask, value); } - public void llGetInventoryPermMask(string item, int mask) { m_LSL_Functions.llGetInventoryPermMask(item, mask); } - public void llSetInventoryPermMask(string item, int mask, int value) { m_LSL_Functions.llSetInventoryPermMask(item, mask, value); } - public string llGetInventoryCreator(string item) { return m_LSL_Functions.llGetInventoryCreator(item); } - public void llOwnerSay(string msg) { m_LSL_Functions.llOwnerSay(msg); } - public void llRequestSimulatorData(string simulator, int data) { m_LSL_Functions.llRequestSimulatorData(simulator, data); } - public void llForceMouselook(int mouselook) { m_LSL_Functions.llForceMouselook(mouselook); } - public double llGetObjectMass(string id) { return m_LSL_Functions.llGetObjectMass(id); } - public void llListReplaceList() { m_LSL_Functions.llListReplaceList(); } - public void llLoadURL(string avatar_id, string message, string url) { m_LSL_Functions.llLoadURL(avatar_id, message, url); } - public void llParcelMediaCommandList(List commandList) { m_LSL_Functions.llParcelMediaCommandList(commandList); } - public void llParcelMediaQuery() { m_LSL_Functions.llParcelMediaQuery(); } - public int llModPow(int a, int b, int c) { return m_LSL_Functions.llModPow(a, b, c); } + public string llIntegerToBase64(int number) + { + return m_LSL_Functions.llIntegerToBase64(number); + } + + public int llBase64ToInteger(string str) + { + return m_LSL_Functions.llBase64ToInteger(str); + } + + public double llGetGMTclock() + { + return m_LSL_Functions.llGetGMTclock(); + } + + public string llGetSimulatorHostname() + { + return m_LSL_Functions.llGetSimulatorHostname(); + } + + public void llSetLocalRot(rotation rot) + { + m_LSL_Functions.llSetLocalRot(rot); + } + + public List llParseStringKeepNulls(string src, List seperators, List spacers) + { + return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers); + } + + public void llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, int param) + { + m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param); + } + + public int llGetObjectPermMask(int mask) + { + return m_LSL_Functions.llGetObjectPermMask(mask); + } + + public void llSetObjectPermMask(int mask, int value) + { + m_LSL_Functions.llSetObjectPermMask(mask, value); + } + + public void llGetInventoryPermMask(string item, int mask) + { + m_LSL_Functions.llGetInventoryPermMask(item, mask); + } + + public void llSetInventoryPermMask(string item, int mask, int value) + { + m_LSL_Functions.llSetInventoryPermMask(item, mask, value); + } + + public string llGetInventoryCreator(string item) + { + return m_LSL_Functions.llGetInventoryCreator(item); + } + + public void llOwnerSay(string msg) + { + m_LSL_Functions.llOwnerSay(msg); + } + + public void llRequestSimulatorData(string simulator, int data) + { + m_LSL_Functions.llRequestSimulatorData(simulator, data); + } + + public void llForceMouselook(int mouselook) + { + m_LSL_Functions.llForceMouselook(mouselook); + } + + public double llGetObjectMass(string id) + { + return m_LSL_Functions.llGetObjectMass(id); + } + + public void llListReplaceList() + { + m_LSL_Functions.llListReplaceList(); + } + + public void llLoadURL(string avatar_id, string message, string url) + { + m_LSL_Functions.llLoadURL(avatar_id, message, url); + } + + public void llParcelMediaCommandList(List commandList) + { + m_LSL_Functions.llParcelMediaCommandList(commandList); + } + + public void llParcelMediaQuery() + { + m_LSL_Functions.llParcelMediaQuery(); + } + + public int llModPow(int a, int b, int c) + { + return m_LSL_Functions.llModPow(a, b, c); + } + // // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs // - public int llGetInventoryType(string name) { return m_LSL_Functions.llGetInventoryType(name); } - public void llSetPayPrice(int price, List quick_pay_buttons) { m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons); } - public LSL_Types.Vector3 llGetCameraPos() { return m_LSL_Functions.llGetCameraPos(); } - public LSL_Types.Quaternion llGetCameraRot() { return m_LSL_Functions.llGetCameraRot(); } - public void llSetPrimURL() { m_LSL_Functions.llSetPrimURL(); } - public void llRefreshPrimURL() { m_LSL_Functions.llRefreshPrimURL(); } - public string llEscapeURL(string url) { return m_LSL_Functions.llEscapeURL(url); } - public string llUnescapeURL(string url) { return m_LSL_Functions.llUnescapeURL(url); } - public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) { m_LSL_Functions.llMapDestination(simname, pos, look_at); } - public void llAddToLandBanList(string avatar, double hours) { m_LSL_Functions.llAddToLandBanList(avatar, hours); } - public void llRemoveFromLandPassList(string avatar) { m_LSL_Functions.llRemoveFromLandPassList(avatar); } - public void llRemoveFromLandBanList(string avatar) { m_LSL_Functions.llRemoveFromLandBanList(avatar); } - public void llSetCameraParams(List rules) { m_LSL_Functions.llSetCameraParams(rules); } - public void llClearCameraParams() { m_LSL_Functions.llClearCameraParams(); } - public double llListStatistics(int operation, List src) { return m_LSL_Functions.llListStatistics(operation, src); } - public int llGetUnixTime() { return m_LSL_Functions.llGetUnixTime(); } - public int llGetParcelFlags(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelFlags(pos); } - public int llGetRegionFlags() { return m_LSL_Functions.llGetRegionFlags(); } - public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } - public void llHTTPRequest(string url, List parameters, string body) { m_LSL_Functions.llHTTPRequest(url, parameters, body); } - public void llResetLandBanList() { m_LSL_Functions.llResetLandBanList(); } - public void llResetLandPassList() { m_LSL_Functions.llResetLandPassList(); } - public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); } - public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelPrimOwners(pos); } - public int llGetObjectPrimCount(string object_id) { return m_LSL_Functions.llGetObjectPrimCount(object_id); } + public int llGetInventoryType(string name) + { + return m_LSL_Functions.llGetInventoryType(name); + } + + public void llSetPayPrice(int price, List quick_pay_buttons) + { + m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons); + } + + public vector llGetCameraPos() + { + return m_LSL_Functions.llGetCameraPos(); + } + + public rotation llGetCameraRot() + { + return m_LSL_Functions.llGetCameraRot(); + } + + public void llSetPrimURL() + { + m_LSL_Functions.llSetPrimURL(); + } + + public void llRefreshPrimURL() + { + m_LSL_Functions.llRefreshPrimURL(); + } + + public string llEscapeURL(string url) + { + return m_LSL_Functions.llEscapeURL(url); + } + + public string llUnescapeURL(string url) + { + return m_LSL_Functions.llUnescapeURL(url); + } + + public void llMapDestination(string simname, vector pos, vector look_at) + { + m_LSL_Functions.llMapDestination(simname, pos, look_at); + } + + public void llAddToLandBanList(string avatar, double hours) + { + m_LSL_Functions.llAddToLandBanList(avatar, hours); + } + + public void llRemoveFromLandPassList(string avatar) + { + m_LSL_Functions.llRemoveFromLandPassList(avatar); + } + + public void llRemoveFromLandBanList(string avatar) + { + m_LSL_Functions.llRemoveFromLandBanList(avatar); + } + + public void llSetCameraParams(List rules) + { + m_LSL_Functions.llSetCameraParams(rules); + } + + public void llClearCameraParams() + { + m_LSL_Functions.llClearCameraParams(); + } + + public double llListStatistics(int operation, List src) + { + return m_LSL_Functions.llListStatistics(operation, src); + } + + public int llGetUnixTime() + { + return m_LSL_Functions.llGetUnixTime(); + } + + public int llGetParcelFlags(vector pos) + { + return m_LSL_Functions.llGetParcelFlags(pos); + } + + public int llGetRegionFlags() + { + return m_LSL_Functions.llGetRegionFlags(); + } + + public string llXorBase64StringsCorrect(string str1, string str2) + { + return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); + } + + public void llHTTPRequest(string url, List parameters, string body) + { + m_LSL_Functions.llHTTPRequest(url, parameters, body); + } + + public void llResetLandBanList() + { + m_LSL_Functions.llResetLandBanList(); + } + + public void llResetLandPassList() + { + m_LSL_Functions.llResetLandPassList(); + } + + public int llGetParcelPrimCount(vector pos, int category, int sim_wide) + { + return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); + } + + public List llGetParcelPrimOwners(vector pos) + { + return m_LSL_Functions.llGetParcelPrimOwners(pos); + } + + public int llGetObjectPrimCount(string object_id) + { + return m_LSL_Functions.llGetObjectPrimCount(object_id); + } + // // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs // - public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) { return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); } - public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) { return m_LSL_Functions.llGetParcelDetails(pos, param); } + public int llGetParcelMaxPrims(vector pos, int sim_wide) + { + return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); + } + + public List llGetParcelDetails(vector pos, List param) + { + return m_LSL_Functions.llGetParcelDetails(pos, param); + } // // OpenSim Functions // - public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) { return m_LSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer); } + public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, + int timer) + { + return m_LSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer); + } // LSL CONSTANTS public const int TRUE = 1; @@ -803,10 +2115,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL public const double SQRT2 = 1.414213538f; // Can not be public const? - public LSL_Types.Vector3 ZERO_VECTOR = new LSL_Types.Vector3(0, 0, 0); - public LSL_Types.Quaternion ZERO_ROTATION = new LSL_Types.Quaternion(0, 0, 0, 0); - - - + 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/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs index e1ea916..25c3346 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs @@ -27,31 +27,32 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { public static class Common { - static public bool Debug = true; - static public bool IL_UseTryCatch = true; - static public bool IL_CreateConstructor = true; - static public bool IL_CreateFunctionList = true; - static public bool IL_ProcessCodeChunks = true; + public static bool Debug = true; + public static bool IL_UseTryCatch = true; + public static bool IL_CreateConstructor = true; + public static bool IL_CreateFunctionList = true; + public static bool IL_ProcessCodeChunks = true; public delegate void SendToDebugEventDelegate(string Message); + public delegate void SendToLogEventDelegate(string Message); - static public event SendToDebugEventDelegate SendToDebugEvent; - static public event SendToLogEventDelegate SendToLogEvent; - static public void SendToDebug(string Message) + public static event SendToDebugEventDelegate SendToDebugEvent; + public static event SendToLogEventDelegate SendToLogEvent; + + public static void SendToDebug(string Message) { //if (Debug == true) Console.WriteLine("COMPILER:Debug: " + Message); SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } - static public void SendToLog(string Message) + + public static void SendToLog(string Message) { //if (Debug == true) Console.WriteLine("COMPILER:LOG: " + Message); @@ -68,6 +69,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("ReverseFormatString format: " + format); return string.Format(format, text1); } + public static string ReverseFormatString(string text1, UInt32 text2, string format) { Common.SendToDebug("ReverseFormatString text1: " + text1); @@ -75,10 +77,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("ReverseFormatString format: " + format); return string.Format(format, text1, text2.ToString()); } + public static string Cast_ToString(object obj) { Common.SendToDebug("OBJECT TO BE CASTED: " + obj.GetType().ToString()); return "ABCDEFGIHJKLMNOPQ123"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs index cfae2c5..f3f4bea 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs @@ -27,20 +27,19 @@ */ /* Original code: Tedd Hansen */ using System; +using System.IO; using System.Reflection; using System.Reflection.Emit; +using System.Text; using System.Threading; - namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { - - public class Engine { //private string LSO_FileName = @"LSO\AdditionTest.lso"; - private string LSO_FileName;// = @"LSO\CloseToDefault.lso"; - AppDomain appDomain; + private string LSO_FileName; // = @"LSO\CloseToDefault.lso"; + private AppDomain appDomain; public string Compile(string LSOFileName) { @@ -52,20 +51,19 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // Create Assembly Name AssemblyName asmName = new AssemblyName(); - asmName.Name = System.IO.Path.GetFileNameWithoutExtension(LSO_FileName); + asmName.Name = Path.GetFileNameWithoutExtension(LSO_FileName); //asmName.Name = "TestAssembly"; string DLL_FileName = asmName.Name + ".dll"; - string DLL_FileName_WithPath = System.IO.Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; + string DLL_FileName_WithPath = Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; - Common.SendToLog("LSO File Name: " + System.IO.Path.GetFileName(LSO_FileName)); + Common.SendToLog("LSO File Name: " + Path.GetFileName(LSO_FileName)); Common.SendToLog("Assembly name: " + asmName.Name); Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll"); Common.SendToLog("Starting processing of LSL ByteCode..."); Common.SendToLog(""); - // Create Assembly AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly( asmName, @@ -78,15 +76,15 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // Create a module (and save to disk) ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule - (asmName.Name, - DLL_FileName); + (asmName.Name, + DLL_FileName); //Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\""); // Create a Class (/Type) TypeBuilder typeBuilder = modBuilder.DefineType( - "LSL_ScriptObject", - TypeAttributes.Public | TypeAttributes.BeforeFieldInit, - typeof(OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass)); + "LSL_ScriptObject", + TypeAttributes.Public | TypeAttributes.BeforeFieldInit, + typeof (LSL_BaseClass)); //, // typeof()); //, typeof(LSL_BuiltIn_Commands_Interface)); @@ -95,7 +93,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // new Type[] { typeof(LSL_CLRInterface.LSLScript) }); - /* * Generate the IL itself */ @@ -123,7 +120,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO asmBuilder.Save(DLL_FileName); Common.SendToLog("Returning assembly filename: " + DLL_FileName); - + return DLL_FileName; @@ -135,9 +132,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //object MyScript = (object)Activator.CreateInstance(type); - - - //System.Reflection.MemberInfo[] Members = type.GetMembers(); //Common.SendToLog("Members of assembly " + type.ToString() + ":"); @@ -165,29 +159,25 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" }); //} - - } private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP) { - - Common.SendToDebug("IL_CREATE_CONSTRUCTOR()"); //ConstructorBuilder constructor = typeBuilder.DefineConstructor( // MethodAttributes.Public, // CallingConventions.Standard, // new Type[0]); ConstructorBuilder constructor = typeBuilder.DefineConstructor( - MethodAttributes.Public | - MethodAttributes.SpecialName | - MethodAttributes.RTSpecialName, - CallingConventions.Standard, - new Type[0]); + MethodAttributes.Public | + MethodAttributes.SpecialName | + MethodAttributes.RTSpecialName, + CallingConventions.Standard, + new Type[0]); //Define the reflection ConstructorInfor for System.Object - ConstructorInfo conObj = typeof(LSL_BaseClass).GetConstructor(new Type[0]); + ConstructorInfo conObj = typeof (LSL_BaseClass).GetConstructor(new Type[0]); //call constructor of base object ILGenerator il = constructor.GetILGenerator(); @@ -230,58 +220,61 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO LSO_Struct.StaticBlock sb; LSOP.StaticBlocks.TryGetValue(pos, out sb); - if (sb.ObjectType > 0 && sb.ObjectType < 8) { // We don't want void or null's - - il.Emit(OpCodes.Ldarg_0); - // Push position to stack - il.Emit(OpCodes.Ldc_I4, pos); - //il.Emit(OpCodes.Box, typeof(UInt32)); - - - Type datatype = null; - - // Push data to stack - Common.SendToDebug("Adding to static (" + pos + ") type: " + ((LSO_Enums.Variable_Type_Codes)sb.ObjectType).ToString() + " (" + sb.ObjectType + ")"); - switch ((LSO_Enums.Variable_Type_Codes)sb.ObjectType) + if (sb.ObjectType > 0 && sb.ObjectType < 8) { - case LSO_Enums.Variable_Type_Codes.Float: - case LSO_Enums.Variable_Type_Codes.Integer: - //UInt32 - il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); - datatype = typeof(UInt32); - il.Emit(OpCodes.Box, datatype); - break; - case LSO_Enums.Variable_Type_Codes.String: - case LSO_Enums.Variable_Type_Codes.Key: - //String - LSO_Struct.HeapBlock hb = LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); - il.Emit(OpCodes.Ldstr, System.Text.Encoding.UTF8.GetString(hb.Data)); - datatype = typeof(string); - break; - case LSO_Enums.Variable_Type_Codes.Vector: - datatype = typeof(LSO_Enums.Vector); - //TODO: Not implemented - break; - case LSO_Enums.Variable_Type_Codes.Rotation: - //Object - //TODO: Not implemented - datatype = typeof(LSO_Enums.Rotation); - break; - default: - datatype = typeof(object); - break; - } - - - // Make call - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddToStatic", new Type[] { typeof(UInt32), datatype })); + // We don't want void or null's + + il.Emit(OpCodes.Ldarg_0); + // Push position to stack + il.Emit(OpCodes.Ldc_I4, pos); + //il.Emit(OpCodes.Box, typeof(UInt32)); + + + Type datatype = null; + + // Push data to stack + Common.SendToDebug("Adding to static (" + pos + ") type: " + + ((LSO_Enums.Variable_Type_Codes) sb.ObjectType).ToString() + " (" + sb.ObjectType + + ")"); + switch ((LSO_Enums.Variable_Type_Codes) sb.ObjectType) + { + case LSO_Enums.Variable_Type_Codes.Float: + case LSO_Enums.Variable_Type_Codes.Integer: + //UInt32 + il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); + datatype = typeof (UInt32); + il.Emit(OpCodes.Box, datatype); + break; + case LSO_Enums.Variable_Type_Codes.String: + case LSO_Enums.Variable_Type_Codes.Key: + //String + LSO_Struct.HeapBlock hb = + LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); + il.Emit(OpCodes.Ldstr, Encoding.UTF8.GetString(hb.Data)); + datatype = typeof (string); + break; + case LSO_Enums.Variable_Type_Codes.Vector: + datatype = typeof (LSO_Enums.Vector); + //TODO: Not implemented + break; + case LSO_Enums.Variable_Type_Codes.Rotation: + //Object + //TODO: Not implemented + datatype = typeof (LSO_Enums.Rotation); + break; + default: + datatype = typeof (object); + break; + } + + + // Make call + il.Emit(OpCodes.Call, + typeof (LSL_BaseClass).GetMethod("AddToStatic", new Type[] {typeof (UInt32), datatype})); } - } - - ////il.Emit(OpCodes.Newobj, typeof(UInt32)); //il.Emit(OpCodes.Starg_0); //// Create LSL function library @@ -293,8 +286,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO } - - // End of class } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs index eef9d20..064166b 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs @@ -27,30 +27,25 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; using System.Reflection; using System.Reflection.Emit; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { - partial class LSO_Parser + internal partial class LSO_Parser { private static TypeBuilder CreateType(ModuleBuilder modBuilder, string typeName) { TypeBuilder typeBuilder = modBuilder.DefineType(typeName, - TypeAttributes.Public | - TypeAttributes.Class | - TypeAttributes.AutoClass | - TypeAttributes.AnsiClass | - TypeAttributes.BeforeFieldInit | - TypeAttributes.AutoLayout, - typeof(object), - new Type[] { typeof(object) }); + TypeAttributes.Public | + TypeAttributes.Class | + TypeAttributes.AutoClass | + TypeAttributes.AnsiClass | + TypeAttributes.BeforeFieldInit | + TypeAttributes.AutoLayout, + typeof (object), + new Type[] {typeof (object)}); return typeBuilder; - } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs index ac3bc11..46da5f8 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs @@ -28,9 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; -using System.IO; -using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler; using OpenSim.Region.ScriptEngine.Common; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO @@ -39,9 +36,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { //public MemoryStream LSLStack = new MemoryStream(); public Stack LSLStack = new Stack(); - public Dictionary StaticVariables = new Dictionary(); - public Dictionary GlobalVariables = new Dictionary(); - public Dictionary LocalVariables = new Dictionary(); + public Dictionary StaticVariables = new Dictionary(); + public Dictionary GlobalVariables = new Dictionary(); + public Dictionary LocalVariables = new Dictionary(); //public System.Collections.Generic.List FunctionList = new System.Collections.Generic.List(); //public void AddFunction(String x) { // FunctionList.Add(x); @@ -54,19 +51,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //} public UInt32 State = 0; public LSL_BuiltIn_Commands_Interface LSL_Builtins; + public LSL_BuiltIn_Commands_Interface GetLSL_BuiltIn() { return LSL_Builtins; } - public LSL_BaseClass() { } + public LSL_BaseClass() + { + } public virtual int OverrideMe() { return 0; } + public void Start(LSL_BuiltIn_Commands_Interface LSLBuiltins) { LSL_Builtins = LSLBuiltins; @@ -81,8 +82,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("AddToStatic: " + index + " type: " + obj.GetType()); StaticVariables.Add(index, obj); } - - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs index 8a43cc1..0b6970a 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { @@ -53,6 +51,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO LocalVariables.Remove(index); LocalVariables.Add(index, LSLStack.Peek()); } + public void StoreToGlobal(UInt32 index) { Common.SendToDebug("::StoreToGlobal " + index); @@ -60,6 +59,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO GlobalVariables.Remove(index); GlobalVariables.Add(index, LSLStack.Peek()); } + public void StoreToStatic(UInt32 index) { Common.SendToDebug("::StoreToStatic " + index); @@ -67,6 +67,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // StaticVariables.Remove(index); StaticVariables.Add(index, LSLStack.Peek()); } + public void GetFromLocal(UInt32 index) { // TODO: How to determine local? @@ -76,6 +77,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO LSLStack.Push(ret); //return ret; } + public void GetFromGlobal(UInt32 index) { Common.SendToDebug("::GetFromGlobal " + index); @@ -84,6 +86,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO LSLStack.Push(ret); //return ret; } + public void GetFromStatic(UInt32 index) { Common.SendToDebug("::GetFromStatic " + index); @@ -99,22 +102,22 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("::POPToStack"); //return LSLStack.Pop(); object p = LSLStack.Pop(); - if (p.GetType() == typeof(UInt32)) - return (UInt32)p; - if (p.GetType() == typeof(string)) - return (string)p; - if (p.GetType() == typeof(Int32)) - return (Int32)p; - if (p.GetType() == typeof(UInt16)) - return (UInt16)p; - if (p.GetType() == typeof(float)) - return (float)p; - if (p.GetType() == typeof(LSO_Enums.Vector)) - return (LSO_Enums.Vector)p; - if (p.GetType() == typeof(LSO_Enums.Rotation)) - return (LSO_Enums.Rotation)p; - if (p.GetType() == typeof(LSO_Enums.Key)) - return (LSO_Enums.Key)p; + if (p.GetType() == typeof (UInt32)) + return (UInt32) p; + if (p.GetType() == typeof (string)) + return (string) p; + if (p.GetType() == typeof (Int32)) + return (Int32) p; + if (p.GetType() == typeof (UInt16)) + return (UInt16) p; + if (p.GetType() == typeof (float)) + return (float) p; + if (p.GetType() == typeof (LSO_Enums.Vector)) + return (LSO_Enums.Vector) p; + if (p.GetType() == typeof (LSO_Enums.Rotation)) + return (LSO_Enums.Rotation) p; + if (p.GetType() == typeof (LSO_Enums.Key)) + return (LSO_Enums.Key) p; return p; } @@ -151,6 +154,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO LSLStack.Pop(); } } + public void PUSH(object Param) { if (Param == null) @@ -159,205 +163,218 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO } else { - //Common.SendToDebug("::PUSH: " + Param.GetType()); } LSLStack.Push(Param); } + public void ADD(UInt32 Param) { Common.SendToDebug("::ADD: " + Param); object o2 = LSLStack.Pop(); object o1 = LSLStack.Pop(); - Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + " (" + o2.ToString() + ")"); - if (o2.GetType() == typeof(string)) + Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + + " (" + o2.ToString() + ")"); + if (o2.GetType() == typeof (string)) { - LSLStack.Push((string)o1 + (string)o2); + LSLStack.Push((string) o1 + (string) o2); return; } - if (o2.GetType() == typeof(UInt32)) + if (o2.GetType() == typeof (UInt32)) { - LSLStack.Push((UInt32)o1 + (UInt32)o2); + LSLStack.Push((UInt32) o1 + (UInt32) o2); return; } - } + public void SUB(UInt32 Param) { Common.SendToDebug("::SUB: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 - i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 - i2)); } + public void MUL(UInt32 Param) { Common.SendToDebug("::SUB: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 * i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1*i2)); } + public void DIV(UInt32 Param) { Common.SendToDebug("::DIV: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 / i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1/i2)); } public void MOD(UInt32 Param) { Common.SendToDebug("::MOD: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 % i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1%i2)); } + public void EQ(UInt32 Param) { Common.SendToDebug("::EQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 == i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void NEQ(UInt32 Param) { Common.SendToDebug("::NEQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 != i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void LEQ(UInt32 Param) { Common.SendToDebug("::LEQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 <= i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void GEQ(UInt32 Param) { Common.SendToDebug("::GEQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 >= i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void LESS(UInt32 Param) { Common.SendToDebug("::LESS: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 < i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void GREATER(UInt32 Param) { Common.SendToDebug("::GREATER: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 > i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } - public void BITAND() { Common.SendToDebug("::BITAND"); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 & i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 & i2)); } + public void BITOR() { Common.SendToDebug("::BITOR"); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 | i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 | i2)); } + public void BITXOR() { Common.SendToDebug("::BITXOR"); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 ^ i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 ^ i2)); } + public void BOOLAND() { Common.SendToDebug("::BOOLAND"); - bool b2 = bool.Parse((string)LSLStack.Pop()); - bool b1 = bool.Parse((string)LSLStack.Pop()); + bool b2 = bool.Parse((string) LSLStack.Pop()); + bool b1 = bool.Parse((string) LSLStack.Pop()); if (b1 && b2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void BOOLOR() { Common.SendToDebug("::BOOLOR"); - bool b2 = bool.Parse((string)LSLStack.Pop()); - bool b1 = bool.Parse((string)LSLStack.Pop()); + bool b2 = bool.Parse((string) LSLStack.Pop()); + bool b1 = bool.Parse((string) LSLStack.Pop()); if (b1 || b2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } - } + public void NEG(UInt32 Param) { Common.SendToDebug("::NEG: " + Param); //UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 * -1)); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1*-1)); } + public void BITNOT() { //Common.SendToDebug("::BITNOT"); @@ -365,6 +382,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //UInt32 i1 = (UInt32)LSLStack.Pop(); //LSLStack.Push((UInt32)(i1 / i2)); } + public void BOOLNOT() { //Common.SendToDebug("::BOOLNOT"); @@ -372,7 +390,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //UInt32 i1 = (UInt32)LSLStack.Pop(); //LSLStack.Push((UInt32)(i1)); } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs index 5da1d71..ed07cfc 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs @@ -26,10 +26,6 @@ * */ /* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { public class LSL_CLRInterface @@ -76,4 +72,4 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //void event_http_response(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs index 45cca25..d25644c 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs @@ -27,32 +27,28 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; using System.Reflection; using System.Reflection.Emit; using OpenSim.Region.ScriptEngine.Common; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { - partial class LSO_Parser + internal partial class LSO_Parser { //internal Stack ILStack = new Stack(); //LSO_Enums MyLSO_Enums = new LSO_Enums(); internal bool LSL_PROCESS_OPCODE(ILGenerator il) { - byte bp1; UInt32 u32p1; float fp1; UInt16 opcode = br_read(1)[0]; - Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); - string idesc = ((LSO_Enums.Operation_Table)opcode).ToString(); - switch ((LSO_Enums.Operation_Table)opcode) + Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table) opcode).ToString()); + string idesc = ((LSO_Enums.Operation_Table) opcode).ToString(); + switch ((LSO_Enums.Operation_Table) opcode) { - - /*************** + /*************** * IMPLEMENTED * ***************/ case LSO_Enums.Operation_Table.NOOP: @@ -60,33 +56,34 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO case LSO_Enums.Operation_Table.PUSHSP: // Push Stack Top (Memory Address) to stack Common.SendToDebug("Instruction " + idesc); - Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack"); - IL_Push(il, (UInt32)myHeader.SP); + Common.SendToDebug("Instruction " + idesc + + ": Description: Pushing Stack Top (Memory Address from header) to stack"); + IL_Push(il, (UInt32) myHeader.SP); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.PUSHARGB: Common.SendToDebug("Param1: " + br_read(1)[0]); break; - // INTEGER + // INTEGER case LSO_Enums.Operation_Table.PUSHARGI: u32p1 = BitConverter.ToUInt32(br_read(4), 0); Common.SendToDebug("Instruction " + idesc + ", Param1: " + u32p1); IL_Push(il, u32p1); break; - // FLOAT + // FLOAT case LSO_Enums.Operation_Table.PUSHARGF: fp1 = BitConverter.ToUInt32(br_read(4), 0); Common.SendToDebug("Instruction " + idesc + ", Param1: " + fp1); IL_Push(il, fp1); break; - // STRING + // STRING case LSO_Enums.Operation_Table.PUSHARGS: string s = Read_String(); Common.SendToDebug("Instruction " + idesc + ", Param1: " + s); IL_Debug(il, "OPCODE: " + idesc + ":" + s); IL_Push(il, s); break; - // VECTOR z,y,x + // VECTOR z,y,x case LSO_Enums.Operation_Table.PUSHARGV: LSO_Enums.Vector v = new LSO_Enums.Vector(); v.Z = BitConverter.ToUInt32(br_read(4), 0); @@ -97,7 +94,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Param1 X: " + v.X); IL_Push(il, v); break; - // ROTATION s,z,y,x + // ROTATION s,z,y,x case LSO_Enums.Operation_Table.PUSHARGQ: LSO_Enums.Rotation r = new LSO_Enums.Rotation(); r.S = BitConverter.ToUInt32(br_read(4), 0); @@ -112,7 +109,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO break; case LSO_Enums.Operation_Table.PUSHE: - IL_Push(il, (UInt32)0); + IL_Push(il, (UInt32) 0); break; case LSO_Enums.Operation_Table.PUSHARGE: @@ -121,7 +118,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //IL_Push(il, new string(" ".ToCharArray()[0], Convert.ToInt32(u32p1))); IL_Push(il, u32p1); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.ADD: case LSO_Enums.Operation_Table.SUB: case LSO_Enums.Operation_Table.MUL: @@ -136,10 +133,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO case LSO_Enums.Operation_Table.MOD: bp1 = br_read(1)[0]; Common.SendToDebug("Param1: " + bp1); - IL_CallBaseFunction(il, idesc, (UInt32)bp1); + IL_CallBaseFunction(il, idesc, (UInt32) bp1); break; - // NO ARGUMENTS + // NO ARGUMENTS case LSO_Enums.Operation_Table.BITAND: case LSO_Enums.Operation_Table.BITOR: case LSO_Enums.Operation_Table.BITXOR: @@ -149,22 +146,23 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO case LSO_Enums.Operation_Table.BOOLNOT: IL_CallBaseFunction(il, idesc); break; - // SHORT + // SHORT case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: // TODO: What is size of short? UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); - Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()); + Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + + ((LSO_Enums.BuiltIn_Functions) U16p1).ToString()); //Common.SendToDebug("Param1: " + U16p1); - string fname = ((LSO_Enums.BuiltIn_Functions)U16p1).ToString(); + string fname = ((LSO_Enums.BuiltIn_Functions) U16p1).ToString(); bool cmdFound = false; - foreach (MethodInfo mi in typeof(LSL_BuiltIn_Commands_Interface).GetMethods()) + foreach (MethodInfo mi in typeof (LSL_BuiltIn_Commands_Interface).GetMethods()) { // Found command if (mi.Name == fname) { il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] { })); + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] {})); // Pop required number of items from my stack to .Net stack IL_PopToStack(il, mi.GetParameters().Length); il.Emit(OpCodes.Callvirt, mi); @@ -179,7 +177,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO break; - // RETURN + // RETURN case LSO_Enums.Operation_Table.RETURN: Common.SendToDebug("OPCODE: RETURN"); @@ -195,7 +193,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO IL_Pop(il); break; - // LONG + // LONG case LSO_Enums.Operation_Table.STORE: case LSO_Enums.Operation_Table.STORES: case LSO_Enums.Operation_Table.STOREL: @@ -238,7 +236,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO IL_Pop(il); break; - // PUSH FROM LOCAL FRAME + // PUSH FROM LOCAL FRAME case LSO_Enums.Operation_Table.PUSH: case LSO_Enums.Operation_Table.PUSHS: case LSO_Enums.Operation_Table.PUSHL: @@ -250,7 +248,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO break; - // PUSH FROM STATIC FRAME + // PUSH FROM STATIC FRAME case LSO_Enums.Operation_Table.PUSHG: case LSO_Enums.Operation_Table.PUSHGS: case LSO_Enums.Operation_Table.PUSHGL: @@ -262,26 +260,25 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO break; - /*********************** + /*********************** * NOT IMPLEMENTED YET * ***********************/ - case LSO_Enums.Operation_Table.POPIP: case LSO_Enums.Operation_Table.POPSP: case LSO_Enums.Operation_Table.POPSLR: case LSO_Enums.Operation_Table.POPARG: case LSO_Enums.Operation_Table.POPBP: //Common.SendToDebug("Instruction " + idesc + ": Ignored"); - Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); + Common.SendToDebug("Instruction " + idesc + + ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); //Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); IL_Pop(il); break; - - // None + // None case LSO_Enums.Operation_Table.PUSHIP: // PUSH INSTRUCTION POINTER break; @@ -293,17 +290,17 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO break; - // LONG + // LONG case LSO_Enums.Operation_Table.JUMP: Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); break; - // BYTE, LONG + // BYTE, LONG case LSO_Enums.Operation_Table.JUMPIF: case LSO_Enums.Operation_Table.JUMPNIF: Common.SendToDebug("Param1: " + br_read(1)[0]); Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); break; - // LONG + // LONG case LSO_Enums.Operation_Table.STATE: bp1 = br_read(1)[0]; //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack @@ -315,12 +312,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); Common.SendToDebug("ERROR: Function CALL not implemented yet."); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.CAST: bp1 = br_read(1)[0]; - Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)); + Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + + ((LSO_Enums.OpCode_Cast_TypeDefs) bp1)); Common.SendToDebug("Param1: " + bp1); - switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1) + switch ((LSO_Enums.OpCode_Cast_TypeDefs) bp1) { case LSO_Enums.OpCode_Cast_TypeDefs.String: Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Box, ILStack.Pop());"); @@ -330,12 +328,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO break; } break; - // LONG + // LONG case LSO_Enums.Operation_Table.STACKTOS: case LSO_Enums.Operation_Table.STACKTOL: Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.PRINT: case LSO_Enums.Operation_Table.CALLLIB: Common.SendToDebug("Param1: " + br_read(1)[0]); @@ -348,6 +346,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { IL_PopToStack(il, 1); } + private void IL_PopToStack(ILGenerator il, int count) { Common.SendToDebug("IL_PopToStack();"); @@ -360,31 +359,35 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // new Type[] { })); } } + private void IL_Pop(ILGenerator il) { Common.SendToDebug("IL_Pop();"); IL_CallBaseFunction(il, "POP"); } + private void IL_Debug(ILGenerator il, string text) { il.Emit(OpCodes.Ldstr, text); - il.Emit(OpCodes.Call, typeof(Common).GetMethod("SendToDebug", - new Type[] { typeof(string) } - )); + il.Emit(OpCodes.Call, typeof (Common).GetMethod("SendToDebug", + new Type[] {typeof (string)} + )); } + private void IL_CallBaseFunction(ILGenerator il, string methodname) { il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { })); + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {})); } + private void IL_CallBaseFunction(ILGenerator il, string methodname, object data) { il.Emit(OpCodes.Ldarg_0); - if (data.GetType() == typeof(string)) - il.Emit(OpCodes.Ldstr, (string)data); - if (data.GetType() == typeof(UInt32)) - il.Emit(OpCodes.Ldc_I4, (UInt32)data); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { data.GetType() })); + if (data.GetType() == typeof (string)) + il.Emit(OpCodes.Ldstr, (string) data); + if (data.GetType() == typeof (UInt32)) + il.Emit(OpCodes.Ldc_I4, (UInt32) data); + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {data.GetType()})); } private void IL_Push(ILGenerator il, object data) @@ -394,43 +397,39 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO IL_PushDataTypeToILStack(il, data); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("PUSH", new Type[] { data.GetType() })); - + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("PUSH", new Type[] {data.GetType()})); } private void IL_PushDataTypeToILStack(ILGenerator il, object data) { - if (data.GetType() == typeof(UInt16)) + if (data.GetType() == typeof (UInt16)) { - il.Emit(OpCodes.Ldc_I4, (UInt16)data); + il.Emit(OpCodes.Ldc_I4, (UInt16) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(UInt32)) + if (data.GetType() == typeof (UInt32)) { - il.Emit(OpCodes.Ldc_I4, (UInt32)data); + il.Emit(OpCodes.Ldc_I4, (UInt32) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(Int32)) + if (data.GetType() == typeof (Int32)) { - il.Emit(OpCodes.Ldc_I4, (Int32)data); + il.Emit(OpCodes.Ldc_I4, (Int32) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(float)) + if (data.GetType() == typeof (float)) { - il.Emit(OpCodes.Ldc_I4, (float)data); + il.Emit(OpCodes.Ldc_I4, (float) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(string)) - il.Emit(OpCodes.Ldstr, (string)data); + if (data.GetType() == typeof (string)) + il.Emit(OpCodes.Ldstr, (string) data); //if (data.GetType() == typeof(LSO_Enums.Rotation)) // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data); //if (data.GetType() == typeof(LSO_Enums.Vector)) // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data); //if (data.GetType() == typeof(LSO_Enums.Key)) // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data); - } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs index 3de2a36..fef9ad2 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs @@ -27,8 +27,6 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { @@ -47,6 +45,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO String = 51, UInt32 = 17 } + [Serializable] public enum OpCode_Cast_TypeDefs { @@ -66,6 +65,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO public UInt32 Y; public UInt32 X; } + [Serializable] public struct Rotation { @@ -74,6 +74,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO public UInt32 Y; public UInt32 X; } + [Serializable] public enum Variable_Type_Codes { @@ -87,6 +88,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO List = 7, Null = 8 } + [Serializable] public enum Event_Mask_Values { @@ -124,6 +126,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO remote_data = 31, http_response = 32 } + [Serializable] public enum Operation_Table { @@ -220,6 +223,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO SHL = 0xe0, SHR = 0xe1 } + [Serializable] public enum BuiltIn_Functions { @@ -552,6 +556,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO llGetParcelMaxPrims = 326, llGetParcelDetails = 327 } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs index 8b24e68..11c51c5 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs @@ -27,15 +27,16 @@ */ /* Original code: Tedd Hansen */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.IO; using System.Reflection; using System.Reflection.Emit; +using System.Text; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { - partial class LSO_Parser + internal partial class LSO_Parser { private string FileName; private FileStream fs; @@ -45,7 +46,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //private System.Collections.Hashtable StaticBlocks = new System.Collections.Hashtable(); private TypeBuilder typeBuilder; - private System.Collections.Generic.List EventList = new System.Collections.Generic.List(); + private List EventList = new List(); public LSO_Parser(string _FileName, TypeBuilder _typeBuilder) { @@ -59,11 +60,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Opening filename: " + FileName); fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); br = new BinaryReader(fs, Encoding.BigEndianUnicode); - } + internal void CloseFile() { - // Close br.Close(); fs.Close(); @@ -75,9 +75,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO /// public void Parse() { - - - // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. @@ -148,14 +145,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); myStaticBlock.ObjectType = br_read(1)[0]; - Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); + Common.SendToDebug("Static Block ObjectType: " + + ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); myStaticBlock.Unknown = br_read(1)[0]; // Size of datatype varies -- what about strings? if (myStaticBlock.ObjectType != 0) myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); - StaticBlocks.Add((UInt32)startReadPos, myStaticBlock); - + StaticBlocks.Add((UInt32) startReadPos, myStaticBlock); } Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount); @@ -183,7 +180,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // TODO: ADD TO FUNCTION LIST (How do we identify it later?) // Note! Absolute position myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; - Common.SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); + Common.SendToDebug("Fuction " + i + " code chunk position: " + + myFunctionBlock.CodeChunkPointer[i]); } } } @@ -204,14 +202,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Reading STATE POINTER BLOCK " + (i + 1) + " at: " + fs.Position); // Position is relative to state frame myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); - myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); + myStateFrameBlock.StatePointer[i].EventMask = new BitArray(br_read(8)); Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); - Common.SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); + Common.SendToDebug("Total potential EventMask bits: " + + myStateFrameBlock.StatePointer[i].EventMask.Count); //// Read STATE BLOCK //long CurPos = fs.Position; //fs.Seek(CurPos, SeekOrigin.Begin); - } } @@ -224,19 +222,20 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // Go through all State Frame Pointers found for (int i = 0; i < myStateFrameBlock.StateCount; i++) { - fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); // READ: STATE BLOCK HEADER myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); - myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note + myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32) fs.Position; // Note myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; - myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note + myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32) fs.Position; // Note Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); - Common.SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); - Common.SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); + Common.SendToDebug("State block Header Size: " + + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); + Common.SendToDebug("State block Header End Pos: " + + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); // We need to count number of bits flagged in EventMask? @@ -245,27 +244,36 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE //TODO: Create event hooks - myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = + new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) { - if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) { // We got an event // READ: STATE BLOCK HANDLER - Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); - myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); - myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); - Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); - Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize); + Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + + " (" + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") at: " + + fs.Position); + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = + myStateFrameBlock.StatePointer[i].StateBlock.EndPos + + BitConverter.ToUInt32(br_read(4), 0); + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = + BitConverter.ToUInt32(br_read(4), 0); + Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Code Chunk Pointer: " + + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. + CodeChunkPointer); + Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Call Frame Size: " + + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. + CallFrameSize); } } } } - - //// READ FUNCTION CODE CHUNKS //// Functions + Function start pos (GFR) //// TODO: Somehow be able to identify and reference this @@ -291,37 +299,32 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // two level search ain't no good for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) { - - if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) { - Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); + Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + + (LSO_Enums.Event_Mask_Values) ii); // Override a Method / Function - string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values)ii; + string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values) ii; Common.SendToDebug("Event Name: " + eventname); if (Common.IL_ProcessCodeChunks) { EventList.Add(eventname); // JUMP TO CODE PROCESSOR - ProcessCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, typeBuilder, eventname); + ProcessCodeChunk( + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, + typeBuilder, eventname); } } - } - } - } - - if (Common.IL_CreateFunctionList) IL_INSERT_FUNCTIONLIST(); - } internal LSO_Struct.HeapBlock GetHeap(UInt32 pos) @@ -342,11 +345,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); - Common.SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); + Common.SendToDebug("Heap Block ObjectType: " + + ((LSO_Enums.Variable_Type_Codes) myHeapBlock.ObjectType).ToString()); Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); return myHeapBlock; } + private byte[] br_read(int len) { if (len <= 0) @@ -365,6 +370,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO throw (e); } } + //private byte[] br_read_smallendian(int len) //{ // byte[] bytes = new byte[len]; @@ -373,29 +379,38 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //} private Type getLLObjectType(byte objectCode) { - switch ((LSO_Enums.Variable_Type_Codes)objectCode) + switch ((LSO_Enums.Variable_Type_Codes) objectCode) { - case LSO_Enums.Variable_Type_Codes.Void: return typeof(void); - case LSO_Enums.Variable_Type_Codes.Integer: return typeof(UInt32); - case LSO_Enums.Variable_Type_Codes.Float: return typeof(float); - case LSO_Enums.Variable_Type_Codes.String: return typeof(string); - case LSO_Enums.Variable_Type_Codes.Key: return typeof(string); - case LSO_Enums.Variable_Type_Codes.Vector: return typeof(LSO_Enums.Vector); - case LSO_Enums.Variable_Type_Codes.Rotation: return typeof(LSO_Enums.Rotation); + case LSO_Enums.Variable_Type_Codes.Void: + return typeof (void); + case LSO_Enums.Variable_Type_Codes.Integer: + return typeof (UInt32); + case LSO_Enums.Variable_Type_Codes.Float: + return typeof (float); + case LSO_Enums.Variable_Type_Codes.String: + return typeof (string); + case LSO_Enums.Variable_Type_Codes.Key: + return typeof (string); + case LSO_Enums.Variable_Type_Codes.Vector: + return typeof (LSO_Enums.Vector); + case LSO_Enums.Variable_Type_Codes.Rotation: + return typeof (LSO_Enums.Rotation); case LSO_Enums.Variable_Type_Codes.List: Common.SendToDebug("TODO: List datatype not implemented yet!"); - return typeof(System.Collections.ArrayList); + return typeof (ArrayList); case LSO_Enums.Variable_Type_Codes.Null: Common.SendToDebug("TODO: Datatype null is not implemented, using string instead.!"); - return typeof(string); + return typeof (string); default: - Common.SendToDebug("Lookup of LSL datatype " + objectCode + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); - return typeof(object); + Common.SendToDebug("Lookup of LSL datatype " + objectCode + + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); + return typeof (object); } } + private int getObjectSize(byte ObjectType) { - switch ((LSO_Enums.Variable_Type_Codes)ObjectType) + switch ((LSO_Enums.Variable_Type_Codes) ObjectType) { case LSO_Enums.Variable_Type_Codes.Integer: case LSO_Enums.Variable_Type_Codes.Float: @@ -411,13 +426,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO return 0; } } + private string Read_String() { string ret = ""; byte reader = br_read(1)[0]; while (reader != 0x000) { - ret += (char)reader; + ret += (char) reader; reader = br_read(1)[0]; } return ret; @@ -431,7 +447,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO /// Name of event (function) to generate private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname) { - LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); Common.SendToDebug("Reading Function Code Chunk at: " + pos); @@ -442,12 +457,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO myCodeChunk.Comment = Read_String(); Common.SendToDebug("Function comment: " + myCodeChunk.Comment); myCodeChunk.ReturnTypePos = br_read(1)[0]; - myCodeChunk.ReturnType = GetStaticBlock((long)myCodeChunk.ReturnTypePos + (long)myHeader.GVR); - Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " + ((LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType.ObjectType).ToString()); + myCodeChunk.ReturnType = GetStaticBlock((long) myCodeChunk.ReturnTypePos + (long) myHeader.GVR); + Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " + + ((LSO_Enums.Variable_Type_Codes) myCodeChunk.ReturnType.ObjectType).ToString()); // TODO: How to determine number of codechunks -- does this method work? - myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List(); + myCodeChunk.CodeChunkArguments = new List(); byte reader = br_read(1)[0]; reader = br_read(1)[0]; @@ -464,14 +480,17 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO CCA.NullString = reader; CCA.FunctionReturnType = GetStaticBlock(CCA.FunctionReturnTypePos + myHeader.GVR); myCodeChunk.CodeChunkArguments.Add(CCA); - Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType + ": " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType.ObjectType); + Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType + + ": " + (LSO_Enums.Variable_Type_Codes) CCA.FunctionReturnType.ObjectType); } // Create string array Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count]; for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) { MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType); - Common.SendToDebug("Method argument " + _ic + ": " + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType).ToString()); + Common.SendToDebug("Method argument " + _ic + ": " + + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType). + ToString()); } // End marker is 0x000 myCodeChunk.EndMarker = reader; @@ -483,9 +502,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, - MethodAttributes.Public, - typeof(void), - new Type[] { typeof(object) }); + MethodAttributes.Public, + typeof (void), + new Type[] {typeof (object)}); //MethodArgs); //typeof(void), //getLLObjectType(myCodeChunk.ReturnType), // new Type[] { typeof(object) }, //); @@ -504,7 +523,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO IL_INSERT_TRY(il, eventname); - // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); //il.Emit(OpCodes.Call, typeof(Console).GetMethod @@ -520,7 +538,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO } - // // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL // @@ -538,12 +555,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO il.Emit(OpCodes.Ret); return; - } private void IL_INSERT_FUNCTIONLIST() { - Common.SendToDebug("Creating function list"); @@ -557,11 +572,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private); - MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, - MethodAttributes.Public, - typeof(string[]), - null); + MethodAttributes.Public, + typeof (string[]), + null); //typeBuilder.DefineMethodOverride(methodBuilder, // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); @@ -569,8 +583,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO ILGenerator il = methodBuilder.GetILGenerator(); - - // IL_INSERT_TRY(il, eventname); // // Push string to stack @@ -586,37 +598,34 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO ////il.Emit(OpCodes.Ldarg_0); - il.DeclareLocal(typeof(string[])); + il.DeclareLocal(typeof (string[])); ////il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length - il.Emit(OpCodes.Newarr, typeof(String)); // create new string array - il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack + il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length + il.Emit(OpCodes.Newarr, typeof (String)); // create new string array + il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack ////SetFunctionList for (int lv = 0; lv < EventList.Count; lv++) { - il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack - il.Emit(OpCodes.Ldc_I4, lv); // Push index position - il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value - il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value + il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack + il.Emit(OpCodes.Ldc_I4, lv); // Push index position + il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value + il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value //il.Emit(OpCodes.Ldarg_0); //il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value //il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddFunction", new Type[] { typeof(string) })); - } - // IL_INSERT_END_TRY(il, eventname); - il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack + il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack // il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("SetFunctionList", new Type[] { typeof(Array) })); - il.Emit(OpCodes.Ret); // Return - + il.Emit(OpCodes.Ret); // Return } @@ -631,7 +640,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // Push "Hello World!" string to stack //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); //il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); - } private void IL_INSERT_END_TRY(ILGenerator il, string eventname) @@ -640,7 +648,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO * CATCH */ Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); - il.BeginCatchBlock(typeof(Exception)); + il.BeginCatchBlock(typeof (Exception)); // Push "Hello World!" string to stack Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); @@ -648,18 +656,18 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO //call void [mscorlib]System.Console::WriteLine(string) Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); - il.Emit(OpCodes.Call, typeof(Console).GetMethod - ("Write", new Type[] { typeof(string) })); + il.Emit(OpCodes.Call, typeof (Console).GetMethod + ("Write", new Type[] {typeof (string)})); //callvirt instance string [mscorlib]System.Exception::get_Message() Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); - il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod - ("get_Message")); + il.Emit(OpCodes.Callvirt, typeof (Exception).GetMethod + ("get_Message")); //call void [mscorlib]System.Console::WriteLine(string) Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); - il.Emit(OpCodes.Call, typeof(Console).GetMethod - ("WriteLine", new Type[] { typeof(string) })); + il.Emit(OpCodes.Call, typeof (Console).GetMethod + ("WriteLine", new Type[] {typeof (string)})); /* * CLR END TRY @@ -673,7 +681,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO long FirstPos = fs.Position; try { - UInt32 position = (UInt32)pos; + UInt32 position = (UInt32) pos; // STATIC BLOCK Common.SendToDebug("Reading STATIC BLOCK at: " + position); fs.Seek(position, SeekOrigin.Begin); @@ -683,7 +691,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Found cached STATIC BLOCK"); - return StaticBlocks[pos]; } @@ -699,7 +706,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); myStaticBlock.ObjectType = br_read(1)[0]; - Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); + Common.SendToDebug("Static Block ObjectType: " + + ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); myStaticBlock.Unknown = br_read(1)[0]; // Size of datatype varies if (myStaticBlock.ObjectType != 0) @@ -715,8 +723,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO // Go back to original read pos fs.Seek(FirstPos, SeekOrigin.Begin); } - } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs index f0203b3..2bb2c38 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs @@ -28,14 +28,13 @@ /* Original code: Tedd Hansen */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO { - static class LSO_Struct + internal static class LSO_Struct { - public struct Header { public UInt32 TM; @@ -69,6 +68,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO public byte Unknown; public byte[] BlockVariable; } + /* Not actually a structure public struct StaticBlockVariable { @@ -80,6 +80,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO public byte[] Rotation_16; public UInt32 Pointer_List_Structure; } */ + public struct HeapBlock { public Int32 DataBlockSize; @@ -87,17 +88,20 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO public UInt16 ReferenceCount; public byte[] Data; } + public struct StateFrameBlock { public UInt32 StateCount; public StatePointerBlock[] StatePointer; } + public struct StatePointerBlock { public UInt32 Location; - public System.Collections.BitArray EventMask; + public BitArray EventMask; public StateBlock StateBlock; } + public struct StateBlock { public UInt32 StartPos; @@ -106,25 +110,29 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO public byte Unknown; public StateBlockHandler[] StateBlockHandlers; } + public struct StateBlockHandler { public UInt32 CodeChunkPointer; public UInt32 CallFrameSize; } + public struct FunctionBlock { public UInt32 FunctionCount; public UInt32[] CodeChunkPointer; } + public struct CodeChunk { public UInt32 CodeChunkHeaderSize; public string Comment; - public System.Collections.Generic.List CodeChunkArguments; + public List CodeChunkArguments; public byte EndMarker; public byte ReturnTypePos; public StaticBlock ReturnType; } + public struct CodeChunkArgument { public byte FunctionReturnTypePos; @@ -132,4 +140,4 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO public StaticBlock FunctionReturnType; } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index 8e7b95e..7bc3ce4 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -26,19 +26,18 @@ * */ -using Axiom.Math; using System; using System.Collections.Generic; +using System.Runtime.Remoting.Lifetime; using System.Text; +using System.Threading; +using Axiom.Math; using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; +using OpenSim.Framework; +using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL; using OpenSim.Region.Environment.Interfaces; -using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler; +using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ScriptEngine.Common; -using OpenSim.Framework.Console; -using OpenSim.Framework; -using System.Runtime.Remoting.Lifetime; namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler { @@ -53,8 +52,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler /// public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface { - - private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + private ASCIIEncoding enc = new ASCIIEncoding(); private ScriptEngine m_ScriptEngine; private SceneObjectPart m_host; private uint m_localID; @@ -86,7 +84,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler { //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()"); // return null; - ILease lease = (ILease)base.InitializeLifetimeService(); + ILease lease = (ILease) base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { @@ -98,426 +96,1082 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler } - public Scene World + public Scene World + { + get { return m_ScriptEngine.World; } + } + + //These are the implementations of the various ll-functions used by the LSL scripts. + //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 + public double llSin(double f) + { + return (double) Math.Sin(f); + } + + public double llCos(double f) + { + return (double) Math.Cos(f); + } + + public double llTan(double f) + { + return (double) Math.Tan(f); + } + + public double llAtan2(double x, double y) + { + return (double) Math.Atan2(y, x); + } + + public double llSqrt(double f) + { + return (double) Math.Sqrt(f); + } + + public double llPow(double fbase, double fexponent) + { + return (double) Math.Pow(fbase, fexponent); + } + + public int llAbs(int i) + { + return (int) Math.Abs(i); + } + + public double llFabs(double f) + { + return (double) Math.Abs(f); + } + + public double llFrand(double mag) + { + lock (Util.RandomClass) + { + return Util.RandomClass.Next((int) mag); + } + } + + public int llFloor(double f) + { + return (int) Math.Floor(f); + } + + public int llCeil(double f) + { + return (int) Math.Ceiling(f); + } + + public int llRound(double f) + { + return (int) Math.Round(f, 3); + } + + //This next group are vector operations involving squaring and square root. ckrinke + public double llVecMag(LSL_Types.Vector3 v) + { + return (v.X*v.X + v.Y*v.Y + v.Z*v.Z); + } + + public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) + { + double mag = v.X*v.X + v.Y*v.Y + v.Z*v.Z; + LSL_Types.Vector3 nor = new LSL_Types.Vector3(); + nor.X = v.X/mag; + nor.Y = v.Y/mag; + nor.Z = v.Z/mag; + return nor; + } + + public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) + { + double dx = a.X - b.X; + double dy = a.Y - b.Y; + double dz = a.Z - b.Z; + return Math.Sqrt(dx*dx + dy*dy + dz*dz); + } + + //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke + public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) + { + //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke + LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X*r.X, r.Y*r.Y, r.Z*r.Z, r.R*r.R); + double m = (t.X + t.Y + t.Z + t.R); + if (m == 0) return new LSL_Types.Vector3(); + double n = 2*(r.Y*r.R + r.X*r.Z); + double p = m*m - n*n; + if (p > 0) + return new LSL_Types.Vector3(Math.Atan2(2.0*(r.X*r.R - r.Y*r.Z), (-t.X - t.Y + t.Z + t.R)), + Math.Atan2(n, Math.Sqrt(p)), + Math.Atan2(2.0*(r.Z*r.R - r.X*r.Y), (t.X - t.Y - t.Z + t.R))); + else if (n > 0) + return new LSL_Types.Vector3(0.0, Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); + else + return new LSL_Types.Vector3(0.0, -Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); + } + + public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) + { + //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07 + float err = 0.00001f; + double ax = Math.Sin(v.X/2); + double aw = Math.Cos(v.X/2); + double by = Math.Sin(v.Y/2); + double bw = Math.Cos(v.Y/2); + double cz = Math.Sin(v.Z/2); + double cw = Math.Cos(v.Z/2); + LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw); + LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw); + LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw); + LSL_Types.Quaternion a = new LSL_Types.Quaternion(); + //This multiplication doesnt compile, yet. a = a1 * a2 * a3; + LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax*bw*cw + aw*by*cz, + aw*by*cw - ax*bw*cz, aw*bw*cz + ax*by*cw, + aw*bw*cw - ax*by*cz); + LSL_Types.Quaternion c = new LSL_Types.Quaternion(); + //This addition doesnt compile yet c = a + b; + LSL_Types.Quaternion d = new LSL_Types.Quaternion(); + //This addition doesnt compile yet d = a - b; + if ((Math.Abs(c.X) > err && Math.Abs(d.X) > err) || + (Math.Abs(c.Y) > err && Math.Abs(d.Y) > err) || + (Math.Abs(c.Z) > err && Math.Abs(d.Z) > err) || + (Math.Abs(c.R) > err && Math.Abs(d.R) > err)) + { + //return a new Quaternion that is null until I figure this out + // return b; + // return a; + } + return new LSL_Types.Quaternion(); + } + + public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) + { + return new LSL_Types.Quaternion(); + } + + public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) + { + return new LSL_Types.Quaternion(); + } + + public void llWhisper(int channelID, string text) + { + //type for whisper is 0 + World.SimChat(Helpers.StringToField(text), + 0, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + + public void llSay(int channelID, string text) + { + //type for say is 1 + + World.SimChat(Helpers.StringToField(text), + 1, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + + public void llShout(int channelID, string text) + { + //type for shout is 2 + World.SimChat(Helpers.StringToField(text), + 2, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + + public int llListen(int channelID, string name, string ID, string msg) + { + NotImplemented("llListen"); + return 0; + } + + public void llListenControl(int number, int active) + { + NotImplemented("llListenControl"); + return; + } + + public void llListenRemove(int number) + { + NotImplemented("llListenRemove"); + return; + } + + public void llSensor(string name, string id, int type, double range, double arc) + { + NotImplemented("llSensor"); + return; + } + + public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) + { + NotImplemented("llSensorRepeat"); + return; + } + + public void llSensorRemove() + { + NotImplemented("llSensorRemove"); + return; + } + + public string llDetectedName(int number) + { + NotImplemented("llDetectedName"); + return ""; + } + + public string llDetectedKey(int number) + { + NotImplemented("llDetectedKey"); + return ""; + } + + public string llDetectedOwner(int number) + { + NotImplemented("llDetectedOwner"); + return ""; + } + + public int llDetectedType(int number) + { + NotImplemented("llDetectedType"); + return 0; + } + + public LSL_Types.Vector3 llDetectedPos(int number) + { + NotImplemented("llDetectedPos"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llDetectedVel(int number) + { + NotImplemented("llDetectedVel"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llDetectedGrab(int number) + { + NotImplemented("llDetectedGrab"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Quaternion llDetectedRot(int number) + { + NotImplemented("llDetectedRot"); + return new LSL_Types.Quaternion(); + } + + public int llDetectedGroup(int number) + { + NotImplemented("llDetectedGroup"); + return 0; + } + + public int llDetectedLinkNumber(int number) + { + NotImplemented("llDetectedLinkNumber"); + return 0; + } + + public void llDie() + { + NotImplemented("llDie"); + return; + } + + public double llGround(LSL_Types.Vector3 offset) + { + NotImplemented("llGround"); + return 0; + } + + public double llCloud(LSL_Types.Vector3 offset) + { + NotImplemented("llCloud"); + return 0; + } + + public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) + { + NotImplemented("llWind"); + return new LSL_Types.Vector3(); + } + + public void llSetStatus(int status, int value) + { + NotImplemented("llSetStatus"); + return; + } + + public int llGetStatus(int status) + { + NotImplemented("llGetStatus"); + return 0; + } + + public void llSetScale(LSL_Types.Vector3 scale) + { + // TODO: this needs to trigger a persistance save as well + LLVector3 tmp = m_host.Scale; + tmp.X = (float) scale.X; + tmp.Y = (float) scale.Y; + tmp.Z = (float) scale.Z; + m_host.Scale = tmp; + return; + } + + public LSL_Types.Vector3 llGetScale() + { + return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); + } + + public void llSetColor(LSL_Types.Vector3 color, int face) + { + NotImplemented("llSetColor"); + return; + } + + public double llGetAlpha(int face) + { + NotImplemented("llGetAlpha"); + return 0; + } + + public void llSetAlpha(double alpha, int face) + { + NotImplemented("llSetAlpha"); + return; + } + + public LSL_Types.Vector3 llGetColor(int face) + { + NotImplemented("llGetColor"); + return new LSL_Types.Vector3(); + } + + public void llSetTexture(string texture, int face) + { + NotImplemented("llSetTexture"); + return; + } + + public void llScaleTexture(double u, double v, int face) + { + NotImplemented("llScaleTexture"); + return; + } + + public void llOffsetTexture(double u, double v, int face) + { + NotImplemented("llOffsetTexture"); + return; + } + + public void llRotateTexture(double rotation, int face) + { + NotImplemented("llRotateTexture"); + return; + } + + public string llGetTexture(int face) + { + NotImplemented("llGetTexture"); + return ""; + } + + public void llSetPos(LSL_Types.Vector3 pos) + { + if (m_host.ParentID != 0) + { + m_host.UpdateOffSet(new LLVector3((float) pos.X, (float) pos.Y, (float) pos.Z)); + } + else + { + m_host.UpdateGroupPosition(new LLVector3((float) pos.X, (float) pos.Y, (float) pos.Z)); + } + } + + public LSL_Types.Vector3 llGetPos() + { + return new LSL_Types.Vector3(m_host.AbsolutePosition.X, + m_host.AbsolutePosition.Y, + m_host.AbsolutePosition.Z); + } + + public LSL_Types.Vector3 llGetLocalPos() + { + if (m_host.ParentID != 0) + { + return new LSL_Types.Vector3(m_host.OffsetPosition.X, + m_host.OffsetPosition.Y, + m_host.OffsetPosition.Z); + } + else + { + return new LSL_Types.Vector3(m_host.AbsolutePosition.X, + m_host.AbsolutePosition.Y, + m_host.AbsolutePosition.Z); + } + } + + public void llSetRot(LSL_Types.Quaternion rot) + { + m_host.UpdateRotation(new LLQuaternion((float) rot.X, (float) rot.Y, (float) rot.Z, (float) rot.R)); + } + + public LSL_Types.Quaternion llGetRot() + { + LLQuaternion q = m_host.RotationOffset; + return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); + } + + public LSL_Types.Quaternion llGetLocalRot() + { + NotImplemented("llGetLocalRot"); + return new LSL_Types.Quaternion(); + } + + public void llSetForce(LSL_Types.Vector3 force, int local) + { + NotImplemented("llSetForce"); + } + + public LSL_Types.Vector3 llGetForce() + { + NotImplemented("llGetForce"); + return new LSL_Types.Vector3(); + } + + public int llTarget(LSL_Types.Vector3 position, double range) + { + NotImplemented("llTarget"); + return 0; + } + + public void llTargetRemove(int number) + { + NotImplemented("llTargetRemove"); + } + + public int llRotTarget(LSL_Types.Quaternion rot, double error) + { + NotImplemented("llRotTarget"); + return 0; + } + + public void llRotTargetRemove(int number) + { + NotImplemented("llRotTargetRemove"); + } + + public void llMoveToTarget(LSL_Types.Vector3 target, double tau) + { + NotImplemented("llMoveToTarget"); + } + + public void llStopMoveToTarget() + { + NotImplemented("llStopMoveToTarget"); + } + + public void llApplyImpulse(LSL_Types.Vector3 force, int local) + { + NotImplemented("llApplyImpulse"); + } + + public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) + { + NotImplemented("llApplyRotationalImpulse"); + } + + public void llSetTorque(LSL_Types.Vector3 torque, int local) + { + NotImplemented("llSetTorque"); + } + + public LSL_Types.Vector3 llGetTorque() + { + NotImplemented("llGetTorque"); + return new LSL_Types.Vector3(); + } + + public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) + { + NotImplemented("llSetForceAndTorque"); + } + + public LSL_Types.Vector3 llGetVel() + { + NotImplemented("llGetVel"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llGetAccel() + { + NotImplemented("llGetAccel"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llGetOmega() + { + NotImplemented("llGetOmega"); + return new LSL_Types.Vector3(); + } + + public double llGetTimeOfDay() + { + NotImplemented("llGetTimeOfDay"); + return 0; + } + + public double llGetWallclock() + { + return DateTime.Now.TimeOfDay.TotalSeconds; + } + + public double llGetTime() + { + NotImplemented("llGetTime"); + return 0; + } + + public void llResetTime() + { + NotImplemented("llResetTime"); + } + + public double llGetAndResetTime() + { + NotImplemented("llGetAndResetTime"); + return 0; + } + + public void llSound() + { + NotImplemented("llSound"); + } + + public void llPlaySound(string sound, double volume) + { + NotImplemented("llPlaySound"); + } + + public void llLoopSound(string sound, double volume) + { + NotImplemented("llLoopSound"); + } + + public void llLoopSoundMaster(string sound, double volume) + { + NotImplemented("llLoopSoundMaster"); + } + + public void llLoopSoundSlave(string sound, double volume) + { + NotImplemented("llLoopSoundSlave"); + } + + public void llPlaySoundSlave(string sound, double volume) + { + NotImplemented("llPlaySoundSlave"); + } + + public void llTriggerSound(string sound, double volume) + { + NotImplemented("llTriggerSound"); + } + + public void llStopSound() + { + NotImplemented("llStopSound"); + } + + public void llPreloadSound(string sound) + { + NotImplemented("llPreloadSound"); + } + + public string llGetSubString(string src, int start, int end) + { + return src.Substring(start, end); + } + + public string llDeleteSubString(string src, int start, int end) + { + return src.Remove(start, end - start); + } + + public string llInsertString(string dst, int position, string src) + { + return dst.Insert(position, src); + } + + public string llToUpper(string src) + { + return src.ToUpper(); + } + + public string llToLower(string src) + { + return src.ToLower(); + } + + public int llGiveMoney(string destination, int amount) + { + NotImplemented("llGiveMoney"); + return 0; + } + + public void llMakeExplosion() + { + NotImplemented("llMakeExplosion"); + } + + public void llMakeFountain() + { + NotImplemented("llMakeFountain"); + } + + public void llMakeSmoke() + { + NotImplemented("llMakeSmoke"); + } + + public void llMakeFire() + { + NotImplemented("llMakeFire"); + } + + public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) + { + NotImplemented("llRezObject"); + } + + public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) + { + NotImplemented("llLookAt"); + } + + public void llStopLookAt() + { + NotImplemented("llStopLookAt"); + } + + public void llSetTimerEvent(double sec) + { + // Setting timer repeat + m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec); + } + + public void llSleep(double sec) + { + Thread.Sleep((int) (sec*1000)); + } + + public double llGetMass() + { + NotImplemented("llGetMass"); + return 0; + } + + public void llCollisionFilter(string name, string id, int accept) + { + NotImplemented("llCollisionFilter"); + } + + public void llTakeControls(int controls, int accept, int pass_on) + { + NotImplemented("llTakeControls"); + } + + public void llReleaseControls() + { + NotImplemented("llReleaseControls"); + } + + public void llAttachToAvatar(int attachment) + { + NotImplemented("llAttachToAvatar"); + } + + public void llDetachFromAvatar() + { + NotImplemented("llDetachFromAvatar"); + } + + public void llTakeCamera() + { + NotImplemented("llTakeCamera"); + } + + public void llReleaseCamera() + { + NotImplemented("llReleaseCamera"); + } + + public string llGetOwner() + { + return m_host.ObjectOwner.ToStringHyphenated(); + } + + public void llInstantMessage(string user, string message) + { + NotImplemented("llInstantMessage"); + } + + public void llEmail(string address, string subject, string message) + { + NotImplemented("llEmail"); + } + + public void llGetNextEmail(string address, string subject) + { + NotImplemented("llGetNextEmail"); + } + + public string llGetKey() + { + return m_host.UUID.ToStringHyphenated(); + } + + public void llSetBuoyancy(double buoyancy) + { + NotImplemented("llSetBuoyancy"); + } + + public void llSetHoverHeight(double height, int water, double tau) + { + NotImplemented("llSetHoverHeight"); + } + + public void llStopHover() + { + NotImplemented("llStopHover"); + } + + public void llMinEventDelay(double delay) + { + NotImplemented("llMinEventDelay"); + } + + public void llSoundPreload() + { + NotImplemented("llSoundPreload"); + } + + public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) + { + NotImplemented("llRotLookAt"); + } + + public int llStringLength(string str) + { + if (str.Length > 0) + { + return str.Length; + } + else + { + return 0; + } + } + + public void llStartAnimation(string anim) + { + NotImplemented("llStartAnimation"); + } + + public void llStopAnimation(string anim) + { + NotImplemented("llStopAnimation"); + } + + public void llPointAt() + { + NotImplemented("llPointAt"); + } + + public void llStopPointAt() + { + NotImplemented("llStopPointAt"); + } + + public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) + { + NotImplemented("llTargetOmega"); + } + + public int llGetStartParameter() + { + NotImplemented("llGetStartParameter"); + return 0; + } + + public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) { - get { return m_ScriptEngine.World; } + NotImplemented("llGodLikeRezObject"); } - //These are the implementations of the various ll-functions used by the LSL scripts. - //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 - public double llSin(double f) { return (double)Math.Sin(f); } - public double llCos(double f) { return (double)Math.Cos(f); } - public double llTan(double f) { return (double)Math.Tan(f); } - public double llAtan2(double x, double y) { return (double)Math.Atan2(y, x); } - public double llSqrt(double f) { return (double)Math.Sqrt(f); } - public double llPow(double fbase, double fexponent) { return (double)Math.Pow(fbase, fexponent); } - public int llAbs(int i) { return (int)Math.Abs(i); } - public double llFabs(double f) { return (double)Math.Abs(f); } + public void llRequestPermissions(string agent, int perm) + { + NotImplemented("llRequestPermissions"); + } - public double llFrand(double mag) + public string llGetPermissionsKey() { - lock (Util.RandomClass) - { - return Util.RandomClass.Next((int)mag); - } + NotImplemented("llGetPermissionsKey"); + return ""; } - public int llFloor(double f) { return (int)Math.Floor(f); } - public int llCeil(double f) { return (int)Math.Ceiling(f); } - public int llRound(double f) { return (int)Math.Round(f, 3); } + public int llGetPermissions() + { + NotImplemented("llGetPermissions"); + return 0; + } - //This next group are vector operations involving squaring and square root. ckrinke - public double llVecMag(LSL_Types.Vector3 v) + public int llGetLinkNumber() { - return (v.X * v.X + v.Y * v.Y + v.Z * v.Z); + NotImplemented("llGetLinkNumber"); + return 0; } - public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) + public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) { - double mag = v.X * v.X + v.Y * v.Y + v.Z * v.Z; - LSL_Types.Vector3 nor = new LSL_Types.Vector3(); - nor.X = v.X / mag; nor.Y = v.Y / mag; nor.Z = v.Z / mag; - return nor; + NotImplemented("llSetLinkColor"); } - public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) + public void llCreateLink(string target, int parent) { - double dx = a.X - b.X; double dy = a.Y - b.Y; double dz = a.Z - b.Z; - return Math.Sqrt(dx * dx + dy * dy + dz * dz); + NotImplemented("llCreateLink"); } - //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke - public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) + public void llBreakLink(int linknum) { - //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke - LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X * r.X, r.Y * r.Y, r.Z * r.Z, r.R * r.R); - double m = (t.X + t.Y + t.Z + t.R); - if (m == 0) return new LSL_Types.Vector3(); - double n = 2 * (r.Y * r.R + r.X * r.Z); - double p = m * m - n * n; - if (p > 0) - return new LSL_Types.Vector3(Math.Atan2(2.0 * (r.X * r.R - r.Y * r.Z), (-t.X - t.Y + t.Z + t.R)), - Math.Atan2(n, Math.Sqrt(p)), Math.Atan2(2.0 * (r.Z * r.R - r.X * r.Y), (t.X - t.Y - t.Z + t.R))); - else if (n > 0) - return new LSL_Types.Vector3(0.0, Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); - else - return new LSL_Types.Vector3(0.0, -Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); + NotImplemented("llBreakLink"); } - public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) + public void llBreakAllLinks() { - //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07 - float err = 0.00001f; - double ax = Math.Sin(v.X / 2); double aw = Math.Cos(v.X / 2); - double by = Math.Sin(v.Y / 2); double bw = Math.Cos(v.Y / 2); - double cz = Math.Sin(v.Z / 2); double cw = Math.Cos(v.Z / 2); - LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw); - LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw); - LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw); - LSL_Types.Quaternion a = new LSL_Types.Quaternion(); - //This multiplication doesnt compile, yet. a = a1 * a2 * a3; - LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax * bw * cw + aw * by * cz, - aw * by * cw - ax * bw * cz, aw * bw * cz + ax * by * cw, aw * bw * cw - ax * by * cz); - LSL_Types.Quaternion c = new LSL_Types.Quaternion(); - //This addition doesnt compile yet c = a + b; - LSL_Types.Quaternion d = new LSL_Types.Quaternion(); - //This addition doesnt compile yet d = a - b; - if ((Math.Abs(c.X) > err && Math.Abs(d.X) > err) || - (Math.Abs(c.Y) > err && Math.Abs(d.Y) > err) || - (Math.Abs(c.Z) > err && Math.Abs(d.Z) > err) || - (Math.Abs(c.R) > err && Math.Abs(d.R) > err)) - { - //return a new Quaternion that is null until I figure this out - // return b; - // return a; - } - return new LSL_Types.Quaternion(); + NotImplemented("llBreakAllLinks"); } - public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return new LSL_Types.Quaternion(); } - public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) { return new LSL_Types.Quaternion(); } + public string llGetLinkKey(int linknum) + { + NotImplemented("llGetLinkKey"); + return ""; + } - public void llWhisper(int channelID, string text) + public void llGetLinkName(int linknum) { - //type for whisper is 0 - World.SimChat(Helpers.StringToField(text), - 0, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + NotImplemented("llGetLinkName"); } - public void llSay(int channelID, string text) + public int llGetInventoryNumber(int type) { - //type for say is 1 + NotImplemented("llGetInventoryNumber"); + return 0; + } - World.SimChat(Helpers.StringToField(text), - 1, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + public string llGetInventoryName(int type, int number) + { + NotImplemented("llGetInventoryName"); + return ""; } - public void llShout(int channelID, string text) + public void llSetScriptState(string name, int run) { - //type for shout is 2 - World.SimChat(Helpers.StringToField(text), - 2, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + NotImplemented("llSetScriptState"); } - public int llListen(int channelID, string name, string ID, string msg) { NotImplemented("llListen"); return 0; } - public void llListenControl(int number, int active) { NotImplemented("llListenControl"); return; } - public void llListenRemove(int number) { NotImplemented("llListenRemove"); return; } - public void llSensor(string name, string id, int type, double range, double arc) { NotImplemented("llSensor"); return; } - public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { NotImplemented("llSensorRepeat"); return; } - public void llSensorRemove() { NotImplemented("llSensorRemove"); return; } - public string llDetectedName(int number) { NotImplemented("llDetectedName"); return ""; } - public string llDetectedKey(int number) { NotImplemented("llDetectedKey"); return ""; } - public string llDetectedOwner(int number) { NotImplemented("llDetectedOwner"); return ""; } - public int llDetectedType(int number) { NotImplemented("llDetectedType"); return 0; } - public LSL_Types.Vector3 llDetectedPos(int number) { NotImplemented("llDetectedPos"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llDetectedVel(int number) { NotImplemented("llDetectedVel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llDetectedGrab(int number) { NotImplemented("llDetectedGrab"); return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llDetectedRot(int number) { NotImplemented("llDetectedRot"); return new LSL_Types.Quaternion(); } - public int llDetectedGroup(int number) { NotImplemented("llDetectedGroup"); return 0; } - public int llDetectedLinkNumber(int number) { NotImplemented("llDetectedLinkNumber"); return 0; } - public void llDie() { NotImplemented("llDie"); return; } - public double llGround(LSL_Types.Vector3 offset) { NotImplemented("llGround"); return 0; } - public double llCloud(LSL_Types.Vector3 offset) { NotImplemented("llCloud"); return 0; } - public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) { NotImplemented("llWind"); return new LSL_Types.Vector3(); } - public void llSetStatus(int status, int value) { NotImplemented("llSetStatus"); return; } - public int llGetStatus(int status) { NotImplemented("llGetStatus"); return 0; } + public double llGetEnergy() + { + return 1.0f; + } - public void llSetScale(LSL_Types.Vector3 scale) + public void llGiveInventory(string destination, string inventory) { - // TODO: this needs to trigger a persistance save as well - LLVector3 tmp = m_host.Scale; - tmp.X = (float)scale.X; - tmp.Y = (float)scale.Y; - tmp.Z = (float)scale.Z; - m_host.Scale = tmp; - return; + NotImplemented("llGiveInventory"); } - public LSL_Types.Vector3 llGetScale() + + public void llRemoveInventory(string item) { - return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); + NotImplemented("llRemoveInventory"); } - public void llSetColor(LSL_Types.Vector3 color, int face) { NotImplemented("llSetColor"); return; } - public double llGetAlpha(int face) { NotImplemented("llGetAlpha"); return 0; } - public void llSetAlpha(double alpha, int face) { NotImplemented("llSetAlpha"); return; } - public LSL_Types.Vector3 llGetColor(int face) { NotImplemented("llGetColor"); return new LSL_Types.Vector3(); } - public void llSetTexture(string texture, int face) { NotImplemented("llSetTexture"); return; } - public void llScaleTexture(double u, double v, int face) { NotImplemented("llScaleTexture"); return; } - public void llOffsetTexture(double u, double v, int face) { NotImplemented("llOffsetTexture"); return; } - public void llRotateTexture(double rotation, int face) { NotImplemented("llRotateTexture"); return; } + public void llSetText(string text, LSL_Types.Vector3 color, double alpha) + { + Vector3 av3 = new Vector3((float) color.X, (float) color.Y, (float) color.Z); + m_host.SetText(text, av3, alpha); + } - public string llGetTexture(int face) { NotImplemented("llGetTexture"); return ""; } - public void llSetPos(LSL_Types.Vector3 pos) + public double llWater(LSL_Types.Vector3 offset) { - if (m_host.ParentID != 0) - { - m_host.UpdateOffSet(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); - } - else - { - m_host.UpdateGroupPosition(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); - } + NotImplemented("llWater"); + return 0; } - public LSL_Types.Vector3 llGetPos() + public void llPassTouches(int pass) { - return new LSL_Types.Vector3(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z); + NotImplemented("llPassTouches"); } - public LSL_Types.Vector3 llGetLocalPos() + public string llRequestAgentData(string id, int data) { - if (m_host.ParentID != 0) - { - return new LSL_Types.Vector3(m_host.OffsetPosition.X, - m_host.OffsetPosition.Y, - m_host.OffsetPosition.Z); - } - else - { - return new LSL_Types.Vector3(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z); - } + NotImplemented("llRequestAgentData"); + return ""; } - public void llSetRot(LSL_Types.Quaternion rot) + + public string llRequestInventoryData(string name) { - m_host.UpdateRotation(new LLQuaternion((float)rot.X, (float)rot.Y, (float)rot.Z, (float)rot.R)); + NotImplemented("llRequestInventoryData"); + return ""; } - public LSL_Types.Quaternion llGetRot() + + public void llSetDamage(double damage) { - LLQuaternion q = m_host.RotationOffset; - return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); + NotImplemented("llSetDamage"); } - public LSL_Types.Quaternion llGetLocalRot() { NotImplemented("llGetLocalRot"); return new LSL_Types.Quaternion(); } - public void llSetForce(LSL_Types.Vector3 force, int local) { NotImplemented("llSetForce"); } - public LSL_Types.Vector3 llGetForce() { NotImplemented("llGetForce"); return new LSL_Types.Vector3(); } - public int llTarget(LSL_Types.Vector3 position, double range) { NotImplemented("llTarget"); return 0; } - public void llTargetRemove(int number) { NotImplemented("llTargetRemove"); } - public int llRotTarget(LSL_Types.Quaternion rot, double error) { NotImplemented("llRotTarget"); return 0; } - public void llRotTargetRemove(int number) { NotImplemented("llRotTargetRemove"); } - public void llMoveToTarget(LSL_Types.Vector3 target, double tau) { NotImplemented("llMoveToTarget"); } - public void llStopMoveToTarget() { NotImplemented("llStopMoveToTarget"); } - public void llApplyImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyImpulse"); } - public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyRotationalImpulse"); } - public void llSetTorque(LSL_Types.Vector3 torque, int local) { NotImplemented("llSetTorque"); } - public LSL_Types.Vector3 llGetTorque() { NotImplemented("llGetTorque"); return new LSL_Types.Vector3(); } - public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) { NotImplemented("llSetForceAndTorque"); } - public LSL_Types.Vector3 llGetVel() { NotImplemented("llGetVel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetAccel() { NotImplemented("llGetAccel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetOmega() { NotImplemented("llGetOmega"); return new LSL_Types.Vector3(); } - public double llGetTimeOfDay() { NotImplemented("llGetTimeOfDay"); return 0; } - public double llGetWallclock() + public void llTeleportAgentHome(string agent) { - return DateTime.Now.TimeOfDay.TotalSeconds; + NotImplemented("llTeleportAgentHome"); } - public double llGetTime() { NotImplemented("llGetTime"); return 0; } - public void llResetTime() { NotImplemented("llResetTime"); } - public double llGetAndResetTime() { NotImplemented("llGetAndResetTime"); return 0; } - public void llSound() { NotImplemented("llSound"); } - public void llPlaySound(string sound, double volume) { NotImplemented("llPlaySound"); } - public void llLoopSound(string sound, double volume) { NotImplemented("llLoopSound"); } - public void llLoopSoundMaster(string sound, double volume) { NotImplemented("llLoopSoundMaster"); } - public void llLoopSoundSlave(string sound, double volume) { NotImplemented("llLoopSoundSlave"); } - public void llPlaySoundSlave(string sound, double volume) { NotImplemented("llPlaySoundSlave"); } - public void llTriggerSound(string sound, double volume) { NotImplemented("llTriggerSound"); } - public void llStopSound() { NotImplemented("llStopSound"); } - public void llPreloadSound(string sound) { NotImplemented("llPreloadSound"); } - - public string llGetSubString(string src, int start, int end) + public void llModifyLand(int action, int brush) { - return src.Substring(start, end); } - public string llDeleteSubString(string src, int start, int end) + public void llCollisionSound(string impact_sound, double impact_volume) { - return src.Remove(start, end - start); + NotImplemented("llCollisionSound"); } - public string llInsertString(string dst, int position, string src) + + public void llCollisionSprite(string impact_sprite) { - return dst.Insert(position, src); + NotImplemented("llCollisionSprite"); } - public string llToUpper(string src) + + public string llGetAnimation(string id) { - return src.ToUpper(); + NotImplemented("llGetAnimation"); + return ""; } - public string llToLower(string src) + public void llResetScript() { - return src.ToLower(); + m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); } - public int llGiveMoney(string destination, int amount) { NotImplemented("llGiveMoney"); return 0; } - public void llMakeExplosion() { NotImplemented("llMakeExplosion"); } - public void llMakeFountain() { NotImplemented("llMakeFountain"); } - public void llMakeSmoke() { NotImplemented("llMakeSmoke"); } - public void llMakeFire() { NotImplemented("llMakeFire"); } - public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezObject"); } - public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { NotImplemented("llLookAt"); } - public void llStopLookAt() { NotImplemented("llStopLookAt"); } - - public void llSetTimerEvent(double sec) + public void llMessageLinked(int linknum, int num, string str, string id) { - // Setting timer repeat - m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec); } - public void llSleep(double sec) + public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { - System.Threading.Thread.Sleep((int)(sec * 1000)); } - public double llGetMass() { NotImplemented("llGetMass"); return 0; } - public void llCollisionFilter(string name, string id, int accept) { NotImplemented("llCollisionFilter"); } - public void llTakeControls(int controls, int accept, int pass_on) { NotImplemented("llTakeControls"); } - public void llReleaseControls() { NotImplemented("llReleaseControls"); } - public void llAttachToAvatar(int attachment) { NotImplemented("llAttachToAvatar"); } - public void llDetachFromAvatar() { NotImplemented("llDetachFromAvatar"); } - public void llTakeCamera() { NotImplemented("llTakeCamera"); } - public void llReleaseCamera() { NotImplemented("llReleaseCamera"); } + public void llPassCollisions(int pass) + { + } - public string llGetOwner() + public string llGetScriptName() { - return m_host.ObjectOwner.ToStringHyphenated(); + return ""; } - public void llInstantMessage(string user, string message) { NotImplemented("llInstantMessage"); } - public void llEmail(string address, string subject, string message) { NotImplemented("llEmail"); } - public void llGetNextEmail(string address, string subject) { NotImplemented("llGetNextEmail"); } + public int llGetNumberOfSides() + { + return 0; + } - public string llGetKey() + public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { - return m_host.UUID.ToStringHyphenated(); + return new LSL_Types.Quaternion(); } - public void llSetBuoyancy(double buoyancy) { NotImplemented("llSetBuoyancy"); } - public void llSetHoverHeight(double height, int water, double tau) { NotImplemented("llSetHoverHeight"); } - public void llStopHover() { NotImplemented("llStopHover"); } - public void llMinEventDelay(double delay) { NotImplemented("llMinEventDelay"); } - public void llSoundPreload() { NotImplemented("llSoundPreload"); } - public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) { NotImplemented("llRotLookAt"); } + public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) + { + return new LSL_Types.Vector3(); + } - public int llStringLength(string str) + public void llRot2Angle() { - if (str.Length > 0) - { - return str.Length; - } - else - { - return 0; - } } - public void llStartAnimation(string anim) { NotImplemented("llStartAnimation"); } - public void llStopAnimation(string anim) { NotImplemented("llStopAnimation"); } - public void llPointAt() { NotImplemented("llPointAt"); } - public void llStopPointAt() { NotImplemented("llStopPointAt"); } - public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) { NotImplemented("llTargetOmega"); } - public int llGetStartParameter() { NotImplemented("llGetStartParameter"); return 0; } - public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) { NotImplemented("llGodLikeRezObject"); } - public void llRequestPermissions(string agent, int perm) { NotImplemented("llRequestPermissions"); } - public string llGetPermissionsKey() { NotImplemented("llGetPermissionsKey"); return ""; } - public int llGetPermissions() { NotImplemented("llGetPermissions"); return 0; } - public int llGetLinkNumber() { NotImplemented("llGetLinkNumber"); return 0; } - public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) { NotImplemented("llSetLinkColor"); } - public void llCreateLink(string target, int parent) { NotImplemented("llCreateLink"); } - public void llBreakLink(int linknum) { NotImplemented("llBreakLink"); } - public void llBreakAllLinks() { NotImplemented("llBreakAllLinks"); } - public string llGetLinkKey(int linknum) { NotImplemented("llGetLinkKey"); return ""; } - public void llGetLinkName(int linknum) { NotImplemented("llGetLinkName"); } - public int llGetInventoryNumber(int type) { NotImplemented("llGetInventoryNumber"); return 0; } - public string llGetInventoryName(int type, int number) { NotImplemented("llGetInventoryName"); return ""; } - public void llSetScriptState(string name, int run) { NotImplemented("llSetScriptState"); } - public double llGetEnergy() { return 1.0f; } - public void llGiveInventory(string destination, string inventory) { NotImplemented("llGiveInventory"); } - public void llRemoveInventory(string item) { NotImplemented("llRemoveInventory"); } + public double llAcos(double val) + { + return (double) Math.Acos(val); + } - public void llSetText(string text, LSL_Types.Vector3 color, double alpha) + public double llAsin(double val) { - Axiom.Math.Vector3 av3 = new Axiom.Math.Vector3((float)color.X, (float)color.Y, (float)color.Z); - m_host.SetText(text, av3, alpha); + return (double) Math.Asin(val); } + public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) + { + return 0; + } - public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); return 0; } - public void llPassTouches(int pass) { NotImplemented("llPassTouches"); } - public string llRequestAgentData(string id, int data) { NotImplemented("llRequestAgentData"); return ""; } - public string llRequestInventoryData(string name) { NotImplemented("llRequestInventoryData"); return ""; } - public void llSetDamage(double damage) { NotImplemented("llSetDamage"); } - public void llTeleportAgentHome(string agent) { NotImplemented("llTeleportAgentHome"); } - public void llModifyLand(int action, int brush) { } - public void llCollisionSound(string impact_sound, double impact_volume) { NotImplemented("llCollisionSound"); } - public void llCollisionSprite(string impact_sprite) { NotImplemented("llCollisionSprite"); } - public string llGetAnimation(string id) { NotImplemented("llGetAnimation"); return ""; } - public void llResetScript() + public string llGetInventoryKey(string name) { - m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); + return ""; } - public void llMessageLinked(int linknum, int num, string str, string id) { } - public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { } - public void llPassCollisions(int pass) { } - public string llGetScriptName() { return ""; } - public int llGetNumberOfSides() { return 0; } + public void llAllowInventoryDrop(int add) + { + } - public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { return new LSL_Types.Quaternion(); } - public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) { return new LSL_Types.Vector3(); } - public void llRot2Angle() { } + public LSL_Types.Vector3 llGetSunDirection() + { + return new LSL_Types.Vector3(); + } - public double llAcos(double val) + public LSL_Types.Vector3 llGetTextureOffset(int face) { - return (double)Math.Acos(val); + return new LSL_Types.Vector3(); } - public double llAsin(double val) + public LSL_Types.Vector3 llGetTextureScale(int side) { - return (double)Math.Asin(val); + return new LSL_Types.Vector3(); } - public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) { return 0; } - public string llGetInventoryKey(string name) { return ""; } - public void llAllowInventoryDrop(int add) { } - public LSL_Types.Vector3 llGetSunDirection() { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetTextureOffset(int face) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetTextureScale(int side) { return new LSL_Types.Vector3(); } - public double llGetTextureRot(int side) { return 0; } + public double llGetTextureRot(int side) + { + return 0; + } public int llSubStringIndex(string source, string pattern) { return source.IndexOf(pattern); } - public string llGetOwnerKey(string id) { NotImplemented("llGetOwnerKey"); return ""; } + public string llGetOwnerKey(string id) + { + NotImplemented("llGetOwnerKey"); + return ""; + } - public LSL_Types.Vector3 llGetCenterOfMass() { NotImplemented("llGetCenterOfMass"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGetCenterOfMass() + { + NotImplemented("llGetCenterOfMass"); + return new LSL_Types.Vector3(); + } public List llListSort(List src, int stride, int ascending) { @@ -551,7 +1205,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler ret.AddRange(ls); } - if (ascending == LSL.LSL_BaseClass.TRUE) + if (ascending == LSL_BaseClass.TRUE) return ret; ret.Reverse(); return ret; @@ -590,12 +1244,18 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler public LSL_Types.Vector3 llList2Vector(List src, int index) { - return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2])); + return + new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), + double.Parse(src[index + 2])); } + public LSL_Types.Quaternion llList2Rot(List src, int index) { - return new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]), double.Parse(src[index + 3])); + return + new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), + double.Parse(src[index + 2]), double.Parse(src[index + 3])); } + public List llList2List(List src, int start, int end) { if (end > start) @@ -612,18 +1272,21 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler ret.AddRange(src.GetRange(0, end)); return ret; } - - - - } + public List llDeleteSubList(List src, int start, int end) { List ret = new List(src); ret.RemoveRange(start, end - start); return ret; } - public int llGetListEntryType(List src, int index) { NotImplemented("llGetListEntryType"); return 0; } + + public int llGetListEntryType(List src, int index) + { + NotImplemented("llGetListEntryType"); + return 0; + } + public string llList2CSV(List src) { string ret = ""; @@ -635,6 +1298,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler } return ret; } + public List llCSV2List(string src) { List ret = new List(); @@ -644,6 +1308,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler } return ret; } + public List llListRandomize(List src, int stride) { int s = stride; @@ -685,9 +1350,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler } return ret; - - } + public List llList2ListStrided(List src, int start, int end, int stride) { List ret = new List(); @@ -713,12 +1377,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler public LSL_Types.Vector3 llGetRegionCorner() { - return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * 256, World.RegionInfo.RegionLocY * 256, 0); + return new LSL_Types.Vector3(World.RegionInfo.RegionLocX*256, World.RegionInfo.RegionLocY*256, 0); } public List llListInsertList(List dest, List src, int start) { - List ret = new List(dest); //foreach (string s in src.Reverse()) for (int ci = src.Count - 1; ci > -1; ci--) @@ -727,68 +1390,170 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler } return ret; } + public int llListFindList(List src, List test) { foreach (string s in test) { for (int ci = 0; ci < src.Count; ci++) { + if (s == src[ci]) + return ci; + } + } + return -1; + } + + public string llGetObjectName() + { + return m_host.Name; + } + + public void llSetObjectName(string name) + { + m_host.Name = name; + } + + public string llGetDate() + { + DateTime date = DateTime.Now.ToUniversalTime(); + string result = date.ToString("yyyy-MM-dd"); + return result; + } + + public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) + { + NotImplemented("llEdgeOfWorld"); + return 0; + } + + public int llGetAgentInfo(string id) + { + NotImplemented("llGetAgentInfo"); + return 0; + } + + public void llAdjustSoundVolume(double volume) + { + NotImplemented("llAdjustSoundVolume"); + } + + public void llSetSoundQueueing(int queue) + { + NotImplemented("llSetSoundQueueing"); + } + + public void llSetSoundRadius(double radius) + { + NotImplemented("llSetSoundRadius"); + } + + public string llKey2Name(string id) + { + NotImplemented("llKey2Name"); + return ""; + } + + public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) + { + NotImplemented("llSetTextureAnim"); + } + + public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, + LSL_Types.Vector3 bottom_south_west) + { + NotImplemented("llTriggerSoundLimited"); + } + + public void llEjectFromLand(string pest) + { + NotImplemented("llEjectFromLand"); + } + + public void llParseString2List() + { + NotImplemented("llParseString2List"); + } + + public int llOverMyLand(string id) + { + NotImplemented("llOverMyLand"); + return 0; + } + + public string llGetLandOwnerAt(LSL_Types.Vector3 pos) + { + NotImplemented("llGetLandOwnerAt"); + return ""; + } + + public string llGetNotecardLine(string name, int line) + { + NotImplemented("llGetNotecardLine"); + return ""; + } + + public LSL_Types.Vector3 llGetAgentSize(string id) + { + NotImplemented("llGetAgentSize"); + return new LSL_Types.Vector3(); + } + + public int llSameGroup(string agent) + { + NotImplemented("llSameGroup"); + return 0; + } + + public void llUnSit(string id) + { + NotImplemented("llUnSit"); + } - if (s == src[ci]) - return ci; - } - } - return -1; + public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) + { + NotImplemented("llGroundSlope"); + return new LSL_Types.Vector3(); } - public string llGetObjectName() + public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { - return m_host.Name; + NotImplemented("llGroundNormal"); + return new LSL_Types.Vector3(); } - public void llSetObjectName(string name) + public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { - m_host.Name = name; + NotImplemented("llGroundContour"); + return new LSL_Types.Vector3(); } - public string llGetDate() + public int llGetAttached() { - DateTime date = DateTime.Now.ToUniversalTime(); - string result = date.ToString("yyyy-MM-dd"); - return result; + NotImplemented("llGetAttached"); + return 0; } - public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) { NotImplemented("llEdgeOfWorld"); return 0; } - public int llGetAgentInfo(string id) { NotImplemented("llGetAgentInfo"); return 0; } - public void llAdjustSoundVolume(double volume) { NotImplemented("llAdjustSoundVolume"); } - public void llSetSoundQueueing(int queue) { NotImplemented("llSetSoundQueueing"); } - public void llSetSoundRadius(double radius) { NotImplemented("llSetSoundRadius"); } - public string llKey2Name(string id) { NotImplemented("llKey2Name"); return ""; } - public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { NotImplemented("llSetTextureAnim"); } - public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west) { NotImplemented("llTriggerSoundLimited"); } - public void llEjectFromLand(string pest) { NotImplemented("llEjectFromLand"); } - - public void llParseString2List() { NotImplemented("llParseString2List"); } - - public int llOverMyLand(string id) { NotImplemented("llOverMyLand"); return 0; } - public string llGetLandOwnerAt(LSL_Types.Vector3 pos) { NotImplemented("llGetLandOwnerAt"); return ""; } - public string llGetNotecardLine(string name, int line) { NotImplemented("llGetNotecardLine"); return ""; } - public LSL_Types.Vector3 llGetAgentSize(string id) { NotImplemented("llGetAgentSize"); return new LSL_Types.Vector3(); } - public int llSameGroup(string agent) { NotImplemented("llSameGroup"); return 0; } - public void llUnSit(string id) { NotImplemented("llUnSit"); } - public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) { NotImplemented("llGroundSlope"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { NotImplemented("llGroundNormal"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { NotImplemented("llGroundContour"); return new LSL_Types.Vector3(); } - public int llGetAttached() { NotImplemented("llGetAttached"); return 0; } - public int llGetFreeMemory() { NotImplemented("llGetFreeMemory"); return 0; } + public int llGetFreeMemory() + { + NotImplemented("llGetFreeMemory"); + return 0; + } public string llGetRegionName() { return World.RegionInfo.RegionName; } - public double llGetRegionTimeDilation() { return 1.0f; } - public double llGetRegionFPS() { return 10.0f; } + public double llGetRegionTimeDilation() + { + return 1.0f; + } + + public double llGetRegionFPS() + { + return 10.0f; + } /* particle system rules should be coming into this routine as doubles, that is rule[0] should be an integer from this list and rule[1] should be the arg @@ -798,6 +1563,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler We iterate through the list for 'Count' elements, incrementing by two for each iteration and set the members of Primitive.ParticleSystem, one at a time. */ + public enum PrimitiveRule : int { PSYS_PART_FLAGS = 0, @@ -828,109 +1594,152 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); for (int i = 0; i < rules.Count; i += 2) { - switch ((int)rules[i]) + switch ((int) rules[i]) { - case (int)PrimitiveRule.PSYS_PART_FLAGS: - prules.PartFlags = (uint)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_FLAGS: + prules.PartFlags = (uint) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_START_COLOR: - prules.PartStartColor = (LLColor)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_START_COLOR: + prules.PartStartColor = (LLColor) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_START_ALPHA: + case (int) PrimitiveRule.PSYS_PART_START_ALPHA: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_END_COLOR: - prules.PartEndColor = (LLColor)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_END_COLOR: + prules.PartEndColor = (LLColor) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_END_ALPHA: + case (int) PrimitiveRule.PSYS_PART_END_ALPHA: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_START_SCALE: + case (int) PrimitiveRule.PSYS_PART_START_SCALE: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_END_SCALE: + case (int) PrimitiveRule.PSYS_PART_END_SCALE: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_MAX_AGE: - prules.MaxAge = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_MAX_AGE: + prules.MaxAge = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_ACCEL: + case (int) PrimitiveRule.PSYS_SRC_ACCEL: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_PATTERN: + case (int) PrimitiveRule.PSYS_SRC_PATTERN: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_TEXTURE: - prules.Texture = (LLUUID)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_TEXTURE: + prules.Texture = (LLUUID) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_RATE: - prules.BurstRate = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_RATE: + prules.BurstRate = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_PART_COUNT: - prules.BurstPartCount = (byte)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_PART_COUNT: + prules.BurstPartCount = (byte) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_RADIUS: - prules.BurstRadius = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_RADIUS: + prules.BurstRadius = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MIN: - prules.BurstSpeedMin = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_SPEED_MIN: + prules.BurstSpeedMin = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MAX: - prules.BurstSpeedMax = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_SPEED_MAX: + prules.BurstSpeedMax = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_MAX_AGE: - prules.MaxAge = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_MAX_AGE: + prules.MaxAge = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_TARGET_KEY: - prules.Target = (LLUUID)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_TARGET_KEY: + prules.Target = (LLUUID) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_OMEGA: + case (int) PrimitiveRule.PSYS_SRC_OMEGA: //cast?? prules.MaxAge = (float)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_ANGLE_BEGIN: - prules.InnerAngle = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_ANGLE_BEGIN: + prules.InnerAngle = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_ANGLE_END: - prules.OuterAngle = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_ANGLE_END: + prules.OuterAngle = (float) rules[i + 1]; break; - } } m_host.AddNewParticleSystem(prules); } - public void llGroundRepel(double height, int water, double tau) { NotImplemented("llGroundRepel"); } - public void llGiveInventoryList() { NotImplemented("llGiveInventoryList"); } - public void llSetVehicleType(int type) { NotImplemented("llSetVehicleType"); } - public void llSetVehicledoubleParam(int param, double value) { NotImplemented("llSetVehicledoubleParam"); } - public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) { NotImplemented("llSetVehicleVectorParam"); } - public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) { NotImplemented("llSetVehicleRotationParam"); } - public void llSetVehicleFlags(int flags) { NotImplemented("llSetVehicleFlags"); } - public void llRemoveVehicleFlags(int flags) { NotImplemented("llRemoveVehicleFlags"); } - public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) { NotImplemented("llSitTarget"); } - public string llAvatarOnSitTarget() { NotImplemented("llAvatarOnSitTarget"); return ""; } - public void llAddToLandPassList(string avatar, double hours) { NotImplemented("llAddToLandPassList"); } + public void llGroundRepel(double height, int water, double tau) + { + NotImplemented("llGroundRepel"); + } + + public void llGiveInventoryList() + { + NotImplemented("llGiveInventoryList"); + } + + public void llSetVehicleType(int type) + { + NotImplemented("llSetVehicleType"); + } + + public void llSetVehicledoubleParam(int param, double value) + { + NotImplemented("llSetVehicledoubleParam"); + } + + public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) + { + NotImplemented("llSetVehicleVectorParam"); + } + + public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) + { + NotImplemented("llSetVehicleRotationParam"); + } + + public void llSetVehicleFlags(int flags) + { + NotImplemented("llSetVehicleFlags"); + } + + public void llRemoveVehicleFlags(int flags) + { + NotImplemented("llRemoveVehicleFlags"); + } + + public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) + { + NotImplemented("llSitTarget"); + } + + public string llAvatarOnSitTarget() + { + NotImplemented("llAvatarOnSitTarget"); + return ""; + } + + public void llAddToLandPassList(string avatar, double hours) + { + NotImplemented("llAddToLandPassList"); + } public void llSetTouchText(string text) { @@ -942,37 +1751,99 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler m_host.SitName = text; } - public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraEyeOffset"); } - public void llSetCameraAtOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraAtOffset"); } - public void llDumpList2String() { NotImplemented("llDumpList2String"); } - public void llScriptDanger(LSL_Types.Vector3 pos) { NotImplemented("llScriptDanger"); } - public void llDialog(string avatar, string message, List buttons, int chat_channel) { NotImplemented("llDialog"); } - public void llVolumeDetect(int detect) { NotImplemented("llVolumeDetect"); } - public void llResetOtherScript(string name) { NotImplemented("llResetOtherScript"); } + public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) + { + NotImplemented("llSetCameraEyeOffset"); + } + + public void llSetCameraAtOffset(LSL_Types.Vector3 offset) + { + NotImplemented("llSetCameraAtOffset"); + } + + public void llDumpList2String() + { + NotImplemented("llDumpList2String"); + } + + public void llScriptDanger(LSL_Types.Vector3 pos) + { + NotImplemented("llScriptDanger"); + } + + public void llDialog(string avatar, string message, List buttons, int chat_channel) + { + NotImplemented("llDialog"); + } + + public void llVolumeDetect(int detect) + { + NotImplemented("llVolumeDetect"); + } + + public void llResetOtherScript(string name) + { + NotImplemented("llResetOtherScript"); + } + + public int llGetScriptState(string name) + { + NotImplemented("llGetScriptState"); + return 0; + } + + public void llRemoteLoadScript() + { + NotImplemented("llRemoteLoadScript"); + } + + public void llSetRemoteScriptAccessPin(int pin) + { + NotImplemented("llSetRemoteScriptAccessPin"); + } + + public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) + { + NotImplemented("llRemoteLoadScriptPin"); + } + + public void llOpenRemoteDataChannel() + { + NotImplemented("llOpenRemoteDataChannel"); + } + + public string llSendRemoteData(string channel, string dest, int idata, string sdata) + { + NotImplemented("llSendRemoteData"); + return ""; + } - public int llGetScriptState(string name) { NotImplemented("llGetScriptState"); return 0; } + public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) + { + NotImplemented("llRemoteDataReply"); + } - public void llRemoteLoadScript() { NotImplemented("llRemoteLoadScript"); } - public void llSetRemoteScriptAccessPin(int pin) { NotImplemented("llSetRemoteScriptAccessPin"); } - public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { NotImplemented("llRemoteLoadScriptPin"); } - public void llOpenRemoteDataChannel() { NotImplemented("llOpenRemoteDataChannel"); } - public string llSendRemoteData(string channel, string dest, int idata, string sdata) { NotImplemented("llSendRemoteData"); return ""; } - public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) { NotImplemented("llRemoteDataReply"); } - public void llCloseRemoteDataChannel(string channel) { NotImplemented("llCloseRemoteDataChannel"); } + public void llCloseRemoteDataChannel(string channel) + { + NotImplemented("llCloseRemoteDataChannel"); + } public string llMD5String(string src, int nonce) { return Util.Md5Hash(src + ":" + nonce.ToString()); } - public void llSetPrimitiveParams(List rules) { NotImplemented("llSetPrimitiveParams"); } - public string llStringToBase64(string str) + public void llSetPrimitiveParams(List rules) { + NotImplemented("llSetPrimitiveParams"); + } + public string llStringToBase64(string str) + { try { byte[] encData_byte = new byte[str.Length]; - encData_byte = System.Text.Encoding.UTF8.GetBytes(str); + encData_byte = Encoding.UTF8.GetBytes(str); string encodedData = Convert.ToBase64String(encData_byte); return encodedData; } @@ -984,11 +1855,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler public string llBase64ToString(string str) { - System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); - System.Text.Decoder utf8Decode = encoder.GetDecoder(); + UTF8Encoding encoder = new UTF8Encoding(); + Decoder utf8Decode = encoder.GetDecoder(); try { - byte[] todecode_byte = Convert.FromBase64String(str); int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); char[] decoded_char = new char[charCount]; @@ -1001,16 +1871,49 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler throw new Exception("Error in base64Decode" + e.Message); } } - public void llXorBase64Strings() { throw new Exception("Command deprecated! Use llXorBase64StringsCorrect instead."); } - public void llRemoteDataSetRegion() { NotImplemented("llRemoteDataSetRegion"); } - public double llLog10(double val) { return (double)Math.Log10(val); } - public double llLog(double val) { return (double)Math.Log(val); } - public List llGetAnimationList(string id) { NotImplemented("llGetAnimationList"); return new List(); } - public void llSetParcelMusicURL(string url) { NotImplemented("llSetParcelMusicURL"); } - public LSL_Types.Vector3 llGetRootPosition() { NotImplemented("llGetRootPosition"); return new LSL_Types.Vector3(); } + public void llXorBase64Strings() + { + throw new Exception("Command deprecated! Use llXorBase64StringsCorrect instead."); + } + + public void llRemoteDataSetRegion() + { + NotImplemented("llRemoteDataSetRegion"); + } + + public double llLog10(double val) + { + return (double) Math.Log10(val); + } + + public double llLog(double val) + { + return (double) Math.Log(val); + } + + public List llGetAnimationList(string id) + { + NotImplemented("llGetAnimationList"); + return new List(); + } + + public void llSetParcelMusicURL(string url) + { + NotImplemented("llSetParcelMusicURL"); + } + + public LSL_Types.Vector3 llGetRootPosition() + { + NotImplemented("llGetRootPosition"); + return new LSL_Types.Vector3(); + } - public LSL_Types.Quaternion llGetRootRotation() { NotImplemented("llGetRootRotation"); return new LSL_Types.Quaternion(); } + public LSL_Types.Quaternion llGetRootRotation() + { + NotImplemented("llGetRootRotation"); + return new LSL_Types.Quaternion(); + } public string llGetObjectDesc() { @@ -1027,20 +1930,55 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler return m_host.ObjectCreator.ToStringHyphenated(); } - public string llGetTimestamp() { return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } - public void llSetLinkAlpha(int linknumber, double alpha, int face) { NotImplemented("llSetLinkAlpha"); } - public int llGetNumberOfPrims() { NotImplemented("llGetNumberOfPrims"); return 0; } - public string llGetNumberOfNotecardLines(string name) { NotImplemented("llGetNumberOfNotecardLines"); return ""; } - public List llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); return new List(); } - public LSL_Types.Vector3 llGetGeometricCenter() { NotImplemented("llGetGeometricCenter"); return new LSL_Types.Vector3(); } - public void llGetPrimitiveParams() { NotImplemented("llGetPrimitiveParams"); } + public string llGetTimestamp() + { + return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); + } + + public void llSetLinkAlpha(int linknumber, double alpha, int face) + { + NotImplemented("llSetLinkAlpha"); + } + + public int llGetNumberOfPrims() + { + NotImplemented("llGetNumberOfPrims"); + return 0; + } + + public string llGetNumberOfNotecardLines(string name) + { + NotImplemented("llGetNumberOfNotecardLines"); + return ""; + } + + public List llGetBoundingBox(string obj) + { + NotImplemented("llGetBoundingBox"); + return new List(); + } + + public LSL_Types.Vector3 llGetGeometricCenter() + { + NotImplemented("llGetGeometricCenter"); + return new LSL_Types.Vector3(); + } + + public void llGetPrimitiveParams() + { + NotImplemented("llGetPrimitiveParams"); + } + public string llIntegerToBase64(int number) { - NotImplemented("llIntegerToBase64"); return ""; + NotImplemented("llIntegerToBase64"); + return ""; } + public int llBase64ToInteger(string str) { - NotImplemented("llBase64ToInteger"); return 0; + NotImplemented("llBase64ToInteger"); + return 0; } public double llGetGMTclock() @@ -1050,34 +1988,95 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler public string llGetSimulatorHostname() { - return System.Environment.MachineName; + return Environment.MachineName; + } + + public void llSetLocalRot(LSL_Types.Quaternion rot) + { + NotImplemented("llSetLocalRot"); + } + + public List llParseStringKeepNulls(string src, List seperators, List spacers) + { + NotImplemented("llParseStringKeepNulls"); + return new List(); + } + + public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, + LSL_Types.Quaternion rot, int param) + { + NotImplemented("llRezAtRoot"); + } + + public int llGetObjectPermMask(int mask) + { + NotImplemented("llGetObjectPermMask"); + return 0; + } + + public void llSetObjectPermMask(int mask, int value) + { + NotImplemented("llSetObjectPermMask"); + } + + public void llGetInventoryPermMask(string item, int mask) + { + NotImplemented("llGetInventoryPermMask"); + } + + public void llSetInventoryPermMask(string item, int mask, int value) + { + NotImplemented("llSetInventoryPermMask"); + } + + public string llGetInventoryCreator(string item) + { + NotImplemented("llGetInventoryCreator"); + return ""; + } + + public void llOwnerSay(string msg) + { + NotImplemented("llOwnerSay"); } - public void llSetLocalRot(LSL_Types.Quaternion rot) { NotImplemented("llSetLocalRot"); } - public List llParseStringKeepNulls(string src, List seperators, List spacers) { NotImplemented("llParseStringKeepNulls"); return new List(); } - public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezAtRoot"); } + public void llRequestSimulatorData(string simulator, int data) + { + NotImplemented("llRequestSimulatorData"); + } - public int llGetObjectPermMask(int mask) { NotImplemented("llGetObjectPermMask"); return 0; } + public void llForceMouselook(int mouselook) + { + NotImplemented("llForceMouselook"); + } - public void llSetObjectPermMask(int mask, int value) { NotImplemented("llSetObjectPermMask"); } + public double llGetObjectMass(string id) + { + NotImplemented("llGetObjectMass"); + return 0; + } - public void llGetInventoryPermMask(string item, int mask) { NotImplemented("llGetInventoryPermMask"); } - public void llSetInventoryPermMask(string item, int mask, int value) { NotImplemented("llSetInventoryPermMask"); } - public string llGetInventoryCreator(string item) { NotImplemented("llGetInventoryCreator"); return ""; } - public void llOwnerSay(string msg) { NotImplemented("llOwnerSay"); } - public void llRequestSimulatorData(string simulator, int data) { NotImplemented("llRequestSimulatorData"); } - public void llForceMouselook(int mouselook) { NotImplemented("llForceMouselook"); } - public double llGetObjectMass(string id) { NotImplemented("llGetObjectMass"); return 0; } - public void llListReplaceList() { NotImplemented("llListReplaceList"); } + public void llListReplaceList() + { + NotImplemented("llListReplaceList"); + } public void llLoadURL(string avatar_id, string message, string url) { LLUUID avatarId = new LLUUID(avatar_id); - m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message, url); + m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message, + url); } - public void llParcelMediaCommandList(List commandList) { NotImplemented("llParcelMediaCommandList"); } - public void llParcelMediaQuery() { NotImplemented("llParcelMediaQuery"); } + public void llParcelMediaCommandList(List commandList) + { + NotImplemented("llParcelMediaCommandList"); + } + + public void llParcelMediaQuery() + { + NotImplemented("llParcelMediaQuery"); + } public int llModPow(int a, int b, int c) { @@ -1086,13 +2085,38 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler return Convert.ToInt32(tmp); } - public int llGetInventoryType(string name) { NotImplemented("llGetInventoryType"); return 0; } + public int llGetInventoryType(string name) + { + NotImplemented("llGetInventoryType"); + return 0; + } + + public void llSetPayPrice(int price, List quick_pay_buttons) + { + NotImplemented("llSetPayPrice"); + } + + public LSL_Types.Vector3 llGetCameraPos() + { + NotImplemented("llGetCameraPos"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Quaternion llGetCameraRot() + { + NotImplemented("llGetCameraRot"); + return new LSL_Types.Quaternion(); + } + + public void llSetPrimURL() + { + NotImplemented("llSetPrimURL"); + } - public void llSetPayPrice(int price, List quick_pay_buttons) { NotImplemented("llSetPayPrice"); } - public LSL_Types.Vector3 llGetCameraPos() { NotImplemented("llGetCameraPos"); return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llGetCameraRot() { NotImplemented("llGetCameraRot"); return new LSL_Types.Quaternion(); } - public void llSetPrimURL() { NotImplemented("llSetPrimURL"); } - public void llRefreshPrimURL() { NotImplemented("llRefreshPrimURL"); } + public void llRefreshPrimURL() + { + NotImplemented("llRefreshPrimURL"); + } public string llEscapeURL(string url) { @@ -1117,21 +2141,60 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler return "llUnescapeURL: " + ex.ToString(); } } - public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) { NotImplemented("llMapDestination"); } - public void llAddToLandBanList(string avatar, double hours) { NotImplemented("llAddToLandBanList"); } - public void llRemoveFromLandPassList(string avatar) { NotImplemented("llRemoveFromLandPassList"); } - public void llRemoveFromLandBanList(string avatar) { NotImplemented("llRemoveFromLandBanList"); } - public void llSetCameraParams(List rules) { NotImplemented("llSetCameraParams"); } - public void llClearCameraParams() { NotImplemented("llClearCameraParams"); } - public double llListStatistics(int operation, List src) { NotImplemented("llListStatistics"); return 0; } + + public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) + { + NotImplemented("llMapDestination"); + } + + public void llAddToLandBanList(string avatar, double hours) + { + NotImplemented("llAddToLandBanList"); + } + + public void llRemoveFromLandPassList(string avatar) + { + NotImplemented("llRemoveFromLandPassList"); + } + + public void llRemoveFromLandBanList(string avatar) + { + NotImplemented("llRemoveFromLandBanList"); + } + + public void llSetCameraParams(List rules) + { + NotImplemented("llSetCameraParams"); + } + + public void llClearCameraParams() + { + NotImplemented("llClearCameraParams"); + } + + public double llListStatistics(int operation, List src) + { + NotImplemented("llListStatistics"); + return 0; + } public int llGetUnixTime() { return Util.UnixTimeSinceEpoch(); } - public int llGetParcelFlags(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelFlags"); return 0; } - public int llGetRegionFlags() { NotImplemented("llGetRegionFlags"); return 0; } + public int llGetParcelFlags(LSL_Types.Vector3 pos) + { + NotImplemented("llGetParcelFlags"); + return 0; + } + + public int llGetRegionFlags() + { + NotImplemented("llGetRegionFlags"); + return 0; + } + public string llXorBase64StringsCorrect(string str1, string str2) { string ret = ""; @@ -1148,27 +2211,64 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler } return llStringToBase64(ret); } + public void llHTTPRequest(string url, List parameters, string body) { m_ScriptEngine.m_LSLLongCmdHandler.StartHttpRequest(m_localID, m_itemID, url, parameters, body); } - public void llResetLandBanList() { NotImplemented("llResetLandBanList"); } - public void llResetLandPassList() { NotImplemented("llResetLandPassList"); } - public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { NotImplemented("llGetParcelPrimCount"); return 0; } - public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelPrimOwners"); return new List(); } - public int llGetObjectPrimCount(string object_id) { NotImplemented("llGetObjectPrimCount"); return 0; } - public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) { NotImplemented("llGetParcelMaxPrims"); return 0; } - public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) { NotImplemented("llGetParcelDetails"); return new List(); } + + public void llResetLandBanList() + { + NotImplemented("llResetLandBanList"); + } + + public void llResetLandPassList() + { + NotImplemented("llResetLandPassList"); + } + + public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) + { + NotImplemented("llGetParcelPrimCount"); + return 0; + } + + public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) + { + NotImplemented("llGetParcelPrimOwners"); + return new List(); + } + + public int llGetObjectPrimCount(string object_id) + { + NotImplemented("llGetObjectPrimCount"); + return 0; + } + + public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) + { + NotImplemented("llGetParcelMaxPrims"); + return 0; + } + + public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) + { + NotImplemented("llGetParcelDetails"); + return new List(); + } // // OpenSim functions // - public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) + public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, + int timer) { if (dynamicID == "") { - IDynamicTextureManager textureManager = this.World.RequestModuleInterface(); - LLUUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, this.m_host.UUID, contentType, url, extraParams, timer); + IDynamicTextureManager textureManager = World.RequestModuleInterface(); + LLUUID createdTexture = + textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, + extraParams, timer); return createdTexture.ToStringHyphenated(); } else @@ -1184,6 +2284,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler if (throwErrorOnNotImplemented) throw new NotImplementedException("Command not implemented: " + Command); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs index 44ed123..1847e87 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventManager.cs @@ -27,11 +27,8 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; using OpenSim.Framework; -using OpenSim.Region.Environment.Scenes.Scripting; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { @@ -39,7 +36,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it. /// [Serializable] - class EventManager + internal class EventManager { private ScriptEngine myScriptEngine; //public IScriptHost TEMP_OBJECT_ID; @@ -55,7 +52,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine myScriptEngine.World.EventManager.OnObjectGrab += touch_start; myScriptEngine.World.EventManager.OnRezScript += OnRezScript; myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; - } public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) @@ -63,17 +59,20 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Add to queue for all scripts in ObjectID object //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start"); //Console.WriteLine("touch_start localID: " + localID); - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] { (int)1 }); + myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1}); } + public void OnRezScript(uint localID, LLUUID itemID, string script) { //myScriptEngine.myScriptManager.StartScript( // Path.Combine("ScriptEngines", "Default.lsl"), // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost() //); - Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length); + Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + + script.Length); myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script); } + public void OnRemoveScript(uint localID, LLUUID itemID) { //myScriptEngine.myScriptManager.StartScript( @@ -84,48 +83,138 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine myScriptEngine.m_ScriptManager.StopScript( localID, itemID - ); - + ); } // TODO: Replace placeholders below // These needs to be hooked up to OpenSim during init of this class // then queued in EventQueueManager. // When queued in EventQueueManager they need to be LSL compatible (name and params) - + //public void state_entry() { } // - public void state_exit() { } + public void state_exit() + { + } + //public void touch_start() { } - public void touch() { } - public void touch_end() { } - public void collision_start() { } - public void collision() { } - public void collision_end() { } - public void land_collision_start() { } - public void land_collision() { } - public void land_collision_end() { } - public void timer() { } - public void listen() { } - public void on_rez() { } - public void sensor() { } - public void no_sensor() { } - public void control() { } - public void money() { } - public void email() { } - public void at_target() { } - public void not_at_target() { } - public void at_rot_target() { } - public void not_at_rot_target() { } - public void run_time_permissions() { } - public void changed() { } - public void attach() { } - public void dataserver() { } - public void link_message() { } - public void moving_start() { } - public void moving_end() { } - public void object_rez() { } - public void remote_data() { } - public void http_response() { } + public void touch() + { + } + + public void touch_end() + { + } + + public void collision_start() + { + } + + public void collision() + { + } + + public void collision_end() + { + } + + public void land_collision_start() + { + } + + public void land_collision() + { + } + + public void land_collision_end() + { + } + + public void timer() + { + } + + public void listen() + { + } + + public void on_rez() + { + } + + public void sensor() + { + } + + public void no_sensor() + { + } + + public void control() + { + } + + public void money() + { + } + + public void email() + { + } + + public void at_target() + { + } + + public void not_at_target() + { + } + + public void at_rot_target() + { + } + + public void not_at_rot_target() + { + } + + public void run_time_permissions() + { + } + + public void changed() + { + } + + public void attach() + { + } + + public void dataserver() + { + } + + public void link_message() + { + } + + public void moving_start() + { + } + + public void moving_end() + { + } + + public void object_rez() + { + } + + public void remote_data() + { + } + public void http_response() + { + } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs index 8ee005a..31d090f 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/EventQueueManager.cs @@ -27,13 +27,12 @@ */ /* Original code: Tedd Hansen */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.Threading; -using System.Reflection; -using OpenSim.Region.Environment.Scenes.Scripting; using libsecondlife; using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL; +using OpenSim.Region.Environment.Scenes.Scripting; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { @@ -42,25 +41,30 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// Events are queued and executed in separate thread /// [Serializable] - class EventQueueManager + internal class EventQueueManager { /// /// List of threads processing event queue /// private List eventQueueThreads = new List(); + private object queueLock = new object(); // Mutex lock object + /// /// How many ms to sleep if queue is empty /// private int nothingToDoSleepms = 50; + /// /// How many threads to process queue with /// private int numberOfThreads = 2; + /// /// Queue containing events waiting to be executed /// private Queue eventQueue = new Queue(); + /// /// Queue item structure /// @@ -76,9 +80,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// List of localID locks for mutex processing of script events /// private List objectLocks = new List(); + private object tryLockLock = new object(); // Mutex lock object private ScriptEngine m_ScriptEngine; + public EventQueueManager(ScriptEngine _ScriptEngine) { m_ScriptEngine = _ScriptEngine; @@ -96,11 +102,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine EventQueueThread.Start(); } } + ~EventQueueManager() { - // Kill worker threads - foreach (Thread EventQueueThread in new System.Collections.ArrayList(eventQueueThreads)) + foreach (Thread EventQueueThread in new ArrayList(eventQueueThreads)) { if (EventQueueThread != null && EventQueueThread.IsAlive == true) { @@ -118,7 +124,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine eventQueueThreads.Clear(); // Todo: Clean up our queues eventQueue.Clear(); - } /// @@ -176,18 +181,21 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Execute function try { - m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.functionName, QIS.param); + m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, + QIS.functionName, QIS.param); } catch (Exception e) { // DISPLAY ERROR INWORLD string text = "Error executing script function \"" + QIS.functionName + "\":\r\n"; if (e.InnerException != null) - { // Send inner exception + { + // Send inner exception text += e.InnerException.Message.ToString(); } else - { // Send normal + { + // Send normal text += e.Message.ToString(); } try @@ -195,28 +203,33 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine if (text.Length > 1500) text = text.Substring(0, 1500); IScriptHost m_host = m_ScriptEngine.World.GetSceneObjectPart(QIS.localID); - //if (m_host != null) - //{ - m_ScriptEngine.World.SimChat(Helpers.StringToField(text), 1, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); - } catch { - //} - //else - //{ + //if (m_host != null) + //{ + m_ScriptEngine.World.SimChat(Helpers.StringToField(text), 1, 0, + m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + catch + { + //} + //else + //{ // T oconsole Console.WriteLine("Unable to send text in-world:\r\n" + text); } - } finally { ReleaseLock(QIS.localID); } } - } // Something in queue - } catch (ThreadAbortException tae) { + } + catch (ThreadAbortException tae) + { throw tae; - } catch (Exception e) { + } + catch (Exception e) + { Console.WriteLine("Exception in EventQueueThreadLoop: " + e.ToString()); } } // while @@ -283,15 +296,15 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine return; } - Dictionary.KeyCollection scriptKeys = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID); + Dictionary.KeyCollection scriptKeys = + m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID); - foreach ( LLUUID itemID in scriptKeys ) + foreach (LLUUID itemID in scriptKeys) { // Add to each script in that object // TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter? AddToScriptQueue(localID, itemID, FunctionName, param); } - } /// @@ -316,6 +329,5 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine eventQueue.Enqueue(QIS); } } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index 13979ba..303bddb 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs @@ -28,24 +28,23 @@ using System; using System.Collections.Generic; -using System.Text; using System.Threading; using libsecondlife; -using OpenSim.Region.ScriptEngine.Common; -using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { /// /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. /// - class LSLLongCmdHandler + internal class LSLLongCmdHandler { private Thread cmdHandlerThread; private int cmdHandlerThreadCycleSleepms = 100; private ScriptEngine m_ScriptEngine; + public LSLLongCmdHandler(ScriptEngine _ScriptEngine) { m_ScriptEngine = _ScriptEngine; @@ -56,8 +55,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine cmdHandlerThread.Priority = ThreadPriority.BelowNormal; cmdHandlerThread.IsBackground = true; cmdHandlerThread.Start(); - } + ~LSLLongCmdHandler() { // Shut down thread @@ -72,7 +71,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } } } - catch { } + catch + { + } } private void CmdHandlerThreadLoop() @@ -124,8 +125,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine public double interval; public DateTime next; } + private List Timers = new List(); private object TimerListLock = new object(); + public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) { Console.WriteLine("SetTimerEvent"); @@ -146,6 +149,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine Timers.Add(ts); } } + public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) { // Remove from timer @@ -163,6 +167,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine Timers = NewTimers; } } + public void CheckTimerEvents() { // Nothing to do here? @@ -171,7 +176,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine lock (TimerListLock) { - // Go through all timers foreach (TimerClass ts in Timers) { @@ -179,7 +183,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) { // Add it to queue - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", + new object[] {}); // set next interval @@ -188,6 +193,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine } } // lock } + #endregion #region HTTP REQUEST @@ -213,10 +219,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine { // TODO: SEND REQUEST!!! } + public void Stop() { // TODO: Cancel any ongoing request } + public bool CheckResponse() { // TODO: Check if we got a response yet, return true if so -- false if not @@ -227,11 +235,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine //response_status //response_metadata //response_body - } } + private List HttpRequests = new List(); private object HttpListLock = new object(); + public void StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) { Console.WriteLine("StartHttpRequest"); @@ -244,11 +253,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine htc.body = body; lock (HttpListLock) { - //ADD REQUEST HttpRequests.Add(htc); } } + public void StopHttpRequest(uint m_localID, LLUUID m_itemID) { // Remove from list @@ -272,6 +281,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine HttpRequests = NewHttpList; } } + public void CheckHttpRequests() { // Nothing to do here? @@ -282,68 +292,64 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine { foreach (HttpClass ts in HttpRequests) { - if (ts.CheckResponse() == true) { // Add it to event queue //key request_id, integer status, list metadata, string body - object[] resobj = new object[] { ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body }; - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", resobj); + object[] resobj = + new object[] + {ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body}; + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", + resobj); // Now stop it StopHttpRequest(ts.localID, ts.itemID); } } } // lock } + #endregion public void CheckXMLRPCRequests() { - IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface(); while (xmlrpc.hasRequests()) { RPCRequestInfo rInfo = xmlrpc.GetNextRequest(); - System.Console.WriteLine("PICKED REQUEST"); + Console.WriteLine("PICKED REQUEST"); //Deliver data to prim's remote_data handler - object[] resobj = new object[] { - 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), rInfo.GetStrVal() - }; + object[] resobj = new object[] + { + 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), + rInfo.GetStrVal() + }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj - ); - + ); } - } public void CheckListeners() { - IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface(); while (comms.HasMessages()) { ListenerInfo lInfo = comms.GetNextMessage(); - System.Console.WriteLine("PICKED LISTENER"); + Console.WriteLine("PICKED LISTENER"); //Deliver data to prim's listen handler - object[] resobj = new object[] { - lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() - }; + object[] resobj = new object[] + { + lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() + }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj - ); - + ); } - } - - - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs index e1e025c..a0ac023 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/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.Grid.ScriptEngine.DotNetEngine")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Grid.ScriptEngine.DotNetEngine")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Grid.ScriptEngine.DotNetEngine")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Grid.ScriptEngine.DotNetEngine")] +[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("2842257e-6fde-4460-9368-4cde57fa9cc4")] + +[assembly : Guid("2842257e-6fde-4460-9368-4cde57fa9cc4")] // Version information for an assembly consists of the following four values: // @@ -31,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs index 5ec77f3..6373d3c 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -27,14 +27,10 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; +using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Interfaces; -using libsecondlife; -using Nini.Config; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { @@ -42,17 +38,16 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// This is the root object for ScriptEngine /// [Serializable] - public class ScriptEngine :IRegionModule + public class ScriptEngine : IRegionModule { - - internal OpenSim.Region.Environment.Scenes.Scene World; - internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim - internal EventQueueManager m_EventQueueManager; // Executes events - internal ScriptManager m_ScriptManager; // Load, unload and execute scripts + internal Scene World; + internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim + internal EventQueueManager m_EventQueueManager; // Executes events + internal ScriptManager m_ScriptManager; // Load, unload and execute scripts internal AppDomainManager m_AppDomainManager; internal LSLLongCmdHandler m_LSLLongCmdHandler; - private OpenSim.Framework.Console.LogBase m_log; + private LogBase m_log; public ScriptEngine() { @@ -65,9 +60,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine get { return m_log; } } - public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger) + public void InitializeEngine(Scene Sceneworld, LogBase logger) { - World = Sceneworld; m_log = logger; @@ -84,10 +78,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Should we iterate the region for scripts that needs starting? // Or can we assume we are loaded before anything else so we can use proper events? - - } - + public void Shutdown() { // We are shutting down @@ -106,12 +98,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine public void Initialise(Scene scene, IConfigSource config) { - this.InitializeEngine(scene, MainLog.Instance); + InitializeEngine(scene, MainLog.Instance); } public void PostInitialise() { - } public void Close() @@ -130,4 +121,4 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs index 988230f..2149bf0 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -28,19 +28,14 @@ /* Original code: Tedd Hansen */ using System; using System.Collections.Generic; -using System.Text; -using System.Threading; +using System.IO; using System.Reflection; -using System.Runtime.Remoting; -using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; +using System.Threading; +using libsecondlife; using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler; using OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL; -using OpenSim.Region.ScriptEngine.Common; -using libsecondlife; - +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { @@ -53,16 +48,19 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine public class ScriptManager { #region Declares + private Thread scriptLoadUnloadThread; private int scriptLoadUnloadThread_IdleSleepms = 100; private Queue loadQueue = new Queue(); private Queue unloadQueue = new Queue(); + private struct LoadStruct { public uint localID; public LLUUID itemID; public string script; } + private struct UnloadStruct { public uint localID; @@ -72,17 +70,20 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Object> // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! - internal Dictionary> Scripts = new Dictionary>(); + internal Dictionary> Scripts = + new Dictionary>(); + public Scene World { - get - { - return m_scriptEngine.World; - } + get { return m_scriptEngine.World; } } -#endregion + + #endregion + #region Object init/shutdown + private ScriptEngine m_scriptEngine; + public ScriptManager(ScriptEngine scriptEngine) { m_scriptEngine = scriptEngine; @@ -92,9 +93,9 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine scriptLoadUnloadThread.IsBackground = true; scriptLoadUnloadThread.Priority = ThreadPriority.BelowNormal; scriptLoadUnloadThread.Start(); - } - ~ScriptManager () + + ~ScriptManager() { // Abort load/unload thread try @@ -112,8 +113,11 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine { } } + #endregion + #region Load / Unload scripts (Thread loop) + private void ScriptLoadUnloadThreadLoop() { try @@ -134,9 +138,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine UnloadStruct item = unloadQueue.Dequeue(); _StopScript(item.localID, item.itemID); } - - - } } catch (ThreadAbortException tae) @@ -145,21 +146,22 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine a = ""; // Expected } - } + #endregion + #region Helper functions + private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { - //Console.WriteLine("ScriptManager.CurrentDomain_AssemblyResolve: " + args.Name); return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null; - } - #endregion + #region Internal functions to keep track of script + internal Dictionary.KeyCollection GetScriptKeys(uint localID) { if (Scripts.ContainsKey(localID) == false) @@ -169,7 +171,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine Scripts.TryGetValue(localID, out Obj); return Obj.Keys; - } internal LSL_BaseClass GetScript(uint localID, LLUUID itemID) @@ -187,8 +188,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine Obj.TryGetValue(itemID, out Script); return Script; - } + internal void SetScript(uint localID, LLUUID itemID, LSL_BaseClass Script) { // Create object if it doesn't exist @@ -205,8 +206,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Add to object Obj.Add(itemID, Script); - } + internal void RemoveScript(uint localID, LLUUID itemID) { // Don't have that object? @@ -218,10 +219,12 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine Scripts.TryGetValue(localID, out Obj); if (Obj.ContainsKey(itemID) == true) Obj.Remove(itemID); - } + #endregion + #region Start/Stop/Reset script + /// /// Fetches, loads and hooks up a script to an objects events /// @@ -235,6 +238,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine ls.script = Script; loadQueue.Enqueue(ls); } + /// /// Disables and unloads a script /// @@ -247,6 +251,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine ls.itemID = itemID; unloadQueue.Enqueue(ls); } + public void ResetScript(uint localID, LLUUID itemID) { string script = GetScript(localID, itemID).SourceCode; @@ -267,12 +272,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine try { - - - - // Create a new instance of the compiler (currently we don't want reuse) - OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler(); + Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); // Compile (We assume LSL) ScriptSource = LSLCompiler.CompileFromLSLText(Script); //Console.WriteLine("Compilation of " + FileName + " done"); @@ -289,10 +290,10 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource); #if DEBUG - Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); + Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); #endif - CompiledScript.SourceCode = ScriptSource; + CompiledScript.SourceCode = ScriptSource; // Add it to our script memstruct SetScript(localID, itemID, CompiledScript); @@ -306,9 +307,7 @@ namespace OpenSim.Grid.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) { @@ -326,9 +325,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString()); } } - - - } private void _StopScript(uint localID, LLUUID itemID) @@ -359,19 +355,24 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Tell AppDomain that we have stopped script m_scriptEngine.m_AppDomainManager.StopScript(ad); } - catch(Exception e) + catch (Exception e) { - Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + ": " + e.ToString()); + Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + + ": " + e.ToString()); } } - private string ProcessYield(string FileName) + + private string ProcessYield(string FileName) { // TODO: Create a new assembly and copy old but insert Yield Code //return TempDotNetMicroThreadingCodeInjector.TestFix(FileName); return FileName; } + #endregion + #region Perform event execution in script + /// /// Execute a LL-event-function in Script /// @@ -381,7 +382,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// Arguments to pass to function internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args) { - // Execute a function in the script //m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName); LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID); @@ -390,28 +390,29 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine // Must be done in correct AppDomain, so leaving it up to the script itself Script.Exec.ExecuteEvent(FunctionName, args); - } + #endregion #region Script serialization/deserialization + public void GetSerializedScript(uint localID, LLUUID itemID) { // Serialize the script and return it // Should not be a problem - System.IO.FileStream fs = System.IO.File.Create("SERIALIZED_SCRIPT_" + itemID); + FileStream fs = File.Create("SERIALIZED_SCRIPT_" + itemID); BinaryFormatter b = new BinaryFormatter(); - b.Serialize(fs, GetScript(localID,itemID)); + b.Serialize(fs, GetScript(localID, itemID)); fs.Close(); - - } + public void PutSerializedScript(uint localID, LLUUID itemID) { // Deserialize the script and inject it into an AppDomain // How to inject into an AppDomain? } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs index 0498ef3..8a8c96d 100644 --- a/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs +++ b/OpenSim/Grid/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs @@ -27,12 +27,9 @@ */ using System; -using System.Collections.Generic; -using System.Text; -using Rail.Transformation; +using System.IO; using Rail.Reflect; -using Rail.Exceptions; -using Rail.MSIL; +using Rail.Transformation; namespace OpenSim.Grid.ScriptEngine.DotNetEngine { @@ -40,26 +37,26 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine /// Tedds Sandbox for RAIL/microtrheading. This class is only for testing purposes! /// Its offspring will be the actual implementation. /// - class TempDotNetMicroThreadingCodeInjector + internal class TempDotNetMicroThreadingCodeInjector { public static string TestFix(string FileName) { - string ret = System.IO.Path.GetFileNameWithoutExtension(FileName + "_fixed.dll"); + string ret = Path.GetFileNameWithoutExtension(FileName + "_fixed.dll"); Console.WriteLine("Loading: \"" + FileName + "\""); RAssemblyDef rAssembly = RAssemblyDef.LoadAssembly(FileName); - + //Get the type of the method to copy from assembly Teste2.exe to assembly Teste.exe - RTypeDef type = (RTypeDef)rAssembly.RModuleDef.GetType("SecondLife.Script"); + RTypeDef type = (RTypeDef) rAssembly.RModuleDef.GetType("SecondLife.Script"); //Get the methods in the type RMethod[] m = type.GetMethods(); //Create a MethodPrologueAdder visitor object with the method to add //and with the flag that enables local variable creation set to true - MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef)m[0], true); - + MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef) m[0], true); + //Apply the changes to the assembly rAssembly.Accept(mpa); @@ -67,7 +64,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine rAssembly.SaveAssembly(ret); return ret; - } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/Application.cs b/OpenSim/Grid/ScriptServer/Application.cs index 7fc9a53..e049fd7 100644 --- a/OpenSim/Grid/ScriptServer/Application.cs +++ b/OpenSim/Grid/ScriptServer/Application.cs @@ -26,25 +26,23 @@ * */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Grid.ScriptServer { - class OpenScript_Main + internal class OpenScript_Main { - public static ScriptServerMain SE; - - static void Main(string[] args) + + private static void Main(string[] args) { // Application is starting SE = new ScriptServerMain(); - System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + AppDomain.CurrentDomain.UnhandledException += + new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); } - static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(""); Console.WriteLine("APPLICATION EXCEPTION DETECTED"); @@ -53,6 +51,5 @@ namespace OpenSim.Grid.ScriptServer Console.WriteLine("Exception:"); Console.WriteLine(e.ExceptionObject.ToString()); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs index 63f40d4..2886ec7 100644 --- a/OpenSim/Grid/ScriptServer/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/ScriptServer/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.Grid.ScriptServer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Grid.ScriptServer")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Grid.ScriptServer")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Grid.ScriptServer")] +[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("b6861b87-5203-4040-b756-fd4774932f82")] + +[assembly : Guid("b6861b87-5203-4040-b756-fd4774932f82")] // Version information for an assembly consists of the following four values: // @@ -29,5 +31,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs index b18bda2..cb6734f 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionBase.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Grid.ScriptServer { public abstract class RegionBase @@ -73,42 +69,176 @@ namespace OpenSim.Grid.ScriptServer public event DefaultDelegate onobject_rez; public event DefaultDelegate onremote_data; public event DefaultDelegate onhttp_response; - - - public void ScriptRez() { onScriptRez(); } - public void state_entry() { onstate_entry(); } - public void state_exit() { onstate_exit(); } - public void touch_start() { ontouch_start(); } - public void touch() { ontouch(); } - public void touch_end() { ontouch_end(); } - public void collision_start() { oncollision_start(); } - public void collision() { oncollision(); } - public void collision_end() { oncollision_end(); } - public void land_collision_start() { onland_collision_start(); } - public void land_collision() { onland_collision(); } - public void land_collision_end() { onland_collision_end(); } - public void timer() { ontimer(); } - public void listen() { onlisten(); } - public void on_rez() { onon_rez(); } - public void sensor() { onsensor(); } - public void no_sensor() { onno_sensor(); } - public void control() { oncontrol(); } - public void money() { onmoney(); } - public void email() { onemail(); } - public void at_target() { onat_target(); } - public void not_at_target() { onnot_at_target(); } - public void at_rot_target() { onat_rot_target(); } - public void not_at_rot_target() { onnot_at_rot_target(); } - public void run_time_permissions() { onrun_time_permissions(); } - public void changed() { onchanged(); } - public void attach() { onattach(); } - public void dataserver() { ondataserver(); } - public void link_message() { onlink_message(); } - public void moving_start() { onmoving_start(); } - public void moving_end() { onmoving_end(); } - public void object_rez() { onobject_rez(); } - public void remote_data() { onremote_data(); } - public void http_response() { onhttp_response(); } - + + + public void ScriptRez() + { + onScriptRez(); + } + + public void state_entry() + { + onstate_entry(); + } + + public void state_exit() + { + onstate_exit(); + } + + public void touch_start() + { + ontouch_start(); + } + + public void touch() + { + ontouch(); + } + + public void touch_end() + { + ontouch_end(); + } + + public void collision_start() + { + oncollision_start(); + } + + public void collision() + { + oncollision(); + } + + public void collision_end() + { + oncollision_end(); + } + + public void land_collision_start() + { + onland_collision_start(); + } + + public void land_collision() + { + onland_collision(); + } + + public void land_collision_end() + { + onland_collision_end(); + } + + public void timer() + { + ontimer(); + } + + public void listen() + { + onlisten(); + } + + public void on_rez() + { + onon_rez(); + } + + public void sensor() + { + onsensor(); + } + + public void no_sensor() + { + onno_sensor(); + } + + public void control() + { + oncontrol(); + } + + public void money() + { + onmoney(); + } + + public void email() + { + onemail(); + } + + public void at_target() + { + onat_target(); + } + + public void not_at_target() + { + onnot_at_target(); + } + + public void at_rot_target() + { + onat_rot_target(); + } + + public void not_at_rot_target() + { + onnot_at_rot_target(); + } + + public void run_time_permissions() + { + onrun_time_permissions(); + } + + public void changed() + { + onchanged(); + } + + public void attach() + { + onattach(); + } + + public void dataserver() + { + ondataserver(); + } + + public void link_message() + { + onlink_message(); + } + + public void moving_start() + { + onmoving_start(); + } + + public void moving_end() + { + onmoving_end(); + } + + public void object_rez() + { + onobject_rez(); + } + + public void remote_data() + { + onremote_data(); + } + + public void http_response() + { + onhttp_response(); + } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs index fa13807..819a037 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/Region/RegionConnectionManager.cs @@ -26,19 +26,17 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using OpenSim.Framework.Console; namespace OpenSim.Grid.ScriptServer { // Maintains connection and communication to a region - public class RegionConnectionManager: RegionBase + public class RegionConnectionManager : RegionBase { - private LogBase m_log; + private LogBase m_log; private ScriptServerMain m_ScriptServerMain; private object m_Connection; + public RegionConnectionManager(ScriptServerMain scm, LogBase logger, object Connection) { m_ScriptServerMain = scm; @@ -56,8 +54,6 @@ namespace OpenSim.Grid.ScriptServer // EVENT? DELIVER EVENT DIRECTLY TO SCRIPTENGINE touch_start(); - } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs index ac56fbe..45bf88d 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/RegionCommManager.cs @@ -25,9 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; using System.Collections.Generic; -using System.Text; using System.Threading; using OpenSim.Framework.Console; @@ -42,11 +40,13 @@ namespace OpenSim.Grid.ScriptServer private LogBase m_log; private ScriptServerMain m_ScriptServerMain; + public RegionCommManager(ScriptServerMain scm, LogBase logger) { m_ScriptServerMain = scm; m_log = logger; } + ~RegionCommManager() { Stop(); @@ -64,6 +64,7 @@ namespace OpenSim.Grid.ScriptServer listenThread.IsBackground = true; listenThread.Start(); } + /// /// Stops listening for region requests /// @@ -78,7 +79,9 @@ namespace OpenSim.Grid.ScriptServer listenThread.Abort(); listenThread.Join(1000); // Wait 1 second for thread to shut down } - catch { } + catch + { + } listenThread = null; } } @@ -97,6 +100,5 @@ namespace OpenSim.Grid.ScriptServer // TODO: FAKING A CONNECTION Regions.Add(new RegionConnectionManager(m_ScriptServerMain, m_log, null)); } - } -} +} \ 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 a259b1b..3dbd42d 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEngineManager/ScriptEngineLoader.cs @@ -121,5 +121,4 @@ namespace OpenSim.Grid.ScriptServer return ret; } } -} - +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs index 4ec2b35..7b49127 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServer/ScriptEnginesManager.cs @@ -26,9 +26,7 @@ * */ -using System; using System.Collections.Generic; -using System.Text; using OpenSim.Framework.Console; namespace OpenSim.Grid.ScriptServer @@ -46,10 +44,11 @@ namespace OpenSim.Grid.ScriptServer m_ScriptServerMain = scm; m_log = logger; ScriptEngineLoader = new ScriptEngineLoader(m_log); - + // Temp - we should not load during initialize... Loading should be done later. LoadEngine("DotNetScriptEngine"); } + ~ScriptEngineManager() { } @@ -63,7 +62,5 @@ namespace OpenSim.Grid.ScriptServer scriptEngines.Add(sei); } } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs index 82035ac..1749376 100644 --- a/OpenSim/Grid/ScriptServer/ScriptServerMain.cs +++ b/OpenSim/Grid/ScriptServer/ScriptServerMain.cs @@ -26,20 +26,17 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using System.IO; -using OpenSim.Framework.Console; using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Grid.ScriptServer { public class ScriptServerMain : conscmd_callback { private readonly string m_logFilename = ("region-console.log"); - internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region - internal ScriptEngineManager ScriptEngines; // Loads scriptengines + internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region + internal ScriptEngineManager ScriptEngines; // Loads scriptengines private LogBase m_log; public ScriptServerMain() @@ -48,7 +45,6 @@ namespace OpenSim.Grid.ScriptServer RegionScriptDaemon = new RegionCommManager(this, m_log); ScriptEngines = new ScriptEngineManager(this, m_log); - } ~ScriptServerMain() @@ -68,9 +64,9 @@ namespace OpenSim.Grid.ScriptServer public void RunCmd(string command, string[] cmdparams) { } + public void Show(string ShowWhat) { } - } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 492f67f..779a72b 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -27,28 +27,23 @@ */ using System; -using System.Collections.Generic; using System.IO; -using System.Reflection; -using libsecondlife; +using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Framework; namespace OpenSim.Grid.UserServer { /// /// - public class OpenUser_Main : conscmd_callback + public class OpenUser_Main : conscmd_callback { private UserConfig Cfg; public UserManager m_userManager; public UserLoginService m_loginService; - LogBase m_console; + private LogBase m_console; [STAThread] public static void Main(string[] args) @@ -67,7 +62,8 @@ namespace OpenSim.Grid.UserServer { Directory.CreateDirectory(Util.logDir()); } - m_console = new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true); + m_console = + new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true); MainLog.Instance = m_console; } @@ -83,7 +79,7 @@ namespace OpenSim.Grid.UserServer public void Startup() { - this.Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); + Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); MainLog.Instance.Verbose("Main.cs:Startup() - Establishing data connection"); m_userManager = new UserManager(); @@ -93,15 +89,16 @@ namespace OpenSim.Grid.UserServer m_loginService = new UserLoginService(m_userManager, Cfg, Cfg.DefaultStartupMsg); MainLog.Instance.Verbose("Main.cs:Startup() - Starting HTTP process"); - BaseHttpServer httpServer = new BaseHttpServer((int)Cfg.HttpPort); + BaseHttpServer httpServer = new BaseHttpServer((int) Cfg.HttpPort); httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); - httpServer.AddStreamHandler( new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod )); - + httpServer.AddStreamHandler( + new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); + httpServer.Start(); m_console.Status("SERVER", "Userserver 0.4 - Startup complete"); } @@ -126,7 +123,7 @@ namespace OpenSim.Grid.UserServer tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); - m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); + m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); break; } } @@ -178,4 +175,4 @@ namespace OpenSim.Grid.UserServer { } } -} +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs index 877f02f..079e05e 100644 --- a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs +++ b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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("OGS-UserServer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OGS-UserServer")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OGS-UserServer")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OGS-UserServer")] +[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("e266513a-090b-4d38-80f6-8599eef68c8c")] + +[assembly : Guid("e266513a-090b-4d38-80f6-8599eef68c8c")] // Version information for an assembly consists of the following four values: // @@ -27,5 +31,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 1523f81..bbef4b2 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -30,12 +30,10 @@ using System; using System.Collections; using System.Net; using Nwc.XmlRpc; -using OpenSim.Framework.Data; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework; -using OpenSim.Framework; using OpenSim.Framework; using OpenSim.Framework.Console; +using OpenSim.Framework.Data; +using OpenSim.Framework.UserManagement; namespace OpenSim.Grid.UserServer { @@ -58,18 +56,24 @@ namespace OpenSim.Grid.UserServer { // Load information from the gridserver RegionProfileData SimInfo = new RegionProfileData(); - SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); + SimInfo = + SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, + m_config.GridSendKey, m_config.GridRecvKey); // Customise the response // Home Location - 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() + "]}"; + 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("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY); + MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + + SimInfo.regionLocY); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); - response.SimPort = (Int32)SimInfo.serverPort; + response.SimPort = (Int32) SimInfo.serverPort; response.RegionX = SimInfo.regionLocX; response.RegionY = SimInfo.regionLocY; @@ -87,7 +91,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(); @@ -107,21 +111,20 @@ namespace OpenSim.Grid.UserServer XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); } - catch( WebException e ) + catch (WebException e) { - switch( e.Status ) + switch (e.Status) { case WebExceptionStatus.Timeout: //TODO: Send him to nearby or default region instead - MainLog.Instance.Verbose("Unable to connect to " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); + MainLog.Instance.Verbose("Unable to connect to " + SimInfo.regionName + " (" + SimInfo.serverURI + + ")"); break; - + default: throw; } } } } -} - - +} \ No newline at end of file diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 2b2bf72..96cdfb3 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -27,12 +27,10 @@ */ using System; using System.Collections; -using System.Net; +using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.UserManagement; -using OpenSim.Framework; -using libsecondlife; namespace OpenSim.Grid.UserServer { @@ -118,11 +116,11 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; UserProfileData userProfile; if (requestData.Contains("avatar_name")) { - userProfile = GetUserProfile((string)requestData["avatar_name"]); + userProfile = GetUserProfile((string) requestData["avatar_name"]); if (userProfile == null) { return CreateUnknownUserErrorResponse(); @@ -139,12 +137,12 @@ namespace OpenSim.Grid.UserServer public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; UserProfileData userProfile; - System.Console.WriteLine("METHOD BY UUID CALLED"); + Console.WriteLine("METHOD BY UUID CALLED"); if (requestData.Contains("avatar_uuid")) { - userProfile = GetUserProfile((LLUUID)(string)requestData["avatar_uuid"]); + userProfile = GetUserProfile((LLUUID) (string) requestData["avatar_uuid"]); if (userProfile == null) { return CreateUnknownUserErrorResponse(); @@ -158,6 +156,7 @@ namespace OpenSim.Grid.UserServer return ProfileToXmlRPCResponse(userProfile); } + #endregion public override UserProfileData SetupMasterUser(string firstName, string lastName) @@ -170,4 +169,4 @@ namespace OpenSim.Grid.UserServer 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 0288f63..bb26ce3 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -26,27 +26,24 @@ * */ using System; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; using Nini.Config; -using System.Threading; using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim { public class Application - { + { //could move our main function into OpenSimMain and kill this class [STAThread] public static void Main(string[] args) { - Console.WriteLine("OpenSim " + VersionInfo.Version + "\n"); - + Console.Write("Performing compatibility checks... "); string supported = ""; - if (OpenSim.Framework.Util.IsEnvironmentSupported(ref supported)) + if (Util.IsEnvironmentSupported(ref supported)) { Console.WriteLine(" Environment is compatible.\n"); } @@ -54,10 +51,10 @@ namespace OpenSim { Console.WriteLine(" Environment is unsupported (" + supported + ")\n"); } - + Console.WriteLine("Starting...\n"); - Culture.SetCurrentCulture(); + Culture.SetCurrentCulture(); ArgvConfigSource configSource = new ArgvConfigSource(args); @@ -80,4 +77,4 @@ namespace OpenSim } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/OpenSimController.cs b/OpenSim/Region/Application/OpenSimController.cs index da93b54..1fa4b04 100644 --- a/OpenSim/Region/Application/OpenSimController.cs +++ b/OpenSim/Region/Application/OpenSimController.cs @@ -1,28 +1,15 @@ using System; -using System.Collections.Generic; using System.Collections; -using System.IO; -using System.Text; -using Nini.Config; -using OpenSim.Framework.Communications.Cache; +using System.Net; +using System.Timers; +using Nwc.XmlRpc; +using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Framework; -using OpenSim.Region.ClientStack; -using OpenSim.Region.Communications.Local; -using OpenSim.Region.Communications.OGS1; -using OpenSim.Region.Environment; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Physics.Manager; -using System.Globalization; -using Nwc.XmlRpc; -using RegionInfo = OpenSim.Framework.RegionInfo; namespace OpenSim { - class OpenSimController + internal class OpenSimController { private OpenSimMain m_app; private BaseHttpServer m_httpServer; @@ -44,22 +31,23 @@ namespace OpenSim { MainLog.Instance.Verbose("CONTROLLER", "Recieved Shutdown Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; - if ((string)requestData["shutdown"] == "delayed") + if ((string) requestData["shutdown"] == "delayed") { - int timeout = Convert.ToInt32((string)requestData["milliseconds"]); + int timeout = Convert.ToInt32((string) requestData["milliseconds"]); Hashtable responseData = new Hashtable(); responseData["accepted"] = "true"; response.Value = responseData; - m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int)(timeout / 1000)).ToString() + " second(s). Please save what you are doing and log out."); + 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 - System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing + Timer shutdownTimer = new Timer(timeout); // Wait before firing shutdownTimer.AutoReset = false; - shutdownTimer.Elapsed += new System.Timers.ElapsedEventHandler(shutdownTimer_Elapsed); + shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); return response; } @@ -72,15 +60,15 @@ namespace OpenSim m_app.SceneManager.SendGeneralMessage("Region is going down now."); // Perform shutdown - System.Timers.Timer shutdownTimer = new System.Timers.Timer(2000); // Wait 2 seconds before firing + Timer shutdownTimer = new Timer(2000); // Wait 2 seconds before firing shutdownTimer.AutoReset = false; - shutdownTimer.Elapsed += new System.Timers.ElapsedEventHandler(shutdownTimer_Elapsed); + shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); return response; } } - void shutdownTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + private void shutdownTimer_Elapsed(object sender, ElapsedEventArgs e) { m_app.Shutdown(); } @@ -89,28 +77,28 @@ namespace OpenSim { MainLog.Instance.Verbose("CONTROLLER", "Recieved Create Region Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; RegionInfo newRegionData = new RegionInfo(); try { - newRegionData.RegionID = (string)requestData["region_id"]; - newRegionData.RegionName = (string)requestData["region_name"]; - newRegionData.RegionLocX = Convert.ToUInt32((string)requestData["region_x"]); - newRegionData.RegionLocY = Convert.ToUInt32((string)requestData["region_y"]); + newRegionData.RegionID = (string) requestData["region_id"]; + newRegionData.RegionName = (string) requestData["region_name"]; + newRegionData.RegionLocX = Convert.ToUInt32((string) requestData["region_x"]); + newRegionData.RegionLocY = Convert.ToUInt32((string) requestData["region_y"]); // Security risk - newRegionData.DataStore = (string)requestData["datastore"]; + newRegionData.DataStore = (string) requestData["datastore"]; - newRegionData.InternalEndPoint = new System.Net.IPEndPoint( - System.Net.IPAddress.Parse((string)requestData["listen_ip"]), 0); + newRegionData.InternalEndPoint = new IPEndPoint( + IPAddress.Parse((string) requestData["listen_ip"]), 0); - newRegionData.InternalEndPoint.Port = Convert.ToInt32((string)requestData["listen_port"]); - newRegionData.ExternalHostName = (string)requestData["external_address"]; + newRegionData.InternalEndPoint.Port = Convert.ToInt32((string) 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); @@ -129,4 +117,4 @@ namespace OpenSim return response; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index b938227..7245482 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -31,21 +31,17 @@ using System.Collections.Generic; using System.IO; using System.Text; using Nini.Config; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Framework; using OpenSim.Region.ClientStack; using OpenSim.Region.Communications.Local; using OpenSim.Region.Communications.OGS1; using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; -using OpenSim.Framework; -using System.Globalization; -using RegionInfo = OpenSim.Framework.RegionInfo; namespace OpenSim { @@ -114,7 +110,6 @@ namespace OpenSim } else { - // no default config files, so set default values, and save it SetDefaultConfig(); @@ -125,7 +120,6 @@ namespace OpenSim } ReadConfigSettings(); - } protected void SetDefaultConfig() @@ -148,7 +142,6 @@ namespace OpenSim config.Set("script_engine", "DotNetEngine"); config.Set("asset_database", "sqlite"); - } if (m_config.Configs["StandAlone"] == null) @@ -217,7 +210,8 @@ namespace OpenSim standaloneConfig.GetString("inventory_plugin", "OpenSim.Framework.Data.SQLite.dll"); m_standaloneUserPlugin = standaloneConfig.GetString("userDatabase_plugin", "OpenSim.Framework.Data.DB4o.dll"); - m_standaloneAssetPlugin = standaloneConfig.GetString("asset_plugin", "OpenSim.Framework.Data.SQLite.dll"); + m_standaloneAssetPlugin = + standaloneConfig.GetString("asset_plugin", "OpenSim.Framework.Data.SQLite.dll"); m_dumpAssetsToFile = standaloneConfig.GetBoolean("dump_assets_to_file", false); } @@ -230,7 +224,6 @@ namespace OpenSim /// public override void StartUp() { - if (!Directory.Exists(Util.logDir())) { Directory.CreateDirectory(Util.logDir()); @@ -248,22 +241,28 @@ namespace OpenSim LocalInventoryService inventoryService = new LocalInventoryService(); inventoryService.AddPlugin(m_standaloneInventoryPlugin); - LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService); + LocalUserServices userService = + new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, + m_networkServersInfo.DefaultHomeLocY, inventoryService); userService.AddPlugin(m_standaloneUserPlugin); LocalBackEndServices backendService = new LocalBackEndServices(); - CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, inventoryService, backendService, backendService, m_dumpAssetsToFile); + CommunicationsLocal localComms = + new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, + inventoryService, backendService, backendService, m_dumpAssetsToFile); m_commsManager = localComms; - m_loginService = new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo, m_standaloneAuthenticate); + m_loginService = + new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo, + m_standaloneAuthenticate); m_loginService.OnLoginToRegion += backendService.AddNewSession; m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); if (m_standaloneAuthenticate) { - this.CreateAccount = localComms.doCreate; + CreateAccount = localComms.doCreate; } } else @@ -308,7 +307,7 @@ namespace OpenSim // Start UDP servers for (int i = 0; i < m_udpServers.Count; i++) { - this.m_udpServers[i].ServerListener(); + m_udpServers[i].ServerListener(); } //Run Startup Commands @@ -321,7 +320,8 @@ namespace OpenSim MainLog.Instance.Verbose("STARTUP", "No startup command script specified. Moving on..."); } - MainLog.Instance.Status("STARTUP", "Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)"); + MainLog.Instance.Status("STARTUP", + "Startup complete, serving " + m_udpServers.Count.ToString() + " region(s)"); } public UDPServer CreateRegion(RegionInfo regionInfo) @@ -365,9 +365,12 @@ namespace OpenSim return new StorageManager(m_storageDLL, regionInfo.DataStore, regionInfo.RegionName); } - protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) + protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, + AgentCircuitManager circuitManager) { - return new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, m_moduleLoader, m_dumpAssetsToFile); + return + new Scene(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, + m_moduleLoader, m_dumpAssetsToFile); } protected override void Initialize() @@ -436,7 +439,6 @@ namespace OpenSim protected void ConnectToRemoteGridServer() { - } #endregion @@ -464,6 +466,7 @@ namespace OpenSim } #region Console Commands + /// /// /// @@ -649,11 +652,10 @@ namespace OpenSim case "change-region": if (cmdparams.Length > 0) { - string regionName = this.CombineParams(cmdparams, 0); + string regionName = CombineParams(cmdparams, 0); if (m_sceneManager.TrySetCurrentScene(regionName)) { - } else { @@ -663,11 +665,13 @@ namespace OpenSim if (m_sceneManager.CurrentScene == null) { - MainLog.Instance.Verbose("Currently at Root level. To change region please use 'change-region '"); + MainLog.Instance.Verbose( + "Currently at Root level. To change region please use 'change-region '"); } else { - MainLog.Instance.Verbose("Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + ". To change region please use 'change-region '"); + MainLog.Instance.Verbose("Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + + ". To change region please use 'change-region '"); } break; @@ -676,7 +680,6 @@ namespace OpenSim m_log.Error("Unknown command"); break; } - } public void Debug(string[] args) @@ -695,8 +698,7 @@ namespace OpenSim { m_log.Error("packet debug should be 0..2"); } - System.Console.WriteLine("New packet debug: " + newDebug.ToString()); - + Console.WriteLine("New packet debug: " + newDebug.ToString()); } break; @@ -704,7 +706,6 @@ namespace OpenSim m_log.Error("Unknown debug"); break; } - } /// @@ -720,7 +721,9 @@ namespace OpenSim m_log.Error("That is " + (DateTime.Now - m_startuptime).ToString()); break; case "users": - m_log.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World")); + m_log.Error( + String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", + "Agent ID", "Session ID", "Circuit", "IP", "World")); foreach (ScenePresence presence in m_sceneManager.GetCurrentSceneAvatars()) { @@ -750,7 +753,7 @@ namespace OpenSim break; case "modules": m_log.Error("The currently loaded shared modules are:"); - foreach (OpenSim.Region.Environment.Interfaces.IRegionModule module in m_moduleLoader.GetLoadedSharedModules ) + foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) { m_log.Error("Shared Module: " + module.Name); } @@ -768,8 +771,7 @@ namespace OpenSim result = result.TrimEnd(' '); return result; } + #endregion } - - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/VersionInfo.cs b/OpenSim/Region/Application/VersionInfo.cs index f045164..7840206 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 3960c19..4b44ead 100644 --- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs +++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs @@ -29,12 +29,10 @@ using System.Net.Sockets; namespace OpenSim.Region.ClientStack { - public interface ClientStackNetworkHandler { - void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode);// EndPoint packetSender); + void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode); // EndPoint packetSender); void RemoveClientCircuit(uint circuitcode); void RegisterPacketServer(PacketServer server); } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 24962f8..7dcf1e8 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -32,10 +32,8 @@ using System.Text; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Region.ClientStack { @@ -116,26 +114,18 @@ namespace OpenSim.Region.ClientStack /// public LLVector3 StartPos { - get - { - return startpos; - } - set - { - startpos = value; - } + get { return startpos; } + set { startpos = value; } } /// /// /// private LLUUID m_agentId; + public LLUUID AgentId { - get - { - return m_agentId; - } + get { return m_agentId; } } /// @@ -143,11 +133,7 @@ namespace OpenSim.Region.ClientStack /// public string FirstName { - get - { - return this.firstName; - } - + get { return firstName; } } /// @@ -155,10 +141,7 @@ namespace OpenSim.Region.ClientStack /// public string LastName { - get - { - return this.lastName; - } + get { return lastName; } } #region Scene/Avatar to Client @@ -182,11 +165,11 @@ namespace OpenSim.Region.ClientStack handshake.RegionInfo.TerrainStartHeight01 = regionInfo.EstateSettings.terrainStartHeight1; handshake.RegionInfo.TerrainStartHeight10 = regionInfo.EstateSettings.terrainStartHeight2; handshake.RegionInfo.TerrainStartHeight11 = regionInfo.EstateSettings.terrainStartHeight3; - handshake.RegionInfo.SimAccess = (byte)regionInfo.EstateSettings.simAccess; + handshake.RegionInfo.SimAccess = (byte) regionInfo.EstateSettings.simAccess; handshake.RegionInfo.WaterHeight = regionInfo.EstateSettings.waterHeight; - handshake.RegionInfo.RegionFlags = (uint)regionInfo.EstateSettings.regionFlags; + handshake.RegionInfo.RegionFlags = (uint) regionInfo.EstateSettings.regionFlags; handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0"); handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; @@ -200,7 +183,7 @@ namespace OpenSim.Region.ClientStack handshake.RegionInfo.TerrainDetail3 = regionInfo.EstateSettings.terrainDetail3; handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? - this.OutPacket(handshake); + OutPacket(handshake); } /// @@ -210,14 +193,14 @@ namespace OpenSim.Region.ClientStack public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); - mov.AgentData.SessionID = this.m_sessionId; - mov.AgentData.AgentID = this.AgentId; + mov.AgentData.SessionID = m_sessionId; + mov.AgentData.AgentID = AgentId; mov.Data.RegionHandle = regInfo.RegionHandle; mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) { - mov.Data.Position = this.startpos; + mov.Data.Position = startpos; } else { @@ -255,7 +238,7 @@ namespace OpenSim.Region.ClientStack reply.ChatData.OwnerID = fromAgentID; reply.ChatData.SourceID = fromAgentID; - this.OutPacket(reply); + OutPacket(reply); } /// @@ -264,27 +247,27 @@ namespace OpenSim.Region.ClientStack /// TODO /// /// - public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) + public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, + LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) { - - Encoding enc = Encoding.ASCII; - ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); - msg.AgentData.AgentID = fromAgent; - msg.AgentData.SessionID = fromAgentSession; - msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); - msg.MessageBlock.Dialog = dialog; - msg.MessageBlock.FromGroup = false; - msg.MessageBlock.ID = imSessionID; - msg.MessageBlock.Offline = 0; - msg.MessageBlock.ParentEstateID = 0; - msg.MessageBlock.Position = new LLVector3(); - msg.MessageBlock.RegionID = LLUUID.Random(); - msg.MessageBlock.Timestamp = timeStamp; - msg.MessageBlock.ToAgentID = toAgent; - msg.MessageBlock.Message = enc.GetBytes(message + "\0"); - msg.MessageBlock.BinaryBucket = new byte[0]; - - this.OutPacket(msg); + Encoding enc = Encoding.ASCII; + ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); + msg.AgentData.AgentID = fromAgent; + msg.AgentData.SessionID = fromAgentSession; + msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); + msg.MessageBlock.Dialog = dialog; + msg.MessageBlock.FromGroup = false; + msg.MessageBlock.ID = imSessionID; + msg.MessageBlock.Offline = 0; + msg.MessageBlock.ParentEstateID = 0; + msg.MessageBlock.Position = new LLVector3(); + msg.MessageBlock.RegionID = LLUUID.Random(); + msg.MessageBlock.Timestamp = timeStamp; + msg.MessageBlock.ToAgentID = toAgent; + msg.MessageBlock.Message = enc.GetBytes(message + "\0"); + msg.MessageBlock.BinaryBucket = new byte[0]; + + OutPacket(msg); } /// @@ -301,10 +284,10 @@ namespace OpenSim.Region.ClientStack { for (int x = 0; x < 16; x = x + 4) { - patches[0] = x + 0 + y * 16; - patches[1] = x + 1 + y * 16; - patches[2] = x + 2 + y * 16; - patches[3] = x + 3 + y * 16; + patches[0] = x + 0 + y*16; + patches[1] = x + 1 + y*16; + patches[2] = x + 2 + y*16; + patches[3] = x + 3 + y*16; Packet layerpack = TerrainManager.CreateLandPacket(map, patches); OutPacket(layerpack); @@ -313,7 +296,8 @@ namespace OpenSim.Region.ClientStack } catch (Exception e) { - MainLog.Instance.Warn("client", "ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); + MainLog.Instance.Warn("client", + "ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); } } @@ -332,14 +316,15 @@ namespace OpenSim.Region.ClientStack patchx = px; patchy = py; - patches[0] = patchx + 0 + patchy * 16; + patches[0] = patchx + 0 + patchy*16; Packet layerpack = TerrainManager.CreateLandPacket(map, patches); OutPacket(layerpack); } catch (Exception e) { - MainLog.Instance.Warn("client", "ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); + MainLog.Instance.Warn("client", + "ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); } } @@ -352,17 +337,17 @@ namespace OpenSim.Region.ClientStack public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) { IPAddress neighbourIP = neighbourEndPoint.Address; - ushort neighbourPort = (ushort)neighbourEndPoint.Port; + ushort neighbourPort = (ushort) neighbourEndPoint.Port; EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); enablesimpacket.SimulatorInfo.Handle = neighbourHandle; byte[] byteIP = neighbourIP.GetAddressBytes(); - enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; - enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; + enablesimpacket.SimulatorInfo.IP = (uint) byteIP[3] << 24; + enablesimpacket.SimulatorInfo.IP += (uint) byteIP[2] << 16; + enablesimpacket.SimulatorInfo.IP += (uint) byteIP[1] << 8; + enablesimpacket.SimulatorInfo.IP += (uint) byteIP[0]; enablesimpacket.SimulatorInfo.Port = neighbourPort; OutPacket(enablesimpacket); } @@ -374,46 +359,48 @@ namespace OpenSim.Region.ClientStack public AgentCircuitData RequestClientInfo() { AgentCircuitData agentData = new AgentCircuitData(); - agentData.AgentID = this.AgentId; - agentData.SessionID = this.m_sessionId; - agentData.SecureSessionID = this.SecureSessionID; - agentData.circuitcode = this.m_circuitCode; + agentData.AgentID = AgentId; + agentData.SessionID = m_sessionId; + agentData.SecureSessionID = SecureSessionID; + agentData.circuitcode = m_circuitCode; agentData.child = false; - agentData.firstname = this.firstName; - agentData.lastname = this.lastName; + agentData.firstname = firstName; + agentData.lastname = lastName; agentData.CapsPath = ""; return agentData; } - public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint, string capsURL) + public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint, + string capsURL) { - LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); + LLVector3 look = new LLVector3(lookAt.X*10, lookAt.Y*10, lookAt.Z*10); CrossedRegionPacket newSimPack = new CrossedRegionPacket(); newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); - newSimPack.AgentData.AgentID = this.AgentId; - newSimPack.AgentData.SessionID = this.m_sessionId; + newSimPack.AgentData.AgentID = AgentId; + newSimPack.AgentData.SessionID = m_sessionId; newSimPack.Info = new CrossedRegionPacket.InfoBlock(); newSimPack.Info.Position = pos; - newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! + newSimPack.Info.LookAt = look; + // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); newSimPack.RegionData.RegionHandle = newRegionHandle; byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); - newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; - newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; - newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; - newSimPack.RegionData.SimIP += (uint)byteIP[0]; - newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; + newSimPack.RegionData.SimIP = (uint) byteIP[3] << 24; + newSimPack.RegionData.SimIP += (uint) byteIP[2] << 16; + newSimPack.RegionData.SimIP += (uint) byteIP[1] << 8; + newSimPack.RegionData.SimIP += (uint) byteIP[0]; + newSimPack.RegionData.SimPort = (ushort) externalIPEndPoint.Port; //newSimPack.RegionData.SeedCapability = new byte[0]; newSimPack.RegionData.SeedCapability = Helpers.StringToField(capsURL); - this.OutPacket(newSimPack); + OutPacket(newSimPack); } public void SendMapBlock(List mapBlocks) { MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); - mapReply.AgentData.AgentID = this.AgentId; + mapReply.AgentData.AgentID = AgentId; mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; mapReply.AgentData.Flags = 0; @@ -429,13 +416,13 @@ namespace OpenSim.Region.ClientStack mapReply.Data[i].Access = mapBlocks[i].Access; mapReply.Data[i].Agents = mapBlocks[i].Agents; } - this.OutPacket(mapReply); + OutPacket(mapReply); } public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { TeleportLocalPacket tpLocal = new TeleportLocalPacket(); - tpLocal.Info.AgentID = this.AgentId; + tpLocal.Info.AgentID = AgentId; tpLocal.Info.TeleportFlags = flags; tpLocal.Info.LocationID = 2; tpLocal.Info.LookAt = lookAt; @@ -443,10 +430,11 @@ namespace OpenSim.Region.ClientStack OutPacket(tpLocal); } - public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags, string capsURL) + public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, + uint flags, string capsURL) { TeleportFinishPacket teleport = new TeleportFinishPacket(); - teleport.Info.AgentID = this.AgentId; + teleport.Info.AgentID = AgentId; teleport.Info.RegionHandle = regionHandle; teleport.Info.SimAccess = simAccess; @@ -455,13 +443,13 @@ namespace OpenSim.Region.ClientStack IPAddress oIP = newRegionEndPoint.Address; byte[] byteIP = oIP.GetAddressBytes(); - uint ip = (uint)byteIP[3] << 24; - ip += (uint)byteIP[2] << 16; - ip += (uint)byteIP[1] << 8; - ip += (uint)byteIP[0]; + uint ip = (uint) byteIP[3] << 24; + ip += (uint) byteIP[2] << 16; + ip += (uint) byteIP[1] << 8; + ip += (uint) byteIP[0]; teleport.Info.SimIP = ip; - teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; + teleport.Info.SimPort = (ushort) newRegionEndPoint.Port; teleport.Info.LocationID = 4; teleport.Info.TeleportFlags = 1 << 4; OutPacket(teleport); @@ -473,8 +461,8 @@ namespace OpenSim.Region.ClientStack public void SendTeleportCancel() { TeleportCancelPacket tpCancel = new TeleportCancelPacket(); - tpCancel.Info.SessionID = this.m_sessionId; - tpCancel.Info.AgentID = this.AgentId; + tpCancel.Info.SessionID = m_sessionId; + tpCancel.Info.AgentID = AgentId; OutPacket(tpCancel); } @@ -492,7 +480,7 @@ namespace OpenSim.Region.ClientStack public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket(); - money.MoneyData.AgentID = this.AgentId; + money.MoneyData.AgentID = AgentId; money.MoneyData.TransactionID = transaction; money.MoneyData.TransactionSuccess = success; money.MoneyData.Description = description; @@ -506,7 +494,6 @@ namespace OpenSim.Region.ClientStack pc.PingID.PingID = seq; pc.Header.Reliable = false; OutPacket(pc); - } public void SendKillObject(ulong regionHandle, uint localID) @@ -522,8 +509,8 @@ namespace OpenSim.Region.ClientStack { Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; - InventoryDescendentsPacket descend = this.CreateInventoryDescendentsPacket(ownerID, folderID); - + InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); + int count = 0; if (items.Count < 40) { @@ -550,25 +537,30 @@ 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 = enc.GetBytes(item.inventoryName + "\0"); 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].CRC = Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100, descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); + descend.ItemData[i].Type = (sbyte) item.assetType; + descend.ItemData[i].CRC = + Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, + descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100, + descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, + descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, + 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); i++; count++; if (i == 40) { - this.OutPacket(descend); - + OutPacket(descend); + if ((items.Count - count) > 0) { - descend = this.CreateInventoryDescendentsPacket(ownerID, folderID); + descend = CreateInventoryDescendentsPacket(ownerID, folderID); if ((items.Count - count) < 40) { descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; @@ -586,15 +578,14 @@ namespace OpenSim.Region.ClientStack if (i < 40) { - this.OutPacket(descend); + OutPacket(descend); } - } private InventoryDescendentsPacket CreateInventoryDescendentsPacket(LLUUID ownerID, LLUUID folderID) { InventoryDescendentsPacket descend = new InventoryDescendentsPacket(); - descend.AgentData.AgentID = this.AgentId; + descend.AgentData.AgentID = AgentId; descend.AgentData.OwnerID = ownerID; descend.AgentData.FolderID = folderID; descend.AgentData.Version = 0; @@ -607,31 +598,39 @@ namespace OpenSim.Region.ClientStack Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); - inventoryReply.AgentData.AgentID = this.AgentId; + inventoryReply.AgentData.AgentID = AgentId; inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); inventoryReply.InventoryData[0].ItemID = item.inventoryID; inventoryReply.InventoryData[0].AssetID = item.assetID; inventoryReply.InventoryData[0].CreatorID = item.creatorsID; inventoryReply.InventoryData[0].BaseMask = item.inventoryBasePermissions; - inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + inventoryReply.InventoryData[0].CreationDate = + (int) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0"); inventoryReply.InventoryData[0].EveryoneMask = item.inventoryEveryOnePermissions; inventoryReply.InventoryData[0].Flags = 0; inventoryReply.InventoryData[0].FolderID = item.parentFolderID; inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); inventoryReply.InventoryData[0].GroupMask = 0; - inventoryReply.InventoryData[0].InvType = (sbyte)item.invType; + inventoryReply.InventoryData[0].InvType = (sbyte) item.invType; inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0"); inventoryReply.InventoryData[0].NextOwnerMask = item.inventoryNextPermissions; inventoryReply.InventoryData[0].OwnerID = item.avatarID; inventoryReply.InventoryData[0].OwnerMask = item.inventoryCurrentPermissions; inventoryReply.InventoryData[0].SalePrice = 0; inventoryReply.InventoryData[0].SaleType = 0; - inventoryReply.InventoryData[0].Type = (sbyte)item.assetType; - inventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, inventoryReply.InventoryData[0].GroupID, 100, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); - - this.OutPacket(inventoryReply); + inventoryReply.InventoryData[0].Type = (sbyte) item.assetType; + inventoryReply.InventoryData[0].CRC = + Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, + inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, + inventoryReply.InventoryData[0].GroupID, 100, + inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, + inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, + FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, + FULL_MASK_PERMISSIONS); + + OutPacket(inventoryReply); } public void SendInventoryItemUpdate(InventoryItemBase Item) @@ -639,7 +638,7 @@ namespace OpenSim.Region.ClientStack Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); - InventoryReply.AgentData.AgentID = this.AgentId; + InventoryReply.AgentData.AgentID = AgentId; InventoryReply.AgentData.SimApproved = true; InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); @@ -654,15 +653,22 @@ namespace OpenSim.Region.ClientStack InventoryReply.InventoryData[0].FolderID = Item.parentFolderID; InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); InventoryReply.InventoryData[0].GroupMask = 0; - InventoryReply.InventoryData[0].InvType = (sbyte)Item.invType; + InventoryReply.InventoryData[0].InvType = (sbyte) Item.invType; InventoryReply.InventoryData[0].Name = enc.GetBytes(Item.inventoryName + "\0"); InventoryReply.InventoryData[0].NextOwnerMask = Item.inventoryNextPermissions; InventoryReply.InventoryData[0].OwnerID = Item.avatarID; InventoryReply.InventoryData[0].OwnerMask = Item.inventoryCurrentPermissions; InventoryReply.InventoryData[0].SalePrice = 100; InventoryReply.InventoryData[0].SaleType = 0; - InventoryReply.InventoryData[0].Type = (sbyte)Item.assetType; - InventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); + InventoryReply.InventoryData[0].Type = (sbyte) Item.assetType; + InventoryReply.InventoryData[0].CRC = + Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, + InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, + InventoryReply.InventoryData[0].GroupID, 100, + InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, + InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, + FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, + FULL_MASK_PERMISSIONS); OutPacket(InventoryReply); } @@ -670,8 +676,8 @@ namespace OpenSim.Region.ClientStack public void SendRemoveInventoryItem(LLUUID itemID) { RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket(); - remove.AgentData.AgentID = this.AgentId; - remove.AgentData.SessionID = this.m_sessionId; + remove.AgentData.AgentID = AgentId; + remove.AgentData.SessionID = m_sessionId; remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); remove.InventoryData[0].ItemID = itemID; @@ -716,13 +722,14 @@ namespace OpenSim.Region.ClientStack public void SendAgentAlertMessage(string message, bool modal) { AgentAlertMessagePacket alertPack = new AgentAlertMessagePacket(); - alertPack.AgentData.AgentID = this.AgentId; + alertPack.AgentData.AgentID = AgentId; alertPack.AlertData.Message = Helpers.StringToField(message); alertPack.AlertData.Modal = modal; OutPacket(alertPack); } - public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) + public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, + string url) { LoadURLPacket loadURL = new LoadURLPacket(); loadURL.Data.ObjectName = Helpers.StringToField(objectname); @@ -761,14 +768,13 @@ namespace OpenSim.Region.ClientStack public void SendViewerTime(int phase) { - SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); //viewertime.TimeInfo.SecPerDay = 86400; // viewertime.TimeInfo.SecPerYear = 31536000; viewertime.TimeInfo.SecPerDay = 1000; viewertime.TimeInfo.SecPerYear = 365000; viewertime.TimeInfo.SunPhase = 1; - int sunPhase = (phase + 2) / 2; + int sunPhase = (phase + 2)/2; if ((sunPhase < 6) || (sunPhase > 36)) { viewertime.TimeInfo.SunDirection = new LLVector3(0f, 0.8f, -0.8f); @@ -781,27 +787,41 @@ namespace OpenSim.Region.ClientStack sunPhase = 12; } sunPhase = sunPhase - 12; - float yValue = 0.1f * (sunPhase); - if (yValue > 1.2f) { yValue = yValue - 1.2f; } - if (yValue > 1 ) { yValue = 1; } - if (yValue < 0) { yValue = 0; } + float yValue = 0.1f*(sunPhase); + if (yValue > 1.2f) + { + yValue = yValue - 1.2f; + } + if (yValue > 1) + { + yValue = 1; + } + if (yValue < 0) + { + yValue = 0; + } if (sunPhase < 14) { yValue = 1 - yValue; } - if (sunPhase < 12) { yValue *= -1; } + if (sunPhase < 12) + { + yValue *= -1; + } viewertime.TimeInfo.SunDirection = new LLVector3(0f, yValue, 0.3f); //Console.WriteLine("sending sun update " + yValue); } viewertime.TimeInfo.SunAngVelocity = new LLVector3(0, 0.0f, 10.0f); - viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch(); + viewertime.TimeInfo.UsecSinceStart = (ulong) Util.UnixTimeSinceEpoch(); OutPacket(viewertime); } - public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID) + public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, + string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, + LLUUID partnerID) { AvatarPropertiesReplyPacket avatarReply = new AvatarPropertiesReplyPacket(); - avatarReply.AgentData.AgentID = this.AgentId; + avatarReply.AgentData.AgentID = AgentId; avatarReply.AgentData.AvatarID = avatarID; avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText); avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn); @@ -827,6 +847,7 @@ namespace OpenSim.Region.ClientStack OutPacket(avatarSitResponse); } + #endregion #region Appearance/ Wearables Methods @@ -838,22 +859,22 @@ namespace OpenSim.Region.ClientStack public void SendWearables(AvatarWearable[] wearables) { AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); - aw.AgentData.AgentID = this.AgentId; + aw.AgentData.AgentID = AgentId; aw.AgentData.SerialNum = 0; - aw.AgentData.SessionID = this.m_sessionId; + aw.AgentData.SessionID = m_sessionId; aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; AgentWearablesUpdatePacket.WearableDataBlock awb; for (int i = 0; i < wearables.Length; i++) { awb = new AgentWearablesUpdatePacket.WearableDataBlock(); - awb.WearableType = (byte)i; + awb.WearableType = (byte) i; awb.AssetID = wearables[i].AssetID; awb.ItemID = wearables[i].ItemID; aw.WearableData[i] = awb; } - this.OutPacket(aw); + OutPacket(aw); } /// @@ -893,7 +914,7 @@ namespace OpenSim.Region.ClientStack ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); ani.AnimationList[0].AnimID = animID; ani.AnimationList[0].AnimSequenceID = seq; - this.OutPacket(ani); + OutPacket(ani); } #endregion @@ -909,25 +930,26 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) + public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, + uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) { ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); objupdate.RegionData.RegionHandle = regionHandle; objupdate.RegionData.TimeDilation = 64096; objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; - objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry); + objupdate.ObjectData[0] = CreateDefaultAvatarPacket(textureEntry); //give this avatar object a local id and assign the user a name objupdate.ObjectData[0].ID = avatarLocalID; objupdate.ObjectData[0].FullID = avatarID; objupdate.ObjectData[0].ParentID = parentID; - objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); - LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); + objupdate.ObjectData[0].NameValue = + Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); + LLVector3 pos2 = new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z); byte[] pb = pos2.GetBytes(); Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); OutPacket(objupdate); - } /// @@ -938,38 +960,41 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation) + public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, + LLVector3 velocity, LLQuaternion rotation) { - ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity, rotation); + ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = + CreateAvatarImprovedBlock(localID, position, velocity, rotation); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; terse.ObjectData[0] = terseBlock; - this.OutPacket(terse); + OutPacket(terse); } - public void SendCoarseLocationUpdate(List CoarseLocations) - { - CoarseLocationUpdatePacket loc = new CoarseLocationUpdatePacket(); - int total = CoarseLocations.Count; - CoarseLocationUpdatePacket.IndexBlock ib = - new CoarseLocationUpdatePacket.IndexBlock(); - loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; - for(int i=0; i CoarseLocations) + { + CoarseLocationUpdatePacket loc = new CoarseLocationUpdatePacket(); + int total = CoarseLocations.Count; + CoarseLocationUpdatePacket.IndexBlock ib = + new CoarseLocationUpdatePacket.IndexBlock(); + loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; + for (int i = 0; i < total; i++) + { + CoarseLocationUpdatePacket.LocationBlock lb = + new CoarseLocationUpdatePacket.LocationBlock(); + lb.X = (byte) CoarseLocations[i].X; + lb.Y = (byte) CoarseLocations[i].Y; + lb.Z = (byte) (CoarseLocations[i].Z/4); + loc.Location[i] = lb; + } + ib.You = -1; + ib.Prey = -1; + loc.Index = ib; + OutPacket(loc); + } #endregion @@ -984,27 +1009,28 @@ namespace OpenSim.Region.ClientStack public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { ObjectAttachPacket attach = new ObjectAttachPacket(); - attach.AgentData.AgentID = this.AgentId; - attach.AgentData.SessionID = this.m_sessionId; + attach.AgentData.AgentID = AgentId; + attach.AgentData.SessionID = m_sessionId; attach.AgentData.AttachmentPoint = attachPoint; attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); attach.ObjectData[0].ObjectLocalID = localID; attach.ObjectData[0].Rotation = rotation; - this.OutPacket(attach); + OutPacket(attach); } public void SendPrimitiveToClient( - ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, + ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, + uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID, byte[] particleSystem, LLQuaternion rotation) { ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); outPacket.RegionData.RegionHandle = regionHandle; - outPacket.RegionData.TimeDilation = timeDilation; + outPacket.RegionData.TimeDilation = timeDilation; outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; - outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); + outPacket.ObjectData[0] = CreatePrimUpdateBlock(primShape, flags); outPacket.ObjectData[0].ID = localID; outPacket.ObjectData[0].FullID = objectID; @@ -1033,35 +1059,38 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) + public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, + LLQuaternion rotation) { ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation); + terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation); - this.OutPacket(terse); + OutPacket(terse); } #endregion #region Helper Methods - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity, LLQuaternion rotation) + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, + LLVector3 velocity, + LLQuaternion rotation) { byte[] bytes = new byte[60]; int i = 0; ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); - dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; + dat.TextureEntry = new byte[0]; // AvatarTemplate.TextureEntry; uint ID = localID; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte) (ID%256); + bytes[i++] = (byte) ((ID >> 8)%256); + bytes[i++] = (byte) ((ID >> 16)%256); + bytes[i++] = (byte) ((ID >> 24)%256); bytes[i++] = 0; bytes[i++] = 1; i += 14; @@ -1078,55 +1107,55 @@ namespace OpenSim.Region.ClientStack internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); - internDirec = internDirec / 128.0f; + internDirec = internDirec/128.0f; internDirec.x += 1; internDirec.y += 1; internDirec.z += 1; - InternVelocityX = (ushort)(32768 * internDirec.x); - InternVelocityY = (ushort)(32768 * internDirec.y); - InternVelocityZ = (ushort)(32768 * internDirec.z); + InternVelocityX = (ushort) (32768*internDirec.x); + InternVelocityY = (ushort) (32768*internDirec.y); + InternVelocityZ = (ushort) (32768*internDirec.z); ushort ac = 32767; - bytes[i++] = (byte)(InternVelocityX % 256); - bytes[i++] = (byte)((InternVelocityX >> 8) % 256); - bytes[i++] = (byte)(InternVelocityY % 256); - bytes[i++] = (byte)((InternVelocityY >> 8) % 256); - bytes[i++] = (byte)(InternVelocityZ % 256); - bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); + bytes[i++] = (byte) (InternVelocityX%256); + bytes[i++] = (byte) ((InternVelocityX >> 8)%256); + bytes[i++] = (byte) (InternVelocityY%256); + bytes[i++] = (byte) ((InternVelocityY >> 8)%256); + bytes[i++] = (byte) (InternVelocityZ%256); + bytes[i++] = (byte) ((InternVelocityZ >> 8)%256); //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); //rotation ushort rw, rx, ry, rz; - rw = (ushort)(32768 * (rotation.W + 1)); - rx = (ushort)(32768 * (rotation.X + 1)); - ry = (ushort)(32768 * (rotation.Y + 1)); - rz = (ushort)(32768 * (rotation.Z + 1)); + rw = (ushort) (32768*(rotation.W + 1)); + rx = (ushort) (32768*(rotation.X + 1)); + ry = (ushort) (32768*(rotation.Y + 1)); + rz = (ushort) (32768*(rotation.Z + 1)); //rot - bytes[i++] = (byte)(rx % 256); - bytes[i++] = (byte)((rx >> 8) % 256); - bytes[i++] = (byte)(ry % 256); - bytes[i++] = (byte)((ry >> 8) % 256); - bytes[i++] = (byte)(rz % 256); - bytes[i++] = (byte)((rz >> 8) % 256); - bytes[i++] = (byte)(rw % 256); - bytes[i++] = (byte)((rw >> 8) % 256); + bytes[i++] = (byte) (rx%256); + bytes[i++] = (byte) ((rx >> 8)%256); + bytes[i++] = (byte) (ry%256); + bytes[i++] = (byte) ((ry >> 8)%256); + bytes[i++] = (byte) (rz%256); + bytes[i++] = (byte) ((rz >> 8)%256); + bytes[i++] = (byte) (rw%256); + bytes[i++] = (byte) ((rw >> 8)%256); //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); dat.Data = bytes; @@ -1140,7 +1169,9 @@ namespace OpenSim.Region.ClientStack /// /// /// - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation) + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, + LLVector3 position, + LLQuaternion rotation) { uint ID = localID; byte[] bytes = new byte[60]; @@ -1148,10 +1179,10 @@ namespace OpenSim.Region.ClientStack int i = 0; ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); dat.TextureEntry = new byte[0]; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte) (ID%256); + bytes[i++] = (byte) ((ID >> 8)%256); + bytes[i++] = (byte) ((ID >> 16)%256); + bytes[i++] = (byte) ((ID >> 24)%256); bytes[i++] = 0; bytes[i++] = 0; @@ -1161,44 +1192,44 @@ namespace OpenSim.Region.ClientStack ushort ac = 32767; //vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); //accel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); ushort rw, rx, ry, rz; - rw = (ushort)(32768 * (rotation.W + 1)); - rx = (ushort)(32768 * (rotation.X + 1)); - ry = (ushort)(32768 * (rotation.Y + 1)); - rz = (ushort)(32768 * (rotation.Z + 1)); + rw = (ushort) (32768*(rotation.W + 1)); + rx = (ushort) (32768*(rotation.X + 1)); + ry = (ushort) (32768*(rotation.Y + 1)); + rz = (ushort) (32768*(rotation.Z + 1)); //rot - bytes[i++] = (byte)(rx % 256); - bytes[i++] = (byte)((rx >> 8) % 256); - bytes[i++] = (byte)(ry % 256); - bytes[i++] = (byte)((ry >> 8) % 256); - bytes[i++] = (byte)(rz % 256); - bytes[i++] = (byte)((rz >> 8) % 256); - bytes[i++] = (byte)(rw % 256); - bytes[i++] = (byte)((rw >> 8) % 256); + bytes[i++] = (byte) (rx%256); + bytes[i++] = (byte) ((rx >> 8)%256); + bytes[i++] = (byte) (ry%256); + bytes[i++] = (byte) ((ry >> 8)%256); + bytes[i++] = (byte) (rz%256); + bytes[i++] = (byte) ((rz >> 8)%256); + bytes[i++] = (byte) (rw%256); + bytes[i++] = (byte) ((rw >> 8)%256); //rotation vel - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); - bytes[i++] = (byte)(ac % 256); - bytes[i++] = (byte)((ac >> 8) % 256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); + bytes[i++] = (byte) (ac%256); + bytes[i++] = (byte) ((ac >> 8)%256); dat.Data = bytes; return dat; @@ -1212,16 +1243,15 @@ namespace OpenSim.Region.ClientStack protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) { ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); - this.SetDefaultPrimPacketValues(objupdate); + SetDefaultPrimPacketValues(objupdate); objupdate.UpdateFlags = flags; - this.SetPrimPacketShapeData(objupdate, primShape); + SetPrimPacketShapeData(objupdate, primShape); return objupdate; } protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) { - objectData.TextureEntry = primData.TextureEntry; objectData.PCode = primData.PCode; objectData.PathBegin = primData.PathBegin; @@ -1278,10 +1308,11 @@ namespace OpenSim.Region.ClientStack /// protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) { - ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); + ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); + // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); SetDefaultAvatarPacketValues(ref objdata); - objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); + objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); objdata.PathCurve = 16; objdata.ProfileCurve = 1; objdata.PathScaleX = 100; @@ -1353,6 +1384,5 @@ namespace OpenSim.Region.ClientStack } #endregion - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs index 0771a4a..d589a7b 100644 --- a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs +++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs @@ -27,9 +27,8 @@ */ using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Region.ClientStack { @@ -37,17 +36,17 @@ namespace OpenSim.Region.ClientStack { protected virtual void RegisterLocalPacketHandlers() { - this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); - this.AddLocalPacketHandler(PacketType.ViewerEffect, this.HandleViewerEffect); - this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); - this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); + AddLocalPacketHandler(PacketType.LogoutRequest, Logout); + AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); + AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); + AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); } private bool HandleViewerEffect(IClientAPI sender, Packet Pack) { - ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; + ViewerEffectPacket viewer = (ViewerEffectPacket) Pack; - if( OnViewerEffect != null ) + if (OnViewerEffect != null) { OnViewerEffect(sender, viewer.Effect); } @@ -59,7 +58,7 @@ namespace OpenSim.Region.ClientStack { MainLog.Instance.Verbose("CLIENT", "Got a logout request"); - if( OnLogout != null ) + if (OnLogout != null) { OnLogout(client); } @@ -70,13 +69,14 @@ namespace OpenSim.Region.ClientStack protected bool AgentTextureCached(IClientAPI simclient, Packet packet) { //System.Console.WriteLine("texture cached: " + packet.ToString()); - AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; + AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket) packet; AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); - cachedresp.AgentData.AgentID = this.AgentId; - cachedresp.AgentData.SessionID = this.m_sessionId; - cachedresp.AgentData.SerialNum = this.cachedtextureserial; - this.cachedtextureserial++; - cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; + cachedresp.AgentData.AgentID = AgentId; + cachedresp.AgentData.SessionID = m_sessionId; + cachedresp.AgentData.SerialNum = cachedtextureserial; + cachedtextureserial++; + cachedresp.WearableData = + new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; for (int i = 0; i < chechedtex.WearableData.Length; i++) { cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); @@ -84,17 +84,18 @@ namespace OpenSim.Region.ClientStack cachedresp.WearableData[i].TextureID = LLUUID.Zero; cachedresp.WearableData[i].HostName = new byte[0]; } - this.OutPacket(cachedresp); + OutPacket(cachedresp); return true; } protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet) { - MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; + MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket) packet; // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); for (int i = 0; i < multipleupdate.ObjectData.Length; i++) { #region position + if (multipleupdate.ObjectData[i].Type == 9) //change position { if (OnUpdatePrimGroupPosition != null) @@ -102,20 +103,20 @@ namespace OpenSim.Region.ClientStack LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } - } else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position { if (OnUpdatePrimSinglePosition != null) { - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - #endregion position - #region rotation - else if (multipleupdate.ObjectData[i].Type == 2)// single item of group rotation from tab + #endregion position + #region rotation + + else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab { if (OnUpdatePrimSingleRotation != null) { @@ -124,38 +125,39 @@ namespace OpenSim.Region.ClientStack OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); } } - else if (multipleupdate.ObjectData[i].Type == 3)// single item of group rotation from mouse + else if (multipleupdate.ObjectData[i].Type == 3) // single item of group rotation from mouse { if (OnUpdatePrimSingleRotation != null) { - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); + LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); //System.Console.WriteLine("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); } } - else if (multipleupdate.ObjectData[i].Type == 10)//group rotation from object tab + else if (multipleupdate.ObjectData[i].Type == 10) //group rotation from object tab { if (OnUpdatePrimGroupRotation != null) { - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); + LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); } } - else if (multipleupdate.ObjectData[i].Type == 11)//group rotation from mouse + else if (multipleupdate.ObjectData[i].Type == 11) //group rotation from mouse { if (OnUpdatePrimGroupMouseRotation != null) { - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); - libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + 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); } } - #endregion - #region scale - else if (multipleupdate.ObjectData[i].Type == 13)//group scale from object tab + #endregion + #region scale + + else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab { if (OnUpdatePrimScale != null) { @@ -164,40 +166,41 @@ namespace OpenSim.Region.ClientStack OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); // Change the position based on scale (for bug number 246) - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - else if (multipleupdate.ObjectData[i].Type == 29)//group scale from mouse + else if (multipleupdate.ObjectData[i].Type == 29) //group scale from mouse { if (OnUpdatePrimScale != null) { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); - libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); + LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab + else if (multipleupdate.ObjectData[i].Type == 5) //single prim scale from object tab { if (OnUpdatePrimScale != null) { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); } } - else if (multipleupdate.ObjectData[i].Type == 21)//single prim scale from mouse + else if (multipleupdate.ObjectData[i].Type == 21) //single prim scale from mouse { if (OnUpdatePrimScale != null) { - libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); + LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); } } + #endregion } return true; @@ -208,7 +211,7 @@ namespace OpenSim.Region.ClientStack //should be getting the map layer from the grid server //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); - mapReply.AgentData.AgentID = this.AgentId; + mapReply.AgentData.AgentID = AgentId; mapReply.AgentData.Flags = 0; mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); @@ -217,7 +220,7 @@ namespace OpenSim.Region.ClientStack mapReply.LayerData[0].Top = 30000; mapReply.LayerData[0].Right = 30000; mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); - this.OutPacket(mapReply); + OutPacket(mapReply); } public void RequestMapBlocks(int minX, int minY, int maxX, int maxY) @@ -251,4 +254,4 @@ namespace OpenSim.Region.ClientStack */ } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs index 5cd30ce..efeff29 100644 --- a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs +++ b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs @@ -32,13 +32,12 @@ using System.Net.Sockets; using System.Timers; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; using OpenSim.Framework; -using OpenSim.Region.Environment; +using OpenSim.Framework.Console; namespace OpenSim.Region.ClientStack { - public partial class ClientView + public partial class ClientView { protected BlockingQueue PacketQueue; protected Dictionary PendingAcks = new Dictionary(); @@ -84,7 +83,7 @@ namespace OpenSim.Region.ClientStack Pack.Header.Sequence = Sequence; } - if (Pack.Header.Reliable) //DIRTY HACK + if (Pack.Header.Reliable) //DIRTY HACK { lock (NeedAck) { @@ -148,19 +147,21 @@ namespace OpenSim.Region.ClientStack if (Pack.Header.Zerocoded) { int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode);//userEP); + m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); //userEP); } else { - m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); //userEP); + m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); + //userEP); } } catch (Exception) { - MainLog.Instance.Warn("client", "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); - this.KillThread(); + MainLog.Instance.Warn("client", + "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + + userEP.ToString() + " - killing thread"); + KillThread(); } - } public virtual void InPacket(Packet NewPack) @@ -180,7 +181,7 @@ namespace OpenSim.Region.ClientStack // Handle PacketAck packets if (NewPack.Type == PacketType.PacketAck) { - PacketAckPacket ackPacket = (PacketAckPacket)NewPack; + PacketAckPacket ackPacket = (PacketAckPacket) NewPack; lock (NeedAck) { @@ -193,7 +194,7 @@ namespace OpenSim.Region.ClientStack else if ((NewPack.Type == PacketType.StartPingCheck)) { //reply to pingcheck - StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack; + StartPingCheckPacket startPing = (StartPingCheckPacket) NewPack; CompletePingCheckPacket endPing = new CompletePingCheckPacket(); endPing.PingID.PingID = startPing.PingID.PingID; OutPacket(endPing); @@ -203,9 +204,8 @@ namespace OpenSim.Region.ClientStack QueItem item = new QueItem(); item.Packet = NewPack; item.Incoming = true; - this.PacketQueue.Enqueue(item); + PacketQueue.Enqueue(item); } - } public virtual void OutPacket(Packet NewPack) @@ -213,7 +213,7 @@ namespace OpenSim.Region.ClientStack QueItem item = new QueItem(); item.Packet = NewPack; item.Incoming = false; - this.PacketQueue.Enqueue(item); + PacketQueue.Enqueue(item); } # region Low Level Packet Methods @@ -229,7 +229,6 @@ namespace OpenSim.Region.ClientStack ack_it.Header.Reliable = false; OutPacket(ack_it); - } /* if (Pack.Header.Reliable) @@ -252,8 +251,8 @@ namespace OpenSim.Region.ClientStack { if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) { - MainLog.Instance.Verbose( "Resending " + packet.Type.ToString() + " packet, " + - (now - packet.TickCount) + "ms have passed"); + MainLog.Instance.Verbose("Resending " + packet.Type.ToString() + " packet, " + + (now - packet.TickCount) + "ms have passed"); packet.Header.Resent = true; OutPacket(packet); @@ -271,7 +270,7 @@ namespace OpenSim.Region.ClientStack if (PendingAcks.Count > 250) { // FIXME: Handle the odd case where we have too many pending ACKs queued up - MainLog.Instance.Verbose( "Too many ACKs queued up!"); + MainLog.Instance.Verbose("Too many ACKs queued up!"); return; } @@ -302,6 +301,7 @@ namespace OpenSim.Region.ClientStack SendAcks(); ResendUnacked(); } + #endregion #region Nested Classes @@ -315,6 +315,7 @@ namespace OpenSim.Region.ClientStack public Packet Packet; public bool Incoming; } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 13e8b43..dd2562c 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -31,8 +31,6 @@ using System.Text; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.ClientStack { @@ -63,7 +61,7 @@ namespace OpenSim.Region.ClientStack { ack_pack(Pack); - if (this.ProcessPacketMethod(Pack)) + if (ProcessPacketMethod(Pack)) { //there is a handler registered that handled this packet type return; @@ -74,16 +72,17 @@ namespace OpenSim.Region.ClientStack switch (Pack.Type) { - #region Scene/Avatar + #region Scene/Avatar + case PacketType.AvatarPropertiesRequest: - AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; + AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket) Pack; if (OnRequestAvatarProperties != null) { OnRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); } break; case PacketType.ChatFromViewer: - ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; + ChatFromViewerPacket inchatpack = (ChatFromViewerPacket) Pack; if (Util.FieldToString(inchatpack.ChatData.Message) == "") { //empty message so don't bother with it @@ -103,30 +102,32 @@ namespace OpenSim.Region.ClientStack args.Channel = channel; args.From = fromName; args.Message = Util.FieldToString(message); - args.Type = (ChatTypeEnum)type; + args.Type = (ChatTypeEnum) type; args.Position = fromPos; args.Scene = Scene; args.Sender = this; - this.OnChatFromViewer(this, args); + OnChatFromViewer(this, args); } break; case PacketType.ImprovedInstantMessage: - ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; + ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket) Pack; string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message); if (OnInstantMessage != null) { - this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, - msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, msgpack.MessageBlock.Dialog); + OnInstantMessage(msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, + msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, + msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, + msgpack.MessageBlock.Dialog); } break; case PacketType.RezObject: - RezObjectPacket rezPacket = (RezObjectPacket)Pack; + RezObjectPacket rezPacket = (RezObjectPacket) Pack; if (OnRezObject != null) { - this.OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd); + OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd); } break; case PacketType.DeRezObject: @@ -136,13 +137,15 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ModifyLand: - ModifyLandPacket modify = (ModifyLandPacket)Pack; + ModifyLandPacket modify = (ModifyLandPacket) Pack; if (modify.ParcelData.Length > 0) { if (OnModifyTerrain != null) { - OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, - modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West, this); + OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, + modify.ModifyBlock.BrushSize, + modify.ModifyBlock.Action, modify.ParcelData[0].North, + modify.ParcelData[0].West, this); } } break; @@ -164,7 +167,7 @@ namespace OpenSim.Region.ClientStack break; case PacketType.AgentSetAppearance: //OpenSim.Framework.Console.MainLog.Instance.Verbose("set appear", Pack.ToString()); - AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; + AgentSetAppearancePacket appear = (AgentSetAppearancePacket) Pack; if (OnSetAppearance != null) { OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); @@ -179,17 +182,16 @@ namespace OpenSim.Region.ClientStack case PacketType.AgentUpdate: if (OnAgentUpdate != null) { - AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; + AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation); } break; case PacketType.AgentAnimation: - AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; + AgentAnimationPacket AgentAni = (AgentAnimationPacket) Pack; for (int i = 0; i < AgentAni.AnimationList.Length; i++) { if (AgentAni.AnimationList[i].StartAnim) { - if (OnStartAnim != null) { OnStartAnim(this, AgentAni.AnimationList[i].AnimID, 1); @@ -198,27 +200,29 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.AgentRequestSit: - AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; + AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket) Pack; SendSitResponse(agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); if (OnAgentRequestSit != null) { - OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, agentRequestSit.TargetObject.TargetID); + OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, + agentRequestSit.TargetObject.TargetID); } break; case PacketType.AgentSit: if (OnAgentSit != null) { - AgentSitPacket agentSit = (AgentSitPacket)Pack; + AgentSitPacket agentSit = (AgentSitPacket) Pack; OnAgentSit(this, agentSit.AgentData.AgentID); } break; - #endregion + #endregion + + #region Objects/m_sceneObjects - #region Objects/m_sceneObjects case PacketType.ObjectLink: // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); - ObjectLinkPacket link = (ObjectLinkPacket)Pack; + ObjectLinkPacket link = (ObjectLinkPacket) Pack; uint parentprimid = 0; List childrenprims = new List(); if (link.ObjectData.Length > 1) @@ -238,13 +242,13 @@ namespace OpenSim.Region.ClientStack case PacketType.ObjectAdd: if (OnAddPrim != null) { - ObjectAddPacket addPacket = (ObjectAddPacket)Pack; + ObjectAddPacket addPacket = (ObjectAddPacket) Pack; PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); - OnAddPrim(this.AgentId, addPacket.ObjectData.RayEnd, shape); + OnAddPrim(AgentId, addPacket.ObjectData.RayEnd, shape); } break; case PacketType.ObjectShape: - ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; + ObjectShapePacket shapePacket = (ObjectShapePacket) Pack; for (int i = 0; i < shapePacket.ObjectData.Length; i++) { if (OnUpdatePrimShape != null) @@ -254,26 +258,28 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectExtraParams: - ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack; + ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack; if (OnUpdateExtraParams != null) { - OnUpdateExtraParams(extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); + OnUpdateExtraParams(extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, + extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); } break; case PacketType.ObjectDuplicate: - ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; + ObjectDuplicatePacket dupe = (ObjectDuplicatePacket) Pack; for (int i = 0; i < dupe.ObjectData.Length; i++) { if (OnObjectDuplicate != null) { - OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags); + OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, + dupe.SharedData.DuplicateFlags); } } break; case PacketType.ObjectSelect: - ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; + ObjectSelectPacket incomingselect = (ObjectSelectPacket) Pack; for (int i = 0; i < incomingselect.ObjectData.Length; i++) { if (OnObjectSelect != null) @@ -283,7 +289,7 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectDeselect: - ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; + ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket) Pack; for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) { if (OnObjectDeselect != null) @@ -293,55 +299,58 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectFlagUpdate: - ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; + ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket) Pack; if (OnUpdatePrimFlags != null) { OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); } break; case PacketType.ObjectImage: - ObjectImagePacket imagePack = (ObjectImagePacket)Pack; + ObjectImagePacket imagePack = (ObjectImagePacket) Pack; for (int i = 0; i < imagePack.ObjectData.Length; i++) { if (OnUpdatePrimTexture != null) { - OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this); + OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, + imagePack.ObjectData[i].TextureEntry, this); } } break; case PacketType.ObjectGrab: - ObjectGrabPacket grab = (ObjectGrabPacket)Pack; + ObjectGrabPacket grab = (ObjectGrabPacket) Pack; if (OnGrabObject != null) { OnGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this); } break; case PacketType.ObjectGrabUpdate: - ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack; + ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket) Pack; if (OnGrabUpdate != null) { - OnGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, grabUpdate.ObjectData.GrabPosition, this); + OnGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, + grabUpdate.ObjectData.GrabPosition, this); } break; case PacketType.ObjectDeGrab: - ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack; + ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket) Pack; if (OnDeGrabObject != null) { OnDeGrabObject(deGrab.ObjectData.LocalID, this); } break; case PacketType.ObjectDescription: - ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; + ObjectDescriptionPacket objDes = (ObjectDescriptionPacket) Pack; for (int i = 0; i < objDes.ObjectData.Length; i++) { if (OnObjectDescription != null) { - OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); + OnObjectDescription(objDes.ObjectData[i].LocalID, + enc.GetString(objDes.ObjectData[i].Description)); } } break; case PacketType.ObjectName: - ObjectNamePacket objName = (ObjectNamePacket)Pack; + ObjectNamePacket objName = (ObjectNamePacket) Pack; for (int i = 0; i < objName.ObjectData.Length; i++) { if (OnObjectName != null) @@ -353,15 +362,16 @@ namespace OpenSim.Region.ClientStack case PacketType.ObjectPermissions: //Console.WriteLine("permissions set " + Pack.ToString()); break; - #endregion - #region Inventory/Asset/Other related packets + #endregion + + #region Inventory/Asset/Other related packets + case PacketType.RequestImage: - RequestImagePacket imageRequest = (RequestImagePacket)Pack; + RequestImagePacket imageRequest = (RequestImagePacket) Pack; //Console.WriteLine("image request: " + Pack.ToString()); for (int i = 0; i < imageRequest.RequestImage.Length; i++) { - // still working on the Texture download module so for now using old method // TextureRequestArgs args = new TextureRequestArgs(); // args.RequestedAssetID = imageRequest.RequestImage[i].Image; @@ -373,86 +383,104 @@ namespace OpenSim.Region.ClientStack // OnRequestTexture(this, args); // } - m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, imageRequest.RequestImage[i].Packet, imageRequest.RequestImage[i].DiscardLevel); + m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, + imageRequest.RequestImage[i].Packet, + imageRequest.RequestImage[i].DiscardLevel); } break; case PacketType.TransferRequest: //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); - TransferRequestPacket transfer = (TransferRequestPacket)Pack; + TransferRequestPacket transfer = (TransferRequestPacket) Pack; m_assetCache.AddAssetRequest(this, transfer); break; case PacketType.AssetUploadRequest: - AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; + AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack; // Console.WriteLine("upload request " + Pack.ToString()); // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionID).ToStringHyphenated()); if (OnAssetUploadRequest != null) { - OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(this.SecureSessionID), request.AssetBlock.TransactionID, request.AssetBlock.Type, request.AssetBlock.AssetData, request.AssetBlock.StoreLocal); + OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionID), + request.AssetBlock.TransactionID, request.AssetBlock.Type, + request.AssetBlock.AssetData, request.AssetBlock.StoreLocal); } break; case PacketType.RequestXfer: - RequestXferPacket xferReq = (RequestXferPacket)Pack; + RequestXferPacket xferReq = (RequestXferPacket) Pack; if (OnRequestXfer != null) { OnRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); } break; case PacketType.SendXferPacket: - SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; + SendXferPacketPacket xferRec = (SendXferPacketPacket) Pack; if (OnXferReceive != null) { OnXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); } break; case PacketType.ConfirmXferPacket: - ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; + ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket) Pack; if (OnConfirmXfer != null) { OnConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); } break; case PacketType.CreateInventoryFolder: - if (this.OnCreateNewInventoryFolder != null) + if (OnCreateNewInventoryFolder != null) { - CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; - this.OnCreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); + CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket) Pack; + OnCreateNewInventoryFolder(this, invFolder.FolderData.FolderID, + (ushort) invFolder.FolderData.Type, + Util.FieldToString(invFolder.FolderData.Name), + invFolder.FolderData.ParentID); } break; case PacketType.CreateInventoryItem: - CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; - if (this.OnCreateNewInventoryItem != null) + CreateInventoryItemPacket createItem = (CreateInventoryItemPacket) Pack; + if (OnCreateNewInventoryItem != null) { - this.OnCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, createItem.InventoryBlock.FolderID, createItem.InventoryBlock.CallbackID, - Util.FieldToString(createItem.InventoryBlock.Description), Util.FieldToString(createItem.InventoryBlock.Name), createItem.InventoryBlock.InvType, - createItem.InventoryBlock.Type, createItem.InventoryBlock.WearableType, createItem.InventoryBlock.NextOwnerMask); + OnCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, + createItem.InventoryBlock.FolderID, + createItem.InventoryBlock.CallbackID, + Util.FieldToString(createItem.InventoryBlock.Description), + Util.FieldToString(createItem.InventoryBlock.Name), + createItem.InventoryBlock.InvType, + createItem.InventoryBlock.Type, + createItem.InventoryBlock.WearableType, + createItem.InventoryBlock.NextOwnerMask); } break; case PacketType.FetchInventory: - if (this.OnFetchInventory != null) + if (OnFetchInventory != null) { - FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; + FetchInventoryPacket FetchInventory = (FetchInventoryPacket) Pack; for (int i = 0; i < FetchInventory.InventoryData.Length; i++) { - this.OnFetchInventory(this, FetchInventory.InventoryData[i].ItemID, FetchInventory.InventoryData[i].OwnerID); + OnFetchInventory(this, FetchInventory.InventoryData[i].ItemID, + FetchInventory.InventoryData[i].OwnerID); } } break; case PacketType.FetchInventoryDescendents: - if (this.OnFetchInventoryDescendents != null) + if (OnFetchInventoryDescendents != null) { - FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; - this.OnFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, Fetch.InventoryData.SortOrder); + FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket) Pack; + OnFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, + Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, + Fetch.InventoryData.SortOrder); } break; case PacketType.UpdateInventoryItem: - UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; + UpdateInventoryItemPacket update = (UpdateInventoryItemPacket) Pack; if (OnUpdateInventoryItem != null) { for (int i = 0; i < update.InventoryData.Length; i++) { if (update.InventoryData[i].TransactionID != LLUUID.Zero) { - OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, update.InventoryData[i].TransactionID.Combine(this.SecureSessionID), update.InventoryData[i].ItemID); + OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, + update.InventoryData[i].TransactionID.Combine(SecureSessionID), + update.InventoryData[i].ItemID); } } } @@ -488,25 +516,26 @@ namespace OpenSim.Region.ClientStack }*/ break; case PacketType.RequestTaskInventory: - RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; - if (this.OnRequestTaskInventory != null) + RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket) Pack; + if (OnRequestTaskInventory != null) { - this.OnRequestTaskInventory(this, requesttask.InventoryData.LocalID); + OnRequestTaskInventory(this, requesttask.InventoryData.LocalID); } break; case PacketType.UpdateTaskInventory: //Console.WriteLine(Pack.ToString()); - UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; + UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket) Pack; if (OnUpdateTaskInventory != null) { if (updatetask.UpdateData.Key == 0) { - OnUpdateTaskInventory(this, updatetask.InventoryData.ItemID, updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID); + OnUpdateTaskInventory(this, updatetask.InventoryData.ItemID, + updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID); } } break; case PacketType.RemoveTaskInventory: - RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack; + RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket) Pack; if (OnRemoveTaskItem != null) { OnRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); @@ -517,38 +546,39 @@ namespace OpenSim.Region.ClientStack break; case PacketType.RezScript: //Console.WriteLine(Pack.ToString()); - RezScriptPacket rezScript = (RezScriptPacket)Pack; + RezScriptPacket rezScript = (RezScriptPacket) Pack; if (OnRezScript != null) { OnRezScript(this, rezScript.InventoryBlock.ItemID, rezScript.UpdateBlock.ObjectLocalID); } break; case PacketType.MapLayerRequest: - this.RequestMapLayer(); + RequestMapLayer(); break; case PacketType.MapBlockRequest: - MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; + MapBlockRequestPacket MapRequest = (MapBlockRequestPacket) Pack; if (OnRequestMapBlocks != null) { - OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); + OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, + MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); } break; case PacketType.TeleportLandmarkRequest: - TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; + TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket) Pack; TeleportStartPacket tpStart = new TeleportStartPacket(); tpStart.Info.TeleportFlags = 8; // tp via lm - this.OutPacket(tpStart); + OutPacket(tpStart); TeleportProgressPacket tpProgress = new TeleportProgressPacket(); tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); tpProgress.Info.TeleportFlags = 8; tpProgress.AgentData.AgentID = tpReq.Info.AgentID; - this.OutPacket(tpProgress); + OutPacket(tpProgress); // Fetch landmark LLUUID lmid = tpReq.Info.LandmarkID; - AssetBase lma = this.m_assetCache.GetAsset(lmid); + AssetBase lma = m_assetCache.GetAsset(lmid); if (lma != null) { AssetLandmark lm = new AssetLandmark(lma); @@ -558,7 +588,7 @@ namespace OpenSim.Region.ClientStack TeleportLocalPacket tpLocal = new TeleportLocalPacket(); tpLocal.Info.AgentID = tpReq.Info.AgentID; - tpLocal.Info.TeleportFlags = 8; // Teleport via landmark + tpLocal.Info.TeleportFlags = 8; // Teleport via landmark tpLocal.Info.LocationID = 2; tpLocal.Info.Position = lm.Position; OutPacket(tpLocal); @@ -582,12 +612,13 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.TeleportLocationRequest: - TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; + TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket) Pack; // Console.WriteLine(tpLocReq.ToString()); if (OnTeleportLocationRequest != null) { - OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16); + OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, + tpLocReq.Info.LookAt, 16); } else { @@ -598,76 +629,94 @@ namespace OpenSim.Region.ClientStack OutPacket(tpCancel); } break; - #endregion + + #endregion case PacketType.MoneyBalanceRequest: SendMoneyBalance(LLUUID.Zero, true, new byte[0], MoneyBalance); break; case PacketType.UUIDNameRequest: - UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; + UUIDNameRequestPacket incoming = (UUIDNameRequestPacket) Pack; foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) { OnNameFromUUIDRequest(UUIDBlock.ID, this); } break; - #region Parcel related packets + + #region Parcel related packets + case PacketType.ParcelPropertiesRequest: - ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; + ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket) Pack; if (OnParcelPropertiesRequest != null) { - OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this); + OnParcelPropertiesRequest((int) Math.Round(propertiesRequest.ParcelData.West), + (int) Math.Round(propertiesRequest.ParcelData.South), + (int) Math.Round(propertiesRequest.ParcelData.East), + (int) Math.Round(propertiesRequest.ParcelData.North), + propertiesRequest.ParcelData.SequenceID, + propertiesRequest.ParcelData.SnapSelection, this); } break; case PacketType.ParcelDivide: - ParcelDividePacket landDivide = (ParcelDividePacket)Pack; + ParcelDividePacket landDivide = (ParcelDividePacket) Pack; if (OnParcelDivideRequest != null) { - OnParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), (int)Math.Round(landDivide.ParcelData.South), (int)Math.Round(landDivide.ParcelData.East), (int)Math.Round(landDivide.ParcelData.North), this); + OnParcelDivideRequest((int) Math.Round(landDivide.ParcelData.West), + (int) Math.Round(landDivide.ParcelData.South), + (int) Math.Round(landDivide.ParcelData.East), + (int) Math.Round(landDivide.ParcelData.North), this); } break; case PacketType.ParcelJoin: - ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack; + ParcelJoinPacket landJoin = (ParcelJoinPacket) Pack; if (OnParcelJoinRequest != null) { - OnParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West), (int)Math.Round(landJoin.ParcelData.South), (int)Math.Round(landJoin.ParcelData.East), (int)Math.Round(landJoin.ParcelData.North), this); + OnParcelJoinRequest((int) Math.Round(landJoin.ParcelData.West), + (int) Math.Round(landJoin.ParcelData.South), + (int) Math.Round(landJoin.ParcelData.East), + (int) Math.Round(landJoin.ParcelData.North), this); } break; case PacketType.ParcelPropertiesUpdate: - ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack; + ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket) Pack; if (OnParcelPropertiesUpdateRequest != null) { OnParcelPropertiesUpdateRequest(updatePacket, this); - } break; case PacketType.ParcelSelectObjects: - ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; + ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket) Pack; if (OnParcelSelectObjects != null) { - OnParcelSelectObjects(selectPacket.ParcelData.LocalID, Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); + OnParcelSelectObjects(selectPacket.ParcelData.LocalID, + Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); } break; case PacketType.ParcelObjectOwnersRequest: - ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; + ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket) Pack; if (OnParcelObjectOwnerRequest != null) { OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); } break; - #endregion - #region Estate Packets + #endregion + + #region Estate Packets + case PacketType.EstateOwnerMessage: - EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; + EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket) Pack; if (OnEstateOwnerMessage != null) { OnEstateOwnerMessage(messagePacket, this); } break; - #endregion - #region unimplemented handlers + #endregion + + #region unimplemented handlers + case PacketType.AgentIsNowWearing: // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; //Console.WriteLine(Pack.ToString()); @@ -675,7 +724,8 @@ namespace OpenSim.Region.ClientStack case PacketType.ObjectScale: //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); break; - #endregion + + #endregion } } } @@ -721,4 +771,4 @@ namespace OpenSim.Region.ClientStack OutPacket(logReply); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 6d49e34..55f50a4 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -36,7 +36,7 @@ using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using Timer = System.Timers.Timer; +using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack { @@ -50,8 +50,11 @@ namespace OpenSim.Region.ClientStack { public static TerrainManager TerrainManager; - protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients - protected Dictionary m_packetHandlers = new Dictionary(); //local handlers for this instance + protected static Dictionary PacketHandlers = + new Dictionary(); //Global/static handlers for all clients + + protected Dictionary m_packetHandlers = new Dictionary(); + //local handlers for this instance private LLUUID m_sessionId; public LLUUID SecureSessionID = LLUUID.Zero; @@ -84,7 +87,9 @@ namespace OpenSim.Region.ClientStack private int probesWithNoIngressPackets = 0; private int lastPacketsReceived = 0; - public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions) + public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, + IScene scene, AssetCache assetCache, PacketServer packServer, + AgentCircuitManager authenSessions) { m_moneyBalance = 1000; @@ -96,11 +101,11 @@ namespace OpenSim.Region.ClientStack // m_inventoryCache = inventoryCache; m_authenticateSessionsHandler = authenSessions; - MainLog.Instance.Verbose("CLIENT","Started up new client thread to handle incoming request"); + MainLog.Instance.Verbose("CLIENT", "Started up new client thread to handle incoming request"); cirpack = initialcirpack; userEP = remoteEP; - this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); + startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); PacketQueue = new BlockingQueue(); @@ -109,7 +114,7 @@ namespace OpenSim.Region.ClientStack AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); AckTimer.Start(); - this.RegisterLocalPacketHandlers(); + RegisterLocalPacketHandlers(); ClientThread = new Thread(new ThreadStart(AuthUser)); ClientThread.IsBackground = true; @@ -121,7 +126,7 @@ namespace OpenSim.Region.ClientStack get { return m_sessionId; } } - public void SetDebug(int newDebug) + public void SetDebug(int newDebug) { debug = newDebug; } @@ -132,14 +137,15 @@ namespace OpenSim.Region.ClientStack { clientPingTimer.Stop(); - m_scene.RemoveClient(this.AgentId); + m_scene.RemoveClient(AgentId); - this.ClientThread.Abort(); + ClientThread.Abort(); } #endregion # region Packet Handling + public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) { bool result = false; @@ -195,23 +201,27 @@ namespace OpenSim.Region.ClientStack protected void DebugPacket(string direction, Packet packet) { - if (debug > 0) { + if (debug > 0) + { string info; - if (debug < 255 && packet.Type == PacketType.AgentUpdate) - return; - if (debug < 254 && packet.Type == PacketType.ViewerEffect) - return; + if (debug < 255 && packet.Type == PacketType.AgentUpdate) + return; + if (debug < 254 && packet.Type == PacketType.ViewerEffect) + return; if (debug < 253 && ( - packet.Type == PacketType.CompletePingCheck || - packet.Type == PacketType.StartPingCheck - ) ) - return; - if (debug < 252 && packet.Type == PacketType.PacketAck) - return; - - if (debug > 1) { + packet.Type == PacketType.CompletePingCheck || + packet.Type == PacketType.StartPingCheck + )) + return; + if (debug < 252 && packet.Type == PacketType.PacketAck) + return; + + if (debug > 1) + { info = packet.ToString(); - } else { + } + else + { info = packet.Type.ToString(); } Console.WriteLine(m_circuitCode + ":" + direction + ": " + info); @@ -242,6 +252,7 @@ namespace OpenSim.Region.ClientStack } } } + # endregion protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) @@ -251,7 +262,7 @@ namespace OpenSim.Region.ClientStack probesWithNoIngressPackets++; if (probesWithNoIngressPackets > 30) { - if( OnConnectionClosed != null ) + if (OnConnectionClosed != null) { OnConnectionClosed(this); } @@ -278,14 +289,16 @@ namespace OpenSim.Region.ClientStack clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); clientPingTimer.Enabled = true; - MainLog.Instance.Verbose("CLIENT","Adding viewer agent to scene"); - this.m_scene.AddNewClient(this, true); + MainLog.Instance.Verbose("CLIENT", "Adding viewer agent to scene"); + m_scene.AddNewClient(this, true); } protected virtual void AuthUser() { // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.m_circuitCode.m_sessionId, cirpack.m_circuitCode.ID, cirpack.m_circuitCode.Code); - AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); + AuthenticateResponse sessionInfo = + m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, + cirpack.CircuitCode.Code); if (!sessionInfo.Authorised) { //session/circuit not authorised @@ -297,27 +310,26 @@ namespace OpenSim.Region.ClientStack MainLog.Instance.Notice("CLIENT", "Got authenticated connection from " + userEP.ToString()); //session is authorised m_agentId = cirpack.CircuitCode.ID; - this.m_sessionId = cirpack.CircuitCode.SessionID; - this.m_circuitCode = cirpack.CircuitCode.Code; - this.firstName = sessionInfo.LoginInfo.First; - this.lastName = sessionInfo.LoginInfo.Last; + m_sessionId = cirpack.CircuitCode.SessionID; + m_circuitCode = cirpack.CircuitCode.Code; + firstName = sessionInfo.LoginInfo.First; + lastName = sessionInfo.LoginInfo.Last; if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) { - this.SecureSessionID = sessionInfo.LoginInfo.SecureSession; + SecureSessionID = sessionInfo.LoginInfo.SecureSession; } InitNewClient(); ClientLoop(); } } - # endregion + # endregion protected void KillThread() { - this.ClientThread.Abort(); + ClientThread.Abort(); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 1b64602..f75536a 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -25,15 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Collections.Generic; using System.Net; using System.Net.Sockets; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using libsecondlife; namespace OpenSim.Region.ClientStack { @@ -56,10 +52,7 @@ namespace OpenSim.Region.ClientStack public IScene LocalScene { - set - { - this.m_scene = value; - } + set { m_scene = value; } } /// @@ -72,17 +65,21 @@ namespace OpenSim.Region.ClientStack m_scene.ClientManager.InPacket(circuitCode, packet); } - protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions) + protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, + ClientManager clientManager, IScene scene, AssetCache assetCache, + PacketServer packServer, AgentCircuitManager authenSessions) { - return new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions ); + return + new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions); } - public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass) + public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, + AgentCircuitManager authenticateSessionsClass) { IClientAPI newuser; if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser)) - { + { return false; } else @@ -104,7 +101,7 @@ namespace OpenSim.Region.ClientStack { client.SendLogoutPacket(); - CloseClient( client ); + CloseClient(client); } @@ -117,7 +114,7 @@ namespace OpenSim.Region.ClientStack /// public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) { - this.m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode); + m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode); } /// @@ -126,13 +123,13 @@ namespace OpenSim.Region.ClientStack /// public virtual void CloseCircuit(uint circuitcode) { - m_networkHandler.RemoveClientCircuit( circuitcode ); + m_networkHandler.RemoveClientCircuit(circuitcode); m_scene.ClientManager.CloseAllAgents(circuitcode); } - public virtual void CloseClient( IClientAPI client ) + public virtual void CloseClient(IClientAPI client) { - CloseCircuit( client.CircuitCode ); + CloseCircuit(client.CircuitCode); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 657af54..7551bff 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -28,17 +28,15 @@ using System; using System.Collections.Generic; using System.Net; +using libsecondlife; using OpenSim.Framework; +using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; -using OpenSim.Region.Physics.Manager; using OpenSim.Region.Environment; -using libsecondlife; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Communications; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.ClientStack { @@ -67,9 +65,8 @@ namespace OpenSim.Region.ClientStack m_startuptime = DateTime.Now; } - virtual public void StartUp() + public virtual void StartUp() { - ClientView.TerrainManager = new TerrainManager(new SecondLife()); Initialize(); @@ -116,7 +113,10 @@ namespace OpenSim.Region.ClientStack scene.PhysScene.SetTerrain(scene.Terrain.GetHeights1D()); //Master Avatar Setup - UserProfileData masterAvatar = m_commsManager.UserService.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, scene.RegionInfo.MasterAvatarLastName, scene.RegionInfo.MasterAvatarSandboxPassword); + UserProfileData masterAvatar = + m_commsManager.UserService.SetupMasterUser(scene.RegionInfo.MasterAvatarFirstName, + scene.RegionInfo.MasterAvatarLastName, + scene.RegionInfo.MasterAvatarSandboxPassword); if (masterAvatar != null) { m_log.Verbose("PARCEL", "Found master avatar [" + masterAvatar.UUID.ToStringHyphenated() + "]"); @@ -126,7 +126,7 @@ namespace OpenSim.Region.ClientStack else { m_log.Verbose("PARCEL", "No master avatar found, using null."); - scene.RegionInfo.MasterAvatarAssignedUUID = libsecondlife.LLUUID.Zero; + scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; //TODO: Load parcels from storageManager } @@ -138,8 +138,7 @@ namespace OpenSim.Region.ClientStack return scene; } - protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager); - - + 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 584b80c..e5965cb 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -32,13 +32,10 @@ using System.Net.Sockets; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; namespace OpenSim.Region.ClientStack { - public class UDPServer : ClientStackNetworkHandler { protected Dictionary clientCircuits = new Dictionary(); @@ -59,22 +56,16 @@ namespace OpenSim.Region.ClientStack public PacketServer PacketServer { - get - { - return m_packetServer; - } - set - { - m_packetServer = value; - } + get { return m_packetServer; } + set { m_packetServer = value; } } public IScene LocalScene { set { - this.m_localScene = value; - this.m_packetServer.LocalScene = this.m_localScene; + m_localScene = value; + m_packetServer.LocalScene = m_localScene; } } @@ -85,10 +76,10 @@ namespace OpenSim.Region.ClientStack public UDPServer(int port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass) { listenPort = port; - this.m_assetCache = assetCache; - this.m_log = console; - this.m_authenticateSessionsClass = authenticateClass; - this.CreatePacketServer(); + m_assetCache = assetCache; + m_log = console; + m_authenticateSessionsClass = authenticateClass; + CreatePacketServer(); } protected virtual void CreatePacketServer() @@ -99,7 +90,7 @@ namespace OpenSim.Region.ClientStack protected virtual void OnReceivedData(IAsyncResult result) { ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - epSender = (EndPoint)ipeSender; + epSender = (EndPoint) ipeSender; Packet packet = null; int numBytes; @@ -108,7 +99,7 @@ namespace OpenSim.Region.ClientStack { numBytes = Server.EndReceiveFrom(result, ref epSender); } - catch (System.Net.Sockets.SocketException e) + catch (SocketException e) { // TODO : Actually only handle those states that we have control over, re-throw everything else, // TODO: implement cases as we encounter them. @@ -134,7 +125,7 @@ namespace OpenSim.Region.ClientStack if (clientCircuits.TryGetValue(epSender, out circuit)) { //if so then send packet to the packetserver - this.m_packetServer.InPacket(circuit, packet); + m_packetServer.InPacket(circuit, packet); } else if (packet.Type == PacketType.UseCircuitCode) { @@ -142,7 +133,8 @@ namespace OpenSim.Region.ClientStack AddNewClient(packet); } else - { // invalid client + { + // invalid client m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); } @@ -160,10 +152,10 @@ namespace OpenSim.Region.ClientStack protected virtual void AddNewClient(Packet packet) { - UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; - this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); + UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; + clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); - this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); + PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); } public void ServerListener() @@ -177,24 +169,24 @@ namespace OpenSim.Region.ClientStack m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen"); ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); - epSender = (EndPoint)ipeSender; - ReceivedData = new AsyncCallback(this.OnReceivedData); + epSender = (EndPoint) ipeSender; + ReceivedData = new AsyncCallback(OnReceivedData); Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); m_log.Status("SERVER", "Listening..."); - } public virtual void RegisterPacketServer(PacketServer server) { - this.m_packetServer = server; + m_packetServer = server; } - public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) + public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) + //EndPoint packetSender) { // find the endpoint for this circuit EndPoint sendto = null; - foreach (KeyValuePair p in this.clientCircuits) + foreach (KeyValuePair p in clientCircuits) { if (p.Value == circuitcode) { @@ -205,22 +197,20 @@ namespace OpenSim.Region.ClientStack if (sendto != null) { //we found the endpoint so send the packet to it - this.Server.SendTo(buffer, size, flags, sendto); + Server.SendTo(buffer, size, flags, sendto); } } public virtual void RemoveClientCircuit(uint circuitcode) { - foreach (KeyValuePair p in this.clientCircuits) + foreach (KeyValuePair p in clientCircuits) { if (p.Value == circuitcode) { - this.clientCircuits.Remove(p.Key); + clientCircuits.Remove(p.Key); break; } } } - - } } \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index ef5150f..eac293e 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -25,32 +25,30 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; namespace OpenSim.Region.Communications.Local { public class CommunicationsLocal : CommunicationsManager { public CommunicationsLocal( - NetworkServersInfo serversInfo, - BaseHttpServer httpServer, - AssetCache assetCache, - IUserService userService, - LocalInventoryService inventoryService, - IInterRegionCommunications interRegionService, - IGridServices gridService, bool dumpAssetsToFile ) + NetworkServersInfo serversInfo, + BaseHttpServer httpServer, + AssetCache assetCache, + IUserService userService, + LocalInventoryService inventoryService, + IInterRegionCommunications interRegionService, + IGridServices gridService, bool dumpAssetsToFile) : base(serversInfo, httpServer, assetCache, dumpAssetsToFile) { m_inventoryService = inventoryService; m_userService = userService; m_gridService = gridService; 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 99c4bc3..3a0b47f 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -25,25 +25,25 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System.Collections; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Framework; -using System.Collections; namespace OpenSim.Region.Communications.Local { - public class LocalBackEndServices : IGridServices, IInterRegionCommunications { protected Dictionary m_regions = new Dictionary(); - protected Dictionary m_regionListeners = new Dictionary(); + + protected Dictionary m_regionListeners = + new Dictionary(); + private Dictionary m_remoteRegionInfoCache = new Dictionary(); public LocalBackEndServices() { - } /// @@ -54,13 +54,13 @@ namespace OpenSim.Region.Communications.Local public RegionCommsListener RegisterRegion(RegionInfo regionInfo) { //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering"); - if (!this.m_regions.ContainsKey((uint)regionInfo.RegionHandle)) + if (!m_regions.ContainsKey((uint) regionInfo.RegionHandle)) { //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle ); - this.m_regions.Add(regionInfo.RegionHandle, regionInfo); + m_regions.Add(regionInfo.RegionHandle, regionInfo); RegionCommsListener regionHost = new RegionCommsListener(); - this.m_regionListeners.Add(regionInfo.RegionHandle, regionHost); + m_regionListeners.Add(regionInfo.RegionHandle, regionHost); return regionHost; } @@ -103,9 +103,9 @@ namespace OpenSim.Region.Communications.Local /// public RegionInfo RequestNeighbourInfo(ulong regionHandle) { - if (this.m_regions.ContainsKey(regionHandle)) + if (m_regions.ContainsKey(regionHandle)) { - return this.m_regions[regionHandle]; + return m_regions[regionHandle]; } return null; } @@ -121,16 +121,18 @@ namespace OpenSim.Region.Communications.Local public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) { List mapBlocks = new List(); - foreach (RegionInfo regInfo in this.m_regions.Values) + foreach (RegionInfo regInfo in m_regions.Values) { - if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY))) + if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && + ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY))) { MapBlockData map = new MapBlockData(); map.Name = regInfo.RegionName; - map.X = (ushort)regInfo.RegionLocX; - map.Y = (ushort)regInfo.RegionLocY; - map.WaterHeight = (byte)regInfo.EstateSettings.waterHeight; - map.MapImageId = regInfo.EstateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007"); + map.X = (ushort) regInfo.RegionLocX; + map.Y = (ushort) regInfo.RegionLocY; + map.WaterHeight = (byte) regInfo.EstateSettings.waterHeight; + map.MapImageId = regInfo.EstateSettings.terrainImageID; + //new LLUUID("00000000-0000-0000-9999-000000000007"); map.Agents = 1; map.RegionFlags = 72458694; map.Access = 13; @@ -145,13 +147,14 @@ namespace OpenSim.Region.Communications.Local /// /// /// - public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData + public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) + //should change from agentCircuitData { //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent"); - if (this.m_regionListeners.ContainsKey(regionHandle)) + if (m_regionListeners.ContainsKey(regionHandle)) { // Console.WriteLine("CommsManager- Informing a region to expect child agent"); - this.m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agentData); + m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agentData); return true; } return false; @@ -166,10 +169,10 @@ namespace OpenSim.Region.Communications.Local /// public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { - if (this.m_regionListeners.ContainsKey(regionHandle)) + if (m_regionListeners.ContainsKey(regionHandle)) { // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing"); - this.m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); + m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); return true; } return false; @@ -177,7 +180,7 @@ namespace OpenSim.Region.Communications.Local public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) { - if (this.m_regionListeners.ContainsKey(regionHandle)) + if (m_regionListeners.ContainsKey(regionHandle)) { return true; } @@ -210,15 +213,15 @@ namespace OpenSim.Region.Communications.Local public void TriggerExpectUser(ulong regionHandle, AgentCircuitData agent) { - if (this.m_regionListeners.ContainsKey(regionHandle)) + if (m_regionListeners.ContainsKey(regionHandle)) { - this.m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agent); + m_regionListeners[regionHandle].TriggerExpectUser(regionHandle, agent); } } public void PingCheckReply(Hashtable respData) { - foreach (ulong region in this.m_regions.Keys) + foreach (ulong region in m_regions.Keys) { Hashtable regData = new Hashtable(); RegionInfo reg = m_regions[region]; @@ -234,7 +237,7 @@ namespace OpenSim.Region.Communications.Local if (m_regionListeners.ContainsKey(regionHandle)) { return m_regionListeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position, - isFlying); + isFlying); } return false; @@ -250,11 +253,5 @@ 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 b7d78bc..c38e922 100644 --- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs @@ -28,29 +28,28 @@ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; namespace OpenSim.Region.Communications.Local { public class LocalInventoryService : InventoryServiceBase { - public LocalInventoryService() { - } - public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) + public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, + InventoryItemInfo itemCallBack) { - List folders = this.RequestFirstLevelFolders(userID); + List folders = RequestFirstLevelFolders(userID); InventoryFolderImpl rootFolder = null; //need to make sure we send root folder first foreach (InventoryFolderBase folder in folders) { - if (folder.parentID == libsecondlife.LLUUID.Zero) + if (folder.parentID == LLUUID.Zero) { InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); rootFolder = newfolder; @@ -67,7 +66,7 @@ namespace OpenSim.Region.Communications.Local InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); folderCallBack(userID, newfolder); - List items = this.RequestFolderItems(newfolder.folderID); + List items = RequestFolderItems(newfolder.folderID); foreach (InventoryItemBase item in items) { itemCallBack(userID, item); @@ -79,17 +78,17 @@ namespace OpenSim.Region.Communications.Local public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) { - this.AddFolder(folder); + AddFolder(folder); } public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) { - this.AddItem(item); + AddItem(item); } public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) { - this.deleteItem(item); + deleteItem(item); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 1043683..aa1a0d9 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -30,9 +30,9 @@ using System; using System.Collections; using System.Collections.Generic; using libsecondlife; -using OpenSim.Framework.Communications; using OpenSim.Framework; using OpenSim.Framework.UserManagement; +using InventoryFolder=OpenSim.Framework.InventoryFolder; namespace OpenSim.Region.Communications.Local { @@ -49,23 +49,23 @@ namespace OpenSim.Region.Communications.Local public event LoginToRegionEvent OnLoginToRegion; - public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) + public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, + NetworkServersInfo serversInfo, bool authenticate) : base(userManager, welcomeMess) { m_Parent = parent; this.serversInfo = serversInfo; defaultHomeX = this.serversInfo.DefaultHomeLocX; defaultHomeY = this.serversInfo.DefaultHomeLocY; - this.authUsers = authenticate; + authUsers = authenticate; } public override UserProfileData GetTheUser(string firstname, string lastname) { - UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname); + UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); if (profile != null) { - return profile; } @@ -73,9 +73,9 @@ namespace OpenSim.Region.Communications.Local { //no current user account so make one Console.WriteLine("No User account found so creating a new one "); - this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); + m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); - profile = this.m_userManager.GetUserProfile(firstname, lastname); + profile = m_userManager.GetUserProfile(firstname, lastname); if (profile != null) { m_Parent.InventoryService.CreateNewUserInventory(profile.UUID); @@ -113,18 +113,22 @@ namespace OpenSim.Region.Communications.Local if (reg != null) { - response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.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() + "]}"; + response.Home = "{'region_handle':[r" + (reg.RegionLocX*256).ToString() + ",r" + + (reg.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() + "]}"; string capsPath = Util.GetRandomCapsPath(); response.SimAddress = reg.ExternalEndPoint.Address.ToString(); - response.SimPort = (Int32)reg.ExternalEndPoint.Port; + response.SimPort = (Int32) reg.ExternalEndPoint.Port; response.RegionX = reg.RegionLocX; response.RegionY = reg.RegionLocY; - - response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; - // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; + + response.SeedCapability = "http://" + reg.ExternalHostName + ":" + + serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; + // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; theUser.currentAgent.currentRegion = reg.RegionID; theUser.currentAgent.currentHandle = reg.RegionHandle; @@ -135,11 +139,11 @@ namespace OpenSim.Region.Communications.Local _login.Agent = response.AgentID; _login.Session = response.SessionID; _login.SecureSession = response.SecureSessionID; - _login.CircuitCode = (uint)response.CircuitCode; + _login.CircuitCode = (uint) response.CircuitCode; _login.StartPos = new LLVector3(128, 128, 70); _login.CapsPath = capsPath; - if( OnLoginToRegion != null ) + if (OnLoginToRegion != null) { OnLoginToRegion(currentRegion, _login); } @@ -148,7 +152,6 @@ namespace OpenSim.Region.Communications.Local { Console.WriteLine("not found region " + currentRegion); } - } protected override InventoryData CreateInventoryData(LLUUID userID) @@ -168,8 +171,8 @@ namespace OpenSim.Region.Communications.Local TempHash = new Hashtable(); TempHash["name"] = InvFolder.name; TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); - 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.ToStringHyphenated(); AgentInventoryArray.Add(TempHash); } @@ -182,13 +185,13 @@ namespace OpenSim.Region.Communications.Local ArrayList AgentInventoryArray = new ArrayList(); Hashtable TempHash; - foreach (OpenSim.Framework.InventoryFolder InvFolder in userInventory.InventoryFolders.Values) + foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) { TempHash = new Hashtable(); TempHash["name"] = InvFolder.FolderName; TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); - 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.ToStringHyphenated(); AgentInventoryArray.Add(TempHash); } @@ -197,4 +200,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 1dede97..a7687c7 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -27,8 +27,8 @@ */ using System; -using OpenSim.Framework.Communications; using OpenSim.Framework; +using OpenSim.Framework.Communications; using OpenSim.Framework.UserManagement; namespace OpenSim.Region.Communications.Local @@ -41,7 +41,8 @@ namespace OpenSim.Region.Communications.Local private IInventoryServices m_inventoryService; - public LocalUserServices(NetworkServersInfo serversInfo, uint defaultHomeLocX, uint defaultHomeLocY, IInventoryServices inventoryService) + public LocalUserServices(NetworkServersInfo serversInfo, uint defaultHomeLocX, uint defaultHomeLocY, + IInventoryServices inventoryService) { m_serversInfo = serversInfo; @@ -49,7 +50,6 @@ namespace OpenSim.Region.Communications.Local m_defaultHomeY = defaultHomeLocY; m_inventoryService = inventoryService; - } public override UserProfileData SetupMasterUser(string firstName, string lastName) @@ -82,4 +82,4 @@ namespace OpenSim.Region.Communications.Local return profile; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs index ca64319..481577e 100644 --- a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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.Region.Communications.Local")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Region.Communications.Local")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Region.Communications.Local")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Region.Communications.Local")] +[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("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")] + +[assembly : Guid("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")] // Version information for an assembly consists of the following four values: // @@ -29,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index 1807cc7..941cc30 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -26,17 +26,17 @@ * */ +using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; using OpenSim.Framework.Servers; - namespace OpenSim.Region.Communications.OGS1 { public class CommunicationsOGS1 : CommunicationsManager { - public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache ) :base(serversInfo, httpServer, assetCache, false) + public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache) + : base(serversInfo, httpServer, assetCache, false) { OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer); m_gridService = gridInterComms; @@ -46,4 +46,4 @@ namespace OpenSim.Region.Communications.OGS1 m_userService = new OGS1UserServices(this); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 3719c97..d9af95b 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -35,14 +35,12 @@ using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Security.Authentication; - using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Console; using OpenSim.Framework.Servers; -using OpenSim.Framework; using OpenSim.Region.Communications.Local; namespace OpenSim.Region.Communications.OGS1 @@ -65,10 +63,10 @@ namespace OpenSim.Region.Communications.OGS1 { serversInfo = servers_info; httpServer = httpServe; - httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); - httpServer.AddXmlRPCHandler("check", this.PingCheckReply); + httpServer.AddXmlRPCHandler("expect_user", ExpectUser); + httpServer.AddXmlRPCHandler("check", PingCheckReply); - this.StartRemoting(); + StartRemoting(); } /// @@ -99,14 +97,14 @@ namespace OpenSim.Region.Communications.OGS1 // Send Request XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 10000); - Hashtable GridRespData = (Hashtable)GridResp.Value; + Hashtable GridRespData = (Hashtable) GridResp.Value; Hashtable griddatahash = GridRespData; // 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; } @@ -121,8 +119,7 @@ namespace OpenSim.Region.Communications.OGS1 /// public List RequestNeighbours(uint x, uint y) { - - Hashtable respData = MapBlockQuery((int)x - 1, (int)y - 1, (int)x + 1, (int)y + 1); + Hashtable respData = MapBlockQuery((int) x - 1, (int) y - 1, (int) x + 1, (int) y + 1); List neighbours = new List(); @@ -134,16 +131,15 @@ namespace OpenSim.Region.Communications.OGS1 uint regY = Convert.ToUInt32(neighbourData["y"]); if ((x != regX) || (y != regY)) { - - string simIp = (string)neighbourData["sim_ip"]; + string simIp = (string) neighbourData["sim_ip"]; int port = Convert.ToInt32(neighbourData["sim_port"]); - string externalUri = (string)neighbourData["sim_uri"]; + string externalUri = (string) neighbourData["sim_uri"]; - string externalIpStr = OpenSim.Framework.Util.GetHostFromDNS(simIp).ToString(); + string externalIpStr = Util.GetHostFromDNS(simIp).ToString(); SimpleRegionInfo sri = new SimpleRegionInfo(regX, regY, simIp, port); sri.RemotingPort = Convert.ToUInt32(neighbourData["remoting_port"]); - sri.RegionID = new LLUUID((string)neighbourData["uuid"]); + sri.RegionID = new LLUUID((string) neighbourData["uuid"]); neighbours.Add(sri); } @@ -175,11 +171,11 @@ namespace OpenSim.Region.Communications.OGS1 { Hashtable requestData = new Hashtable(); requestData["region_handle"] = regionHandle.ToString(); - requestData["authkey"] = this.serversInfo.GridSendKey; + requestData["authkey"] = serversInfo.GridSendKey; ArrayList SendParams = new ArrayList(); SendParams.Add(requestData); XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); - XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); + XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); Hashtable responseData = (Hashtable) GridResp.Value; @@ -205,7 +201,7 @@ namespace OpenSim.Region.Communications.OGS1 regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); regionInfo.RegionName = (string) responseData["region_name"]; - m_remoteRegionInfoCache.Add( regionHandle, regionInfo ); + m_remoteRegionInfoCache.Add(regionHandle, regionInfo); } return regionInfo; @@ -234,11 +230,11 @@ namespace OpenSim.Region.Communications.OGS1 neighbour.X = Convert.ToUInt16(n["x"]); neighbour.Y = Convert.ToUInt16(n["y"]); - neighbour.Name = (string)n["name"]; + neighbour.Name = (string) n["name"]; neighbour.Access = Convert.ToByte(n["access"]); neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]); neighbour.WaterHeight = Convert.ToByte(n["water-height"]); - neighbour.MapImageId = new LLUUID((string)n["map-image-id"]); + neighbour.MapImageId = new LLUUID((string) n["map-image-id"]); neighbours.Add(neighbour); } @@ -267,7 +263,7 @@ namespace OpenSim.Region.Communications.OGS1 parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); XmlRpcResponse resp = req.Send(serversInfo.GridURL, 10000); - Hashtable respData = (Hashtable)resp.Value; + Hashtable respData = (Hashtable) resp.Value; return respData; } @@ -300,15 +296,15 @@ namespace OpenSim.Region.Communications.OGS1 public XmlRpcResponse ExpectUser(XmlRpcRequest request) { Console.WriteLine("Expecting User..."); - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; AgentCircuitData agentData = new AgentCircuitData(); - agentData.SessionID = new LLUUID((string)requestData["session_id"]); - agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); - agentData.firstname = (string)requestData["firstname"]; - agentData.lastname = (string)requestData["lastname"]; - agentData.AgentID = new LLUUID((string)requestData["agent_id"]); + agentData.SessionID = new LLUUID((string) requestData["session_id"]); + agentData.SecureSessionID = new LLUUID((string) requestData["secure_session_id"]); + agentData.firstname = (string) requestData["firstname"]; + agentData.lastname = (string) requestData["lastname"]; + agentData.AgentID = new LLUUID((string) requestData["agent_id"]); agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); - agentData.CapsPath = (string)requestData["caps_path"]; + agentData.CapsPath = (string) requestData["caps_path"]; if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) { @@ -316,12 +312,14 @@ namespace OpenSim.Region.Communications.OGS1 } else { - agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"])); + agentData.startpos = + new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), + Convert.ToUInt32(requestData["startpos_y"]), + Convert.ToUInt32(requestData["startpos_z"])); agentData.child = false; - } - ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); + ulong regionHandle = Convert.ToUInt64((string) requestData["regionhandle"]); m_localBackend.TriggerExpectUser(regionHandle, agentData); @@ -331,6 +329,7 @@ namespace OpenSim.Region.Communications.OGS1 } #region m_interRegion Comms + /// /// /// @@ -339,13 +338,16 @@ namespace OpenSim.Region.Communications.OGS1 TcpChannel ch = new TcpChannel(NetworkServersInfo.RemotingListenerPort); ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesnt support this. - WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton); + WellKnownServiceTypeEntry wellType = + new WellKnownServiceTypeEntry(typeof (OGS1InterRegionRemoting), "InterRegions", + WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(wellType); - InterRegionSingleton.Instance.OnArrival += this.TriggerExpectAvatarCrossing; - InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; + InterRegionSingleton.Instance.OnArrival += TriggerExpectAvatarCrossing; + InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; } #region Methods called by regions in this instance + /// /// /// @@ -361,17 +363,19 @@ namespace OpenSim.Region.Communications.OGS1 return true; } - RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); + RegionInfo regInfo = RequestNeighbourInfo(regionHandle); if (regInfo != null) { //don't want to be creating a new link to the remote instance every time like we are here bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); - + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof (OGS1InterRegionRemoting), + "tcp://" + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions"); + if (remObject != null) { retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData); @@ -388,7 +392,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } - catch (System.Runtime.Remoting.RemotingException e) + catch (RemotingException e) { MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); return false; @@ -432,13 +436,15 @@ namespace OpenSim.Region.Communications.OGS1 return true; } - RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); + RegionInfo regInfo = RequestNeighbourInfo(regionHandle); if (regInfo != null) { bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof (OGS1InterRegionRemoting), + "tcp://" + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions"); if (remObject != null) { retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); @@ -455,7 +461,7 @@ namespace OpenSim.Region.Communications.OGS1 // to inform it. return false; } - catch (System.Runtime.Remoting.RemotingException e) + catch (RemotingException e) { MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); return false; @@ -474,6 +480,7 @@ namespace OpenSim.Region.Communications.OGS1 #endregion #region Methods triggered by calls from external instances + /// /// /// @@ -486,7 +493,7 @@ namespace OpenSim.Region.Communications.OGS1 { return m_localBackend.IncomingChildAgent(regionHandle, agentData); } - catch (System.Runtime.Remoting.RemotingException e) + catch (RemotingException e) { MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); return false; @@ -502,18 +509,19 @@ namespace OpenSim.Region.Communications.OGS1 /// public bool TriggerExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) { - try { return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); } - catch (System.Runtime.Remoting.RemotingException e) + catch (RemotingException e) { MainLog.Instance.Error("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); return false; } } + #endregion + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs index 0b7bd82..a127010 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs @@ -27,17 +27,19 @@ */ using System; +using System.Runtime.Remoting; using libsecondlife; using OpenSim.Framework; namespace OpenSim.Region.Communications.OGS1 { public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData); + public delegate bool ExpectArrival(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying); public sealed class InterRegionSingleton { - static readonly InterRegionSingleton instance = new InterRegionSingleton(); + private static readonly InterRegionSingleton instance = new InterRegionSingleton(); public event InformRegionChild OnChildAgent; public event ExpectArrival OnArrival; @@ -46,16 +48,13 @@ namespace OpenSim.Region.Communications.OGS1 { } - InterRegionSingleton() + private InterRegionSingleton() { } public static InterRegionSingleton Instance { - get - { - return instance; - } + get { return instance; } } public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) @@ -79,7 +78,6 @@ namespace OpenSim.Region.Communications.OGS1 public class OGS1InterRegionRemoting : MarshalByRefObject { - public OGS1InterRegionRemoting() { } @@ -90,7 +88,7 @@ namespace OpenSim.Region.Communications.OGS1 { return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, agentData); } - catch (System.Runtime.Remoting.RemotingException e) + catch (RemotingException e) { Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); return false; @@ -103,11 +101,11 @@ namespace OpenSim.Region.Communications.OGS1 { return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); } - catch (System.Runtime.Remoting.RemotingException e) + catch (RemotingException e) { Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); 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 11dee2d..49fdee9 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -28,46 +28,39 @@ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework; - namespace OpenSim.Region.Communications.OGS1 { public class OGS1InventoryService : IInventoryServices { - public OGS1InventoryService() { - } #region IInventoryServices Members - - public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) + + public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, + InventoryItemInfo itemCallBack) { - } public void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) { - } public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) { - } public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) { - } public void CreateNewUserInventory(LLUUID user) { - } public List RequestFirstLevelFolders(LLUUID userID) @@ -77,4 +70,4 @@ namespace OpenSim.Region.Communications.OGS1 #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 19a3c3b..d00a813 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -28,16 +28,19 @@ using System; using System.Collections; +using System.Net; using libsecondlife; using Nwc.XmlRpc; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Interfaces; namespace OpenSim.Region.Communications.OGS1 { - public class OGS1UserServices :IUserService + public class OGS1UserServices : IUserService { - CommunicationsOGS1 m_parent; + private CommunicationsOGS1 m_parent; + public OGS1UserServices(CommunicationsOGS1 parent) { m_parent = parent; @@ -47,32 +50,41 @@ namespace OpenSim.Region.Communications.OGS1 { if (data.Contains("error_type")) { - Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + "): " + data["error_desc"]); + Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + + "): " + data["error_desc"]); return null; } UserProfileData userData = new UserProfileData(); - userData.username = (string)data["firstname"]; - userData.surname = (string)data["lastname"]; - userData.UUID = new LLUUID((string)data["uuid"]); - userData.userInventoryURI = (string)data["server_inventory"]; - userData.userAssetURI = (string)data["server_asset"]; - userData.profileFirstText = (string)data["profile_firstlife_about"]; - userData.profileFirstImage = new LLUUID((string)data["profile_firstlife_image"]); - userData.profileCanDoMask = Convert.ToUInt32((string)data["profile_can_do"]); + userData.username = (string) data["firstname"]; + userData.surname = (string) data["lastname"]; + userData.UUID = new LLUUID((string) data["uuid"]); + userData.userInventoryURI = (string) data["server_inventory"]; + userData.userAssetURI = (string) data["server_asset"]; + userData.profileFirstText = (string) data["profile_firstlife_about"]; + userData.profileFirstImage = new LLUUID((string) data["profile_firstlife_image"]); + userData.profileCanDoMask = Convert.ToUInt32((string) data["profile_can_do"]); userData.profileWantDoMask = Convert.ToUInt32(data["profile_want_do"]); - userData.profileImage = new LLUUID((string)data["profile_image"]); - userData.lastLogin = Convert.ToInt32((string)data["profile_lastlogin"]); - userData.homeRegion = Convert.ToUInt64((string)data["home_region"]); - userData.homeLocation = new LLVector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), (float)Convert.ToDecimal((string)data["home_coordinates_y"]), (float)Convert.ToDecimal((string)data["home_coordinates_z"])); - userData.homeLookAt = new LLVector3((float)Convert.ToDecimal((string)data["home_look_x"]), (float)Convert.ToDecimal((string)data["home_look_y"]), (float)Convert.ToDecimal((string)data["home_look_z"])); + userData.profileImage = new LLUUID((string) data["profile_image"]); + userData.lastLogin = Convert.ToInt32((string) data["profile_lastlogin"]); + userData.homeRegion = Convert.ToUInt64((string) data["home_region"]); + userData.homeLocation = + new LLVector3((float) Convert.ToDecimal((string) data["home_coordinates_x"]), + (float) Convert.ToDecimal((string) data["home_coordinates_y"]), + (float) Convert.ToDecimal((string) data["home_coordinates_z"])); + userData.homeLookAt = + new LLVector3((float) Convert.ToDecimal((string) data["home_look_x"]), + (float) Convert.ToDecimal((string) data["home_look_y"]), + (float) Convert.ToDecimal((string) data["home_look_z"])); return userData; } + public UserProfileData GetUserProfile(string firstName, string lastName) { return GetUserProfile(firstName + " " + lastName); } + public UserProfileData GetUserProfile(string name) { try @@ -83,16 +95,18 @@ namespace OpenSim.Region.Communications.OGS1 parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters); XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); - Hashtable respData = (Hashtable)resp.Value; + Hashtable respData = (Hashtable) resp.Value; return ConvertXMLRPCDataToUserProfile(respData); } - catch (System.Net.WebException e) + catch (WebException e) { - OpenSim.Framework.Console.MainLog.Instance.Warn("Error when trying to fetch profile data by name from remote user server: " + e.Message); + MainLog.Instance.Warn("Error when trying to fetch profile data by name from remote user server: " + + e.Message); } return null; } + public UserProfileData GetUserProfile(LLUUID avatarID) { try @@ -103,18 +117,19 @@ namespace OpenSim.Region.Communications.OGS1 parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); - Hashtable respData = (Hashtable)resp.Value; + Hashtable respData = (Hashtable) resp.Value; return ConvertXMLRPCDataToUserProfile(respData); } catch (Exception e) { - Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + e.Message); + Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + + e.Message); } return null; } - public void clearUserAgent(LLUUID avatarID) + public void clearUserAgent(LLUUID avatarID) { // TODO: implement } @@ -135,4 +150,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/Communications/OGS1/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs index 2bebf9f..631cfd0 100644 --- a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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("OpenGrid.Framework.Communications.OGS1")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenGrid.Framework.Communications.OGS1")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenGrid.Framework.Communications.OGS1")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenGrid.Framework.Communications.OGS1")] +[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("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")] + +[assembly : Guid("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")] // Version information for an assembly consists of the following four values: // @@ -29,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 41d14f0..9e32b35 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -30,12 +30,10 @@ using System.Collections.Generic; using System.Text; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; - namespace OpenSim.Region.Environment { /// @@ -216,14 +214,14 @@ namespace OpenSim.Region.Environment int tempMaxAgents = Convert.ToInt16(Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[4].Parameter))); - m_regInfo.EstateSettings.maxAgents = (byte)tempMaxAgents; + m_regInfo.EstateSettings.maxAgents = (byte) tempMaxAgents; float tempObjectBonusFactor = - (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); + (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); m_regInfo.EstateSettings.objectBonusFactor = tempObjectBonusFactor; int tempMatureLevel = Convert.ToInt16(Helpers.FieldToUTF8String(packet.ParamList[6].Parameter)); - m_regInfo.EstateSettings.simAccess = (Simulator.SimAccess)tempMatureLevel; + m_regInfo.EstateSettings.simAccess = (Simulator.SimAccess) tempMatureLevel; if (convertParamStringToBool(packet.ParamList[7].Parameter)) @@ -250,13 +248,13 @@ namespace OpenSim.Region.Environment } else { - float WaterHeight = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); + float WaterHeight = (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[0].Parameter)); float TerrainRaiseLimit = - (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); + (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[1].Parameter)); float TerrainLowerLimit = - (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); + (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[2].Parameter)); bool UseFixedSun = convertParamStringToBool(packet.ParamList[4].Parameter); - float SunHour = (float)Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); + float SunHour = (float) Convert.ToDecimal(Helpers.FieldToUTF8String(packet.ParamList[5].Parameter)); setRegionSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseFixedSun, SunHour); @@ -273,8 +271,8 @@ namespace OpenSim.Region.Environment if (splitField.Length == 3) { Int16 corner = Convert.ToInt16(splitField[0]); - float lowValue = (float)Convert.ToDecimal(splitField[1]); - float highValue = (float)Convert.ToDecimal(splitField[2]); + float lowValue = (float) Convert.ToDecimal(splitField[1]); + float highValue = (float) Convert.ToDecimal(splitField[2]); setEstateTextureRange(corner, lowValue, highValue); } @@ -343,7 +341,7 @@ namespace OpenSim.Region.Environment { m_scene.Broadcast( sendRegionHandshake - ); + ); } public void sendRegionInfoPacket(IClientAPI remote_client) @@ -363,8 +361,8 @@ namespace OpenSim.Region.Environment regionInfoPacket.RegionInfo.PricePerMeter = m_regInfo.EstateSettings.pricePerMeter; regionInfoPacket.RegionInfo.RedirectGridX = m_regInfo.EstateSettings.redirectGridX; regionInfoPacket.RegionInfo.RedirectGridY = m_regInfo.EstateSettings.redirectGridY; - regionInfoPacket.RegionInfo.RegionFlags = (uint)m_regInfo.EstateSettings.regionFlags; - regionInfoPacket.RegionInfo.SimAccess = (byte)m_regInfo.EstateSettings.simAccess; + regionInfoPacket.RegionInfo.RegionFlags = (uint) m_regInfo.EstateSettings.regionFlags; + regionInfoPacket.RegionInfo.SimAccess = (byte) m_regInfo.EstateSettings.simAccess; regionInfoPacket.RegionInfo.SimName = _enc.GetBytes(m_regInfo.RegionName); regionInfoPacket.RegionInfo.SunHour = m_regInfo.EstateSettings.sunHour; regionInfoPacket.RegionInfo.TerrainLowerLimit = m_regInfo.EstateSettings.terrainLowerLimit; diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs index 90c3730..e7ce957 100644 --- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs +++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; using OpenSim.Framework; @@ -10,4 +7,4 @@ namespace OpenSim.Region.Environment.Interfaces { bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, out byte[] visualParams); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs index 8a31d87..daecf86 100644 --- a/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Environment/Interfaces/IDynamicTextureManager.cs @@ -53,4 +53,4 @@ namespace OpenSim.Region.Environment.Interfaces bool AsyncConvertUrl(LLUUID id, string url, string extraParams); bool AsyncConvertData(LLUUID id, string bodyData, string extraParams); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs index 19cf131..0357139 100644 --- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs @@ -34,4 +34,4 @@ namespace OpenSim.Region.Environment.Interfaces { LLUUID MakeHttpRequest(string url, string type, string body); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs index 808b94a..e5d0b26 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs @@ -26,8 +26,8 @@ * */ -using OpenSim.Region.Environment.Scenes; using Nini.Config; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Interfaces { @@ -39,4 +39,4 @@ namespace OpenSim.Region.Environment.Interfaces string Name { get; } bool IsSharedModule { get; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/ISimChat.cs b/OpenSim/Region/Environment/Interfaces/ISimChat.cs index 7dc3e0b..fb491cc 100644 --- a/OpenSim/Region/Environment/Interfaces/ISimChat.cs +++ b/OpenSim/Region/Environment/Interfaces/ISimChat.cs @@ -26,12 +26,13 @@ * */ -using libsecondlife; +using System; +using OpenSim.Framework; namespace OpenSim.Region.Environment.Interfaces { public interface ISimChat { - void SimChat(System.Object sender, OpenSim.Framework.ChatFromViewerArgs e); + void SimChat(Object sender, ChatFromViewerArgs e); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/ITerrain.cs b/OpenSim/Region/Environment/Interfaces/ITerrain.cs index 77ec2dd..9171d09 100644 --- a/OpenSim/Region/Environment/Interfaces/ITerrain.cs +++ b/OpenSim/Region/Environment/Interfaces/ITerrain.cs @@ -26,7 +26,6 @@ * */ -using OpenSim.Framework.Interfaces; using OpenSim.Framework; namespace OpenSim.Region.Environment.Interfaces @@ -72,4 +71,4 @@ namespace OpenSim.Region.Environment.Interfaces void ExportImage(string filename, string gradientmap); byte[] ExportJpegImage(string gradientmap); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs index 9d8c259..27b5466 100644 --- a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs @@ -40,4 +40,4 @@ namespace OpenSim.Region.Environment.Interfaces void ListenControl(int handle, int active); void ListenRemove(int handle); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs b/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs index d888a36..6786b8c 100644 --- a/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs +++ b/OpenSim/Region/Environment/Interfaces/IXMLRPC.cs @@ -39,4 +39,4 @@ namespace OpenSim.Region.Environment.Interfaces RPCRequestInfo GetNextRequest(); void RemoteDataReply(string channel, string message_id, string sdata, int idata); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IXfer.cs b/OpenSim/Region/Environment/Interfaces/IXfer.cs index 3cbd549..5e5ff1b 100644 --- a/OpenSim/Region/Environment/Interfaces/IXfer.cs +++ b/OpenSim/Region/Environment/Interfaces/IXfer.cs @@ -32,4 +32,4 @@ namespace OpenSim.Region.Environment.Interfaces { bool AddNewFile(string fileName, byte[] data); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 3962e5f..e9837c0 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -30,7 +30,6 @@ using System; using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; @@ -652,4 +651,4 @@ namespace OpenSim.Region.Environment.LandManagement } #endregion -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index ae89d85..785aafa 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index c0dd52a..cb72638 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -27,15 +27,14 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Reflection; +using Nini.Config; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Scenes; -using Nini.Config; namespace OpenSim.Region.Environment { @@ -58,8 +57,8 @@ namespace OpenSim.Region.Environment { get { - IRegionModule[] regionModules = new IRegionModule[ m_loadedSharedModules.Count ]; - m_loadedSharedModules.Values.CopyTo( regionModules, 0 ); + IRegionModule[] regionModules = new IRegionModule[m_loadedSharedModules.Count]; + m_loadedSharedModules.Values.CopyTo(regionModules, 0); return regionModules; } } @@ -132,7 +131,7 @@ namespace OpenSim.Region.Environment if (modules.Length > 0) { - m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); + m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName); foreach (IRegionModule module in modules) { if (!module.IsSharedModule) @@ -179,16 +178,16 @@ namespace OpenSim.Region.Environment List modules = new List(); Assembly pluginAssembly; - if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) + if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly)) { try { pluginAssembly = Assembly.LoadFrom(dllName); LoadedAssemblys.Add(dllName, pluginAssembly); } - catch( BadImageFormatException e ) + catch (BadImageFormatException e) { - m_log.Verbose( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); + m_log.Verbose("MODULES", "The file [{0}] is not a module assembly.", e.FileName); } } @@ -201,7 +200,7 @@ namespace OpenSim.Region.Environment { if (!pluginType.IsAbstract) { - if( pluginType.GetInterface("IRegionModule") != null ) + if (pluginType.GetInterface("IRegionModule") != null) { modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); } @@ -231,4 +230,4 @@ namespace OpenSim.Region.Environment LoadedAssemblys.Clear(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs index e414713..54d5ad8 100644 --- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs @@ -26,11 +26,10 @@ * */ -using OpenSim.Framework.Interfaces; +using Nini.Config; +using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -70,4 +69,4 @@ namespace OpenSim.Region.Environment.Modules { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs index 456d838..4bb0638 100644 --- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; using Nini.Config; using OpenSim.Framework; @@ -11,7 +8,8 @@ namespace OpenSim.Region.Environment.Modules { public class AvatarFactoryModule : IAvatarFactory { - public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, out byte[] visualParams) + public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, + out byte[] visualParams) { GetDefaultAvatarAppearance(out wearables, out visualParams); return true; @@ -51,7 +49,4 @@ namespace OpenSim.Region.Environment.Modules wearables = AvatarWearable.DefaultWearables; } } - - - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs index 802655f..1b7e2a4 100644 --- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs @@ -27,11 +27,10 @@ */ using libsecondlife; -using OpenSim.Framework.Interfaces; +using Nini.Config; +using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -92,4 +91,4 @@ namespace OpenSim.Region.Environment.Modules partner); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index bdb8ee5..9d4187a 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -27,13 +27,13 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Net.Sockets; -using System.Threading; -using System.Collections.Generic; using System.Text.RegularExpressions; +using System.Threading; using libsecondlife; -using OpenSim.Framework.Interfaces; +using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; @@ -54,18 +54,22 @@ namespace OpenSim.Region.Environment.Modules public ChatModule() { - m_log = OpenSim.Framework.Console.MainLog.Instance; + m_log = MainLog.Instance; } - public void Initialise(Scene scene, Nini.Config.IConfigSource config) + public void Initialise(Scene scene, IConfigSource config) { // wrap this in a try block so that defaults will work if // the config file doesn't specify otherwise. - try { - m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); + try + { + m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); - } catch (Exception e) {} + } + catch (Exception e) + { + } if (!m_scenes.Contains(scene)) { @@ -73,20 +77,20 @@ namespace OpenSim.Region.Environment.Modules scene.EventManager.OnNewClient += NewClient; scene.RegisterModuleInterface(this); } - + // setup IRC Relay m_irc = new IRCChatModule(config); } public void PostInitialise() { - - if (m_irc.Enabled) { + if (m_irc.Enabled) + { m_irc.Connect(m_scenes); } } - public void Close() + public void Close() { m_irc.Close(); } @@ -111,7 +115,7 @@ namespace OpenSim.Region.Environment.Modules ScenePresence avatar = null; //TODO: Move ForEachScenePresence and others into IScene. - Scene scene = (Scene)e.Scene; + Scene scene = (Scene) e.Scene; //TODO: Remove the need for this check if (scene == null) @@ -119,10 +123,12 @@ namespace OpenSim.Region.Environment.Modules // Filled in since it's easier than rewriting right now. LLVector3 fromPos = e.Position; - LLVector3 fromRegionPos = e.Position + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0); + LLVector3 fromRegionPos = e.Position + + new LLVector3(e.Scene.RegionInfo.RegionLocX*256, e.Scene.RegionInfo.RegionLocY*256, + 0); string fromName = e.From; string message = e.Message; - byte type = (byte)e.Type; + byte type = (byte) e.Type; LLUUID fromAgentID = LLUUID.Zero; if (e.Sender != null) @@ -133,7 +139,8 @@ namespace OpenSim.Region.Environment.Modules if (avatar != null) { fromPos = avatar.AbsolutePosition; - fromRegionPos = fromPos + new LLVector3(e.Scene.RegionInfo.RegionLocX * 256, e.Scene.RegionInfo.RegionLocY * 256, 0); + fromRegionPos = fromPos + + new LLVector3(e.Scene.RegionInfo.RegionLocX*256, e.Scene.RegionInfo.RegionLocY*256, 0); fromName = avatar.Firstname + " " + avatar.Lastname; fromAgentID = e.Sender.AgentId; avatar = null; @@ -159,75 +166,84 @@ namespace OpenSim.Region.Environment.Modules break; } - m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message); - - if (m_irc.Connected) - { - m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message); - } - - if (e.Channel == 0) - { - foreach (Scene m_scene in m_scenes) - { - m_scene.ForEachScenePresence(delegate(ScenePresence presence) - { - int dis = -100000; - - LLVector3 avatarRegionPos = presence.AbsolutePosition + new LLVector3(scene.RegionInfo.RegionLocX * 256, scene.RegionInfo.RegionLocY * 256, 0); - dis = Math.Abs((int)avatarRegionPos.GetDistanceTo(fromRegionPos)); - - switch (e.Type) - { - case ChatTypeEnum.Whisper: - if (dis < m_whisperdistance) - { - //should change so the message is sent through the avatar rather than direct to the ClientView - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case ChatTypeEnum.Say: - if (dis < m_saydistance) - { - //Console.WriteLine("sending chat"); - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - case ChatTypeEnum.Shout: - if (dis < m_shoutdistance) - { - presence.ControllingClient.SendChatMessage(message, - type, - fromPos, - fromName, - fromAgentID); - } - break; - - case ChatTypeEnum.Broadcast: - presence.ControllingClient.SendChatMessage(message, type, - fromPos, - fromName, - fromAgentID); - break; - default: - break; - } - }); + m_log.Verbose("CHAT", + fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + + e.Message); + + if (m_irc.Connected) + { + m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message); + } + + if (e.Channel == 0) + { + foreach (Scene m_scene in m_scenes) + { + m_scene.ForEachScenePresence(delegate(ScenePresence presence) + { + int dis = -100000; + + LLVector3 avatarRegionPos = presence.AbsolutePosition + + new LLVector3( + scene.RegionInfo.RegionLocX*256, + scene.RegionInfo.RegionLocY*256, + 0); + dis = + Math.Abs((int) avatarRegionPos.GetDistanceTo(fromRegionPos)); + + switch (e.Type) + { + case ChatTypeEnum.Whisper: + if (dis < m_whisperdistance) + { + //should change so the message is sent through the avatar rather than direct to the ClientView + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case ChatTypeEnum.Say: + if (dis < m_saydistance) + { + //Console.WriteLine("sending chat"); + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + case ChatTypeEnum.Shout: + if (dis < m_shoutdistance) + { + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + } + break; + + case ChatTypeEnum.Broadcast: + presence.ControllingClient.SendChatMessage(message, + type, + fromPos, + fromName, + fromAgentID); + break; + default: + break; + } + }); } } } } - class IRCChatModule { + internal class IRCChatModule + { private string m_server = null; private int m_port = 6668; private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; @@ -238,7 +254,7 @@ namespace OpenSim.Region.Environment.Modules private TcpClient m_tcp; private StreamWriter m_writer; private StreamReader m_reader; - + private Thread pingSender; private Thread listener; @@ -248,29 +264,36 @@ namespace OpenSim.Region.Environment.Modules private List m_scenes = null; private LogBase m_log; - public IRCChatModule(Nini.Config.IConfigSource config) { + public IRCChatModule(IConfigSource config) + { m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); m_tcp = null; m_writer = null; m_reader = null; - try { + try + { m_server = config.Configs["IRC"].GetString("server"); m_nick = config.Configs["IRC"].GetString("nick"); m_channel = config.Configs["IRC"].GetString("channel"); m_port = config.Configs["IRC"].GetInt("port", m_port); m_user = config.Configs["IRC"].GetString("username", m_user); - if (m_server != null && m_nick != null && m_channel != null) { + if (m_server != null && m_nick != null && m_channel != null) + { m_enabled = true; } - } catch (Exception e) { + } + catch (Exception e) + { Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); } - m_log = OpenSim.Framework.Console.MainLog.Instance; + m_log = MainLog.Instance; } - public bool Connect(List scenes) { - try { + public bool Connect(List scenes) + { + try + { m_scenes = scenes; m_tcp = new TcpClient(m_server, m_port); @@ -279,13 +302,13 @@ namespace OpenSim.Region.Environment.Modules m_log.Verbose("IRC", "Connected to " + m_server); m_reader = new StreamReader(m_stream); m_writer = new StreamWriter(m_stream); - - pingSender = new Thread(new ThreadStart(this.PingRun)); + + pingSender = new Thread(new ThreadStart(PingRun)); pingSender.Start(); - - listener = new Thread(new ThreadStart(this.ListenerRun)); + + listener = new Thread(new ThreadStart(ListenerRun)); listener.Start(); - + m_writer.WriteLine(m_user); m_writer.Flush(); m_writer.WriteLine("NICK " + m_nick); @@ -294,50 +317,61 @@ namespace OpenSim.Region.Environment.Modules m_writer.Flush(); m_log.Verbose("IRC", "Connection fully established"); m_connected = true; - } catch (Exception e) { + } + catch (Exception e) + { Console.WriteLine(e.ToString()); } return m_connected; } - public bool Enabled + public bool Enabled { get { return m_enabled; } } - + public bool Connected { get { return m_connected; } } - public void PrivMsg(string from, string region, string msg) { - try { + public void PrivMsg(string from, string region, string msg) + { + try + { m_writer.WriteLine("PRIVMSG {0} :<{1} in {2}>: {3}", m_channel, from, region, msg); m_writer.Flush(); - } catch (IOException) { - m_log.Error("IRC","Disconnected from IRC server."); + } + catch (IOException) + { + m_log.Error("IRC", "Disconnected from IRC server."); listener.Abort(); pingSender.Abort(); m_connected = false; } } - private Dictionary ExtractMsg(string input) { + private Dictionary ExtractMsg(string input) + { Dictionary result = null; string regex = @":(?\w*)!~(?\S*) PRIVMSG (?\S+) :(?.*)"; Regex RE = new Regex(regex, RegexOptions.Multiline); MatchCollection matches = RE.Matches(input); // Get some direct matches $1 $4 is a - if ((matches.Count == 1) && (matches[0].Groups.Count == 5)) { + if ((matches.Count == 1) && (matches[0].Groups.Count == 5)) + { result = new Dictionary(); result.Add("nick", matches[0].Groups[1].Value); result.Add("user", matches[0].Groups[2].Value); result.Add("channel", matches[0].Groups[3].Value); result.Add("msg", matches[0].Groups[4].Value); - } else { + } + else + { m_log.Verbose("IRC", "Number of matches: " + matches.Count); - if (matches.Count > 0) { - m_log.Verbose("IRC", "Number of groups: " + matches[0].Groups.Count); + if (matches.Count > 0) + { + m_log.Verbose("IRC", "Number of groups: " + matches[0].Groups.Count); } } return result; @@ -365,19 +399,20 @@ namespace OpenSim.Region.Environment.Modules if (inputLine.Contains(m_channel)) { Dictionary data = ExtractMsg(inputLine); - if (data != null ) + if (data != null) { foreach (Scene m_scene in m_scenes) { m_scene.ForEachScenePresence(delegate(ScenePresence avatar) - { - if (!avatar.IsChildAgent) { - avatar.ControllingClient.SendChatMessage( - Helpers.StringToField(data["msg"]), 255, pos, data["nick"], - LLUUID.Zero); - } - }); + if (!avatar.IsChildAgent) + { + avatar.ControllingClient.SendChatMessage( + Helpers.StringToField(data["msg"]), 255, + pos, data["nick"], + LLUUID.Zero); + } + }); } } } @@ -387,7 +422,8 @@ namespace OpenSim.Region.Environment.Modules } - public void Close() { + public void Close() + { listener.Abort(); pingSender.Abort(); m_writer.Close(); @@ -395,4 +431,4 @@ namespace OpenSim.Region.Environment.Modules m_tcp.Close(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index 7c852dc..2bc3db8 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs @@ -29,10 +29,10 @@ using System; using System.Collections.Generic; using libsecondlife; +using Nini.Config; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -99,7 +99,7 @@ namespace OpenSim.Region.Environment.Modules if (RenderPlugins.ContainsKey(contentType)) { //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); - + DynamicTextureUpdater updater = new DynamicTextureUpdater(); updater.SimUUID = simID; updater.PrimID = primID; @@ -187,4 +187,4 @@ namespace OpenSim.Region.Environment.Modules } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/EmailModule.cs b/OpenSim/Region/Environment/Modules/EmailModule.cs index 00ea07a..046a46c 100644 --- a/OpenSim/Region/Environment/Modules/EmailModule.cs +++ b/OpenSim/Region/Environment/Modules/EmailModule.cs @@ -31,4 +31,4 @@ namespace OpenSim.Region.Environment.Modules internal class EmailModule { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs index 9144bee..d9f09f7 100644 --- a/OpenSim/Region/Environment/Modules/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs @@ -26,9 +26,9 @@ * */ +using Nini.Config; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -59,4 +59,4 @@ namespace OpenSim.Region.Environment.Modules get { return false; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs index 150f294..50e9a39 100644 --- a/OpenSim/Region/Environment/Modules/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs @@ -26,9 +26,9 @@ * */ +using Nini.Config; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -59,4 +59,4 @@ namespace OpenSim.Region.Environment.Modules get { return false; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index 9ac1d76..2ad027a 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs @@ -27,11 +27,12 @@ */ using System.Collections.Generic; +using libsecondlife; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Console; -using OpenSim.Framework; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -42,7 +43,7 @@ namespace OpenSim.Region.Environment.Modules public InstantMessageModule() { - m_log = OpenSim.Framework.Console.MainLog.Instance; + m_log = MainLog.Instance; } public void Initialise(Scene scene, IConfigSource config) @@ -50,33 +51,34 @@ namespace OpenSim.Region.Environment.Modules if (!m_scenes.Contains(scene)) { m_scenes.Add(scene); - scene.EventManager.OnNewClient += OnNewClient; + scene.EventManager.OnNewClient += OnNewClient; } } - void OnNewClient(OpenSim.Framework.IClientAPI client) + private void OnNewClient(IClientAPI client) { client.OnInstantMessage += OnInstantMessage; } - void OnInstantMessage(libsecondlife.LLUUID fromAgentID, - libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID, - libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName, - string message, byte dialog) + private void OnInstantMessage(LLUUID fromAgentID, + LLUUID fromAgentSession, LLUUID toAgentID, + LLUUID imSessionID, uint timestamp, string fromAgentName, + string message, byte dialog) { // TODO: Remove after debugging. Privacy implications. - m_log.Verbose("IM",fromAgentName + ": " + message); + m_log.Verbose("IM", fromAgentName + ": " + message); foreach (Scene m_scene in m_scenes) { if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) { // Local Message - ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; + ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID]; if (!user.IsChildAgent) { user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, - toAgentID, imSessionID, fromAgentName, dialog, timestamp); + toAgentID, imSessionID, fromAgentName, dialog, + timestamp); } // Message sent return; @@ -104,4 +106,4 @@ namespace OpenSim.Region.Environment.Modules get { return true; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/InventoryModule.cs index 3f8cd6e..e2ad0d5 100644 --- a/OpenSim/Region/Environment/Modules/InventoryModule.cs +++ b/OpenSim/Region/Environment/Modules/InventoryModule.cs @@ -26,9 +26,9 @@ * */ +using Nini.Config; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -59,4 +59,4 @@ namespace OpenSim.Region.Environment.Modules get { return false; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs index 8b8b386..9d10fc3 100644 --- a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs @@ -1,18 +1,16 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Net; -using System.IO; using System.Drawing; +using System.IO; +using System.Net; using libsecondlife; +using Nini.Config; using OpenJPEGNet; -using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Interfaces; -using Nini.Config; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules { - public class LoadImageURLModule : IRegionModule , IDynamicTextureRender + public class LoadImageURLModule : IRegionModule, IDynamicTextureRender { private string m_name = "LoadImageURL"; private IDynamicTextureManager m_textureManager; @@ -85,25 +83,25 @@ namespace OpenSim.Region.Environment.Modules private void MakeHttpRequest(string url, LLUUID requestID) { WebRequest request = HttpWebRequest.Create(url); - RequestState state = new RequestState((HttpWebRequest)request, requestID); + RequestState state = new RequestState((HttpWebRequest) request, requestID); IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); - state.TimeOfRequest = (int)t.TotalSeconds; + state.TimeOfRequest = (int) t.TotalSeconds; } private void HttpRequestReturn(IAsyncResult result) { - RequestState state = (RequestState)result.AsyncState; - WebRequest request = (WebRequest)state.Request; - HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); + RequestState state = (RequestState) result.AsyncState; + WebRequest request = (WebRequest) state.Request; + HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(result); if (response.StatusCode == HttpStatusCode.OK) { - Bitmap image = new Bitmap(response.GetResponseStream()); - Bitmap resize = new Bitmap(image, new Size(512, 512)); - byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); + Bitmap image = new Bitmap(response.GetResponseStream()); + Bitmap resize = new Bitmap(image, new Size(512, 512)); + byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); - m_textureManager.ReturnData(state.RequestID, imageJ2000); + m_textureManager.ReturnData(state.RequestID, imageJ2000); } } @@ -119,6 +117,5 @@ namespace OpenSim.Region.Environment.Modules RequestID = requestID; } } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index 9412089..5ac0b39 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -31,4 +31,4 @@ namespace OpenSim.Region.Environment.Modules internal class ScriptsHttpRequests { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/TeleportModule.cs b/OpenSim/Region/Environment/Modules/TeleportModule.cs index d22a722..77f8db2 100644 --- a/OpenSim/Region/Environment/Modules/TeleportModule.cs +++ b/OpenSim/Region/Environment/Modules/TeleportModule.cs @@ -31,4 +31,4 @@ namespace OpenSim.Region.Environment.Modules internal class TeleportModule { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 5eeeca6..66c499b 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -27,14 +27,12 @@ */ using System; using System.Collections.Generic; -using System.Threading; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; +using Nini.Config; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -42,17 +40,19 @@ namespace OpenSim.Region.Environment.Modules { private Scene m_scene; private List m_scenes = new List(); - private Dictionary> ClientRequests = new Dictionary>(); + + private Dictionary> ClientRequests = + new Dictionary>(); private BlockingQueue QueueSenders = new BlockingQueue(); private Dictionary> InProcess = new Dictionary>(); - // private Thread m_thread; + // private Thread m_thread; public TextureDownloadModule() { - // m_thread = new Thread(new ThreadStart(ProcessTextureSenders)); - // m_thread.IsBackground = true; - // m_thread.Start(); + // m_thread = new Thread(new ThreadStart(ProcessTextureSenders)); + // m_thread.IsBackground = true; + // m_thread.Start(); } public void Initialise(Scene scene, IConfigSource config) @@ -85,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules public void NewClient(IClientAPI client) { - /* lock (ClientRequests) + /* lock (ClientRequests) { if (!ClientRequests.ContainsKey(client.AgentId)) { @@ -120,7 +120,7 @@ namespace OpenSim.Region.Environment.Modules public void TextureRequest(Object sender, TextureRequestArgs e) { - IClientAPI client = (IClientAPI)sender; + IClientAPI client = (IClientAPI) sender; if (!ClientRequests[client.AgentId].ContainsKey(e.RequestedAssetID)) { lock (ClientRequests) @@ -136,15 +136,15 @@ namespace OpenSim.Region.Environment.Modules { while (true) { - TextureSender sender = this.QueueSenders.Dequeue(); + TextureSender sender = QueueSenders.Dequeue(); bool finished = sender.SendTexture(); if (finished) { - this.TextureSent(sender); + TextureSent(sender); } else { - this.QueueSenders.Enqueue(sender); + QueueSenders.Enqueue(sender); } } } @@ -173,13 +173,13 @@ namespace OpenSim.Region.Environment.Modules if (asset.Data.LongLength > 600) { - NumPackets = 2 + (int)(asset.Data.Length - 601) / 1000; + NumPackets = 2 + (int) (asset.Data.Length - 601)/1000; } else { NumPackets = 1; } - + PacketCounter = (int) req.PacketNumber; } @@ -205,7 +205,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; req.RequestUser.OutPacket(im); @@ -215,9 +215,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; @@ -229,18 +229,16 @@ 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]; - 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); req.RequestUser.OutPacket(im); - PacketCounter++; + PacketCounter++; } - } - } public class AssetRequest @@ -258,6 +256,5 @@ namespace OpenSim.Region.Environment.Modules PacketNumber = packetNumber; } } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index a697162..7a631d7 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs @@ -27,20 +27,12 @@ */ using System; -using System.IO; -using System.Net.Sockets; -using System.Text; -using System.Threading; +using System.Collections.Generic; using libsecondlife; -using OpenSim.Framework.Interfaces; +using Nini.Config; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Servers; -using Nwc.XmlRpc; -using System.Collections; -using System.Collections.Generic; -using Nini.Config; /***************************************************** * @@ -71,6 +63,7 @@ using Nini.Config; * thats the way it works. * * **************************************************/ + namespace OpenSim.Region.Environment.Modules { public class WorldCommModule : IRegionModule, IWorldComm @@ -120,9 +113,9 @@ namespace OpenSim.Region.Environment.Modules private void DeliverClientMessage(Object sender, ChatFromViewerArgs e) { DeliverMessage(e.Sender.AgentId.ToString(), - (int)e.Type, e.Channel, - e.Sender.FirstName + " " + e.Sender.LastName, - e.Message); + (int) e.Type, e.Channel, + e.Sender.FirstName + " " + e.Sender.LastName, + e.Message); } public int Listen(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) @@ -132,11 +125,10 @@ namespace OpenSim.Region.Environment.Modules public void ListenControl(int handle, int active) { - if ( active == 1 ) + if (active == 1) m_listenerManager.Activate(handle); - else if ( active == 0 ) + else if (active == 0) m_listenerManager.Dectivate(handle); - } public void ListenRemove(int handle) @@ -151,7 +143,6 @@ namespace OpenSim.Region.Environment.Modules // nearby avatards, the SimChat function is used. public void DeliverMessage(string sourceItemID, int type, int channel, string name, string msg) { - SceneObjectPart source = null; ScenePresence avatar = null; @@ -160,7 +151,7 @@ namespace OpenSim.Region.Environment.Modules { avatar = m_scene.GetScenePresence(new LLUUID(sourceItemID)); } - if( (avatar != null) || (source != null) ) + if ((avatar != null) || (source != null)) { // Loop through the objects in the scene // If they are in proximity, then if they are @@ -169,12 +160,12 @@ namespace OpenSim.Region.Environment.Modules foreach (LLUUID eb in m_scene.Entities.Keys) { EntityBase sPart; - + m_scene.Entities.TryGetValue(eb, out sPart); // Dont process if this message is from itself! if (eb.ToString().Equals(sourceItemID) || - sPart.UUID.ToString().Equals(sourceItemID) ) + sPart.UUID.ToString().Equals(sourceItemID)) continue; double dis = 0; @@ -192,12 +183,11 @@ namespace OpenSim.Region.Environment.Modules { ListenerInfo isListener = m_listenerManager.IsListenerMatch( sourceItemID, sPart.UUID, channel, name, msg - ); + ); if (isListener != null) { m_pending.Enqueue(isListener); } - } break; @@ -207,12 +197,11 @@ namespace OpenSim.Region.Environment.Modules { ListenerInfo isListener = m_listenerManager.IsListenerMatch( sourceItemID, sPart.UUID, channel, name, msg - ); + ); if (isListener != null) { m_pending.Enqueue(isListener); } - } break; @@ -221,22 +210,22 @@ namespace OpenSim.Region.Environment.Modules { ListenerInfo isListener = m_listenerManager.IsListenerMatch( sourceItemID, sPart.UUID, channel, name, msg - ); + ); if (isListener != null) { m_pending.Enqueue(isListener); } - } break; case 0xff: // Broadcast - ListenerInfo isListen = m_listenerManager.IsListenerMatch(sourceItemID, eb, channel, name, msg); + ListenerInfo isListen = + m_listenerManager.IsListenerMatch(sourceItemID, eb, channel, name, msg); if (isListen != null) { ListenerInfo isListener = m_listenerManager.IsListenerMatch( sourceItemID, sPart.UUID, channel, name, msg - ); + ); if (isListener != null) { m_pending.Enqueue(isListener); @@ -244,10 +233,9 @@ namespace OpenSim.Region.Environment.Modules } break; } - }; - + } + ; } - } public bool HasMessages() @@ -257,18 +245,15 @@ namespace OpenSim.Region.Environment.Modules public ListenerInfo GetNextMessage() { - ListenerInfo li = null; lock (CommListLock) { - li = m_pending.Dequeue(); + li = m_pending.Dequeue(); } return li; - } - } // hostID: the ID of the ScenePart @@ -285,20 +270,19 @@ namespace OpenSim.Region.Environment.Modules m_listeners = new Dictionary(); } - public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) + public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, + string msg) { - - if ( m_listeners.Count < m_MaxListeners ) + if (m_listeners.Count < m_MaxListeners) { ListenerInfo isListener = IsListenerMatch(LLUUID.Zero.ToString(), itemID, channel, name, msg); - if(isListener == null) + if (isListener == null) { int newHandle = GetNewHandle(); if (newHandle > -1) { - ListenerInfo li = new ListenerInfo(localID, newHandle, itemID, hostID, channel, name, id, msg); lock (ListenersLock) @@ -308,13 +292,10 @@ namespace OpenSim.Region.Environment.Modules return newHandle; } - } - } return -1; - } public void Remove(int handle) @@ -324,7 +305,6 @@ namespace OpenSim.Region.Environment.Modules private int GetNewHandle() { - for (int i = 0; i < int.MaxValue - 1; i++) { if (!m_listeners.ContainsKey(i)) @@ -332,12 +312,10 @@ namespace OpenSim.Region.Environment.Modules } return -1; - } public bool IsListener(LLUUID hostID) { - foreach (ListenerInfo li in m_listeners.Values) { if (li.GetHostID().Equals(hostID)) @@ -345,15 +323,13 @@ namespace OpenSim.Region.Environment.Modules } return false; - } public void Activate(int handle) { - ListenerInfo li; - if( m_listeners.TryGetValue(handle, out li) ) + if (m_listeners.TryGetValue(handle, out li)) { li.Activate(); } @@ -361,10 +337,9 @@ namespace OpenSim.Region.Environment.Modules public void Dectivate(int handle) { - ListenerInfo li; - if( m_listeners.TryGetValue(handle, out li) ) + if (m_listeners.TryGetValue(handle, out li)) { li.Deactivate(); } @@ -372,40 +347,40 @@ namespace OpenSim.Region.Environment.Modules // Theres probably a more clever and efficient way to // do this, maybe with regex. - public ListenerInfo IsListenerMatch(string sourceItemID, LLUUID listenerKey, int channel, string name, string msg) + public ListenerInfo IsListenerMatch(string sourceItemID, LLUUID listenerKey, int channel, string name, + string msg) { - bool isMatch = true; foreach (ListenerInfo li in m_listeners.Values) { if (li.GetHostID().Equals(listenerKey)) { - if ( li.IsActive() ) + if (li.IsActive()) { - if ( channel == li.GetChannel() ) + if (channel == li.GetChannel()) { - if ( (li.GetID().ToString().Length > 0) && - (!li.GetID().Equals(LLUUID.Zero)) ) + if ((li.GetID().ToString().Length > 0) && + (!li.GetID().Equals(LLUUID.Zero))) { if (!li.GetID().ToString().Equals(sourceItemID)) { isMatch = false; } } - if ( isMatch && (li.GetName().Length > 0) ) + if (isMatch && (li.GetName().Length > 0)) { - if ( li.GetName().Equals(name) ) + if (li.GetName().Equals(name)) { isMatch = false; } } - if ( isMatch ) + if (isMatch) { return new ListenerInfo( li.GetLocalID(), li.GetHandle(), li.GetItemID(), li.GetHostID(), li.GetChannel(), name, li.GetID(), msg, new LLUUID(sourceItemID) - ); + ); } } } @@ -413,35 +388,36 @@ namespace OpenSim.Region.Environment.Modules } return null; } - } public class ListenerInfo { - - private LLUUID m_itemID; // ID of the host script engine - private LLUUID m_hostID; // ID of the host/scene part - private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message - private int m_channel; // Channel - private int m_handle; // Assigned handle of this listener - private uint m_localID; // Local ID from script engine - private string m_name; // Object name to filter messages from - private LLUUID m_id; // ID to filter messages from - private string m_message; // The message - private bool m_active; // Listener is active or not - - public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message) + private LLUUID m_itemID; // ID of the host script engine + private LLUUID m_hostID; // ID of the host/scene part + private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message + private int m_channel; // Channel + private int m_handle; // Assigned handle of this listener + private uint m_localID; // Local ID from script engine + private string m_name; // Object name to filter messages from + private LLUUID m_id; // ID to filter messages from + private string m_message; // The message + private bool m_active; // Listener is active or not + + public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, + string message) { Initialise(localID, handle, ItemID, hostID, channel, name, id, message); } - public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message, LLUUID sourceItemID) + public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, + string message, LLUUID sourceItemID) { Initialise(localID, handle, ItemID, hostID, channel, name, id, message); m_sourceItemID = sourceItemID; } - private void Initialise(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message) + private void Initialise(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, + LLUUID id, string message) { m_handle = handle; m_channel = channel; @@ -453,55 +429,65 @@ namespace OpenSim.Region.Environment.Modules m_active = true; m_localID = localID; } + public LLUUID GetItemID() { return m_itemID; } + public LLUUID GetHostID() { return m_hostID; } + public LLUUID GetSourceItemID() { return m_sourceItemID; } + public int GetChannel() { return m_channel; } + public uint GetLocalID() { return m_localID; } + public int GetHandle() { return m_handle; } + public string GetMessage() { return m_message; } + public string GetName() { return m_name; } + public bool IsActive() { return m_active; } + public void Deactivate() { m_active = false; } + public void Activate() { m_active = true; } + public LLUUID GetID() { 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 dd84778..434c92f 100644 --- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs @@ -26,20 +26,15 @@ * */ -using System; -using System.IO; -using System.Net.Sockets; +using System.Collections; +using System.Collections.Generic; using System.Threading; using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; +using Nini.Config; +using Nwc.XmlRpc; +using OpenSim.Framework.Servers; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Servers; -using Nwc.XmlRpc; -using System.Collections; -using System.Collections.Generic; -using Nini.Config; /***************************************************** * @@ -73,6 +68,7 @@ using Nini.Config; * llCloseRemoteDataChannel * * **************************************************/ + namespace OpenSim.Region.Environment.Modules { public class XMLRPCModule : IRegionModule, IXMLRPC @@ -83,7 +79,7 @@ namespace OpenSim.Region.Environment.Modules private string m_name = "XMLRPCModule"; private int RemoteReplyScriptWait = 100; private int RemoteReplyScriptTimeout = 300; - + // private Dictionary m_openChannels; @@ -106,7 +102,7 @@ namespace OpenSim.Region.Environment.Modules // Start http server // Attach xmlrpc handlers BaseHttpServer httpServer = new BaseHttpServer(20800); - httpServer.AddXmlRPCHandler("llRemoteData", this.XmlRpcRemoteData); + httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); httpServer.Start(); } @@ -141,6 +137,7 @@ namespace OpenSim.Region.Environment.Modules * current channel and assign a new one. * * ********************************************/ + public LLUUID OpenXMLRPCChannel(uint localID, LLUUID itemID) { LLUUID channel = null; @@ -156,7 +153,7 @@ namespace OpenSim.Region.Environment.Modules } } - if ( (channel == null) || (channel.Equals(LLUUID.Zero)) ) + if ((channel == null) || (channel.Equals(LLUUID.Zero))) { channel = LLUUID.Random(); RPCChannelInfo rpcChanInfo = new RPCChannelInfo(localID, itemID, channel); @@ -164,7 +161,6 @@ namespace OpenSim.Region.Environment.Modules { m_openChannels.Add(channel, rpcChanInfo); } - } return channel; @@ -176,6 +172,7 @@ namespace OpenSim.Region.Environment.Modules * Response to RPC message * *********************************************/ + public void RemoteDataReply(string channel, string message_id, string sdata, int idata) { RPCRequestInfo rpcInfo; @@ -191,7 +188,6 @@ namespace OpenSim.Region.Environment.Modules m_pendingResponse.Remove(message_key); } } - } /********************************************** @@ -200,41 +196,44 @@ namespace OpenSim.Region.Environment.Modules * Remove channel from dictionary * *********************************************/ + public void CloseXMLRPCChannel(LLUUID channelKey) { - if(m_openChannels.ContainsKey(channelKey)) + if (m_openChannels.ContainsKey(channelKey)) m_openChannels.Remove(channelKey); } public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request) { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") && requestData.Contains("StringValue")); + Hashtable requestData = (Hashtable) request.Params[0]; + bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") && + requestData.Contains("StringValue")); if (GoodXML) { - LLUUID channel = new LLUUID((string)requestData["Channel"]); + LLUUID channel = new LLUUID((string) requestData["Channel"]); RPCChannelInfo rpcChanInfo; if (m_openChannels.TryGetValue(channel, out rpcChanInfo)) { - string intVal = (string)requestData["IntValue"]; - string strVal = (string)requestData["StringValue"]; + string intVal = (string) requestData["IntValue"]; + string strVal = (string) requestData["StringValue"]; RPCRequestInfo rpcInfo; lock (XMLRPCListLock) { - rpcInfo = new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal, intVal); + rpcInfo = + new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal, + intVal); rpcQueue.Enqueue(rpcInfo); } int timeoutCtr = 0; - while(!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout)) + while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout)) { Thread.Sleep(RemoteReplyScriptWait); timeoutCtr += RemoteReplyScriptWait; @@ -252,13 +251,11 @@ namespace OpenSim.Region.Environment.Modules m_pendingResponse.Remove(rpcInfo.GetMessageID()); } } - } else { response.SetFault(-1, "Invalid channel"); } - } return response; @@ -278,7 +275,6 @@ namespace OpenSim.Region.Environment.Modules return rpcInfo; } } - } /************************************************************** @@ -288,6 +284,7 @@ namespace OpenSim.Region.Environment.Modules * Holds details about incoming requests until they are picked * from the queue by LSLLongCmdHandler * ***********************************************************/ + public class RPCRequestInfo { private string m_StrVal; @@ -315,6 +312,7 @@ namespace OpenSim.Region.Environment.Modules { return m_processed; } + public LLUUID GetChannelKey() { return m_ChannelKey; @@ -324,36 +322,41 @@ namespace OpenSim.Region.Environment.Modules { m_processed = processed; } + public void SetRetval(string resp) { m_resp = resp; } + public string GetRetval() { return m_resp; } + public uint GetLocalID() { return m_localID; } + public LLUUID GetItemID() { return m_ItemID; } + public string GetStrVal() { return m_StrVal; } + public int GetIntValue() { return int.Parse(m_IntVal); } + public LLUUID GetMessageID() { return m_MessageID; } - - } public class RPCChannelInfo @@ -383,7 +386,5 @@ namespace OpenSim.Region.Environment.Modules { return m_localID; } - } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs index e555475..807b46c 100644 --- a/OpenSim/Region/Environment/Modules/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/XferModule.cs @@ -29,11 +29,10 @@ using System; using System.Collections.Generic; using libsecondlife; -using OpenSim.Framework.Interfaces; +using Nini.Config; +using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework; -using Nini.Config; namespace OpenSim.Region.Environment.Modules { @@ -200,4 +199,4 @@ namespace OpenSim.Region.Environment.Modules } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 63285dc..fd55833 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -29,7 +29,6 @@ using libsecondlife; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework; namespace OpenSim.Region.Environment { @@ -337,4 +336,4 @@ namespace OpenSim.Region.Environment #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index 767a740..b8bae57 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -146,4 +146,4 @@ namespace OpenSim.Region.Environment.Scenes public abstract void SetText(string text, Vector3 color, double alpha); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs index 14a1c7e..0f3bca1 100644 --- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs +++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs @@ -29,7 +29,6 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Interfaces; namespace OpenSim.Region.Environment.Scenes { @@ -40,4 +39,4 @@ namespace OpenSim.Region.Environment.Scenes void SendOurAppearance(IClientAPI OurClient); void SendAppearanceToOtherAgent(ScenePresence avatarInfo); } -} +} \ 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 68591d4..a0c9a50 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -29,9 +29,8 @@ using Axiom.Math; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes @@ -45,7 +44,7 @@ namespace OpenSim.Region.Environment.Scenes { ScenePresence avatar; - if ( TryGetAvatar( avatarId, out avatar )) + if (TryGetAvatar(avatarId, out avatar)) { AddInventoryItem(avatar.ControllingClient, item); } @@ -392,7 +391,7 @@ namespace OpenSim.Region.Environment.Scenes remoteClient.SendInventoryItemUpdate(item); } - DeleteSceneObjectGroup((SceneObjectGroup)selectedEnt); + DeleteSceneObjectGroup((SceneObjectGroup) selectedEnt); } } } @@ -471,4 +470,4 @@ namespace OpenSim.Region.Environment.Scenes } } } -} +} \ 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 3a35e21..69bd310 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -28,9 +28,8 @@ using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -73,12 +72,12 @@ namespace OpenSim.Region.Environment.Scenes { ChatFromViewerArgs args = new ChatFromViewerArgs(); - args.Message = OpenSim.Framework.Util.FieldToString(message); + args.Message = Util.FieldToString(message); args.Channel = channel; - args.Type = (ChatTypeEnum)type; + args.Type = (ChatTypeEnum) type; args.Position = fromPos; - ScenePresence user = this.GetScenePresence(fromAgentID); + ScenePresence user = GetScenePresence(fromAgentID); if (user != null) args.Sender = user.ControllingClient; else @@ -488,10 +487,7 @@ namespace OpenSim.Region.Environment.Scenes public void StartAnimation(LLUUID animID, int seq, LLUUID agentId) { - Broadcast(delegate(IClientAPI client) - { - client.SendAnimation(animID, seq, agentId); - }); + Broadcast(delegate(IClientAPI client) { client.SendAnimation(animID, seq, agentId); }); } public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) @@ -503,14 +499,14 @@ namespace OpenSim.Region.Environment.Scenes if (ent is SceneObjectGroup) { SceneObjectGroup obj = ent as SceneObjectGroup; - - if( obj.HasChildPrim( localID ) ) + + if (obj.HasChildPrim(localID)) { obj.ObjectGrabHandler(localID, offsetPos, remoteClient); return; - } + } } } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b54c25b..db4d230 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -26,9 +26,9 @@ * */ using System; -using System.Net; using System.Collections.Generic; using System.IO; +using System.Net; using System.Threading; using System.Timers; using System.Xml; @@ -38,17 +38,16 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; 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 OpenSim.Region.Environment.Modules; +using Timer=System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { @@ -130,6 +129,7 @@ namespace OpenSim.Region.Environment.Scenes private readonly EstateManager m_estateManager; private PhysicsScene phyScene; + public PhysicsScene PhysScene { set { phyScene = value; } @@ -199,7 +199,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneObjects = new Dictionary(); MainLog.Instance.Verbose("Creating LandMap"); - Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); + Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); ScenePresence.LoadAnims(); @@ -233,7 +233,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); } @@ -267,33 +267,33 @@ 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) UpdatePreparePhysics(); - if (m_frame % m_update_entitymovement == 0) + if (m_frame%m_update_entitymovement == 0) UpdateEntityMovement(); - if (m_frame % m_update_physics == 0) + if (m_frame%m_update_physics == 0) UpdatePhysics( Math.Max(SinceLastFrame.TotalSeconds, m_timespan) ); - if (m_frame % m_update_entities == 0) + if (m_frame%m_update_entities == 0) 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) + if (m_frame%m_update_avatars == 0) UpdateInWorldTime(); } catch (NotImplementedException) @@ -308,7 +308,7 @@ 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; } } @@ -369,24 +369,23 @@ namespace OpenSim.Region.Environment.Scenes phyScene.SetTerrain(Terrain.GetHeights1D()); } - storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(),RegionInfo.RegionID); + storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID); float[] terData = Terrain.GetHeights1D(); Broadcast(delegate(IClientAPI client) - { - for (int x = 0; x < 16; x++) - { - for (int y = 0; y < 16; y++) - { - if (Terrain.Tainted(x * 16, y * 16)) - { - client.SendLayerData(x, y, terData); - } - } - } - }); - + { + for (int x = 0; x < 16; x++) + { + for (int y = 0; y < 16; y++) + { + if (Terrain.Tainted(x*16, y*16)) + { + client.SendLayerData(x, y, terData); + } + } + } + }); Terrain.ResetTaint(); @@ -418,7 +417,7 @@ namespace OpenSim.Region.Environment.Scenes { lock (m_syncRoot) { - phyScene.Simulate((float)elapsed); + phyScene.Simulate((float) elapsed); } } @@ -438,11 +437,9 @@ namespace OpenSim.Region.Environment.Scenes /// internal void Broadcast(Action whatToDo) { - ForEachScenePresence(delegate(ScenePresence presence) - { - whatToDo(presence.ControllingClient); - }); + ForEachScenePresence(delegate(ScenePresence presence) { whatToDo(presence.ControllingClient); }); } + /// /// /// @@ -473,7 +470,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Verbose("TERRAIN", "No default terrain. Generating a new terrain."); Terrain.HillsGenerator(); - storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(),RegionInfo.RegionID); + storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID); } else { @@ -484,7 +481,8 @@ namespace OpenSim.Region.Environment.Scenes } catch { - MainLog.Instance.Verbose("TERRAIN", "No terrain found in database or default. Generating a new terrain."); + MainLog.Instance.Verbose("TERRAIN", + "No terrain found in database or default. Generating a new terrain."); Terrain.HillsGenerator(); } storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID); @@ -535,7 +533,7 @@ namespace OpenSim.Region.Environment.Scenes { AddEntityFromStorage(prim); SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrimShape( rootPart.Name, rootPart.Shape, @@ -581,17 +579,17 @@ namespace OpenSim.Region.Environment.Scenes // if grass or tree, make phantom if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255)) { - rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; + rootPart.ObjectFlags += (uint) LLObject.ObjectFlags.Phantom; } // if not phantom, add to physics - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrimShape( - rootPart.Name, - rootPart.Shape, - new PhysicsVector(pos.X, pos.Y, pos.Z), - new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), - new Quaternion()); + rootPart.Name, + rootPart.Shape, + new PhysicsVector(pos.X, pos.Y, pos.Z), + new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), + new Quaternion()); } } @@ -601,9 +599,9 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - if (((SceneObjectGroup)obj).LocalId == localID) + if (((SceneObjectGroup) obj).LocalId == localID) { - RemoveEntity((SceneObjectGroup)obj); + RemoveEntity((SceneObjectGroup) obj); return; } } @@ -657,7 +655,6 @@ namespace OpenSim.Region.Environment.Scenes int primCount = 0; if ((fileName.StartsWith("http:")) | (File.Exists(fileName))) { - XmlTextReader reader = new XmlTextReader(fileName); reader.WhitespaceHandling = WhitespaceHandling.None; doc.Load(reader); @@ -672,7 +669,7 @@ namespace OpenSim.Region.Environment.Scenes AddEntity(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrimShape( rootPart.Name, rootPart.Shape, @@ -700,7 +697,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); primCount++; } } @@ -737,7 +734,7 @@ namespace OpenSim.Region.Environment.Scenes AddEntityFromStorage(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrimShape( rootPart.Name, rootPart.Shape, @@ -758,7 +755,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2()); primCount++; } } @@ -857,7 +854,8 @@ namespace OpenSim.Region.Environment.Scenes byte[] visualParams; AvatarWearable[] wearables; - if( m_AvatarFactory == null || !m_AvatarFactory.TryGetIntialAvatarAppearance( client.AgentId, out wearables, out visualParams)) + if (m_AvatarFactory == null || + !m_AvatarFactory.TryGetIntialAvatarAppearance(client.AgentId, out wearables, out visualParams)) { AvatarFactoryModule.GetDefaultAvatarAppearance(out wearables, out visualParams); } @@ -916,16 +914,10 @@ namespace OpenSim.Region.Environment.Scenes ScenePresence avatar = GetScenePresence(agentID); - Broadcast(delegate(IClientAPI client) - { - client.SendKillObject(avatar.RegionHandle, avatar.LocalId); - }); + Broadcast(delegate(IClientAPI client) { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); }); ForEachScenePresence( - delegate(ScenePresence presence) - { - presence.CoarseLocationChange(); - }); + delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); lock (m_scenePresences) { @@ -965,10 +957,8 @@ namespace OpenSim.Region.Environment.Scenes public List GetAvatars() { - List result = GetScenePresences(delegate(ScenePresence scenePresence) - { - return !scenePresence.IsChildAgent; - }); + List result = + GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; }); return result; } @@ -1046,18 +1036,12 @@ namespace OpenSim.Region.Environment.Scenes public void SendKillObject(uint localID) { - Broadcast(delegate(IClientAPI client) - { - client.SendKillObject(m_regionHandle, localID); - }); + Broadcast(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); } public void NotifyMyCoarseLocationChange() { - ForEachScenePresence(delegate(ScenePresence presence) - { - presence.CoarseLocationChange(); - }); + ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); } public void SendAllSceneObjectsToClient(ScenePresence presence) @@ -1067,7 +1051,7 @@ namespace OpenSim.Region.Environment.Scenes if (ent is SceneObjectGroup) { // ((SceneObjectGroup)ent).SendFullUpdateToClient(client); - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); } } } @@ -1137,11 +1121,12 @@ namespace OpenSim.Region.Environment.Scenes } } - delegate void InformClientOfNeighbourDelegate(IClientAPI remoteClient, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); + private delegate void InformClientOfNeighbourDelegate( + IClientAPI remoteClient, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); private void InformClientOfNeighbourCompleted(IAsyncResult iar) { - InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; + InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState; icon.EndInvoke(iar); @@ -1157,7 +1142,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - private void InformClientOfNeighbourAsync(IClientAPI remoteClient, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint) + private void InformClientOfNeighbourAsync(IClientAPI remoteClient, AgentCircuitData a, ulong regionHandle, + IPEndPoint endPoint) { MainLog.Instance.Notice("INTERGRID", "Starting to inform client about neighbours"); bool regionAccepted = commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, a); @@ -1172,7 +1158,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void InformClientOfNeighbours(IClientAPI remoteClient) { - List neighbours = commsManager.GridService.RequestNeighbours(m_regInfo.RegionLocX, m_regInfo.RegionLocY); + List neighbours = + commsManager.GridService.RequestNeighbours(m_regInfo.RegionLocX, m_regInfo.RegionLocY); if (neighbours != null) { for (int i = 0; i < neighbours.Count; i++) @@ -1185,9 +1172,8 @@ namespace OpenSim.Region.Environment.Scenes InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; d.BeginInvoke(remoteClient, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint, - InformClientOfNeighbourCompleted, - d); - + InformClientOfNeighbourCompleted, + d); } } } @@ -1289,17 +1275,17 @@ namespace OpenSim.Region.Environment.Scenes public void RegisterModuleInterface(M mod) { - if (!ModuleInterfaces.ContainsKey(typeof(M))) + if (!ModuleInterfaces.ContainsKey(typeof (M))) { - ModuleInterfaces.Add(typeof(M), mod); + ModuleInterfaces.Add(typeof (M), mod); } } public T RequestModuleInterface() { - if (ModuleInterfaces.ContainsKey(typeof(T))) + if (ModuleInterfaces.ContainsKey(typeof (T))) { - return (T)ModuleInterfaces[typeof(T)]; + return (T) ModuleInterfaces[typeof (T)]; } else { @@ -1317,7 +1303,8 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(avatarID)) { - m_scenePresences[avatarID].ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, message, url); + m_scenePresences[avatarID].ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, + message, url); } } @@ -1388,7 +1375,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); + ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); } } } @@ -1400,7 +1387,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 == cmmdparams[0]) @@ -1429,14 +1416,14 @@ namespace OpenSim.Region.Environment.Scenes foreach (ScenePresence scenePrescence in GetAvatars()) { MainLog.Instance.Error( - String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", - scenePrescence.Firstname, - scenePrescence.Lastname, - scenePrescence.UUID, - scenePrescence.ControllingClient.AgentId, - "Unknown", - "Unknown", - RegionInfo.RegionName)); + String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", + scenePrescence.Firstname, + scenePrescence.Lastname, + scenePrescence.UUID, + scenePrescence.ControllingClient.AgentId, + "Unknown", + "Unknown", + RegionInfo.RegionName)); } break; case "modules": @@ -1482,10 +1469,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - return ((SceneObjectGroup)ent).GetPartsFullID(localID); + return ((SceneObjectGroup) ent).GetPartsFullID(localID); } } } @@ -1499,10 +1486,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID); if (hasPrim != false) { - return ((SceneObjectGroup)ent).GetChildPart(localID); + return ((SceneObjectGroup) ent).GetChildPart(localID); } } } @@ -1516,10 +1503,10 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); + hasPrim = ((SceneObjectGroup) ent).HasChildPrim(fullID); if (hasPrim != false) { - return ((SceneObjectGroup)ent).GetChildPart(fullID); + return ((SceneObjectGroup) ent).GetChildPart(fullID); } } } @@ -1569,12 +1556,12 @@ namespace OpenSim.Region.Environment.Scenes return false; } - internal void ForEachClient( Action action ) + internal void ForEachClient(Action action) { - foreach (ScenePresence presence in m_scenePresences.Values ) + foreach (ScenePresence presence in m_scenePresences.Values) { action(presence.ControllingClient); } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 0072d4e..4ad9d65 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -28,10 +28,9 @@ using System; using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using OpenSim.Region.Terrain; namespace OpenSim.Region.Environment.Scenes @@ -39,6 +38,7 @@ namespace OpenSim.Region.Environment.Scenes public abstract class SceneBase : IScene { private readonly ClientManager m_clientManager = new ClientManager(); + public ClientManager ClientManager { get { return m_clientManager; } diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index ea47713..493afd1 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -27,9 +27,8 @@ */ using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Interfaces; using OpenSim.Framework; +using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.Scenes { @@ -207,4 +206,4 @@ namespace OpenSim.Region.Environment.Scenes } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index a315d02..75e2a41 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -28,9 +28,9 @@ using System; using System.Collections.Generic; -using OpenSim.Framework.Console; -using OpenSim.Framework; using libsecondlife; +using OpenSim.Framework; +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -152,10 +152,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendGeneralMessage(string msg) { - ForEachCurrentScene(delegate(Scene scene) - { - scene.SendGeneralAlert(msg); - }); + ForEachCurrentScene(delegate(Scene scene) { scene.SendGeneralAlert(msg); }); } public bool TrySetCurrentScene(string regionName) @@ -185,23 +182,24 @@ namespace OpenSim.Region.Environment.Scenes public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug) { ForEachCurrentScene(delegate(Scene scene) - { - foreach (EntityBase entity in scene.Entities.Values) - { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.IsChildAgent) { - log.Error(String.Format("Packet debug for {0} {1} set to {2}", - scenePrescence.Firstname, scenePrescence.Lastname, - newDebug)); - - scenePrescence.ControllingClient.SetDebug(newDebug); - } - } - } - }); + foreach (EntityBase entity in scene.Entities.Values) + { + if (entity is ScenePresence) + { + ScenePresence scenePrescence = entity as ScenePresence; + if (!scenePrescence.IsChildAgent) + { + log.Error(String.Format("Packet debug for {0} {1} set to {2}", + scenePrescence.Firstname, + scenePrescence.Lastname, + newDebug)); + + scenePrescence.ControllingClient.SetDebug(newDebug); + } + } + } + }); } public List GetCurrentSceneAvatars() @@ -209,19 +207,19 @@ namespace OpenSim.Region.Environment.Scenes List avatars = new List(); ForEachCurrentScene(delegate(Scene scene) - { - foreach (EntityBase entity in scene.Entities.Values) - { - if (entity is ScenePresence) - { - ScenePresence scenePrescence = entity as ScenePresence; - if (!scenePrescence.IsChildAgent) { - avatars.Add(scenePrescence); - } - } - } - }); + foreach (EntityBase entity in scene.Entities.Values) + { + if (entity is ScenePresence) + { + ScenePresence scenePrescence = entity as ScenePresence; + if (!scenePrescence.IsChildAgent) + { + avatars.Add(scenePrescence); + } + } + } + }); return avatars; } @@ -242,11 +240,11 @@ namespace OpenSim.Region.Environment.Scenes public void SetCurrentSceneTimePhase(int timePhase) { ForEachCurrentScene(delegate(Scene scene) - { - scene.SetTimePhase( - timePhase) - ; - }); + { + scene.SetTimePhase( + timePhase) + ; + }); } @@ -260,11 +258,11 @@ namespace OpenSim.Region.Environment.Scenes ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); } - public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar ) + public bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) { foreach (Scene scene in m_localScenes) { - if( scene.TryGetAvatar( avatarId, out avatar )) + if (scene.TryGetAvatar(avatarId, out avatar)) { return true; } @@ -311,9 +309,9 @@ namespace OpenSim.Region.Environment.Scenes return false; } - public void ForEachScene(Action action ) + public void ForEachScene(Action action) { - m_localScenes.ForEach( action ); + 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 4603902..4d439b2 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -34,7 +34,6 @@ using System.Xml; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Physics.Manager; @@ -270,7 +269,7 @@ namespace OpenSim.Region.Environment.Scenes StringReader sr = new StringReader(xmlData); XmlTextReader reader = new XmlTextReader(sr); reader.Read(); - + reader.ReadStartElement("SceneObjectGroup"); m_rootPart = SceneObjectPart.FromXml(reader); @@ -285,14 +284,14 @@ namespace OpenSim.Region.Environment.Scenes if (reader.Name == "SceneObjectPart") { SceneObjectPart Part = SceneObjectPart.FromXml(reader); - AddPart(Part); + AddPart(Part); } break; case XmlNodeType.EndElement: - reader.Read(); + reader.Read(); break; } - more = !reader.EOF; + more = !reader.EOF; } reader.Close(); sr.Close(); @@ -424,13 +423,13 @@ namespace OpenSim.Region.Environment.Scenes PrimitiveBaseShape pbs = dupe.RootPart.Shape; dupe.RootPart.PhysActor = m_scene.PhysScene.AddPrimShape( - dupe.RootPart.Name, - pbs, - new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, dupe.RootPart.AbsolutePosition.Z), - new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), - new Axiom.Math.Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, - dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z)); - + dupe.RootPart.Name, + pbs, + new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, + dupe.RootPart.AbsolutePosition.Z), + 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)); } List partList = new List(m_parts.Values); @@ -951,14 +950,15 @@ namespace OpenSim.Region.Environment.Scenes } if (m_rootPart.PhysActor != null) { - this.m_scene.PhysScene.RemovePrim(m_rootPart.PhysActor); + m_scene.PhysScene.RemovePrim(m_rootPart.PhysActor); m_rootPart.PhysActor = m_scene.PhysScene.AddPrimShape( - m_rootPart.Name, - m_rootPart.Shape, - new PhysicsVector(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y, m_rootPart.AbsolutePosition.Z), - new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z), - new Axiom.Math.Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, - m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z)); + m_rootPart.Name, + m_rootPart.Shape, + new PhysicsVector(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y, + m_rootPart.AbsolutePosition.Z), + new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z), + new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, + m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z)); } } @@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Environment.Scenes AbsolutePosition = pos; ScheduleGroupForTerseUpdate(); - m_scene.EventManager.TriggerGroupMove(this.UUID, pos); + m_scene.EventManager.TriggerGroupMove(UUID, pos); } /// @@ -1350,7 +1350,7 @@ namespace OpenSim.Region.Environment.Scenes public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) { - m_scene.EventManager.TriggerGroupGrab(this.UUID, offsetPos, remoteClient.AgentId); + m_scene.EventManager.TriggerGroupGrab(UUID, offsetPos, remoteClient.AgentId); } public void DeleteGroup() @@ -1377,4 +1377,4 @@ namespace OpenSim.Region.Environment.Scenes Text = text; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 3e104e3..387f573 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -33,12 +33,10 @@ using System.Xml.Serialization; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Physics.Manager; -using OpenSim.Region.Environment.Types; namespace OpenSim.Region.Environment.Scenes { @@ -49,8 +47,7 @@ namespace OpenSim.Region.Environment.Scenes private string m_inventoryFileName = ""; private LLUUID m_folderID = LLUUID.Zero; - [XmlIgnore] - public PhysicsActor PhysActor = null; + [XmlIgnore] public PhysicsActor PhysActor = null; protected Dictionary TaskInventory = new Dictionary(); @@ -68,10 +65,8 @@ namespace OpenSim.Region.Environment.Scenes protected byte[] m_particleSystem = new byte[0]; - [XmlIgnore] - public uint TimeStampFull = 0; - [XmlIgnore] - public uint TimeStampTerse = 0; + [XmlIgnore] public uint TimeStampFull = 0; + [XmlIgnore] public uint TimeStampTerse = 0; protected SceneObjectGroup m_parentGroup; @@ -124,7 +119,7 @@ namespace OpenSim.Region.Environment.Scenes set { m_name = value; } } - protected LLObject.ObjectFlags m_flags =0; + protected LLObject.ObjectFlags m_flags = 0; public uint ObjectFlags { @@ -132,7 +127,7 @@ namespace OpenSim.Region.Environment.Scenes set { m_flags = (LLObject.ObjectFlags) value; } } - protected LLObject.MaterialType m_material =0; + protected LLObject.MaterialType m_material = 0; public byte Material { @@ -712,7 +707,7 @@ namespace OpenSim.Region.Environment.Scenes List avatars = m_parentGroup.GetScenePresences(); for (int i = 0; i < avatars.Count; i++) { - avatars[i].QueuePartForUpdate(this); + avatars[i].QueuePartForUpdate(this); } } @@ -774,13 +769,13 @@ namespace OpenSim.Region.Environment.Scenes List avatars = m_parentGroup.GetScenePresences(); for (int i = 0; i < avatars.Count; i++) { - avatars[i].QueuePartForUpdate(this); + avatars[i].QueuePartForUpdate(this); } } public void AddTerseUpdateToAvatar(ScenePresence presence) { - presence.QueuePartForUpdate(this); + presence.QueuePartForUpdate(this); } /// @@ -927,4 +922,4 @@ namespace OpenSim.Region.Environment.Scenes } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs index 8ed4e87..f43a9fc 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.Animations.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.Environment.Scenes public void LoadAnims() { //OpenSim.Framework.Console.MainLog.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations"); - using( XmlTextReader reader = new XmlTextReader("data/avataranimations.xml") ) + using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml")) { XmlDocument doc = new XmlDocument(); doc.Load(reader); diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 6ed50b7..527eb22 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -30,11 +30,10 @@ using System.Collections.Generic; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Console; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; -using OpenSim.Region.Physics.Manager; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Types; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { @@ -116,18 +115,21 @@ namespace OpenSim.Region.Environment.Scenes } private readonly ulong m_regionHandle; + public ulong RegionHandle { get { return m_regionHandle; } } private readonly string m_firstname; + public string Firstname { get { return m_firstname; } } private readonly string m_lastname; + public string Lastname { get { return m_lastname; } @@ -210,6 +212,7 @@ namespace OpenSim.Region.Environment.Scenes } private bool m_isChildAgent = true; + public bool IsChildAgent { get { return m_isChildAgent; } @@ -217,6 +220,7 @@ namespace OpenSim.Region.Environment.Scenes } private uint m_parentID = 0; + public uint ParentID { get { return m_parentID; } @@ -227,7 +231,8 @@ namespace OpenSim.Region.Environment.Scenes #region Constructor(s) - public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, AvatarWearable[] wearables) + public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, + AvatarWearable[] wearables) { m_scene = world; m_uuid = client.AgentId; @@ -309,24 +314,24 @@ namespace OpenSim.Region.Environment.Scenes if (update.LastFullUpdateTime < part.TimeStampFull) { //need to do a full update - part.SendFullUpdate(this.ControllingClient); - update.LastFullUpdateTime = (uint)Util.UnixTimeSinceEpoch(); + part.SendFullUpdate(ControllingClient); + update.LastFullUpdateTime = (uint) Util.UnixTimeSinceEpoch(); updateCount++; } else if (update.LastTerseUpdateTime < part.TimeStampTerse) { - part.SendTerseUpdate(this.ControllingClient); - update.LastTerseUpdateTime = (uint)Util.UnixTimeSinceEpoch(); + part.SendTerseUpdate(ControllingClient); + update.LastTerseUpdateTime = (uint) Util.UnixTimeSinceEpoch(); updateCount++; } } else { //never been sent to client before so do full update - part.SendFullUpdate(this.ControllingClient); + part.SendFullUpdate(ControllingClient); ScenePartUpdate update = new ScenePartUpdate(); update.FullID = part.UUID; - update.LastFullUpdateTime = (uint)Util.UnixTimeSinceEpoch(); + update.LastFullUpdateTime = (uint) Util.UnixTimeSinceEpoch(); m_updateTimes.Add(part.UUID, update); updateCount++; } @@ -339,7 +344,6 @@ namespace OpenSim.Region.Environment.Scenes } } - #region Status Methods public void MakeRootAgent(LLVector3 pos, bool isFlying) @@ -368,10 +372,10 @@ namespace OpenSim.Region.Environment.Scenes private void RemoveFromPhysicalScene() { - if (this.PhysicsActor != null) + if (PhysicsActor != null) { - m_scene.PhysScene.RemoveAvatar(this.PhysicsActor); - this.PhysicsActor = null; + m_scene.PhysScene.RemoveAvatar(PhysicsActor); + PhysicsActor = null; } } @@ -432,7 +436,7 @@ namespace OpenSim.Region.Environment.Scenes m_isChildAgent = false; //this.m_scene.SendAllSceneObjectsToClient(this.ControllingClient); - this.MakeRootAgent(this.AbsolutePosition, false); + MakeRootAgent(AbsolutePosition, false); } } @@ -457,13 +461,13 @@ namespace OpenSim.Region.Environment.Scenes Vector3 agent_control_v3 = new Vector3(0, 0, 0); Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); bool oldflying = PhysicsActor.Flying; - PhysicsActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); + PhysicsActor.Flying = ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); if (PhysicsActor.Flying != oldflying) { update_movementflag = true; } - if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + if ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); update_movementflag = true; @@ -477,23 +481,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; } } @@ -580,10 +584,10 @@ namespace OpenSim.Region.Environment.Scenes } NewForce newVelocity = new NewForce(); - Vector3 direc = rotation * vec; + Vector3 direc = rotation*vec; direc.Normalize(); - direc = direc * ((0.03f) * 128f); + direc = direc*((0.03f)*128f); if (m_physicsActor.Flying) direc *= 4; @@ -692,8 +696,6 @@ namespace OpenSim.Region.Environment.Scenes } - - /// /// /// @@ -701,7 +703,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, AbsolutePosition, m_textureEntry.ToBytes(), m_parentID); + LocalId, AbsolutePosition, m_textureEntry.ToBytes(), + m_parentID); } public void SendFullUpdateToAllClients() @@ -784,7 +787,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendAppearanceToOtherAgent(ScenePresence avatarInfo) { avatarInfo.m_controllingClient.SendAppearance(m_controllingClient.AgentId, m_visualParams, - m_textureEntry.ToBytes()); + m_textureEntry.ToBytes()); } /// @@ -798,10 +801,7 @@ namespace OpenSim.Region.Environment.Scenes AnimationSeq = seq; LLUUID sourceAgentId = m_controllingClient.AgentId; - m_scene.Broadcast(delegate(IClientAPI client) - { - client.SendAnimation(animID, seq, sourceAgentId); - }); + m_scene.Broadcast(delegate(IClientAPI client) { client.SendAnimation(animID, seq, sourceAgentId); }); } /// @@ -842,9 +842,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)) { @@ -889,7 +889,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)); RegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); if (neighbourRegion != null) { @@ -901,7 +901,7 @@ namespace OpenSim.Region.Environment.Scenes AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); string capsPath = Util.GetCapsURL(m_controllingClient.AgentId); m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, - capsPath); + capsPath); MakeChildAgent(); m_scene.SendKillObject(m_localId); m_scene.NotifyMyCoarseLocationChange(); @@ -980,7 +980,6 @@ namespace OpenSim.Region.Environment.Scenes LastFullUpdateTime = 0; LastTerseUpdateTime = 0; } - } @@ -997,7 +996,7 @@ namespace OpenSim.Region.Environment.Scenes new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); - m_physicsActor = scene.AddAvatar(this.Firstname + "." + this.Lastname, pVec); + m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec); } internal void Close() @@ -1008,7 +1007,7 @@ namespace OpenSim.Region.Environment.Scenes public void SetWearable(int wearableId, AvatarWearable wearable) { m_wearables[wearableId] = wearable; - SendOurAppearance( m_controllingClient ); + SendOurAppearance(m_controllingClient); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs index 01c1d65..cb000c4 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/IScriptHost.cs @@ -43,4 +43,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting LLVector3 AbsolutePosition { get; } void SetText(string text, Vector3 color, double alpha); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs index 2fb3e78..c1bf72b 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/NullScriptHost.cs @@ -85,4 +85,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting Console.WriteLine("Tried to SetText [{0}] on NullScriptHost", text); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs index 42048ea..11f0ce0 100644 --- a/OpenSim/Region/Environment/StorageManager.cs +++ b/OpenSim/Region/Environment/StorageManager.cs @@ -78,4 +78,4 @@ namespace OpenSim.Region.Environment //TODO: Add checking and warning to make sure it initialised. } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs index 942ec4d..70b957e 100644 --- a/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs +++ b/OpenSim/Region/Environment/Types/BasicQuadTreeNode.cs @@ -44,7 +44,8 @@ namespace OpenSim.Region.Environment.Types //private int m_quadNumber; private string m_quadID; - public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width, short height) + public BasicQuadTreeNode(BasicQuadTreeNode parent, string quadID, short leftX, short leftY, short width, + short height) { m_parent = parent; m_quadID = quadID; @@ -66,9 +67,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (obj.AbsolutePosition.X < (m_leftX + (m_width / 2))) + if (obj.AbsolutePosition.X < (m_leftX + (m_width/2))) { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) { m_childNodes[0].AddObject(obj); } @@ -79,7 +80,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (obj.AbsolutePosition.Y < (m_leftY + (m_height / 2))) + if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) { m_childNodes[1].AddObject(obj); } @@ -96,10 +97,18 @@ namespace OpenSim.Region.Environment.Types if (m_childNodes == null) { m_childNodes = new BasicQuadTreeNode[4]; - m_childNodes[0] = new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short)(m_width / 2), (short)(m_height / 2)); - m_childNodes[1] = new BasicQuadTreeNode(this, m_quadID + "2/", (short)(m_leftX + (m_width / 2)), m_leftY, (short)(m_width / 2), (short)(m_height / 2)); - m_childNodes[2] = new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short)(m_leftY + (m_height / 2)), (short)(m_width / 2), (short)(m_height / 2)); - m_childNodes[3] = new BasicQuadTreeNode(this, m_quadID + "4/", (short)(m_leftX + (m_width / 2)), (short)(m_height + (m_height / 2)), (short)(m_width / 2), (short)(m_height / 2)); + m_childNodes[0] = + new BasicQuadTreeNode(this, m_quadID + "1/", m_leftX, m_leftY, (short) (m_width/2), + (short) (m_height/2)); + m_childNodes[1] = + new BasicQuadTreeNode(this, m_quadID + "2/", (short) (m_leftX + (m_width/2)), m_leftY, + (short) (m_width/2), (short) (m_height/2)); + m_childNodes[2] = + new BasicQuadTreeNode(this, m_quadID + "3/", m_leftX, (short) (m_leftY + (m_height/2)), + (short) (m_width/2), (short) (m_height/2)); + m_childNodes[3] = + new BasicQuadTreeNode(this, m_quadID + "4/", (short) (m_leftX + (m_width/2)), + (short) (m_height + (m_height/2)), (short) (m_width/2), (short) (m_height/2)); } else { @@ -118,9 +127,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (x < m_leftX + (m_width / 2)) + if (x < m_leftX + (m_width/2)) { - if (y < m_leftY + (m_height / 2)) + if (y < m_leftY + (m_height/2)) { return m_childNodes[0].GetObjectsFrom(x, y); } @@ -131,7 +140,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (y < m_leftY + (m_height / 2)) + if (y < m_leftY + (m_height/2)) { return m_childNodes[1].GetObjectsFrom(x, y); } @@ -172,9 +181,9 @@ namespace OpenSim.Region.Environment.Types } else { - if (x < m_leftX + (m_width / 2)) + if (x < m_leftX + (m_width/2)) { - if (y < m_leftY + (m_height / 2)) + if (y < m_leftY + (m_height/2)) { return m_childNodes[0].GetNodeID(x, y); } @@ -185,7 +194,7 @@ namespace OpenSim.Region.Environment.Types } else { - if (y < m_leftY + (m_height / 2)) + if (y < m_leftY + (m_height/2)) { return m_childNodes[1].GetNodeID(x, y); } @@ -211,7 +220,8 @@ namespace OpenSim.Region.Environment.Types List outBounds = new List(); foreach (SceneObjectGroup group in m_objects) { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && + ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) { //still in bounds } @@ -235,7 +245,8 @@ namespace OpenSim.Region.Environment.Types public void PassUp(SceneObjectGroup group) { - if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) + if (((group.AbsolutePosition.X > m_leftX) && (group.AbsolutePosition.X < (m_leftX + m_width))) && + ((group.AbsolutePosition.Y > m_leftY) && (group.AbsolutePosition.Y < (m_leftY + m_height)))) { AddObject(group); } @@ -255,4 +266,4 @@ namespace OpenSim.Region.Environment.Types return retVal; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Types/UpdateQueue.cs b/OpenSim/Region/Environment/Types/UpdateQueue.cs index 442e9d5..0648476 100644 --- a/OpenSim/Region/Environment/Types/UpdateQueue.cs +++ b/OpenSim/Region/Environment/Types/UpdateQueue.cs @@ -76,4 +76,4 @@ namespace OpenSim.Region.Environment.Types return part; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs b/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs index f5a080f..bfd9d06 100644 --- a/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/ComplexObject.cs @@ -26,60 +26,69 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using Axiom.Math; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; namespace SimpleApp { public class ComplexObject : SceneObjectGroup { private LLQuaternion m_rotationDirection; - + private class RotatingWheel : SceneObjectPart { private LLQuaternion m_rotationDirection; - public RotatingWheel(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID, LLVector3 groupPosition, LLVector3 offsetPosition, LLQuaternion rotationDirection) - : base(regionHandle, parent, ownerID, localID, new CylinderShape( 0.5f, 0.2f ), groupPosition, offsetPosition ) + public RotatingWheel(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID, + LLVector3 groupPosition, LLVector3 offsetPosition, LLQuaternion rotationDirection) + : base( + regionHandle, parent, ownerID, localID, new CylinderShape(0.5f, 0.2f), groupPosition, offsetPosition + ) { - m_rotationDirection = rotationDirection; + m_rotationDirection = rotationDirection; } public override void UpdateMovement() { - UpdateRotation(RotationOffset * m_rotationDirection); + UpdateRotation(RotationOffset*m_rotationDirection); } } public override void UpdateMovement() { - UpdateGroupRotation(GroupRotation * m_rotationDirection); - + UpdateGroupRotation(GroupRotation*m_rotationDirection); + base.UpdateMovement(); } - - - public ComplexObject(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos ) - : base(scene, regionHandle, ownerID, localID, pos, BoxShape.Default ) + + public ComplexObject(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos) + : base(scene, regionHandle, ownerID, localID, pos, BoxShape.Default) { m_rotationDirection = new LLQuaternion(0.05f, 0.1f, 0.15f); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, 0.75f), new LLQuaternion(0.05f,0,0))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, -0.75f), new LLQuaternion(-0.05f,0,0))); + AddPart( + new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, 0.75f), + new LLQuaternion(0.05f, 0, 0))); + AddPart( + new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0, -0.75f), + new LLQuaternion(-0.05f, 0, 0))); + + AddPart( + new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0.75f, 0), + new LLQuaternion(0.5f, 0, 0.05f))); + AddPart( + new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, -0.75f, 0), + new LLQuaternion(-0.5f, 0, -0.05f))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, 0.75f,0), new LLQuaternion(0.5f, 0, 0.05f))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0, -0.75f,0), new LLQuaternion(-0.5f, 0, -0.05f))); + AddPart( + new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0.75f, 0, 0), + new LLQuaternion(0, 0.5f, 0.05f))); + AddPart( + new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(-0.75f, 0, 0), + new LLQuaternion(0, -0.5f, -0.05f))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(0.75f, 0, 0), new LLQuaternion(0, 0.5f, 0.05f))); - AddPart(new RotatingWheel(regionHandle, this, ownerID, scene.PrimIDAllocate(), pos, new LLVector3(-0.75f, 0, 0), new LLQuaternion(0, -0.5f, -0.05f))); - UpdateParentIDs(); } @@ -88,12 +97,12 @@ namespace SimpleApp m_parts.Remove(part.UUID); remoteClient.SendKillObject(m_regionHandle, part.LocalID); remoteClient.AddMoney(1); - remoteClient.SendChatMessage("Poof!", 1, this.AbsolutePosition, "Party Party", LLUUID.Zero); + remoteClient.SendChatMessage("Poof!", 1, AbsolutePosition, "Party Party", LLUUID.Zero); } - public override void OnGrabGroup( LLVector3 offsetPos, IClientAPI remoteClient) + public override void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) { - if( m_parts.Count == 1 ) + if (m_parts.Count == 1) { m_parts.Remove(m_rootPart.UUID); m_scene.RemoveEntity(this); @@ -103,4 +112,4 @@ namespace SimpleApp } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs b/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs index 0f833ea..cbc4dea 100644 --- a/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs @@ -27,37 +27,34 @@ */ using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; +using System.Diagnostics; using libsecondlife; using OpenSim.Framework; -using System.Timers; -using System.Diagnostics; +using OpenSim.Region.Environment.Scenes; namespace SimpleApp { public class CpuCounterObject : SceneObjectGroup { private PerformanceCounter m_counter; - - public CpuCounterObject(Scene world, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos ) - : base(world, regionHandle, ownerID, localID, pos, BoxShape.Default ) + + public CpuCounterObject(Scene world, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos) + : base(world, regionHandle, ownerID, localID, pos, BoxShape.Default) { String objectName = "Processor"; String counterName = "% Processor Time"; String instanceName = "_Total"; - + m_counter = new PerformanceCounter(objectName, counterName, instanceName); } - public override void UpdateMovement( ) + public override void UpdateMovement() { - float cpu = m_counter.NextValue() / 40f; - LLVector3 size = new LLVector3(cpu, cpu, cpu); + float cpu = m_counter.NextValue()/40f; + LLVector3 size = new LLVector3(cpu, cpu, cpu); //rootPrimitive.ResizeGoup( size ); - + base.UpdateMovement(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs index 746340f..7b1420b 100644 --- a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs @@ -27,14 +27,10 @@ */ using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; +using System.IO; using libsecondlife; using OpenSim.Framework; -using System.Timers; -using System.Diagnostics; -using System.IO; +using OpenSim.Region.Environment.Scenes; namespace SimpleApp { @@ -43,9 +39,7 @@ namespace SimpleApp public FileSystemObject(Scene world, FileInfo fileInfo, LLVector3 pos) : base(world, world.RegionInfo.RegionHandle, LLUUID.Zero, world.NextLocalId, pos, BoxShape.Default) { - - - float size = (float)Math.Pow((double)fileInfo.Length, (double)1 / 3) / 5; + float size = (float) Math.Pow((double) fileInfo.Length, (double) 1/3)/5; // rootPrimitive.ResizeGoup(new LLVector3(size, size, size)); Text = fileInfo.Name; ScheduleGroupForFullUpdate(); @@ -56,4 +50,4 @@ namespace SimpleApp base.Update(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 03e0f98..f7fdbb5 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -26,16 +26,14 @@ * */ +using System; using System.Collections.Generic; using System.Net; using System.Text; using libsecondlife; using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; -using System; namespace SimpleApp { @@ -126,13 +124,15 @@ namespace SimpleApp #pragma warning restore 67 private LLUUID myID = LLUUID.Random(); - public MyNpcCharacter( EventManager eventManager ) + + public MyNpcCharacter(EventManager eventManager) { - // startPos = new LLVector3(128, (float)(Util.RandomClass.NextDouble()*100), 2); + // startPos = new LLVector3(128, (float)(Util.RandomClass.NextDouble()*100), 2); eventManager.OnFrame += Update; } - private LLVector3 startPos = new LLVector3(128, 128,2); + private LLVector3 startPos = new LLVector3(128, 128, 2); + public virtual LLVector3 StartPos { get { return startPos; } @@ -155,92 +155,218 @@ namespace SimpleApp } private string lastName = "NPC" + Util.RandomClass.Next(1, 1000); + public virtual string LastName { get { return lastName; } } - public virtual void OutPacket(Packet newPack) { } - public virtual void SendWearables(AvatarWearable[] wearables) { } - public virtual void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) { } - public virtual void SendStartPingCheck(byte seq) { } - public virtual void SendKillObject(ulong regionHandle, uint localID) { } - public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) { } - public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } - public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { } - public virtual void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) { } - public virtual void SendLayerData(float[] map) { } - public virtual void SendLayerData(int px, int py, float[] map) { } - public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) { } - public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) { } - public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); } - public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL) { } - public virtual void SendMapBlock(List mapBlocks) { } - public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { } - public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL) { } - public virtual void SendTeleportCancel() { } - public virtual void SendTeleportLocationStart() { } - public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { } - - public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) { } - public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation) { } - public virtual void SendCoarseLocationUpdate(List CoarseLocations) { } - - public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) { } - - public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID, byte[] particleSystem, LLQuaternion rotation) { } - public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { } - - public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items) { } - public virtual void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) { } - public virtual void SendInventoryItemUpdate(InventoryItemBase Item) { } - public virtual void SendRemoveInventoryItem(LLUUID itemID) { } - public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) { } - public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) { } - - public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) { } - - public virtual void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID) { } - public virtual void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags) { } - - public void SendAlertMessage(string message) { } - public void SendAgentAlertMessage(string message, bool modal) { } - public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { } + public virtual void OutPacket(Packet newPack) + { + } + + public virtual void SendWearables(AvatarWearable[] wearables) + { + } + + public virtual void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) + { + } + + public virtual void SendStartPingCheck(byte seq) + { + } + + public virtual void SendKillObject(ulong regionHandle, uint localID) + { + } + + public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) + { + } + + public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, + LLUUID fromAgentID) + { + } + + public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, + LLUUID fromAgentID) + { + } + + public virtual void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, + LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) + { + } + + public virtual void SendLayerData(float[] map) + { + } + + public virtual void SendLayerData(int px, int py, float[] map) + { + } + + public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) + { + } + + public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) + { + } + + public virtual AgentCircuitData RequestClientInfo() + { + return new AgentCircuitData(); + } + + public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, + IPEndPoint newRegionExternalEndPoint, string capsURL) + { + } + + public virtual void SendMapBlock(List mapBlocks) + { + } + + public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) + { + } + + public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, + uint locationID, uint flags, string capsURL) + { + } + + public virtual void SendTeleportCancel() + { + } + + public virtual void SendTeleportLocationStart() + { + } + + public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) + { + } + + public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, + uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) + { + } + + public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, + LLVector3 position, LLVector3 velocity, LLQuaternion rotation) + { + } + + public virtual void SendCoarseLocationUpdate(List CoarseLocations) + { + } + + public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) + { + } + + public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, + PrimitiveBaseShape primShape, LLVector3 pos, uint flags, + LLUUID objectID, LLUUID ownerID, string text, uint parentID, + byte[] particleSystem, LLQuaternion rotation) + { + } + + public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, + LLVector3 position, LLQuaternion rotation) + { + } + + public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items) + { + } + + public virtual void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) + { + } + + public virtual void SendInventoryItemUpdate(InventoryItemBase Item) + { + } + + public virtual void SendRemoveInventoryItem(LLUUID itemID) + { + } + + public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) + { + } + + public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) + { + } + + public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname) + { + } + + public virtual void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID) + { + } + + public virtual void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, + byte flags) + { + } + + public void SendAlertMessage(string message) + { + } + + public void SendAgentAlertMessage(string message, bool modal) + { + } + + public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, + string url) + { + } public virtual void SendRegionHandshake(RegionInfo regionInfo) { if (OnRegionHandShakeReply != null) { - this.OnRegionHandShakeReply(this); + OnRegionHandShakeReply(this); } if (OnCompleteMovementToRegion != null) { - this.OnCompleteMovementToRegion(); + OnCompleteMovementToRegion(); } } - private void Update( ) + private void Update() { Encoding enc = Encoding.ASCII; - if (this.OnAgentUpdate != null) + if (OnAgentUpdate != null) { - this.OnAgentUpdate(this, movementFlag, bodyDirection); + OnAgentUpdate(this, movementFlag, bodyDirection); } - if (this.flyState == 0) + if (flyState == 0) { - movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG; + movementFlag = (uint) MainAvatar.ControlFlags.AGENT_CONTROL_FLY | + (uint) MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG; flyState = 1; } - else if (this.flyState == 1) + else if (flyState == 1) { - movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY | (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS; + movementFlag = (uint) MainAvatar.ControlFlags.AGENT_CONTROL_FLY | + (uint) MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS; flyState = 2; } else { - movementFlag = (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY; + movementFlag = (uint) MainAvatar.ControlFlags.AGENT_CONTROL_FLY; flyState = 0; } @@ -251,15 +377,14 @@ namespace SimpleApp ChatFromViewerArgs args = new ChatFromViewerArgs(); args.Message = "Kinda quiet around here, isn't it?"; args.Channel = 0; - args.From = this.FirstName + " " + this.LastName; + args.From = FirstName + " " + LastName; args.Position = new LLVector3(128, 128, 26); args.Sender = this; args.Type = ChatTypeEnum.Shout; - this.OnChatFromViewer(this, args); + OnChatFromViewer(this, args); } count = -1; - } count++; @@ -270,9 +395,19 @@ namespace SimpleApp return false; } - public void SendViewerTime(int phase) { } - public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID) { } - public void SetDebug(int newDebug) { } + public void SendViewerTime(int phase) + { + } + + public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, + string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, + LLUUID partnerID) + { + } + + public void SetDebug(int newDebug) + { + } public void InPacket(Packet NewPack) { @@ -281,22 +416,17 @@ namespace SimpleApp public void Close() { } - + private uint m_circuitCode; + public uint CircuitCode { - get - { - return m_circuitCode; - } - set - { - m_circuitCode = value; - } + get { return m_circuitCode; } + set { m_circuitCode = value; } } public void SendLogoutPacket() { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 9a7b340..c616f6a 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs @@ -31,13 +31,9 @@ using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Interfaces; using OpenSim.Framework.Servers; -using OpenSim.Framework; - -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Terrain; using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Scenes; using Avatar=OpenSim.Region.Environment.Scenes.ScenePresence; namespace SimpleApp @@ -46,8 +42,10 @@ namespace SimpleApp { private List m_avatars; - public MyWorld( RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, ModuleLoader moduleLoader) - : base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer, moduleLoader, false) + public MyWorld(RegionInfo regionInfo, AgentCircuitManager authen, CommunicationsManager commsMan, + AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, + ModuleLoader moduleLoader) + : base(regionInfo, authen, commsMan, assetCach, storeMan, httpServer, moduleLoader, false) { m_avatars = new List(); } @@ -58,32 +56,30 @@ namespace SimpleApp for (int i = 0; i < 65536; i++) { - int x = i % 256; - int y = i / 256; + int x = i%256; + int y = i/256; map[i] = 25f; } - this.Terrain.GetHeights1D(map); - this.CreateTerrainTexture(); + Terrain.GetHeights1D(map); + CreateTerrainTexture(); } - override public void AddNewClient(IClientAPI client, bool child) + public override void AddNewClient(IClientAPI client, bool child) { SubscribeToClientEvents(client); - ScenePresence avatar = CreateAndAddScenePresence(client, child ); + ScenePresence avatar = CreateAndAddScenePresence(client, child); avatar.AbsolutePosition = new LLVector3(128, 128, 26); LLVector3 pos = new LLVector3(128, 128, 128); - client.OnCompleteMovementToRegion += delegate() - { - client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero ); - }; + client.OnCompleteMovementToRegion += + delegate() { client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero); }; client.SendRegionHandshake(m_regInfo); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 72aaf6b..b37c2ee 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -31,23 +31,23 @@ using System.Collections.Generic; using System.IO; using System.Net; using libsecondlife; +using Nini.Config; +using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Framework; using OpenSim.Region.ClientStack; using OpenSim.Region.Communications.Local; using OpenSim.Region.Environment; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; -using Nini.Config; namespace SimpleApp { - class Program : RegionApplicationBase, conscmd_callback + internal class Program : RegionApplicationBase, conscmd_callback { private ModuleLoader m_moduleLoader; private IConfigSource m_config; - + protected override LogBase CreateLog() { return new LogBase(null, "SimpleApp", this, true); @@ -57,45 +57,51 @@ namespace SimpleApp { StartLog(); - m_networkServersInfo = new NetworkServersInfo( 1000, 1000 ); + m_networkServersInfo = new NetworkServersInfo(1000, 1000); LocalAssetServer assetServer = new LocalAssetServer(); m_assetCache = new AssetCache(assetServer); } - + public void Run() { base.StartUp(); - + LocalInventoryService inventoryService = new LocalInventoryService(); - LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService); + LocalUserServices userService = + new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, + m_networkServersInfo.DefaultHomeLocY, inventoryService); LocalBackEndServices backendService = new LocalBackEndServices(); - CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, inventoryService, backendService, backendService, false); + CommunicationsLocal localComms = + new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, userService, inventoryService, + backendService, backendService, false); m_commsManager = localComms; - LocalLoginService loginService = new LocalLoginService(userService, "", localComms, m_networkServersInfo, false); + LocalLoginService loginService = + new LocalLoginService(userService, "", localComms, m_networkServersInfo, false); loginService.OnLoginToRegion += backendService.AddNewSession; m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); m_log.Notice(m_log.LineInfo); - - IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), m_networkServersInfo.HttpListenerPort); + + IPEndPoint internalEndPoint = + new IPEndPoint(IPAddress.Parse("127.0.0.1"), m_networkServersInfo.HttpListenerPort); RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "localhost"); regionInfo.DataStore = "simpleapp_datastore.yap"; - + UDPServer udpServer; - m_moduleLoader = new ModuleLoader( m_log, m_config ); + m_moduleLoader = new ModuleLoader(m_log, m_config); m_moduleLoader.LoadDefaultSharedModules(); Scene scene = SetupScene(regionInfo, out udpServer); m_moduleLoader.InitialiseSharedModules(scene); - + scene.SetModuleInterfaces(); scene.StartTimer(); @@ -104,18 +110,22 @@ namespace SimpleApp m_moduleLoader.PostInitialise(); m_moduleLoader.ClearCache(); - + udpServer.ServerListener(); - + LLVector3 pos = new LLVector3(110, 129, 27); - SceneObjectGroup sceneObject = new CpuCounterObject(scene, regionInfo.RegionHandle, LLUUID.Zero, scene.PrimIDAllocate(), pos + new LLVector3( 1f, 1f, 1f )); + SceneObjectGroup sceneObject = + new CpuCounterObject(scene, regionInfo.RegionHandle, LLUUID.Zero, scene.PrimIDAllocate(), + pos + new LLVector3(1f, 1f, 1f)); scene.AddEntity(sceneObject); for (int i = 0; i < 27; i++) { - LLVector3 posOffset = new LLVector3( (i%3)*4, (i%9)/3 * 4, (i/9) * 4 ); - ComplexObject complexObject = new ComplexObject(scene, regionInfo.RegionHandle, LLUUID.Zero, scene.PrimIDAllocate(), pos + posOffset ); + LLVector3 posOffset = new LLVector3((i%3)*4, (i%9)/3*4, (i/9)*4); + ComplexObject complexObject = + new ComplexObject(scene, regionInfo.RegionHandle, LLUUID.Zero, scene.PrimIDAllocate(), + pos + posOffset); scene.AddEntity(complexObject); } @@ -128,45 +138,48 @@ namespace SimpleApp List avatars = scene.GetAvatars(); foreach (ScenePresence avatar in avatars) { - avatar.AbsolutePosition = new LLVector3((float)OpenSim.Framework.Util.RandomClass.Next(100,200), (float)OpenSim.Framework.Util.RandomClass.Next(30, 200), 2); + avatar.AbsolutePosition = + new LLVector3((float) Util.RandomClass.Next(100, 200), (float) Util.RandomClass.Next(30, 200), 2); } - - - DirectoryInfo dirInfo = new DirectoryInfo( "." ); + + DirectoryInfo dirInfo = new DirectoryInfo("."); float x = 0; float z = 0; - - foreach( FileInfo fileInfo in dirInfo.GetFiles()) + + foreach (FileInfo fileInfo in dirInfo.GetFiles()) { LLVector3 filePos = new LLVector3(100 + x, 129, 27 + z); x = x + 2; - if( x > 50 ) + if (x > 50) { x = 0; z = z + 2; } - - FileSystemObject fileObject = new FileSystemObject( scene, fileInfo, filePos ); + + FileSystemObject fileObject = new FileSystemObject(scene, fileInfo, filePos); scene.AddEntity(fileObject); } - + m_log.Notice("Press enter to quit."); - m_log.ReadLine(); + m_log.ReadLine(); } - protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager) + protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, + AgentCircuitManager circuitManager) { - return new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, new ModuleLoader( m_log, m_config )); + return + new MyWorld(regionInfo, circuitManager, m_commsManager, m_assetCache, storageManager, m_httpServer, + new ModuleLoader(m_log, m_config)); } protected override StorageManager CreateStorageManager(RegionInfo regionInfo) { return new StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp"); } - - protected override PhysicsScene GetPhysicsScene( ) + + protected override PhysicsScene GetPhysicsScene() { return GetPhysicsScene("basicphysics"); } @@ -185,11 +198,11 @@ namespace SimpleApp #endregion - static void Main(string[] args) + private static void Main(string[] args) { Program app = new Program(); app.Run(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs index 2250613..a5c8f05 100644 --- a/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Examples/SimpleApp/Properties/AssemblyInfo.cs @@ -1,24 +1,28 @@ -using System.Reflection; +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("SimpleApp")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Playahead AB")] -[assembly: AssemblyProduct("SimpleApp")] -[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("SimpleApp")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("Playahead AB")] +[assembly : AssemblyProduct("SimpleApp")] +[assembly : AssemblyCopyright("Copyright © Playahead AB 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("a5cfa45f-5acf-4b2e-9c50-1dd1fd7608ee")] + +[assembly : Guid("a5cfa45f-5acf-4b2e-9c50-1dd1fd7608ee")] // Version information for an assembly consists of the following four values: // @@ -27,5 +31,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs index d4b27fc..176fc7b 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp return ".cs"; } - private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) + private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) { CompilerParameters compilerParams = new CompilerParameters(); CompilerResults compilerResults; @@ -66,15 +66,16 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp } else { - Dictionary scripts = new Dictionary(); - + Dictionary scripts = new Dictionary(); + foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) { Type testInterface = pluginType.GetInterface("IScript", true); if (testInterface != null) { - IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); + IScript script = + (IScript) compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); string scriptName = "C#/" + script.Name; Console.WriteLine("Script: " + scriptName + " loaded."); @@ -94,10 +95,10 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp return null; } - public Dictionary compile(string filename) + public Dictionary compile(string filename) { CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); 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 7ae4658..2d684d1 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs @@ -26,19 +26,13 @@ * */ -using OpenSim.Framework.Console; -using OpenSim.Framework; -using OpenSim.Region.Environment; using OpenSim.Region.Environment.Scenes; -using System.Collections.Generic; -using libsecondlife; - namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples { public class LSLExportScript : IScript { - ScriptInfo script; + private ScriptInfo script; public string Name { @@ -48,11 +42,11 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples public void Initialise(ScriptInfo scriptInfo) { script = scriptInfo; - + script.events.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(ProcessConsoleMsg); } - void ProcessConsoleMsg(string[] args) + private void ProcessConsoleMsg(string[] args) { /*if (args[0].ToLower() == "lslexport") { @@ -79,7 +73,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples }*/ } - string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim) + private string processPrimitiveToString(SceneObjectPart prim) { /*string desc = prim.Description; string name = prim.Name; @@ -97,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 4bde721..ea0e92a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs @@ -74,7 +74,8 @@ namespace OpenSim.Region.ExtensionsScriptModule.JScript if (testInterface != null) { - IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); + IScript script = + (IScript) compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); string scriptName = "JS.NET/" + script.Name; Console.WriteLine("Script: " + scriptName + " loaded."); @@ -100,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 6100c67..3f09099 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs @@ -25,9 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; using System.Collections.Generic; -using System.Text; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM @@ -40,7 +38,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public ClassInstance() { - } } -} +} \ 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 5c3629c..3bcc824 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs @@ -26,9 +26,8 @@ * */ using System; -using System.IO; using System.Collections.Generic; -using System.Text; +using System.IO; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; @@ -56,7 +55,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public ClassRecord() { - } public ClassInstance CreateNewInstance() @@ -72,7 +70,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { Console.WriteLine("loading script " + fileName); FileStream fs = File.OpenRead(fileName); - this.LoadClassFromBytes(ReadFully(fs)); + LoadClassFromBytes(ReadFully(fs)); fs.Close(); } @@ -80,9 +78,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { int i = 0; i += 4; - m_minorVersion = (ushort)((data[i++] << 8) + data[i++]); - m_majorVersion = (ushort)((data[i++] << 8) + data[i++]); - m_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); + m_minorVersion = (ushort) ((data[i++] << 8) + data[i++]); + m_majorVersion = (ushort) ((data[i++] << 8) + data[i++]); + m_constantPoolCount = (ushort) ((data[i++] << 8) + data[i++]); Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool"); for (int count = 0; count < (m_constantPoolCount - 1); count++) { @@ -92,13 +90,13 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM //Console.WriteLine("start position is: " + i); switch (pooltype) { - case 1: //Utf8 - ushort uLength = (ushort)((data[i++] << 8) + data[i++]); + case 1: //Utf8 + ushort uLength = (ushort) ((data[i++] << 8) + data[i++]); // Console.WriteLine("new utf8 type, length is " + uLength); PoolUtf8 utf8 = new PoolUtf8(); utf8.readValue(data, ref i, uLength); - this.m_constantsPool.Add(utf8); + m_constantsPool.Add(utf8); break; case 3: //Int break; @@ -107,53 +105,53 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM case 7: //Class PoolClass pClass = new PoolClass(this); pClass.readValue(data, ref i); - this.m_constantsPool.Add(pClass); + m_constantsPool.Add(pClass); break; case 9: //FieldRef PoolFieldRef pField = new PoolFieldRef(this); pField.readValue(data, ref i); - this.m_constantsPool.Add(pField); + m_constantsPool.Add(pField); break; case 10: //Method PoolMethodRef pMeth = new PoolMethodRef(this); pMeth.readValue(data, ref i); - this.m_constantsPool.Add(pMeth); + m_constantsPool.Add(pMeth); break; - case 12: //NamedType + case 12: //NamedType PoolNamedType pNamed = new PoolNamedType(this); pNamed.readValue(data, ref i); - this.m_constantsPool.Add(pNamed); + m_constantsPool.Add(pNamed); break; } } - m_accessFlags = (ushort)((data[i++] << 8) + data[i++]); - m_thisClass = (ushort)((data[i++] << 8) + data[i++]); - m_supperClass = (ushort)((data[i++] << 8) + data[i++]); + m_accessFlags = (ushort) ((data[i++] << 8) + data[i++]); + m_thisClass = (ushort) ((data[i++] << 8) + data[i++]); + m_supperClass = (ushort) ((data[i++] << 8) + data[i++]); - if (this.m_constantsPool[this.m_thisClass - 1] is PoolClass) + if (m_constantsPool[m_thisClass - 1] is PoolClass) { - this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]); + MClass = ((PoolClass) m_constantsPool[m_thisClass - 1]); } - m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); + m_interfaceCount = (ushort) ((data[i++] << 8) + data[i++]); //should now read in the info for each interface - m_fieldCount = (ushort)((data[i++] << 8) + data[i++]); + m_fieldCount = (ushort) ((data[i++] << 8) + data[i++]); //should now read in the info for each field for (int count = 0; count < m_fieldCount; count++) { FieldInfo fieldInf = new FieldInfo(this); fieldInf.ReadData(data, ref i); - this.m_fieldList.Add(fieldInf); + m_fieldList.Add(fieldInf); } - m_methodCount = (ushort)((data[i++] << 8) + data[i++]); + m_methodCount = (ushort) ((data[i++] << 8) + data[i++]); for (int count = 0; count < m_methodCount; count++) { MethodInfo methInf = new MethodInfo(this); methInf.ReadData(data, ref i); - this.m_methodsList.Add(methInf); + m_methodsList.Add(methInf); } } @@ -161,7 +159,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { for (int count = 0; count < m_methodCount; count++) { - this.m_methodsList[count].AddMethodCode(memory); + m_methodsList[count].AddMethodCode(memory); } } @@ -169,12 +167,12 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { for (int count = 0; count < m_methodCount; count++) { - if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8) + if (m_constantsPool[m_methodsList[count].NameIndex - 1] is PoolUtf8) { - if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName) + if (((PoolUtf8) m_constantsPool[m_methodsList[count].NameIndex - 1]).Value == methodName) { //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); - thread.SetPC(this.m_methodsList[count].CodePointer); + thread.SetPC(m_methodsList[count].CodePointer); return true; } } @@ -191,7 +189,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM for (int i = 0; i < m_constantsPool.Count; i++) { - this.m_constantsPool[i].Print(); + m_constantsPool[i].Print(); } Console.WriteLine("Access flags: " + m_accessFlags); @@ -201,16 +199,16 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM for (int count = 0; count < m_fieldCount; count++) { Console.WriteLine(); - this.m_fieldList[count].Print(); + m_fieldList[count].Print(); } for (int count = 0; count < m_methodCount; count++) { Console.WriteLine(); - this.m_methodsList[count].Print(); + m_methodsList[count].Print(); } - Console.WriteLine("class name is " + this.MClass.Name.Value); + Console.WriteLine("class name is " + MClass.Name.Value); } public static byte[] ReadFully(Stream stream) @@ -229,11 +227,11 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } #region nested classes + public class PoolItem { public virtual void Print() { - } } @@ -245,21 +243,21 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { for (int i = 0; i < length; i++) { - int a = (int)data[pointer++]; + int a = (int) data[pointer++]; if ((a & 0x80) == 0) { - Value = Value + (char)a; + Value = Value + (char) a; } else if ((a & 0x20) == 0) { - int b = (int)data[pointer++]; - Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); + int b = (int) data[pointer++]; + Value = Value + (char) (((a & 0x1f) << 6) + (b & 0x3f)); } else { - int b = (int)data[pointer++]; - int c = (int)data[pointer++]; - Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); + int b = (int) data[pointer++]; + int c = (int) data[pointer++]; + Value = Value + (char) (((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); } } } @@ -272,7 +270,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM private class PoolInt : PoolItem { - } public class PoolClass : PoolItem @@ -289,15 +286,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + namePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); } public override void Print() { - this.Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); + Name = ((PoolUtf8) parent.m_constantsPool[namePointer - 1]); Console.Write("Class type: " + namePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); - + Console.WriteLine(" // " + ((PoolUtf8) parent.m_constantsPool[namePointer - 1]).Value); } } @@ -316,14 +312,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + classPointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); + nameTypePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); } public override void Print() { - this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); - this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); + mNameType = ((PoolNamedType) parent.m_constantsPool[nameTypePointer - 1]); + mClass = ((PoolClass) parent.m_constantsPool[classPointer - 1]); Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); } } @@ -343,14 +339,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + classPointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); + nameTypePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); } public override void Print() { - this.mNameType = ((PoolNamedType)this.parent.m_constantsPool[nameTypePointer - 1]); - this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); + mNameType = ((PoolNamedType) parent.m_constantsPool[nameTypePointer - 1]); + mClass = ((PoolClass) parent.m_constantsPool[classPointer - 1]); Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); } } @@ -370,16 +366,16 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - typePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + namePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); + typePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); } public override void Print() { - Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); - Type = ((PoolUtf8)this.parent.m_constantsPool[typePointer - 1]); + Name = ((PoolUtf8) parent.m_constantsPool[namePointer - 1]); + Type = ((PoolUtf8) parent.m_constantsPool[typePointer - 1]); Console.Write("Named type: " + namePointer + " , " + typePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); + Console.WriteLine(" // " + ((PoolUtf8) parent.m_constantsPool[namePointer - 1]).Value); } } @@ -402,23 +398,23 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void AddMethodCode(MethodMemory memory) { - Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); + Array.Copy(Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, Attributes[0].Code.Length); memory.Methodcount++; - this.CodePointer = memory.NextMethodPC; - memory.NextMethodPC += this.Attributes[0].Code.Length; + CodePointer = memory.NextMethodPC; + memory.NextMethodPC += Attributes[0].Code.Length; } public void ReadData(byte[] data, ref int pointer) { - AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + AccessFlags = (ushort) ((data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]); + DescriptorIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]); + AttributeCount = (ushort) ((data[pointer++] << 8) + data[pointer++]); for (int i = 0; i < AttributeCount; i++) { - MethodAttribute attri = new MethodAttribute(this.parent); + MethodAttribute attri = new MethodAttribute(parent); attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); + Attributes.Add(attri); } } @@ -426,12 +422,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { Console.WriteLine("Method Info Struct: "); Console.WriteLine("AccessFlags: " + AccessFlags); - Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); + Console.WriteLine("NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[DescriptorIndex - 1]).Value); Console.WriteLine("Attribute Count:" + AttributeCount); for (int i = 0; i < AttributeCount; i++) { - this.Attributes[i].Print(); + Attributes[i].Print(); } } @@ -457,30 +455,35 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void ReadData(byte[] data, ref int pointer) { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); - MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); - CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]); + Length = + (Int32) + ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + MaxStack = (ushort) ((data[pointer++] << 8) + data[pointer++]); + MaxLocals = (ushort) ((data[pointer++] << 8) + data[pointer++]); + CodeLength = + (Int32) + ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); Code = new byte[CodeLength]; for (int i = 0; i < CodeLength; i++) { Code[i] = data[pointer++]; } - ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); - SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + ExceptionTableLength = (ushort) ((data[pointer++] << 8) + data[pointer++]); + SubAttributeCount = (ushort) ((data[pointer++] << 8) + data[pointer++]); for (int i = 0; i < SubAttributeCount; i++) { - SubAttribute subAttri = new SubAttribute(this.parent); + SubAttribute subAttri = new SubAttribute(parent); subAttri.ReadData(data, ref pointer); - this.SubAttributes.Add(subAttri); + SubAttributes.Add(subAttri); } } public void Print() { Console.WriteLine("Method Attribute: "); - Console.WriteLine("Name Index: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("Name Index: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); Console.WriteLine("Length: " + Length); Console.WriteLine("MaxStack: " + MaxStack); Console.WriteLine("MaxLocals: " + MaxLocals); @@ -492,7 +495,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM Console.WriteLine("SubAttributes: " + SubAttributeCount); for (int i = 0; i < SubAttributeCount; i++) { - this.SubAttributes[i].Print(); + SubAttributes[i].Print(); } } @@ -511,8 +514,11 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void ReadData(byte[] data, ref int pointer) { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]); + Length = + (Int32) + ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + + data[pointer++]); Data = new byte[Length]; for (int i = 0; i < Length; i++) { @@ -522,18 +528,17 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void Print() { - Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); } - } } - } + private class InterfaceInfo { public void ReadData(byte[] data, ref int i) { - } } @@ -554,15 +559,15 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void ReadData(byte[] data, ref int pointer) { - AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + AccessFlags = (ushort) ((data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]); + DescriptorIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]); + AttributeCount = (ushort) ((data[pointer++] << 8) + data[pointer++]); for (int i = 0; i < AttributeCount; i++) { - FieldAttribute attri = new FieldAttribute(this.parent); + FieldAttribute attri = new FieldAttribute(parent); attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); + Attributes.Add(attri); } } @@ -570,29 +575,30 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { Console.WriteLine("Field Info Struct: "); Console.WriteLine("AccessFlags: " + AccessFlags); - Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); + Console.WriteLine("NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[DescriptorIndex - 1]).Value); Console.WriteLine("Attribute Count:" + AttributeCount); //if static, add to static field list // if (this.AccessFlags == 9) //public and static - if ((this.AccessFlags & 0x08) != 0) + if ((AccessFlags & 0x08) != 0) { - switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value) + switch (((PoolUtf8) parent.m_constantsPool[DescriptorIndex - 1]).Value) { case "I": Int newin = new Int(); - this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newin); + parent.StaticFields.Add(((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value, newin); break; case "F": Float newfl = new Float(); - this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newfl); + parent.StaticFields.Add(((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value, newfl); break; } - } for (int i = 0; i < AttributeCount; i++) { - this.Attributes[i].Print(); + Attributes[i].Print(); } } @@ -611,8 +617,10 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void ReadData(byte[] data, ref int pointer) { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]); + Length = + (Int32) + ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); Data = new byte[Length]; for (int i = 0; i < Length; i++) { @@ -622,7 +630,8 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void Print() { - Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); } } } @@ -631,10 +640,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { public void ReadData(byte[] data, ref int i) { - } } - #endregion + #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 c76767a..9876caa 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs @@ -25,9 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { @@ -37,7 +35,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public Heap() { - } } -} +} \ 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 6b8930e..b172562 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs @@ -25,9 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; @@ -42,304 +39,313 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM bool result = false; switch (opcode) { - case (byte)(byte)OpCode.iconst_m1: + case (byte) (byte) OpCode.iconst_m1: Int m_int = new Int(); m_int.mValue = -1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_0: + case (byte) (byte) OpCode.iconst_0: m_int = new Int(); m_int.mValue = 0; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_1: + case (byte) (byte) OpCode.iconst_1: m_int = new Int(); m_int.mValue = 1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_2: + case (byte) (byte) OpCode.iconst_2: m_int = new Int(); m_int.mValue = 2; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_3: + case (byte) (byte) OpCode.iconst_3: m_int = new Int(); m_int.mValue = 3; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); break; - case (byte)(byte)OpCode.iconst_4: + case (byte) (byte) OpCode.iconst_4: m_int = new Int(); m_int.mValue = 4; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)OpCode.iconst_5: + case (byte) OpCode.iconst_5: m_int = new Int(); m_int.mValue = 5; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)OpCode.fconst_0: + case (byte) OpCode.fconst_0: Float m_float = new Float(); m_float.mValue = 0.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); + m_thread.m_currentFrame.OpStack.Push(m_float); result = true; break; - case (byte)OpCode.fconst_1: + case (byte) OpCode.fconst_1: m_float = new Float(); m_float.mValue = 1.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); + m_thread.m_currentFrame.OpStack.Push(m_float); result = true; break; - case (byte)OpCode.fconst_2: + case (byte) OpCode.fconst_2: m_float = new Float(); m_float.mValue = 2.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); + m_thread.m_currentFrame.OpStack.Push(m_float); result = true; break; - case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? - int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]; + case (byte) OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? + int pushvalue = (int) GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]; Int pushInt = new Int(); pushInt.mValue = pushvalue; - this.m_thread.m_currentFrame.OpStack.Push(pushInt); - this.m_thread.PC++; + m_thread.m_currentFrame.OpStack.Push(pushInt); + m_thread.PC++; result = true; break; - case (byte)OpCode.sipush: - short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + case (byte) OpCode.sipush: + short pushvalue2 = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); Int pushInt2 = new Int(); pushInt2.mValue = pushvalue2; - this.m_thread.m_currentFrame.OpStack.Push(pushInt2); - this.m_thread.PC += 2; + m_thread.m_currentFrame.OpStack.Push(pushInt2); + m_thread.PC += 2; result = true; break; - case (byte)OpCode.fload: - short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + case (byte) OpCode.fload: + short findex1 = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); Float fload = new Float(); - if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null) + if (m_thread.m_currentFrame.LocalVariables[findex1] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float) + if (m_thread.m_currentFrame.LocalVariables[findex1] is Float) { - fload.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[findex1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(fload); + fload.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[findex1]).mValue; + m_thread.m_currentFrame.OpStack.Push(fload); } } - this.m_thread.PC++; + m_thread.PC++; result = true; break; - case (byte)OpCode.iload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + case (byte) OpCode.iload_0: + if (m_thread.m_currentFrame.LocalVariables[0] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Int) + if (m_thread.m_currentFrame.LocalVariables[0] is Int) { Int newInt = new Int(); - newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newInt); + newInt.mValue = ((Int) m_thread.m_currentFrame.LocalVariables[0]).mValue; + m_thread.m_currentFrame.OpStack.Push(newInt); } } result = true; break; - case (byte)OpCode.iload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + case (byte) OpCode.iload_1: + if (m_thread.m_currentFrame.LocalVariables[1] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Int) + if (m_thread.m_currentFrame.LocalVariables[1] is Int) { Int newInt = new Int(); - newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newInt); + newInt.mValue = ((Int) m_thread.m_currentFrame.LocalVariables[1]).mValue; + m_thread.m_currentFrame.OpStack.Push(newInt); } } result = true; break; - case (byte)OpCode.fload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + case (byte) OpCode.fload_0: + if (m_thread.m_currentFrame.LocalVariables[0] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Float) + if (m_thread.m_currentFrame.LocalVariables[0] is Float) { Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[0]).mValue; + m_thread.m_currentFrame.OpStack.Push(newfloat); } } result = true; break; - case (byte)OpCode.fload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + case (byte) OpCode.fload_1: + if (m_thread.m_currentFrame.LocalVariables[1] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Float) + if (m_thread.m_currentFrame.LocalVariables[1] is Float) { Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[1]).mValue; + m_thread.m_currentFrame.OpStack.Push(newfloat); } } result = true; break; - case (byte)OpCode.fload_2: - if (this.m_thread.m_currentFrame.LocalVariables[2] != null) + case (byte) OpCode.fload_2: + if (m_thread.m_currentFrame.LocalVariables[2] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[2] is Float) + if (m_thread.m_currentFrame.LocalVariables[2] is Float) { Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[2]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[2]).mValue; + m_thread.m_currentFrame.OpStack.Push(newfloat); } } result = true; break; - case (byte)OpCode.fload_3: - if (this.m_thread.m_currentFrame.LocalVariables[3] != null) + case (byte) OpCode.fload_3: + if (m_thread.m_currentFrame.LocalVariables[3] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[3] is Float) + if (m_thread.m_currentFrame.LocalVariables[3] is Float) { Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[3]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[3]).mValue; + m_thread.m_currentFrame.OpStack.Push(newfloat); } } result = true; break; - case (byte)OpCode.istore: - short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - BaseType istor = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.istore: + short findex3 = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); + BaseType istor = m_thread.m_currentFrame.OpStack.Pop(); if (istor is Int) { - this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor; + m_thread.m_currentFrame.LocalVariables[findex3] = (Int) istor; } - this.m_thread.PC++; + m_thread.PC++; result = true; break; - case (byte)OpCode.fstore: - short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - BaseType fstor = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore: + short findex = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); + BaseType fstor = m_thread.m_currentFrame.OpStack.Pop(); if (fstor is Float) { - this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor; + m_thread.m_currentFrame.LocalVariables[findex] = (Float) fstor; } - this.m_thread.PC++; + m_thread.PC++; result = true; break; - case (byte)OpCode.istore_0: - BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.istore_0: + BaseType baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Int) { - this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset; + m_thread.m_currentFrame.LocalVariables[0] = (Int) baset; } result = true; break; - case (byte)OpCode.istore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.istore_1: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Int) { - this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset; + m_thread.m_currentFrame.LocalVariables[1] = (Int) baset; } result = true; break; - case (byte)OpCode.fstore_0: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_0: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[0] = (Float) baset; } result = true; break; - case (byte)OpCode.fstore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_1: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[1] = (Float) baset; } result = true; break; - case (byte)OpCode.fstore_2: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_2: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[2] = (Float) baset; } result = true; break; - case (byte)OpCode.fstore_3: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_3: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[3] = (Float) baset; } result = true; break; - case (byte)OpCode.pop: - this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.pop: + m_thread.m_currentFrame.OpStack.Pop(); result = true; break; - case (byte)OpCode.fadd: - BaseType bf2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bf1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fadd: + BaseType bf2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bf1 = m_thread.m_currentFrame.OpStack.Pop(); if (bf1 is Float && bf2 is Float) { Float nflt = new Float(); - nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(nflt); + nflt.mValue = ((Float) bf1).mValue + ((Float) bf2).mValue; + m_thread.m_currentFrame.OpStack.Push(nflt); } result = true; break; - case (byte)OpCode.fsub: - BaseType bsf2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bsf1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fsub: + BaseType bsf2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bsf1 = m_thread.m_currentFrame.OpStack.Pop(); if (bsf1 is Float && bsf2 is Float) { Float resf = new Float(); - resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(resf); + resf.mValue = ((Float) bsf1).mValue - ((Float) bsf2).mValue; + m_thread.m_currentFrame.OpStack.Push(resf); } result = true; break; - case (byte)OpCode.imul: //check the order of the two values off the stack is correct - BaseType bs2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bs1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.imul: //check the order of the two values off the stack is correct + BaseType bs2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bs1 = m_thread.m_currentFrame.OpStack.Pop(); if (bs1 is Int && bs2 is Int) { Int nInt = new Int(); - nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(nInt); + nInt.mValue = ((Int) bs1).mValue*((Int) bs2).mValue; + m_thread.m_currentFrame.OpStack.Push(nInt); } result = true; break; - case (byte)OpCode.iinc: - if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] != null) + case (byte) OpCode.iinc: + if (m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]] != + null) { - if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int) + if ( + m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] + ] is Int) { - ((Int)this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]; + ((Int) + m_thread.m_currentFrame.LocalVariables[ + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]]).mValue += + (sbyte) GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]; } } - this.m_thread.PC += 2; + m_thread.PC += 2; result = true; break; - case (byte)OpCode.f2i: - BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.f2i: + BaseType conv1 = m_thread.m_currentFrame.OpStack.Pop(); if (conv1 is Float) { Int newconv = new Int(); - newconv.mValue = (int)((Float)conv1).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newconv); + newconv.mValue = (int) ((Float) conv1).mValue; + m_thread.m_currentFrame.OpStack.Push(newconv); } result = true; break; - case (byte)OpCode.fcmpl: - BaseType flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fcmpl: + BaseType flcom2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType flcom1 = m_thread.m_currentFrame.OpStack.Pop(); if (flcom1 is Float && flcom2 is Float) { Int compres = new Int(); - if (((Float)flcom1).mValue < ((Float)flcom2).mValue) + if (((Float) flcom1).mValue < ((Float) flcom2).mValue) { compres.mValue = -1; } - else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) + else if (((Float) flcom1).mValue > ((Float) flcom2).mValue) { compres.mValue = 1; } @@ -347,21 +353,21 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { compres.mValue = 0; } - this.m_thread.m_currentFrame.OpStack.Push(compres); + m_thread.m_currentFrame.OpStack.Push(compres); } result = true; break; - case (byte)OpCode.fcmpg: - flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); - flcom1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fcmpg: + flcom2 = m_thread.m_currentFrame.OpStack.Pop(); + flcom1 = m_thread.m_currentFrame.OpStack.Pop(); if (flcom1 is Float && flcom2 is Float) { Int compres = new Int(); - if (((Float)flcom1).mValue < ((Float)flcom2).mValue) + if (((Float) flcom1).mValue < ((Float) flcom2).mValue) { compres.mValue = -1; } - else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) + else if (((Float) flcom1).mValue > ((Float) flcom2).mValue) { compres.mValue = 1; } @@ -369,128 +375,169 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { compres.mValue = 0; } - this.m_thread.m_currentFrame.OpStack.Push(compres); + m_thread.m_currentFrame.OpStack.Push(compres); } result = true; break; - case (byte)OpCode.ifge: - short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType compe1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.ifge: + short compareoffset2 = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType compe1 = m_thread.m_currentFrame.OpStack.Pop(); if (compe1 is Int) { - if (((Int)compe1).mValue >= 0) + if (((Int) compe1).mValue >= 0) { - this.m_thread.PC += -1 + compareoffset2; + m_thread.PC += -1 + compareoffset2; } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } result = true; break; - case (byte)OpCode.ifle: - short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType comp1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.ifle: + short compareoffset1 = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType comp1 = m_thread.m_currentFrame.OpStack.Pop(); if (comp1 is Int) { - if (((Int)comp1).mValue <= 0) + if (((Int) comp1).mValue <= 0) { - this.m_thread.PC += -1 + compareoffset1; + m_thread.PC += -1 + compareoffset1; } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } result = true; break; - case (byte)OpCode.if_icmpge: - short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType bc2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bc1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.if_icmpge: + short compareoffset = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType bc2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bc1 = m_thread.m_currentFrame.OpStack.Pop(); if (bc1 is Int && bc2 is Int) { //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); - if (((Int)bc1).mValue >= ((Int)bc2).mValue) + if (((Int) bc1).mValue >= ((Int) bc2).mValue) { // Console.WriteLine("branch compare true , offset is " +compareoffset); // Console.WriteLine("current PC is " + this._mThread.PC); - this.m_thread.PC += -1 + compareoffset; + m_thread.PC += -1 + compareoffset; //Console.WriteLine("new PC is " + this._mThread.PC); } else { //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } result = true; break; - case (byte)OpCode.if_icmple: - short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType bcl2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bcl1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.if_icmple: + short compareloffset = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType bcl2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bcl1 = m_thread.m_currentFrame.OpStack.Pop(); if (bcl1 is Int && bcl2 is Int) { //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); - if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) + if (((Int) bcl1).mValue <= ((Int) bcl2).mValue) { // Console.WriteLine("branch compare true , offset is " + compareloffset); // Console.WriteLine("current PC is " + this._mThread.PC); - this.m_thread.PC += -1 + compareloffset; + m_thread.PC += -1 + compareloffset; // Console.WriteLine("new PC is " + this._mThread.PC); } else { //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } result = true; break; - case (byte)OpCode._goto: - short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - this.m_thread.PC += -1 + offset; + case (byte) OpCode._goto: + short offset = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + m_thread.PC += -1 + offset; result = true; break; - case (byte)OpCode.getstatic: - short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) + case (byte) OpCode.getstatic: + short fieldrefIndex = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + if (m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) { - if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + if ( + ((ClassRecord.PoolFieldRef) m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). + mClass.Name.Value == m_thread.currentClass.MClass.Name.Value) { //from this class - if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) + if ( + m_thread.currentClass.StaticFields.ContainsKey( + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) + if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name. + Value] is Float) { Float retFloat = new Float(); - retFloat.mValue = ((Float)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(retFloat); + retFloat.mValue = + ((Float) + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value]).mValue; + m_thread.m_currentFrame.OpStack.Push(retFloat); } - else if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) + else if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value] is Int) { Int retInt = new Int(); - retInt.mValue = ((Int)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; + retInt.mValue = + ((Int) + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). + mNameType.Name.Value]).mValue; // Console.WriteLine("getting static field, " + retInt.mValue); - this.m_thread.m_currentFrame.OpStack.Push(retInt); + m_thread.m_currentFrame.OpStack.Push(retInt); } } } @@ -499,36 +546,58 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM //get from a different class } } - this.m_thread.PC += 2; + m_thread.PC += 2; result = true; break; - case (byte)OpCode.putstatic: - fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType addstatic = this.m_thread.m_currentFrame.OpStack.Pop(); - if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) + case (byte) OpCode.putstatic: + fieldrefIndex = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType addstatic = m_thread.m_currentFrame.OpStack.Pop(); + if (m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) { - if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + if ( + ((ClassRecord.PoolFieldRef) m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). + mClass.Name.Value == m_thread.currentClass.MClass.Name.Value) { // this class - if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) + if ( + m_thread.currentClass.StaticFields.ContainsKey( + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) { if (addstatic is Float) { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) + if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value] is Float) { Float newf = new Float(); - newf.mValue = ((Float)addstatic).mValue; - this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf; + newf.mValue = ((Float) addstatic).mValue; + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value] = newf; } } else if (addstatic is Int) { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) + if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value] is Int) { //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); Int newi = new Int(); - newi.mValue = ((Int)addstatic).mValue; - this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi; + newi.mValue = ((Int) addstatic).mValue; + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value] = newi; } } } @@ -538,10 +607,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM // a different class } } - this.m_thread.PC += 2; + m_thread.PC += 2; result = true; break; - } return result; diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs index a5bd48b..b27630a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs @@ -25,15 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Framework; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { partial class Thread @@ -46,10 +37,15 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM switch (opcode) { case 184: - short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]); - if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) + short refIndex = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + if (m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) { - string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Type.Value; + string typ = + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]). + mNameType.Type.Value; string typeparam = ""; string typereturn = ""; int firstbrak = 0; @@ -58,16 +54,22 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM secondbrak = typ.LastIndexOf(')'); typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); - if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + if ( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass + .Name.Value == m_thread.currentClass.MClass.Name.Value) { //calling a method in this class if (typeparam.Length == 0) { - this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2)); + m_thread.JumpToStaticVoidMethod( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]) + .mNameType.Name.Value, (m_thread.PC + 2)); } else { - this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2)); + m_thread.JumpToStaticParamMethod( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]) + .mNameType.Name.Value, typeparam, (m_thread.PC + 2)); } } else @@ -75,15 +77,19 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM //calling a method of a different class // OpenSimAPI Class - if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") + if ( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]). + mClass.Name.Value == "OpenSimAPI") { - this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null); + m_thread.scriptInfo.api.CallMethod( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]) + .mNameType.Name.Value, null); } } } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } result = true; break; @@ -93,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 5a42285..2814720 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs @@ -25,10 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { partial class Thread @@ -37,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 698a518..4e7351e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs @@ -26,8 +26,6 @@ * */ using System; -using System.Collections.Generic; -using System.Text; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; @@ -47,77 +45,77 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public bool Excute() { bool run = true; - byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++]; - // Console.WriteLine("opCode is: " + currentOpCode); + byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[m_thread.PC++]; + // Console.WriteLine("opCode is: " + currentOpCode); bool handled = false; - handled = this.IsLogicOpCode(currentOpCode); + handled = IsLogicOpCode(currentOpCode); if (!handled) { - handled = this.IsMethodOpCode(currentOpCode); + handled = IsMethodOpCode(currentOpCode); } if (!handled) { if (currentOpCode == 172) { - if (this.m_thread.stack.StackFrames.Count > 1) + if (m_thread.stack.StackFrames.Count > 1) { Console.WriteLine("returning int from function"); - int retPC1 = this.m_thread.m_currentFrame.ReturnPC; - BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC1; + int retPC1 = m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = m_thread.m_currentFrame.OpStack.Pop(); + m_thread.stack.StackFrames.Pop(); + m_thread.m_currentFrame = m_thread.stack.StackFrames.Peek(); + m_thread.PC = retPC1; if (bas1 is Int) { - this.m_thread.m_currentFrame.OpStack.Push((Int)bas1); + m_thread.m_currentFrame.OpStack.Push((Int) bas1); } } else { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); + // Console.WriteLine("No parent function so ending program"); + m_thread.stack.StackFrames.Pop(); run = false; } handled = true; } if (currentOpCode == 174) { - if (this.m_thread.stack.StackFrames.Count > 1) + if (m_thread.stack.StackFrames.Count > 1) { Console.WriteLine("returning float from function"); - int retPC1 = this.m_thread.m_currentFrame.ReturnPC; - BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC1; + int retPC1 = m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = m_thread.m_currentFrame.OpStack.Pop(); + m_thread.stack.StackFrames.Pop(); + m_thread.m_currentFrame = m_thread.stack.StackFrames.Peek(); + m_thread.PC = retPC1; if (bas1 is Float) { - this.m_thread.m_currentFrame.OpStack.Push((Float)bas1); + m_thread.m_currentFrame.OpStack.Push((Float) bas1); } } else { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); + // Console.WriteLine("No parent function so ending program"); + m_thread.stack.StackFrames.Pop(); run = false; } handled = true; } if (currentOpCode == 177) { - if (this.m_thread.stack.StackFrames.Count > 1) + if (m_thread.stack.StackFrames.Count > 1) { Console.WriteLine("returning from function"); - int retPC = this.m_thread.m_currentFrame.ReturnPC; - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC; + int retPC = m_thread.m_currentFrame.ReturnPC; + m_thread.stack.StackFrames.Pop(); + m_thread.m_currentFrame = m_thread.stack.StackFrames.Peek(); + m_thread.PC = retPC; } else { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); + // Console.WriteLine("No parent function so ending program"); + m_thread.stack.StackFrames.Pop(); run = false; } handled = true; @@ -128,8 +126,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM Console.WriteLine("opcode " + currentOpCode + " not been handled "); } return run; - } } } -} +} \ 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 34d4fc5..adad1a8 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs @@ -25,21 +25,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { public class MainMemory { public Heap HeapArea; public MethodMemory MethodArea; - + public MainMemory() { MethodArea = new MethodMemory(); 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 f470583..86df4c2 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs @@ -25,9 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { @@ -43,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 21e467a..1d9cabb 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs @@ -25,13 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { public class Object { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs index 9fcec49..616b64e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { public enum OpCode : byte @@ -81,4 +77,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM getstatic = 178, putstatic = 179 } -} +} \ 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 56e02ff..4f6c1e7 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs @@ -25,9 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { @@ -39,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 a5f9029..306a70d 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs @@ -25,9 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; using System.Collections.Generic; -using System.Text; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM @@ -44,6 +42,5 @@ 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 b810676..64093ef 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs @@ -25,15 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; +using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.ExtensionsScriptModule; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { @@ -55,8 +49,8 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public Thread() { - this.m_Interpreter = new Interpreter(this); - this.stack = new Stack(); + m_Interpreter = new Interpreter(this); + stack = new Stack(); } public void SetPC(int methodpointer) @@ -68,15 +62,15 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void StartMethod(ClassRecord rec, string methName) { m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); - this.currentClass = rec; + stack.StackFrames.Push(m_currentFrame); + currentClass = rec; currentClass.StartMethod(this, methName); } - public void StartMethod( string methName) + public void StartMethod(string methName) { m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); + stack.StackFrames.Push(m_currentFrame); currentClass.StartMethod(this, methName); } @@ -84,7 +78,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { m_currentFrame = new StackFrame(); m_currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(m_currentFrame); + stack.StackFrames.Push(m_currentFrame); currentClass.StartMethod(this, methName); } @@ -95,25 +89,23 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM BaseType bs1 = m_currentFrame.OpStack.Pop(); m_currentFrame = new StackFrame(); m_currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(m_currentFrame); - m_currentFrame.LocalVariables[0] = ((Int)bs1); + stack.StackFrames.Push(m_currentFrame); + m_currentFrame.LocalVariables[0] = ((Int) bs1); currentClass.StartMethod(this, methName); } if (param == "F") { - } } public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) { - } public bool Excute() { excutionCounter++; - return this.m_Interpreter.Excute(); + return m_Interpreter.Excute(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs index 0f0ff16..ea99626 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs @@ -26,11 +26,7 @@ * */ -using System; using System.Collections.Generic; -using System.Text; - -using OpenSim.Region.ExtensionsScriptModule; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine { @@ -53,4 +49,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine return returns; } } -} +} \ 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 b1258f6..274932a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs @@ -27,15 +27,11 @@ */ using System; using System.Collections.Generic; -using System.Text; +using System.Diagnostics; using System.IO; -using System.Threading; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM; -using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine { @@ -45,14 +41,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine private BlockingQueue CompileScripts = new BlockingQueue(); private MainMemory _mainMemory; - ScriptInfo scriptInfo; + private ScriptInfo scriptInfo; public void Initialise(ScriptInfo info) { scriptInfo = info; _mainMemory = new MainMemory(); - Thread.GlobalMemory = this._mainMemory; + Thread.GlobalMemory = _mainMemory; Thread.World = info.world; CompileScript(); @@ -60,33 +56,33 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); } - void events_OnNewPresence(ScenePresence presence) + private void events_OnNewPresence(ScenePresence presence) { - for (int i = 0; i < this._threads.Count; i++) + for (int i = 0; i < _threads.Count; i++) { - if (!this._threads[i].running) + if (!_threads[i].running) { - this._threads[i].StartMethod("OnNewPresence"); + _threads[i].StartMethod("OnNewPresence"); bool run = true; while (run) { - run = this._threads[i].Excute(); + run = _threads[i].Excute(); } } } } - void events_OnFrame() + private void events_OnFrame() { - for (int i = 0; i < this._threads.Count; i++) + for (int i = 0; i < _threads.Count; i++) { - if (!this._threads[i].running) + if (!_threads[i].running) { - this._threads[i].StartMethod("OnFrame"); + _threads[i].StartMethod("OnFrame"); bool run = true; while (run) { - run = this._threads[i].Excute(); + run = _threads[i].Excute(); } } } @@ -103,12 +99,12 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine CompileInfo comp = new CompileInfo(); comp.script = script; comp.scriptName = script; - this.CompileScripts.Enqueue(comp); + CompileScripts.Enqueue(comp); } public void CompileScript() { - CompileInfo comp = this.CompileScripts.Dequeue(); + CompileInfo comp = CompileScripts.Dequeue(); string script = comp.script; string scriptName = comp.scriptName; try @@ -121,13 +117,13 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine tw.Close(); //now compile - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); + ProcessStartInfo psi = new ProcessStartInfo("javac.exe", "*.java"); // psi.RedirectStandardOutput = true; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + psi.WindowStyle = ProcessWindowStyle.Hidden; psi.UseShellExecute = false; - System.Diagnostics.Process javacomp; - javacomp = System.Diagnostics.Process.Start(psi); + Process javacomp; + javacomp = Process.Start(psi); javacomp.WaitForExit(); @@ -136,17 +132,17 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine class1.LoadClassFromFile(scriptName + ".class"); class1.PrintToConsole(); //Console.WriteLine(); - this._mainMemory.MethodArea.Classes.Add(class1); - class1.AddMethodsToMemory(this._mainMemory.MethodArea); + _mainMemory.MethodArea.Classes.Add(class1); + class1.AddMethodsToMemory(_mainMemory.MethodArea); Thread newThread = new Thread(); - this._threads.Add(newThread); + _threads.Add(newThread); newThread.currentClass = class1; newThread.scriptInfo = scriptInfo; //now delete the created files - System.IO.File.Delete(scriptName + ".java"); - System.IO.File.Delete(scriptName + ".class"); + File.Delete(scriptName + ".java"); + File.Delete(scriptName + ".class"); //this.OnFrame(); } catch (Exception e) @@ -164,8 +160,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine public CompileInfo() { - } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs index a36ad77..3c82952 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs @@ -26,13 +26,9 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types { - public class ArrayReference :BaseType + public class ArrayReference : BaseType { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs index 5921446..4026c10 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types { public class ObjectReference : BaseType @@ -38,7 +34,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types public ObjectReference() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs index aa59681..de1aa87 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs @@ -26,14 +26,9 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes { public class Byte : BaseType { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs index 1cef150..0e17057 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs @@ -26,14 +26,9 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes { public class Char : BaseType { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs index 0614dfd..ce8648c 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs @@ -26,11 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes { public class Float : BaseType @@ -39,7 +34,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes public Float() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs index 35f9822..251b736 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs @@ -26,11 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes { public class Int : BaseType @@ -39,7 +34,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes public Int() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Script.cs b/OpenSim/Region/ExtensionsScriptModule/Script.cs index 251b8c3..5f85799 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Script.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Script.cs @@ -37,7 +37,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public class TestScript : IScript { - ScriptInfo script; + private ScriptInfo script; public string Name { @@ -51,14 +51,14 @@ namespace OpenSim.Region.ExtensionsScriptModule script.events.OnNewPresence += events_OnNewPresence; } - void events_OnNewPresence(ScenePresence presence) + private void events_OnNewPresence(ScenePresence presence) { script.logger.Verbose("Hello " + presence.Firstname.ToString() + "!"); } - void events_OnFrame() + private void events_OnFrame() { //script.logger.Verbose("Hello World!"); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs index 39dc878..9384efa 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs @@ -27,24 +27,21 @@ */ using System; -using System.Collections.Generic; -using System.Text; +using OpenSim.Region.Environment.Scenes; using Key = libsecondlife.LLUUID; using Rotation = libsecondlife.LLQuaternion; using Vector = libsecondlife.LLVector3; using LSLList = System.Collections.Generic.List; -using OpenSim.Region.Environment.Scenes; - namespace OpenSim.Region.ExtensionsScriptModule { // This class is to be used for engines which may not be able to access the Scene directly. // Scene access is preffered, but obviously not possible on some non-.NET languages. public class ScriptAPI { - Scene scene; - ScriptInterpretedAPI interpretedAPI; + private Scene scene; + private ScriptInterpretedAPI interpretedAPI; public ScriptAPI(Scene world, Key taskID) { @@ -57,4 +54,4 @@ namespace OpenSim.Region.ExtensionsScriptModule return null; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs index aaadd1f..cfa3c8e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using libsecondlife; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; @@ -52,12 +53,12 @@ namespace OpenSim.Region.ExtensionsScriptModule world = scene; events = world.EventManager; logger = MainLog.Instance; - api = new ScriptAPI(world, libsecondlife.LLUUID.Zero); + api = new ScriptAPI(world, LLUUID.Zero); } - public void CreateTaskAPI(libsecondlife.LLUUID task) + public void CreateTaskAPI(LLUUID task) { api = new ScriptAPI(world, task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs index eb85dbe..2895c4e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs @@ -27,26 +27,25 @@ */ using System; -using System.Collections.Generic; using System.Text; +using Axiom.Math; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.LandManagement; +using OpenSim.Region.Environment.Scenes; using Key = libsecondlife.LLUUID; using Rotation = libsecondlife.LLQuaternion; using Vector = libsecondlife.LLVector3; using LSLList = System.Collections.Generic.List; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; -using libsecondlife; - namespace OpenSim.Region.ExtensionsScriptModule { /// /// A class inteded to act as an API for LSL-styled interpreted languages /// /// Avoid at all costs. This should ONLY be used for LSL. - class ScriptInterpretedAPI + internal class ScriptInterpretedAPI { - protected LLUUID m_object; + protected Key m_object; protected Scene m_scene; /// @@ -78,7 +77,7 @@ namespace OpenSim.Region.ExtensionsScriptModule /// /// The scene the object is located in /// The specific member being 'occupied' by the script - public ScriptInterpretedAPI(Scene world, libsecondlife.LLUUID member) + public ScriptInterpretedAPI(Scene world, Key member) { m_scene = world; m_object = member; @@ -96,7 +95,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public float osAcos(float val) { - return (float)Math.Acos(val); + return (float) Math.Acos(val); } [Obsolete("Unimplemented")] @@ -105,14 +104,15 @@ namespace OpenSim.Region.ExtensionsScriptModule Vector myPosition = Task.AbsolutePosition; Land myParcel = Scene.LandManager.getLandObject(myPosition.X, myPosition.Y); - OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); + MainLog.Instance.Warn("script", + "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); return; } [Obsolete("Unimplemented")] public void osAdjustSoundVolume(float volume) { - OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)"); + MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)"); return; } @@ -125,8 +125,8 @@ namespace OpenSim.Region.ExtensionsScriptModule [Obsolete("Unimplemented")] public float osAngleBetween(Rotation a, Rotation b) { - Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); - Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); + Quaternion axA = new Quaternion(a.W, a.X, a.Y, a.Z); + Quaternion axB = new Quaternion(b.W, b.X, b.Y, b.Z); return 0; } @@ -145,12 +145,12 @@ namespace OpenSim.Region.ExtensionsScriptModule public float osAsin(float val) { - return (float)Math.Asin(val); + return (float) Math.Asin(val); } public float osAtan2(float x, float y) { - return (float)Math.Atan2(x, y); + return (float) Math.Atan2(x, y); } [Obsolete("Unimplemented")] @@ -178,10 +178,10 @@ namespace OpenSim.Region.ExtensionsScriptModule public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) { - Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); - Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); - Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); - Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); + Quaternion axQ = new Quaternion(); + Vector3 axFwd = new Vector3(fwd.X, fwd.Y, fwd.Z); + Vector3 axLeft = new Vector3(left.X, left.Y, left.Z); + Vector3 axUp = new Vector3(up.X, up.Y, up.Z); axQ.FromAxes(axFwd, axLeft, axUp); @@ -190,14 +190,14 @@ namespace OpenSim.Region.ExtensionsScriptModule public Rotation osAxisAngle2Rot(Vector axis, float angle) { - Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); + Quaternion axQ = Quaternion.FromAngleAxis(angle, new Vector3(axis.X, axis.Y, axis.Z)); return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); } public string osBase64ToString(string str) { - Encoding enc = System.Text.Encoding.UTF8; + Encoding enc = Encoding.UTF8; return enc.GetString(Convert.FromBase64String(str)); } @@ -223,7 +223,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public int osCeil(float val) { - return (int)Math.Ceiling(val); + return (int) Math.Ceiling(val); } [Obsolete("Unimplemented")] @@ -252,13 +252,13 @@ namespace OpenSim.Region.ExtensionsScriptModule public float osCos(float theta) { - return (float)Math.Cos(theta); + return (float) Math.Cos(theta); } public void osCreateLink(Key target, int parent) { - if(Scene.Entities[target] is SceneObjectGroup) - Task.LinkToGroup((SceneObjectGroup)Scene.Entities[target]); + if (Scene.Entities[target] is SceneObjectGroup) + Task.LinkToGroup((SceneObjectGroup) Scene.Entities[target]); return; } @@ -292,4 +292,4 @@ namespace OpenSim.Region.ExtensionsScriptModule return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs index 068df33..44feaff 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs @@ -26,19 +26,14 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using libsecondlife; using Key = libsecondlife.LLUUID; namespace OpenSim.Region.ExtensionsScriptModule { - public class ScriptInterpretedEvents { public delegate void OnTouchStartDelegate(Key user); + public event OnTouchStartDelegate OnTouchStart; @@ -48,4 +43,4 @@ namespace OpenSim.Region.ExtensionsScriptModule OnTouchStart(user); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index 95ab2ca..2778e9c 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -26,27 +26,28 @@ * */ using System.Collections.Generic; +using Nini.Config; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ExtensionsScriptModule.CSharp; using OpenSim.Region.ExtensionsScriptModule.JScript; using OpenSim.Region.ExtensionsScriptModule.JVMEngine; -using Nini.Config; namespace OpenSim.Region.ExtensionsScriptModule { public class ScriptManager : IRegionModule, IExtensionScriptModule { - readonly List scripts = new List(); - Scene m_scene; - readonly Dictionary compilers = new Dictionary(); + private readonly List scripts = new List(); + private Scene m_scene; + private readonly Dictionary compilers = new Dictionary(); private void LoadFromCompiler(Dictionary compiledscripts) { foreach (KeyValuePair script in compiledscripts) { - ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + ScriptInfo scriptInfo = new ScriptInfo(m_scene); + // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. MainLog.Instance.Verbose("Loading " + script.Key); script.Value.Initialise(scriptInfo); scripts.Add(script.Value); @@ -70,7 +71,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public void Initialise(Scene scene, IConfigSource config) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("SCRIPTMODULE", "Initialising Extensions Scripting Module"); + MainLog.Instance.Verbose("SCRIPTMODULE", "Initialising Extensions Scripting Module"); m_scene = scene; m_scene.RegisterModuleInterface(this); @@ -78,12 +79,10 @@ namespace OpenSim.Region.ExtensionsScriptModule public void PostInitialise() { - } public void Close() { - } public string Name @@ -92,8 +91,8 @@ namespace OpenSim.Region.ExtensionsScriptModule } public bool IsSharedModule -{ - get { return false; } + { + get { return false; } } public bool Compile(string filename) @@ -127,7 +126,8 @@ namespace OpenSim.Region.ExtensionsScriptModule public bool AddPreCompiledScript(IScript script) { MainLog.Instance.Verbose("Loading script " + script.Name); - ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + ScriptInfo scriptInfo = new ScriptInfo(m_scene); + // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. script.Initialise(scriptInfo); scripts.Add(script); @@ -141,9 +141,9 @@ namespace OpenSim.Region.ExtensionsScriptModule bool AddPreCompiledScript(IScript script); } - interface IScriptCompiler + internal interface IScriptCompiler { Dictionary 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 2d4d898..a8f1de1 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs @@ -27,24 +27,26 @@ */ using System.Reflection; using System.Runtime.InteropServices; + // Information about this assembly is defined by the following // attributes. // // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("PhysXplugin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PhysXplugin")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly : AssemblyTitle("PhysXplugin")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("PhysXplugin")] +[assembly : AssemblyCopyright("")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. -[assembly: ComVisible(false)] + +[assembly : ComVisible(false)] // The assembly version has following format : // @@ -53,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 95e6095..b412818 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -39,7 +39,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { public BasicPhysicsPlugin() { - } public bool Init() @@ -59,7 +58,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public void Dispose() { - } } @@ -70,7 +68,6 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public BasicScene() { - } public override PhysicsActor AddAvatar(string avName, PhysicsVector position) @@ -83,17 +80,15 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override void RemovePrim(PhysicsActor prim) { - } public override void RemoveAvatar(PhysicsActor actor) { - BasicActor act = (BasicActor)actor; + BasicActor act = (BasicActor) actor; if (_actors.Contains(act)) { _actors.Remove(act); } - } /* @@ -102,7 +97,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin return null; } */ - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) + + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + PhysicsVector size, Quaternion rotation) { return null; } @@ -112,8 +109,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { foreach (BasicActor actor in _actors) { - actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep); - actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep); + actor.Position.X = actor.Position.X + (actor.Velocity.X*timeStep); + actor.Position.Y = actor.Position.Y + (actor.Velocity.Y*timeStep); if (actor.Position.Y < 0) { actor.Position.Y = 0.1F; @@ -132,17 +129,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.Position.Z + (actor.Velocity.Z * timeStep); + actor.Position.Z = actor.Position.Z + (actor.Velocity.Z*timeStep); } } else @@ -150,32 +148,26 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin actor.Position.Z = height; actor.Velocity.Z = 0; } - - } } public override void GetResults() { - } public override bool IsThreaded { - get - { - return (false); // for now we won't be multithreaded + get { return (false); // for now we won't be multithreaded } } public override void SetTerrain(float[] heightMap) { - this._heightMap = heightMap; + _heightMap = heightMap; } public override void DeleteTerrain() { - } } @@ -185,6 +177,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin private PhysicsVector _velocity; private PhysicsVector _acceleration; private bool flying; + public BasicActor() { _velocity = new PhysicsVector(); @@ -194,97 +187,56 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override bool Flying { - get - { - return flying; - } - set - { - flying = value; - } + get { return flying; } + set { flying = value; } } public override PhysicsVector Position { - get - { - return _position; - } - set - { - _position = value; - } + get { return _position; } + set { _position = value; } } public override PhysicsVector Size { - get - { - return new PhysicsVector(0, 0, 0); - } - set - { - } + get { return new PhysicsVector(0, 0, 0); } + set { } } public override PhysicsVector Velocity { - get - { - return _velocity; - } - set - { - _velocity = value; - } + get { return _velocity; } + set { _velocity = value; } } public override Quaternion Orientation { - get - { - return Quaternion.Identity; - } - set - { - - } + get { return Quaternion.Identity; } + set { } } public override PhysicsVector Acceleration { - get - { - return _acceleration; - } - + get { return _acceleration; } } public override bool Kinematic { - get - { - return true; - } - set - { - - } + get { return true; } + set { } } + public void SetAcceleration(PhysicsVector accel) { - this._acceleration = accel; + _acceleration = accel; } public override void AddForce(PhysicsVector force) { - } public override void SetMomentum(PhysicsVector momentum) { - } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs index 0180917..c8596f7 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -27,24 +27,26 @@ */ using System.Reflection; using System.Runtime.InteropServices; + // Information about this assembly is defined by the following // attributes. // // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("BulletXPlugin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BulletXPlugin")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly : AssemblyTitle("BulletXPlugin")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("BulletXPlugin")] +[assembly : AssemblyCopyright("")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. -[assembly: ComVisible(false)] + +[assembly : ComVisible(false)] // The assembly version has following format : // @@ -53,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 9fdc017..1658e2d 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -27,6 +27,7 @@ */ #region Copyright + /* * Copyright (c) Contributors, http://www.openmetaverse.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. @@ -54,18 +55,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + #endregion + #region References + using System; using System.Collections.Generic; -using OpenSim.Region.Physics.Manager; -using OpenSim.Framework; -using Axiom.Math; -using AxiomQuaternion = Axiom.Math.Quaternion; -//Specific References for BulletXPlugin using MonoXnaCompactMaths; +using OpenSim.Framework; +using OpenSim.Region.Physics.Manager; using XnaDevRu.BulletX; using XnaDevRu.BulletX.Dynamics; +using AxiomQuaternion = Axiom.Math.Quaternion; +using BoxShape=XnaDevRu.BulletX.BoxShape; +//Specific References for BulletXPlugin #endregion @@ -80,27 +84,31 @@ namespace OpenSim.Region.Physics.BulletXPlugin { } } + /// /// BulletXConversions are called now BulletXMaths /// This Class converts objects and types for BulletX and give some operations /// - public class BulletXMaths + public class BulletXMaths { //Vector3 - public static MonoXnaCompactMaths.Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector) + public static Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector) { - return new MonoXnaCompactMaths.Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z); + return new Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z); } - public static PhysicsVector XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3) + + public static PhysicsVector XnaVector3ToPhysicsVector(Vector3 xnaVector3) { return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z); } + //Quaternion - public static MonoXnaCompactMaths.Quaternion AxiomQuaternionToXnaQuaternion(AxiomQuaternion axiomQuaternion) + public static Quaternion AxiomQuaternionToXnaQuaternion(AxiomQuaternion axiomQuaternion) { - return new MonoXnaCompactMaths.Quaternion(axiomQuaternion.x, axiomQuaternion.y, axiomQuaternion.z, axiomQuaternion.w); + return new Quaternion(axiomQuaternion.x, axiomQuaternion.y, axiomQuaternion.z, axiomQuaternion.w); } - public static AxiomQuaternion XnaQuaternionToAxiomQuaternion(MonoXnaCompactMaths.Quaternion xnaQuaternion) + + public static AxiomQuaternion XnaQuaternionToAxiomQuaternion(Quaternion xnaQuaternion) { return new AxiomQuaternion(xnaQuaternion.W, xnaQuaternion.X, xnaQuaternion.Y, xnaQuaternion.Z); } @@ -110,70 +118,79 @@ namespace OpenSim.Region.Physics.BulletXPlugin //- GetRotation (class MatrixOperations) //- GetElement (class MathHelper) //- SetElement (class MathHelper) - internal static void SetRotation(ref Matrix m, MonoXnaCompactMaths.Quaternion q) + internal static void SetRotation(ref Matrix m, Quaternion q) { float d = q.LengthSquared(); - float s = 2f / d; - float xs = q.X * s, ys = q.Y * s, zs = q.Z * s; - float wx = q.W * xs, wy = q.W * ys, wz = q.W * zs; - float xx = q.X * xs, xy = q.X * ys, xz = q.X * zs; - float yy = q.Y * ys, yz = q.Y * zs, zz = q.Z * zs; + float s = 2f/d; + float xs = q.X*s, ys = q.Y*s, zs = q.Z*s; + float wx = q.W*xs, wy = q.W*ys, wz = q.W*zs; + float xx = q.X*xs, xy = q.X*ys, xz = q.X*zs; + float yy = q.Y*ys, yz = q.Y*zs, zz = q.Z*zs; m = new Matrix(1 - (yy + zz), xy - wz, xz + wy, 0, - xy + wz, 1 - (xx + zz), yz - wx, 0, - xz - wy, yz + wx, 1 - (xx + yy), 0, - m.M41, m.M42, m.M43, 1); + xy + wz, 1 - (xx + zz), yz - wx, 0, + xz - wy, yz + wx, 1 - (xx + yy), 0, + m.M41, m.M42, m.M43, 1); } - internal static MonoXnaCompactMaths.Quaternion GetRotation(Matrix m) + + internal static Quaternion GetRotation(Matrix m) { - MonoXnaCompactMaths.Quaternion q = new MonoXnaCompactMaths.Quaternion(); + Quaternion q = new Quaternion(); float trace = m.M11 + m.M22 + m.M33; if (trace > 0) { - float s = (float)Math.Sqrt(trace + 1); - q.W = s * 0.5f; - s = 0.5f / s; + float s = (float) Math.Sqrt(trace + 1); + q.W = s*0.5f; + s = 0.5f/s; - q.X = (m.M32 - m.M23) * s; - q.Y = (m.M13 - m.M31) * s; - q.Z = (m.M21 - m.M12) * s; + q.X = (m.M32 - m.M23)*s; + q.Y = (m.M13 - m.M31)*s; + q.Z = (m.M21 - m.M12)*s; } else { - int i = m.M11 < m.M22 ? - (m.M22 < m.M33 ? 2 : 1) : - (m.M11 < m.M33 ? 2 : 0); - int j = (i + 1) % 3; - int k = (i + 2) % 3; - - float s = (float)Math.Sqrt(GetElement(m, i, i) - GetElement(m, j, j) - GetElement(m, k, k) + 1); - SetElement(ref q, i, s * 0.5f); - s = 0.5f / s; - - q.W = (GetElement(m, k, j) - GetElement(m, j, k)) * s; - SetElement(ref q, j, (GetElement(m, j, i) + GetElement(m, i, j)) * s); - SetElement(ref q, k, (GetElement(m, k, i) + GetElement(m, i, k)) * s); + int i = m.M11 < m.M22 + ? + (m.M22 < m.M33 ? 2 : 1) + : + (m.M11 < m.M33 ? 2 : 0); + int j = (i + 1)%3; + int k = (i + 2)%3; + + float s = (float) Math.Sqrt(GetElement(m, i, i) - GetElement(m, j, j) - GetElement(m, k, k) + 1); + SetElement(ref q, i, s*0.5f); + s = 0.5f/s; + + q.W = (GetElement(m, k, j) - GetElement(m, j, k))*s; + SetElement(ref q, j, (GetElement(m, j, i) + GetElement(m, i, j))*s); + SetElement(ref q, k, (GetElement(m, k, i) + GetElement(m, i, k))*s); } return q; } - internal static float SetElement(ref MonoXnaCompactMaths.Quaternion q, int index, float value) + + internal static float SetElement(ref Quaternion q, int index, float value) { switch (index) { case 0: - q.X = value; break; + q.X = value; + break; case 1: - q.Y = value; break; + q.Y = value; + break; case 2: - q.Z = value; break; + q.Z = value; + break; case 3: - q.W = value; break; + q.W = value; + break; } return 0; } + internal static float GetElement(Matrix mat, int row, int col) { switch (row) @@ -187,7 +204,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin return mat.M12; case 2: return mat.M13; - } break; + } + break; case 1: switch (col) { @@ -197,7 +215,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin return mat.M22; case 2: return mat.M23; - } break; + } + break; case 2: switch (col) { @@ -207,12 +226,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin return mat.M32; case 2: return mat.M33; - } break; + } + break; } return 0; } } + /// /// PhysicsPlugin Class for BulletX /// @@ -223,10 +244,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin public BulletXPlugin() { } + public bool Init() { return true; } + public PhysicsScene GetScene() { if (_mScene == null) @@ -235,20 +258,24 @@ namespace OpenSim.Region.Physics.BulletXPlugin } return (_mScene); } + public string GetName() { - return ("modified_BulletX");//Changed!! "BulletXEngine" To "modified_BulletX" + return ("modified_BulletX"); //Changed!! "BulletXEngine" To "modified_BulletX" } + public void Dispose() { } } + /// /// PhysicsScene Class for BulletX /// public class BulletXScene : PhysicsScene { #region BulletXScene Fields + public DiscreteDynamicsWorld ddWorld; private CollisionDispatcher cDispatcher; private OverlappingPairCache opCache; @@ -271,33 +298,58 @@ namespace OpenSim.Region.Physics.BulletXPlugin private List _characters = new List(); private List _prims = new List(); - public static float Gravity { get { return gravity; } } - public static float HeightLevel0 { get { return heightLevel0; } } - public static float HeightLevel1 { get { return heightLevel1; } } - public static float LowGravityFactor { get { return lowGravityFactor; } } - public static int MaxXY { get { return maxXY; } } - public static int MaxZ { get { return maxZ; } } + public static float Gravity + { + get { return gravity; } + } + + public static float HeightLevel0 + { + get { return heightLevel0; } + } + + public static float HeightLevel1 + { + get { return heightLevel1; } + } + + public static float LowGravityFactor + { + get { return lowGravityFactor; } + } + + public static int MaxXY + { + get { return maxXY; } + } + + public static int MaxZ + { + get { return maxZ; } + } private List _forgottenRigidBodies = new List(); internal string is_ex_message = "Can't remove rigidBody!: "; + #endregion public BulletXScene() { cDispatcher = new CollisionDispatcher(); - MonoXnaCompactMaths.Vector3 worldMinDim = new MonoXnaCompactMaths.Vector3((float)minXY, (float)minXY, (float)minZ); - MonoXnaCompactMaths.Vector3 worldMaxDim = new MonoXnaCompactMaths.Vector3((float)maxXY, (float)maxXY, (float)maxZ); + Vector3 worldMinDim = new Vector3((float) minXY, (float) minXY, (float) minZ); + Vector3 worldMaxDim = new Vector3((float) maxXY, (float) maxXY, (float) maxZ); opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles); sicSolver = new SequentialImpulseConstraintSolver(); lock (BulletXLock) { ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver); - ddWorld.Gravity = new MonoXnaCompactMaths.Vector3(0, 0, -gravity); + ddWorld.Gravity = new Vector3(0, 0, -gravity); } //this._heightmap = new float[65536]; } - public override PhysicsActor AddAvatar(string avName, PhysicsVector position) + + public override PhysicsActor AddAvatar(string avName, PhysicsVector position) { PhysicsVector pos = new PhysicsVector(); pos.X = position.X; @@ -311,6 +363,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin } return newAv; } + public override void RemoveAvatar(PhysicsActor actor) { if (actor is BulletXCharacter) @@ -319,20 +372,22 @@ namespace OpenSim.Region.Physics.BulletXPlugin { try { - ddWorld.RemoveRigidBody(((BulletXCharacter)actor).RigidBody); + ddWorld.RemoveRigidBody(((BulletXCharacter) actor).RigidBody); } catch (Exception ex) { BulletXMessage(is_ex_message + ex.Message, true); - ((BulletXCharacter)actor).RigidBody.ActivationState = ActivationState.DisableSimulation; - AddForgottenRigidBody(((BulletXCharacter)actor).RigidBody); + ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation; + AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody); } - _characters.Remove((BulletXCharacter)actor); + _characters.Remove((BulletXCharacter) actor); } GC.Collect(); } } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation) + + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + PhysicsVector size, AxiomQuaternion rotation) { PhysicsActor result; @@ -358,11 +413,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin return result; } - public PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Axiom.Math.Quaternion rotation) + + public PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation) { return AddPrim("", position, size, rotation, null, null); } - public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) + + public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation, + Mesh mesh, PrimitiveBaseShape pbs) { BulletXPrim newPrim = null; lock (BulletXLock) @@ -372,6 +430,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin } return newPrim; } + public override void RemovePrim(PhysicsActor prim) { if (prim is BulletXPrim) @@ -380,19 +439,20 @@ namespace OpenSim.Region.Physics.BulletXPlugin { try { - ddWorld.RemoveRigidBody(((BulletXPrim)prim).RigidBody); + ddWorld.RemoveRigidBody(((BulletXPrim) prim).RigidBody); } catch (Exception ex) { BulletXMessage(is_ex_message + ex.Message, true); - ((BulletXPrim)prim).RigidBody.ActivationState = ActivationState.DisableSimulation; - AddForgottenRigidBody(((BulletXPrim)prim).RigidBody); + ((BulletXPrim) prim).RigidBody.ActivationState = ActivationState.DisableSimulation; + AddForgottenRigidBody(((BulletXPrim) prim).RigidBody); } - _prims.Remove((BulletXPrim)prim); + _prims.Remove((BulletXPrim) prim); } GC.Collect(); } } + public override void Simulate(float timeStep) { lock (BulletXLock) @@ -408,6 +468,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin UpdateKineticsForAll(); } } + private void MoveAllObjects(float timeStep) { foreach (BulletXCharacter actor in _characters) @@ -418,6 +479,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin { } } + private void ValidateHeightForAll() { float _height; @@ -431,7 +493,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin foreach (BulletXPrim prim in _prims) { //_height = HeightValue(prim.RigidBodyPosition); - _height = _simFlatPlanet.HeightValue(prim.RigidBodyPosition); + _height = _simFlatPlanet.HeightValue(prim.RigidBodyPosition); prim.ValidateHeight(_height); //if (_simFlatPlanet.heightIsNotValid(prim.RigidBodyPosition, out _height)) prim.ValidateHeight(_height); } @@ -444,6 +506,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin // prim.ValidateHeight(0); //} } + private void UpdateKineticsForAll() { //UpdatePosition > UpdateKinetics. @@ -458,17 +521,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin } //if(this._simFlatPlanet!=null) this._simFlatPlanet.Restore(); } + public override void GetResults() { - } + public override bool IsThreaded { - get - { - return (false); // for now we won't be multithreaded + get { return (false); // for now we won't be multithreaded } } + public override void SetTerrain(float[] heightMap) { ////As the same as ODE, heightmap (x,y) must be swapped for BulletX @@ -494,41 +557,44 @@ namespace OpenSim.Region.Physics.BulletXPlugin DeleteTerrain(); //There is a BulletXLock inside the constructor of BulletXPlanet //this._simFlatPlanet = new BulletXPlanet(this, swappedHeightMap); - this._simFlatPlanet = new BulletXPlanet(this, heightMap); + _simFlatPlanet = new BulletXPlanet(this, heightMap); //this._heightmap = heightMap; } + public override void DeleteTerrain() { - if (this._simFlatPlanet != null) + if (_simFlatPlanet != null) { lock (BulletXLock) { try { - ddWorld.RemoveRigidBody(this._simFlatPlanet.RigidBody); + ddWorld.RemoveRigidBody(_simFlatPlanet.RigidBody); } catch (Exception ex) { BulletXMessage(is_ex_message + ex.Message, true); - this._simFlatPlanet.RigidBody.ActivationState = ActivationState.DisableSimulation; - AddForgottenRigidBody(this._simFlatPlanet.RigidBody); + _simFlatPlanet.RigidBody.ActivationState = ActivationState.DisableSimulation; + AddForgottenRigidBody(_simFlatPlanet.RigidBody); } } - this._simFlatPlanet = null; + _simFlatPlanet = null; GC.Collect(); BulletXMessage("Terrain erased!", false); } //this._heightmap = null; } + internal void AddForgottenRigidBody(RigidBody forgottenRigidBody) { _forgottenRigidBodies.Add(forgottenRigidBody); } + private void RemoveForgottenRigidBodies() { RigidBody forgottenRigidBody; int nRigidBodies = _forgottenRigidBodies.Count; - for(int i = nRigidBodies - 1; i >= 0; i--) + for (int i = nRigidBodies - 1; i >= 0; i--) { forgottenRigidBody = _forgottenRigidBodies[i]; try @@ -544,10 +610,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin } GC.Collect(); } + internal void BulletXMessage(string message, bool isWarning) { PhysicsPluginManager.PhysicsPluginMessage("[Modified BulletX]:\t" + message, isWarning); } + //temp //private float HeightValue(MonoXnaCompactMaths.Vector3 position) //{ @@ -559,10 +627,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin // height = this._heightmap[li_y * 256 + li_x]; // if (height < 0) height = 0; // else if (height > maxZ) height = maxZ; - + // return height; //} } + /// /// PhysicsActor Character Class for BulletX /// @@ -576,21 +645,24 @@ namespace OpenSim.Region.Physics.BulletXPlugin private bool flying; private RigidBody rigidBody; - public MonoXnaCompactMaths.Vector3 RigidBodyPosition + public Vector3 RigidBodyPosition { - get { return this.rigidBody.CenterOfMassPosition; } + get { return rigidBody.CenterOfMassPosition; } } + public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos) : 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) + AxiomQuaternion.Identity) { } + public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, - PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation) + PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation) { //This fields will be removed. They're temporal float _sizeX = 0.5f; @@ -622,23 +694,23 @@ namespace OpenSim.Region.Physics.BulletXPlugin //For now, like ODE, collisionShape = sphere of radious = 1.0 CollisionShape _collisionShape = new SphereShape(1.0f); DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); - MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3(); + Vector3 _localInertia = new Vector3(); _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 - MonoXnaCompactMaths.Vector3 _vDebugTranslation; + Vector3 _vDebugTranslation; _vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition; rigidBody.Translate(_vDebugTranslation); parent_scene.ddWorld.AddRigidBody(rigidBody); } } + public override PhysicsVector Position { - get - { - return _position; - } + get { return _position; } set { lock (BulletXScene.BulletXLock) @@ -648,12 +720,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Velocity { - get - { - return _velocity; - } + get { return _velocity; } set { lock (BulletXScene.BulletXLock) @@ -663,12 +733,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Size { - get - { - return _size; - } + get { return _size; } set { lock (BulletXScene.BulletXLock) @@ -677,19 +745,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Acceleration { - get - { - return _acceleration; - } + get { return _acceleration; } } + public override AxiomQuaternion Orientation { - get - { - return _orientation; - } + get { return _orientation; } set { lock (BulletXScene.BulletXLock) @@ -698,24 +762,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public RigidBody RigidBody { - get - { - return rigidBody; - } + get { return rigidBody; } } + public override bool Flying { - get - { - return flying; - } - set - { - flying = value; - } + get { return flying; } + set { flying = value; } } + public void SetAcceleration(PhysicsVector accel) { lock (BulletXScene.BulletXLock) @@ -723,116 +781,121 @@ namespace OpenSim.Region.Physics.BulletXPlugin _acceleration = accel; } } + public override bool Kinematic { - get - { - return false; - } - set - { - - } + get { return false; } + set { } } + public override void AddForce(PhysicsVector force) { - } + public override void SetMomentum(PhysicsVector momentum) { - } + internal void Move(float timeStep) { - MonoXnaCompactMaths.Vector3 vec = new MonoXnaCompactMaths.Vector3(); + Vector3 vec = new Vector3(); //At this point it's supossed that: //_velocity == rigidBody.LinearVelocity - vec.X = this._velocity.X; - vec.Y = this._velocity.Y; - vec.Z = this._velocity.Z; + vec.X = _velocity.X; + vec.Y = _velocity.Y; + vec.Z = _velocity.Z; if ((vec.X != 0.0f) || (vec.Y != 0.0f) || (vec.Z != 0.0f)) rigidBody.Activate(); if (flying) { //Antigravity with movement - if (this._position.Z <= BulletXScene.HeightLevel0) + if (_position.Z <= BulletXScene.HeightLevel0) { - vec.Z += BulletXScene.Gravity * timeStep; + vec.Z += BulletXScene.Gravity*timeStep; } - //Lowgravity with movement - else if ((this._position.Z > BulletXScene.HeightLevel0) - && (this._position.Z <= BulletXScene.HeightLevel1)) + //Lowgravity with movement + else if ((_position.Z > BulletXScene.HeightLevel0) + && (_position.Z <= BulletXScene.HeightLevel1)) { - vec.Z += BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor); + vec.Z += BulletXScene.Gravity*timeStep*(1.0f - BulletXScene.LowGravityFactor); } - //Lowgravity with... - else if (this._position.Z > BulletXScene.HeightLevel1) + //Lowgravity with... + else if (_position.Z > BulletXScene.HeightLevel1) { if (vec.Z > 0) //no movement - vec.Z = BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor); + vec.Z = BulletXScene.Gravity*timeStep*(1.0f - BulletXScene.LowGravityFactor); else - vec.Z += BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor); - + vec.Z += BulletXScene.Gravity*timeStep*(1.0f - BulletXScene.LowGravityFactor); } } rigidBody.LinearVelocity = vec; } + //This validation is very basic internal void ValidateHeight(float heighmapPositionValue) { - if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z / 2.0f) + if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z/2.0f) { Matrix m = rigidBody.WorldTransform; - MonoXnaCompactMaths.Vector3 v3 = m.Translation; - v3.Z = heighmapPositionValue + _size.Z / 2.0f; + Vector3 v3 = m.Translation; + v3.Z = heighmapPositionValue + _size.Z/2.0f; m.Translation = v3; rigidBody.WorldTransform = m; //When an Avie touch the ground it's vertical velocity it's reduced to ZERO - Speed(new PhysicsVector(this.rigidBody.LinearVelocity.X, this.rigidBody.LinearVelocity.Y, 0.0f)); + Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); } } + internal void UpdateKinetics() { - this._position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); - this._velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity); + _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); + _velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity); //Orientation it seems that it will be the default. ReOrient(); } #region Methods for updating values of RigidBody + private void Translate() { - Translate(this._position); + Translate(_position); } + private void Translate(PhysicsVector _newPos) { - MonoXnaCompactMaths.Vector3 _translation; + Vector3 _translation; _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; rigidBody.Translate(_translation); } + private void Speed() { - Speed(this._velocity); + Speed(_velocity); } + private void Speed(PhysicsVector _newSpeed) { - MonoXnaCompactMaths.Vector3 _speed; + Vector3 _speed; _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); rigidBody.LinearVelocity = _speed; } + private void ReOrient() { - ReOrient(this._orientation); + ReOrient(_orientation); } + private void ReOrient(AxiomQuaternion _newOrient) { - MonoXnaCompactMaths.Quaternion _newOrientation; + Quaternion _newOrientation; _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient); Matrix _comTransform = rigidBody.CenterOfMassTransform; BulletXMaths.SetRotation(ref _comTransform, _newOrientation); rigidBody.CenterOfMassTransform = _comTransform; } + #endregion } + /// /// PhysicsActor Prim Class for BulletX /// @@ -851,27 +914,32 @@ namespace OpenSim.Region.Physics.BulletXPlugin //_physical value will be linked with the prim object value private Boolean _physical = false; - public MonoXnaCompactMaths.Vector3 RigidBodyPosition + public Vector3 RigidBodyPosition { - get { return this.rigidBody.CenterOfMassPosition; } + get { return rigidBody.CenterOfMassPosition; } } + public BulletXPrim(BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, AxiomQuaternion rotation) : this("", parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, null, null) { } - public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, - AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) + + public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, + AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) : this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs) { } - public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, PhysicsVector size, - PhysicsVector aceleration, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) + + public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, + PhysicsVector size, + PhysicsVector aceleration, AxiomQuaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) { if ((size.X == 0) || (size.Y == 0) || (size.Z == 0)) throw new Exception("Size 0"); if (rotation.Norm == 0f) rotation = AxiomQuaternion.Identity; _position = pos; - if (_physical) _velocity = velocity; else _velocity = new PhysicsVector(); + if (_physical) _velocity = velocity; + else _velocity = new PhysicsVector(); _size = size; _acceleration = aceleration; _orientation = rotation; @@ -889,26 +957,26 @@ namespace OpenSim.Region.Physics.BulletXPlugin { _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(pos); //For now all prims are boxes - CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_size) / 2.0f); + CollisionShape _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_size)/2.0f); DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); - MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3(); - if(_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 - rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); + 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.ActivationState = ActivationState.DisableDeactivation; //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition - MonoXnaCompactMaths.Vector3 _vDebugTranslation; + Vector3 _vDebugTranslation; _vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition; rigidBody.Translate(_vDebugTranslation); //--- parent_scene.ddWorld.AddRigidBody(rigidBody); } } + public override PhysicsVector Position { - get - { - return _position; - } + get { return _position; } set { lock (BulletXScene.BulletXLock) @@ -918,12 +986,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Velocity { - get - { - return _velocity; - } + get { return _velocity; } set { lock (BulletXScene.BulletXLock) @@ -941,12 +1007,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Size { - get - { - return _size; - } + get { return _size; } set { lock (BulletXScene.BulletXLock) @@ -956,19 +1020,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Acceleration { - get - { - return _acceleration; - } + get { return _acceleration; } } + public override AxiomQuaternion Orientation { - get - { - return _orientation; - } + get { return _orientation; } set { lock (BulletXScene.BulletXLock) @@ -978,43 +1038,34 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public float Mass { 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 RigidBody RigidBody { - get - { - return rigidBody; - } + get { return rigidBody; } } + public override bool Flying { - get - { - return false; //no flying prims for you - } - set - { - + get { return false; //no flying prims for you } + set { } } + public Boolean Physical { - get - { - return _physical; - } - set - { - _physical = value; - } + get { return _physical; } + set { _physical = value; } } + public void SetAcceleration(PhysicsVector accel) { lock (BulletXScene.BulletXLock) @@ -1022,6 +1073,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin _acceleration = accel; } } + public override bool Kinematic { get @@ -1034,36 +1086,38 @@ namespace OpenSim.Region.Physics.BulletXPlugin //this._prim.Kinematic = value; } } + public override void AddForce(PhysicsVector force) { - } + public override void SetMomentum(PhysicsVector momentum) { - } + internal void ValidateHeight(float heighmapPositionValue) { - if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z / 2.0f) + if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue + _size.Z/2.0f) { Matrix m = rigidBody.WorldTransform; - MonoXnaCompactMaths.Vector3 v3 = m.Translation; - v3.Z = heighmapPositionValue + _size.Z / 2.0f; + Vector3 v3 = m.Translation; + v3.Z = heighmapPositionValue + _size.Z/2.0f; m.Translation = v3; rigidBody.WorldTransform = m; //When a Prim touch the ground it's vertical velocity it's reduced to ZERO //Static objects don't have linear velocity - if(_physical) - Speed(new PhysicsVector(this.rigidBody.LinearVelocity.X, this.rigidBody.LinearVelocity.Y, 0.0f)); + if (_physical) + Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); } } + internal void UpdateKinetics() { if (_physical) //Updates properties. Prim updates its properties physically { - this._position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); - this._velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity); - this._orientation = BulletXMaths.XnaQuaternionToAxiomQuaternion(rigidBody.Orientation); + _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); + _velocity = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.LinearVelocity); + _orientation = BulletXMaths.XnaQuaternionToAxiomQuaternion(rigidBody.Orientation); } else //Doesn't updates properties. That's a cancel { @@ -1074,35 +1128,41 @@ namespace OpenSim.Region.Physics.BulletXPlugin } #region Methods for updating values of RigidBody + private void Translate() { - Translate(this._position); + Translate(_position); } + private void Translate(PhysicsVector _newPos) { - MonoXnaCompactMaths.Vector3 _translation; + Vector3 _translation; _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; rigidBody.Translate(_translation); } + private void Speed() { - Speed(this._velocity); + Speed(_velocity); } + private void Speed(PhysicsVector _newSpeed) { - MonoXnaCompactMaths.Vector3 _speed; + Vector3 _speed; _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); rigidBody.LinearVelocity = _speed; } + private void ReSize() { - ReSize(this._size); + ReSize(_size); } + private 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 - MonoXnaCompactMaths.Vector3 _newsize; + Vector3 _newsize; _newsize = BulletXMaths.PhysicsVectorToXnaVector3(_newSize); if ((_newsize.X == 0) || (_newsize.Y == 0) || (_newsize.Z == 0)) throw new Exception("Size 0"); @@ -1114,67 +1174,77 @@ namespace OpenSim.Region.Physics.BulletXPlugin Matrix _startTransform = Matrix.Identity; Matrix _centerOfMassOffset = Matrix.Identity; RigidBody _tmpRigidBody; - _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(this._position); + _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(_position); //For now all prims are boxes - CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_newSize) / 2.0f); + CollisionShape _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_newSize)/2.0f); DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); - MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3(); + Vector3 _localInertia = new Vector3(); if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 - _tmpRigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); + _tmpRigidBody = + 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 - MonoXnaCompactMaths.Vector3 _vDebugTranslation; + Vector3 _vDebugTranslation; _vDebugTranslation = _startTransform.Translation - rigidBody.CenterOfMassPosition; _tmpRigidBody.Translate(_vDebugTranslation); //--- //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) + 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); } rigidBody = _tmpRigidBody; - this._parent_scene.ddWorld.AddRigidBody(rigidBody); - if (_physical) Speed();//Static objects don't have linear velocity + _parent_scene.ddWorld.AddRigidBody(rigidBody); + if (_physical) Speed(); //Static objects don't have linear velocity ReOrient(); GC.Collect(); } + private void ReOrient() { - ReOrient(this._orientation); + ReOrient(_orientation); } + private void ReOrient(AxiomQuaternion _newOrient) { - MonoXnaCompactMaths.Quaternion _newOrientation; + Quaternion _newOrientation; _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient); Matrix _comTransform = rigidBody.CenterOfMassTransform; BulletXMaths.SetRotation(ref _comTransform, _newOrientation); rigidBody.CenterOfMassTransform = _comTransform; } - #endregion + #endregion } + /// /// This Class manage a HeighField as a RigidBody. This is for to be added in the BulletXScene /// internal class BulletXPlanet { private PhysicsVector _staticPosition; - private PhysicsVector _staticVelocity; + private PhysicsVector _staticVelocity; private AxiomQuaternion _staticOrientation; private float _mass; private BulletXScene _parentscene; internal float[] _heightField; private RigidBody _flatPlanet; - internal RigidBody RigidBody { get { return _flatPlanet; } } + + internal RigidBody RigidBody + { + get { return _flatPlanet; } + } + internal BulletXPlanet(BulletXScene parent_scene, float[] heightField) { - _staticPosition = new PhysicsVector(BulletXScene.MaxXY / 2, BulletXScene.MaxXY/2, 0); + _staticPosition = new PhysicsVector(BulletXScene.MaxXY/2, BulletXScene.MaxXY/2, 0); _staticVelocity = new PhysicsVector(); _staticOrientation = AxiomQuaternion.Identity; _mass = 0; //No active @@ -1193,40 +1263,45 @@ namespace OpenSim.Region.Physics.BulletXPlugin try { _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(_staticPosition); - CollisionShape _collisionShape = new HeightfieldTerrainShape(BulletXScene.MaxXY, BulletXScene.MaxXY, _heightField, (float)BulletXScene.MaxZ, 2, true, false); + CollisionShape _collisionShape = + new HeightfieldTerrainShape(BulletXScene.MaxXY, BulletXScene.MaxXY, _heightField, + (float) BulletXScene.MaxZ, 2, true, false); DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); - MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3(); + Vector3 _localInertia = new Vector3(); //_collisionShape.CalculateLocalInertia(_mass, out _localInertia); //Always when mass > 0 - _flatPlanet = new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); + _flatPlanet = + new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, + _angularDamping, _friction, _restitution); //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition - MonoXnaCompactMaths.Vector3 _vDebugTranslation; + Vector3 _vDebugTranslation; _vDebugTranslation = _startTransform.Translation - _flatPlanet.CenterOfMassPosition; _flatPlanet.Translate(_vDebugTranslation); parent_scene.ddWorld.AddRigidBody(_flatPlanet); } catch (Exception ex) { - this._parentscene.BulletXMessage(ex.Message, true); + _parentscene.BulletXMessage(ex.Message, true); } } - this._parentscene.BulletXMessage("BulletXPlanet created.", false); + _parentscene.BulletXMessage("BulletXPlanet created.", false); } - internal float HeightValue(MonoXnaCompactMaths.Vector3 position) + + internal float HeightValue(Vector3 position) { int li_x, li_y; float height; - li_x = (int)Math.Round(position.X); + li_x = (int) Math.Round(position.X); if (li_x < 0) li_x = 0; if (li_x >= BulletXScene.MaxXY) li_x = BulletXScene.MaxXY - 1; - li_y = (int)Math.Round(position.Y); + li_y = (int) Math.Round(position.Y); if (li_y < 0) li_y = 0; if (li_y >= BulletXScene.MaxXY) li_y = BulletXScene.MaxXY - 1; - height = ((HeightfieldTerrainShape)this._flatPlanet.CollisionShape).getHeightFieldValue(li_x, li_y); + height = ((HeightfieldTerrainShape) _flatPlanet.CollisionShape).getHeightFieldValue(li_x, li_y); if (height < 0) height = 0; else if (height > BulletXScene.MaxZ) height = BulletXScene.MaxZ; return height; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs index 2355e91..c213b64 100644 --- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs @@ -27,24 +27,26 @@ */ using System.Reflection; using System.Runtime.InteropServices; + // Information about this assembly is defined by the following // attributes. // // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("PhysicsManager")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("PhysicsManager")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly : AssemblyTitle("PhysicsManager")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("PhysicsManager")] +[assembly : AssemblyCopyright("")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. -[assembly: ComVisible(false)] + +[assembly : ComVisible(false)] // The assembly version has following format : // @@ -53,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/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 0fa7455..b59c13a 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -30,7 +30,9 @@ using Axiom.Math; namespace OpenSim.Region.Physics.Manager { public delegate void PositionUpdate(PhysicsVector position); + public delegate void VelocityUpdate(PhysicsVector velocity); + public delegate void OrientationUpdate(Quaternion orientation); public abstract class PhysicsActor @@ -43,52 +45,22 @@ namespace OpenSim.Region.Physics.Manager public static PhysicsActor Null { - get - { - return new NullPhysicsActor(); - } + get { return new NullPhysicsActor(); } } - public abstract PhysicsVector Size - { - get; - set; - } + public abstract PhysicsVector Size { get; set; } - public abstract PhysicsVector Position - { - get; - set; - } + public abstract PhysicsVector Position { get; set; } - public abstract PhysicsVector Velocity - { - get; - set; - } + public abstract PhysicsVector Velocity { get; set; } - public abstract PhysicsVector Acceleration - { - get; - } + public abstract PhysicsVector Acceleration { get; } - public abstract Quaternion Orientation - { - get; - set; - } + public abstract Quaternion Orientation { get; set; } - public abstract bool Flying - { - get; - set; - } + public abstract bool Flying { get; set; } - public abstract bool Kinematic - { - get; - set; - } + public abstract bool Kinematic { get; set; } public abstract void AddForce(PhysicsVector force); @@ -99,50 +71,26 @@ namespace OpenSim.Region.Physics.Manager { public override PhysicsVector Position { - get - { - return PhysicsVector.Zero; - } - set - { - return; - } + get { return PhysicsVector.Zero; } + set { return; } } public override PhysicsVector Size { - get - { - return PhysicsVector.Zero; - } - set - { - return; - } + get { return PhysicsVector.Zero; } + set { return; } } public override PhysicsVector Velocity { - get - { - return PhysicsVector.Zero; - } - set - { - return; - } + get { return PhysicsVector.Zero; } + set { return; } } public override Quaternion Orientation { - get - { - return Quaternion.Identity; - } - set - { - - } + get { return Quaternion.Identity; } + set { } } public override PhysicsVector Acceleration @@ -152,26 +100,14 @@ namespace OpenSim.Region.Physics.Manager public override bool Flying { - get - { - return false; - } - set - { - return; - } + get { return false; } + set { return; } } public override bool Kinematic { - get - { - return true; - } - set - { - return; - } + get { return true; } + set { return; } } public override void AddForce(PhysicsVector force) @@ -184,4 +120,4 @@ namespace OpenSim.Region.Physics.Manager return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index 81bc938..09ebf29 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs @@ -33,77 +33,77 @@ using OpenSim.Framework.Console; namespace OpenSim.Region.Physics.Manager { - /// - /// Description of MyClass. - /// - public class PhysicsPluginManager - { - private Dictionary _plugins=new Dictionary(); - - public PhysicsPluginManager() - { - - } - - public PhysicsScene GetPhysicsScene(string engineName) - { + /// + /// Description of MyClass. + /// + public class PhysicsPluginManager + { + private Dictionary _plugins = new Dictionary(); + + public PhysicsPluginManager() + { + } + + public PhysicsScene GetPhysicsScene(string engineName) + { if (String.IsNullOrEmpty(engineName)) { return PhysicsScene.Null; } - if(_plugins.ContainsKey(engineName)) - { - MainLog.Instance.Verbose("PHYSICS","creating "+engineName); - return _plugins[engineName].GetScene(); - } - else + if (_plugins.ContainsKey(engineName)) + { + MainLog.Instance.Verbose("PHYSICS", "creating " + engineName); + return _plugins[engineName].GetScene(); + } + else { MainLog.Instance.Warn("PHYSICS", "couldn't find physicsEngine: {0}", engineName); - throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName)); - } - } - - public void LoadPlugins() - { - string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics"); - string[] pluginFiles = Directory.GetFiles(path, "*.dll"); - + throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}", engineName)); + } + } + + public void LoadPlugins() + { + string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); + string[] pluginFiles = Directory.GetFiles(path, "*.dll"); + - for(int i= 0; i"; + return "<" + X + "," + Y + "," + Z + ">"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs index 3f840cc..d110a17 100644 --- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs @@ -27,24 +27,26 @@ */ using System.Reflection; using System.Runtime.InteropServices; + // Information about this assembly is defined by the following // attributes. // // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("RealPhysXplugin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RealPhysXplugin")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly : AssemblyTitle("RealPhysXplugin")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("RealPhysXplugin")] +[assembly : AssemblyCopyright("")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. -[assembly: ComVisible(false)] + +[assembly : ComVisible(false)] // The assembly version has following format : // @@ -53,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/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/OdePlugin/Meshing/HelperTypes.cs index 2ace097..13184e2 100644 --- a/OpenSim/Region/Physics/OdePlugin/Meshing/HelperTypes.cs +++ b/OpenSim/Region/Physics/OdePlugin/Meshing/HelperTypes.cs @@ -27,10 +27,9 @@ */ using System; -using System.Globalization; -using System.Diagnostics; using System.Collections.Generic; - +using System.Diagnostics; +using System.Globalization; using OpenSim.Region.Physics.Manager; public class Vertex : IComparable @@ -76,8 +75,6 @@ public class Vertex : IComparable { return me.CompareTo(other) < 0; } - - } public class Simplex : IComparable @@ -122,8 +119,7 @@ public class Simplex : IComparable return 0; } - -}; +} ; public class Triangle { @@ -131,9 +127,9 @@ public class Triangle public Vertex v2; public Vertex v3; - float radius_square; - float cx; - float cy; + private float radius_square; + private float cx; + private float cy; public Triangle(Vertex _v1, Vertex _v2, Vertex _v3) { @@ -149,18 +145,18 @@ public class Triangle float dx, dy; float dd; - dx = x - this.cx; - dy = y - this.cy; + dx = x - cx; + dy = y - cy; - dd = dx * dx + dy * dy; - if (dd < this.radius_square) + dd = dx*dx + dy*dy; + if (dd < radius_square) return true; else return false; } - void CalcCircle() + private void CalcCircle() { // Calculate the center and the radius of a circle given by three points p1, p2, p3 // It is assumed, that the triangles vertices are already set correctly @@ -198,8 +194,8 @@ public class Triangle p3y = v3.point.Y; /* calc helping values first */ - c1 = (p1x * p1x + p1y * p1y - p2x * p2x - p2y * p2y) / 2; - c2 = (p1x * p1x + p1y * p1y - p3x * p3x - p3y * p3y) / 2; + c1 = (p1x*p1x + p1y*p1y - p2x*p2x - p2y*p2y)/2; + c2 = (p1x*p1x + p1y*p1y - p3x*p3x - p3y*p3y)/2; v1x = p1x - p2x; v1y = p1y - p2y; @@ -207,35 +203,34 @@ public class Triangle v2x = p1x - p3x; v2y = p1y - p3y; - z = (c1 * v2x - c2 * v1x); - n = (v1y * v2x - v2y * v1x); + z = (c1*v2x - c2*v1x); + n = (v1y*v2x - v2y*v1x); - if (n == 0.0) // This is no triangle, i.e there are (at least) two points at the same location + if (n == 0.0) // This is no triangle, i.e there are (at least) two points at the same location { radius_square = 0.0f; return; } - this.cy = (float)(z / n); + cy = (float) (z/n); if (v2x != 0.0) { - this.cx = (float)((c2 - v2y * this.cy) / v2x); + cx = (float) ((c2 - v2y*cy)/v2x); } else if (v1x != 0.0) { - this.cx = (float)((c1 - v1y * this.cy) / v1x); + cx = (float) ((c1 - v1y*cy)/v1x); } else { Debug.Assert(false, "Malformed triangle"); /* Both terms zero means nothing good */ } - rx = (p1x - this.cx); - ry = (p1y - this.cy); - - this.radius_square = (float)(rx * rx + ry * ry); + rx = (p1x - cx); + ry = (p1y - cy); + radius_square = (float) (rx*rx + ry*ry); } public List GetSimplices() @@ -254,17 +249,18 @@ public class Triangle public override String ToString() { - NumberFormatInfo nfi = new NumberFormatInfo(); nfi.CurrencyDecimalDigits = 2; nfi.CurrencyDecimalSeparator = "."; - String s1 = "<" + v1.point.X.ToString(nfi) + "," + v1.point.Y.ToString(nfi) + "," + v1.point.Z.ToString(nfi) + ">"; - String s2 = "<" + v2.point.X.ToString(nfi) + "," + v2.point.Y.ToString(nfi) + "," + v2.point.Z.ToString(nfi) + ">"; - String s3 = "<" + v3.point.X.ToString(nfi) + "," + v3.point.Y.ToString(nfi) + "," + v3.point.Z.ToString(nfi) + ">"; + String s1 = "<" + v1.point.X.ToString(nfi) + "," + v1.point.Y.ToString(nfi) + "," + v1.point.Z.ToString(nfi) + + ">"; + String s2 = "<" + v2.point.X.ToString(nfi) + "," + v2.point.Y.ToString(nfi) + "," + v2.point.Z.ToString(nfi) + + ">"; + String s3 = "<" + v3.point.X.ToString(nfi) + "," + v3.point.Y.ToString(nfi) + "," + v3.point.Z.ToString(nfi) + + ">"; return s1 + ";" + s2 + ";" + s3; - } public PhysicsVector getNormal() @@ -281,12 +277,12 @@ public class Triangle // Cross product for normal PhysicsVector n = new PhysicsVector(); float nx, ny, nz; - n.X = e1.Y * e2.Z - e1.Z * e2.Y; - n.Y = e1.Z * e2.X - e1.X * e2.Z; - n.Z = e1.X * e2.Y - e1.Y * e2.X; + n.X = e1.Y*e2.Z - e1.Z*e2.Y; + n.Y = e1.Z*e2.X - e1.X*e2.Z; + n.Z = e1.X*e2.Y - e1.Y*e2.X; // Length - float l = (float)Math.Sqrt(n.X * n.X + n.Y * n.Y + n.Z * n.Z); + float l = (float) Math.Sqrt(n.X*n.X + n.Y*n.Y + n.Z*n.Z); // Normalized "normal" n.X /= l; @@ -303,6 +299,4 @@ public class Triangle v1 = v2; v2 = vt; } -} - - +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs index dd18e24..46de15e 100644 --- a/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/OdePlugin/Meshing/Meshmerizer.cs @@ -27,12 +27,8 @@ */ using System; -using System.Globalization; -using System.Diagnostics; using System.Collections.Generic; -using System.Text; using System.Runtime.InteropServices; - using OpenSim.Framework; using OpenSim.Region.Physics.Manager; @@ -75,14 +71,14 @@ namespace OpenSim.Region.Physics.OdePlugin public float[] getVertexListAsFloat() { - 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]; PhysicsVector point = v.point; - result[3 * i + 0] = point.X; - result[3 * i + 1] = point.Y; - result[3 * i + 2] = point.Z; + result[3*i + 0] = point.X; + result[3*i + 1] = point.Y; + result[3*i + 2] = point.Z; } GCHandle.Alloc(result, GCHandleType.Pinned); return result; @@ -90,13 +86,13 @@ namespace OpenSim.Region.Physics.OdePlugin 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); } GCHandle.Alloc(result, GCHandleType.Pinned); return result; @@ -110,16 +106,13 @@ namespace OpenSim.Region.Physics.OdePlugin foreach (Triangle t in newMesh.triangles) Add(t); - } } - public class Meshmerizer { - - static List FindInfluencedTriangles(List triangles, Vertex v) + private static List FindInfluencedTriangles(List triangles, Vertex v) { List influenced = new List(); foreach (Triangle t in triangles) @@ -133,9 +126,10 @@ namespace OpenSim.Region.Physics.OdePlugin } return influenced; } - - - static void InsertVertices(List vertices, int usedForSeed, List triangles, List innerBorders) + + + private static void InsertVertices(List vertices, int usedForSeed, List triangles, + List innerBorders) { // This is a variant of the delaunay algorithm // each time a new vertex is inserted, all triangles that are influenced by it are deleted @@ -143,7 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin // It is not very time efficient but easy to implement. int iCurrentVertex; - int iMaxVertex=vertices.Count; + int iMaxVertex = vertices.Count; for (iCurrentVertex = usedForSeed; iCurrentVertex < iMaxVertex; iCurrentVertex++) { // Background: A triangle mesh fulfills the delaunay condition if (iff!) @@ -154,8 +148,8 @@ namespace OpenSim.Region.Physics.OdePlugin // 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]; - List influencedTriangles=FindInfluencedTriangles(triangles, v); + Vertex v = vertices[iCurrentVertex]; + List influencedTriangles = FindInfluencedTriangles(triangles, v); List simplices = new List(); @@ -175,10 +169,10 @@ namespace OpenSim.Region.Physics.OdePlugin // Look for duplicate simplices here. // Remember, they are directly side by side in the list right now int iSimplex; - List innerSimplices=new List(); + List innerSimplices = new List(); for (iSimplex = 1; iSimplex < simplices.Count; iSimplex++) // Startindex=1, so we can refer backwards { - if (simplices[iSimplex - 1].CompareTo(simplices[iSimplex])==0) + if (simplices[iSimplex - 1].CompareTo(simplices[iSimplex]) == 0) { innerSimplices.Add(simplices[iSimplex - 1]); innerSimplices.Add(simplices[iSimplex]); @@ -187,7 +181,7 @@ namespace OpenSim.Region.Physics.OdePlugin foreach (Simplex s in innerSimplices) { - simplices.Remove(s); + simplices.Remove(s); } // each simplex still in the list belongs to the hull of the region in question @@ -210,7 +204,7 @@ namespace OpenSim.Region.Physics.OdePlugin foreach (Triangle t in triangles) { if ( - innerBorders.Contains(vertices.IndexOf(t.v1)) + innerBorders.Contains(vertices.IndexOf(t.v1)) && innerBorders.Contains(vertices.IndexOf(t.v2)) && innerBorders.Contains(vertices.IndexOf(t.v3)) ) @@ -223,18 +217,18 @@ namespace OpenSim.Region.Physics.OdePlugin } - static Mesh CreateBoxMeshX(PrimitiveBaseShape primShape, PhysicsVector size) - // Builds the x (+ and -) surfaces of a box shaped prim + private static Mesh CreateBoxMeshX(PrimitiveBaseShape primShape, PhysicsVector size) + // Builds the x (+ and -) surfaces of a box shaped prim { UInt16 hollowFactor = primShape.ProfileHollow; Mesh meshMX = new Mesh(); // Surface 0, -X - meshMX.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f)); - meshMX.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f)); - meshMX.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f)); - meshMX.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f)); + meshMX.Add(new Vertex("-X-Y-Z", -size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f)); + meshMX.Add(new Vertex("-X+Y-Z", -size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f)); + meshMX.Add(new Vertex("-X-Y+Z", -size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f)); + meshMX.Add(new Vertex("-X+Y+Z", -size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f)); meshMX.Add(new Triangle(meshMX.vertices[0], meshMX.vertices[2], meshMX.vertices[1])); meshMX.Add(new Triangle(meshMX.vertices[1], meshMX.vertices[2], meshMX.vertices[3])); @@ -242,10 +236,10 @@ namespace OpenSim.Region.Physics.OdePlugin Mesh meshPX = new Mesh(); // Surface 1, +X - meshPX.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f)); - meshPX.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f)); - meshPX.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f)); - meshPX.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f)); + meshPX.Add(new Vertex("+X-Y-Z", +size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f)); + meshPX.Add(new Vertex("+X+Y-Z", +size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f)); + meshPX.Add(new Vertex("+X-Y+Z", +size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f)); + meshPX.Add(new Vertex("+X+Y+Z", +size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f)); meshPX.Add(new Triangle(meshPX.vertices[0], meshPX.vertices[1], meshPX.vertices[2])); @@ -254,17 +248,17 @@ namespace OpenSim.Region.Physics.OdePlugin if (hollowFactor > 0) { - float hollowFactorF = (float)hollowFactor / (float)50000; + float hollowFactorF = (float) hollowFactor/(float) 50000; Vertex IPP; Vertex IPM; Vertex IMP; Vertex IMM; - IPP = new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IPM = new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); - IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); + IPP = new Vertex("Inner-X+Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IPM = new Vertex("Inner-X+Y-Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f); + IMP = new Vertex("Inner-X-Y+Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IMM = new Vertex("Inner-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f); meshMX.Add(IPP); meshMX.Add(IPM); @@ -280,11 +274,10 @@ namespace OpenSim.Region.Physics.OdePlugin } - - IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IPM = new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); - IMP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IMM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); + IPP = new Vertex("Inner+X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IPM = new Vertex("Inner+X+Y-Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f); + IMP = new Vertex("Inner+X-Y+Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IMM = new Vertex("Inner+X-Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f); meshPX.Add(IPP); meshPX.Add(IPM); @@ -308,18 +301,17 @@ namespace OpenSim.Region.Physics.OdePlugin } - - static Mesh CreateBoxMeshY(PrimitiveBaseShape primShape, PhysicsVector size) - // Builds the y (+ and -) surfaces of a box shaped prim + private static Mesh CreateBoxMeshY(PrimitiveBaseShape primShape, PhysicsVector size) + // Builds the y (+ and -) surfaces of a box shaped prim { UInt16 hollowFactor = primShape.ProfileHollow; // (M)inus Y Mesh MeshMY = new Mesh(); - MeshMY.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f)); - MeshMY.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f)); - MeshMY.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f)); - MeshMY.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, +size.Z / 2.0f)); + MeshMY.Add(new Vertex("-X-Y-Z", -size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f)); + MeshMY.Add(new Vertex("+X-Y-Z", +size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f)); + MeshMY.Add(new Vertex("-X-Y+Z", -size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f)); + MeshMY.Add(new Vertex("+X-Y+Z", +size.X/2.0f, -size.Y/2.0f, +size.Z/2.0f)); MeshMY.Add(new Triangle(MeshMY.vertices[0], MeshMY.vertices[1], MeshMY.vertices[2])); MeshMY.Add(new Triangle(MeshMY.vertices[2], MeshMY.vertices[1], MeshMY.vertices[3])); @@ -327,27 +319,27 @@ namespace OpenSim.Region.Physics.OdePlugin // (P)lus Y Mesh MeshPY = new Mesh(); - MeshPY.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f)); - MeshPY.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f)); - MeshPY.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f)); - MeshPY.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, +size.Z / 2.0f)); + MeshPY.Add(new Vertex("-X+Y-Z", -size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f)); + MeshPY.Add(new Vertex("+X+Y-Z", +size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f)); + MeshPY.Add(new Vertex("-X+Y+Z", -size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f)); + MeshPY.Add(new Vertex("+X+Y+Z", +size.X/2.0f, +size.Y/2.0f, +size.Z/2.0f)); MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[0], MeshPY.vertices[2])); MeshPY.Add(new Triangle(MeshPY.vertices[1], MeshPY.vertices[2], MeshPY.vertices[3])); if (hollowFactor > 0) { - float hollowFactorF = (float)hollowFactor / (float)50000; + float hollowFactorF = (float) hollowFactor/(float) 50000; Vertex IPP; Vertex IPM; Vertex IMP; Vertex IMM; - IPP = new Vertex("Inner+X-Y+Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IPM = new Vertex("Inner+X-Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); - IMP = new Vertex("Inner-X-Y+Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IMM = new Vertex("Inner-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); + IPP = new Vertex("Inner+X-Y+Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IPM = new Vertex("Inner+X-Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f); + IMP = new Vertex("Inner-X-Y+Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IMM = new Vertex("Inner-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, -size.Z/2.0f); MeshMY.Add(IPP); MeshMY.Add(IPM); @@ -363,11 +355,10 @@ namespace OpenSim.Region.Physics.OdePlugin } - - IPP = new Vertex("Inner+X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IPM=new Vertex("Inner+X+Y-Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); - IMP=new Vertex("Inner-X+Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, +size.Z / 2.0f); - IMM=new Vertex("Inner-X+Y-Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, -size.Z / 2.0f); + IPP = new Vertex("Inner+X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IPM = new Vertex("Inner+X+Y-Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f); + IMP = new Vertex("Inner-X+Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, +size.Z/2.0f); + IMM = new Vertex("Inner-X+Y-Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, -size.Z/2.0f); MeshPY.Add(IPP); MeshPY.Add(IPM); @@ -381,9 +372,6 @@ namespace OpenSim.Region.Physics.OdePlugin { PhysicsVector n = t.getNormal(); } - - - } @@ -393,9 +381,9 @@ namespace OpenSim.Region.Physics.OdePlugin return result; } - - static Mesh CreateBoxMeshZ(PrimitiveBaseShape primShape, PhysicsVector size) - // Builds the z (+ and -) surfaces of a box shaped prim + + private static Mesh CreateBoxMeshZ(PrimitiveBaseShape primShape, PhysicsVector size) + // Builds the z (+ and -) surfaces of a box shaped prim { UInt16 hollowFactor = primShape.ProfileHollow; @@ -403,10 +391,10 @@ namespace OpenSim.Region.Physics.OdePlugin // (M)inus Z Mesh MZ = new Mesh(); - MZ.Add(new Vertex("-X-Y-Z", -size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f)); - MZ.Add(new Vertex("+X-Y-Z", +size.X / 2.0f, -size.Y / 2.0f, -size.Z / 2.0f)); - MZ.Add(new Vertex("-X+Y-Z", -size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f)); - MZ.Add(new Vertex("+X+Y-Z", +size.X / 2.0f, +size.Y / 2.0f, -size.Z / 2.0f)); + MZ.Add(new Vertex("-X-Y-Z", -size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f)); + MZ.Add(new Vertex("+X-Y-Z", +size.X/2.0f, -size.Y/2.0f, -size.Z/2.0f)); + MZ.Add(new Vertex("-X+Y-Z", -size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f)); + MZ.Add(new Vertex("+X+Y-Z", +size.X/2.0f, +size.Y/2.0f, -size.Z/2.0f)); MZ.Add(new Triangle(MZ.vertices[1], MZ.vertices[0], MZ.vertices[2])); @@ -415,10 +403,10 @@ namespace OpenSim.Region.Physics.OdePlugin // (P)lus Z Mesh PZ = new Mesh(); - PZ.Add(new Vertex("-X-Y+Z", -size.X / 2.0f, -size.Y / 2.0f, 0.0f)); - PZ.Add(new Vertex("+X-Y+Z", +size.X / 2.0f, -size.Y / 2.0f, 0.0f)); - PZ.Add(new Vertex("-X+Y+Z", -size.X / 2.0f, +size.Y / 2.0f, 0.0f)); - PZ.Add(new Vertex("+X+Y+Z", +size.X / 2.0f, +size.Y / 2.0f, 0.0f)); + PZ.Add(new Vertex("-X-Y+Z", -size.X/2.0f, -size.Y/2.0f, 0.0f)); + PZ.Add(new Vertex("+X-Y+Z", +size.X/2.0f, -size.Y/2.0f, 0.0f)); + PZ.Add(new Vertex("-X+Y+Z", -size.X/2.0f, +size.Y/2.0f, 0.0f)); + PZ.Add(new Vertex("+X+Y+Z", +size.X/2.0f, +size.Y/2.0f, 0.0f)); // Surface 5, +Z PZ.Add(new Triangle(PZ.vertices[0], PZ.vertices[1], PZ.vertices[2])); @@ -426,12 +414,12 @@ namespace OpenSim.Region.Physics.OdePlugin if (hollowFactor > 0) { - float hollowFactorF = (float)hollowFactor / (float)50000; + float hollowFactorF = (float) hollowFactor/(float) 50000; - MZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f)); - MZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f)); - MZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f)); - MZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f)); + MZ.Add(new Vertex("-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f)); + MZ.Add(new Vertex("-X+Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f)); + MZ.Add(new Vertex("-X-Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f)); + MZ.Add(new Vertex("-X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f)); List innerBorders = new List(); innerBorders.Add(4); @@ -441,10 +429,10 @@ namespace OpenSim.Region.Physics.OdePlugin InsertVertices(MZ.vertices, 4, MZ.triangles, innerBorders); - PZ.Add(new Vertex("-X-Y-Z", -size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f)); - PZ.Add(new Vertex("-X+Y-Z", +size.X * hollowFactorF / 2.0f, -size.Y * hollowFactorF / 2.0f, 0.0f)); - PZ.Add(new Vertex("-X-Y+Z", -size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f)); - PZ.Add(new Vertex("-X+Y+Z", +size.X * hollowFactorF / 2.0f, +size.Y * hollowFactorF / 2.0f, 0.0f)); + PZ.Add(new Vertex("-X-Y-Z", -size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f)); + PZ.Add(new Vertex("-X+Y-Z", +size.X*hollowFactorF/2.0f, -size.Y*hollowFactorF/2.0f, 0.0f)); + PZ.Add(new Vertex("-X-Y+Z", -size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f)); + PZ.Add(new Vertex("-X+Y+Z", +size.X*hollowFactorF/2.0f, +size.Y*hollowFactorF/2.0f, 0.0f)); innerBorders = new List(); innerBorders.Add(4); @@ -453,16 +441,15 @@ namespace OpenSim.Region.Physics.OdePlugin innerBorders.Add(7); InsertVertices(PZ.vertices, 4, PZ.triangles, innerBorders); - } foreach (Vertex v in PZ.vertices) { - v.point.Z = size.Z / 2.0f; + v.point.Z = size.Z/2.0f; } foreach (Vertex v in MZ.vertices) { - v.point.Z = -size.Z / 2.0f; + v.point.Z = -size.Z/2.0f; } foreach (Triangle t in MZ.triangles) @@ -486,15 +473,14 @@ namespace OpenSim.Region.Physics.OdePlugin return result; } - static Mesh CreateBoxMesh(PrimitiveBaseShape primShape, PhysicsVector size) + private static Mesh CreateBoxMesh(PrimitiveBaseShape primShape, PhysicsVector size) { Mesh result = new Mesh(); - - Mesh MeshX = Meshmerizer.CreateBoxMeshX(primShape, size); - Mesh MeshY = Meshmerizer.CreateBoxMeshY(primShape, size); - Mesh MeshZ = Meshmerizer.CreateBoxMeshZ(primShape, size); + Mesh MeshX = CreateBoxMeshX(primShape, size); + Mesh MeshY = CreateBoxMeshY(primShape, size); + Mesh MeshZ = CreateBoxMeshZ(primShape, size); result.Append(MeshX); result.Append(MeshY); @@ -504,64 +490,63 @@ namespace OpenSim.Region.Physics.OdePlugin } - public static void CalcNormals(Mesh mesh) + public static void CalcNormals(Mesh mesh) { int iTriangles = mesh.triangles.Count; mesh.normals = new float[iTriangles*3]; - int i=0; + int i = 0; foreach (Triangle t in mesh.triangles) { - float ux, uy, uz; float vx, vy, vz; float wx, wy, wz; - ux = t.v1.point.X; - uy = t.v1.point.Y; - uz = t.v1.point.Z; + ux = t.v1.point.X; + uy = t.v1.point.Y; + uz = t.v1.point.Z; - vx = t.v2.point.X; - vy = t.v2.point.Y; - vz = t.v2.point.Z; + vx = t.v2.point.X; + vy = t.v2.point.Y; + vz = t.v2.point.Z; - wx = t.v3.point.X; - wy = t.v3.point.Y; - wz = t.v3.point.Z; + wx = t.v3.point.X; + wy = t.v3.point.Y; + wz = t.v3.point.Z; - // Vectors for edges - float e1x, e1y, e1z; - float e2x, e2y, e2z; + // Vectors for edges + float e1x, e1y, e1z; + float e2x, e2y, e2z; - e1x = ux - vx; - e1y = uy - vy; - e1z = uz - vz; + e1x = ux - vx; + e1y = uy - vy; + e1z = uz - vz; - e2x = ux - wx; - e2y = uy - wy; - e2z = uz - wz; + e2x = ux - wx; + e2y = uy - wy; + e2z = uz - wz; - // Cross product for normal - float nx, ny, nz; - nx = e1y * e2z - e1z * e2y; - ny = e1z * e2x - e1x * e2z; - nz = e1x * e2y - e1y * e2x; + // Cross product for normal + float nx, ny, nz; + nx = e1y*e2z - e1z*e2y; + ny = e1z*e2x - e1x*e2z; + nz = e1x*e2y - e1y*e2x; - // Length - float l = (float)Math.Sqrt(nx * nx + ny * ny + nz * nz); + // Length + float l = (float) Math.Sqrt(nx*nx + ny*ny + nz*nz); - // Normalized "normal" - nx /= l; - ny /= l; - nz /= l; + // Normalized "normal" + nx /= l; + ny /= l; + nz /= l; mesh.normals[i] = nx; mesh.normals[i + 1] = ny; mesh.normals[i + 2] = nz; - i+=3; + i += 3; } } @@ -572,18 +557,15 @@ namespace OpenSim.Region.Physics.OdePlugin switch (primShape.ProfileShape) { case ProfileShape.Square: - mesh=CreateBoxMesh(primShape, size); + mesh = CreateBoxMesh(primShape, size); CalcNormals(mesh); break; default: - mesh=null; + mesh = null; break; } return mesh; - } } -} - - +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index a20452f..c9af6dd 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -25,19 +25,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + using System; -using System.Threading; using System.Collections.Generic; - -using libsecondlife; - using Axiom.Math; using Ode.NET; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; - namespace OpenSim.Region.Physics.OdePlugin { /// @@ -49,7 +44,6 @@ namespace OpenSim.Region.Physics.OdePlugin public OdePlugin() { - } public bool Init() @@ -73,7 +67,6 @@ namespace OpenSim.Region.Physics.OdePlugin public void Dispose() { - } } @@ -82,17 +75,17 @@ namespace OpenSim.Region.Physics.OdePlugin private static float ODE_STEPSIZE = 0.004f; private static bool RENDER_FLAG = false; private IntPtr contactgroup; - private IntPtr LandGeom=(IntPtr)0; + private IntPtr LandGeom = (IntPtr) 0; private double[] _heightmap; private d.NearCallback nearCallback; public d.TriCallback triCallback; public d.TriArrayCallback triArrayCallback; private List _characters = new List(); private List _prims = new List(); - public Dictionary geom_name_map=new Dictionary(); + public Dictionary geom_name_map = new Dictionary(); private d.ContactGeom[] contacts = new d.ContactGeom[30]; private d.Contact contact; - private float step_time=0.0f; + private float step_time = 0.0f; public IntPtr world; public IntPtr space; public static Object OdeLock = new Object(); @@ -140,7 +133,7 @@ namespace OpenSim.Region.Physics.OdePlugin return; d.GeomClassID id = d.GeomGetClass(g1); - if (id==d.GeomClassID.TriMeshClass) + if (id == d.GeomClassID.TriMeshClass) { String name1 = null; String name2 = null; @@ -163,7 +156,6 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact); d.JointAttach(joint, b1, b2); } - } private void collision_optimized() @@ -171,7 +163,8 @@ namespace OpenSim.Region.Physics.OdePlugin foreach (OdeCharacter chr in _characters) { d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback); - foreach (OdeCharacter ch2 in _characters) /// should be a separate space -- lots of avatars will be N**2 slow + foreach (OdeCharacter ch2 in _characters) + /// should be a separate space -- lots of avatars will be N**2 slow { d.SpaceCollide2(chr.Shell, ch2.Shell, IntPtr.Zero, nearCallback); } @@ -193,8 +186,8 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (OdeLock) { - ((OdeCharacter)actor).Destroy(); - _characters.Remove((OdeCharacter)actor); + ((OdeCharacter) actor).Destroy(); + _characters.Remove((OdeCharacter) actor); } } @@ -204,13 +197,14 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (OdeLock) { - d.GeomDestroy(((OdePrim)prim).prim_geom); - _prims.Remove((OdePrim)prim); + d.GeomDestroy(((OdePrim) prim).prim_geom); + _prims.Remove((OdePrim) prim); } } } - PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) + private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, + Mesh mesh, PrimitiveBaseShape pbs) { PhysicsVector pos = new PhysicsVector(); pos.X = position.X; @@ -235,7 +229,7 @@ namespace OpenSim.Region.Physics.OdePlugin } - public int TriArrayCallback(System.IntPtr trimesh, System.IntPtr refObject, int[] triangleIndex, int triCount) + public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount) { /* String name1 = null; String name2 = null; @@ -254,15 +248,14 @@ namespace OpenSim.Region.Physics.OdePlugin return 1; } - public int TriCallback(System.IntPtr trimesh, System.IntPtr refObject, int triangleIndex) + public int TriCallback(IntPtr trimesh, IntPtr refObject, int triangleIndex) { - String name1 = null; String name2 = null; if (!geom_name_map.TryGetValue(trimesh, out name1)) { - name1 = "null"; + name1 = "null"; } if (!geom_name_map.TryGetValue(refObject, out name2)) { @@ -282,11 +275,12 @@ namespace OpenSim.Region.Physics.OdePlugin } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + PhysicsVector size, Quaternion rotation) { PhysicsActor result; - switch(pbs.ProfileShape) + switch (pbs.ProfileShape) { case ProfileShape.Square: /// support simple box & hollow box now; later, more shapes @@ -310,7 +304,6 @@ namespace OpenSim.Region.Physics.OdePlugin } - public override void Simulate(float timeStep) { step_time += timeStep; @@ -327,11 +320,12 @@ namespace OpenSim.Region.Physics.OdePlugin Vector3 rx, ry, rz; p.Orientation.ToAxes(out rx, out ry, out rz); Console.WriteLine("RENDER: block; " + p.Size.X + ", " + p.Size.Y + ", " + p.Size.Z + "; " + - " 0, 0, 1; " + //shape, size, color - (p.Position.X - 128.0f) + ", " + (p.Position.Y - 128.0f) + ", " + (p.Position.Z - 33.0f) + "; " + // position - rx.x + "," + ry.x + "," + rz.x + ", " + // rotation - rx.y + "," + ry.y + "," + rz.y + ", " + - rx.z + "," + ry.z + "," + rz.z); + " 0, 0, 1; " + //shape, size, color + (p.Position.X - 128.0f) + ", " + (p.Position.Y - 128.0f) + ", " + + (p.Position.Z - 33.0f) + "; " + // position + rx.x + "," + ry.x + "," + rz.x + ", " + // rotation + rx.y + "," + ry.y + "," + rz.y + ", " + + rx.z + "," + ry.z + "," + rz.z); } } int i = 0; @@ -357,22 +351,27 @@ namespace OpenSim.Region.Physics.OdePlugin float Zoff = -33.0f; d.Matrix3 temp = d.BodyGetRotation(actor.Body); Console.WriteLine("RENDER: cylinder; " + // shape - OdeCharacter.CAPSULE_RADIUS + ", " + OdeCharacter.CAPSULE_LENGTH + //size - "; 0, 1, 0; " + // color - (actor.Position.X - 128.0f) + ", " + (actor.Position.Y - 128.0f) + ", " + (actor.Position.Z + Zoff) + "; " + // position - temp.M00 + "," + temp.M10 + "," + temp.M20 + ", " + // rotation - temp.M01 + "," + temp.M11 + "," + temp.M21 + ", " + - temp.M02 + "," + temp.M12 + "," + temp.M22); - d.Vector3 caphead; d.BodyGetRelPointPos(actor.Body, 0, 0, OdeCharacter.CAPSULE_LENGTH * .5f, out caphead); - d.Vector3 capfoot; d.BodyGetRelPointPos(actor.Body, 0, 0, -OdeCharacter.CAPSULE_LENGTH * .5f, out capfoot); + OdeCharacter.CAPSULE_RADIUS + ", " + OdeCharacter.CAPSULE_LENGTH + //size + "; 0, 1, 0; " + // color + (actor.Position.X - 128.0f) + ", " + (actor.Position.Y - 128.0f) + ", " + + (actor.Position.Z + Zoff) + "; " + // position + temp.M00 + "," + temp.M10 + "," + temp.M20 + ", " + // rotation + temp.M01 + "," + temp.M11 + "," + temp.M21 + ", " + + temp.M02 + "," + temp.M12 + "," + temp.M22); + d.Vector3 caphead; + d.BodyGetRelPointPos(actor.Body, 0, 0, OdeCharacter.CAPSULE_LENGTH*.5f, out caphead); + d.Vector3 capfoot; + d.BodyGetRelPointPos(actor.Body, 0, 0, -OdeCharacter.CAPSULE_LENGTH*.5f, out capfoot); Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size - "; 1, 0, 1; " + //color - (caphead.X - 128.0f) + ", " + (caphead.Y - 128.0f) + ", " + (caphead.Z + Zoff) + "; " + // position - "1,0,0, 0,1,0, 0,0,1"); // rotation + "; 1, 0, 1; " + //color + (caphead.X - 128.0f) + ", " + (caphead.Y - 128.0f) + ", " + (caphead.Z + Zoff) + + "; " + // position + "1,0,0, 0,1,0, 0,0,1"); // rotation Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size - "; 1, 0, 0; " + //color - (capfoot.X - 128.0f) + ", " + (capfoot.Y - 128.0f) + ", " + (capfoot.Z + Zoff) + "; " + // position - "1,0,0, 0,1,0, 0,0,1"); // rotation + "; 1, 0, 0; " + //color + (capfoot.X - 128.0f) + ", " + (capfoot.Y - 128.0f) + ", " + (capfoot.Z + Zoff) + + "; " + // position + "1,0,0, 0,1,0, 0,0,1"); // rotation } } } @@ -380,14 +379,11 @@ namespace OpenSim.Region.Physics.OdePlugin public override void GetResults() { - } public override bool IsThreaded { - get - { - return (false); // for now we won't be multithreaded + get { return (false); // for now we won't be multithreaded } } @@ -400,21 +396,21 @@ namespace OpenSim.Region.Physics.OdePlugin { for (int y = 0; y < 258; y++) { - int xx = x-1; + int xx = x - 1; if (xx < 0) xx = 0; if (xx > 255) xx = 255; - int yy = y-1; + int yy = y - 1; if (yy < 0) yy = 0; if (yy > 255) yy = 255; - double val = (double)heightMap[yy * 256 + xx]; - _heightmap[x * 258 + y] = val; + double val = (double) heightMap[yy*256 + xx]; + _heightmap[x*258 + y] = val; } } lock (OdeLock) { - if (!(LandGeom == (IntPtr)0)) + if (!(LandGeom == (IntPtr) 0)) { d.SpaceRemove(space, LandGeom); } @@ -422,7 +418,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 258, 258, 258, 258, 1.0f, 0.0f, 2.0f, 0); d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); LandGeom = d.CreateHeightfield(space, HeightmapData, 1); - this.geom_name_map[LandGeom]="Terrain"; + geom_name_map[LandGeom] = "Terrain"; d.Matrix3 R = new d.Matrix3(); @@ -430,7 +426,7 @@ namespace OpenSim.Region.Physics.OdePlugin Quaternion q2 = Quaternion.FromAngleAxis(1.5707f, new Vector3(0, 1, 0)); //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); - q1 = q1 * q2; + q1 = q1*q2; //q1 = q1 * q3; Vector3 v3 = new Vector3(); float angle = 0; @@ -444,7 +440,6 @@ namespace OpenSim.Region.Physics.OdePlugin public override void DeleteTerrain() { - } } @@ -452,12 +447,12 @@ namespace OpenSim.Region.Physics.OdePlugin { private PhysicsVector _position; private d.Vector3 _zeroPosition; - private bool _zeroFlag=false; + private bool _zeroFlag = false; private PhysicsVector _velocity; private PhysicsVector _target_velocity; private PhysicsVector _acceleration; - private static float PID_D=4000.0f; - private static float PID_P=7000.0f; + private static float PID_D = 4000.0f; + private static float PID_P = 7000.0f; private static float POSTURE_SERVO = 10000.0f; public static float CAPSULE_RADIUS = 0.5f; public static float CAPSULE_LENGTH = 0.9f; @@ -484,28 +479,18 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); d.GeomSetBody(Shell, Body); } - parent_scene.geom_name_map[Shell]=avName; - + parent_scene.geom_name_map[Shell] = avName; } public override bool Flying { - get - { - return flying; - } - set - { - flying = value; - } + get { return flying; } + set { flying = value; } } public override PhysicsVector Position { - get - { - return _position; - } + get { return _position; } set { lock (OdeScene.OdeLock) @@ -518,60 +503,34 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsVector Size { - get - { - return new PhysicsVector(0,0,0); - } - set - { - } + get { return new PhysicsVector(0, 0, 0); } + set { } } public override PhysicsVector Velocity { - get - { - return _velocity; - } - set - { - _target_velocity = value; - } + get { return _velocity; } + set { _target_velocity = value; } } public override bool Kinematic { - get - { - return false; - } - set - { - - } + get { return false; } + set { } } public override Quaternion Orientation { - get - { - return Quaternion.Identity; - } - set - { - - } + get { return Quaternion.Identity; } + set { } } public override PhysicsVector Acceleration { - get - { - return _acceleration; - } - + get { return _acceleration; } } + public void SetAcceleration(PhysicsVector accel) { _acceleration = accel; @@ -579,12 +538,10 @@ namespace OpenSim.Region.Physics.OdePlugin public override void AddForce(PhysicsVector force) { - } public override void SetMomentum(PhysicsVector momentum) { - } public void Move(float timeStep) @@ -603,28 +560,28 @@ namespace OpenSim.Region.Physics.OdePlugin _zeroPosition = d.BodyGetPosition(Body); } 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 + (_zeroPosition.Z - pos.Z) * PID_P; + vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P; } } else { _zeroFlag = false; - vec.X = (_target_velocity.X - vel.X) * PID_D; - vec.Y = (_target_velocity.Y - vel.Y) * PID_D; + vec.X = (_target_velocity.X - vel.X)*PID_D; + vec.Y = (_target_velocity.Y - vel.Y)*PID_D; if (flying) { - vec.Z = (_target_velocity.Z - vel.Z) * PID_D; + vec.Z = (_target_velocity.Z - vel.Z)*PID_D; } } if (flying) { vec.Z += 10.0f; } - d.BodyAddForce(this.Body, vec.X, vec.Y, vec.Z); + d.BodyAddForce(Body, vec.X, vec.Y, vec.Z); // ok -- let's stand up straight! d.Vector3 feet; @@ -634,7 +591,7 @@ namespace OpenSim.Region.Physics.OdePlugin float posture = head.Z - feet.Z; // restoring force proportional to lack of posture: - float servo = (2.5f-posture) * POSTURE_SERVO; + float servo = (2.5f - posture)*POSTURE_SERVO; d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); } @@ -650,9 +607,9 @@ namespace OpenSim.Region.Physics.OdePlugin if (vec.X > 255.95f) vec.X = 255.95f; if (vec.Y > 255.95f) vec.Y = 255.95f; - this._position.X = vec.X; - this._position.Y = vec.Y; - this._position.Z = vec.Z; + _position.X = vec.X; + _position.Y = vec.Y; + _position.Z = vec.Z; if (_zeroFlag) { @@ -673,9 +630,9 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (OdeScene.OdeLock) { - d.GeomDestroy(this.Shell); - this._parent_scene.geom_name_map.Remove(this.Shell); - d.BodyDestroy(this.Body); + d.GeomDestroy(Shell); + _parent_scene.geom_name_map.Remove(Shell); + d.BodyDestroy(Body); } } } @@ -693,7 +650,7 @@ namespace OpenSim.Region.Physics.OdePlugin public IntPtr prim_geom; public IntPtr _triMeshData; - public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, + public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs) { _velocity = new PhysicsVector(); @@ -707,7 +664,7 @@ namespace OpenSim.Region.Physics.OdePlugin lock (OdeScene.OdeLock) { - if (mesh!=null) + if (mesh != null) { setMesh(parent_scene, mesh); } @@ -723,20 +680,22 @@ namespace OpenSim.Region.Physics.OdePlugin myrot.Y = rotation.y; myrot.Z = rotation.z; d.GeomSetQuaternion(prim_geom, ref myrot); - parent_scene.geom_name_map[prim_geom] = primName; // don't do .add() here; old geoms get recycled with the same hash + parent_scene.geom_name_map[prim_geom] = primName; + // don't do .add() here; old geoms get recycled with the same hash } } - public void setMesh(OdeScene parent_scene, Mesh mesh) + public void setMesh(OdeScene parent_scene, Mesh mesh) { float[] vertexList = mesh.getVertexListAsFloat(); // Note, that vertextList is pinned in memory int[] indexList = mesh.getIndexListAsInt(); // 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(parent_scene.space, _triMeshData, parent_scene.triCallback, null, null); @@ -744,21 +703,14 @@ namespace OpenSim.Region.Physics.OdePlugin public override bool Flying { - get - { - return false; //no flying prims for you - } - set - { + get { return false; //no flying prims for you } + set { } } public override PhysicsVector Position { - get - { - return _position; - } + get { return _position; } set { _position = value; @@ -771,10 +723,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsVector Size { - get - { - return _size; - } + get { return _size; } set { _size = value; @@ -798,33 +747,19 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsVector Velocity { - get - { - return _velocity; - } - set - { - _velocity = value; - } + get { return _velocity; } + set { _velocity = value; } } public override bool Kinematic { - get - { - return false; - } - set - { - } + get { return false; } + set { } } public override Quaternion Orientation { - get - { - return _orientation; - } + get { return _orientation; } set { _orientation = value; @@ -842,15 +777,12 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsVector Acceleration { - get - { - return _acceleration; - } + get { return _acceleration; } } public void SetAcceleration(PhysicsVector accel) { - this._acceleration = accel; + _acceleration = accel; } public override void AddForce(PhysicsVector force) @@ -861,4 +793,4 @@ namespace OpenSim.Region.Physics.OdePlugin { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs index 3f840cc..d110a17 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs @@ -27,24 +27,26 @@ */ using System.Reflection; using System.Runtime.InteropServices; + // Information about this assembly is defined by the following // attributes. // // change them to the information which is associated with the assembly // you compile. -[assembly: AssemblyTitle("RealPhysXplugin")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RealPhysXplugin")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly : AssemblyTitle("RealPhysXplugin")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("RealPhysXplugin")] +[assembly : AssemblyCopyright("")] +[assembly : AssemblyTrademark("")] +[assembly : AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. -[assembly: ComVisible(false)] + +[assembly : ComVisible(false)] // The assembly version has following format : // @@ -53,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 a7cef88..4896359 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -34,102 +34,99 @@ using Quaternion=Axiom.Math.Quaternion; namespace OpenSim.Region.Physics.PhysXPlugin { - /// - /// Will be the PhysX plugin but for now will be a very basic physics engine - /// - public class PhysXPlugin : IPhysicsPlugin - { - private PhysXScene _mScene; - - public PhysXPlugin() - { - - } - - public bool Init() - { - return true; - } - - public PhysicsScene GetScene() - { - if(_mScene == null) - { - _mScene = new PhysXScene(); - } - return(_mScene); - } - - public string GetName() - { - return("RealPhysX"); - } - - public void Dispose() - { - - } - } - - public class PhysXScene :PhysicsScene - { - private List _characters = new List(); - private List _prims = new List(); - private float[] _heightMap = null; - private NxPhysicsSDK mySdk; - private NxScene scene; - - public PhysXScene() - { - mySdk = NxPhysicsSDK.CreateSDK(); - Console.WriteLine("Sdk created - now creating scene"); - scene = mySdk.CreateScene(); - - } - - public override PhysicsActor AddAvatar(string avName, PhysicsVector position) - { - Vec3 pos = new Vec3(); - pos.X = position.X; - pos.Y = position.Y; - pos.Z = position.Z; - PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos)); + /// + /// Will be the PhysX plugin but for now will be a very basic physics engine + /// + public class PhysXPlugin : IPhysicsPlugin + { + private PhysXScene _mScene; + + public PhysXPlugin() + { + } + + public bool Init() + { + return true; + } + + public PhysicsScene GetScene() + { + if (_mScene == null) + { + _mScene = new PhysXScene(); + } + return (_mScene); + } + + public string GetName() + { + return ("RealPhysX"); + } + + public void Dispose() + { + } + } + + public class PhysXScene : PhysicsScene + { + private List _characters = new List(); + private List _prims = new List(); + private float[] _heightMap = null; + private NxPhysicsSDK mySdk; + private NxScene scene; + + public PhysXScene() + { + mySdk = NxPhysicsSDK.CreateSDK(); + Console.WriteLine("Sdk created - now creating scene"); + scene = mySdk.CreateScene(); + } + + public override PhysicsActor AddAvatar(string avName, PhysicsVector position) + { + Vec3 pos = new Vec3(); + pos.X = position.X; + pos.Y = position.Y; + pos.Z = position.Z; + PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos)); act.Position = position; - _characters.Add(act); - return act; - } + _characters.Add(act); + return act; + } public override void RemovePrim(PhysicsActor prim) { - } public override void RemoveAvatar(PhysicsActor actor) { + } + private PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) + { + Vec3 pos = new Vec3(); + pos.X = position.X; + pos.Y = position.Y; + pos.Z = position.Z; + Vec3 siz = new Vec3(); + siz.X = size.X; + siz.Y = size.Y; + siz.Z = size.Z; + PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz)); + _prims.Add(act); + return act; } - - PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) - { - Vec3 pos = new Vec3(); - pos.X = position.X; - pos.Y = position.Y; - pos.Z = position.Z; - Vec3 siz = new Vec3(); - siz.X = size.X; - siz.Y = size.Y; - siz.Z = size.Z; - PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz)); - _prims.Add(act); - return act; - } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) + + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + PhysicsVector size, Quaternion rotation) { return AddPrim(position, size, rotation); } - public override void Simulate(float timeStep) - { + public override void Simulate(float timeStep) + { try { foreach (PhysXCharacter actor in _characters) @@ -149,309 +146,237 @@ namespace OpenSim.Region.Physics.PhysXPlugin { Console.WriteLine(e.Message); } - - } - - public override void GetResults() - { - - } - - public override bool IsThreaded - { - get - { - return(false); // for now we won't be multithreaded - } - } - - public override void SetTerrain(float[] heightMap) - { - if (this._heightMap != null) + } + + public override void GetResults() + { + } + + public override bool IsThreaded + { + get { return (false); // for now we won't be multithreaded + } + } + + public override void SetTerrain(float[] heightMap) + { + if (_heightMap != null) { Console.WriteLine("PhysX - deleting old terrain"); - this.scene.DeleteTerrain(); + scene.DeleteTerrain(); } - this._heightMap = heightMap; - this.scene.AddTerrain(heightMap); - } + _heightMap = heightMap; + scene.AddTerrain(heightMap); + } public override void DeleteTerrain() { - this.scene.DeleteTerrain(); - } + scene.DeleteTerrain(); + } } - - public class PhysXCharacter : PhysicsActor - { - private PhysicsVector _position; - private PhysicsVector _velocity; - private PhysicsVector _acceleration; - private NxCharacter _character; - private bool flying; - private float gravityAccel; - - public PhysXCharacter(NxCharacter character) - { - _velocity = new PhysicsVector(); - _position = new PhysicsVector(); - _acceleration = new PhysicsVector(); - _character = character; - } - - public override bool Flying - { - get - { - return flying; - } - set - { - flying = value; - } - } - - public override PhysicsVector Position - { - get - { - return _position; - } - set - { - _position = value; + + public class PhysXCharacter : PhysicsActor + { + private PhysicsVector _position; + private PhysicsVector _velocity; + private PhysicsVector _acceleration; + private NxCharacter _character; + private bool flying; + private float gravityAccel; + + public PhysXCharacter(NxCharacter character) + { + _velocity = new PhysicsVector(); + _position = new PhysicsVector(); + _acceleration = new PhysicsVector(); + _character = character; + } + + public override bool Flying + { + get { return flying; } + set { flying = value; } + } + + public override PhysicsVector Position + { + get { return _position; } + set + { + _position = value; Vec3 ps = new Vec3(); ps.X = value.X; ps.Y = value.Y; ps.Z = value.Z; - this._character.Position = ps; - } - } + _character.Position = ps; + } + } public override PhysicsVector Size { - get + get { return new PhysicsVector(0, 0, 0); } + set { } + } + + public override PhysicsVector Velocity + { + get { return _velocity; } + set { _velocity = value; } + } + + public override bool Kinematic + { + get { return false; } + set { } + } + + public override Quaternion Orientation + { + get { return Quaternion.Identity; } + set { } + } + + public override PhysicsVector Acceleration + { + get { return _acceleration; } + } + + public void SetAcceleration(PhysicsVector accel) + { + _acceleration = accel; + } + + public override void AddForce(PhysicsVector force) + { + } + + public override void SetMomentum(PhysicsVector momentum) + { + } + + public void Move(float timeStep) + { + Vec3 vec = new Vec3(); + vec.X = _velocity.X*timeStep; + vec.Y = _velocity.Y*timeStep; + if (flying) { - return new PhysicsVector(0,0,0); + vec.Z = (_velocity.Z)*timeStep; } - set + else + { + gravityAccel += -9.8f; + vec.Z = (gravityAccel + _velocity.Z)*timeStep; + } + int res = _character.Move(vec); + if (res == 1) { + gravityAccel = 0; } } - public override PhysicsVector Velocity - { - get - { - return _velocity; - } - set - { - _velocity = value; - } - } - - public override bool Kinematic - { - get - { - return false; - } - set - { - - } - } - - public override Quaternion Orientation - { - get - { - return Quaternion.Identity; - } - set - { - - } - } - - public override PhysicsVector Acceleration - { - get - { - return _acceleration; - } - - } - public void SetAcceleration (PhysicsVector accel) - { - this._acceleration = accel; - } - - public override void AddForce(PhysicsVector force) - { - - } - - public override void SetMomentum(PhysicsVector momentum) - { - - } - - public void Move(float timeStep) - { - Vec3 vec = new Vec3(); - vec.X = this._velocity.X * timeStep; - vec.Y = this._velocity.Y * timeStep; - if(flying) - { - vec.Z = ( this._velocity.Z) * timeStep; - } - else - { - gravityAccel+= -9.8f; - vec.Z = (gravityAccel + this._velocity.Z) * timeStep; - } - int res = this._character.Move(vec); - if(res == 1) - { - gravityAccel = 0; - } - } - - 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 - { - private PhysicsVector _position; - private PhysicsVector _velocity; - private PhysicsVector _acceleration; - private NxActor _prim; - - public PhysXPrim(NxActor prim) - { - _velocity = new PhysicsVector(); - _position = new PhysicsVector(); - _acceleration = new PhysicsVector(); - _prim = prim; - } - public override bool Flying - { - get - { - return false; //no flying prims for you - } - set - { - - } - } - public override PhysicsVector Position - { - get - { - PhysicsVector pos = new PhysicsVector(); - Vec3 vec = this._prim.Position; - pos.X = vec.X; - pos.Y = vec.Y; - pos.Z = vec.Z; - return pos; - - } - set - { - PhysicsVector vec = value; - Vec3 pos = new Vec3(); - pos.X = vec.X; - pos.Y = vec.Y; - pos.Z = vec.Z; - this._prim.Position = pos; - } - } - public override PhysicsVector Size + public void UpdatePosition() + { + Vec3 vec = _character.Position; + _position.X = vec.X; + _position.Y = vec.Y; + _position.Z = vec.Z; + } + } + + public class PhysXPrim : PhysicsActor + { + private PhysicsVector _position; + private PhysicsVector _velocity; + private PhysicsVector _acceleration; + private NxActor _prim; + + public PhysXPrim(NxActor prim) + { + _velocity = new PhysicsVector(); + _position = new PhysicsVector(); + _acceleration = new PhysicsVector(); + _prim = prim; + } + + public override bool Flying + { + get { return false; //no flying prims for you + } + set { } + } + + public override PhysicsVector Position { get { - return new PhysicsVector(0, 0, 0); + PhysicsVector pos = new PhysicsVector(); + Vec3 vec = _prim.Position; + pos.X = vec.X; + pos.Y = vec.Y; + pos.Z = vec.Z; + return pos; } set { + PhysicsVector vec = value; + Vec3 pos = new Vec3(); + pos.X = vec.X; + pos.Y = vec.Y; + pos.Z = vec.Z; + _prim.Position = pos; } } - public override PhysicsVector Velocity - { - get - { - return _velocity; - } - set - { - _velocity = value; - } - } - - public override bool Kinematic - { - get - { - return this._prim.Kinematic; - } - set - { - this._prim.Kinematic = value; - } - } - - public override Quaternion Orientation - { - get - { - Quaternion res = new Quaternion(); - PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); - res.w = quat.W; - res.x = quat.X; - res.y = quat.Y; - res.z = quat.Z; - return res; - } - set - { - - } - } - - public override PhysicsVector Acceleration - { - get - { - return _acceleration; - } - - } - public void SetAcceleration (PhysicsVector accel) - { - this._acceleration = accel; - } - - public override void AddForce(PhysicsVector force) - { - - } - - public override void SetMomentum(PhysicsVector momentum) - { - - } - - - } - -} + public override PhysicsVector Size + { + get { return new PhysicsVector(0, 0, 0); } + set { } + } + + public override PhysicsVector Velocity + { + get { return _velocity; } + set { _velocity = value; } + } + + public override bool Kinematic + { + get { return _prim.Kinematic; } + set { _prim.Kinematic = value; } + } + + public override Quaternion Orientation + { + get + { + Quaternion res = new Quaternion(); + PhysXWrapper.Quaternion quat = _prim.GetOrientation(); + res.w = quat.W; + res.x = quat.X; + res.y = quat.Y; + res.z = quat.Z; + return res; + } + set { } + } + + public override PhysicsVector Acceleration + { + get { return _acceleration; } + } + + public void SetAcceleration(PhysicsVector accel) + { + _acceleration = accel; + } + + public override void AddForce(PhysicsVector force) + { + } + + public override void SetMomentum(PhysicsVector momentum) + { + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index a2148ea..c656e01 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; using System.Reflection; using System.Runtime.Remoting.Lifetime; @@ -53,7 +52,7 @@ namespace OpenSim.Region.ScriptEngine.Common { //Console.WriteLine("Executor: InitializeLifetimeService()"); // return null; - ILease lease = (ILease)base.InitializeLifetimeService(); + ILease lease = (ILease) base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { @@ -75,56 +74,56 @@ namespace OpenSim.Region.ScriptEngine.Common // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! //try //{ - if (m_Running == false) - { - // Script is inactive, do not execute! - return; - } + if (m_Running == false) + { + // Script is inactive, do not execute! + return; + } - string EventName = m_Script.State() + "_event_" + FunctionName; + string EventName = m_Script.State() + "_event_" + FunctionName; - //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); + //type.InvokeMember(EventName, BindingFlags.InvokeMethod, null, m_Script, args); - //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); + //Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + EventName + "\""); - if (Events.ContainsKey(EventName) == false) + if (Events.ContainsKey(EventName) == false) + { + // Not found, create + Type type = m_Script.GetType(); + try { - // Not found, create - Type type = m_Script.GetType(); - try - { - MethodInfo mi = type.GetMethod(EventName); - Events.Add(EventName, mi); - } - catch - { - // Event name not found, cache it as not found - Events.Add(EventName, null); - } + MethodInfo mi = type.GetMethod(EventName); + Events.Add(EventName, mi); } - - // Get event - MethodInfo ev = null; - Events.TryGetValue(EventName, out ev); - - if (ev == null) // No event by that name! + catch { - //Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); - return; + // Event name not found, cache it as not found + Events.Add(EventName, null); } + } + + // Get event + MethodInfo ev = null; + Events.TryGetValue(EventName, out ev); + + if (ev == null) // No event by that name! + { + //Console.WriteLine("ScriptEngine Can not find any event named: \"" + EventName + "\""); + return; + } - // Found - //try - //{ - // Invoke it - ev.Invoke(m_Script, args); + // Found + //try + //{ + // Invoke it + ev.Invoke(m_Script, args); - //} - //catch (Exception e) - //{ - // // TODO: Send to correct place - // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); - //} + //} + //catch (Exception e) + //{ + // // TODO: Send to correct place + // Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); + //} //} @@ -136,8 +135,5 @@ namespace OpenSim.Region.ScriptEngine.Common { m_Running = false; } - - } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/IScript.cs b/OpenSim/Region/ScriptEngine/Common/IScript.cs index df0e824..08c0e9c 100644 --- a/OpenSim/Region/ScriptEngine/Common/IScript.cs +++ b/OpenSim/Region/ScriptEngine/Common/IScript.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ScriptEngine.Common { public interface IScript @@ -37,4 +33,4 @@ namespace OpenSim.Region.ScriptEngine.Common string State(); Executor Exec { get; } } -} +} \ 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 ff5c6bf..9cba882 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -26,15 +26,12 @@ * */ /* Original code: Tedd Hansen */ -using System; using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ScriptEngine.Common { public interface LSL_BuiltIn_Commands_Interface { - string State(); double llSin(double f); @@ -404,7 +401,9 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: llSetTextureAnim(integer mode, integer face, integer sizex, integer sizey, double start, double length, double rate) void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate); //wiki: llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west) - void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west); + void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, + LSL_Types.Vector3 bottom_south_west); + //wiki: llEjectFromLand(key pest) void llEjectFromLand(string pest); void llParseString2List(); @@ -437,7 +436,7 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: double llGetRegionFPS() double llGetRegionFPS(); //wiki: llParticleSystem(List rules - void llParticleSystem(List rules); + void llParticleSystem(List rules); //wiki: llGroundRepel(double height, integer water, double tau) void llGroundRepel(double height, int water, double tau); void llGiveInventoryList(); @@ -548,7 +547,9 @@ namespace OpenSim.Region.ScriptEngine.Common //wiki: list llParseStringKeepNulls( string src, list separators, list spacers ) List llParseStringKeepNulls(string src, List seperators, List spacers); //wiki: llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, integer param) - void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param); + void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, + LSL_Types.Quaternion rot, int param); + //wiki: integer llGetObjectPermMask(integer mask) int llGetObjectPermMask(int mask); //wiki: llSetObjectPermMask(integer mask, integer value) @@ -632,4 +633,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 7d69379..df3d752 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -41,11 +41,12 @@ namespace OpenSim.Region.ScriptEngine.Common public double Z; public Vector3(Vector3 vector) - { - X = (float)vector.X; - Y = (float)vector.Y; - Z = (float)vector.Z; - } + { + X = (float) vector.X; + Y = (float) vector.Y; + Z = (float) vector.Z; + } + public Vector3(double x, double y, double z) { X = x; @@ -53,6 +54,7 @@ namespace OpenSim.Region.ScriptEngine.Common Z = z; } } + [Serializable] public struct Quaternion { @@ -62,12 +64,13 @@ namespace OpenSim.Region.ScriptEngine.Common public double R; public Quaternion(Quaternion Quat) - { - X = (float)Quat.X; - Y = (float)Quat.Y; - Z = (float)Quat.Z; - R = (float)Quat.R; + { + X = (float) Quat.X; + Y = (float) Quat.Y; + Z = (float) Quat.Z; + R = (float) Quat.R; } + public Quaternion(double x, double y, double z, double r) { X = x; @@ -75,7 +78,6 @@ namespace OpenSim.Region.ScriptEngine.Common Z = z; R = r; } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Common/Properties/AssemblyInfo.cs index 98704d5..48cf45a 100644 --- a/OpenSim/Region/ScriptEngine/Common/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/Common/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.Region.ScriptEngine.Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Region.ScriptEngine.Common")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Region.ScriptEngine.Common")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Region.ScriptEngine.Common")] +[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("0bf07c53-ae51-487f-a907-e9b30c251602")] + +[assembly : Guid("0bf07c53-ae51-487f-a907-e9b30c251602")] // Version information for an assembly consists of the following four values: // @@ -29,5 +31,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[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/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs index 391e3aa..bc241ce 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs @@ -27,27 +27,22 @@ */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.Reflection; -using System.Threading; -using System.Runtime.Remoting; -using System.IO; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; -using OpenSim.Region.ScriptEngine.Common; -using libsecondlife; namespace OpenSim.Region.ScriptEngine.DotNetEngine { public class AppDomainManager { private int maxScriptsPerAppDomain = 1; + /// /// Internal list of all AppDomains /// private List appDomains = new List(); + /// /// Structure to keep track of data around AppDomain /// @@ -57,19 +52,23 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// The AppDomain itself /// public AppDomain CurrentAppDomain; + /// /// Number of scripts loaded into AppDomain /// public int ScriptsLoaded; + /// /// Number of dead scripts /// public int ScriptsWaitingUnload; } + /// /// Current AppDomain /// private AppDomainStructure currentAD; + private object getLock = new object(); // Mutex private object freeLock = new object(); // Mutex @@ -94,22 +93,23 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { // Add it to AppDomains list and empty current appDomains.Add(currentAD); - currentAD = null; + currentAD = null; } // No current if (currentAD == null) { // Create a new current AppDomain currentAD = new AppDomainStructure(); - currentAD.CurrentAppDomain = PrepareNewAppDomain(); + currentAD.CurrentAppDomain = PrepareNewAppDomain(); } - Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded); + Console.WriteLine("Scripts loaded in this Appdomain: " + currentAD.ScriptsLoaded); return currentAD; } // lock } private int AppDomainNameCount; + /// /// Create and prepare a new AppDomain for scripts /// @@ -130,12 +130,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads); - Console.WriteLine("Loading: " + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); + Console.WriteLine("Loading: " + + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString()); AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll")); // Return the new AppDomain return AD; - } /// @@ -146,7 +146,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine lock (freeLock) { // Go through all - foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains)) + foreach (AppDomainStructure ads in new ArrayList(appDomains)) { // Don't process current AppDomain if (ads.CurrentAppDomain != currentAD.CurrentAppDomain) @@ -164,23 +164,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Unload AppDomain.Unload(ads.CurrentAppDomain); #if DEBUG - Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) + " bytes of memory"); + Console.WriteLine("AppDomain unload freed " + (m - GC.GetTotalMemory(true)) + + " bytes of memory"); #endif } } } // foreach } // lock } - - public OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadScript(string FileName) + public LSL_BaseClass LoadScript(string FileName) { // Find next available AppDomain to put it in AppDomainStructure FreeAppDomain = GetFreeAppDomain(); - + Console.WriteLine("Loading into AppDomain: " + FileName); - LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); + LSL_BaseClass mbrt = + (LSL_BaseClass) + FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); //Console.WriteLine("ScriptEngine AppDomainManager: is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); FreeAppDomain.ScriptsLoaded++; @@ -207,7 +209,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } // Lopp through all AppDomains - foreach (AppDomainStructure ads in new System.Collections.ArrayList(appDomains)) + foreach (AppDomainStructure ads in new ArrayList(appDomains)) { if (ads.CurrentAppDomain == ad) { @@ -219,10 +221,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } // lock UnloadAppDomains(); // Outsite lock, has its own GetLock - - } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs index 49ce8b8..e04a9ed 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs @@ -26,34 +26,30 @@ * */ /* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ScriptEngine.DotNetEngine { public static class Common { - static public bool debug = true; - static public ScriptEngine mySE; + public static bool debug = true; + public static ScriptEngine mySE; //public delegate void SendToDebugEventDelegate(string Message); //public delegate void SendToLogEventDelegate(string Message); //static public event SendToDebugEventDelegate SendToDebugEvent; //static public event SendToLogEventDelegate SendToLogEvent; - static public void SendToDebug(string Message) + public static void SendToDebug(string Message) { //if (Debug == true) mySE.Log.Verbose("ScriptEngine", "Debug: " + Message); //SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } - static public void SendToLog(string Message) + + public static void SendToLog(string Message) { //if (Debug == true) mySE.Log.Verbose("ScriptEngine", "LOG: " + Message); //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 a2eee66..7f452e0 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -27,16 +27,13 @@ */ using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using Microsoft.CSharp; using System.CodeDom.Compiler; +using System.IO; using System.Reflection; +using Microsoft.CSharp; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { - public class Compiler { private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); @@ -45,7 +42,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL //private ICodeCompiler icc = codeProvider.CreateCompiler(); public string CompileFromFile(string LSOFileName) { - switch (System.IO.Path.GetExtension(LSOFileName).ToLower()) + switch (Path.GetExtension(LSOFileName).ToLower()) { case ".txt": case ".lsl": @@ -58,6 +55,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL throw new Exception("Unknown script type."); } } + /// /// Converts script from LSL to CS and calls CompileFromCSText /// @@ -67,13 +65,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { if (Script.Substring(0, 4).ToLower() == "//c#") { - return CompileFromCSText( Script ); + return CompileFromCSText(Script); } else { return CompileFromCSText(LSL_Converter.Convert(Script)); } } + /// /// Compile CS script to .Net assembly (.dll) /// @@ -81,14 +80,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL /// Filename to .dll assembly public string CompileFromCSText(string Script) { - - // Output assembly name scriptCompileCounter++; string OutFile = Path.Combine("ScriptEngines", "Script_" + scriptCompileCounter + ".dll"); try { - System.IO.File.Delete(OutFile); + File.Delete(OutFile); } catch (Exception e) { @@ -99,12 +96,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // DEBUG - write source to disk try { - File.WriteAllText(Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script); + File.WriteAllText( + Path.Combine("ScriptEngines", "debug_" + Path.GetFileNameWithoutExtension(OutFile) + ".cs"), Script); + } + catch + { } - catch { } // Do actual compile - System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); + CompilerParameters parameters = new CompilerParameters(); parameters.IncludeDebugInformation = true; // Add all available assemblies foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) @@ -114,11 +114,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL } string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); - string rootPathSE = Path.GetDirectoryName(this.GetType().Assembly.Location); + string rootPathSE = Path.GetDirectoryName(GetType().Assembly.Location); //Console.WriteLine("Assembly location: " + rootPath); parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Common.dll")); parameters.ReferencedAssemblies.Add(Path.Combine(rootPathSE, "OpenSim.Region.ScriptEngine.DotNetEngine.dll")); - + //parameters.ReferencedAssemblies.Add("OpenSim.Region.Environment"); parameters.GenerateExecutable = false; parameters.OutputAssembly = OutFile; @@ -129,13 +129,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // TODO: Return errors to user somehow if (results.Errors.Count > 0) { - string errtext = ""; foreach (CompilerError CompErr in results.Errors) { errtext += "Line number " + (CompErr.Line - 1) + - ", Error Number: " + CompErr.ErrorNumber + - ", '" + CompErr.ErrorText + "'\r\n"; + ", Error Number: " + CompErr.ErrorNumber + + ", '" + CompErr.ErrorText + "'\r\n"; } throw new Exception(errtext); } @@ -143,6 +142,5 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL return OutFile; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 18eeaa3..0c28617 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -26,9 +26,7 @@ * */ -using System; using System.Collections.Generic; -using System.Text; using System.Text.RegularExpressions; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL @@ -51,9 +49,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL dataTypes.Add("rotation", "LSL_Types.Quaternion"); dataTypes.Add("list", "list"); dataTypes.Add("null", "null"); - } - + public string Convert(string Script) { string Return = ""; @@ -81,7 +78,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL int quote_replaced_count = 0; for (int p = 0; p < Script.Length; p++) { - C = Script.Substring(p, 1); while (true) { @@ -99,10 +95,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL if (quote == "") { // We didn't replace quote, probably because of empty string? - _Script += quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); + _Script += quote_replacement_string + + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); } // We just left a quote - quotes.Add(quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote); + quotes.Add( + quote_replacement_string + + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]), quote); quote = ""; } break; @@ -112,7 +111,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { // We are not inside a quote quote_replaced = false; - } else { @@ -120,7 +118,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL if (!quote_replaced) { // Replace quote - _Script += quote_replacement_string + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); + _Script += quote_replacement_string + + quote_replaced_count.ToString().PadLeft(5, "0".ToCharArray()[0]); quote_replaced = true; } quote += C; @@ -141,7 +140,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // - // // PROCESS STATES // Remove state definitions and add state names to start of each event within state @@ -170,7 +168,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL if (ilevel == 1 && lastlevel == 0) { // 0 => 1: Get last - Match m = Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Match m = + Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); in_state = false; if (m.Success) @@ -179,7 +179,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL in_state = true; current_statename = m.Groups[1].Captures[0].Value; //Console.WriteLine("Current statename: " + current_statename); - cache = Regex.Replace(cache, @"(?(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){", "${s1}${s2}", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + cache = + Regex.Replace(cache, + @"(?(?![a-zA-Z_]+)\s*)" + @"([a-zA-Z_]+)(?[^a-zA-Z_\(\)]*){", + "${s1}${s2}", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); } ret += cache; cache = ""; @@ -196,7 +200,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // void dataserver(key query_id, string data) { //cache = Regex.Replace(cache, @"([^a-zA-Z_]\s*)((?!if|switch|for)[a-zA-Z_]+\s*\([^\)]*\)[^{]*{)", "$1" + "" + "$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); //Console.WriteLine("Replacing using statename: " + current_statename); - cache = Regex.Replace(cache, @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1public " + current_statename + "_event_$2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + cache = + Regex.Replace(cache, + @"^(\s*)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", + @"$1public " + current_statename + "_event_$2", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); } ret += cache; @@ -216,32 +224,48 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL ret = ""; - foreach (string key in dataTypes.Keys) { string val; dataTypes.TryGetValue(key, out val); // Replace CAST - (integer) with (int) - Script = Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")", RegexOptions.Compiled | RegexOptions.Multiline); + Script = + Regex.Replace(Script, @"\(" + key + @"\)", @"(" + val + ")", + RegexOptions.Compiled | RegexOptions.Multiline); // Replace return types and function variables - integer a() and f(integer a, integer a) - Script = Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)", @"$1$2" + val + "$3", RegexOptions.Compiled | RegexOptions.Multiline); + Script = + Regex.Replace(Script, @"(^|;|}|[\(,])(\s*)" + key + @"(\s*)", @"$1$2" + val + "$3", + RegexOptions.Compiled | RegexOptions.Multiline); } // Add "void" in front of functions that needs it - Script = Regex.Replace(Script, @"^(\s*public\s+)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, + @"^(\s*public\s+)((?!(if|switch|for)[^a-zA-Z0-9_])[a-zA-Z0-9_]*\s*\([^\)]*\)[^;]*\{)", + @"$1void $2", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // Replace and - Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); - Script = Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Vector3($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Quaternion($1)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"<([^,>]*,[^,>]*,[^,>]*)>", @"new LSL_Types.Vector3($1)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // Replace List []'s - Script = Regex.Replace(Script, @"\[([^\]]*)\]", @"List.Parse($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"\[([^\]]*)\]", @"List.Parse($1)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // Replace (string) to .ToString() // - Script = Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.ToString()", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); - Script = Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.Parse($2)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.ToString()", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); + Script = + Regex.Replace(Script, @"\((float|int)\)\s*([a-zA-Z0-9_]+(\s*\([^\)]*\))?)", @"$1.Parse($2)", + RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); // REPLACE BACK QUOTES @@ -256,7 +280,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // Add namespace, class name and inheritance Return = "" + - "using OpenSim.Region.ScriptEngine.Common;"; + "using OpenSim.Region.ScriptEngine.Common;"; //"using System; " + //"using System.Collections.Generic; " + //"using System.Text; " + @@ -278,17 +302,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL Return += "" + - "namespace SecondLife { "; - Return += "" + - //"[Serializable] " + - "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { "; + "namespace SecondLife { "; + Return += "" + + //"[Serializable] " + + "public class Script : OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass { "; Return += @"public Script() { } "; Return += Script; Return += "} }\r\n"; 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 ea05efc..f2774d6 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -28,476 +28,1788 @@ using System; using System.Collections.Generic; -using System.Text; -using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; -using OpenSim.Region.ScriptEngine.Common; -using System.Threading; -using System.Reflection; using System.Runtime.Remoting.Lifetime; +using System.Threading; +using OpenSim.Region.ScriptEngine.Common; using integer = System.Int32; using key = System.String; using vector = OpenSim.Region.ScriptEngine.Common.LSL_Types.Vector3; using rotation = OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion; -namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL -{ - //[Serializable] - public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript - { +namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL +{ + //[Serializable] + public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript + { + // Object never expires + public override Object InitializeLifetimeService() + { + //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()"); + // return null; + ILease lease = (ILease) base.InitializeLifetimeService(); + + if (lease.CurrentState == LeaseState.Initial) + { + lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); + //lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); + //lease.RenewOnCallTime = TimeSpan.FromSeconds(2); + } + return lease; + } + + + private Executor m_Exec; + + public Executor Exec + { + get + { + if (m_Exec == null) + m_Exec = new Executor(this); + return m_Exec; + } + } + + public LSL_BuiltIn_Commands_Interface m_LSL_Functions; + public string SourceCode = ""; + + public LSL_BaseClass() + { + } + + public string State() + { + return m_LSL_Functions.State(); + } + + + public void Start(LSL_BuiltIn_Commands_Interface LSL_Functions) + { + m_LSL_Functions = LSL_Functions; + + //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called."); + + // Get this AppDomain's settings and display some of them. + AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation; + Console.WriteLine("AppName={0}, AppBase={1}, ConfigFile={2}", + ads.ApplicationName, + ads.ApplicationBase, + ads.ConfigurationFile + ); + + // Display the name of the calling AppDomain and the name + // of the second domain. + // NOTE: The application's thread has transitioned between + // AppDomains. + Console.WriteLine("Calling to '{0}'.", + Thread.GetDomain().FriendlyName + ); + + return; + } + + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + // They are only forwarders to LSL_BuiltIn_Commands.cs + // + public double llSin(double f) + { + return m_LSL_Functions.llSin(f); + } + + public double llCos(double f) + { + return m_LSL_Functions.llCos(f); + } + + public double llTan(double f) + { + return m_LSL_Functions.llTan(f); + } + + public double llAtan2(double x, double y) + { + return m_LSL_Functions.llAtan2(x, y); + } + + public double llSqrt(double f) + { + return m_LSL_Functions.llSqrt(f); + } + + public double llPow(double fbase, double fexponent) + { + return m_LSL_Functions.llPow(fbase, fexponent); + } + + public int llAbs(int i) + { + return m_LSL_Functions.llAbs(i); + } + + public double llFabs(double f) + { + return m_LSL_Functions.llFabs(f); + } + + public double llFrand(double mag) + { + return m_LSL_Functions.llFrand(mag); + } + + public int llFloor(double f) + { + return m_LSL_Functions.llFloor(f); + } + + public int llCeil(double f) + { + return m_LSL_Functions.llCeil(f); + } + + public int llRound(double f) + { + return m_LSL_Functions.llRound(f); + } + + public double llVecMag(vector v) + { + return m_LSL_Functions.llVecMag(v); + } + + public vector llVecNorm(vector v) + { + return m_LSL_Functions.llVecNorm(v); + } + + public double llVecDist(vector a, vector b) + { + return m_LSL_Functions.llVecDist(a, b); + } + + public vector llRot2Euler(rotation r) + { + return m_LSL_Functions.llRot2Euler(r); + } + + public rotation llEuler2Rot(vector v) + { + return m_LSL_Functions.llEuler2Rot(v); + } + + public rotation llAxes2Rot(vector fwd, vector left, vector up) + { + return m_LSL_Functions.llAxes2Rot(fwd, left, up); + } + + public vector llRot2Fwd(rotation r) + { + return m_LSL_Functions.llRot2Fwd(r); + } + + public vector llRot2Left(rotation r) + { + return m_LSL_Functions.llRot2Left(r); + } + + public vector llRot2Up(rotation r) + { + return m_LSL_Functions.llRot2Up(r); + } + + public rotation llRotBetween(vector start, vector end) + { + return m_LSL_Functions.llRotBetween(start, end); + } + + public void llWhisper(int channelID, string text) + { + m_LSL_Functions.llWhisper(channelID, text); + } + + public void llSay(int channelID, string text) + { + m_LSL_Functions.llSay(channelID, text); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llShout(int channelID, string text) + { + m_LSL_Functions.llShout(channelID, text); + } + + public int llListen(int channelID, string name, string ID, string msg) + { + return m_LSL_Functions.llListen(channelID, name, ID, msg); + } + + public void llListenControl(int number, int active) + { + m_LSL_Functions.llListenControl(number, active); + } + + public void llListenRemove(int number) + { + m_LSL_Functions.llListenRemove(number); + } + + public void llSensor(string name, string id, int type, double range, double arc) + { + m_LSL_Functions.llSensor(name, id, type, range, arc); + } + + public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) + { + m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate); + } + + public void llSensorRemove() + { + m_LSL_Functions.llSensorRemove(); + } + + public string llDetectedName(int number) + { + return m_LSL_Functions.llDetectedName(number); + } + + public string llDetectedKey(int number) + { + return m_LSL_Functions.llDetectedKey(number); + } + + public string llDetectedOwner(int number) + { + return m_LSL_Functions.llDetectedOwner(number); + } + + public int llDetectedType(int number) + { + return m_LSL_Functions.llDetectedType(number); + } + + public vector llDetectedPos(int number) + { + return m_LSL_Functions.llDetectedPos(number); + } + + public vector llDetectedVel(int number) + { + return m_LSL_Functions.llDetectedVel(number); + } + + public vector llDetectedGrab(int number) + { + return m_LSL_Functions.llDetectedGrab(number); + } + + public rotation llDetectedRot(int number) + { + return m_LSL_Functions.llDetectedRot(number); + } + + public int llDetectedGroup(int number) + { + return m_LSL_Functions.llDetectedGroup(number); + } + + public int llDetectedLinkNumber(int number) + { + return m_LSL_Functions.llDetectedLinkNumber(number); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llDie() + { + m_LSL_Functions.llDie(); + } + + public double llGround(vector offset) + { + return m_LSL_Functions.llGround(offset); + } + + public double llCloud(vector offset) + { + return m_LSL_Functions.llCloud(offset); + } + + public vector llWind(vector offset) + { + return m_LSL_Functions.llWind(offset); + } + + public void llSetStatus(int status, int value) + { + m_LSL_Functions.llSetStatus(status, value); + } + + public int llGetStatus(int status) + { + return m_LSL_Functions.llGetStatus(status); + } + + public void llSetScale(vector scale) + { + m_LSL_Functions.llSetScale(scale); + } + + public vector llGetScale() + { + return m_LSL_Functions.llGetScale(); + } + + public void llSetColor(vector color, int face) + { + m_LSL_Functions.llSetColor(color, face); + } + + public double llGetAlpha(int face) + { + return m_LSL_Functions.llGetAlpha(face); + } + + public void llSetAlpha(double alpha, int face) + { + m_LSL_Functions.llSetAlpha(alpha, face); + } + + public vector llGetColor(int face) + { + return m_LSL_Functions.llGetColor(face); + } + + public void llSetTexture(string texture, int face) + { + m_LSL_Functions.llSetTexture(texture, face); + } + + public void llScaleTexture(double u, double v, int face) + { + m_LSL_Functions.llScaleTexture(u, v, face); + } + + public void llOffsetTexture(double u, double v, int face) + { + m_LSL_Functions.llOffsetTexture(u, v, face); + } + + public void llRotateTexture(double rotation, int face) + { + m_LSL_Functions.llRotateTexture(rotation, face); + } + + public string llGetTexture(int face) + { + return m_LSL_Functions.llGetTexture(face); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llSetPos(vector pos) + { + m_LSL_Functions.llSetPos(pos); + } + + public vector llGetPos() + { + return m_LSL_Functions.llGetPos(); + } + + public vector llGetLocalPos() + { + return m_LSL_Functions.llGetLocalPos(); + } + + public void llSetRot(rotation rot) + { + m_LSL_Functions.llSetRot(rot); + } + + public rotation llGetRot() + { + return m_LSL_Functions.llGetRot(); + } + + public rotation llGetLocalRot() + { + return m_LSL_Functions.llGetLocalRot(); + } + + public void llSetForce(vector force, int local) + { + m_LSL_Functions.llSetForce(force, local); + } + + public vector llGetForce() + { + return m_LSL_Functions.llGetForce(); + } + + public int llTarget(vector position, double range) + { + return m_LSL_Functions.llTarget(position, range); + } + + public void llTargetRemove(int number) + { + m_LSL_Functions.llTargetRemove(number); + } + + public int llRotTarget(rotation rot, double error) + { + return m_LSL_Functions.llRotTarget(rot, error); + } + + public void llRotTargetRemove(int number) + { + m_LSL_Functions.llRotTargetRemove(number); + } + + public void llMoveToTarget(vector target, double tau) + { + m_LSL_Functions.llMoveToTarget(target, tau); + } + + public void llStopMoveToTarget() + { + m_LSL_Functions.llStopMoveToTarget(); + } + + public void llApplyImpulse(vector force, int local) + { + m_LSL_Functions.llApplyImpulse(force, local); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llApplyRotationalImpulse(vector force, int local) + { + m_LSL_Functions.llApplyRotationalImpulse(force, local); + } + + public void llSetTorque(vector torque, int local) + { + m_LSL_Functions.llSetTorque(torque, local); + } + + public vector llGetTorque() + { + return m_LSL_Functions.llGetTorque(); + } + + public void llSetForceAndTorque(vector force, vector torque, int local) + { + m_LSL_Functions.llSetForceAndTorque(force, torque, local); + } + + public vector llGetVel() + { + return m_LSL_Functions.llGetVel(); + } + + public vector llGetAccel() + { + return m_LSL_Functions.llGetAccel(); + } + + public vector llGetOmega() + { + return m_LSL_Functions.llGetOmega(); + } + + public double llGetTimeOfDay() + { + return m_LSL_Functions.llGetTimeOfDay(); + } + + public double llGetWallclock() + { + return m_LSL_Functions.llGetWallclock(); + } + + public double llGetTime() + { + return m_LSL_Functions.llGetTime(); + } + + public void llResetTime() + { + m_LSL_Functions.llResetTime(); + } + + public double llGetAndResetTime() + { + return m_LSL_Functions.llGetAndResetTime(); + } + + public void llSound() + { + m_LSL_Functions.llSound(); + } + + public void llPlaySound(string sound, double volume) + { + m_LSL_Functions.llPlaySound(sound, volume); + } + + public void llLoopSound(string sound, double volume) + { + m_LSL_Functions.llLoopSound(sound, volume); + } + + public void llLoopSoundMaster(string sound, double volume) + { + m_LSL_Functions.llLoopSoundMaster(sound, volume); + } + + public void llLoopSoundSlave(string sound, double volume) + { + m_LSL_Functions.llLoopSoundSlave(sound, volume); + } + + public void llPlaySoundSlave(string sound, double volume) + { + m_LSL_Functions.llPlaySoundSlave(sound, volume); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llTriggerSound(string sound, double volume) + { + m_LSL_Functions.llTriggerSound(sound, volume); + } + + public void llStopSound() + { + m_LSL_Functions.llStopSound(); + } + + public void llPreloadSound(string sound) + { + m_LSL_Functions.llPreloadSound(sound); + } + + public string llGetSubString(string src, int start, int end) + { + return m_LSL_Functions.llGetSubString(src, start, end); + } + + public string llDeleteSubString(string src, int start, int end) + { + return m_LSL_Functions.llDeleteSubString(src, start, end); + } + + public string llInsertString(string dst, int position, string src) + { + return m_LSL_Functions.llInsertString(dst, position, src); + } + + public string llToUpper(string source) + { + return m_LSL_Functions.llToUpper(source); + } + + public string llToLower(string source) + { + return m_LSL_Functions.llToLower(source); + } + + public int llGiveMoney(string destination, int amount) + { + return m_LSL_Functions.llGiveMoney(destination, amount); + } + + public void llMakeExplosion() + { + m_LSL_Functions.llMakeExplosion(); + } + + public void llMakeFountain() + { + m_LSL_Functions.llMakeFountain(); + } + + public void llMakeSmoke() + { + m_LSL_Functions.llMakeSmoke(); + } + + public void llMakeFire() + { + m_LSL_Functions.llMakeFire(); + } + + public void llRezObject(string inventory, vector pos, rotation rot, int param) + { + m_LSL_Functions.llRezObject(inventory, pos, rot, param); + } + + public void llLookAt(vector target, double strength, double damping) + { + m_LSL_Functions.llLookAt(target, strength, damping); + } + + public void llStopLookAt() + { + m_LSL_Functions.llStopLookAt(); + } + + public void llSetTimerEvent(double sec) + { + m_LSL_Functions.llSetTimerEvent(sec); + } + + public void llSleep(double sec) + { + m_LSL_Functions.llSleep(sec); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public double llGetMass() + { + return m_LSL_Functions.llGetMass(); + } + + public void llCollisionFilter(string name, string id, int accept) + { + m_LSL_Functions.llCollisionFilter(name, id, accept); + } + + public void llTakeControls(int controls, int accept, int pass_on) + { + m_LSL_Functions.llTakeControls(controls, accept, pass_on); + } + + public void llReleaseControls() + { + m_LSL_Functions.llReleaseControls(); + } + + public void llAttachToAvatar(int attachment) + { + m_LSL_Functions.llAttachToAvatar(attachment); + } + + public void llDetachFromAvatar() + { + m_LSL_Functions.llDetachFromAvatar(); + } + + public void llTakeCamera() + { + m_LSL_Functions.llTakeCamera(); + } + + public void llReleaseCamera() + { + m_LSL_Functions.llReleaseCamera(); + } + + public string llGetOwner() + { + return m_LSL_Functions.llGetOwner(); + } + + public void llInstantMessage(string user, string message) + { + m_LSL_Functions.llInstantMessage(user, message); + } + + public void llEmail(string address, string subject, string message) + { + m_LSL_Functions.llEmail(address, subject, message); + } + + public void llGetNextEmail(string address, string subject) + { + m_LSL_Functions.llGetNextEmail(address, subject); + } + + public string llGetKey() + { + return m_LSL_Functions.llGetKey(); + } + + public void llSetBuoyancy(double buoyancy) + { + m_LSL_Functions.llSetBuoyancy(buoyancy); + } + + public void llSetHoverHeight(double height, int water, double tau) + { + m_LSL_Functions.llSetHoverHeight(height, water, tau); + } + + public void llStopHover() + { + m_LSL_Functions.llStopHover(); + } + + public void llMinEventDelay(double delay) + { + m_LSL_Functions.llMinEventDelay(delay); + } + + public void llSoundPreload() + { + m_LSL_Functions.llSoundPreload(); + } + + public void llRotLookAt(rotation target, double strength, double damping) + { + m_LSL_Functions.llRotLookAt(target, strength, damping); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public int llStringLength(string str) + { + return m_LSL_Functions.llStringLength(str); + } + + public void llStartAnimation(string anim) + { + m_LSL_Functions.llStartAnimation(anim); + } + + public void llStopAnimation(string anim) + { + m_LSL_Functions.llStopAnimation(anim); + } + + public void llPointAt() + { + m_LSL_Functions.llPointAt(); + } + + public void llStopPointAt() + { + m_LSL_Functions.llStopPointAt(); + } + + public void llTargetOmega(vector axis, double spinrate, double gain) + { + m_LSL_Functions.llTargetOmega(axis, spinrate, gain); + } + + public int llGetStartParameter() + { + return m_LSL_Functions.llGetStartParameter(); + } + + public void llGodLikeRezObject(string inventory, vector pos) + { + m_LSL_Functions.llGodLikeRezObject(inventory, pos); + } + + public void llRequestPermissions(string agent, int perm) + { + m_LSL_Functions.llRequestPermissions(agent, perm); + } + + public string llGetPermissionsKey() + { + return m_LSL_Functions.llGetPermissionsKey(); + } + + public int llGetPermissions() + { + return m_LSL_Functions.llGetPermissions(); + } + + public int llGetLinkNumber() + { + return m_LSL_Functions.llGetLinkNumber(); + } + + public void llSetLinkColor(int linknumber, vector color, int face) + { + m_LSL_Functions.llSetLinkColor(linknumber, color, face); + } + + public void llCreateLink(string target, int parent) + { + m_LSL_Functions.llCreateLink(target, parent); + } + + public void llBreakLink(int linknum) + { + m_LSL_Functions.llBreakLink(linknum); + } + + public void llBreakAllLinks() + { + m_LSL_Functions.llBreakAllLinks(); + } + + public string llGetLinkKey(int linknum) + { + return m_LSL_Functions.llGetLinkKey(linknum); + } + + public void llGetLinkName(int linknum) + { + m_LSL_Functions.llGetLinkName(linknum); + } + + public int llGetInventoryNumber(int type) + { + return m_LSL_Functions.llGetInventoryNumber(type); + } + + public string llGetInventoryName(int type, int number) + { + return m_LSL_Functions.llGetInventoryName(type, number); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llSetScriptState(string name, int run) + { + m_LSL_Functions.llSetScriptState(name, run); + } + + public double llGetEnergy() + { + return m_LSL_Functions.llGetEnergy(); + } + + public void llGiveInventory(string destination, string inventory) + { + m_LSL_Functions.llGiveInventory(destination, inventory); + } + + public void llRemoveInventory(string item) + { + m_LSL_Functions.llRemoveInventory(item); + } + + public void llSetText(string text, vector color, double alpha) + { + m_LSL_Functions.llSetText(text, color, alpha); + } + + public double llWater(vector offset) + { + return m_LSL_Functions.llWater(offset); + } + + public void llPassTouches(int pass) + { + m_LSL_Functions.llPassTouches(pass); + } + + public string llRequestAgentData(string id, int data) + { + return m_LSL_Functions.llRequestAgentData(id, data); + } + + public string llRequestInventoryData(string name) + { + return m_LSL_Functions.llRequestInventoryData(name); + } + + public void llSetDamage(double damage) + { + m_LSL_Functions.llSetDamage(damage); + } + + public void llTeleportAgentHome(string agent) + { + m_LSL_Functions.llTeleportAgentHome(agent); + } + + public void llModifyLand(int action, int brush) + { + m_LSL_Functions.llModifyLand(action, brush); + } + + public void llCollisionSound(string impact_sound, double impact_volume) + { + m_LSL_Functions.llCollisionSound(impact_sound, impact_volume); + } + + public void llCollisionSprite(string impact_sprite) + { + m_LSL_Functions.llCollisionSprite(impact_sprite); + } + + public string llGetAnimation(string id) + { + return m_LSL_Functions.llGetAnimation(id); + } + + public void llResetScript() + { + m_LSL_Functions.llResetScript(); + } + + public void llMessageLinked(int linknum, int num, string str, string id) + { + m_LSL_Functions.llMessageLinked(linknum, num, str, id); + } + + public void llPushObject(string target, vector impulse, vector ang_impulse, int local) + { + m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local); + } + + public void llPassCollisions(int pass) + { + m_LSL_Functions.llPassCollisions(pass); + } + + public string llGetScriptName() + { + return m_LSL_Functions.llGetScriptName(); + } + + public int llGetNumberOfSides() + { + return m_LSL_Functions.llGetNumberOfSides(); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public rotation llAxisAngle2Rot(vector axis, double angle) + { + return m_LSL_Functions.llAxisAngle2Rot(axis, angle); + } + + public vector llRot2Axis(rotation rot) + { + return m_LSL_Functions.llRot2Axis(rot); + } + + public void llRot2Angle() + { + m_LSL_Functions.llRot2Angle(); + } + + public double llAcos(double val) + { + return m_LSL_Functions.llAcos(val); + } + + public double llAsin(double val) + { + return m_LSL_Functions.llAsin(val); + } + + public double llAngleBetween(rotation a, rotation b) + { + return m_LSL_Functions.llAngleBetween(a, b); + } + + public string llGetInventoryKey(string name) + { + return m_LSL_Functions.llGetInventoryKey(name); + } + + public void llAllowInventoryDrop(int add) + { + m_LSL_Functions.llAllowInventoryDrop(add); + } + + public vector llGetSunDirection() + { + return m_LSL_Functions.llGetSunDirection(); + } + + public vector llGetTextureOffset(int face) + { + return m_LSL_Functions.llGetTextureOffset(face); + } + + public vector llGetTextureScale(int side) + { + return m_LSL_Functions.llGetTextureScale(side); + } + + public double llGetTextureRot(int side) + { + return m_LSL_Functions.llGetTextureRot(side); + } + + public int llSubStringIndex(string source, string pattern) + { + return m_LSL_Functions.llSubStringIndex(source, pattern); + } + + public string llGetOwnerKey(string id) + { + return m_LSL_Functions.llGetOwnerKey(id); + } + + public vector llGetCenterOfMass() + { + return m_LSL_Functions.llGetCenterOfMass(); + } + + public List llListSort(List src, int stride, int ascending) + { + return m_LSL_Functions.llListSort(src, stride, ascending); + } + + public int llGetListLength(List src) + { + return m_LSL_Functions.llGetListLength(src); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public int llList2Integer(List src, int index) + { + return m_LSL_Functions.llList2Integer(src, index); + } + + public double llList2double(List src, int index) + { + return m_LSL_Functions.llList2double(src, index); + } + + public string llList2String(List src, int index) + { + return m_LSL_Functions.llList2String(src, index); + } + + public string llList2Key(List src, int index) + { + return m_LSL_Functions.llList2Key(src, index); + } + + public vector llList2Vector(List src, int index) + { + return m_LSL_Functions.llList2Vector(src, index); + } + + public rotation llList2Rot(List src, int index) + { + return m_LSL_Functions.llList2Rot(src, index); + } + + public List llList2List(List src, int start, int end) + { + return m_LSL_Functions.llList2List(src, start, end); + } + + public List llDeleteSubList(List src, int start, int end) + { + return m_LSL_Functions.llDeleteSubList(src, start, end); + } + + public int llGetListEntryType(List src, int index) + { + return m_LSL_Functions.llGetListEntryType(src, index); + } + + public string llList2CSV(List src) + { + return m_LSL_Functions.llList2CSV(src); + } + + public List llCSV2List(string src) + { + return m_LSL_Functions.llCSV2List(src); + } + + public List llListRandomize(List src, int stride) + { + return m_LSL_Functions.llListRandomize(src, stride); + } + + public List llList2ListStrided(List src, int start, int end, int stride) + { + return m_LSL_Functions.llList2ListStrided(src, start, end, stride); + } + + public vector llGetRegionCorner() + { + return m_LSL_Functions.llGetRegionCorner(); + } + + public List llListInsertList(List dest, List src, int start) + { + return m_LSL_Functions.llListInsertList(dest, src, start); + } + + public int llListFindList(List src, List test) + { + return m_LSL_Functions.llListFindList(src, test); + } + + public string llGetObjectName() + { + return m_LSL_Functions.llGetObjectName(); + } + + public void llSetObjectName(string name) + { + m_LSL_Functions.llSetObjectName(name); + } + + public string llGetDate() + { + return m_LSL_Functions.llGetDate(); + } + + public int llEdgeOfWorld(vector pos, vector dir) + { + return m_LSL_Functions.llEdgeOfWorld(pos, dir); + } + + public int llGetAgentInfo(string id) + { + return m_LSL_Functions.llGetAgentInfo(id); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llAdjustSoundVolume(double volume) + { + m_LSL_Functions.llAdjustSoundVolume(volume); + } + + public void llSetSoundQueueing(int queue) + { + m_LSL_Functions.llSetSoundQueueing(queue); + } + + public void llSetSoundRadius(double radius) + { + m_LSL_Functions.llSetSoundRadius(radius); + } + + public string llKey2Name(string id) + { + return m_LSL_Functions.llKey2Name(id); + } + + public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) + { + m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate); + } + + public void llTriggerSoundLimited(string sound, double volume, vector top_north_east, vector bottom_south_west) + { + m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west); + } + + public void llEjectFromLand(string pest) + { + m_LSL_Functions.llEjectFromLand(pest); + } + + public void llParseString2List() + { + m_LSL_Functions.llParseString2List(); + } + + public int llOverMyLand(string id) + { + return m_LSL_Functions.llOverMyLand(id); + } + + public string llGetLandOwnerAt(vector pos) + { + return m_LSL_Functions.llGetLandOwnerAt(pos); + } + + public string llGetNotecardLine(string name, int line) + { + return m_LSL_Functions.llGetNotecardLine(name, line); + } + + public vector llGetAgentSize(string id) + { + return m_LSL_Functions.llGetAgentSize(id); + } + + public int llSameGroup(string agent) + { + return m_LSL_Functions.llSameGroup(agent); + } + + public void llUnSit(string id) + { + m_LSL_Functions.llUnSit(id); + } + + public vector llGroundSlope(vector offset) + { + return m_LSL_Functions.llGroundSlope(offset); + } + + public vector llGroundNormal(vector offset) + { + return m_LSL_Functions.llGroundNormal(offset); + } + + public vector llGroundContour(vector offset) + { + return m_LSL_Functions.llGroundContour(offset); + } + + public int llGetAttached() + { + return m_LSL_Functions.llGetAttached(); + } + + public int llGetFreeMemory() + { + return m_LSL_Functions.llGetFreeMemory(); + } + + public string llGetRegionName() + { + return m_LSL_Functions.llGetRegionName(); + } + + public double llGetRegionTimeDilation() + { + return m_LSL_Functions.llGetRegionTimeDilation(); + } + + public double llGetRegionFPS() + { + return m_LSL_Functions.llGetRegionFPS(); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llParticleSystem(List rules) + { + m_LSL_Functions.llParticleSystem(rules); + } + + public void llGroundRepel(double height, int water, double tau) + { + m_LSL_Functions.llGroundRepel(height, water, tau); + } + + public void llGiveInventoryList() + { + m_LSL_Functions.llGiveInventoryList(); + } + + public void llSetVehicleType(int type) + { + m_LSL_Functions.llSetVehicleType(type); + } + + public void llSetVehicledoubleParam(int param, double value) + { + m_LSL_Functions.llSetVehicledoubleParam(param, value); + } + + public void llSetVehicleVectorParam(int param, vector vec) + { + m_LSL_Functions.llSetVehicleVectorParam(param, vec); + } + + public void llSetVehicleRotationParam(int param, rotation rot) + { + m_LSL_Functions.llSetVehicleRotationParam(param, rot); + } + + public void llSetVehicleFlags(int flags) + { + m_LSL_Functions.llSetVehicleFlags(flags); + } + + public void llRemoveVehicleFlags(int flags) + { + m_LSL_Functions.llRemoveVehicleFlags(flags); + } + + public void llSitTarget(vector offset, rotation rot) + { + m_LSL_Functions.llSitTarget(offset, rot); + } + + public string llAvatarOnSitTarget() + { + return m_LSL_Functions.llAvatarOnSitTarget(); + } + + public void llAddToLandPassList(string avatar, double hours) + { + m_LSL_Functions.llAddToLandPassList(avatar, hours); + } + + public void llSetTouchText(string text) + { + m_LSL_Functions.llSetTouchText(text); + } + + public void llSetSitText(string text) + { + m_LSL_Functions.llSetSitText(text); + } + + public void llSetCameraEyeOffset(vector offset) + { + m_LSL_Functions.llSetCameraEyeOffset(offset); + } + + public void llSetCameraAtOffset(vector offset) + { + m_LSL_Functions.llSetCameraAtOffset(offset); + } + + public void llDumpList2String() + { + m_LSL_Functions.llDumpList2String(); + } + + public void llScriptDanger(vector pos) + { + m_LSL_Functions.llScriptDanger(pos); + } + + public void llDialog(string avatar, string message, List buttons, int chat_channel) + { + m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); + } + + public void llVolumeDetect(int detect) + { + m_LSL_Functions.llVolumeDetect(detect); + } + + public void llResetOtherScript(string name) + { + m_LSL_Functions.llResetOtherScript(name); + } + + public int llGetScriptState(string name) + { + return m_LSL_Functions.llGetScriptState(name); + } + + public void llRemoteLoadScript() + { + m_LSL_Functions.llRemoteLoadScript(); + } + + public void llSetRemoteScriptAccessPin(int pin) + { + m_LSL_Functions.llSetRemoteScriptAccessPin(pin); + } + + public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) + { + m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param); + } + + // + // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs + // + public void llOpenRemoteDataChannel() + { + m_LSL_Functions.llOpenRemoteDataChannel(); + } + + public string llSendRemoteData(string channel, string dest, int idata, string sdata) + { + return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); + } + + public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) + { + m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata); + } + + public void llCloseRemoteDataChannel(string channel) + { + m_LSL_Functions.llCloseRemoteDataChannel(channel); + } + + public string llMD5String(string src, int nonce) + { + return m_LSL_Functions.llMD5String(src, nonce); + } + + public void llSetPrimitiveParams(List rules) + { + m_LSL_Functions.llSetPrimitiveParams(rules); + } + + public string llStringToBase64(string str) + { + return m_LSL_Functions.llStringToBase64(str); + } + + public string llBase64ToString(string str) + { + return m_LSL_Functions.llBase64ToString(str); + } + + public void llXorBase64Strings() + { + m_LSL_Functions.llXorBase64Strings(); + } + + public void llRemoteDataSetRegion() + { + m_LSL_Functions.llRemoteDataSetRegion(); + } + + public double llLog10(double val) + { + return m_LSL_Functions.llLog10(val); + } - // Object never expires - public override Object InitializeLifetimeService() + public double llLog(double val) { - //Console.WriteLine("LSL_BaseClass: InitializeLifetimeService()"); - // return null; - ILease lease = (ILease)base.InitializeLifetimeService(); + return m_LSL_Functions.llLog(val); + } - if (lease.CurrentState == LeaseState.Initial) - { - lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); - //lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); - //lease.RenewOnCallTime = TimeSpan.FromSeconds(2); - } - return lease; + public List llGetAnimationList(string id) + { + return m_LSL_Functions.llGetAnimationList(id); } + public void llSetParcelMusicURL(string url) + { + m_LSL_Functions.llSetParcelMusicURL(url); + } - private Executor m_Exec; - public Executor Exec + public vector llGetRootPosition() { - get - { - if (m_Exec == null) - m_Exec = new Executor(this); - return m_Exec; - } + return m_LSL_Functions.llGetRootPosition(); } - public LSL_BuiltIn_Commands_Interface m_LSL_Functions; - public string SourceCode = ""; + public rotation llGetRootRotation() + { + return m_LSL_Functions.llGetRootRotation(); + } - public LSL_BaseClass() + public string llGetObjectDesc() { + return m_LSL_Functions.llGetObjectDesc(); } - public string State() + + public void llSetObjectDesc(string desc) { - return m_LSL_Functions.State(); + m_LSL_Functions.llSetObjectDesc(desc); } + public string llGetCreator() + { + return m_LSL_Functions.llGetCreator(); + } - public void Start(LSL_BuiltIn_Commands_Interface LSL_Functions) + public string llGetTimestamp() { - m_LSL_Functions = LSL_Functions; + return m_LSL_Functions.llGetTimestamp(); + } - //MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called."); + public void llSetLinkAlpha(int linknumber, double alpha, int face) + { + m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face); + } - // Get this AppDomain's settings and display some of them. - AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation; - Console.WriteLine("AppName={0}, AppBase={1}, ConfigFile={2}", - ads.ApplicationName, - ads.ApplicationBase, - ads.ConfigurationFile - ); + public int llGetNumberOfPrims() + { + return m_LSL_Functions.llGetNumberOfPrims(); + } - // Display the name of the calling AppDomain and the name - // of the second domain. - // NOTE: The application's thread has transitioned between - // AppDomains. - Console.WriteLine("Calling to '{0}'.", - Thread.GetDomain().FriendlyName - ); + public string llGetNumberOfNotecardLines(string name) + { + return m_LSL_Functions.llGetNumberOfNotecardLines(name); + } - return; + public List llGetBoundingBox(string obj) + { + return m_LSL_Functions.llGetBoundingBox(obj); } + public vector llGetGeometricCenter() + { + return m_LSL_Functions.llGetGeometricCenter(); + } + public void llGetPrimitiveParams() + { + m_LSL_Functions.llGetPrimitiveParams(); + } // // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs // - // They are only forwarders to LSL_BuiltIn_Commands.cs - // - public double llSin(double f) { return m_LSL_Functions.llSin(f); } - public double llCos(double f) { return m_LSL_Functions.llCos(f); } - public double llTan(double f) { return m_LSL_Functions.llTan(f); } - public double llAtan2(double x, double y) { return m_LSL_Functions.llAtan2(x, y); } - public double llSqrt(double f) { return m_LSL_Functions.llSqrt(f); } - public double llPow(double fbase, double fexponent) { return m_LSL_Functions.llPow(fbase, fexponent); } - public int llAbs(int i) { return m_LSL_Functions.llAbs(i); } - public double llFabs(double f) { return m_LSL_Functions.llFabs(f); } - public double llFrand(double mag) { return m_LSL_Functions.llFrand(mag); } - public int llFloor(double f) { return m_LSL_Functions.llFloor(f); } - public int llCeil(double f) { return m_LSL_Functions.llCeil(f); } - public int llRound(double f) { return m_LSL_Functions.llRound(f); } - public double llVecMag(LSL_Types.Vector3 v) { return m_LSL_Functions.llVecMag(v); } - public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) { return m_LSL_Functions.llVecNorm(v); } - public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) { return m_LSL_Functions.llVecDist(a, b); } - public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Euler(r); } - public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) { return m_LSL_Functions.llEuler2Rot(v); } - public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return m_LSL_Functions.llAxes2Rot(fwd, left, up); } - public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Fwd(r); } - public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Left(r); } - public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) { return m_LSL_Functions.llRot2Up(r); } - public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) { return m_LSL_Functions.llRotBetween(start, end); } - public void llWhisper(int channelID, string text) { m_LSL_Functions.llWhisper(channelID, text); } - public void llSay(int channelID, string text) { m_LSL_Functions.llSay(channelID, text); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llShout(int channelID, string text) { m_LSL_Functions.llShout(channelID, text); } - public int llListen(int channelID, string name, string ID, string msg) { return m_LSL_Functions.llListen(channelID, name, ID, msg); } - public void llListenControl(int number, int active) { m_LSL_Functions.llListenControl(number, active); } - public void llListenRemove(int number) { m_LSL_Functions.llListenRemove(number); } - public void llSensor(string name, string id, int type, double range, double arc) { m_LSL_Functions.llSensor(name, id, type, range, arc); } - public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { m_LSL_Functions.llSensorRepeat(name, id, type, range, arc, rate); } - public void llSensorRemove() { m_LSL_Functions.llSensorRemove(); } - public string llDetectedName(int number) { return m_LSL_Functions.llDetectedName(number); } - public string llDetectedKey(int number) { return m_LSL_Functions.llDetectedKey(number); } - public string llDetectedOwner(int number) { return m_LSL_Functions.llDetectedOwner(number); } - public int llDetectedType(int number) { return m_LSL_Functions.llDetectedType(number); } - public LSL_Types.Vector3 llDetectedPos(int number) { return m_LSL_Functions.llDetectedPos(number); } - public LSL_Types.Vector3 llDetectedVel(int number) { return m_LSL_Functions.llDetectedVel(number); } - public LSL_Types.Vector3 llDetectedGrab(int number) { return m_LSL_Functions.llDetectedGrab(number); } - public LSL_Types.Quaternion llDetectedRot(int number) { return m_LSL_Functions.llDetectedRot(number); } - public int llDetectedGroup(int number) { return m_LSL_Functions.llDetectedGroup(number); } - public int llDetectedLinkNumber(int number) { return m_LSL_Functions.llDetectedLinkNumber(number); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llDie() { m_LSL_Functions.llDie(); } - public double llGround(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGround(offset); } - public double llCloud(LSL_Types.Vector3 offset) { return m_LSL_Functions.llCloud(offset); } - public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) { return m_LSL_Functions.llWind(offset); } - public void llSetStatus(int status, int value) { m_LSL_Functions.llSetStatus(status, value); } - public int llGetStatus(int status) { return m_LSL_Functions.llGetStatus(status); } - public void llSetScale(LSL_Types.Vector3 scale) { m_LSL_Functions.llSetScale(scale); } - public LSL_Types.Vector3 llGetScale() { return m_LSL_Functions.llGetScale(); } - public void llSetColor(LSL_Types.Vector3 color, int face) { m_LSL_Functions.llSetColor(color, face); } - public double llGetAlpha(int face) { return m_LSL_Functions.llGetAlpha(face); } - public void llSetAlpha(double alpha, int face) { m_LSL_Functions.llSetAlpha(alpha, face); } - public LSL_Types.Vector3 llGetColor(int face) { return m_LSL_Functions.llGetColor(face); } - public void llSetTexture(string texture, int face) { m_LSL_Functions.llSetTexture(texture, face); } - public void llScaleTexture(double u, double v, int face) { m_LSL_Functions.llScaleTexture(u, v, face); } - public void llOffsetTexture(double u, double v, int face) { m_LSL_Functions.llOffsetTexture(u, v, face); } - public void llRotateTexture(double rotation, int face) { m_LSL_Functions.llRotateTexture(rotation, face); } - public string llGetTexture(int face) { return m_LSL_Functions.llGetTexture(face); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llSetPos(LSL_Types.Vector3 pos) { m_LSL_Functions.llSetPos(pos); } - public LSL_Types.Vector3 llGetPos() { return m_LSL_Functions.llGetPos(); } - public LSL_Types.Vector3 llGetLocalPos() { return m_LSL_Functions.llGetLocalPos(); } - public void llSetRot(LSL_Types.Quaternion rot) { m_LSL_Functions.llSetRot(rot); } - public LSL_Types.Quaternion llGetRot() { return m_LSL_Functions.llGetRot(); } - public LSL_Types.Quaternion llGetLocalRot() { return m_LSL_Functions.llGetLocalRot(); } - public void llSetForce(LSL_Types.Vector3 force, int local) { m_LSL_Functions.llSetForce(force, local); } - public LSL_Types.Vector3 llGetForce() { return m_LSL_Functions.llGetForce(); } - public int llTarget(LSL_Types.Vector3 position, double range) { return m_LSL_Functions.llTarget(position, range); } - public void llTargetRemove(int number) { m_LSL_Functions.llTargetRemove(number); } - public int llRotTarget(LSL_Types.Quaternion rot, double error) { return m_LSL_Functions.llRotTarget(rot, error); } - public void llRotTargetRemove(int number) { m_LSL_Functions.llRotTargetRemove(number); } - public void llMoveToTarget(LSL_Types.Vector3 target, double tau) { m_LSL_Functions.llMoveToTarget(target, tau); } - public void llStopMoveToTarget() { m_LSL_Functions.llStopMoveToTarget(); } - public void llApplyImpulse(LSL_Types.Vector3 force, int local) { m_LSL_Functions.llApplyImpulse(force, local); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) { m_LSL_Functions.llApplyRotationalImpulse(force, local); } - public void llSetTorque(LSL_Types.Vector3 torque, int local) { m_LSL_Functions.llSetTorque(torque, local); } - public LSL_Types.Vector3 llGetTorque() { return m_LSL_Functions.llGetTorque(); } - public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) { m_LSL_Functions.llSetForceAndTorque(force, torque, local); } - public LSL_Types.Vector3 llGetVel() { return m_LSL_Functions.llGetVel(); } - public LSL_Types.Vector3 llGetAccel() { return m_LSL_Functions.llGetAccel(); } - public LSL_Types.Vector3 llGetOmega() { return m_LSL_Functions.llGetOmega(); } - public double llGetTimeOfDay() { return m_LSL_Functions.llGetTimeOfDay(); } - public double llGetWallclock() { return m_LSL_Functions.llGetWallclock(); } - public double llGetTime() { return m_LSL_Functions.llGetTime(); } - public void llResetTime() { m_LSL_Functions.llResetTime(); } - public double llGetAndResetTime() { return m_LSL_Functions.llGetAndResetTime(); } - public void llSound() { m_LSL_Functions.llSound(); } - public void llPlaySound(string sound, double volume) { m_LSL_Functions.llPlaySound(sound, volume); } - public void llLoopSound(string sound, double volume) { m_LSL_Functions.llLoopSound(sound, volume); } - public void llLoopSoundMaster(string sound, double volume) { m_LSL_Functions.llLoopSoundMaster(sound, volume); } - public void llLoopSoundSlave(string sound, double volume) { m_LSL_Functions.llLoopSoundSlave(sound, volume); } - public void llPlaySoundSlave(string sound, double volume) { m_LSL_Functions.llPlaySoundSlave(sound, volume); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llTriggerSound(string sound, double volume) { m_LSL_Functions.llTriggerSound(sound, volume); } - public void llStopSound() { m_LSL_Functions.llStopSound(); } - public void llPreloadSound(string sound) { m_LSL_Functions.llPreloadSound(sound); } - public string llGetSubString(string src, int start, int end) { return m_LSL_Functions.llGetSubString(src, start, end); } - public string llDeleteSubString(string src, int start, int end) { return m_LSL_Functions.llDeleteSubString(src, start, end); } - public string llInsertString(string dst, int position, string src) { return m_LSL_Functions.llInsertString(dst, position, src); } - public string llToUpper(string source) { return m_LSL_Functions.llToUpper(source); } - public string llToLower(string source) { return m_LSL_Functions.llToLower(source); } - public int llGiveMoney(string destination, int amount) { return m_LSL_Functions.llGiveMoney(destination, amount); } - public void llMakeExplosion() { m_LSL_Functions.llMakeExplosion(); } - public void llMakeFountain() { m_LSL_Functions.llMakeFountain(); } - public void llMakeSmoke() { m_LSL_Functions.llMakeSmoke(); } - public void llMakeFire() { m_LSL_Functions.llMakeFire(); } - public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { m_LSL_Functions.llRezObject(inventory, pos, rot, param); } - public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { m_LSL_Functions.llLookAt(target, strength, damping); } - public void llStopLookAt() { m_LSL_Functions.llStopLookAt(); } - public void llSetTimerEvent(double sec) { m_LSL_Functions.llSetTimerEvent(sec); } - public void llSleep(double sec) { m_LSL_Functions.llSleep(sec); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public double llGetMass() { return m_LSL_Functions.llGetMass(); } - public void llCollisionFilter(string name, string id, int accept) { m_LSL_Functions.llCollisionFilter(name, id, accept); } - public void llTakeControls(int controls, int accept, int pass_on) { m_LSL_Functions.llTakeControls(controls, accept, pass_on); } - public void llReleaseControls() { m_LSL_Functions.llReleaseControls(); } - public void llAttachToAvatar(int attachment) { m_LSL_Functions.llAttachToAvatar(attachment); } - public void llDetachFromAvatar() { m_LSL_Functions.llDetachFromAvatar(); } - public void llTakeCamera() { m_LSL_Functions.llTakeCamera(); } - public void llReleaseCamera() { m_LSL_Functions.llReleaseCamera(); } - public string llGetOwner() { return m_LSL_Functions.llGetOwner(); } - public void llInstantMessage(string user, string message) { m_LSL_Functions.llInstantMessage(user, message); } - public void llEmail(string address, string subject, string message) { m_LSL_Functions.llEmail(address, subject, message); } - public void llGetNextEmail(string address, string subject) { m_LSL_Functions.llGetNextEmail(address, subject); } - public string llGetKey() { return m_LSL_Functions.llGetKey(); } - public void llSetBuoyancy(double buoyancy) { m_LSL_Functions.llSetBuoyancy(buoyancy); } - public void llSetHoverHeight(double height, int water, double tau) { m_LSL_Functions.llSetHoverHeight(height, water, tau); } - public void llStopHover() { m_LSL_Functions.llStopHover(); } - public void llMinEventDelay(double delay) { m_LSL_Functions.llMinEventDelay(delay); } - public void llSoundPreload() { m_LSL_Functions.llSoundPreload(); } - public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) { m_LSL_Functions.llRotLookAt(target, strength, damping); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public int llStringLength(string str) { return m_LSL_Functions.llStringLength(str); } - public void llStartAnimation(string anim) { m_LSL_Functions.llStartAnimation(anim); } - public void llStopAnimation(string anim) { m_LSL_Functions.llStopAnimation(anim); } - public void llPointAt() { m_LSL_Functions.llPointAt(); } - public void llStopPointAt() { m_LSL_Functions.llStopPointAt(); } - public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) { m_LSL_Functions.llTargetOmega(axis, spinrate, gain); } - public int llGetStartParameter() { return m_LSL_Functions.llGetStartParameter(); } - public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) { m_LSL_Functions.llGodLikeRezObject(inventory, pos); } - public void llRequestPermissions(string agent, int perm) { m_LSL_Functions.llRequestPermissions(agent, perm); } - public string llGetPermissionsKey() { return m_LSL_Functions.llGetPermissionsKey(); } - public int llGetPermissions() { return m_LSL_Functions.llGetPermissions(); } - public int llGetLinkNumber() { return m_LSL_Functions.llGetLinkNumber(); } - public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) { m_LSL_Functions.llSetLinkColor(linknumber, color, face); } - public void llCreateLink(string target, int parent) { m_LSL_Functions.llCreateLink(target, parent); } - public void llBreakLink(int linknum) { m_LSL_Functions.llBreakLink(linknum); } - public void llBreakAllLinks() { m_LSL_Functions.llBreakAllLinks(); } - public string llGetLinkKey(int linknum) { return m_LSL_Functions.llGetLinkKey(linknum); } - public void llGetLinkName(int linknum) { m_LSL_Functions.llGetLinkName(linknum); } - public int llGetInventoryNumber(int type) { return m_LSL_Functions.llGetInventoryNumber(type); } - public string llGetInventoryName(int type, int number) { return m_LSL_Functions.llGetInventoryName(type, number); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llSetScriptState(string name, int run) { m_LSL_Functions.llSetScriptState(name, run); } - public double llGetEnergy() { return m_LSL_Functions.llGetEnergy(); } - public void llGiveInventory(string destination, string inventory) { m_LSL_Functions.llGiveInventory(destination, inventory); } - public void llRemoveInventory(string item) { m_LSL_Functions.llRemoveInventory(item); } - public void llSetText(string text, LSL_Types.Vector3 color, double alpha) { m_LSL_Functions.llSetText(text, color, alpha); } - public double llWater(LSL_Types.Vector3 offset) { return m_LSL_Functions.llWater(offset); } - public void llPassTouches(int pass) { m_LSL_Functions.llPassTouches(pass); } - public string llRequestAgentData(string id, int data) { return m_LSL_Functions.llRequestAgentData(id, data); } - public string llRequestInventoryData(string name) { return m_LSL_Functions.llRequestInventoryData(name); } - public void llSetDamage(double damage) { m_LSL_Functions.llSetDamage(damage); } - public void llTeleportAgentHome(string agent) { m_LSL_Functions.llTeleportAgentHome(agent); } - public void llModifyLand(int action, int brush) { m_LSL_Functions.llModifyLand(action, brush); } - public void llCollisionSound(string impact_sound, double impact_volume) { m_LSL_Functions.llCollisionSound(impact_sound, impact_volume); } - public void llCollisionSprite(string impact_sprite) { m_LSL_Functions.llCollisionSprite(impact_sprite); } - public string llGetAnimation(string id) { return m_LSL_Functions.llGetAnimation(id); } - public void llResetScript() { m_LSL_Functions.llResetScript(); } - public void llMessageLinked(int linknum, int num, string str, string id) { m_LSL_Functions.llMessageLinked(linknum, num, str, id); } - public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { m_LSL_Functions.llPushObject(target, impulse, ang_impulse, local); } - public void llPassCollisions(int pass) { m_LSL_Functions.llPassCollisions(pass); } - public string llGetScriptName() { return m_LSL_Functions.llGetScriptName(); } - public int llGetNumberOfSides() { return m_LSL_Functions.llGetNumberOfSides(); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { return m_LSL_Functions.llAxisAngle2Rot(axis, angle); } - public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) { return m_LSL_Functions.llRot2Axis(rot); } - public void llRot2Angle() { m_LSL_Functions.llRot2Angle(); } - public double llAcos(double val) { return m_LSL_Functions.llAcos(val); } - public double llAsin(double val) { return m_LSL_Functions.llAsin(val); } - public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) { return m_LSL_Functions.llAngleBetween(a, b); } - public string llGetInventoryKey(string name) { return m_LSL_Functions.llGetInventoryKey(name); } - public void llAllowInventoryDrop(int add) { m_LSL_Functions.llAllowInventoryDrop(add); } - public LSL_Types.Vector3 llGetSunDirection() { return m_LSL_Functions.llGetSunDirection(); } - public LSL_Types.Vector3 llGetTextureOffset(int face) { return m_LSL_Functions.llGetTextureOffset(face); } - public LSL_Types.Vector3 llGetTextureScale(int side) { return m_LSL_Functions.llGetTextureScale(side); } - public double llGetTextureRot(int side) { return m_LSL_Functions.llGetTextureRot(side); } - public int llSubStringIndex(string source, string pattern) { return m_LSL_Functions.llSubStringIndex(source, pattern); } - public string llGetOwnerKey(string id) { return m_LSL_Functions.llGetOwnerKey(id); } - public LSL_Types.Vector3 llGetCenterOfMass() { return m_LSL_Functions.llGetCenterOfMass(); } - public List llListSort(List src, int stride, int ascending) { return m_LSL_Functions.llListSort(src, stride, ascending); } - public int llGetListLength(List src) { return m_LSL_Functions.llGetListLength(src); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public int llList2Integer(List src, int index) { return m_LSL_Functions.llList2Integer(src, index); } - public double llList2double(List src, int index) { return m_LSL_Functions.llList2double(src, index); } - public string llList2String(List src, int index) { return m_LSL_Functions.llList2String(src, index); } - public string llList2Key(List src, int index) { return m_LSL_Functions.llList2Key(src, index); } - public LSL_Types.Vector3 llList2Vector(List src, int index) { return m_LSL_Functions.llList2Vector(src, index); } - public LSL_Types.Quaternion llList2Rot(List src, int index) { return m_LSL_Functions.llList2Rot(src, index); } - public List llList2List(List src, int start, int end) { return m_LSL_Functions.llList2List(src, start, end); } - public List llDeleteSubList(List src, int start, int end) { return m_LSL_Functions.llDeleteSubList(src, start, end); } - public int llGetListEntryType(List src, int index) { return m_LSL_Functions.llGetListEntryType(src, index); } - public string llList2CSV(List src) { return m_LSL_Functions.llList2CSV(src); } - public List llCSV2List(string src) { return m_LSL_Functions.llCSV2List(src); } - public List llListRandomize(List src, int stride) { return m_LSL_Functions.llListRandomize(src, stride); } - public List llList2ListStrided(List src, int start, int end, int stride) { return m_LSL_Functions.llList2ListStrided(src, start, end, stride); } - public LSL_Types.Vector3 llGetRegionCorner() { return m_LSL_Functions.llGetRegionCorner(); } - public List llListInsertList(List dest, List src, int start) { return m_LSL_Functions.llListInsertList(dest, src, start); } - public int llListFindList(List src, List test) { return m_LSL_Functions.llListFindList(src, test); } - public string llGetObjectName() { return m_LSL_Functions.llGetObjectName(); } - public void llSetObjectName(string name) { m_LSL_Functions.llSetObjectName(name); } - public string llGetDate() { return m_LSL_Functions.llGetDate(); } - public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) { return m_LSL_Functions.llEdgeOfWorld(pos, dir); } - public int llGetAgentInfo(string id) { return m_LSL_Functions.llGetAgentInfo(id); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llAdjustSoundVolume(double volume) { m_LSL_Functions.llAdjustSoundVolume(volume); } - public void llSetSoundQueueing(int queue) { m_LSL_Functions.llSetSoundQueueing(queue); } - public void llSetSoundRadius(double radius) { m_LSL_Functions.llSetSoundRadius(radius); } - public string llKey2Name(string id) { return m_LSL_Functions.llKey2Name(id); } - public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { m_LSL_Functions.llSetTextureAnim(mode, face, sizex, sizey, start, length, rate); } - public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west) { m_LSL_Functions.llTriggerSoundLimited(sound, volume, top_north_east, bottom_south_west); } - public void llEjectFromLand(string pest) { m_LSL_Functions.llEjectFromLand(pest); } - public void llParseString2List() { m_LSL_Functions.llParseString2List(); } - public int llOverMyLand(string id) { return m_LSL_Functions.llOverMyLand(id); } - public string llGetLandOwnerAt(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetLandOwnerAt(pos); } - public string llGetNotecardLine(string name, int line) { return m_LSL_Functions.llGetNotecardLine(name, line); } - public LSL_Types.Vector3 llGetAgentSize(string id) { return m_LSL_Functions.llGetAgentSize(id); } - public int llSameGroup(string agent) { return m_LSL_Functions.llSameGroup(agent); } - public void llUnSit(string id) { m_LSL_Functions.llUnSit(id); } - public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGroundSlope(offset); } - public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGroundNormal(offset); } - public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { return m_LSL_Functions.llGroundContour(offset); } - public int llGetAttached() { return m_LSL_Functions.llGetAttached(); } - public int llGetFreeMemory() { return m_LSL_Functions.llGetFreeMemory(); } - public string llGetRegionName() { return m_LSL_Functions.llGetRegionName(); } - public double llGetRegionTimeDilation() { return m_LSL_Functions.llGetRegionTimeDilation(); } - public double llGetRegionFPS() { return m_LSL_Functions.llGetRegionFPS(); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llParticleSystem(List rules) { m_LSL_Functions.llParticleSystem(rules); } - public void llGroundRepel(double height, int water, double tau) { m_LSL_Functions.llGroundRepel(height, water, tau); } - public void llGiveInventoryList() { m_LSL_Functions.llGiveInventoryList(); } - public void llSetVehicleType(int type) { m_LSL_Functions.llSetVehicleType(type); } - public void llSetVehicledoubleParam(int param, double value) { m_LSL_Functions.llSetVehicledoubleParam(param, value); } - public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) { m_LSL_Functions.llSetVehicleVectorParam(param, vec); } - public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) { m_LSL_Functions.llSetVehicleRotationParam(param, rot); } - public void llSetVehicleFlags(int flags) { m_LSL_Functions.llSetVehicleFlags(flags); } - public void llRemoveVehicleFlags(int flags) { m_LSL_Functions.llRemoveVehicleFlags(flags); } - public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) { m_LSL_Functions.llSitTarget(offset, rot); } - public string llAvatarOnSitTarget() { return m_LSL_Functions.llAvatarOnSitTarget(); } - public void llAddToLandPassList(string avatar, double hours) { m_LSL_Functions.llAddToLandPassList(avatar, hours); } - public void llSetTouchText(string text) { m_LSL_Functions.llSetTouchText(text); } - public void llSetSitText(string text) { m_LSL_Functions.llSetSitText(text); } - public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) { m_LSL_Functions.llSetCameraEyeOffset(offset); } - public void llSetCameraAtOffset(LSL_Types.Vector3 offset) { m_LSL_Functions.llSetCameraAtOffset(offset); } - public void llDumpList2String() { m_LSL_Functions.llDumpList2String(); } - public void llScriptDanger(LSL_Types.Vector3 pos) { m_LSL_Functions.llScriptDanger(pos); } - public void llDialog(string avatar, string message, List buttons, int chat_channel) { m_LSL_Functions.llDialog(avatar, message, buttons, chat_channel); } - public void llVolumeDetect(int detect) { m_LSL_Functions.llVolumeDetect(detect); } - public void llResetOtherScript(string name) { m_LSL_Functions.llResetOtherScript(name); } - public int llGetScriptState(string name) { return m_LSL_Functions.llGetScriptState(name); } - public void llRemoteLoadScript() { m_LSL_Functions.llRemoteLoadScript(); } - public void llSetRemoteScriptAccessPin(int pin) { m_LSL_Functions.llSetRemoteScriptAccessPin(pin); } - public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { m_LSL_Functions.llRemoteLoadScriptPin(target, name, pin, running, start_param); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public void llOpenRemoteDataChannel() { m_LSL_Functions.llOpenRemoteDataChannel(); } - public string llSendRemoteData(string channel, string dest, int idata, string sdata) { return m_LSL_Functions.llSendRemoteData(channel, dest, idata, sdata); } - public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) { m_LSL_Functions.llRemoteDataReply(channel, message_id, sdata, idata); } - public void llCloseRemoteDataChannel(string channel) { m_LSL_Functions.llCloseRemoteDataChannel(channel); } - public string llMD5String(string src, int nonce) { return m_LSL_Functions.llMD5String(src, nonce); } - public void llSetPrimitiveParams(List rules) { m_LSL_Functions.llSetPrimitiveParams(rules); } - public string llStringToBase64(string str) { return m_LSL_Functions.llStringToBase64(str); } - public string llBase64ToString(string str) { return m_LSL_Functions.llBase64ToString(str); } - public void llXorBase64Strings() { m_LSL_Functions.llXorBase64Strings(); } - public void llRemoteDataSetRegion() { m_LSL_Functions.llRemoteDataSetRegion(); } - public double llLog10(double val) { return m_LSL_Functions.llLog10(val); } - public double llLog(double val) { return m_LSL_Functions.llLog(val); } - public List llGetAnimationList(string id) { return m_LSL_Functions.llGetAnimationList(id); } - public void llSetParcelMusicURL(string url) { m_LSL_Functions.llSetParcelMusicURL(url); } - public LSL_Types.Vector3 llGetRootPosition() { return m_LSL_Functions.llGetRootPosition(); } - public LSL_Types.Quaternion llGetRootRotation() { return m_LSL_Functions.llGetRootRotation(); } - public string llGetObjectDesc() { return m_LSL_Functions.llGetObjectDesc(); } - public void llSetObjectDesc(string desc) { m_LSL_Functions.llSetObjectDesc(desc); } - public string llGetCreator() { return m_LSL_Functions.llGetCreator(); } - public string llGetTimestamp() { return m_LSL_Functions.llGetTimestamp(); } - public void llSetLinkAlpha(int linknumber, double alpha, int face) { m_LSL_Functions.llSetLinkAlpha(linknumber, alpha, face); } - public int llGetNumberOfPrims() { return m_LSL_Functions.llGetNumberOfPrims(); } - public string llGetNumberOfNotecardLines(string name) { return m_LSL_Functions.llGetNumberOfNotecardLines(name); } - public List llGetBoundingBox(string obj) { return m_LSL_Functions.llGetBoundingBox(obj); } - public LSL_Types.Vector3 llGetGeometricCenter() { return m_LSL_Functions.llGetGeometricCenter(); } - public void llGetPrimitiveParams() { m_LSL_Functions.llGetPrimitiveParams(); } - // - // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs - // - public string llIntegerToBase64(int number) { return m_LSL_Functions.llIntegerToBase64(number); } - public int llBase64ToInteger(string str) { return m_LSL_Functions.llBase64ToInteger(str); } - public double llGetGMTclock() { return m_LSL_Functions.llGetGMTclock(); } - public string llGetSimulatorHostname() { return m_LSL_Functions.llGetSimulatorHostname(); } - public void llSetLocalRot(LSL_Types.Quaternion rot) { m_LSL_Functions.llSetLocalRot(rot); } - public List llParseStringKeepNulls(string src, List seperators, List spacers) { return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers); } - public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param) { m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param); } - public int llGetObjectPermMask(int mask) { return m_LSL_Functions.llGetObjectPermMask(mask); } - public void llSetObjectPermMask(int mask, int value) { m_LSL_Functions.llSetObjectPermMask(mask, value); } - public void llGetInventoryPermMask(string item, int mask) { m_LSL_Functions.llGetInventoryPermMask(item, mask); } - public void llSetInventoryPermMask(string item, int mask, int value) { m_LSL_Functions.llSetInventoryPermMask(item, mask, value); } - public string llGetInventoryCreator(string item) { return m_LSL_Functions.llGetInventoryCreator(item); } - public void llOwnerSay(string msg) { m_LSL_Functions.llOwnerSay(msg); } - public void llRequestSimulatorData(string simulator, int data) { m_LSL_Functions.llRequestSimulatorData(simulator, data); } - public void llForceMouselook(int mouselook) { m_LSL_Functions.llForceMouselook(mouselook); } - public double llGetObjectMass(string id) { return m_LSL_Functions.llGetObjectMass(id); } - public void llListReplaceList() { m_LSL_Functions.llListReplaceList(); } - public void llLoadURL(string avatar_id, string message, string url) { m_LSL_Functions.llLoadURL(avatar_id, message, url); } - public void llParcelMediaCommandList(List commandList) { m_LSL_Functions.llParcelMediaCommandList(commandList); } - public void llParcelMediaQuery() { m_LSL_Functions.llParcelMediaQuery(); } - public int llModPow(int a, int b, int c) { return m_LSL_Functions.llModPow(a, b, c); } + public string llIntegerToBase64(int number) + { + return m_LSL_Functions.llIntegerToBase64(number); + } + + public int llBase64ToInteger(string str) + { + return m_LSL_Functions.llBase64ToInteger(str); + } + + public double llGetGMTclock() + { + return m_LSL_Functions.llGetGMTclock(); + } + + public string llGetSimulatorHostname() + { + return m_LSL_Functions.llGetSimulatorHostname(); + } + + public void llSetLocalRot(rotation rot) + { + m_LSL_Functions.llSetLocalRot(rot); + } + + public List llParseStringKeepNulls(string src, List seperators, List spacers) + { + return m_LSL_Functions.llParseStringKeepNulls(src, seperators, spacers); + } + + public void llRezAtRoot(string inventory, vector position, vector velocity, rotation rot, int param) + { + m_LSL_Functions.llRezAtRoot(inventory, position, velocity, rot, param); + } + + public int llGetObjectPermMask(int mask) + { + return m_LSL_Functions.llGetObjectPermMask(mask); + } + + public void llSetObjectPermMask(int mask, int value) + { + m_LSL_Functions.llSetObjectPermMask(mask, value); + } + + public void llGetInventoryPermMask(string item, int mask) + { + m_LSL_Functions.llGetInventoryPermMask(item, mask); + } + + public void llSetInventoryPermMask(string item, int mask, int value) + { + m_LSL_Functions.llSetInventoryPermMask(item, mask, value); + } + + public string llGetInventoryCreator(string item) + { + return m_LSL_Functions.llGetInventoryCreator(item); + } + + public void llOwnerSay(string msg) + { + m_LSL_Functions.llOwnerSay(msg); + } + + public void llRequestSimulatorData(string simulator, int data) + { + m_LSL_Functions.llRequestSimulatorData(simulator, data); + } + + public void llForceMouselook(int mouselook) + { + m_LSL_Functions.llForceMouselook(mouselook); + } + + public double llGetObjectMass(string id) + { + return m_LSL_Functions.llGetObjectMass(id); + } + + public void llListReplaceList() + { + m_LSL_Functions.llListReplaceList(); + } + + public void llLoadURL(string avatar_id, string message, string url) + { + m_LSL_Functions.llLoadURL(avatar_id, message, url); + } + + public void llParcelMediaCommandList(List commandList) + { + m_LSL_Functions.llParcelMediaCommandList(commandList); + } + + public void llParcelMediaQuery() + { + m_LSL_Functions.llParcelMediaQuery(); + } + + public int llModPow(int a, int b, int c) + { + return m_LSL_Functions.llModPow(a, b, c); + } + // // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs // - public int llGetInventoryType(string name) { return m_LSL_Functions.llGetInventoryType(name); } - public void llSetPayPrice(int price, List quick_pay_buttons) { m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons); } - public LSL_Types.Vector3 llGetCameraPos() { return m_LSL_Functions.llGetCameraPos(); } - public LSL_Types.Quaternion llGetCameraRot() { return m_LSL_Functions.llGetCameraRot(); } - public void llSetPrimURL() { m_LSL_Functions.llSetPrimURL(); } - public void llRefreshPrimURL() { m_LSL_Functions.llRefreshPrimURL(); } - public string llEscapeURL(string url) { return m_LSL_Functions.llEscapeURL(url); } - public string llUnescapeURL(string url) { return m_LSL_Functions.llUnescapeURL(url); } - public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) { m_LSL_Functions.llMapDestination(simname, pos, look_at); } - public void llAddToLandBanList(string avatar, double hours) { m_LSL_Functions.llAddToLandBanList(avatar, hours); } - public void llRemoveFromLandPassList(string avatar) { m_LSL_Functions.llRemoveFromLandPassList(avatar); } - public void llRemoveFromLandBanList(string avatar) { m_LSL_Functions.llRemoveFromLandBanList(avatar); } - public void llSetCameraParams(List rules) { m_LSL_Functions.llSetCameraParams(rules); } - public void llClearCameraParams() { m_LSL_Functions.llClearCameraParams(); } - public double llListStatistics(int operation, List src) { return m_LSL_Functions.llListStatistics(operation, src); } - public int llGetUnixTime() { return m_LSL_Functions.llGetUnixTime(); } - public int llGetParcelFlags(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelFlags(pos); } - public int llGetRegionFlags() { return m_LSL_Functions.llGetRegionFlags(); } - public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); } - public void llHTTPRequest(string url, List parameters, string body) { m_LSL_Functions.llHTTPRequest(url, parameters, body); } - public void llResetLandBanList() { m_LSL_Functions.llResetLandBanList(); } - public void llResetLandPassList() { m_LSL_Functions.llResetLandPassList(); } - public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); } - public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelPrimOwners(pos); } - public int llGetObjectPrimCount(string object_id) { return m_LSL_Functions.llGetObjectPrimCount(object_id); } + public int llGetInventoryType(string name) + { + return m_LSL_Functions.llGetInventoryType(name); + } + + public void llSetPayPrice(int price, List quick_pay_buttons) + { + m_LSL_Functions.llSetPayPrice(price, quick_pay_buttons); + } + + public vector llGetCameraPos() + { + return m_LSL_Functions.llGetCameraPos(); + } + + public rotation llGetCameraRot() + { + return m_LSL_Functions.llGetCameraRot(); + } + + public void llSetPrimURL() + { + m_LSL_Functions.llSetPrimURL(); + } + + public void llRefreshPrimURL() + { + m_LSL_Functions.llRefreshPrimURL(); + } + + public string llEscapeURL(string url) + { + return m_LSL_Functions.llEscapeURL(url); + } + + public string llUnescapeURL(string url) + { + return m_LSL_Functions.llUnescapeURL(url); + } + + public void llMapDestination(string simname, vector pos, vector look_at) + { + m_LSL_Functions.llMapDestination(simname, pos, look_at); + } + + public void llAddToLandBanList(string avatar, double hours) + { + m_LSL_Functions.llAddToLandBanList(avatar, hours); + } + + public void llRemoveFromLandPassList(string avatar) + { + m_LSL_Functions.llRemoveFromLandPassList(avatar); + } + + public void llRemoveFromLandBanList(string avatar) + { + m_LSL_Functions.llRemoveFromLandBanList(avatar); + } + + public void llSetCameraParams(List rules) + { + m_LSL_Functions.llSetCameraParams(rules); + } + + public void llClearCameraParams() + { + m_LSL_Functions.llClearCameraParams(); + } + + public double llListStatistics(int operation, List src) + { + return m_LSL_Functions.llListStatistics(operation, src); + } + + public int llGetUnixTime() + { + return m_LSL_Functions.llGetUnixTime(); + } + + public int llGetParcelFlags(vector pos) + { + return m_LSL_Functions.llGetParcelFlags(pos); + } + + public int llGetRegionFlags() + { + return m_LSL_Functions.llGetRegionFlags(); + } + + public string llXorBase64StringsCorrect(string str1, string str2) + { + return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); + } + + public void llHTTPRequest(string url, List parameters, string body) + { + m_LSL_Functions.llHTTPRequest(url, parameters, body); + } + + public void llResetLandBanList() + { + m_LSL_Functions.llResetLandBanList(); + } + + public void llResetLandPassList() + { + m_LSL_Functions.llResetLandPassList(); + } + + public int llGetParcelPrimCount(vector pos, int category, int sim_wide) + { + return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); + } + + public List llGetParcelPrimOwners(vector pos) + { + return m_LSL_Functions.llGetParcelPrimOwners(pos); + } + + public int llGetObjectPrimCount(string object_id) + { + return m_LSL_Functions.llGetObjectPrimCount(object_id); + } + // // DO NOT MODIFY HERE: MODIFY IN LSL_BuiltIn_Commands.cs // - public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) { return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); } - public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) { return m_LSL_Functions.llGetParcelDetails(pos, param); } + public int llGetParcelMaxPrims(vector pos, int sim_wide) + { + return m_LSL_Functions.llGetParcelMaxPrims(pos, sim_wide); + } + + public List llGetParcelDetails(vector pos, List param) + { + return m_LSL_Functions.llGetParcelDetails(pos, param); + } // // OpenSim Functions // - public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) { return m_LSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer); } + public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, + int timer) + { + return m_LSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer); + } // LSL CONSTANTS public const int TRUE = 1; @@ -803,10 +2115,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public const double SQRT2 = 1.414213538f; // Can not be public const? - public LSL_Types.Vector3 ZERO_VECTOR = new LSL_Types.Vector3(0, 0, 0); - public LSL_Types.Quaternion ZERO_ROTATION = new LSL_Types.Quaternion(0, 0, 0, 0); - - - + 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/LSO/Common.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs index 00eb899..190e6d7 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/Common.cs @@ -27,31 +27,32 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { public static class Common { - static public bool Debug = true; - static public bool IL_UseTryCatch = true; - static public bool IL_CreateConstructor = true; - static public bool IL_CreateFunctionList = true; - static public bool IL_ProcessCodeChunks = true; + public static bool Debug = true; + public static bool IL_UseTryCatch = true; + public static bool IL_CreateConstructor = true; + public static bool IL_CreateFunctionList = true; + public static bool IL_ProcessCodeChunks = true; public delegate void SendToDebugEventDelegate(string Message); + public delegate void SendToLogEventDelegate(string Message); - static public event SendToDebugEventDelegate SendToDebugEvent; - static public event SendToLogEventDelegate SendToLogEvent; - static public void SendToDebug(string Message) + public static event SendToDebugEventDelegate SendToDebugEvent; + public static event SendToLogEventDelegate SendToLogEvent; + + public static void SendToDebug(string Message) { //if (Debug == true) Console.WriteLine("COMPILER:Debug: " + Message); SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } - static public void SendToLog(string Message) + + public static void SendToLog(string Message) { //if (Debug == true) Console.WriteLine("COMPILER:LOG: " + Message); @@ -68,6 +69,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("ReverseFormatString format: " + format); return string.Format(format, text1); } + public static string ReverseFormatString(string text1, UInt32 text2, string format) { Common.SendToDebug("ReverseFormatString text1: " + text1); @@ -75,10 +77,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("ReverseFormatString format: " + format); return string.Format(format, text1, text2.ToString()); } + public static string Cast_ToString(object obj) { Common.SendToDebug("OBJECT TO BE CASTED: " + obj.GetType().ToString()); return "ABCDEFGIHJKLMNOPQ123"; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs index f060f06..97981cc 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/Engine.cs @@ -27,20 +27,19 @@ */ /* Original code: Tedd Hansen */ using System; +using System.IO; using System.Reflection; using System.Reflection.Emit; +using System.Text; using System.Threading; - namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { - - public class Engine { //private string LSO_FileName = @"LSO\AdditionTest.lso"; - private string LSO_FileName;// = @"LSO\CloseToDefault.lso"; - AppDomain appDomain; + private string LSO_FileName; // = @"LSO\CloseToDefault.lso"; + private AppDomain appDomain; public string Compile(string LSOFileName) { @@ -52,20 +51,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // Create Assembly Name AssemblyName asmName = new AssemblyName(); - asmName.Name = System.IO.Path.GetFileNameWithoutExtension(LSO_FileName); + asmName.Name = Path.GetFileNameWithoutExtension(LSO_FileName); //asmName.Name = "TestAssembly"; string DLL_FileName = asmName.Name + ".dll"; - string DLL_FileName_WithPath = System.IO.Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; + string DLL_FileName_WithPath = Path.GetDirectoryName(LSO_FileName) + @"\" + DLL_FileName; - Common.SendToLog("LSO File Name: " + System.IO.Path.GetFileName(LSO_FileName)); + Common.SendToLog("LSO File Name: " + Path.GetFileName(LSO_FileName)); Common.SendToLog("Assembly name: " + asmName.Name); Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll"); Common.SendToLog("Starting processing of LSL ByteCode..."); Common.SendToLog(""); - // Create Assembly AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly( asmName, @@ -78,15 +76,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // Create a module (and save to disk) ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule - (asmName.Name, - DLL_FileName); + (asmName.Name, + DLL_FileName); //Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\""); // Create a Class (/Type) TypeBuilder typeBuilder = modBuilder.DefineType( - "LSL_ScriptObject", - TypeAttributes.Public | TypeAttributes.BeforeFieldInit, - typeof(OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass)); + "LSL_ScriptObject", + TypeAttributes.Public | TypeAttributes.BeforeFieldInit, + typeof (LSL_BaseClass)); //, // typeof()); //, typeof(LSL_BuiltIn_Commands_Interface)); @@ -95,7 +93,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // new Type[] { typeof(LSL_CLRInterface.LSLScript) }); - /* * Generate the IL itself */ @@ -123,7 +120,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO asmBuilder.Save(DLL_FileName); Common.SendToLog("Returning assembly filename: " + DLL_FileName); - + return DLL_FileName; @@ -135,9 +132,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //object MyScript = (object)Activator.CreateInstance(type); - - - //System.Reflection.MemberInfo[] Members = type.GetMembers(); //Common.SendToLog("Members of assembly " + type.ToString() + ":"); @@ -165,29 +159,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" }); //} - - } private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder, LSO_Parser LSOP) { - - Common.SendToDebug("IL_CREATE_CONSTRUCTOR()"); //ConstructorBuilder constructor = typeBuilder.DefineConstructor( // MethodAttributes.Public, // CallingConventions.Standard, // new Type[0]); ConstructorBuilder constructor = typeBuilder.DefineConstructor( - MethodAttributes.Public | - MethodAttributes.SpecialName | - MethodAttributes.RTSpecialName, - CallingConventions.Standard, - new Type[0]); + MethodAttributes.Public | + MethodAttributes.SpecialName | + MethodAttributes.RTSpecialName, + CallingConventions.Standard, + new Type[0]); //Define the reflection ConstructorInfor for System.Object - ConstructorInfo conObj = typeof(LSL_BaseClass).GetConstructor(new Type[0]); + ConstructorInfo conObj = typeof (LSL_BaseClass).GetConstructor(new Type[0]); //call constructor of base object ILGenerator il = constructor.GetILGenerator(); @@ -230,58 +220,61 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO LSO_Struct.StaticBlock sb; LSOP.StaticBlocks.TryGetValue(pos, out sb); - if (sb.ObjectType > 0 && sb.ObjectType < 8) { // We don't want void or null's - - il.Emit(OpCodes.Ldarg_0); - // Push position to stack - il.Emit(OpCodes.Ldc_I4, pos); - //il.Emit(OpCodes.Box, typeof(UInt32)); - - - Type datatype = null; - - // Push data to stack - Common.SendToDebug("Adding to static (" + pos + ") type: " + ((LSO_Enums.Variable_Type_Codes)sb.ObjectType).ToString() + " (" + sb.ObjectType + ")"); - switch ((LSO_Enums.Variable_Type_Codes)sb.ObjectType) + if (sb.ObjectType > 0 && sb.ObjectType < 8) { - case LSO_Enums.Variable_Type_Codes.Float: - case LSO_Enums.Variable_Type_Codes.Integer: - //UInt32 - il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); - datatype = typeof(UInt32); - il.Emit(OpCodes.Box, datatype); - break; - case LSO_Enums.Variable_Type_Codes.String: - case LSO_Enums.Variable_Type_Codes.Key: - //String - LSO_Struct.HeapBlock hb = LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); - il.Emit(OpCodes.Ldstr, System.Text.Encoding.UTF8.GetString(hb.Data)); - datatype = typeof(string); - break; - case LSO_Enums.Variable_Type_Codes.Vector: - datatype = typeof(LSO_Enums.Vector); - //TODO: Not implemented - break; - case LSO_Enums.Variable_Type_Codes.Rotation: - //Object - //TODO: Not implemented - datatype = typeof(LSO_Enums.Rotation); - break; - default: - datatype = typeof(object); - break; - } - - - // Make call - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddToStatic", new Type[] { typeof(UInt32), datatype })); + // We don't want void or null's + + il.Emit(OpCodes.Ldarg_0); + // Push position to stack + il.Emit(OpCodes.Ldc_I4, pos); + //il.Emit(OpCodes.Box, typeof(UInt32)); + + + Type datatype = null; + + // Push data to stack + Common.SendToDebug("Adding to static (" + pos + ") type: " + + ((LSO_Enums.Variable_Type_Codes) sb.ObjectType).ToString() + " (" + sb.ObjectType + + ")"); + switch ((LSO_Enums.Variable_Type_Codes) sb.ObjectType) + { + case LSO_Enums.Variable_Type_Codes.Float: + case LSO_Enums.Variable_Type_Codes.Integer: + //UInt32 + il.Emit(OpCodes.Ldc_I4, BitConverter.ToUInt32(sb.BlockVariable, 0)); + datatype = typeof (UInt32); + il.Emit(OpCodes.Box, datatype); + break; + case LSO_Enums.Variable_Type_Codes.String: + case LSO_Enums.Variable_Type_Codes.Key: + //String + LSO_Struct.HeapBlock hb = + LSOP.GetHeap(LSOP.myHeader.HR + BitConverter.ToUInt32(sb.BlockVariable, 0) - 1); + il.Emit(OpCodes.Ldstr, Encoding.UTF8.GetString(hb.Data)); + datatype = typeof (string); + break; + case LSO_Enums.Variable_Type_Codes.Vector: + datatype = typeof (LSO_Enums.Vector); + //TODO: Not implemented + break; + case LSO_Enums.Variable_Type_Codes.Rotation: + //Object + //TODO: Not implemented + datatype = typeof (LSO_Enums.Rotation); + break; + default: + datatype = typeof (object); + break; + } + + + // Make call + il.Emit(OpCodes.Call, + typeof (LSL_BaseClass).GetMethod("AddToStatic", new Type[] {typeof (UInt32), datatype})); } - } - - ////il.Emit(OpCodes.Newobj, typeof(UInt32)); //il.Emit(OpCodes.Starg_0); //// Create LSL function library @@ -293,8 +286,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO } - - // End of class } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs index 65be5e3..2dc8055 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/IL_common_functions.cs @@ -27,30 +27,25 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; using System.Reflection; using System.Reflection.Emit; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { - partial class LSO_Parser + internal partial class LSO_Parser { private static TypeBuilder CreateType(ModuleBuilder modBuilder, string typeName) { TypeBuilder typeBuilder = modBuilder.DefineType(typeName, - TypeAttributes.Public | - TypeAttributes.Class | - TypeAttributes.AutoClass | - TypeAttributes.AnsiClass | - TypeAttributes.BeforeFieldInit | - TypeAttributes.AutoLayout, - typeof(object), - new Type[] { typeof(object) }); + TypeAttributes.Public | + TypeAttributes.Class | + TypeAttributes.AutoClass | + TypeAttributes.AnsiClass | + TypeAttributes.BeforeFieldInit | + TypeAttributes.AutoLayout, + typeof (object), + new Type[] {typeof (object)}); return typeBuilder; - } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs index 2fb8e45..b84400c 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass.cs @@ -28,9 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; -using System.IO; -using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; using OpenSim.Region.ScriptEngine.Common; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO @@ -39,9 +36,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { //public MemoryStream LSLStack = new MemoryStream(); public Stack LSLStack = new Stack(); - public Dictionary StaticVariables = new Dictionary(); - public Dictionary GlobalVariables = new Dictionary(); - public Dictionary LocalVariables = new Dictionary(); + public Dictionary StaticVariables = new Dictionary(); + public Dictionary GlobalVariables = new Dictionary(); + public Dictionary LocalVariables = new Dictionary(); //public System.Collections.Generic.List FunctionList = new System.Collections.Generic.List(); //public void AddFunction(String x) { // FunctionList.Add(x); @@ -54,19 +51,23 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //} public UInt32 State = 0; public LSL_BuiltIn_Commands_Interface LSL_Builtins; + public LSL_BuiltIn_Commands_Interface GetLSL_BuiltIn() { return LSL_Builtins; } - public LSL_BaseClass() { } + public LSL_BaseClass() + { + } public virtual int OverrideMe() { return 0; } + public void Start(LSL_BuiltIn_Commands_Interface LSLBuiltins) { LSL_Builtins = LSLBuiltins; @@ -81,8 +82,5 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("AddToStatic: " + index + " type: " + obj.GetType()); StaticVariables.Add(index, obj); } - - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs index a75b4c8..c805a01 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { @@ -53,6 +51,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO LocalVariables.Remove(index); LocalVariables.Add(index, LSLStack.Peek()); } + public void StoreToGlobal(UInt32 index) { Common.SendToDebug("::StoreToGlobal " + index); @@ -60,6 +59,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO GlobalVariables.Remove(index); GlobalVariables.Add(index, LSLStack.Peek()); } + public void StoreToStatic(UInt32 index) { Common.SendToDebug("::StoreToStatic " + index); @@ -67,6 +67,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // StaticVariables.Remove(index); StaticVariables.Add(index, LSLStack.Peek()); } + public void GetFromLocal(UInt32 index) { // TODO: How to determine local? @@ -76,6 +77,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO LSLStack.Push(ret); //return ret; } + public void GetFromGlobal(UInt32 index) { Common.SendToDebug("::GetFromGlobal " + index); @@ -84,6 +86,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO LSLStack.Push(ret); //return ret; } + public void GetFromStatic(UInt32 index) { Common.SendToDebug("::GetFromStatic " + index); @@ -99,22 +102,22 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("::POPToStack"); //return LSLStack.Pop(); object p = LSLStack.Pop(); - if (p.GetType() == typeof(UInt32)) - return (UInt32)p; - if (p.GetType() == typeof(string)) - return (string)p; - if (p.GetType() == typeof(Int32)) - return (Int32)p; - if (p.GetType() == typeof(UInt16)) - return (UInt16)p; - if (p.GetType() == typeof(float)) - return (float)p; - if (p.GetType() == typeof(LSO_Enums.Vector)) - return (LSO_Enums.Vector)p; - if (p.GetType() == typeof(LSO_Enums.Rotation)) - return (LSO_Enums.Rotation)p; - if (p.GetType() == typeof(LSO_Enums.Key)) - return (LSO_Enums.Key)p; + if (p.GetType() == typeof (UInt32)) + return (UInt32) p; + if (p.GetType() == typeof (string)) + return (string) p; + if (p.GetType() == typeof (Int32)) + return (Int32) p; + if (p.GetType() == typeof (UInt16)) + return (UInt16) p; + if (p.GetType() == typeof (float)) + return (float) p; + if (p.GetType() == typeof (LSO_Enums.Vector)) + return (LSO_Enums.Vector) p; + if (p.GetType() == typeof (LSO_Enums.Rotation)) + return (LSO_Enums.Rotation) p; + if (p.GetType() == typeof (LSO_Enums.Key)) + return (LSO_Enums.Key) p; return p; } @@ -151,6 +154,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO LSLStack.Pop(); } } + public void PUSH(object Param) { if (Param == null) @@ -159,205 +163,218 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO } else { - //Common.SendToDebug("::PUSH: " + Param.GetType()); } LSLStack.Push(Param); } + public void ADD(UInt32 Param) { Common.SendToDebug("::ADD: " + Param); object o2 = LSLStack.Pop(); object o1 = LSLStack.Pop(); - Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + " (" + o2.ToString() + ")"); - if (o2.GetType() == typeof(string)) + Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + + " (" + o2.ToString() + ")"); + if (o2.GetType() == typeof (string)) { - LSLStack.Push((string)o1 + (string)o2); + LSLStack.Push((string) o1 + (string) o2); return; } - if (o2.GetType() == typeof(UInt32)) + if (o2.GetType() == typeof (UInt32)) { - LSLStack.Push((UInt32)o1 + (UInt32)o2); + LSLStack.Push((UInt32) o1 + (UInt32) o2); return; } - } + public void SUB(UInt32 Param) { Common.SendToDebug("::SUB: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 - i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 - i2)); } + public void MUL(UInt32 Param) { Common.SendToDebug("::SUB: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 * i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1*i2)); } + public void DIV(UInt32 Param) { Common.SendToDebug("::DIV: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 / i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1/i2)); } public void MOD(UInt32 Param) { Common.SendToDebug("::MOD: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 % i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1%i2)); } + public void EQ(UInt32 Param) { Common.SendToDebug("::EQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 == i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void NEQ(UInt32 Param) { Common.SendToDebug("::NEQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 != i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void LEQ(UInt32 Param) { Common.SendToDebug("::LEQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 <= i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void GEQ(UInt32 Param) { Common.SendToDebug("::GEQ: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 >= i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void LESS(UInt32 Param) { Common.SendToDebug("::LESS: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 < i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void GREATER(UInt32 Param) { Common.SendToDebug("::GREATER: " + Param); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); if (i1 > i2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } - public void BITAND() { Common.SendToDebug("::BITAND"); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 & i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 & i2)); } + public void BITOR() { Common.SendToDebug("::BITOR"); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 | i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 | i2)); } + public void BITXOR() { Common.SendToDebug("::BITXOR"); - UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 ^ i2)); + UInt32 i2 = (UInt32) LSLStack.Pop(); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1 ^ i2)); } + public void BOOLAND() { Common.SendToDebug("::BOOLAND"); - bool b2 = bool.Parse((string)LSLStack.Pop()); - bool b1 = bool.Parse((string)LSLStack.Pop()); + bool b2 = bool.Parse((string) LSLStack.Pop()); + bool b1 = bool.Parse((string) LSLStack.Pop()); if (b1 && b2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } } + public void BOOLOR() { Common.SendToDebug("::BOOLOR"); - bool b2 = bool.Parse((string)LSLStack.Pop()); - bool b1 = bool.Parse((string)LSLStack.Pop()); + bool b2 = bool.Parse((string) LSLStack.Pop()); + bool b1 = bool.Parse((string) LSLStack.Pop()); if (b1 || b2) { - LSLStack.Push((UInt32)1); + LSLStack.Push((UInt32) 1); } else { - LSLStack.Push((UInt32)0); + LSLStack.Push((UInt32) 0); } - } + public void NEG(UInt32 Param) { Common.SendToDebug("::NEG: " + Param); //UInt32 i2 = (UInt32)LSLStack.Pop(); - UInt32 i1 = (UInt32)LSLStack.Pop(); - LSLStack.Push((UInt32)(i1 * -1)); + UInt32 i1 = (UInt32) LSLStack.Pop(); + LSLStack.Push((UInt32) (i1*-1)); } + public void BITNOT() { //Common.SendToDebug("::BITNOT"); @@ -365,6 +382,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //UInt32 i1 = (UInt32)LSLStack.Pop(); //LSLStack.Push((UInt32)(i1 / i2)); } + public void BOOLNOT() { //Common.SendToDebug("::BOOLNOT"); @@ -372,7 +390,5 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //UInt32 i1 = (UInt32)LSLStack.Pop(); //LSLStack.Push((UInt32)(i1)); } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs index 5f01bf5..8b233ba 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_CLRInterface.cs @@ -26,10 +26,6 @@ * */ /* Original code: Tedd Hansen */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { public class LSL_CLRInterface @@ -76,4 +72,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //void event_http_response(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs index ee166a6..e1d7768 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_OPCODE_IL_processor.cs @@ -27,32 +27,28 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; using System.Reflection; using System.Reflection.Emit; using OpenSim.Region.ScriptEngine.Common; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { - partial class LSO_Parser + internal partial class LSO_Parser { //internal Stack ILStack = new Stack(); //LSO_Enums MyLSO_Enums = new LSO_Enums(); internal bool LSL_PROCESS_OPCODE(ILGenerator il) { - byte bp1; UInt32 u32p1; float fp1; UInt16 opcode = br_read(1)[0]; - Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString()); - string idesc = ((LSO_Enums.Operation_Table)opcode).ToString(); - switch ((LSO_Enums.Operation_Table)opcode) + Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table) opcode).ToString()); + string idesc = ((LSO_Enums.Operation_Table) opcode).ToString(); + switch ((LSO_Enums.Operation_Table) opcode) { - - /*************** + /*************** * IMPLEMENTED * ***************/ case LSO_Enums.Operation_Table.NOOP: @@ -60,33 +56,34 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO case LSO_Enums.Operation_Table.PUSHSP: // Push Stack Top (Memory Address) to stack Common.SendToDebug("Instruction " + idesc); - Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack"); - IL_Push(il, (UInt32)myHeader.SP); + Common.SendToDebug("Instruction " + idesc + + ": Description: Pushing Stack Top (Memory Address from header) to stack"); + IL_Push(il, (UInt32) myHeader.SP); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.PUSHARGB: Common.SendToDebug("Param1: " + br_read(1)[0]); break; - // INTEGER + // INTEGER case LSO_Enums.Operation_Table.PUSHARGI: u32p1 = BitConverter.ToUInt32(br_read(4), 0); Common.SendToDebug("Instruction " + idesc + ", Param1: " + u32p1); IL_Push(il, u32p1); break; - // FLOAT + // FLOAT case LSO_Enums.Operation_Table.PUSHARGF: fp1 = BitConverter.ToUInt32(br_read(4), 0); Common.SendToDebug("Instruction " + idesc + ", Param1: " + fp1); IL_Push(il, fp1); break; - // STRING + // STRING case LSO_Enums.Operation_Table.PUSHARGS: string s = Read_String(); Common.SendToDebug("Instruction " + idesc + ", Param1: " + s); IL_Debug(il, "OPCODE: " + idesc + ":" + s); IL_Push(il, s); break; - // VECTOR z,y,x + // VECTOR z,y,x case LSO_Enums.Operation_Table.PUSHARGV: LSO_Enums.Vector v = new LSO_Enums.Vector(); v.Z = BitConverter.ToUInt32(br_read(4), 0); @@ -97,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Param1 X: " + v.X); IL_Push(il, v); break; - // ROTATION s,z,y,x + // ROTATION s,z,y,x case LSO_Enums.Operation_Table.PUSHARGQ: LSO_Enums.Rotation r = new LSO_Enums.Rotation(); r.S = BitConverter.ToUInt32(br_read(4), 0); @@ -112,7 +109,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO break; case LSO_Enums.Operation_Table.PUSHE: - IL_Push(il, (UInt32)0); + IL_Push(il, (UInt32) 0); break; case LSO_Enums.Operation_Table.PUSHARGE: @@ -121,7 +118,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //IL_Push(il, new string(" ".ToCharArray()[0], Convert.ToInt32(u32p1))); IL_Push(il, u32p1); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.ADD: case LSO_Enums.Operation_Table.SUB: case LSO_Enums.Operation_Table.MUL: @@ -136,10 +133,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO case LSO_Enums.Operation_Table.MOD: bp1 = br_read(1)[0]; Common.SendToDebug("Param1: " + bp1); - IL_CallBaseFunction(il, idesc, (UInt32)bp1); + IL_CallBaseFunction(il, idesc, (UInt32) bp1); break; - // NO ARGUMENTS + // NO ARGUMENTS case LSO_Enums.Operation_Table.BITAND: case LSO_Enums.Operation_Table.BITOR: case LSO_Enums.Operation_Table.BITXOR: @@ -149,22 +146,23 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO case LSO_Enums.Operation_Table.BOOLNOT: IL_CallBaseFunction(il, idesc); break; - // SHORT + // SHORT case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE: // TODO: What is size of short? UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0); - Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()); + Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + + ((LSO_Enums.BuiltIn_Functions) U16p1).ToString()); //Common.SendToDebug("Param1: " + U16p1); - string fname = ((LSO_Enums.BuiltIn_Functions)U16p1).ToString(); + string fname = ((LSO_Enums.BuiltIn_Functions) U16p1).ToString(); bool cmdFound = false; - foreach (MethodInfo mi in typeof(LSL_BuiltIn_Commands_Interface).GetMethods()) + foreach (MethodInfo mi in typeof (LSL_BuiltIn_Commands_Interface).GetMethods()) { // Found command if (mi.Name == fname) { il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] { })); + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("GetLSL_BuiltIn", new Type[] {})); // Pop required number of items from my stack to .Net stack IL_PopToStack(il, mi.GetParameters().Length); il.Emit(OpCodes.Callvirt, mi); @@ -179,7 +177,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO break; - // RETURN + // RETURN case LSO_Enums.Operation_Table.RETURN: Common.SendToDebug("OPCODE: RETURN"); @@ -195,7 +193,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO IL_Pop(il); break; - // LONG + // LONG case LSO_Enums.Operation_Table.STORE: case LSO_Enums.Operation_Table.STORES: case LSO_Enums.Operation_Table.STOREL: @@ -238,7 +236,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO IL_Pop(il); break; - // PUSH FROM LOCAL FRAME + // PUSH FROM LOCAL FRAME case LSO_Enums.Operation_Table.PUSH: case LSO_Enums.Operation_Table.PUSHS: case LSO_Enums.Operation_Table.PUSHL: @@ -250,7 +248,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO break; - // PUSH FROM STATIC FRAME + // PUSH FROM STATIC FRAME case LSO_Enums.Operation_Table.PUSHG: case LSO_Enums.Operation_Table.PUSHGS: case LSO_Enums.Operation_Table.PUSHGL: @@ -262,26 +260,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO break; - /*********************** + /*********************** * NOT IMPLEMENTED YET * ***********************/ - case LSO_Enums.Operation_Table.POPIP: case LSO_Enums.Operation_Table.POPSP: case LSO_Enums.Operation_Table.POPSLR: case LSO_Enums.Operation_Table.POPARG: case LSO_Enums.Operation_Table.POPBP: //Common.SendToDebug("Instruction " + idesc + ": Ignored"); - Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); + Common.SendToDebug("Instruction " + idesc + + ": Description: Drop x bytes from the stack (TODO: Only popping 1)"); //Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); IL_Pop(il); break; - - // None + // None case LSO_Enums.Operation_Table.PUSHIP: // PUSH INSTRUCTION POINTER break; @@ -293,17 +290,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO break; - // LONG + // LONG case LSO_Enums.Operation_Table.JUMP: Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); break; - // BYTE, LONG + // BYTE, LONG case LSO_Enums.Operation_Table.JUMPIF: case LSO_Enums.Operation_Table.JUMPNIF: Common.SendToDebug("Param1: " + br_read(1)[0]); Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0)); break; - // LONG + // LONG case LSO_Enums.Operation_Table.STATE: bp1 = br_read(1)[0]; //il.Emit(OpCodes.Ld); // Load local variable 0 onto stack @@ -315,12 +312,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); Common.SendToDebug("ERROR: Function CALL not implemented yet."); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.CAST: bp1 = br_read(1)[0]; - Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)); + Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + + ((LSO_Enums.OpCode_Cast_TypeDefs) bp1)); Common.SendToDebug("Param1: " + bp1); - switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1) + switch ((LSO_Enums.OpCode_Cast_TypeDefs) bp1) { case LSO_Enums.OpCode_Cast_TypeDefs.String: Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Box, ILStack.Pop());"); @@ -330,12 +328,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO break; } break; - // LONG + // LONG case LSO_Enums.Operation_Table.STACKTOS: case LSO_Enums.Operation_Table.STACKTOL: Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0)); break; - // BYTE + // BYTE case LSO_Enums.Operation_Table.PRINT: case LSO_Enums.Operation_Table.CALLLIB: Common.SendToDebug("Param1: " + br_read(1)[0]); @@ -348,6 +346,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { IL_PopToStack(il, 1); } + private void IL_PopToStack(ILGenerator il, int count) { Common.SendToDebug("IL_PopToStack();"); @@ -360,31 +359,35 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // new Type[] { })); } } + private void IL_Pop(ILGenerator il) { Common.SendToDebug("IL_Pop();"); IL_CallBaseFunction(il, "POP"); } + private void IL_Debug(ILGenerator il, string text) { il.Emit(OpCodes.Ldstr, text); - il.Emit(OpCodes.Call, typeof(Common).GetMethod("SendToDebug", - new Type[] { typeof(string) } - )); + il.Emit(OpCodes.Call, typeof (Common).GetMethod("SendToDebug", + new Type[] {typeof (string)} + )); } + private void IL_CallBaseFunction(ILGenerator il, string methodname) { il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { })); + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {})); } + private void IL_CallBaseFunction(ILGenerator il, string methodname, object data) { il.Emit(OpCodes.Ldarg_0); - if (data.GetType() == typeof(string)) - il.Emit(OpCodes.Ldstr, (string)data); - if (data.GetType() == typeof(UInt32)) - il.Emit(OpCodes.Ldc_I4, (UInt32)data); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod(methodname, new Type[] { data.GetType() })); + if (data.GetType() == typeof (string)) + il.Emit(OpCodes.Ldstr, (string) data); + if (data.GetType() == typeof (UInt32)) + il.Emit(OpCodes.Ldc_I4, (UInt32) data); + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod(methodname, new Type[] {data.GetType()})); } private void IL_Push(ILGenerator il, object data) @@ -394,43 +397,39 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO IL_PushDataTypeToILStack(il, data); - il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("PUSH", new Type[] { data.GetType() })); - + il.Emit(OpCodes.Call, typeof (LSL_BaseClass).GetMethod("PUSH", new Type[] {data.GetType()})); } private void IL_PushDataTypeToILStack(ILGenerator il, object data) { - if (data.GetType() == typeof(UInt16)) + if (data.GetType() == typeof (UInt16)) { - il.Emit(OpCodes.Ldc_I4, (UInt16)data); + il.Emit(OpCodes.Ldc_I4, (UInt16) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(UInt32)) + if (data.GetType() == typeof (UInt32)) { - il.Emit(OpCodes.Ldc_I4, (UInt32)data); + il.Emit(OpCodes.Ldc_I4, (UInt32) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(Int32)) + if (data.GetType() == typeof (Int32)) { - il.Emit(OpCodes.Ldc_I4, (Int32)data); + il.Emit(OpCodes.Ldc_I4, (Int32) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(float)) + if (data.GetType() == typeof (float)) { - il.Emit(OpCodes.Ldc_I4, (float)data); + il.Emit(OpCodes.Ldc_I4, (float) data); il.Emit(OpCodes.Box, data.GetType()); } - if (data.GetType() == typeof(string)) - il.Emit(OpCodes.Ldstr, (string)data); + if (data.GetType() == typeof (string)) + il.Emit(OpCodes.Ldstr, (string) data); //if (data.GetType() == typeof(LSO_Enums.Rotation)) // il.Emit(OpCodes.Ldobj, (LSO_Enums.Rotation)data); //if (data.GetType() == typeof(LSO_Enums.Vector)) // il.Emit(OpCodes.Ldobj, (LSO_Enums.Vector)data); //if (data.GetType() == typeof(LSO_Enums.Key)) // il.Emit(OpCodes.Ldobj, (LSO_Enums.Key)data); - } - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs index 30ce314..a7e3018 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Enums.cs @@ -27,8 +27,6 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { @@ -47,6 +45,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO String = 51, UInt32 = 17 } + [Serializable] public enum OpCode_Cast_TypeDefs { @@ -66,6 +65,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO public UInt32 Y; public UInt32 X; } + [Serializable] public struct Rotation { @@ -74,6 +74,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO public UInt32 Y; public UInt32 X; } + [Serializable] public enum Variable_Type_Codes { @@ -87,6 +88,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO List = 7, Null = 8 } + [Serializable] public enum Event_Mask_Values { @@ -124,6 +126,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO remote_data = 31, http_response = 32 } + [Serializable] public enum Operation_Table { @@ -220,6 +223,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO SHL = 0xe0, SHR = 0xe1 } + [Serializable] public enum BuiltIn_Functions { @@ -552,6 +556,5 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO llGetParcelMaxPrims = 326, llGetParcelDetails = 327 } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs index ba97375..a0b4977f 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Parser.cs @@ -27,15 +27,16 @@ */ /* Original code: Tedd Hansen */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.IO; using System.Reflection; using System.Reflection.Emit; +using System.Text; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { - partial class LSO_Parser + internal partial class LSO_Parser { private string FileName; private FileStream fs; @@ -45,7 +46,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //private System.Collections.Hashtable StaticBlocks = new System.Collections.Hashtable(); private TypeBuilder typeBuilder; - private System.Collections.Generic.List EventList = new System.Collections.Generic.List(); + private List EventList = new List(); public LSO_Parser(string _FileName, TypeBuilder _typeBuilder) { @@ -59,11 +60,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Opening filename: " + FileName); fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read); br = new BinaryReader(fs, Encoding.BigEndianUnicode); - } + internal void CloseFile() { - // Close br.Close(); fs.Close(); @@ -75,9 +75,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO /// public void Parse() { - - - // The LSO Format consist of 6 major blocks: header, statics, functions, states, heap, and stack. @@ -148,14 +145,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); myStaticBlock.ObjectType = br_read(1)[0]; - Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); + Common.SendToDebug("Static Block ObjectType: " + + ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); myStaticBlock.Unknown = br_read(1)[0]; // Size of datatype varies -- what about strings? if (myStaticBlock.ObjectType != 0) myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType)); - StaticBlocks.Add((UInt32)startReadPos, myStaticBlock); - + StaticBlocks.Add((UInt32) startReadPos, myStaticBlock); } Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount); @@ -183,7 +180,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // TODO: ADD TO FUNCTION LIST (How do we identify it later?) // Note! Absolute position myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR; - Common.SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]); + Common.SendToDebug("Fuction " + i + " code chunk position: " + + myFunctionBlock.CodeChunkPointer[i]); } } } @@ -204,14 +202,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Reading STATE POINTER BLOCK " + (i + 1) + " at: " + fs.Position); // Position is relative to state frame myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0); - myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8)); + myStateFrameBlock.StatePointer[i].EventMask = new BitArray(br_read(8)); Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location); - Common.SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count); + Common.SendToDebug("Total potential EventMask bits: " + + myStateFrameBlock.StatePointer[i].EventMask.Count); //// Read STATE BLOCK //long CurPos = fs.Position; //fs.Seek(CurPos, SeekOrigin.Begin); - } } @@ -224,19 +222,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // Go through all State Frame Pointers found for (int i = 0; i < myStateFrameBlock.StateCount; i++) { - fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin); Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position); // READ: STATE BLOCK HEADER myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock(); - myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32)fs.Position; // Note + myStateFrameBlock.StatePointer[i].StateBlock.StartPos = (UInt32) fs.Position; // Note myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0); myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0]; - myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note + myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32) fs.Position; // Note Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos); - Common.SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); - Common.SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); + Common.SendToDebug("State block Header Size: " + + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize); + Common.SendToDebug("State block Header End Pos: " + + myStateFrameBlock.StatePointer[i].StateBlock.EndPos); // We need to count number of bits flagged in EventMask? @@ -245,27 +244,36 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // ADDING TO ALL RIGHT NOW, SHOULD LIMIT TO ONLY THE ONES IN USE //TODO: Create event hooks - myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers = + new LSO_Struct.StateBlockHandler[myStateFrameBlock.StatePointer[i].EventMask.Count - 1]; for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) { - if (myStateFrameBlock.StatePointer[i].EventMask.Get(ii) == true) { // We got an event // READ: STATE BLOCK HANDLER - Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position); - myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0); - myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0); - Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer); - Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize); + Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + + " (" + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") at: " + + fs.Position); + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = + myStateFrameBlock.StatePointer[i].StateBlock.EndPos + + BitConverter.ToUInt32(br_read(4), 0); + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = + BitConverter.ToUInt32(br_read(4), 0); + Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Code Chunk Pointer: " + + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. + CodeChunkPointer); + Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + + ((LSO_Enums.Event_Mask_Values) ii).ToString() + ") Call Frame Size: " + + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii]. + CallFrameSize); } } } } - - //// READ FUNCTION CODE CHUNKS //// Functions + Function start pos (GFR) //// TODO: Somehow be able to identify and reference this @@ -291,37 +299,32 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // two level search ain't no good for (int ii = 0; ii < myStateFrameBlock.StatePointer[i].EventMask.Count - 1; ii++) { - - if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0) { - Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii); + Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + + (LSO_Enums.Event_Mask_Values) ii); // Override a Method / Function - string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values)ii; + string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values) ii; Common.SendToDebug("Event Name: " + eventname); if (Common.IL_ProcessCodeChunks) { EventList.Add(eventname); // JUMP TO CODE PROCESSOR - ProcessCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, typeBuilder, eventname); + ProcessCodeChunk( + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, + typeBuilder, eventname); } } - } - } - } - - if (Common.IL_CreateFunctionList) IL_INSERT_FUNCTIONLIST(); - } internal LSO_Struct.HeapBlock GetHeap(UInt32 pos) @@ -342,11 +345,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize); - Common.SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString()); + Common.SendToDebug("Heap Block ObjectType: " + + ((LSO_Enums.Variable_Type_Codes) myHeapBlock.ObjectType).ToString()); Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount); return myHeapBlock; } + private byte[] br_read(int len) { if (len <= 0) @@ -365,6 +370,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO throw (e); } } + //private byte[] br_read_smallendian(int len) //{ // byte[] bytes = new byte[len]; @@ -373,29 +379,38 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //} private Type getLLObjectType(byte objectCode) { - switch ((LSO_Enums.Variable_Type_Codes)objectCode) + switch ((LSO_Enums.Variable_Type_Codes) objectCode) { - case LSO_Enums.Variable_Type_Codes.Void: return typeof(void); - case LSO_Enums.Variable_Type_Codes.Integer: return typeof(UInt32); - case LSO_Enums.Variable_Type_Codes.Float: return typeof(float); - case LSO_Enums.Variable_Type_Codes.String: return typeof(string); - case LSO_Enums.Variable_Type_Codes.Key: return typeof(string); - case LSO_Enums.Variable_Type_Codes.Vector: return typeof(LSO_Enums.Vector); - case LSO_Enums.Variable_Type_Codes.Rotation: return typeof(LSO_Enums.Rotation); + case LSO_Enums.Variable_Type_Codes.Void: + return typeof (void); + case LSO_Enums.Variable_Type_Codes.Integer: + return typeof (UInt32); + case LSO_Enums.Variable_Type_Codes.Float: + return typeof (float); + case LSO_Enums.Variable_Type_Codes.String: + return typeof (string); + case LSO_Enums.Variable_Type_Codes.Key: + return typeof (string); + case LSO_Enums.Variable_Type_Codes.Vector: + return typeof (LSO_Enums.Vector); + case LSO_Enums.Variable_Type_Codes.Rotation: + return typeof (LSO_Enums.Rotation); case LSO_Enums.Variable_Type_Codes.List: Common.SendToDebug("TODO: List datatype not implemented yet!"); - return typeof(System.Collections.ArrayList); + return typeof (ArrayList); case LSO_Enums.Variable_Type_Codes.Null: Common.SendToDebug("TODO: Datatype null is not implemented, using string instead.!"); - return typeof(string); + return typeof (string); default: - Common.SendToDebug("Lookup of LSL datatype " + objectCode + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); - return typeof(object); + Common.SendToDebug("Lookup of LSL datatype " + objectCode + + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object."); + return typeof (object); } } + private int getObjectSize(byte ObjectType) { - switch ((LSO_Enums.Variable_Type_Codes)ObjectType) + switch ((LSO_Enums.Variable_Type_Codes) ObjectType) { case LSO_Enums.Variable_Type_Codes.Integer: case LSO_Enums.Variable_Type_Codes.Float: @@ -411,13 +426,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO return 0; } } + private string Read_String() { string ret = ""; byte reader = br_read(1)[0]; while (reader != 0x000) { - ret += (char)reader; + ret += (char) reader; reader = br_read(1)[0]; } return ret; @@ -431,7 +447,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO /// Name of event (function) to generate private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname) { - LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk(); Common.SendToDebug("Reading Function Code Chunk at: " + pos); @@ -442,12 +457,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO myCodeChunk.Comment = Read_String(); Common.SendToDebug("Function comment: " + myCodeChunk.Comment); myCodeChunk.ReturnTypePos = br_read(1)[0]; - myCodeChunk.ReturnType = GetStaticBlock((long)myCodeChunk.ReturnTypePos + (long)myHeader.GVR); - Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " + ((LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType.ObjectType).ToString()); + myCodeChunk.ReturnType = GetStaticBlock((long) myCodeChunk.ReturnTypePos + (long) myHeader.GVR); + Common.SendToDebug("Return type #" + myCodeChunk.ReturnType.ObjectType + ": " + + ((LSO_Enums.Variable_Type_Codes) myCodeChunk.ReturnType.ObjectType).ToString()); // TODO: How to determine number of codechunks -- does this method work? - myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List(); + myCodeChunk.CodeChunkArguments = new List(); byte reader = br_read(1)[0]; reader = br_read(1)[0]; @@ -464,14 +480,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO CCA.NullString = reader; CCA.FunctionReturnType = GetStaticBlock(CCA.FunctionReturnTypePos + myHeader.GVR); myCodeChunk.CodeChunkArguments.Add(CCA); - Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType + ": " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType.ObjectType); + Common.SendToDebug("Code Chunk Argument " + ccount + " type #" + CCA.FunctionReturnType.ObjectType + + ": " + (LSO_Enums.Variable_Type_Codes) CCA.FunctionReturnType.ObjectType); } // Create string array Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count]; for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++) { MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType); - Common.SendToDebug("Method argument " + _ic + ": " + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType).ToString()); + Common.SendToDebug("Method argument " + _ic + ": " + + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType.ObjectType). + ToString()); } // End marker is 0x000 myCodeChunk.EndMarker = reader; @@ -483,9 +502,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod..."); MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, - MethodAttributes.Public, - typeof(void), - new Type[] { typeof(object) }); + MethodAttributes.Public, + typeof (void), + new Type[] {typeof (object)}); //MethodArgs); //typeof(void), //getLLObjectType(myCodeChunk.ReturnType), // new Type[] { typeof(object) }, //); @@ -504,7 +523,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO IL_INSERT_TRY(il, eventname); - // Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!"); //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); //il.Emit(OpCodes.Call, typeof(Console).GetMethod @@ -520,7 +538,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO } - // // CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL // @@ -538,12 +555,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO il.Emit(OpCodes.Ret); return; - } private void IL_INSERT_FUNCTIONLIST() { - Common.SendToDebug("Creating function list"); @@ -557,11 +572,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private); - MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname, - MethodAttributes.Public, - typeof(string[]), - null); + MethodAttributes.Public, + typeof (string[]), + null); //typeBuilder.DefineMethodOverride(methodBuilder, // typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname)); @@ -569,8 +583,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO ILGenerator il = methodBuilder.GetILGenerator(); - - // IL_INSERT_TRY(il, eventname); // // Push string to stack @@ -586,37 +598,34 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO ////il.Emit(OpCodes.Ldarg_0); - il.DeclareLocal(typeof(string[])); + il.DeclareLocal(typeof (string[])); ////il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length - il.Emit(OpCodes.Newarr, typeof(String)); // create new string array - il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack + il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length + il.Emit(OpCodes.Newarr, typeof (String)); // create new string array + il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack ////SetFunctionList for (int lv = 0; lv < EventList.Count; lv++) { - il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack - il.Emit(OpCodes.Ldc_I4, lv); // Push index position - il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value - il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value + il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack + il.Emit(OpCodes.Ldc_I4, lv); // Push index position + il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value + il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value //il.Emit(OpCodes.Ldarg_0); //il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value //il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("AddFunction", new Type[] { typeof(string) })); - } - // IL_INSERT_END_TRY(il, eventname); - il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack + il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack // il.Emit(OpCodes.Call, typeof(LSL_BaseClass).GetMethod("SetFunctionList", new Type[] { typeof(Array) })); - il.Emit(OpCodes.Ret); // Return - + il.Emit(OpCodes.Ret); // Return } @@ -631,7 +640,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // Push "Hello World!" string to stack //Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); //il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname); - } private void IL_INSERT_END_TRY(ILGenerator il, string eventname) @@ -640,7 +648,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO * CATCH */ Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));"); - il.BeginCatchBlock(typeof(Exception)); + il.BeginCatchBlock(typeof (Exception)); // Push "Hello World!" string to stack Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr..."); @@ -648,18 +656,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO //call void [mscorlib]System.Console::WriteLine(string) Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); - il.Emit(OpCodes.Call, typeof(Console).GetMethod - ("Write", new Type[] { typeof(string) })); + il.Emit(OpCodes.Call, typeof (Console).GetMethod + ("Write", new Type[] {typeof (string)})); //callvirt instance string [mscorlib]System.Exception::get_Message() Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt..."); - il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod - ("get_Message")); + il.Emit(OpCodes.Callvirt, typeof (Exception).GetMethod + ("get_Message")); //call void [mscorlib]System.Console::WriteLine(string) Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call..."); - il.Emit(OpCodes.Call, typeof(Console).GetMethod - ("WriteLine", new Type[] { typeof(string) })); + il.Emit(OpCodes.Call, typeof (Console).GetMethod + ("WriteLine", new Type[] {typeof (string)})); /* * CLR END TRY @@ -673,7 +681,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO long FirstPos = fs.Position; try { - UInt32 position = (UInt32)pos; + UInt32 position = (UInt32) pos; // STATIC BLOCK Common.SendToDebug("Reading STATIC BLOCK at: " + position); fs.Seek(position, SeekOrigin.Begin); @@ -683,7 +691,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO Common.SendToDebug("Found cached STATIC BLOCK"); - return StaticBlocks[pos]; } @@ -699,7 +706,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock(); myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0); myStaticBlock.ObjectType = br_read(1)[0]; - Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString()); + Common.SendToDebug("Static Block ObjectType: " + + ((LSO_Enums.Variable_Type_Codes) myStaticBlock.ObjectType).ToString()); myStaticBlock.Unknown = br_read(1)[0]; // Size of datatype varies if (myStaticBlock.ObjectType != 0) @@ -715,8 +723,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO // Go back to original read pos fs.Seek(FirstPos, SeekOrigin.Begin); } - } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs index baeda38..cf64638 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSO/LSO_Struct.cs @@ -28,14 +28,13 @@ /* Original code: Tedd Hansen */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO { - static class LSO_Struct + internal static class LSO_Struct { - public struct Header { public UInt32 TM; @@ -69,6 +68,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO public byte Unknown; public byte[] BlockVariable; } + /* Not actually a structure public struct StaticBlockVariable { @@ -80,6 +80,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO public byte[] Rotation_16; public UInt32 Pointer_List_Structure; } */ + public struct HeapBlock { public Int32 DataBlockSize; @@ -87,17 +88,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO public UInt16 ReferenceCount; public byte[] Data; } + public struct StateFrameBlock { public UInt32 StateCount; public StatePointerBlock[] StatePointer; } + public struct StatePointerBlock { public UInt32 Location; - public System.Collections.BitArray EventMask; + public BitArray EventMask; public StateBlock StateBlock; } + public struct StateBlock { public UInt32 StartPos; @@ -106,25 +110,29 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO public byte Unknown; public StateBlockHandler[] StateBlockHandlers; } + public struct StateBlockHandler { public UInt32 CodeChunkPointer; public UInt32 CallFrameSize; } + public struct FunctionBlock { public UInt32 FunctionCount; public UInt32[] CodeChunkPointer; } + public struct CodeChunk { public UInt32 CodeChunkHeaderSize; public string Comment; - public System.Collections.Generic.List CodeChunkArguments; + public List CodeChunkArguments; public byte EndMarker; public byte ReturnTypePos; public StaticBlock ReturnType; } + public struct CodeChunkArgument { public byte FunctionReturnTypePos; @@ -132,4 +140,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO public StaticBlock FunctionReturnType; } } -} +} \ 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 b94cf90..737dee6 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 @@ -26,19 +26,18 @@ * */ -using Axiom.Math; using System; using System.Collections.Generic; +using System.Runtime.Remoting.Lifetime; using System.Text; +using System.Threading; +using Axiom.Math; using libsecondlife; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; +using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; +using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ScriptEngine.Common; -using OpenSim.Framework.Console; -using OpenSim.Framework; -using System.Runtime.Remoting.Lifetime; +using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler { @@ -53,8 +52,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler /// public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface { - - private System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + private ASCIIEncoding enc = new ASCIIEncoding(); private ScriptEngine m_ScriptEngine; private SceneObjectPart m_host; private uint m_localID; @@ -86,7 +84,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler { //Console.WriteLine("LSL_BuiltIn_Commands: InitializeLifetimeService()"); // return null; - ILease lease = (ILease)base.InitializeLifetimeService(); + ILease lease = (ILease) base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { @@ -105,79 +103,130 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler //These are the implementations of the various ll-functions used by the LSL scripts. //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 - public double llSin(double f) { return (double)Math.Sin(f); } - public double llCos(double f) { return (double)Math.Cos(f); } - public double llTan(double f) { return (double)Math.Tan(f); } - public double llAtan2(double x, double y) { return (double)Math.Atan2(y, x); } - public double llSqrt(double f) { return (double)Math.Sqrt(f); } - public double llPow(double fbase, double fexponent) { return (double)Math.Pow(fbase, fexponent); } - public int llAbs(int i) { return (int)Math.Abs(i); } - public double llFabs(double f) { return (double)Math.Abs(f); } + public double llSin(double f) + { + return (double) Math.Sin(f); + } + + public double llCos(double f) + { + return (double) Math.Cos(f); + } + + public double llTan(double f) + { + return (double) Math.Tan(f); + } + + public double llAtan2(double x, double y) + { + return (double) Math.Atan2(y, x); + } + + public double llSqrt(double f) + { + return (double) Math.Sqrt(f); + } + + public double llPow(double fbase, double fexponent) + { + return (double) Math.Pow(fbase, fexponent); + } + + public int llAbs(int i) + { + return (int) Math.Abs(i); + } + + public double llFabs(double f) + { + return (double) Math.Abs(f); + } public double llFrand(double mag) { lock (Util.RandomClass) { - return Util.RandomClass.Next((int)mag); + return Util.RandomClass.Next((int) mag); } } - public int llFloor(double f) { return (int)Math.Floor(f); } - public int llCeil(double f) { return (int)Math.Ceiling(f); } - public int llRound(double f) { return (int)Math.Round(f, 3); } + public int llFloor(double f) + { + return (int) Math.Floor(f); + } + + public int llCeil(double f) + { + return (int) Math.Ceiling(f); + } + + public int llRound(double f) + { + return (int) Math.Round(f, 3); + } //This next group are vector operations involving squaring and square root. ckrinke public double llVecMag(LSL_Types.Vector3 v) { - return (v.X * v.X + v.Y * v.Y + v.Z * v.Z); + return (v.X*v.X + v.Y*v.Y + v.Z*v.Z); } public LSL_Types.Vector3 llVecNorm(LSL_Types.Vector3 v) { - double mag = v.X * v.X + v.Y * v.Y + v.Z * v.Z; + double mag = v.X*v.X + v.Y*v.Y + v.Z*v.Z; LSL_Types.Vector3 nor = new LSL_Types.Vector3(); - nor.X = v.X / mag; nor.Y = v.Y / mag; nor.Z = v.Z / mag; + nor.X = v.X/mag; + nor.Y = v.Y/mag; + nor.Z = v.Z/mag; return nor; } public double llVecDist(LSL_Types.Vector3 a, LSL_Types.Vector3 b) { - double dx = a.X - b.X; double dy = a.Y - b.Y; double dz = a.Z - b.Z; - return Math.Sqrt(dx * dx + dy * dy + dz * dz); + double dx = a.X - b.X; + double dy = a.Y - b.Y; + double dz = a.Z - b.Z; + return Math.Sqrt(dx*dx + dy*dy + dz*dz); } //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke public LSL_Types.Vector3 llRot2Euler(LSL_Types.Quaternion r) { //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke - LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X * r.X, r.Y * r.Y, r.Z * r.Z, r.R * r.R); + LSL_Types.Quaternion t = new LSL_Types.Quaternion(r.X*r.X, r.Y*r.Y, r.Z*r.Z, r.R*r.R); double m = (t.X + t.Y + t.Z + t.R); if (m == 0) return new LSL_Types.Vector3(); - double n = 2 * (r.Y * r.R + r.X * r.Z); - double p = m * m - n * n; + double n = 2*(r.Y*r.R + r.X*r.Z); + double p = m*m - n*n; if (p > 0) - return new LSL_Types.Vector3(Math.Atan2(2.0 * (r.X * r.R - r.Y * r.Z), (-t.X - t.Y + t.Z + t.R)), - Math.Atan2(n, Math.Sqrt(p)), Math.Atan2(2.0 * (r.Z * r.R - r.X * r.Y), (t.X - t.Y - t.Z + t.R))); + return new LSL_Types.Vector3(Math.Atan2(2.0*(r.X*r.R - r.Y*r.Z), (-t.X - t.Y + t.Z + t.R)), + Math.Atan2(n, Math.Sqrt(p)), + Math.Atan2(2.0*(r.Z*r.R - r.X*r.Y), (t.X - t.Y - t.Z + t.R))); else if (n > 0) - return new LSL_Types.Vector3(0.0, Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); + return new LSL_Types.Vector3(0.0, Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); else - return new LSL_Types.Vector3(0.0, -Math.PI / 2, Math.Atan2((r.Z * r.R + r.X * r.Y), 0.5 - t.X - t.Z)); + return new LSL_Types.Vector3(0.0, -Math.PI/2, Math.Atan2((r.Z*r.R + r.X*r.Y), 0.5 - t.X - t.Z)); } public LSL_Types.Quaternion llEuler2Rot(LSL_Types.Vector3 v) { //this comes from from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions but is incomplete as of 8/19/07 float err = 0.00001f; - double ax = Math.Sin(v.X / 2); double aw = Math.Cos(v.X / 2); - double by = Math.Sin(v.Y / 2); double bw = Math.Cos(v.Y / 2); - double cz = Math.Sin(v.Z / 2); double cw = Math.Cos(v.Z / 2); + double ax = Math.Sin(v.X/2); + double aw = Math.Cos(v.X/2); + double by = Math.Sin(v.Y/2); + double bw = Math.Cos(v.Y/2); + double cz = Math.Sin(v.Z/2); + double cw = Math.Cos(v.Z/2); LSL_Types.Quaternion a1 = new LSL_Types.Quaternion(0.0, 0.0, cz, cw); LSL_Types.Quaternion a2 = new LSL_Types.Quaternion(0.0, by, 0.0, bw); LSL_Types.Quaternion a3 = new LSL_Types.Quaternion(ax, 0.0, 0.0, aw); LSL_Types.Quaternion a = new LSL_Types.Quaternion(); //This multiplication doesnt compile, yet. a = a1 * a2 * a3; - LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax * bw * cw + aw * by * cz, - aw * by * cw - ax * bw * cz, aw * bw * cz + ax * by * cw, aw * bw * cw - ax * by * cz); + LSL_Types.Quaternion b = new LSL_Types.Quaternion(ax*bw*cw + aw*by*cz, + aw*by*cw - ax*bw*cz, aw*bw*cz + ax*by*cw, + aw*bw*cw - ax*by*cz); LSL_Types.Quaternion c = new LSL_Types.Quaternion(); //This addition doesnt compile yet c = a + b; LSL_Types.Quaternion d = new LSL_Types.Quaternion(); @@ -191,359 +240,946 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler // return b; // return a; } - return new LSL_Types.Quaternion(); + return new LSL_Types.Quaternion(); + } + + public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) + { + return new LSL_Types.Quaternion(); + } + + public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) + { + return new LSL_Types.Quaternion(); + } + + public void llWhisper(int channelID, string text) + { + //type for whisper is 0 + World.SimChat(Helpers.StringToField(text), + 0, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + wComm.DeliverMessage(m_host.UUID.ToString(), 0, channelID, m_host.Name, text); + } + + public void llSay(int channelID, string text) + { + //type for say is 1 + World.SimChat(Helpers.StringToField(text), + 1, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + wComm.DeliverMessage(m_host.UUID.ToString(), 1, channelID, m_host.Name, text); + } + + public void llShout(int channelID, string text) + { + //type for shout is 2 + World.SimChat(Helpers.StringToField(text), + 2, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + wComm.DeliverMessage(m_host.UUID.ToString(), 2, channelID, m_host.Name, text); + } + + public int llListen(int channelID, string name, string ID, string msg) + { + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, ID, msg); + } + + public void llListenControl(int number, int active) + { + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + wComm.ListenControl(number, active); + } + + public void llListenRemove(int number) + { + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + wComm.ListenRemove(number); + } + + public void llSensor(string name, string id, int type, double range, double arc) + { + NotImplemented("llSensor"); + return; + } + + public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) + { + NotImplemented("llSensorRepeat"); + return; + } + + public void llSensorRemove() + { + NotImplemented("llSensorRemove"); + return; + } + + public string llDetectedName(int number) + { + NotImplemented("llDetectedName"); + return ""; + } + + public string llDetectedKey(int number) + { + NotImplemented("llDetectedKey"); + return ""; + } + + public string llDetectedOwner(int number) + { + NotImplemented("llDetectedOwner"); + return ""; + } + + public int llDetectedType(int number) + { + NotImplemented("llDetectedType"); + return 0; + } + + public LSL_Types.Vector3 llDetectedPos(int number) + { + NotImplemented("llDetectedPos"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llDetectedVel(int number) + { + NotImplemented("llDetectedVel"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llDetectedGrab(int number) + { + NotImplemented("llDetectedGrab"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Quaternion llDetectedRot(int number) + { + NotImplemented("llDetectedRot"); + return new LSL_Types.Quaternion(); + } + + public int llDetectedGroup(int number) + { + NotImplemented("llDetectedGroup"); + return 0; + } + + public int llDetectedLinkNumber(int number) + { + NotImplemented("llDetectedLinkNumber"); + return 0; + } + + public void llDie() + { + NotImplemented("llDie"); + return; + } + + public double llGround(LSL_Types.Vector3 offset) + { + NotImplemented("llGround"); + return 0; + } + + public double llCloud(LSL_Types.Vector3 offset) + { + NotImplemented("llCloud"); + return 0; + } + + public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) + { + NotImplemented("llWind"); + return new LSL_Types.Vector3(); + } + + public void llSetStatus(int status, int value) + { + NotImplemented("llSetStatus"); + return; + } + + public int llGetStatus(int status) + { + NotImplemented("llGetStatus"); + return 0; + } + + public void llSetScale(LSL_Types.Vector3 scale) + { + // TODO: this needs to trigger a persistance save as well + LLVector3 tmp = m_host.Scale; + tmp.X = (float) scale.X; + tmp.Y = (float) scale.Y; + tmp.Z = (float) scale.Z; + m_host.Scale = tmp; + return; + } + + public LSL_Types.Vector3 llGetScale() + { + return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); + } + + public void llSetColor(LSL_Types.Vector3 color, int face) + { + NotImplemented("llSetColor"); + return; + } + + public double llGetAlpha(int face) + { + NotImplemented("llGetAlpha"); + return 0; + } + + public void llSetAlpha(double alpha, int face) + { + NotImplemented("llSetAlpha"); + return; + } + + public LSL_Types.Vector3 llGetColor(int face) + { + NotImplemented("llGetColor"); + return new LSL_Types.Vector3(); + } + + public void llSetTexture(string texture, int face) + { + NotImplemented("llSetTexture"); + return; + } + + public void llScaleTexture(double u, double v, int face) + { + NotImplemented("llScaleTexture"); + return; + } + + public void llOffsetTexture(double u, double v, int face) + { + NotImplemented("llOffsetTexture"); + return; + } + + public void llRotateTexture(double rotation, int face) + { + NotImplemented("llRotateTexture"); + return; + } + + public string llGetTexture(int face) + { + NotImplemented("llGetTexture"); + return ""; + } + + public void llSetPos(LSL_Types.Vector3 pos) + { + if (m_host.ParentID != 0) + { + m_host.UpdateOffSet(new LLVector3((float) pos.X, (float) pos.Y, (float) pos.Z)); + } + else + { + m_host.UpdateGroupPosition(new LLVector3((float) pos.X, (float) pos.Y, (float) pos.Z)); + } + } + + public LSL_Types.Vector3 llGetPos() + { + return new LSL_Types.Vector3(m_host.AbsolutePosition.X, + m_host.AbsolutePosition.Y, + m_host.AbsolutePosition.Z); + } + + public LSL_Types.Vector3 llGetLocalPos() + { + if (m_host.ParentID != 0) + { + return new LSL_Types.Vector3(m_host.OffsetPosition.X, + m_host.OffsetPosition.Y, + m_host.OffsetPosition.Z); + } + else + { + return new LSL_Types.Vector3(m_host.AbsolutePosition.X, + m_host.AbsolutePosition.Y, + m_host.AbsolutePosition.Z); + } + } + + public void llSetRot(LSL_Types.Quaternion rot) + { + m_host.UpdateRotation(new LLQuaternion((float) rot.X, (float) rot.Y, (float) rot.Z, (float) rot.R)); + } + + public LSL_Types.Quaternion llGetRot() + { + LLQuaternion q = m_host.RotationOffset; + return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); + } + + public LSL_Types.Quaternion llGetLocalRot() + { + NotImplemented("llGetLocalRot"); + return new LSL_Types.Quaternion(); + } + + public void llSetForce(LSL_Types.Vector3 force, int local) + { + NotImplemented("llSetForce"); + } + + public LSL_Types.Vector3 llGetForce() + { + NotImplemented("llGetForce"); + return new LSL_Types.Vector3(); + } + + public int llTarget(LSL_Types.Vector3 position, double range) + { + NotImplemented("llTarget"); + return 0; + } + + public void llTargetRemove(int number) + { + NotImplemented("llTargetRemove"); + } + + public int llRotTarget(LSL_Types.Quaternion rot, double error) + { + NotImplemented("llRotTarget"); + return 0; + } + + public void llRotTargetRemove(int number) + { + NotImplemented("llRotTargetRemove"); + } + + public void llMoveToTarget(LSL_Types.Vector3 target, double tau) + { + NotImplemented("llMoveToTarget"); + } + + public void llStopMoveToTarget() + { + NotImplemented("llStopMoveToTarget"); + } + + public void llApplyImpulse(LSL_Types.Vector3 force, int local) + { + NotImplemented("llApplyImpulse"); + } + + public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) + { + NotImplemented("llApplyRotationalImpulse"); + } + + public void llSetTorque(LSL_Types.Vector3 torque, int local) + { + NotImplemented("llSetTorque"); + } + + public LSL_Types.Vector3 llGetTorque() + { + NotImplemented("llGetTorque"); + return new LSL_Types.Vector3(); + } + + public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) + { + NotImplemented("llSetForceAndTorque"); + } + + public LSL_Types.Vector3 llGetVel() + { + NotImplemented("llGetVel"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llGetAccel() + { + NotImplemented("llGetAccel"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llGetOmega() + { + NotImplemented("llGetOmega"); + return new LSL_Types.Vector3(); + } + + public double llGetTimeOfDay() + { + NotImplemented("llGetTimeOfDay"); + return 0; + } + + public double llGetWallclock() + { + return DateTime.Now.TimeOfDay.TotalSeconds; + } + + public double llGetTime() + { + NotImplemented("llGetTime"); + return 0; + } + + public void llResetTime() + { + NotImplemented("llResetTime"); + } + + public double llGetAndResetTime() + { + NotImplemented("llGetAndResetTime"); + return 0; + } + + public void llSound() + { + NotImplemented("llSound"); + } + + public void llPlaySound(string sound, double volume) + { + NotImplemented("llPlaySound"); + } + + public void llLoopSound(string sound, double volume) + { + NotImplemented("llLoopSound"); + } + + public void llLoopSoundMaster(string sound, double volume) + { + NotImplemented("llLoopSoundMaster"); + } + + public void llLoopSoundSlave(string sound, double volume) + { + NotImplemented("llLoopSoundSlave"); + } + + public void llPlaySoundSlave(string sound, double volume) + { + NotImplemented("llPlaySoundSlave"); + } + + public void llTriggerSound(string sound, double volume) + { + NotImplemented("llTriggerSound"); + } + + public void llStopSound() + { + NotImplemented("llStopSound"); + } + + public void llPreloadSound(string sound) + { + NotImplemented("llPreloadSound"); + } + + public string llGetSubString(string src, int start, int end) + { + return src.Substring(start, end); + } + + public string llDeleteSubString(string src, int start, int end) + { + return src.Remove(start, end - start); + } + + public string llInsertString(string dst, int position, string src) + { + return dst.Insert(position, src); + } + + public string llToUpper(string src) + { + return src.ToUpper(); + } + + public string llToLower(string src) + { + return src.ToLower(); + } + + public int llGiveMoney(string destination, int amount) + { + NotImplemented("llGiveMoney"); + return 0; + } + + public void llMakeExplosion() + { + NotImplemented("llMakeExplosion"); + } + + public void llMakeFountain() + { + NotImplemented("llMakeFountain"); + } + + public void llMakeSmoke() + { + NotImplemented("llMakeSmoke"); + } + + public void llMakeFire() + { + NotImplemented("llMakeFire"); + } + + public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) + { + NotImplemented("llRezObject"); + } + + public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) + { + NotImplemented("llLookAt"); + } + + public void llStopLookAt() + { + NotImplemented("llStopLookAt"); + } + + public void llSetTimerEvent(double sec) + { + // Setting timer repeat + m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec); + } + + public void llSleep(double sec) + { + Thread.Sleep((int) (sec*1000)); + } + + public double llGetMass() + { + NotImplemented("llGetMass"); + return 0; + } + + public void llCollisionFilter(string name, string id, int accept) + { + NotImplemented("llCollisionFilter"); + } + + public void llTakeControls(int controls, int accept, int pass_on) + { + NotImplemented("llTakeControls"); + } + + public void llReleaseControls() + { + NotImplemented("llReleaseControls"); + } + + public void llAttachToAvatar(int attachment) + { + NotImplemented("llAttachToAvatar"); + } + + public void llDetachFromAvatar() + { + NotImplemented("llDetachFromAvatar"); + } + + public void llTakeCamera() + { + NotImplemented("llTakeCamera"); + } + + public void llReleaseCamera() + { + NotImplemented("llReleaseCamera"); + } + + public string llGetOwner() + { + return m_host.ObjectOwner.ToStringHyphenated(); + } + + public void llInstantMessage(string user, string message) + { + NotImplemented("llInstantMessage"); + } + + public void llEmail(string address, string subject, string message) + { + NotImplemented("llEmail"); + } + + public void llGetNextEmail(string address, string subject) + { + NotImplemented("llGetNextEmail"); + } + + public string llGetKey() + { + return m_host.UUID.ToStringHyphenated(); + } + + public void llSetBuoyancy(double buoyancy) + { + NotImplemented("llSetBuoyancy"); + } + + public void llSetHoverHeight(double height, int water, double tau) + { + NotImplemented("llSetHoverHeight"); + } + + public void llStopHover() + { + NotImplemented("llStopHover"); + } + + public void llMinEventDelay(double delay) + { + NotImplemented("llMinEventDelay"); + } + + public void llSoundPreload() + { + NotImplemented("llSoundPreload"); + } + + public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) + { + NotImplemented("llRotLookAt"); + } + + public int llStringLength(string str) + { + if (str.Length > 0) + { + return str.Length; + } + else + { + return 0; + } } - public LSL_Types.Quaternion llAxes2Rot(LSL_Types.Vector3 fwd, LSL_Types.Vector3 left, LSL_Types.Vector3 up) { return new LSL_Types.Quaternion(); } - public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llRot2Up(LSL_Types.Quaternion r) { return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llRotBetween(LSL_Types.Vector3 start, LSL_Types.Vector3 end) { return new LSL_Types.Quaternion(); } - - public void llWhisper(int channelID, string text) + public void llStartAnimation(string anim) { - //type for whisper is 0 - World.SimChat(Helpers.StringToField(text), - 0, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + NotImplemented("llStartAnimation"); + } - IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - wComm.DeliverMessage(m_host.UUID.ToString(), 0, channelID, m_host.Name, text); + public void llStopAnimation(string anim) + { + NotImplemented("llStopAnimation"); } - public void llSay(int channelID, string text) + public void llPointAt() { - //type for say is 1 - World.SimChat(Helpers.StringToField(text), - 1, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + NotImplemented("llPointAt"); + } - IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - wComm.DeliverMessage(m_host.UUID.ToString(), 1, channelID, m_host.Name, text); + public void llStopPointAt() + { + NotImplemented("llStopPointAt"); } - public void llShout(int channelID, string text) + public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) { - //type for shout is 2 - World.SimChat(Helpers.StringToField(text), - 2, channelID, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + NotImplemented("llTargetOmega"); + } - IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - wComm.DeliverMessage(m_host.UUID.ToString(), 2, channelID, m_host.Name, text); + public int llGetStartParameter() + { + NotImplemented("llGetStartParameter"); + return 0; } - public int llListen(int channelID, string name, string ID, string msg) { + public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) + { + NotImplemented("llGodLikeRezObject"); + } - IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - return wComm.Listen(m_localID, m_itemID, m_host.UUID, channelID, name, ID, msg); - + public void llRequestPermissions(string agent, int perm) + { + NotImplemented("llRequestPermissions"); } - public void llListenControl(int number, int active) { + public string llGetPermissionsKey() + { + NotImplemented("llGetPermissionsKey"); + return ""; + } - IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - wComm.ListenControl(number, active); - + public int llGetPermissions() + { + NotImplemented("llGetPermissions"); + return 0; } - public void llListenRemove(int number) { + public int llGetLinkNumber() + { + NotImplemented("llGetLinkNumber"); + return 0; + } - IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); - wComm.ListenRemove(number); - - } - - public void llSensor(string name, string id, int type, double range, double arc) { NotImplemented("llSensor"); return; } - public void llSensorRepeat(string name, string id, int type, double range, double arc, double rate) { NotImplemented("llSensorRepeat"); return; } - public void llSensorRemove() { NotImplemented("llSensorRemove"); return; } - public string llDetectedName(int number) { NotImplemented("llDetectedName"); return ""; } - public string llDetectedKey(int number) { NotImplemented("llDetectedKey"); return ""; } - public string llDetectedOwner(int number) { NotImplemented("llDetectedOwner"); return ""; } - public int llDetectedType(int number) { NotImplemented("llDetectedType"); return 0; } - public LSL_Types.Vector3 llDetectedPos(int number) { NotImplemented("llDetectedPos"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llDetectedVel(int number) { NotImplemented("llDetectedVel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llDetectedGrab(int number) { NotImplemented("llDetectedGrab"); return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llDetectedRot(int number) { NotImplemented("llDetectedRot"); return new LSL_Types.Quaternion(); } - public int llDetectedGroup(int number) { NotImplemented("llDetectedGroup"); return 0; } - public int llDetectedLinkNumber(int number) { NotImplemented("llDetectedLinkNumber"); return 0; } - public void llDie() { NotImplemented("llDie"); return; } - public double llGround(LSL_Types.Vector3 offset) { NotImplemented("llGround"); return 0; } - public double llCloud(LSL_Types.Vector3 offset) { NotImplemented("llCloud"); return 0; } - public LSL_Types.Vector3 llWind(LSL_Types.Vector3 offset) { NotImplemented("llWind"); return new LSL_Types.Vector3(); } - public void llSetStatus(int status, int value) { NotImplemented("llSetStatus"); return; } - public int llGetStatus(int status) { NotImplemented("llGetStatus"); return 0; } + public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) + { + NotImplemented("llSetLinkColor"); + } - public void llSetScale(LSL_Types.Vector3 scale) + public void llCreateLink(string target, int parent) { - // TODO: this needs to trigger a persistance save as well - LLVector3 tmp = m_host.Scale; - tmp.X = (float)scale.X; - tmp.Y = (float)scale.Y; - tmp.Z = (float)scale.Z; - m_host.Scale = tmp; - return; + NotImplemented("llCreateLink"); } - public LSL_Types.Vector3 llGetScale() + + public void llBreakLink(int linknum) { - return new LSL_Types.Vector3(m_host.Scale.X, m_host.Scale.Y, m_host.Scale.Z); + NotImplemented("llBreakLink"); } - public void llSetColor(LSL_Types.Vector3 color, int face) { NotImplemented("llSetColor"); return; } - public double llGetAlpha(int face) { NotImplemented("llGetAlpha"); return 0; } - public void llSetAlpha(double alpha, int face) { NotImplemented("llSetAlpha"); return; } - public LSL_Types.Vector3 llGetColor(int face) { NotImplemented("llGetColor"); return new LSL_Types.Vector3(); } - public void llSetTexture(string texture, int face) { NotImplemented("llSetTexture"); return; } - public void llScaleTexture(double u, double v, int face) { NotImplemented("llScaleTexture"); return; } - public void llOffsetTexture(double u, double v, int face) { NotImplemented("llOffsetTexture"); return; } - public void llRotateTexture(double rotation, int face) { NotImplemented("llRotateTexture"); return; } + public void llBreakAllLinks() + { + NotImplemented("llBreakAllLinks"); + } - public string llGetTexture(int face) { NotImplemented("llGetTexture"); return ""; } + public string llGetLinkKey(int linknum) + { + NotImplemented("llGetLinkKey"); + return ""; + } - public void llSetPos(LSL_Types.Vector3 pos) + public void llGetLinkName(int linknum) { - if (m_host.ParentID != 0) - { - m_host.UpdateOffSet(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); - } - else - { - m_host.UpdateGroupPosition(new LLVector3((float)pos.X, (float)pos.Y, (float)pos.Z)); - } + NotImplemented("llGetLinkName"); } - public LSL_Types.Vector3 llGetPos() + public int llGetInventoryNumber(int type) { - return new LSL_Types.Vector3(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z); + NotImplemented("llGetInventoryNumber"); + return 0; } - public LSL_Types.Vector3 llGetLocalPos() + public string llGetInventoryName(int type, int number) { - if (m_host.ParentID != 0) - { - return new LSL_Types.Vector3(m_host.OffsetPosition.X, - m_host.OffsetPosition.Y, - m_host.OffsetPosition.Z); - } - else - { - return new LSL_Types.Vector3(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z); - } + NotImplemented("llGetInventoryName"); + return ""; } - public void llSetRot(LSL_Types.Quaternion rot) + + public void llSetScriptState(string name, int run) { - m_host.UpdateRotation(new LLQuaternion((float)rot.X, (float)rot.Y, (float)rot.Z, (float)rot.R)); + NotImplemented("llSetScriptState"); } - public LSL_Types.Quaternion llGetRot() + + public double llGetEnergy() { - LLQuaternion q = m_host.RotationOffset; - return new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); + return 1.0f; } - public LSL_Types.Quaternion llGetLocalRot() { NotImplemented("llGetLocalRot"); return new LSL_Types.Quaternion(); } - public void llSetForce(LSL_Types.Vector3 force, int local) { NotImplemented("llSetForce"); } - public LSL_Types.Vector3 llGetForce() { NotImplemented("llGetForce"); return new LSL_Types.Vector3(); } - public int llTarget(LSL_Types.Vector3 position, double range) { NotImplemented("llTarget"); return 0; } - public void llTargetRemove(int number) { NotImplemented("llTargetRemove"); } - public int llRotTarget(LSL_Types.Quaternion rot, double error) { NotImplemented("llRotTarget"); return 0; } - public void llRotTargetRemove(int number) { NotImplemented("llRotTargetRemove"); } - public void llMoveToTarget(LSL_Types.Vector3 target, double tau) { NotImplemented("llMoveToTarget"); } - public void llStopMoveToTarget() { NotImplemented("llStopMoveToTarget"); } - public void llApplyImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyImpulse"); } - public void llApplyRotationalImpulse(LSL_Types.Vector3 force, int local) { NotImplemented("llApplyRotationalImpulse"); } - public void llSetTorque(LSL_Types.Vector3 torque, int local) { NotImplemented("llSetTorque"); } - public LSL_Types.Vector3 llGetTorque() { NotImplemented("llGetTorque"); return new LSL_Types.Vector3(); } - public void llSetForceAndTorque(LSL_Types.Vector3 force, LSL_Types.Vector3 torque, int local) { NotImplemented("llSetForceAndTorque"); } - public LSL_Types.Vector3 llGetVel() { NotImplemented("llGetVel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetAccel() { NotImplemented("llGetAccel"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetOmega() { NotImplemented("llGetOmega"); return new LSL_Types.Vector3(); } - public double llGetTimeOfDay() { NotImplemented("llGetTimeOfDay"); return 0; } - public double llGetWallclock() + public void llGiveInventory(string destination, string inventory) { - return DateTime.Now.TimeOfDay.TotalSeconds; + NotImplemented("llGiveInventory"); } - public double llGetTime() { NotImplemented("llGetTime"); return 0; } - public void llResetTime() { NotImplemented("llResetTime"); } - public double llGetAndResetTime() { NotImplemented("llGetAndResetTime"); return 0; } - public void llSound() { NotImplemented("llSound"); } - public void llPlaySound(string sound, double volume) { NotImplemented("llPlaySound"); } - public void llLoopSound(string sound, double volume) { NotImplemented("llLoopSound"); } - public void llLoopSoundMaster(string sound, double volume) { NotImplemented("llLoopSoundMaster"); } - public void llLoopSoundSlave(string sound, double volume) { NotImplemented("llLoopSoundSlave"); } - public void llPlaySoundSlave(string sound, double volume) { NotImplemented("llPlaySoundSlave"); } - public void llTriggerSound(string sound, double volume) { NotImplemented("llTriggerSound"); } - public void llStopSound() { NotImplemented("llStopSound"); } - public void llPreloadSound(string sound) { NotImplemented("llPreloadSound"); } + public void llRemoveInventory(string item) + { + NotImplemented("llRemoveInventory"); + } - public string llGetSubString(string src, int start, int end) + public void llSetText(string text, LSL_Types.Vector3 color, double alpha) { - return src.Substring(start, end); + Vector3 av3 = new Vector3((float) color.X, (float) color.Y, (float) color.Z); + m_host.SetText(text, av3, alpha); } - public string llDeleteSubString(string src, int start, int end) + + public double llWater(LSL_Types.Vector3 offset) { - return src.Remove(start, end - start); + NotImplemented("llWater"); + return 0; } - public string llInsertString(string dst, int position, string src) + + public void llPassTouches(int pass) { - return dst.Insert(position, src); + NotImplemented("llPassTouches"); } - public string llToUpper(string src) + + public string llRequestAgentData(string id, int data) { - return src.ToUpper(); + NotImplemented("llRequestAgentData"); + return ""; } - public string llToLower(string src) + public string llRequestInventoryData(string name) { - return src.ToLower(); + NotImplemented("llRequestInventoryData"); + return ""; } - public int llGiveMoney(string destination, int amount) { NotImplemented("llGiveMoney"); return 0; } - public void llMakeExplosion() { NotImplemented("llMakeExplosion"); } - public void llMakeFountain() { NotImplemented("llMakeFountain"); } - public void llMakeSmoke() { NotImplemented("llMakeSmoke"); } - public void llMakeFire() { NotImplemented("llMakeFire"); } - public void llRezObject(string inventory, LSL_Types.Vector3 pos, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezObject"); } - public void llLookAt(LSL_Types.Vector3 target, double strength, double damping) { NotImplemented("llLookAt"); } - public void llStopLookAt() { NotImplemented("llStopLookAt"); } + public void llSetDamage(double damage) + { + NotImplemented("llSetDamage"); + } - public void llSetTimerEvent(double sec) + public void llTeleportAgentHome(string agent) { - // Setting timer repeat - m_ScriptEngine.m_LSLLongCmdHandler.SetTimerEvent(m_localID, m_itemID, sec); + NotImplemented("llTeleportAgentHome"); } - public void llSleep(double sec) + public void llModifyLand(int action, int brush) { - System.Threading.Thread.Sleep((int)(sec * 1000)); } - public double llGetMass() { NotImplemented("llGetMass"); return 0; } - public void llCollisionFilter(string name, string id, int accept) { NotImplemented("llCollisionFilter"); } - public void llTakeControls(int controls, int accept, int pass_on) { NotImplemented("llTakeControls"); } - public void llReleaseControls() { NotImplemented("llReleaseControls"); } - public void llAttachToAvatar(int attachment) { NotImplemented("llAttachToAvatar"); } - public void llDetachFromAvatar() { NotImplemented("llDetachFromAvatar"); } - public void llTakeCamera() { NotImplemented("llTakeCamera"); } - public void llReleaseCamera() { NotImplemented("llReleaseCamera"); } + public void llCollisionSound(string impact_sound, double impact_volume) + { + NotImplemented("llCollisionSound"); + } - public string llGetOwner() + public void llCollisionSprite(string impact_sprite) { - return m_host.ObjectOwner.ToStringHyphenated(); + NotImplemented("llCollisionSprite"); } - public void llInstantMessage(string user, string message) { NotImplemented("llInstantMessage"); } - public void llEmail(string address, string subject, string message) { NotImplemented("llEmail"); } - public void llGetNextEmail(string address, string subject) { NotImplemented("llGetNextEmail"); } + public string llGetAnimation(string id) + { + NotImplemented("llGetAnimation"); + return ""; + } - public string llGetKey() + public void llResetScript() { - return m_host.UUID.ToStringHyphenated(); + m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); } - public void llSetBuoyancy(double buoyancy) { NotImplemented("llSetBuoyancy"); } - public void llSetHoverHeight(double height, int water, double tau) { NotImplemented("llSetHoverHeight"); } - public void llStopHover() { NotImplemented("llStopHover"); } - public void llMinEventDelay(double delay) { NotImplemented("llMinEventDelay"); } - public void llSoundPreload() { NotImplemented("llSoundPreload"); } - public void llRotLookAt(LSL_Types.Quaternion target, double strength, double damping) { NotImplemented("llRotLookAt"); } + public void llMessageLinked(int linknum, int num, string str, string id) + { + } - public int llStringLength(string str) + public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { - if (str.Length > 0) - { - return str.Length; - } - else - { - return 0; - } } - public void llStartAnimation(string anim) { NotImplemented("llStartAnimation"); } - public void llStopAnimation(string anim) { NotImplemented("llStopAnimation"); } - public void llPointAt() { NotImplemented("llPointAt"); } - public void llStopPointAt() { NotImplemented("llStopPointAt"); } - public void llTargetOmega(LSL_Types.Vector3 axis, double spinrate, double gain) { NotImplemented("llTargetOmega"); } - public int llGetStartParameter() { NotImplemented("llGetStartParameter"); return 0; } - public void llGodLikeRezObject(string inventory, LSL_Types.Vector3 pos) { NotImplemented("llGodLikeRezObject"); } - public void llRequestPermissions(string agent, int perm) { NotImplemented("llRequestPermissions"); } - public string llGetPermissionsKey() { NotImplemented("llGetPermissionsKey"); return ""; } - public int llGetPermissions() { NotImplemented("llGetPermissions"); return 0; } - public int llGetLinkNumber() { NotImplemented("llGetLinkNumber"); return 0; } - public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) { NotImplemented("llSetLinkColor"); } - public void llCreateLink(string target, int parent) { NotImplemented("llCreateLink"); } - public void llBreakLink(int linknum) { NotImplemented("llBreakLink"); } - public void llBreakAllLinks() { NotImplemented("llBreakAllLinks"); } - public string llGetLinkKey(int linknum) { NotImplemented("llGetLinkKey"); return ""; } - public void llGetLinkName(int linknum) { NotImplemented("llGetLinkName"); } - public int llGetInventoryNumber(int type) { NotImplemented("llGetInventoryNumber"); return 0; } - public string llGetInventoryName(int type, int number) { NotImplemented("llGetInventoryName"); return ""; } - public void llSetScriptState(string name, int run) { NotImplemented("llSetScriptState"); } - public double llGetEnergy() { return 1.0f; } - public void llGiveInventory(string destination, string inventory) { NotImplemented("llGiveInventory"); } - public void llRemoveInventory(string item) { NotImplemented("llRemoveInventory"); } + public void llPassCollisions(int pass) + { + } - public void llSetText(string text, LSL_Types.Vector3 color, double alpha) + public string llGetScriptName() { - Axiom.Math.Vector3 av3 = new Axiom.Math.Vector3((float)color.X, (float)color.Y, (float)color.Z); - m_host.SetText(text, av3, alpha); + return ""; } + public int llGetNumberOfSides() + { + return 0; + } - public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); return 0; } - public void llPassTouches(int pass) { NotImplemented("llPassTouches"); } - public string llRequestAgentData(string id, int data) { NotImplemented("llRequestAgentData"); return ""; } - public string llRequestInventoryData(string name) { NotImplemented("llRequestInventoryData"); return ""; } - public void llSetDamage(double damage) { NotImplemented("llSetDamage"); } - public void llTeleportAgentHome(string agent) { NotImplemented("llTeleportAgentHome"); } - public void llModifyLand(int action, int brush) { } - public void llCollisionSound(string impact_sound, double impact_volume) { NotImplemented("llCollisionSound"); } - public void llCollisionSprite(string impact_sprite) { NotImplemented("llCollisionSprite"); } - public string llGetAnimation(string id) { NotImplemented("llGetAnimation"); return ""; } - public void llResetScript() + public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { - m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); + return new LSL_Types.Quaternion(); } - public void llMessageLinked(int linknum, int num, string str, string id) { } - public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { } - public void llPassCollisions(int pass) { } - public string llGetScriptName() { return ""; } - public int llGetNumberOfSides() { return 0; } + public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) + { + return new LSL_Types.Vector3(); + } - public LSL_Types.Quaternion llAxisAngle2Rot(LSL_Types.Vector3 axis, double angle) { return new LSL_Types.Quaternion(); } - public LSL_Types.Vector3 llRot2Axis(LSL_Types.Quaternion rot) { return new LSL_Types.Vector3(); } - public void llRot2Angle() { } + public void llRot2Angle() + { + } public double llAcos(double val) { - return (double)Math.Acos(val); + return (double) Math.Acos(val); } public double llAsin(double val) { - return (double)Math.Asin(val); + return (double) Math.Asin(val); + } + + public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) + { + return 0; } - public double llAngleBetween(LSL_Types.Quaternion a, LSL_Types.Quaternion b) { return 0; } - public string llGetInventoryKey(string name) { return ""; } - public void llAllowInventoryDrop(int add) { } - public LSL_Types.Vector3 llGetSunDirection() { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetTextureOffset(int face) { return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGetTextureScale(int side) { return new LSL_Types.Vector3(); } - public double llGetTextureRot(int side) { return 0; } + public string llGetInventoryKey(string name) + { + return ""; + } + + public void llAllowInventoryDrop(int add) + { + } + + public LSL_Types.Vector3 llGetSunDirection() + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llGetTextureOffset(int face) + { + return new LSL_Types.Vector3(); + } + + public LSL_Types.Vector3 llGetTextureScale(int side) + { + return new LSL_Types.Vector3(); + } + + public double llGetTextureRot(int side) + { + return 0; + } public int llSubStringIndex(string source, string pattern) { return source.IndexOf(pattern); } - public string llGetOwnerKey(string id) { NotImplemented("llGetOwnerKey"); return ""; } + public string llGetOwnerKey(string id) + { + NotImplemented("llGetOwnerKey"); + return ""; + } - public LSL_Types.Vector3 llGetCenterOfMass() { NotImplemented("llGetCenterOfMass"); return new LSL_Types.Vector3(); } + public LSL_Types.Vector3 llGetCenterOfMass() + { + NotImplemented("llGetCenterOfMass"); + return new LSL_Types.Vector3(); + } public List llListSort(List src, int stride, int ascending) { @@ -577,7 +1213,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler ret.AddRange(ls); } - if (ascending == LSL.LSL_BaseClass.TRUE) + if (ascending == LSL_BaseClass.TRUE) return ret; ret.Reverse(); return ret; @@ -616,12 +1252,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler public LSL_Types.Vector3 llList2Vector(List src, int index) { - return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2])); + return + new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), + double.Parse(src[index + 2])); } + public LSL_Types.Quaternion llList2Rot(List src, int index) { - return new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]), double.Parse(src[index + 3])); + return + new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), + double.Parse(src[index + 2]), double.Parse(src[index + 3])); } + public List llList2List(List src, int start, int end) { if (end > start) @@ -638,18 +1280,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler ret.AddRange(src.GetRange(0, end)); return ret; } - - - - } + public List llDeleteSubList(List src, int start, int end) { List ret = new List(src); ret.RemoveRange(start, end - start); return ret; } - public int llGetListEntryType(List src, int index) { NotImplemented("llGetListEntryType"); return 0; } + + public int llGetListEntryType(List src, int index) + { + NotImplemented("llGetListEntryType"); + return 0; + } + public string llList2CSV(List src) { string ret = ""; @@ -661,6 +1306,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler } return ret; } + public List llCSV2List(string src) { List ret = new List(); @@ -670,6 +1316,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler } return ret; } + public List llListRandomize(List src, int stride) { int s = stride; @@ -711,9 +1358,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler } return ret; - - } + public List llList2ListStrided(List src, int start, int end, int stride) { List ret = new List(); @@ -739,12 +1385,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler public LSL_Types.Vector3 llGetRegionCorner() { - return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * 256, World.RegionInfo.RegionLocY * 256, 0); + return new LSL_Types.Vector3(World.RegionInfo.RegionLocX*256, World.RegionInfo.RegionLocY*256, 0); } public List llListInsertList(List dest, List src, int start) { - List ret = new List(dest); //foreach (string s in src.Reverse()) for (int ci = src.Count - 1; ci > -1; ci--) @@ -753,68 +1398,170 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler } return ret; } + public int llListFindList(List src, List test) { - foreach (string s in test) - { - for (int ci = 0; ci < src.Count; ci++) - { + foreach (string s in test) + { + for (int ci = 0; ci < src.Count; ci++) + { + if (s == src[ci]) + return ci; + } + } + return -1; + } + + public string llGetObjectName() + { + return m_host.Name; + } + + public void llSetObjectName(string name) + { + m_host.Name = name; + } + + public string llGetDate() + { + DateTime date = DateTime.Now.ToUniversalTime(); + string result = date.ToString("yyyy-MM-dd"); + return result; + } + + public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) + { + NotImplemented("llEdgeOfWorld"); + return 0; + } + + public int llGetAgentInfo(string id) + { + NotImplemented("llGetAgentInfo"); + return 0; + } + + public void llAdjustSoundVolume(double volume) + { + NotImplemented("llAdjustSoundVolume"); + } + + public void llSetSoundQueueing(int queue) + { + NotImplemented("llSetSoundQueueing"); + } + + public void llSetSoundRadius(double radius) + { + NotImplemented("llSetSoundRadius"); + } + + public string llKey2Name(string id) + { + NotImplemented("llKey2Name"); + return ""; + } + + public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) + { + NotImplemented("llSetTextureAnim"); + } + + public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, + LSL_Types.Vector3 bottom_south_west) + { + NotImplemented("llTriggerSoundLimited"); + } + + public void llEjectFromLand(string pest) + { + NotImplemented("llEjectFromLand"); + } + + public void llParseString2List() + { + NotImplemented("llParseString2List"); + } + + public int llOverMyLand(string id) + { + NotImplemented("llOverMyLand"); + return 0; + } + + public string llGetLandOwnerAt(LSL_Types.Vector3 pos) + { + NotImplemented("llGetLandOwnerAt"); + return ""; + } + + public string llGetNotecardLine(string name, int line) + { + NotImplemented("llGetNotecardLine"); + return ""; + } + + public LSL_Types.Vector3 llGetAgentSize(string id) + { + NotImplemented("llGetAgentSize"); + return new LSL_Types.Vector3(); + } + + public int llSameGroup(string agent) + { + NotImplemented("llSameGroup"); + return 0; + } + + public void llUnSit(string id) + { + NotImplemented("llUnSit"); + } - if (s == src[ci]) - return ci; - } - } - return -1; + public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) + { + NotImplemented("llGroundSlope"); + return new LSL_Types.Vector3(); } - public string llGetObjectName() + public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { - return m_host.Name; + NotImplemented("llGroundNormal"); + return new LSL_Types.Vector3(); } - public void llSetObjectName(string name) + public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { - m_host.Name = name; + NotImplemented("llGroundContour"); + return new LSL_Types.Vector3(); } - public string llGetDate() + public int llGetAttached() { - DateTime date = DateTime.Now.ToUniversalTime(); - string result = date.ToString("yyyy-MM-dd"); - return result; + NotImplemented("llGetAttached"); + return 0; } - public int llEdgeOfWorld(LSL_Types.Vector3 pos, LSL_Types.Vector3 dir) { NotImplemented("llEdgeOfWorld"); return 0; } - public int llGetAgentInfo(string id) { NotImplemented("llGetAgentInfo"); return 0; } - public void llAdjustSoundVolume(double volume) { NotImplemented("llAdjustSoundVolume"); } - public void llSetSoundQueueing(int queue) { NotImplemented("llSetSoundQueueing"); } - public void llSetSoundRadius(double radius) { NotImplemented("llSetSoundRadius"); } - public string llKey2Name(string id) { NotImplemented("llKey2Name"); return ""; } - public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { NotImplemented("llSetTextureAnim"); } - public void llTriggerSoundLimited(string sound, double volume, LSL_Types.Vector3 top_north_east, LSL_Types.Vector3 bottom_south_west) { NotImplemented("llTriggerSoundLimited"); } - public void llEjectFromLand(string pest) { NotImplemented("llEjectFromLand"); } - - public void llParseString2List() { NotImplemented("llParseString2List"); } - - public int llOverMyLand(string id) { NotImplemented("llOverMyLand"); return 0; } - public string llGetLandOwnerAt(LSL_Types.Vector3 pos) { NotImplemented("llGetLandOwnerAt"); return ""; } - public string llGetNotecardLine(string name, int line) { NotImplemented("llGetNotecardLine"); return ""; } - public LSL_Types.Vector3 llGetAgentSize(string id) { NotImplemented("llGetAgentSize"); return new LSL_Types.Vector3(); } - public int llSameGroup(string agent) { NotImplemented("llSameGroup"); return 0; } - public void llUnSit(string id) { NotImplemented("llUnSit"); } - public LSL_Types.Vector3 llGroundSlope(LSL_Types.Vector3 offset) { NotImplemented("llGroundSlope"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGroundNormal(LSL_Types.Vector3 offset) { NotImplemented("llGroundNormal"); return new LSL_Types.Vector3(); } - public LSL_Types.Vector3 llGroundContour(LSL_Types.Vector3 offset) { NotImplemented("llGroundContour"); return new LSL_Types.Vector3(); } - public int llGetAttached() { NotImplemented("llGetAttached"); return 0; } - public int llGetFreeMemory() { NotImplemented("llGetFreeMemory"); return 0; } + public int llGetFreeMemory() + { + NotImplemented("llGetFreeMemory"); + return 0; + } public string llGetRegionName() { return World.RegionInfo.RegionName; } - public double llGetRegionTimeDilation() { return 1.0f; } - public double llGetRegionFPS() { return 10.0f; } + public double llGetRegionTimeDilation() + { + return 1.0f; + } + + public double llGetRegionFPS() + { + return 10.0f; + } /* particle system rules should be coming into this routine as doubles, that is rule[0] should be an integer from this list and rule[1] should be the arg @@ -824,6 +1571,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler We iterate through the list for 'Count' elements, incrementing by two for each iteration and set the members of Primitive.ParticleSystem, one at a time. */ + public enum PrimitiveRule : int { PSYS_PART_FLAGS = 0, @@ -854,109 +1602,152 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); for (int i = 0; i < rules.Count; i += 2) { - switch ((int)rules[i]) + switch ((int) rules[i]) { - case (int)PrimitiveRule.PSYS_PART_FLAGS: - prules.PartFlags = (uint)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_FLAGS: + prules.PartFlags = (uint) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_START_COLOR: - prules.PartStartColor = (LLColor)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_START_COLOR: + prules.PartStartColor = (LLColor) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_START_ALPHA: + case (int) PrimitiveRule.PSYS_PART_START_ALPHA: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_END_COLOR: - prules.PartEndColor = (LLColor)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_END_COLOR: + prules.PartEndColor = (LLColor) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_END_ALPHA: + case (int) PrimitiveRule.PSYS_PART_END_ALPHA: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_START_SCALE: + case (int) PrimitiveRule.PSYS_PART_START_SCALE: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_END_SCALE: + case (int) PrimitiveRule.PSYS_PART_END_SCALE: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_PART_MAX_AGE: - prules.MaxAge = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_PART_MAX_AGE: + prules.MaxAge = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_ACCEL: + case (int) PrimitiveRule.PSYS_SRC_ACCEL: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_PATTERN: + case (int) PrimitiveRule.PSYS_SRC_PATTERN: //what is the cast? prules.PartStartColor = (LLColor)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_TEXTURE: - prules.Texture = (LLUUID)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_TEXTURE: + prules.Texture = (LLUUID) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_RATE: - prules.BurstRate = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_RATE: + prules.BurstRate = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_PART_COUNT: - prules.BurstPartCount = (byte)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_PART_COUNT: + prules.BurstPartCount = (byte) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_RADIUS: - prules.BurstRadius = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_RADIUS: + prules.BurstRadius = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MIN: - prules.BurstSpeedMin = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_SPEED_MIN: + prules.BurstSpeedMin = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_BURST_SPEED_MAX: - prules.BurstSpeedMax = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_BURST_SPEED_MAX: + prules.BurstSpeedMax = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_MAX_AGE: - prules.MaxAge = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_MAX_AGE: + prules.MaxAge = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_TARGET_KEY: - prules.Target = (LLUUID)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_TARGET_KEY: + prules.Target = (LLUUID) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_OMEGA: + case (int) PrimitiveRule.PSYS_SRC_OMEGA: //cast?? prules.MaxAge = (float)rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_ANGLE_BEGIN: - prules.InnerAngle = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_ANGLE_BEGIN: + prules.InnerAngle = (float) rules[i + 1]; break; - case (int)PrimitiveRule.PSYS_SRC_ANGLE_END: - prules.OuterAngle = (float)rules[i + 1]; + case (int) PrimitiveRule.PSYS_SRC_ANGLE_END: + prules.OuterAngle = (float) rules[i + 1]; break; - } } m_host.AddNewParticleSystem(prules); } - public void llGroundRepel(double height, int water, double tau) { NotImplemented("llGroundRepel"); } - public void llGiveInventoryList() { NotImplemented("llGiveInventoryList"); } - public void llSetVehicleType(int type) { NotImplemented("llSetVehicleType"); } - public void llSetVehicledoubleParam(int param, double value) { NotImplemented("llSetVehicledoubleParam"); } - public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) { NotImplemented("llSetVehicleVectorParam"); } - public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) { NotImplemented("llSetVehicleRotationParam"); } - public void llSetVehicleFlags(int flags) { NotImplemented("llSetVehicleFlags"); } - public void llRemoveVehicleFlags(int flags) { NotImplemented("llRemoveVehicleFlags"); } - public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) { NotImplemented("llSitTarget"); } - public string llAvatarOnSitTarget() { NotImplemented("llAvatarOnSitTarget"); return ""; } - public void llAddToLandPassList(string avatar, double hours) { NotImplemented("llAddToLandPassList"); } + public void llGroundRepel(double height, int water, double tau) + { + NotImplemented("llGroundRepel"); + } + + public void llGiveInventoryList() + { + NotImplemented("llGiveInventoryList"); + } + + public void llSetVehicleType(int type) + { + NotImplemented("llSetVehicleType"); + } + + public void llSetVehicledoubleParam(int param, double value) + { + NotImplemented("llSetVehicledoubleParam"); + } + + public void llSetVehicleVectorParam(int param, LSL_Types.Vector3 vec) + { + NotImplemented("llSetVehicleVectorParam"); + } + + public void llSetVehicleRotationParam(int param, LSL_Types.Quaternion rot) + { + NotImplemented("llSetVehicleRotationParam"); + } + + public void llSetVehicleFlags(int flags) + { + NotImplemented("llSetVehicleFlags"); + } + + public void llRemoveVehicleFlags(int flags) + { + NotImplemented("llRemoveVehicleFlags"); + } + + public void llSitTarget(LSL_Types.Vector3 offset, LSL_Types.Quaternion rot) + { + NotImplemented("llSitTarget"); + } + + public string llAvatarOnSitTarget() + { + NotImplemented("llAvatarOnSitTarget"); + return ""; + } + + public void llAddToLandPassList(string avatar, double hours) + { + NotImplemented("llAddToLandPassList"); + } public void llSetTouchText(string text) { @@ -968,49 +1759,91 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler m_host.SitName = text; } - public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraEyeOffset"); } - public void llSetCameraAtOffset(LSL_Types.Vector3 offset) { NotImplemented("llSetCameraAtOffset"); } - public void llDumpList2String() { NotImplemented("llDumpList2String"); } - public void llScriptDanger(LSL_Types.Vector3 pos) { NotImplemented("llScriptDanger"); } - public void llDialog(string avatar, string message, List buttons, int chat_channel) { NotImplemented("llDialog"); } - public void llVolumeDetect(int detect) { NotImplemented("llVolumeDetect"); } - public void llResetOtherScript(string name) { NotImplemented("llResetOtherScript"); } + public void llSetCameraEyeOffset(LSL_Types.Vector3 offset) + { + NotImplemented("llSetCameraEyeOffset"); + } + + public void llSetCameraAtOffset(LSL_Types.Vector3 offset) + { + NotImplemented("llSetCameraAtOffset"); + } + + public void llDumpList2String() + { + NotImplemented("llDumpList2String"); + } + + public void llScriptDanger(LSL_Types.Vector3 pos) + { + NotImplemented("llScriptDanger"); + } + + public void llDialog(string avatar, string message, List buttons, int chat_channel) + { + NotImplemented("llDialog"); + } + + public void llVolumeDetect(int detect) + { + NotImplemented("llVolumeDetect"); + } + + public void llResetOtherScript(string name) + { + NotImplemented("llResetOtherScript"); + } + + public int llGetScriptState(string name) + { + NotImplemented("llGetScriptState"); + return 0; + } - public int llGetScriptState(string name) { NotImplemented("llGetScriptState"); return 0; } + public void llRemoteLoadScript() + { + NotImplemented("llRemoteLoadScript"); + } + + public void llSetRemoteScriptAccessPin(int pin) + { + NotImplemented("llSetRemoteScriptAccessPin"); + } - public void llRemoteLoadScript() { NotImplemented("llRemoteLoadScript"); } - public void llSetRemoteScriptAccessPin(int pin) { NotImplemented("llSetRemoteScriptAccessPin"); } - public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) { NotImplemented("llRemoteLoadScriptPin"); } + public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) + { + NotImplemented("llRemoteLoadScriptPin"); + } // remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval) // Not sure where these constants should live: // REMOTE_DATA_CHANNEL = 1 // REMOTE_DATA_REQUEST = 2 // REMOTE_DATA_REPLY = 3 - public void llOpenRemoteDataChannel() { - + public void llOpenRemoteDataChannel() + { IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID); - object[] resobj = new object[] { 1, channelID.ToString(), LLUUID.Zero.ToString(), "", 0, "" }; + object[] resobj = new object[] {1, channelID.ToString(), LLUUID.Zero.ToString(), "", 0, ""}; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", resobj); - } - public string llSendRemoteData(string channel, string dest, int idata, string sdata) { NotImplemented("llSendRemoteData"); return ""; } + public string llSendRemoteData(string channel, string dest, int idata, string sdata) + { + NotImplemented("llSendRemoteData"); + return ""; + } public void llRemoteDataReply(string channel, string message_id, string sdata, int idata) { - IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); xmlrpcMod.RemoteDataReply(channel, message_id, sdata, idata); - } - - public void llCloseRemoteDataChannel(string channel) { + public void llCloseRemoteDataChannel(string channel) + { IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface(); xmlrpcMod.CloseXMLRPCChannel(channel); - } public string llMD5String(string src, int nonce) @@ -1018,14 +1851,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return Util.Md5Hash(src + ":" + nonce.ToString()); } - public void llSetPrimitiveParams(List rules) { NotImplemented("llSetPrimitiveParams"); } - public string llStringToBase64(string str) + public void llSetPrimitiveParams(List rules) { + NotImplemented("llSetPrimitiveParams"); + } + public string llStringToBase64(string str) + { try { byte[] encData_byte = new byte[str.Length]; - encData_byte = System.Text.Encoding.UTF8.GetBytes(str); + encData_byte = Encoding.UTF8.GetBytes(str); string encodedData = Convert.ToBase64String(encData_byte); return encodedData; } @@ -1037,11 +1873,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler public string llBase64ToString(string str) { - System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); - System.Text.Decoder utf8Decode = encoder.GetDecoder(); + UTF8Encoding encoder = new UTF8Encoding(); + Decoder utf8Decode = encoder.GetDecoder(); try { - byte[] todecode_byte = Convert.FromBase64String(str); int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); char[] decoded_char = new char[charCount]; @@ -1054,16 +1889,49 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler throw new Exception("Error in base64Decode" + e.Message); } } - public void llXorBase64Strings() { throw new Exception("Command deprecated! Use llXorBase64StringsCorrect instead."); } - public void llRemoteDataSetRegion() { NotImplemented("llRemoteDataSetRegion"); } - public double llLog10(double val) { return (double)Math.Log10(val); } - public double llLog(double val) { return (double)Math.Log(val); } - public List llGetAnimationList(string id) { NotImplemented("llGetAnimationList"); return new List(); } - public void llSetParcelMusicURL(string url) { NotImplemented("llSetParcelMusicURL"); } - public LSL_Types.Vector3 llGetRootPosition() { NotImplemented("llGetRootPosition"); return new LSL_Types.Vector3(); } + public void llXorBase64Strings() + { + throw new Exception("Command deprecated! Use llXorBase64StringsCorrect instead."); + } + + public void llRemoteDataSetRegion() + { + NotImplemented("llRemoteDataSetRegion"); + } + + public double llLog10(double val) + { + return (double) Math.Log10(val); + } + + public double llLog(double val) + { + return (double) Math.Log(val); + } + + public List llGetAnimationList(string id) + { + NotImplemented("llGetAnimationList"); + return new List(); + } + + public void llSetParcelMusicURL(string url) + { + NotImplemented("llSetParcelMusicURL"); + } + + public LSL_Types.Vector3 llGetRootPosition() + { + NotImplemented("llGetRootPosition"); + return new LSL_Types.Vector3(); + } - public LSL_Types.Quaternion llGetRootRotation() { NotImplemented("llGetRootRotation"); return new LSL_Types.Quaternion(); } + public LSL_Types.Quaternion llGetRootRotation() + { + NotImplemented("llGetRootRotation"); + return new LSL_Types.Quaternion(); + } public string llGetObjectDesc() { @@ -1080,20 +1948,55 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return m_host.ObjectCreator.ToStringHyphenated(); } - public string llGetTimestamp() { return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } - public void llSetLinkAlpha(int linknumber, double alpha, int face) { NotImplemented("llSetLinkAlpha"); } - public int llGetNumberOfPrims() { NotImplemented("llGetNumberOfPrims"); return 0; } - public string llGetNumberOfNotecardLines(string name) { NotImplemented("llGetNumberOfNotecardLines"); return ""; } - public List llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); return new List(); } - public LSL_Types.Vector3 llGetGeometricCenter() { NotImplemented("llGetGeometricCenter"); return new LSL_Types.Vector3(); } - public void llGetPrimitiveParams() { NotImplemented("llGetPrimitiveParams"); } + public string llGetTimestamp() + { + return DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); + } + + public void llSetLinkAlpha(int linknumber, double alpha, int face) + { + NotImplemented("llSetLinkAlpha"); + } + + public int llGetNumberOfPrims() + { + NotImplemented("llGetNumberOfPrims"); + return 0; + } + + public string llGetNumberOfNotecardLines(string name) + { + NotImplemented("llGetNumberOfNotecardLines"); + return ""; + } + + public List llGetBoundingBox(string obj) + { + NotImplemented("llGetBoundingBox"); + return new List(); + } + + public LSL_Types.Vector3 llGetGeometricCenter() + { + NotImplemented("llGetGeometricCenter"); + return new LSL_Types.Vector3(); + } + + public void llGetPrimitiveParams() + { + NotImplemented("llGetPrimitiveParams"); + } + public string llIntegerToBase64(int number) { - NotImplemented("llIntegerToBase64"); return ""; + NotImplemented("llIntegerToBase64"); + return ""; } + public int llBase64ToInteger(string str) { - NotImplemented("llBase64ToInteger"); return 0; + NotImplemented("llBase64ToInteger"); + return 0; } public double llGetGMTclock() @@ -1106,31 +2009,92 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return System.Environment.MachineName; } - public void llSetLocalRot(LSL_Types.Quaternion rot) { NotImplemented("llSetLocalRot"); } - public List llParseStringKeepNulls(string src, List seperators, List spacers) { NotImplemented("llParseStringKeepNulls"); return new List(); } - public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, LSL_Types.Quaternion rot, int param) { NotImplemented("llRezAtRoot"); } + public void llSetLocalRot(LSL_Types.Quaternion rot) + { + NotImplemented("llSetLocalRot"); + } + + public List llParseStringKeepNulls(string src, List seperators, List spacers) + { + NotImplemented("llParseStringKeepNulls"); + return new List(); + } + + public void llRezAtRoot(string inventory, LSL_Types.Vector3 position, LSL_Types.Vector3 velocity, + LSL_Types.Quaternion rot, int param) + { + NotImplemented("llRezAtRoot"); + } + + public int llGetObjectPermMask(int mask) + { + NotImplemented("llGetObjectPermMask"); + return 0; + } + + public void llSetObjectPermMask(int mask, int value) + { + NotImplemented("llSetObjectPermMask"); + } + + public void llGetInventoryPermMask(string item, int mask) + { + NotImplemented("llGetInventoryPermMask"); + } + + public void llSetInventoryPermMask(string item, int mask, int value) + { + NotImplemented("llSetInventoryPermMask"); + } + + public string llGetInventoryCreator(string item) + { + NotImplemented("llGetInventoryCreator"); + return ""; + } + + public void llOwnerSay(string msg) + { + NotImplemented("llOwnerSay"); + } + + public void llRequestSimulatorData(string simulator, int data) + { + NotImplemented("llRequestSimulatorData"); + } - public int llGetObjectPermMask(int mask) { NotImplemented("llGetObjectPermMask"); return 0; } + public void llForceMouselook(int mouselook) + { + NotImplemented("llForceMouselook"); + } - public void llSetObjectPermMask(int mask, int value) { NotImplemented("llSetObjectPermMask"); } + public double llGetObjectMass(string id) + { + NotImplemented("llGetObjectMass"); + return 0; + } - public void llGetInventoryPermMask(string item, int mask) { NotImplemented("llGetInventoryPermMask"); } - public void llSetInventoryPermMask(string item, int mask, int value) { NotImplemented("llSetInventoryPermMask"); } - public string llGetInventoryCreator(string item) { NotImplemented("llGetInventoryCreator"); return ""; } - public void llOwnerSay(string msg) { NotImplemented("llOwnerSay"); } - public void llRequestSimulatorData(string simulator, int data) { NotImplemented("llRequestSimulatorData"); } - public void llForceMouselook(int mouselook) { NotImplemented("llForceMouselook"); } - public double llGetObjectMass(string id) { NotImplemented("llGetObjectMass"); return 0; } - public void llListReplaceList() { NotImplemented("llListReplaceList"); } + public void llListReplaceList() + { + NotImplemented("llListReplaceList"); + } public void llLoadURL(string avatar_id, string message, string url) { LLUUID avatarId = new LLUUID(avatar_id); - m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message, url); + m_ScriptEngine.World.SendUrlToUser(avatarId, m_host.Name, m_host.UUID, m_host.ObjectOwner, false, message, + url); } - public void llParcelMediaCommandList(List commandList) { NotImplemented("llParcelMediaCommandList"); } - public void llParcelMediaQuery() { NotImplemented("llParcelMediaQuery"); } + public void llParcelMediaCommandList(List commandList) + { + NotImplemented("llParcelMediaCommandList"); + } + + public void llParcelMediaQuery() + { + NotImplemented("llParcelMediaQuery"); + } public int llModPow(int a, int b, int c) { @@ -1139,13 +2103,38 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return Convert.ToInt32(tmp); } - public int llGetInventoryType(string name) { NotImplemented("llGetInventoryType"); return 0; } + public int llGetInventoryType(string name) + { + NotImplemented("llGetInventoryType"); + return 0; + } + + public void llSetPayPrice(int price, List quick_pay_buttons) + { + NotImplemented("llSetPayPrice"); + } + + public LSL_Types.Vector3 llGetCameraPos() + { + NotImplemented("llGetCameraPos"); + return new LSL_Types.Vector3(); + } + + public LSL_Types.Quaternion llGetCameraRot() + { + NotImplemented("llGetCameraRot"); + return new LSL_Types.Quaternion(); + } + + public void llSetPrimURL() + { + NotImplemented("llSetPrimURL"); + } - public void llSetPayPrice(int price, List quick_pay_buttons) { NotImplemented("llSetPayPrice"); } - public LSL_Types.Vector3 llGetCameraPos() { NotImplemented("llGetCameraPos"); return new LSL_Types.Vector3(); } - public LSL_Types.Quaternion llGetCameraRot() { NotImplemented("llGetCameraRot"); return new LSL_Types.Quaternion(); } - public void llSetPrimURL() { NotImplemented("llSetPrimURL"); } - public void llRefreshPrimURL() { NotImplemented("llRefreshPrimURL"); } + public void llRefreshPrimURL() + { + NotImplemented("llRefreshPrimURL"); + } public string llEscapeURL(string url) { @@ -1170,21 +2159,60 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler return "llUnescapeURL: " + ex.ToString(); } } - public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) { NotImplemented("llMapDestination"); } - public void llAddToLandBanList(string avatar, double hours) { NotImplemented("llAddToLandBanList"); } - public void llRemoveFromLandPassList(string avatar) { NotImplemented("llRemoveFromLandPassList"); } - public void llRemoveFromLandBanList(string avatar) { NotImplemented("llRemoveFromLandBanList"); } - public void llSetCameraParams(List rules) { NotImplemented("llSetCameraParams"); } - public void llClearCameraParams() { NotImplemented("llClearCameraParams"); } - public double llListStatistics(int operation, List src) { NotImplemented("llListStatistics"); return 0; } + + public void llMapDestination(string simname, LSL_Types.Vector3 pos, LSL_Types.Vector3 look_at) + { + NotImplemented("llMapDestination"); + } + + public void llAddToLandBanList(string avatar, double hours) + { + NotImplemented("llAddToLandBanList"); + } + + public void llRemoveFromLandPassList(string avatar) + { + NotImplemented("llRemoveFromLandPassList"); + } + + public void llRemoveFromLandBanList(string avatar) + { + NotImplemented("llRemoveFromLandBanList"); + } + + public void llSetCameraParams(List rules) + { + NotImplemented("llSetCameraParams"); + } + + public void llClearCameraParams() + { + NotImplemented("llClearCameraParams"); + } + + public double llListStatistics(int operation, List src) + { + NotImplemented("llListStatistics"); + return 0; + } public int llGetUnixTime() { return Util.UnixTimeSinceEpoch(); } - public int llGetParcelFlags(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelFlags"); return 0; } - public int llGetRegionFlags() { NotImplemented("llGetRegionFlags"); return 0; } + public int llGetParcelFlags(LSL_Types.Vector3 pos) + { + NotImplemented("llGetParcelFlags"); + return 0; + } + + public int llGetRegionFlags() + { + NotImplemented("llGetRegionFlags"); + return 0; + } + public string llXorBase64StringsCorrect(string str1, string str2) { string ret = ""; @@ -1201,27 +2229,64 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler } return llStringToBase64(ret); } + public void llHTTPRequest(string url, List parameters, string body) { m_ScriptEngine.m_LSLLongCmdHandler.StartHttpRequest(m_localID, m_itemID, url, parameters, body); } - public void llResetLandBanList() { NotImplemented("llResetLandBanList"); } - public void llResetLandPassList() { NotImplemented("llResetLandPassList"); } - public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { NotImplemented("llGetParcelPrimCount"); return 0; } - public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelPrimOwners"); return new List(); } - public int llGetObjectPrimCount(string object_id) { NotImplemented("llGetObjectPrimCount"); return 0; } - public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) { NotImplemented("llGetParcelMaxPrims"); return 0; } - public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) { NotImplemented("llGetParcelDetails"); return new List(); } + + public void llResetLandBanList() + { + NotImplemented("llResetLandBanList"); + } + + public void llResetLandPassList() + { + NotImplemented("llResetLandPassList"); + } + + public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) + { + NotImplemented("llGetParcelPrimCount"); + return 0; + } + + public List llGetParcelPrimOwners(LSL_Types.Vector3 pos) + { + NotImplemented("llGetParcelPrimOwners"); + return new List(); + } + + public int llGetObjectPrimCount(string object_id) + { + NotImplemented("llGetObjectPrimCount"); + return 0; + } + + public int llGetParcelMaxPrims(LSL_Types.Vector3 pos, int sim_wide) + { + NotImplemented("llGetParcelMaxPrims"); + return 0; + } + + public List llGetParcelDetails(LSL_Types.Vector3 pos, List param) + { + NotImplemented("llGetParcelDetails"); + return new List(); + } // // OpenSim functions // - public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer) + public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, + int timer) { if (dynamicID == "") { - IDynamicTextureManager textureManager = this.World.RequestModuleInterface(); - LLUUID createdTexture = textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, this.m_host.UUID, contentType, url, extraParams, timer); + IDynamicTextureManager textureManager = World.RequestModuleInterface(); + LLUUID createdTexture = + textureManager.AddDynamicTextureURL(World.RegionInfo.RegionID, m_host.UUID, contentType, url, + extraParams, timer); return createdTexture.ToStringHyphenated(); } else @@ -1237,6 +2302,5 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler if (throwErrorOnNotImplemented) throw new NotImplementedException("Command not implemented: " + Command); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs index 8f0a591..85ac597 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs @@ -27,11 +27,8 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; using OpenSim.Framework; -using OpenSim.Region.Environment.Scenes.Scripting; namespace OpenSim.Region.ScriptEngine.DotNetEngine { @@ -39,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it. /// [Serializable] - class EventManager + internal class EventManager { private ScriptEngine myScriptEngine; //public IScriptHost TEMP_OBJECT_ID; @@ -55,7 +52,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine myScriptEngine.World.EventManager.OnObjectGrab += touch_start; myScriptEngine.World.EventManager.OnRezScript += OnRezScript; myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; - } public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) @@ -63,17 +59,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Add to queue for all scripts in ObjectID object //myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start"); //Console.WriteLine("touch_start localID: " + localID); - myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] { (int)1 }); + myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1}); } + public void OnRezScript(uint localID, LLUUID itemID, string script) { //myScriptEngine.myScriptManager.StartScript( // Path.Combine("ScriptEngines", "Default.lsl"), // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost() //); - Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length); + Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + + script.Length); myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script); } + public void OnRemoveScript(uint localID, LLUUID itemID) { //myScriptEngine.myScriptManager.StartScript( @@ -84,48 +83,138 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine myScriptEngine.m_ScriptManager.StopScript( localID, itemID - ); - + ); } // TODO: Replace placeholders below // These needs to be hooked up to OpenSim during init of this class // then queued in EventQueueManager. // When queued in EventQueueManager they need to be LSL compatible (name and params) - + //public void state_entry() { } // - public void state_exit() { } + public void state_exit() + { + } + //public void touch_start() { } - public void touch() { } - public void touch_end() { } - public void collision_start() { } - public void collision() { } - public void collision_end() { } - public void land_collision_start() { } - public void land_collision() { } - public void land_collision_end() { } - public void timer() { } - public void listen() { } - public void on_rez() { } - public void sensor() { } - public void no_sensor() { } - public void control() { } - public void money() { } - public void email() { } - public void at_target() { } - public void not_at_target() { } - public void at_rot_target() { } - public void not_at_rot_target() { } - public void run_time_permissions() { } - public void changed() { } - public void attach() { } - public void dataserver() { } - public void link_message() { } - public void moving_start() { } - public void moving_end() { } - public void object_rez() { } - public void remote_data() { } - public void http_response() { } + public void touch() + { + } + + public void touch_end() + { + } + + public void collision_start() + { + } + + public void collision() + { + } + + public void collision_end() + { + } + + public void land_collision_start() + { + } + + public void land_collision() + { + } + + public void land_collision_end() + { + } + + public void timer() + { + } + + public void listen() + { + } + + public void on_rez() + { + } + + public void sensor() + { + } + + public void no_sensor() + { + } + + public void control() + { + } + + public void money() + { + } + + public void email() + { + } + + public void at_target() + { + } + + public void not_at_target() + { + } + + public void at_rot_target() + { + } + + public void not_at_rot_target() + { + } + + public void run_time_permissions() + { + } + + public void changed() + { + } + + public void attach() + { + } + + public void dataserver() + { + } + + public void link_message() + { + } + + public void moving_start() + { + } + + public void moving_end() + { + } + + public void object_rez() + { + } + + public void remote_data() + { + } + public void http_response() + { + } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs index aa36ea2..d7491d9 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs @@ -27,12 +27,11 @@ */ /* Original code: Tedd Hansen */ using System; +using System.Collections; using System.Collections.Generic; -using System.Text; using System.Threading; -using System.Reflection; -using OpenSim.Region.Environment.Scenes.Scripting; using libsecondlife; +using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; namespace OpenSim.Region.ScriptEngine.DotNetEngine @@ -42,25 +41,30 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// Events are queued and executed in separate thread /// [Serializable] - class EventQueueManager + internal class EventQueueManager { /// /// List of threads processing event queue /// private List eventQueueThreads = new List(); + private object queueLock = new object(); // Mutex lock object + /// /// How many ms to sleep if queue is empty /// private int nothingToDoSleepms = 50; + /// /// How many threads to process queue with /// private int numberOfThreads = 2; + /// /// Queue containing events waiting to be executed /// private Queue eventQueue = new Queue(); + /// /// Queue item structure /// @@ -76,9 +80,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// List of localID locks for mutex processing of script events /// private List objectLocks = new List(); + private object tryLockLock = new object(); // Mutex lock object private ScriptEngine m_ScriptEngine; + public EventQueueManager(ScriptEngine _ScriptEngine) { m_ScriptEngine = _ScriptEngine; @@ -96,11 +102,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine EventQueueThread.Start(); } } + ~EventQueueManager() { - // Kill worker threads - foreach (Thread EventQueueThread in new System.Collections.ArrayList(eventQueueThreads)) + foreach (Thread EventQueueThread in new ArrayList(eventQueueThreads)) { if (EventQueueThread != null && EventQueueThread.IsAlive == true) { @@ -118,7 +124,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine eventQueueThreads.Clear(); // Todo: Clean up our queues eventQueue.Clear(); - } /// @@ -176,18 +181,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Execute function try { - m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.functionName, QIS.param); + m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, + QIS.functionName, QIS.param); } catch (Exception e) { // DISPLAY ERROR INWORLD string text = "Error executing script function \"" + QIS.functionName + "\":\r\n"; if (e.InnerException != null) - { // Send inner exception + { + // Send inner exception text += e.InnerException.Message.ToString(); } else - { // Send normal + { + // Send normal text += e.Message.ToString(); } try @@ -195,28 +203,33 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine if (text.Length > 1500) text = text.Substring(0, 1500); IScriptHost m_host = m_ScriptEngine.World.GetSceneObjectPart(QIS.localID); - //if (m_host != null) - //{ - m_ScriptEngine.World.SimChat(Helpers.StringToField(text), 1, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); - } catch { - //} - //else - //{ + //if (m_host != null) + //{ + m_ScriptEngine.World.SimChat(Helpers.StringToField(text), 1, 0, + m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + catch + { + //} + //else + //{ // T oconsole Console.WriteLine("Unable to send text in-world:\r\n" + text); } - } finally { ReleaseLock(QIS.localID); } } - } // Something in queue - } catch (ThreadAbortException tae) { + } + catch (ThreadAbortException tae) + { throw tae; - } catch (Exception e) { + } + catch (Exception e) + { Console.WriteLine("Exception in EventQueueThreadLoop: " + e.ToString()); } } // while @@ -283,15 +296,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine return; } - Dictionary.KeyCollection scriptKeys = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID); + Dictionary.KeyCollection scriptKeys = + m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID); - foreach ( LLUUID itemID in scriptKeys ) + foreach (LLUUID itemID in scriptKeys) { // Add to each script in that object // TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter? AddToScriptQueue(localID, itemID, FunctionName, param); } - } /// @@ -316,6 +329,5 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine eventQueue.Enqueue(QIS); } } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index e6c2c47..5061629 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs @@ -28,24 +28,23 @@ using System; using System.Collections.Generic; -using System.Text; using System.Threading; using libsecondlife; -using OpenSim.Region.ScriptEngine.Common; -using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules; namespace OpenSim.Region.ScriptEngine.DotNetEngine { /// /// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc. /// - class LSLLongCmdHandler + internal class LSLLongCmdHandler { private Thread cmdHandlerThread; private int cmdHandlerThreadCycleSleepms = 100; private ScriptEngine m_ScriptEngine; + public LSLLongCmdHandler(ScriptEngine _ScriptEngine) { m_ScriptEngine = _ScriptEngine; @@ -56,8 +55,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine cmdHandlerThread.Priority = ThreadPriority.BelowNormal; cmdHandlerThread.IsBackground = true; cmdHandlerThread.Start(); - } + ~LSLLongCmdHandler() { // Shut down thread @@ -72,7 +71,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } } } - catch { } + catch + { + } } private void CmdHandlerThreadLoop() @@ -124,8 +125,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public double interval; public DateTime next; } + private List Timers = new List(); private object TimerListLock = new object(); + public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) { Console.WriteLine("SetTimerEvent"); @@ -146,6 +149,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine Timers.Add(ts); } } + public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID) { // Remove from timer @@ -163,6 +167,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine Timers = NewTimers; } } + public void CheckTimerEvents() { // Nothing to do here? @@ -171,7 +176,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine lock (TimerListLock) { - // Go through all timers foreach (TimerClass ts in Timers) { @@ -179,7 +183,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) { // Add it to queue - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", + new object[] {}); // set next interval @@ -188,6 +193,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } } // lock } + #endregion #region HTTP REQUEST @@ -213,10 +219,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { // TODO: SEND REQUEST!!! } + public void Stop() { // TODO: Cancel any ongoing request } + public bool CheckResponse() { // TODO: Check if we got a response yet, return true if so -- false if not @@ -227,11 +235,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //response_status //response_metadata //response_body - } } + private List HttpRequests = new List(); private object HttpListLock = new object(); + public void StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) { Console.WriteLine("StartHttpRequest"); @@ -244,11 +253,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine htc.body = body; lock (HttpListLock) { - //ADD REQUEST HttpRequests.Add(htc); } } + public void StopHttpRequest(uint m_localID, LLUUID m_itemID) { // Remove from list @@ -272,6 +281,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine HttpRequests = NewHttpList; } } + public void CheckHttpRequests() { // Nothing to do here? @@ -282,68 +292,64 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { foreach (HttpClass ts in HttpRequests) { - if (ts.CheckResponse() == true) { // Add it to event queue //key request_id, integer status, list metadata, string body - object[] resobj = new object[] { ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body }; - m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", resobj); + object[] resobj = + new object[] + {ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body}; + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", + resobj); // Now stop it StopHttpRequest(ts.localID, ts.itemID); } } } // lock } + #endregion public void CheckXMLRPCRequests() { - IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface(); while (xmlrpc.hasRequests()) { RPCRequestInfo rInfo = xmlrpc.GetNextRequest(); - System.Console.WriteLine("PICKED REQUEST"); + Console.WriteLine("PICKED REQUEST"); //Deliver data to prim's remote_data handler - object[] resobj = new object[] { - 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), rInfo.GetStrVal() - }; + object[] resobj = new object[] + { + 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), + rInfo.GetStrVal() + }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", resobj - ); - + ); } - } public void CheckListeners() { - IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface(); while (comms.HasMessages()) { ListenerInfo lInfo = comms.GetNextMessage(); - System.Console.WriteLine("PICKED LISTENER"); + Console.WriteLine("PICKED LISTENER"); //Deliver data to prim's listen handler - object[] resobj = new object[] { - lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() - }; + object[] resobj = new object[] + { + lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() + }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( lInfo.GetLocalID(), lInfo.GetItemID(), "listen", resobj - ); - + ); } - } - - - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs index 0aa1a0b..00027ca 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/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.Region.ScriptEngine.DotNetEngine")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Region.ScriptEngine.DotNetEngine")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Region.ScriptEngine.DotNetEngine")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Region.ScriptEngine.DotNetEngine")] +[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("2842257e-6fde-4460-9368-4cde57fa9cc4")] + +[assembly : Guid("2842257e-6fde-4460-9368-4cde57fa9cc4")] // Version information for an assembly consists of the following four values: // @@ -31,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index 38bf746..eaa3a09 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -27,14 +27,10 @@ */ /* Original code: Tedd Hansen */ using System; -using System.Collections.Generic; -using System.Text; +using Nini.Config; using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Interfaces; -using libsecondlife; -using Nini.Config; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.ScriptEngine.DotNetEngine { @@ -42,17 +38,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// This is the root object for ScriptEngine /// [Serializable] - public class ScriptEngine :IRegionModule + public class ScriptEngine : IRegionModule { - - internal OpenSim.Region.Environment.Scenes.Scene World; - internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim - internal EventQueueManager m_EventQueueManager; // Executes events - internal ScriptManager m_ScriptManager; // Load, unload and execute scripts + internal Scene World; + internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim + internal EventQueueManager m_EventQueueManager; // Executes events + internal ScriptManager m_ScriptManager; // Load, unload and execute scripts internal AppDomainManager m_AppDomainManager; internal LSLLongCmdHandler m_LSLLongCmdHandler; - private OpenSim.Framework.Console.LogBase m_log; + private LogBase m_log; public ScriptEngine() { @@ -65,9 +60,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine get { return m_log; } } - public void InitializeEngine(OpenSim.Region.Environment.Scenes.Scene Sceneworld, OpenSim.Framework.Console.LogBase logger) + public void InitializeEngine(Scene Sceneworld, LogBase logger) { - World = Sceneworld; m_log = logger; @@ -84,10 +78,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Should we iterate the region for scripts that needs starting? // Or can we assume we are loaded before anything else so we can use proper events? - - } - + public void Shutdown() { // We are shutting down @@ -106,12 +98,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public void Initialise(Scene scene, IConfigSource config) { - this.InitializeEngine(scene, MainLog.Instance); + InitializeEngine(scene, MainLog.Instance); } public void PostInitialise() { - } public void Close() @@ -130,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 381fd8c..54a5ef5 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -28,19 +28,14 @@ /* Original code: Tedd Hansen */ using System; using System.Collections.Generic; -using System.Text; -using System.Threading; +using System.IO; using System.Reflection; -using System.Runtime.Remoting; -using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; +using System.Threading; +using libsecondlife; using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; -using OpenSim.Region.ScriptEngine.Common; -using libsecondlife; - namespace OpenSim.Region.ScriptEngine.DotNetEngine { @@ -53,16 +48,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public class ScriptManager { #region Declares + private Thread scriptLoadUnloadThread; private int scriptLoadUnloadThread_IdleSleepms = 100; private Queue loadQueue = new Queue(); private Queue unloadQueue = new Queue(); + private struct LoadStruct { public uint localID; public LLUUID itemID; public string script; } + private struct UnloadStruct { public uint localID; @@ -72,17 +70,20 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Object> // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! - internal Dictionary> Scripts = new Dictionary>(); + internal Dictionary> Scripts = + new Dictionary>(); + public Scene World { - get - { - return m_scriptEngine.World; - } + get { return m_scriptEngine.World; } } -#endregion + + #endregion + #region Object init/shutdown + private ScriptEngine m_scriptEngine; + public ScriptManager(ScriptEngine scriptEngine) { m_scriptEngine = scriptEngine; @@ -92,9 +93,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine scriptLoadUnloadThread.IsBackground = true; scriptLoadUnloadThread.Priority = ThreadPriority.BelowNormal; scriptLoadUnloadThread.Start(); - } - ~ScriptManager () + + ~ScriptManager() { // Abort load/unload thread try @@ -112,8 +113,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { } } + #endregion + #region Load / Unload scripts (Thread loop) + private void ScriptLoadUnloadThreadLoop() { try @@ -134,9 +138,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine UnloadStruct item = unloadQueue.Dequeue(); _StopScript(item.localID, item.itemID); } - - - } } catch (ThreadAbortException tae) @@ -145,21 +146,22 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine a = ""; // Expected } - } + #endregion + #region Helper functions + private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { - //Console.WriteLine("ScriptManager.CurrentDomain_AssemblyResolve: " + args.Name); return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null; - } - #endregion + #region Internal functions to keep track of script + internal Dictionary.KeyCollection GetScriptKeys(uint localID) { if (Scripts.ContainsKey(localID) == false) @@ -169,7 +171,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine Scripts.TryGetValue(localID, out Obj); return Obj.Keys; - } internal LSL_BaseClass GetScript(uint localID, LLUUID itemID) @@ -187,8 +188,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine Obj.TryGetValue(itemID, out Script); return Script; - } + internal void SetScript(uint localID, LLUUID itemID, LSL_BaseClass Script) { // Create object if it doesn't exist @@ -205,8 +206,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Add to object Obj.Add(itemID, Script); - } + internal void RemoveScript(uint localID, LLUUID itemID) { // Don't have that object? @@ -218,10 +219,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine Scripts.TryGetValue(localID, out Obj); if (Obj.ContainsKey(itemID) == true) Obj.Remove(itemID); - } + #endregion + #region Start/Stop/Reset script + /// /// Fetches, loads and hooks up a script to an objects events /// @@ -235,6 +238,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine ls.script = Script; loadQueue.Enqueue(ls); } + /// /// Disables and unloads a script /// @@ -247,6 +251,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine ls.itemID = itemID; unloadQueue.Enqueue(ls); } + public void ResetScript(uint localID, LLUUID itemID) { string script = GetScript(localID, itemID).SourceCode; @@ -267,12 +272,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine try { - - - - // Create a new instance of the compiler (currently we don't want reuse) - OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler(); + Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); // Compile (We assume LSL) ScriptSource = LSLCompiler.CompileFromLSLText(Script); //Console.WriteLine("Compilation of " + FileName + " done"); @@ -289,10 +290,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource); #if DEBUG - Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); + Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); #endif - CompiledScript.SourceCode = ScriptSource; + CompiledScript.SourceCode = ScriptSource; // Add it to our script memstruct SetScript(localID, itemID, CompiledScript); @@ -306,9 +307,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) { @@ -326,9 +325,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString()); } } - - - } private void _StopScript(uint localID, LLUUID itemID) @@ -359,19 +355,24 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Tell AppDomain that we have stopped script m_scriptEngine.m_AppDomainManager.StopScript(ad); } - catch(Exception e) + catch (Exception e) { - Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + ": " + e.ToString()); + Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + + ": " + e.ToString()); } } - private string ProcessYield(string FileName) + + private string ProcessYield(string FileName) { // TODO: Create a new assembly and copy old but insert Yield Code //return TempDotNetMicroThreadingCodeInjector.TestFix(FileName); return FileName; } + #endregion + #region Perform event execution in script + /// /// Execute a LL-event-function in Script /// @@ -381,7 +382,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// Arguments to pass to function internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args) { - // Execute a function in the script //m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName); LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID); @@ -390,28 +390,29 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Must be done in correct AppDomain, so leaving it up to the script itself Script.Exec.ExecuteEvent(FunctionName, args); - } + #endregion #region Script serialization/deserialization + public void GetSerializedScript(uint localID, LLUUID itemID) { // Serialize the script and return it // Should not be a problem - System.IO.FileStream fs = System.IO.File.Create("SERIALIZED_SCRIPT_" + itemID); + FileStream fs = File.Create("SERIALIZED_SCRIPT_" + itemID); BinaryFormatter b = new BinaryFormatter(); - b.Serialize(fs, GetScript(localID,itemID)); + b.Serialize(fs, GetScript(localID, itemID)); fs.Close(); - - } + public void PutSerializedScript(uint localID, LLUUID itemID) { // Deserialize the script and inject it into an AppDomain // How to inject into an AppDomain? } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs index 8f935f1..072c249 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/TempDotNetMicroThreadingCodeInjector.cs @@ -27,12 +27,9 @@ */ using System; -using System.Collections.Generic; -using System.Text; -using Rail.Transformation; +using System.IO; using Rail.Reflect; -using Rail.Exceptions; -using Rail.MSIL; +using Rail.Transformation; namespace OpenSim.Region.ScriptEngine.DotNetEngine { @@ -40,25 +37,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine /// Tedds Sandbox for RAIL/microtrheading. This class is only for testing purposes! /// Its offspring will be the actual implementation. /// - class TempDotNetMicroThreadingCodeInjector + internal class TempDotNetMicroThreadingCodeInjector { public static string TestFix(string FileName) { - string ret = System.IO.Path.GetFileNameWithoutExtension(FileName + "_fixed.dll"); + string ret = Path.GetFileNameWithoutExtension(FileName + "_fixed.dll"); Console.WriteLine("Loading: \"" + FileName + "\""); RAssemblyDef rAssembly = RAssemblyDef.LoadAssembly(FileName); - + //Get the type of the method to copy from assembly Teste2.exe to assembly Teste.exe - RTypeDef type = (RTypeDef)rAssembly.RModuleDef.GetType("SecondLife.Script"); + RTypeDef type = (RTypeDef) rAssembly.RModuleDef.GetType("SecondLife.Script"); //Get the methods in the type RMethod[] m = type.GetMethods(); //Create a MethodPrologueAdder visitor object with the method to add //and with the flag that enables local variable creation set to true - MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef)m[0], true); + MethodPrologueAdder mpa = new MethodPrologueAdder((RMethodDef) m[0], true); //Apply the changes to the assembly rAssembly.Accept(mpa); @@ -67,7 +64,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine rAssembly.SaveAssembly(ret); return ret; - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index 729db7e..1b16a07 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs @@ -29,10 +29,11 @@ using System; using System.Collections.Generic; using System.Data; +using System.IO; using libsecondlife; using Mono.Data.SqliteClient; -using OpenSim.Framework.Console; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -55,6 +56,7 @@ namespace OpenSim.DataStore.MonoSqlite * Public Interface Functions * **********************************************************************/ + public void Initialise(string dbfile, string dbname) { string connectionString = "URI=file:" + dbfile + ",version=3"; @@ -80,17 +82,18 @@ namespace OpenSim.DataStore.MonoSqlite // 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); ds.Tables.Add(createTerrainTable()); setupTerrainCommands(terrainDa, conn); - + // WORKAROUND: This is a work around for sqlite on // windows, which gets really unhappy with blob columns // that have no sample data in them. At some point we @@ -118,7 +121,8 @@ namespace OpenSim.DataStore.MonoSqlite 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); @@ -136,11 +140,12 @@ namespace OpenSim.DataStore.MonoSqlite 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) { @@ -149,7 +154,7 @@ namespace OpenSim.DataStore.MonoSqlite row.Delete(); } } - + Commit(); } @@ -165,16 +170,18 @@ namespace OpenSim.DataStore.MonoSqlite 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(); @@ -186,12 +193,13 @@ namespace OpenSim.DataStore.MonoSqlite } 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); } @@ -205,7 +213,8 @@ namespace OpenSim.DataStore.MonoSqlite } 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); @@ -228,46 +237,48 @@ namespace OpenSim.DataStore.MonoSqlite public void StoreTerrain(double[,] ter, LLUUID regionID) { - int revision = OpenSim.Framework.Util.UnixTimeSinceEpoch(); + int revision = Util.UnixTimeSinceEpoch(); MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); DataTable terrain = ds.Tables["terrain"]; - lock (ds) { + lock (ds) + { DataRow newrow = terrain.NewRow(); fillTerrainRow(newrow, regionID, revision, ter); terrain.Rows.Add(newrow); - + Commit(); } } public double[,] LoadTerrain(LLUUID regionID) { - double[,] terret = new double[256, 256]; + double[,] terret = new double[256,256]; terret.Initialize(); DataTable terrain = ds.Tables["terrain"]; - - lock (ds) { - DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'","Revision DESC"); - + + lock (ds) + { + DataRow[] rows = terrain.Select("RegionUUID = '" + regionID.ToString() + "'", "Revision DESC"); + int rev = 0; if (rows.Length > 0) { 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 { @@ -275,7 +286,7 @@ namespace OpenSim.DataStore.MonoSqlite return null; } - + MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); } @@ -284,12 +295,10 @@ namespace OpenSim.DataStore.MonoSqlite public void RemoveLandObject(uint id) { - } public void StoreParcel(Land parcel) { - } public List LoadLandObjects() @@ -299,7 +308,8 @@ namespace OpenSim.DataStore.MonoSqlite public void Commit() { - lock (ds) { + lock (ds) + { primDa.Update(ds, "prims"); shapeDa.Update(ds, "primshapes"); terrainDa.Update(ds, "terrain"); @@ -320,7 +330,7 @@ namespace OpenSim.DataStore.MonoSqlite * **********************************************************************/ - 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); @@ -330,9 +340,9 @@ namespace OpenSim.DataStore.MonoSqlite { DataTable terrain = new DataTable("terrain"); - createCol(terrain, "RegionUUID", typeof(System.String)); - createCol(terrain, "Revision", typeof(System.Int32)); - createCol(terrain, "Heightfield", typeof(System.Byte[])); + createCol(terrain, "RegionUUID", typeof (String)); + createCol(terrain, "Revision", typeof (Int32)); + createCol(terrain, "Heightfield", typeof (Byte[])); return terrain; } @@ -341,52 +351,52 @@ namespace OpenSim.DataStore.MonoSqlite { 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)); // Add in contraints - prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; + prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; return prims; } @@ -394,40 +404,40 @@ namespace OpenSim.DataStore.MonoSqlite 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; } @@ -446,23 +456,23 @@ namespace OpenSim.DataStore.MonoSqlite // 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"]); @@ -510,8 +520,8 @@ namespace OpenSim.DataStore.MonoSqlite row["RegionUUID"] = regionUUID; row["Revision"] = rev; - System.IO.MemoryStream str = new System.IO.MemoryStream(65536 * sizeof(double)); - System.IO.BinaryWriter bw = new System.IO.BinaryWriter(str); + MemoryStream str = new MemoryStream(65536*sizeof (double)); + BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions for (int x = 0; x < 256; x++) @@ -599,8 +609,8 @@ 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 - s.TextureEntry = (byte[])row["Texture"]; - s.ExtraParams = (byte[])row["ExtraParams"]; + s.TextureEntry = (byte[]) row["Texture"]; + s.ExtraParams = (byte[]) row["ExtraParams"]; // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); // string texture = encoding.GetString((Byte[])row["Texture"]); // if (!texture.StartsWith("<")) @@ -751,7 +761,8 @@ namespace OpenSim.DataStore.MonoSqlite 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; @@ -778,7 +789,8 @@ namespace OpenSim.DataStore.MonoSqlite 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 + " " + sqliteType(col.DataType); @@ -812,7 +824,7 @@ namespace OpenSim.DataStore.MonoSqlite /// for us. /// ///a built sqlite parameter - private SqliteParameter createSqliteParameter(string name, System.Type type) + private SqliteParameter createSqliteParameter(string name, Type type) { SqliteParameter param = new SqliteParameter(); param.ParameterName = ":" + name; @@ -831,7 +843,7 @@ namespace OpenSim.DataStore.MonoSqlite da.UpdateCommand.Connection = conn; SqliteCommand delete = new SqliteCommand("delete from prims where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -851,7 +863,7 @@ namespace OpenSim.DataStore.MonoSqlite da.UpdateCommand.Connection = conn; SqliteCommand delete = new SqliteCommand("delete from primshapes where UUID = :UUID"); - delete.Parameters.Add(createSqliteParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqliteParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -871,8 +883,9 @@ namespace OpenSim.DataStore.MonoSqlite { pcmd.ExecuteNonQuery(); } - catch (SqliteSyntaxException) { - MainLog.Instance.Warn("SQLITE","Primitives Table Already Exists"); + catch (SqliteSyntaxException) + { + MainLog.Instance.Warn("SQLITE", "Primitives Table Already Exists"); } try @@ -912,7 +925,7 @@ namespace OpenSim.DataStore.MonoSqlite sDa.Fill(tmpDS, "primshapes"); tDa.Fill(tmpDS, "terrain"); } - catch (Mono.Data.SqliteClient.SqliteSyntaxException) + catch (SqliteSyntaxException) { MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); InitDB(conn); @@ -957,27 +970,27 @@ namespace OpenSim.DataStore.MonoSqlite 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.Byte; } - 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; } @@ -991,19 +1004,19 @@ namespace OpenSim.DataStore.MonoSqlite // slightly differently. private string sqliteType(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 "blob"; } @@ -1013,4 +1026,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 f726ea2..4e1f71e 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs @@ -26,21 +26,16 @@ * */ -using System; using System.Collections.Generic; -using System.Text; - -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Framework.Console; using libsecondlife; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.LandManagement; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.DataStore.NullStorage { public class NullDataStore : IRegionDataStore { - public void Initialise(string dbfile, string dbname) { return; @@ -48,12 +43,10 @@ namespace OpenSim.DataStore.NullStorage public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) { - } public void RemoveObject(LLUUID obj, LLUUID regionUUID) { - } public List LoadObjects(LLUUID regionUUID) @@ -63,7 +56,6 @@ namespace OpenSim.DataStore.NullStorage public void StoreTerrain(double[,] ter, LLUUID regionID) { - } public double[,] LoadTerrain(LLUUID regionID) @@ -73,12 +65,10 @@ namespace OpenSim.DataStore.NullStorage public void RemoveLandObject(uint id) { - } public void StoreParcel(Land land) { - } public List LoadLandObjects() @@ -88,7 +78,6 @@ namespace OpenSim.DataStore.NullStorage public void Shutdown() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs index fd86315..7608202 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/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.DataStore.NullStorage")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.DataStore.NullStorage")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.DataStore.NullStorage")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.DataStore.NullStorage")] +[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("b4a1656d-de22-4080-a970-fd8166acbf16")] + +[assembly : Guid("b4a1656d-de22-4080-a970-fd8166acbf16")] // Version information for an assembly consists of the following four values: // @@ -31,5 +33,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs index e1c3191..e531f01 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -27,25 +27,29 @@ */ 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.Region.Terrain.BasicTerrain")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] + +[assembly : AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")] +[assembly : AssemblyDescription("")] +[assembly : AssemblyConfiguration("")] +[assembly : AssemblyCompany("")] +[assembly : AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")] +[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("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")] + +[assembly : Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")] // Version information for an assembly consists of the following four values: // @@ -56,5 +60,6 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[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/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index c8c6e51..bbbb4d7 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs @@ -29,11 +29,11 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; +using System.Globalization; using System.IO; +using System.Threading; using libTerrain; using OpenJPEGNet; -using OpenSim.Framework.Interfaces; -using System.Globalization; using OpenSim.Framework; namespace OpenSim.Region.Terrain @@ -51,7 +51,7 @@ namespace OpenSim.Region.Terrain public class TerrainEngine { - public static System.Threading.Mutex fileIOLock = new System.Threading.Mutex(); + public static Mutex fileIOLock = new Mutex(); /// /// Plugin library for scripts @@ -95,12 +95,13 @@ namespace OpenSim.Region.Terrain /// public int tainted; - int w, h; + private int w, h; /// /// Used to determine what offset to use when loading singular heightmaps across multiple sims /// private int offsetX; + private int offsetY; @@ -139,13 +140,13 @@ namespace OpenSim.Region.Terrain public bool Tainted(int x, int y) { - return (heightmap.diff[x / 16, y / 16] != 0); + return (heightmap.diff[x/16, y/16] != 0); } public void ResetTaint() { tainted = 0; - heightmap.diff = new int[w / 16, h / 16]; + heightmap.diff = new int[w/16,h/16]; } //Testing to see if moving the TerraForming packet handling code into here works well @@ -158,40 +159,40 @@ namespace OpenSim.Region.Terrain /// The action to be performed /// Distance from the north border where the cursor is located /// Distance from the west border where the cursor is located - public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser) + public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + IClientAPI remoteUser) { - // Shiny. - double size = (double)(1 << brushsize); + double size = (double) (1 << brushsize); switch (action) { case 0: // flatten terrain - this.FlattenTerrain(west, north, size, (double)seconds / 5.0); + FlattenTerrain(west, north, size, (double) seconds/5.0); break; case 1: // raise terrain - this.RaiseTerrain(west, north, size, (double)seconds / 5.0); + RaiseTerrain(west, north, size, (double) seconds/5.0); break; case 2: //lower terrain - this.LowerTerrain(west, north, size, (double)seconds / 5.0); + LowerTerrain(west, north, size, (double) seconds/5.0); break; case 3: // smooth terrain - this.SmoothTerrain(west, north, size, (double)seconds / 5.0); + SmoothTerrain(west, north, size, (double) seconds/5.0); break; case 4: // noise - this.NoiseTerrain(west, north, size, (double)seconds / 5.0); + NoiseTerrain(west, north, size, (double) seconds/5.0); break; case 5: // revert - this.RevertTerrain(west, north, size, (double)seconds / 5.0); + RevertTerrain(west, north, size, (double) seconds/5.0); break; - // CLIENT EXTENSIONS GO HERE + // CLIENT EXTENSIONS GO HERE case 128: // erode-thermal break; @@ -207,9 +208,9 @@ namespace OpenSim.Region.Terrain { for (int y = 0; y < 16; y++) { - if (this.Tainted(x * 16, y * 16)) + if (Tainted(x*16, y*16)) { - remoteUser.SendLayerData(x, y, this.GetHeights1D()); + remoteUser.SendLayerData(x, y, GetHeights1D()); } } } @@ -249,12 +250,12 @@ namespace OpenSim.Region.Terrain /// A float[65536] array containing the heightmap public float[] GetHeights1D() { - float[] heights = new float[w * h]; + float[] heights = new float[w*h]; int i; - for (i = 0; i < w * h; i++) + for (i = 0; i < w*h; i++) { - heights[i] = (float)heightmap.map[i % w, i / w]; + heights[i] = (float) heightmap.map[i%w, i/w]; } return heights; @@ -266,13 +267,13 @@ namespace OpenSim.Region.Terrain /// An array of 256,256 values containing the heightmap public float[,] GetHeights2D() { - float[,] heights = new float[w, h]; + float[,] heights = new float[w,h]; int x, y; for (x = 0; x < w; x++) { for (y = 0; y < h; y++) { - heights[x, y] = (float)heightmap.map[x, y]; + heights[x, y] = (float) heightmap.map[x, y]; } } return heights; @@ -294,9 +295,9 @@ namespace OpenSim.Region.Terrain public void GetHeights1D(float[] heights) { int i; - for (i = 0; i < w * h; i++) + for (i = 0; i < w*h; i++) { - heightmap.map[i % w, i / w] = heights[i]; + heightmap.map[i%w, i/w] = heights[i]; } tainted++; @@ -313,7 +314,7 @@ namespace OpenSim.Region.Terrain { for (y = 0; y < h; y++) { - heightmap.Set(x, y, (double)heights[x, y]); + heightmap.Set(x, y, (double) heights[x, y]); } } SaveRevertMap(); @@ -376,28 +377,36 @@ namespace OpenSim.Region.Terrain try { - switch (command) { case "help": resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; - resultText += "terrain hills \n"; + resultText += + "terrain hills \n"; resultText += " type should be spheres, blocks, cones, or squared\n"; - resultText += "terrain voronoi - generates a worley fractal with X points per block"; + resultText += + "terrain voronoi - generates a worley fractal with X points per block"; resultText += "terrain seed - sets the random seed value to \n"; - resultText += "terrain load - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; - resultText += "terrain save - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n"; - resultText += "terrain save grdmap - creates a PNG snapshot of the region using a named gradient map\n"; - resultText += "terrain rescale - rescales a terrain to be between and meters high\n"; + resultText += + "terrain load - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; + resultText += + "terrain save - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n"; + resultText += + "terrain save grdmap - creates a PNG snapshot of the region using a named gradient map\n"; + resultText += + "terrain rescale - rescales a terrain to be between and meters high\n"; resultText += "terrain fill - fills a terrain at the specified height\n"; - resultText += "terrain erode aerobic \n"; + resultText += + "terrain erode aerobic \n"; resultText += "terrain erode thermal \n"; resultText += "terrain erode hydraulic \n"; resultText += "terrain multiply - multiplies a terrain by \n"; resultText += "terrain revert - reverts the terrain to the stored original\n"; resultText += "terrain bake - saves the current terrain into the revert map\n"; - resultText += "terrain csfilter - loads a new filter from the specified .cs file\n"; - resultText += "terrain jsfilter - loads a new filter from the specified .js file\n"; + resultText += + "terrain csfilter - loads a new filter from the specified .cs file\n"; + resultText += + "terrain jsfilter - loads a new filter from the specified .js file\n"; foreach (KeyValuePair filter in customFilters.filters) { resultText += filter.Value.Help(); @@ -466,8 +475,8 @@ namespace OpenSim.Region.Terrain case "load": string filenameL = args[2].Replace("%name%", simName); - filenameL = filenameL.Replace("%x%", this.offsetX.ToString()); - filenameL = filenameL.Replace("%y%", this.offsetY.ToString()); + filenameL = filenameL.Replace("%x%", offsetX.ToString()); + filenameL = filenameL.Replace("%y%", offsetY.ToString()); switch (args[1].ToLower()) { @@ -499,11 +508,11 @@ namespace OpenSim.Region.Terrain { case "f32": LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), - Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); + Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); break; case "img": LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), - Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); + Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); break; default: resultText = "Unknown or unsupported image or data format"; @@ -513,8 +522,8 @@ namespace OpenSim.Region.Terrain case "save": string filename = args[2].Replace("%name%", simName); - filename = filename.Replace("%x%", this.offsetX.ToString()); - filename = filename.Replace("%y%", this.offsetY.ToString()); + filename = filename.Replace("%x%", offsetX.ToString()); + filename = filename.Replace("%y%", offsetY.ToString()); switch (args[1].ToLower()) { @@ -589,15 +598,20 @@ namespace OpenSim.Region.Terrain { case "aerobic": // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest - heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]), Convert.ToBoolean(args[8])); + heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), + Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), + Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]), + Convert.ToBoolean(args[8])); break; case "thermal": - heightmap.ThermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); + heightmap.ThermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), + Convert.ToDouble(args[4])); break; case "hydraulic": Channel rainMap = new Channel(w, h); rainMap.Fill(Convert.ToDouble(args[2])); - heightmap.HydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); + heightmap.HydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), + Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); break; default: resultText = "Unknown erosion type"; @@ -624,8 +638,10 @@ namespace OpenSim.Region.Terrain if (args.GetLength(0) > 2) { int.TryParse(args[2].ToString(), out count); - double.TryParse(args[3].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out sizeMin); - double.TryParse(args[4].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out sizeRange); + double.TryParse(args[3].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, + out sizeMin); + double.TryParse(args[4].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, + out sizeRange); bool.TryParse(args[5].ToString(), out island); bool.TryParse(args[6].ToString(), out additive); bool.TryParse(args[7].ToString(), out noisy); @@ -669,7 +685,7 @@ namespace OpenSim.Region.Terrain /// Maximum value of the new array public void SetRange(float min, float max) { - heightmap.Normalise((double)min, (double)max); + heightmap.Normalise((double) min, (double) max); tainted++; } @@ -713,7 +729,7 @@ namespace OpenSim.Region.Terrain { for (x = 0; x < w; x++) { - heightmap.map[x, y] = (double)bs.ReadSingle(); + heightmap.map[x, y] = (double) bs.ReadSingle(); } } @@ -736,11 +752,10 @@ namespace OpenSim.Region.Terrain fileIOLock.WaitOne(); try { + int sectionToLoadX = ((offsetX - lowerboundX)*w); + int sectionToLoadY = ((offsetY - lowerboundY)*h); - int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w); - int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h); - - double[,] tempMap = new double[dimensionX, dimensionY]; + double[,] tempMap = new double[dimensionX,dimensionY]; FileInfo file = new FileInfo(filename); FileStream s = file.Open(FileMode.Open, FileAccess.Read); @@ -751,7 +766,7 @@ namespace OpenSim.Region.Terrain { for (y = 0; y < dimensionY; y++) { - tempMap[x, y] = (double)bs.ReadSingle(); + tempMap[x, y] = (double) bs.ReadSingle(); } } @@ -784,19 +799,19 @@ namespace OpenSim.Region.Terrain /// Where sim coords begin for this patch public void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY) { - int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w); - int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h); + int sectionToLoadX = ((offsetX - lowerboundX)*w); + int sectionToLoadY = ((offsetY - lowerboundY)*h); - double[,] tempMap = new double[dimensionX, dimensionY]; + double[,] tempMap = new double[dimensionX,dimensionY]; - System.Drawing.Bitmap lgrBmp = new Bitmap(filename); + Bitmap lgrBmp = new Bitmap(filename); int x, y; for (x = 0; x < dimensionX; x++) { for (y = 0; y < dimensionY; y++) { - tempMap[x, y] = (float)lgrBmp.GetPixel(x, y).GetBrightness(); + tempMap[x, y] = (float) lgrBmp.GetPixel(x, y).GetBrightness(); } } @@ -826,7 +841,7 @@ namespace OpenSim.Region.Terrain { for (x = 0; x < w; x++) { - heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0); + heightmap.map[x, y] = (double) bs.ReadByte()*((double) bs.ReadByte()/127.0); bs.ReadBytes(11); // Advance the stream to next bytes. } } @@ -875,7 +890,7 @@ namespace OpenSim.Region.Terrain { for (x = 0; x < w; x++) { - bs.Write((float)heightmap.Get(x, y)); + bs.Write((float) heightmap.Get(x, y)); } } @@ -897,27 +912,27 @@ namespace OpenSim.Region.Terrain int x, y; // Used for the 'green' channel. - byte avgMultiplier = (byte)heightmap.Avg(); - byte backupMultiplier = (byte)revertmap.Avg(); + byte avgMultiplier = (byte) heightmap.Avg(); + byte backupMultiplier = (byte) revertmap.Avg(); // Limit the multiplier so it can represent points >64m. if (avgMultiplier > 196) avgMultiplier = 196; - if(backupMultiplier > 196) + if (backupMultiplier > 196) backupMultiplier = 196; // Make sure it's at least one to prevent a div by zero if (avgMultiplier < 1) avgMultiplier = 1; - if(backupMultiplier < 1) + if (backupMultiplier < 1) backupMultiplier = 1; for (y = 0; y < h; y++) { for (x = 0; x < h; x++) { - byte red = (byte)(heightmap.Get(x, y) / ((double)avgMultiplier / 128.0)); + byte red = (byte) (heightmap.Get(x, y)/((double) avgMultiplier/128.0)); byte green = avgMultiplier; - byte blue = (byte)watermap.Get(x, y); + byte blue = (byte) watermap.Get(x, y); byte alpha1 = 0; // Land Parcels byte alpha2 = 0; // For Sale Land byte alpha3 = 0; // Public Edit Object @@ -926,7 +941,7 @@ namespace OpenSim.Region.Terrain byte alpha6 = 255; // Flying Allowed byte alpha7 = 255; // Create Landmark byte alpha8 = 255; // Outside Scripts - byte alpha9 = (byte)(revertmap.Get(x, y) / ((double)backupMultiplier / 128.0)); + byte alpha9 = (byte) (revertmap.Get(x, y)/((double) backupMultiplier/128.0)); byte alpha10 = backupMultiplier; binStream.Write(red); @@ -966,7 +981,7 @@ namespace OpenSim.Region.Terrain { for (j = 0; j < 256; j++) { - lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0)); + lookupHeightTable[i + (j*256)] = ((double) i*((double) j/127.0)); } } @@ -988,9 +1003,9 @@ namespace OpenSim.Region.Terrain } } - byte red = (byte)(index & 0xFF); - byte green = (byte)((index >> 8) & 0xFF); - byte blue = (byte)watermap.Get(x, y); + byte red = (byte) (index & 0xFF); + byte green = (byte) ((index >> 8) & 0xFF); + byte blue = (byte) watermap.Get(x, y); byte alpha1 = 0; // Land Parcels byte alpha2 = 0; // For Sale Land byte alpha3 = 0; // Public Edit Object @@ -1140,7 +1155,7 @@ namespace OpenSim.Region.Terrain smoothed.Smooth(amount); Channel mask = new Channel(); - mask.Raise(rx,ry,size,amount); + mask.Raise(rx, ry, size, amount); heightmap.Blend(smoothed, mask); } @@ -1221,8 +1236,7 @@ namespace OpenSim.Region.Terrain { Bitmap bmp = TerrainToBitmap(gradientmap); - imageData = OpenJPEG.EncodeFromImage(bmp, true ); - + imageData = OpenJPEG.EncodeFromImage(bmp, true); } catch (Exception e) { @@ -1252,12 +1266,11 @@ namespace OpenSim.Region.Terrain 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)); + int colorindex = (int) (Math.Max(Math.Min(1.0, copy.Get(x, y)/512.0), 0.0)*(pallete - 1)); bmp.SetPixel(x, y, 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 2ae55f0..8c29c6a 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs @@ -87,11 +87,12 @@ namespace OpenSim.Region.Terrain { foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) { - Type testInterface = pluginType.GetInterface("ITerrainFilter",true); + Type testInterface = pluginType.GetInterface("ITerrainFilter", true); if (testInterface != null) { - ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); + ITerrainFilter filter = + (ITerrainFilter) compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); string filterName = filter.Register(); Console.WriteLine("Plugin: " + filterName + " loaded."); @@ -107,7 +108,6 @@ namespace OpenSim.Region.Terrain } } } - } public void LoadFilterCSharp(string filename) @@ -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 8359f8e..8b5fbed 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs @@ -26,18 +26,16 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; +using System.Drawing.Imaging; namespace libTerrain { - class Raster + internal class Raster { - int w; - int h; - Bitmap bmp; + private int w; + private int h; + private Bitmap bmp; /// /// Creates a new Raster channel for use with bitmap or GDI functions @@ -48,7 +46,7 @@ namespace libTerrain { w = width; h = height; - bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb); } /// @@ -65,7 +63,7 @@ namespace libTerrain for (y = 0; y < bmp.Height; y++) { Color val = bmp.GetPixel(x, y); - chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0; + chan.map[x, y] = (((double) val.R + (double) val.G + (double) val.B)/3.0)/255.0; } } @@ -86,7 +84,7 @@ namespace libTerrain sf.LineAlignment = StringAlignment.Center; Graphics gd = Graphics.FromImage(bmp); - gd.DrawString(txt, new Font(font, (float)size), new SolidBrush(Color.White), area, sf); + 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 093bfb1..4cb70c2 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs @@ -26,12 +26,7 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - - -/* Channel + /* Channel * A channel is a single heightmap array * */ @@ -50,17 +45,16 @@ namespace libTerrain { w = 256; h = 256; - map = new double[w, h]; - diff = new int[(int)(w / 16), (int)(h / 16)]; + map = new double[w,h]; + diff = new int[(int) (w/16),(int) (h/16)]; } public Channel(int width, int height) { w = width; h = height; - map = new double[w, h]; - diff = new int[(int)(w / 16), (int)(h / 16)]; + map = new double[w,h]; + 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 730f206..2ad784b 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs @@ -28,8 +28,6 @@ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -39,6 +37,7 @@ namespace libTerrain { return w; } + public int GetHeight() { return h; @@ -47,7 +46,7 @@ namespace libTerrain public Channel Copy() { Channel x = new Channel(w, h); - x.map = (double[,])this.map.Clone(); + x.map = (double[,]) map.Clone(); return x; } @@ -58,9 +57,9 @@ namespace libTerrain public void SetDiff(int val) { - for (int x = 0; x < w / 16; x++) + for (int x = 0; x < w/16; x++) { - for (int y = 0; y < h / 16; y++) + for (int y = 0; y < h/16; y++) { diff[x, y] = val; } @@ -69,7 +68,7 @@ namespace libTerrain public void SetDiff(int x, int y) { - diff[x / 16, y / 16]++; + diff[x/16, y/16]++; } public void Set(int x, int y, double val) @@ -124,10 +123,10 @@ namespace libTerrain y = 0.0; int stepSize = 1; - double h00 = Get((int)x, (int)y); - double h10 = Get((int)x + stepSize, (int)y); - double h01 = Get((int)x, (int)y + stepSize); - double h11 = Get((int)x + stepSize, (int)y + stepSize); + double h00 = Get((int) x, (int) y); + double h10 = Get((int) x + stepSize, (int) y); + double h01 = Get((int) x, (int) y + stepSize); + double h11 = Get((int) x + stepSize, (int) y + stepSize); double h1 = h00; double h2 = h10; double h3 = h01; @@ -136,9 +135,9 @@ namespace libTerrain double a10 = h2 - h1; double a01 = h3 - h1; double a11 = h1 - h2 - h3 + h4; - double partialx = x - (int)x; - double partialz = y - (int)y; - double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); + double partialx = x - (int) x; + double partialz = y - (int) y; + double hi = a00 + (a10*partialx) + (a01*partialz) + (a11*partialx*partialz); return hi; } @@ -159,7 +158,7 @@ namespace libTerrain { SetDiff(x, y); - map[x % w, y % h] = val; + map[x%w, y%h] = val; } public void SetWrapClip(int x, int y, double val) @@ -171,7 +170,7 @@ namespace libTerrain if (val < 0.0) val = 0.0; - map[x % w, y % h] = val; + map[x%w, y%h] = val; } public void Fill(double val) @@ -255,7 +254,7 @@ namespace libTerrain public double Avg() { - return Sum() / (w * h); + return Sum()/(w*h); } public bool ContainsNaN() @@ -274,4 +273,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 45bb06b..e753847 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs @@ -28,8 +28,6 @@ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -58,12 +56,12 @@ namespace libTerrain // Establish the average height under the area Channel newmap = new Channel(w, h); - newmap.map = (double[,])map.Clone(); + newmap.map = (double[,]) map.Clone(); newmap *= temp; double total_terrain = newmap.Sum(); - double avg_height = total_terrain / total_mod; + double avg_height = total_terrain/total_mod; // Create a flat terrain using the average height Channel flat = new Channel(w, h); @@ -72,7 +70,6 @@ namespace libTerrain // Blend the current terrain with the average height terrain // using the "raised" empty terrain as a mask Blend(flat, temp); - } private void FlattenFast(double rx, double ry, double size, double amount) @@ -81,10 +78,10 @@ namespace libTerrain double avg = 0; double div = 0; - int minX = Math.Max(0, (int)(rx - (size + 1))); - int maxX = Math.Min(w, (int)(rx + (size + 1))); - int minY = Math.Max(0, (int)(ry - (size + 1))); - int maxY = Math.Min(h, (int)(ry + (size + 1))); + int minX = Math.Max(0, (int) (rx - (size + 1))); + int maxX = Math.Min(w, (int) (rx + (size + 1))); + int minY = Math.Max(0, (int) (ry - (size + 1))); + int maxY = Math.Min(h, (int) (ry + (size + 1))); for (x = minX; x < maxX; x++) { @@ -92,17 +89,17 @@ namespace libTerrain { double z = size; z *= z; - z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); if (z < 0) z = 0; - avg += z * amount; + avg += z*amount; div += z; } } - double height = avg / div; + double height = avg/div; for (x = minX; x < maxX; x++) { @@ -110,7 +107,7 @@ namespace libTerrain { double z = size; z *= z; - z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); if (z < 0) z = 0; @@ -123,19 +120,19 @@ namespace libTerrain public void Flatten(Channel mask, double amount) { // Generate the mask - Channel temp = mask * amount; + Channel temp = mask*amount; temp.Clip(0, 1); // Cut off out-of-bounds values double total_mod = temp.Sum(); // Establish the average height under the area Channel map = new Channel(w, h); - map.map = (double[,])this.map.Clone(); + map.map = (double[,]) this.map.Clone(); map *= temp; double total_terrain = map.Sum(); - double avg_height = total_terrain / total_mod; + double avg_height = total_terrain/total_mod; // Create a flat terrain using the average height Channel flat = new Channel(w, h); diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs index 15631df..9e8f3a4 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs @@ -28,8 +28,6 @@ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -63,12 +61,12 @@ namespace libTerrain { double z = size; z *= z; - z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); if (z < 0) z = 0; - Set(x, y, map[x, y] + (z * amount)); + Set(x, y, map[x, y] + (z*amount)); } } } @@ -88,12 +86,12 @@ namespace libTerrain for (y = 0; y < h; y++) { double z = size; - z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); + z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry))); if (z < 0) z = 0; - Set(x, y, map[x, y] + (z * amount)); + Set(x, y, map[x, y] + (z*amount)); } } } @@ -126,12 +124,12 @@ namespace libTerrain { double z = size; z *= z; - z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); if (z < 0) z = 0; - Set(x, y, map[x, y] - (z * amount)); + Set(x, y, map[x, y] - (z*amount)); } } } diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs index 5949759..b4eda47 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs @@ -27,9 +27,8 @@ */ using System; -using System.Collections.Generic; -using System.Text; using System.Drawing; +using System.Drawing.Imaging; namespace libTerrain { @@ -48,7 +47,7 @@ namespace libTerrain for (y = 0; y < bit.Height; y++) { Color val = bit.GetPixel(x, y); - chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0; + chan.map[x, y] = (((double) val.R + (double) val.G + (double) val.B)/3.0)/255.0; } } @@ -57,21 +56,21 @@ namespace libTerrain public void SaveImage(string filename) { - Channel outmap = this.Copy(); + Channel outmap = Copy(); outmap.Normalise(); - Bitmap bit = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + Bitmap bit = new Bitmap(w, h, PixelFormat.Format24bppRgb); int x, y; for (x = 0; x < w; x++) { for (y = 0; y < h; y++) { - int val = Math.Min(255, (int)(outmap.map[x,y] * 255)); - Color col = Color.FromArgb(val,val,val); + int val = Math.Min(255, (int) (outmap.map[x, y]*255)); + Color col = Color.FromArgb(val, val, val); bit.SetPixel(x, y, col); } } 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 3a9b7f7..65badd1 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -60,19 +58,19 @@ namespace libTerrain } if (val < 512) { - ret[0] = (val % 256); + ret[0] = (val%256); ret[1] = 255; return ret; } if (val < 768) { ret[0] = 255; - ret[1] = 255 - (val % 256); + ret[1] = 255 - (val%256); return ret; } if (val < 1024) { - ret[0] = 255 - (val % 256); + ret[0] = 255 - (val%256); ret[1] = 255; return ret; } @@ -100,7 +98,7 @@ namespace libTerrain { for (int y = 0; y < h; y++) { - double miny = Tools.LinearInterpolate(a[1], b[1], (double)x / (double)w); + double miny = Tools.LinearInterpolate(a[1], b[1], (double) x/(double) w); if (v >= 0.5) { diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs index 8a1b048..b6e2491 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs @@ -26,15 +26,10 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace libTerrain { partial class Channel { - public void GradientCube() { SetDiff(); diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs index 7cea800..6806748 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -44,7 +42,8 @@ namespace libTerrain /// Whether to bias hills towards the center of the map /// Whether to add hills together or to pick the largest value /// Generates hill-shaped noise instead of consistent hills - public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) + public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, + bool noisy) { SetDiff(); @@ -55,20 +54,20 @@ namespace libTerrain for (i = 0; i < number; i++) { - double rx = Math.Min(255.0, random.NextDouble() * w); - double ry = Math.Min(255.0, random.NextDouble() * h); + double rx = Math.Min(255.0, random.NextDouble()*w); + double ry = Math.Min(255.0, random.NextDouble()*h); double rand = random.NextDouble(); if (island) { // Move everything towards the center - rx -= w / 2; + rx -= w/2; rx /= 2; - rx += w / 2; + rx += w/2; - ry -= h / 2; + ry -= h/2; ry /= 2; - ry += h / 2; + ry += h/2; } for (x = 0; x < w; x++) @@ -78,9 +77,9 @@ namespace libTerrain if (noisy) rand = random.NextDouble(); - double z = (scale_min + (scale_range * rand)); + double z = (scale_min + (scale_range*rand)); z *= z; - z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); + z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); if (z < 0) z = 0; @@ -121,20 +120,20 @@ namespace libTerrain for (i = 0; i < number; i++) { - double rx = Math.Min(255.0, random.NextDouble() * w); - double ry = Math.Min(255.0, random.NextDouble() * h); + double rx = Math.Min(255.0, random.NextDouble()*w); + double ry = Math.Min(255.0, random.NextDouble()*h); double rand = random.NextDouble(); if (island) { // Move everything towards the center - rx -= w / 2; + rx -= w/2; rx /= 2; - rx += w / 2; + rx += w/2; - ry -= h / 2; + ry -= h/2; ry /= 2; - ry += h / 2; + ry += h/2; } for (x = 0; x < w; x++) @@ -144,8 +143,8 @@ namespace libTerrain if (noisy) rand = random.NextDouble(); - double z = (scale_min + (scale_range * rand)); - z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); + double z = (scale_min + (scale_range*rand)); + z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry))); if (z < 0) z = 0; @@ -176,20 +175,20 @@ namespace libTerrain for (i = 0; i < number; i++) { - double rx = Math.Min(255.0, random.NextDouble() * w); - double ry = Math.Min(255.0, random.NextDouble() * h); + double rx = Math.Min(255.0, random.NextDouble()*w); + double ry = Math.Min(255.0, random.NextDouble()*h); double rand = random.NextDouble(); if (island) { // Move everything towards the center - rx -= w / 2; + rx -= w/2; rx /= 2; - rx += w / 2; + rx += w/2; - ry -= h / 2; + ry -= h/2; ry /= 2; - ry += h / 2; + ry += h/2; } for (x = 0; x < w; x++) @@ -199,8 +198,8 @@ namespace libTerrain if (noisy) rand = random.NextDouble(); - double z = (scale_min + (scale_range * rand)); - z -= Math.Abs(x-rx) + Math.Abs(y-ry); + double z = (scale_min + (scale_range*rand)); + z -= Math.Abs(x - rx) + Math.Abs(y - ry); //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); if (z < 0) @@ -221,7 +220,8 @@ namespace libTerrain Normalise(); } - public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) + public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, + bool noisy) { SetDiff(); @@ -232,20 +232,20 @@ namespace libTerrain for (i = 0; i < number; i++) { - double rx = Math.Min(255.0, random.NextDouble() * w); - double ry = Math.Min(255.0, random.NextDouble() * h); + double rx = Math.Min(255.0, random.NextDouble()*w); + double ry = Math.Min(255.0, random.NextDouble()*h); double rand = random.NextDouble(); if (island) { // Move everything towards the center - rx -= w / 2; + rx -= w/2; rx /= 2; - rx += w / 2; + rx += w/2; - ry -= h / 2; + ry -= h/2; ry /= 2; - ry += h / 2; + ry += h/2; } for (x = 0; x < w; x++) @@ -255,11 +255,11 @@ namespace libTerrain if (noisy) rand = random.NextDouble(); - double z = (scale_min + (scale_range * rand)); - z *= z * z * z; + double z = (scale_min + (scale_range*rand)); + z *= z*z*z; double dx = Math.Abs(x - rx); double dy = Math.Abs(y - ry); - z -= (dx * dx * dx * dx) + (dy * dy * dy * dy); + z -= (dx*dx*dx*dx) + (dy*dy*dy*dy); if (z < 0) z = 0; @@ -278,6 +278,5 @@ 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 43ae37a..5d39cd5 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -53,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 d7e0dcd..10eaf71 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -36,10 +35,10 @@ namespace libTerrain { private double[] CoordinatesToPolar(int x, int y) { - double theta = Math.Atan2(x - (w / 2), y - (h / 2)); - double rx = (double)x - ((double)w / 2); - double ry = (double)y - ((double)h / 2); - double r = Math.Sqrt((rx * rx) + (ry * ry)); + double theta = Math.Atan2(x - (w/2), y - (h/2)); + double rx = (double) x - ((double) w/2); + double ry = (double) y - ((double) h/2); + double r = Math.Sqrt((rx*rx) + (ry*ry)); double[] coords = new double[2]; coords[0] = r; @@ -47,15 +46,16 @@ namespace libTerrain return coords; } - public int[] PolarToCoordinates(double r, double theta) { + public int[] PolarToCoordinates(double r, double theta) + { double nx; double ny; - nx = (double)r * Math.Cos(theta); - ny = (double)r * Math.Sin(theta); + nx = (double) r*Math.Cos(theta); + ny = (double) r*Math.Sin(theta); - nx += w / 2; - ny += h / 2; + nx += w/2; + ny += h/2; if (nx >= w) nx = w - 1; @@ -70,8 +70,8 @@ namespace libTerrain ny = 0; int[] coords = new int[2]; - coords[0] = (int)nx; - coords[1] = (int)ny; + coords[0] = (int) nx; + coords[1] = (int) ny; return coords; } @@ -79,19 +79,19 @@ namespace libTerrain { SetDiff(); - Channel n = this.Copy(); + Channel n = Copy(); int x, y; for (x = 0; x < w; x++) { for (y = 0; y < h; y++) { - double[] coords = CoordinatesToPolar(x,y); + double[] coords = CoordinatesToPolar(x, y); - coords[0] += w / 2.0; - coords[1] += h / 2.0; + coords[0] += w/2.0; + coords[1] += h/2.0; - map[x, y] = n.map[(int)coords[0] % n.w, (int)coords[1] % n.h]; + map[x, y] = n.map[(int) coords[0]%n.w, (int) coords[1]%n.h]; } } } @@ -108,12 +108,13 @@ namespace libTerrain r += incRadius; theta += incAngle; - int[] coords = PolarToCoordinates(r,theta); + int[] coords = PolarToCoordinates(r, theta); Raise(coords[0], coords[1], 20, 1); } } - public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c) + public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, + double[] c) { SetDiff(); @@ -128,7 +129,7 @@ namespace libTerrain theta += incAngle; int[] coords = PolarToCoordinates(r, theta); - points.Add(new Point2D(coords[0],coords[1])); + points.Add(new Point2D(coords[0], coords[1])); } VoronoiDiagram(points, c); @@ -145,9 +146,9 @@ namespace libTerrain for (y = 0; y < h; y++) { z++; - double dx = Math.Abs((w / 2) - x); - double dy = Math.Abs((h / 2) - y); - map[x, y] += Math.Sin(dx / wid) + Math.Cos(dy / hig); + double dx = Math.Abs((w/2) - x); + double dy = Math.Abs((h/2) - y); + map[x, y] += Math.Sin(dx/wid) + Math.Cos(dy/hig); } } Normalise(); diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs index e2f9560..0159b87 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -57,8 +56,8 @@ namespace libTerrain { for (i = 0; i < pointsPerBlock; i++) { - double pX = x + (generator.NextDouble() * (double)blockSize); - double pY = y + (generator.NextDouble() * (double)blockSize); + double pX = x + (generator.NextDouble()*(double) blockSize); + double pY = y + (generator.NextDouble()*(double) blockSize); points.Add(new Point2D(pX, pY)); } @@ -75,10 +74,10 @@ namespace libTerrain for (i = 0; i < points.Count; i++) { double dx, dy; - dx = Math.Abs((double)x - points[i].x); - dy = Math.Abs((double)y - points[i].y); + dx = Math.Abs((double) x - points[i].x); + dy = Math.Abs((double) y - points[i].y); - distances[i] = (dx * dx + dy * dy); + distances[i] = (dx*dx + dy*dy); } Array.Sort(distances); @@ -92,7 +91,7 @@ namespace libTerrain if (i >= points.Count) break; - f += c[i] * distances[i]; + f += c[i]*distances[i]; } map[x, y] = f; @@ -119,10 +118,10 @@ namespace libTerrain for (i = 0; i < points.Count; i++) { double dx, dy; - dx = Math.Abs((double)x - points[i].x); - dy = Math.Abs((double)y - points[i].y); + dx = Math.Abs((double) x - points[i].x); + dy = Math.Abs((double) y - points[i].y); - distances[i] = (dx * dx + dy * dy); + distances[i] = (dx*dx + dy*dy); } Array.Sort(distances); @@ -136,7 +135,7 @@ namespace libTerrain if (i >= points.Count) break; - f += c[i] * distances[i]; + f += c[i]*distances[i]; } map[x, y] = f; @@ -162,8 +161,8 @@ namespace libTerrain { for (i = 0; i < pointsPerBlock; i++) { - double pX = x + (generator.NextDouble() * (double)blockSize); - double pY = y + (generator.NextDouble() * (double)blockSize); + double pX = x + (generator.NextDouble()*(double) blockSize); + double pY = y + (generator.NextDouble()*(double) blockSize); points.Add(new Point2D(pX, pY)); } @@ -180,10 +179,10 @@ namespace libTerrain for (i = 0; i < points.Count; i++) { double dx, dy; - dx = Math.Abs((double)x - points[i].x); - dy = Math.Abs((double)y - points[i].y); + dx = Math.Abs((double) x - points[i].x); + dy = Math.Abs((double) y - points[i].y); - distances[i] = (dx * dx + dy * dy); + distances[i] = (dx*dx + dy*dy); } //Array.Sort(distances); @@ -191,7 +190,7 @@ namespace libTerrain double f = 0.0; double min = double.MaxValue; - for (int j = 0; j < distances.Length;j++ ) + for (int j = 0; j < distances.Length; j++) { if (distances[j] < min) { @@ -211,4 +210,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 788134d..deb2e0e 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -54,18 +52,18 @@ namespace libTerrain double rx, ry; if (centerspawn) { - rx = w / 2.0; - ry = h / 2.0; + rx = w/2.0; + ry = h/2.0; } else { - rx = random.NextDouble() * (w - 1); - ry = random.NextDouble() * (h - 1); + rx = random.NextDouble()*(w - 1); + ry = random.NextDouble()*(h - 1); } for (j = 0; j < rounds; j++) { - rx += (random.NextDouble() * movement) - (movement / 2.0); - ry += (random.NextDouble() * movement) - (movement / 2.0); + rx += (random.NextDouble()*movement) - (movement/2.0); + ry += (random.NextDouble()*movement) - (movement/2.0); Raise(rx, ry, size, 1.0); } } diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs index 0155791..24df5b9 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -49,13 +47,13 @@ namespace libTerrain { for (y = 0; y < h; y++) { - map[x, y] = (map[x, y] - min) * (1.0 / (max - min)); + map[x, y] = (map[x, y] - min)*(1.0/(max - min)); } } } else { - this.Fill(0.5); + Fill(0.5); } return this; @@ -82,7 +80,7 @@ namespace libTerrain { if (min != max) { - double val = (map[x, y] - min) * (1.0 / max - min); + double val = (map[x, y] - min)*(1.0/max - min); val *= maxv - minv; val += minv; @@ -179,9 +177,9 @@ namespace libTerrain SetDiff(); double area = amount; - double step = amount / 4.0; + double step = amount/4.0; - double[,] manipulate = new double[w, h]; + double[,] manipulate = new double[w,h]; int x, y; double n, l; for (x = 0; x < w; x++) @@ -200,7 +198,7 @@ namespace libTerrain } } - manipulate[x, y] = average / avgsteps; + manipulate[x, y] = average/avgsteps; } } map = manipulate; @@ -211,7 +209,7 @@ namespace libTerrain SetDiff(); // Simple pertubation filter - double[,] manipulated = new double[w, h]; + double[,] manipulated = new double[w,h]; Random generator = new Random(seed); // Seeds FTW! //double amount = 8.0; @@ -220,8 +218,8 @@ namespace libTerrain { for (y = 0; y < h; y++) { - double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0); - double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0); + double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0); + double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0); double p = GetBilinearInterpolate(offset_x, offset_y); manipulated[x, y] = p; } @@ -232,7 +230,7 @@ namespace libTerrain public void PertubationMask(Channel mask) { // Simple pertubation filter - double[,] manipulated = new double[w, h]; + double[,] manipulated = new double[w,h]; Random generator = new Random(seed); // Seeds FTW! //double amount = 8.0; @@ -244,8 +242,8 @@ namespace libTerrain for (y = 0; y < h; y++) { amount = mask.map[x, y]; - double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0); - double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0); + double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0); + double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0); if (offset_x > w) offset_x = w - 1; @@ -267,7 +265,7 @@ namespace libTerrain public void Distort(Channel mask, double str) { // Simple pertubation filter - double[,] manipulated = new double[w, h]; + double[,] manipulated = new double[w,h]; double amount; @@ -277,8 +275,8 @@ namespace libTerrain for (y = 0; y < h; y++) { amount = mask.map[x, y]; - double offset_x = (double)x + (amount * str) - (0.5 * str); - double offset_y = (double)y + (amount * str) - (0.5 * str); + double offset_x = (double) x + (amount*str) - (0.5*str); + double offset_y = (double) y + (amount*str) - (0.5*str); if (offset_x > w) offset_x = w - 1; @@ -295,13 +293,12 @@ namespace libTerrain } } map = manipulated; - } public void Distort(Channel mask, Channel mask2, double str) { // Simple pertubation filter - double[,] manipulated = new double[w, h]; + double[,] manipulated = new double[w,h]; double amountX; double amountY; @@ -313,8 +310,8 @@ namespace libTerrain { amountX = mask.map[x, y]; amountY = mask2.map[x, y]; - double offset_x = (double)x + (amountX * str) - (0.5 * str); - double offset_y = (double)y + (amountY * str) - (0.5 * str); + double offset_x = (double) x + (amountX*str) - (0.5*str); + double offset_y = (double) y + (amountY*str) - (0.5*str); if (offset_x > w) offset_x = w - 1; @@ -331,7 +328,6 @@ namespace libTerrain } } map = manipulated; - } public Channel Blend(Channel other, double amount) @@ -360,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 ca93c25..c8584e8 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -74,17 +72,18 @@ namespace libTerrain /// The percentage of rock which can be picked up to pickup 0..1 /// The number of erosion rounds (recommended: 25+) /// Drop sediment at the lowest point? - public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry, int rounds, bool lowest, bool usingFluidDynamics) + public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry, + int rounds, bool lowest, bool usingFluidDynamics) { bool debugImages = false; - Channel wind = new Channel(w, h) ; + Channel wind = new Channel(w, h); Channel sediment = new Channel(w, h); int x, y, i, j; - this.Normalise(); + Normalise(); - wind = this.Copy(); + wind = Copy(); wind.Noise(); if (debugImages) @@ -120,7 +119,7 @@ namespace libTerrain surfacearea += Math.Abs(target - me); } - double amount = surfacearea * wind.map[x, y] * carry; + double amount = surfacearea*wind.map[x, y]*carry; if (amount < 0) amount = 0; @@ -147,7 +146,7 @@ namespace libTerrain } else { - wind.Pertubation(15); // Can do better later + wind.Pertubation(15); // Can do better later wind.seed++; sediment.Pertubation(10); // Sediment is blown around a bit sediment.seed++; @@ -175,12 +174,12 @@ namespace libTerrain if (target < min && lowest) { - minside = (int[])coords.Clone(); + minside = (int[]) coords.Clone(); min = target; } } - double amount = surfacearea * (1.0 - wind.map[x, y]) * carry; + double amount = surfacearea*(1.0 - wind.map[x, y])*carry; if (amount < 0) amount = 0; @@ -199,7 +198,7 @@ namespace libTerrain wind.Normalise(); wind *= windspeed; - this.Normalise(); + Normalise(); } Channel myself = this; @@ -207,7 +206,7 @@ namespace libTerrain myself.Normalise(); if (debugImages) - this.SaveImage("testimg/output.png"); + 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 4f58f71..0e47e1b 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -44,7 +42,7 @@ namespace libTerrain Channel waterFlow = new Channel(w, h); NeighbourSystem type = NeighbourSystem.Moore; - int NEIGHBOUR_ME = 4; + int NEIGHBOUR_ME = 4; int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; @@ -52,7 +50,7 @@ namespace libTerrain { water += rain; - sediment = terrain * water; + sediment = terrain*water; terrain -= sediment; for (int x = 1; x < w - 1; x++) @@ -72,7 +70,8 @@ namespace libTerrain coords[0] += x; coords[1] += y; - heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] + sediment.map[coords[0], coords[1]]; + heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] + + sediment.map[coords[0], coords[1]]; diffs[j] = heightCenter - heights[j]; } } @@ -97,13 +96,13 @@ namespace libTerrain if (totalCellsCounted == 1) continue; - double averageHeight = totalHeight / totalCellsCounted; + double averageHeight = totalHeight/totalCellsCounted; double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight); // TODO: Check this. waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount; - double totalInverseDiff = waterAmount / totalHeightDiff; + double totalInverseDiff = waterAmount/totalHeightDiff; for (int j = 0; j < NEIGHBOUR_MAX; j++) { @@ -115,7 +114,8 @@ namespace libTerrain if (diffs[j] > 0) { - waterFlow.SetWrap(coords[0], coords[1], waterFlow.map[coords[0], coords[1]] + diffs[j] * totalInverseDiff); + waterFlow.SetWrap(coords[0], coords[1], + waterFlow.map[coords[0], coords[1]] + diffs[j]*totalInverseDiff); } } } @@ -131,7 +131,7 @@ namespace libTerrain { for (int y = 0; y < h; y++) { - double deposition = sediment.map[x, y] - water.map[x, y] * solubility; + double deposition = sediment.map[x, y] - water.map[x, y]*solubility; if (deposition > 0) { sediment.map[x, y] -= deposition; @@ -139,7 +139,6 @@ namespace libTerrain } } } - } } } diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs index 401cf95..8c16d7c 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace libTerrain { partial class Channel @@ -42,7 +38,7 @@ namespace libTerrain private static int nsIX(int i, int j, int N) { - return ((i) + (N + 2) * (j)); + return ((i) + (N + 2)*(j)); } private static void nsSwap(ref double x0, ref double x) @@ -62,10 +58,10 @@ namespace libTerrain private void nsAddSource(int N, ref double[] x, ref double[] s, double dt) { int i; - int size = (N + 2) * (N + 2); + int size = (N + 2)*(N + 2); for (i = 0; i < size; i++) { - x[i] += dt * s[i]; + x[i] += dt*s[i]; } } @@ -74,15 +70,15 @@ namespace libTerrain int i; for (i = 0; i <= N; i++) { - x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)]; - x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)]; - x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)]; - x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)]; + x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)]; + x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)]; + x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)]; + x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)]; } - x[nsIX(0, 0, N)] = 0.5f * (x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]); - x[nsIX(0, N + 1, N)] = 0.5f * (x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]); - x[nsIX(N + 1, 0, N)] = 0.5f * (x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]); - x[nsIX(N + 1, N + 1, N)] = 0.5f * (x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]); + x[nsIX(0, 0, N)] = 0.5f*(x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]); + x[nsIX(0, N + 1, N)] = 0.5f*(x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]); + x[nsIX(N + 1, 0, N)] = 0.5f*(x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]); + x[nsIX(N + 1, N + 1, N)] = 0.5f*(x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]); } private void nsLinSolve(int N, int b, ref double[] x, ref double[] x0, double a, double c) @@ -92,11 +88,11 @@ namespace libTerrain { for (j = 1; j <= N; j++) { - x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a * - (x[nsIX(i - 1, j, N)] + - x[nsIX(i + 1, j, N)] + - x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)]) - ) / c; + x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a* + (x[nsIX(i - 1, j, N)] + + x[nsIX(i + 1, j, N)] + + x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)]) + )/c; } } @@ -105,8 +101,8 @@ namespace libTerrain private void nsDiffuse(int N, int b, ref double[] x, ref double[] x0, double diff, double dt) { - double a = dt * diff * N * N; - nsLinSolve(N, b, ref x, ref x0, a, 1 + 4 * a); + double a = dt*diff*N*N; + nsLinSolve(N, b, ref x, ref x0, a, 1 + 4*a); } private void nsAdvect(int N, int b, ref double[] d, ref double[] d0, ref double[] u, ref double[] v, double dt) @@ -114,27 +110,27 @@ namespace libTerrain int i, j, i0, j0, i1, j1; double x, y, s0, t0, s1, t1, dt0; - dt0 = dt * N; + dt0 = dt*N; for (i = 1; i <= N; i++) { for (j = 1; j <= N; j++) { - x = i - dt0 * u[nsIX(i, j, N)]; - y = j - dt0 * v[nsIX(i, j, N)]; + x = i - dt0*u[nsIX(i, j, N)]; + y = j - dt0*v[nsIX(i, j, N)]; if (x < 0.5) x = 0.5; if (x > N + 0.5) x = N + 0.5; - i0 = (int)x; + i0 = (int) x; i1 = i0 + 1; if (y < 0.5) y = 0.5; if (y > N + 0.5) y = N + 0.5; - j0 = (int)y; + j0 = (int) y; j1 = j0 + 1; s1 = x - i0; @@ -142,8 +138,8 @@ namespace libTerrain t1 = y - j0; t0 = 1 - t1; - d[nsIX(i, j, N)] = s0 * (t0 * d0[nsIX(i0, j0, N)] + t1 * d0[nsIX(i0, j1, N)]) + - s1 * (t0 * d0[nsIX(i1, j0, N)] + t1 * d0[nsIX(i1, j1, N)]); + d[nsIX(i, j, N)] = s0*(t0*d0[nsIX(i0, j0, N)] + t1*d0[nsIX(i0, j1, N)]) + + s1*(t0*d0[nsIX(i1, j0, N)] + t1*d0[nsIX(i1, j1, N)]); } } @@ -158,7 +154,9 @@ namespace libTerrain { for (j = 1; j <= N; j++) { - div[nsIX(i, j, N)] = -0.5 * (u[nsIX(i + 1, j, N)] - u[nsIX(i - 1, j, N)] + v[nsIX(i, j + 1, N)] - v[nsIX(i, j - 1, N)]) / N; + div[nsIX(i, j, N)] = -0.5* + (u[nsIX(i + 1, j, N)] - u[nsIX(i - 1, j, N)] + v[nsIX(i, j + 1, N)] - + v[nsIX(i, j - 1, N)])/N; p[nsIX(i, j, N)] = 0; } } @@ -172,8 +170,8 @@ namespace libTerrain { for (j = 1; j <= N; j++) { - u[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]); - v[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]); + u[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]); + v[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]); } } @@ -181,7 +179,8 @@ namespace libTerrain nsSetBnd(N, 2, ref v); } - private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff, double dt) + private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff, + double dt) { nsAddSource(N, ref x, ref x0, dt); nsSwap(ref x0, ref x); @@ -190,7 +189,8 @@ namespace libTerrain nsAdvect(N, 0, ref x, ref x0, ref u, ref v, dt); } - private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc, double dt) + private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc, + double dt) { nsAddSource(N, ref u, ref u0, dt); nsAddSource(N, ref v, ref v0, dt); @@ -236,17 +236,17 @@ namespace libTerrain private void nsSimulate(int N, int rounds, double dt, double diff, double visc) { - int size = (N * 2) * (N * 2); + int size = (N*2)*(N*2); - double[] u = new double[size]; // Force, X axis - double[] v = new double[size]; // Force, Y axis - double[] u_prev = new double[size]; - double[] v_prev = new double[size]; - double[] dens = new double[size]; - double[] dens_prev = new double[size]; + double[] u = new double[size]; // Force, X axis + double[] v = new double[size]; // Force, Y axis + double[] u_prev = new double[size]; + double[] v_prev = new double[size]; + double[] dens = new double[size]; + double[] dens_prev = new double[size]; - nsDoublesToBuffer(this.map, N, ref dens); - nsDoublesToBuffer(this.map, N, ref dens_prev); + nsDoublesToBuffer(map, N, ref dens); + nsDoublesToBuffer(map, N, ref dens_prev); for (int i = 0; i < rounds; i++) { @@ -258,7 +258,7 @@ namespace libTerrain nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt); } - nsBufferToDoubles(ref dens, N, ref this.map); + nsBufferToDoubles(ref dens, N, ref map); } /// @@ -270,14 +270,14 @@ namespace libTerrain /// Fluid viscosity (Recommended: 0.0) public void navierStokes(int rounds, double dt, double diff, double visc) { - nsSimulate(this.h, rounds, dt, diff, visc); + nsSimulate(h, rounds, dt, diff, visc); } public void navierStokes(int rounds, double dt, double diff, double visc, ref double[,] uret, ref double[,] vret) { - int N = this.h; + int N = h; - int size = (N * 2) * (N * 2); + int size = (N*2)*(N*2); double[] u = new double[size]; // Force, X axis double[] v = new double[size]; // Force, Y axis @@ -286,8 +286,8 @@ namespace libTerrain double[] dens = new double[size]; double[] dens_prev = new double[size]; - nsDoublesToBuffer(this.map, N, ref dens); - nsDoublesToBuffer(this.map, N, ref dens_prev); + nsDoublesToBuffer(map, N, ref dens); + nsDoublesToBuffer(map, N, ref dens_prev); for (int i = 0; i < rounds; i++) { @@ -301,7 +301,7 @@ namespace libTerrain nsBufferToDoubles(ref u, N, ref uret); nsBufferToDoubles(ref v, N, ref vret); - nsBufferToDoubles(ref dens, N, ref this.map); + 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 9148c3c..0ca3d48 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace libTerrain { partial class Channel @@ -47,10 +43,11 @@ namespace libTerrain double[,] lastFrame; double[,] thisFrame; - lastFrame = (double[,])map.Clone(); - thisFrame = (double[,])map.Clone(); + lastFrame = (double[,]) map.Clone(); + thisFrame = (double[,]) map.Clone(); - NeighbourSystem type = NeighbourSystem.Moore; // Using moore neighbourhood (twice as computationally expensive) + NeighbourSystem type = NeighbourSystem.Moore; + // Using moore neighbourhood (twice as computationally expensive) int NEIGHBOUR_ME = 4; // I am always 4 in both systems. int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; @@ -88,19 +85,18 @@ namespace libTerrain if (target > heightF + talus) { - double calc = c * ((target - heightF) - talus); + double calc = c*((target - heightF) - talus); heightF += calc; target -= calc; } thisFrame[x, y] = heightF; thisFrame[coords[0], coords[1]] = target; - } } } } - lastFrame = (double[,])thisFrame.Clone(); + lastFrame = (double[,]) thisFrame.Clone(); } map = thisFrame; @@ -109,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 316bd9a..4004747 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs @@ -26,19 +26,15 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace libTerrain { partial class Channel { - enum NeighbourSystem + private enum NeighbourSystem { Moore, VonNeumann - }; + } ; private int[] Neighbours(NeighbourSystem type, int index) { @@ -138,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 0306e58..ae7530c 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs @@ -27,8 +27,6 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { @@ -138,7 +136,7 @@ namespace libTerrain { for (y = 0; y < A.h; y++) { - A.map[x, y] = Math.Pow(A.map[x,y],B.map[x, y]); + A.map[x, y] = Math.Pow(A.map[x, y], B.map[x, y]); } } @@ -230,7 +228,7 @@ namespace libTerrain { for (y = 0; y < A.h; y++) { - A.map[x, y] = Math.Pow(A.map[x,y],B); + A.map[x, y] = Math.Pow(A.map[x, y], B); } } @@ -238,6 +236,5 @@ namespace libTerrain return A; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs index 9985f03..1d52da9 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace libTerrain { public class Point2D @@ -43,4 +39,4 @@ namespace libTerrain y = Y; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs index 3207f15..d805794 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs @@ -27,33 +27,34 @@ */ using System; -using System.Collections.Generic; -using System.Text; namespace libTerrain { - class Tools + internal class Tools { public static double LinearInterpolate(double a, double b, double amount) { - return a + ((b - a) * amount); + return a + ((b - a)*amount); } public static double ExponentialInterpolate(double a, double b, double amount) { a = Math.Pow(a, amount); b = Math.Pow(b - a, 1.0 - amount); - return a+b; + return a + b; } - public static int PowerOf2Log2(int n) { - for (int i = 0; i < 31; i++) { - if ((n & 1) == 1) { - return i; - } - n >>= 1; - } - return 0; - } + public static int PowerOf2Log2(int n) + { + for (int i = 0; i < 31; i++) + { + if ((n & 1) == 1) + { + return i; + } + n >>= 1; + } + return 0; + } } -} +} \ No newline at end of file -- cgit v1.1