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/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 +- 182 files changed, 8211 insertions(+), 5729 deletions(-) (limited to 'OpenSim/Region') 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