From efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Dec 2007 21:41:48 +0000 Subject: * Optimized usings * shortened references * Removed redundant 'this' * Normalized EOF --- OpenSim/Region/Application/Application.cs | 2 +- OpenSim/Region/Application/IApplicationPlugin.cs | 11 +- OpenSim/Region/Application/OpenSimMain.cs | 85 +++-- OpenSim/Region/Application/VersionInfo.cs | 2 +- .../ClientStack/ClientStackNetworkHandler.cs | 2 +- OpenSim/Region/ClientStack/ClientView.cs | 378 ++++++++++--------- OpenSim/Region/ClientStack/PacketQueue.cs | 198 +++++----- OpenSim/Region/ClientStack/PacketServer.cs | 13 +- OpenSim/Region/ClientStack/PacketThrottle.cs | 43 +-- OpenSim/Region/ClientStack/QueItem.cs | 18 +- .../Region/ClientStack/RegionApplicationBase.cs | 9 +- OpenSim/Region/ClientStack/UDPServer.cs | 87 ++--- .../Communications/Local/CommunicationsLocal.cs | 2 +- .../Communications/Local/LocalBackEndServices.cs | 40 +- .../Communications/Local/LocalInventoryService.cs | 10 +- .../Communications/Local/LocalLoginService.cs | 14 +- .../Communications/Local/LocalUserServices.cs | 3 +- .../Region/Communications/OGS1/OGS1GridServices.cs | 219 ++++++----- .../Communications/OGS1/OGS1InterSimComms.cs | 32 +- .../Communications/OGS1/OGS1InventoryService.cs | 24 +- .../Region/Communications/OGS1/OGS1UserServices.cs | 29 +- OpenSim/Region/Environment/EstateManager.cs | 24 +- .../Environment/Interfaces/IAvatarFactory.cs | 1 - .../Region/Environment/Interfaces/IHttpRequests.cs | 2 +- .../Environment/Interfaces/IRegionDataStore.cs | 7 +- OpenSim/Region/Environment/LandManagement/Land.cs | 61 ++- .../Environment/LandManagement/LandManager.cs | 95 ++--- OpenSim/Region/Environment/ModuleLoader.cs | 2 +- .../Environment/Modules/AvatarFactoryModule.cs | 17 +- OpenSim/Region/Environment/Modules/ChatModule.cs | 10 +- .../Environment/Modules/ScriptsHttpRequests.cs | 260 +++++++------ OpenSim/Region/Environment/Modules/SunModule.cs | 37 +- .../Environment/Modules/TextureDownloadModule.cs | 42 ++- .../Region/Environment/Modules/WorldCommModule.cs | 4 +- OpenSim/Region/Environment/Modules/XMLRPCModule.cs | 9 +- OpenSim/Region/Environment/PermissionManager.cs | 31 +- .../Region/Environment/Scenes/AvatarAnimations.cs | 17 +- .../Region/Environment/Scenes/AvatarAppearance.cs | 14 +- OpenSim/Region/Environment/Scenes/EntityBase.cs | 5 +- .../Environment/Scenes/IScenePresenceBody.cs | 1 - OpenSim/Region/Environment/Scenes/InnerScene.cs | 123 +++--- .../Region/Environment/Scenes/Scene.Inventory.cs | 189 +++++----- .../Environment/Scenes/Scene.PacketHandlers.cs | 19 +- OpenSim/Region/Environment/Scenes/Scene.cs | 400 ++++++++++---------- OpenSim/Region/Environment/Scenes/SceneBase.cs | 11 +- .../Scenes/SceneCommunicationService.cs | 72 ++-- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 12 +- OpenSim/Region/Environment/Scenes/SceneManager.cs | 9 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 93 ++--- .../Region/Environment/Scenes/SceneObjectPart.cs | 414 +++++++++++---------- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 132 +++---- .../Region/Environment/Scenes/SceneXmlLoader.cs | 25 +- .../Scenes/Scripting/ScriptEngineInterface.cs | 2 +- .../Scenes/Scripting/ScriptEngineLoader.cs | 2 +- .../Region/Environment/Scenes/SimStatsReporter.cs | 69 ++-- .../Region/Examples/SimpleApp/FileSystemObject.cs | 1 - .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 27 +- OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 9 +- OpenSim/Region/Examples/SimpleApp/Program.cs | 5 +- .../Engines/CSharp/CSharpScriptEngine.cs | 2 +- .../Engines/CSharp/Examples/ExportRegionToLSL.cs | 2 +- .../Engines/JScript/JScriptEngine.cs | 2 +- .../Engines/JVMEngine/JVM/ClassInstance.cs | 2 +- .../Engines/JVMEngine/JVM/ClassRecord.cs | 2 +- .../Engines/JVMEngine/JVM/Heap.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.Logic.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.Methods.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.Return.cs | 2 +- .../Engines/JVMEngine/JVM/Interpreter.cs | 2 +- .../Engines/JVMEngine/JVM/MainMemory.cs | 2 +- .../Engines/JVMEngine/JVM/MethodMemory.cs | 2 +- .../Engines/JVMEngine/JVM/Object.cs | 2 +- .../Engines/JVMEngine/JVM/Stack.cs | 2 +- .../Engines/JVMEngine/JVM/StackFrame.cs | 2 +- .../Engines/JVMEngine/JVM/Thread.cs | 2 +- .../Engines/JVMEngine/OpenSimJVM.cs | 2 +- OpenSim/Region/ExtensionsScriptModule/Script.cs | 2 +- .../Region/ExtensionsScriptModule/ScriptInfo.cs | 2 +- .../Region/ExtensionsScriptModule/ScriptManager.cs | 2 +- .../Physics/BasicPhysicsPlugin/AssemblyInfo.cs | 2 +- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 42 ++- .../Region/Physics/BulletXPlugin/AssemblyInfo.cs | 2 +- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 206 ++++++---- .../BulletXPlugin/TriangleIndexVertexArray.cs | 69 +++- OpenSim/Region/Physics/Manager/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/Manager/IMesher.cs | 9 +- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 101 ++--- .../Region/Physics/Manager/PhysicsPluginManager.cs | 8 +- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 15 +- OpenSim/Region/Physics/Manager/PhysicsVector.cs | 15 +- OpenSim/Region/Physics/Manager/ZeroMesher.cs | 9 +- OpenSim/Region/Physics/Meshing/Extruder.cs | 21 +- OpenSim/Region/Physics/Meshing/HelperTypes.cs | 10 +- OpenSim/Region/Physics/Meshing/Mesh.cs | 42 +-- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 74 ++-- OpenSim/Region/Physics/Meshing/SimpleHull.cs | 120 +++--- OpenSim/Region/Physics/Meshing/Simplex.cs | 49 ++- OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 114 +++--- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 175 ++++----- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 336 +++++++++-------- OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 84 +++-- OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs | 2 +- OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 124 +++--- .../Common/LSL_BuiltIn_Commands_Interface.cs | 2 +- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 66 ++-- OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs | 2 +- .../DotNetEngine/Compiler/LSL/Compiler.cs | 9 +- .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 4 +- .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 8 +- .../Compiler/Server_API/LSL_BuiltIn_Commands.cs | 2 - .../ScriptEngine/DotNetEngine/EventManager.cs | 2 +- .../ScriptEngine/DotNetEngine/EventQueueManager.cs | 21 +- .../ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs | 14 +- .../ScriptEngine/DotNetEngine/ScriptEngine.cs | 2 +- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 65 ++-- .../OpenSim.DataStore.MSSQL/MSSQLDataStore.cs | 309 +++++++-------- .../MonoSqliteDataStore.cs | 306 ++++++++------- .../OpenSim.DataStore.NullStorage/NullDataStore.cs | 5 +- .../Properties/AssemblyInfo.cs | 2 +- .../Region/Terrain.BasicTerrain/TerrainEngine.cs | 35 +- .../Region/Terrain.BasicTerrain/TerrainFilter.cs | 2 +- .../libTerrainBSD/Bitmap/Bitmap.cs | 2 +- .../libTerrainBSD/Channel/Channel.cs | 2 +- .../libTerrainBSD/Channel/Common.cs | 2 +- .../libTerrainBSD/Channel/Editing/Flatten.cs | 2 +- .../libTerrainBSD/Channel/Editing/Raise.cs | 2 +- .../libTerrainBSD/Channel/File.cs | 2 +- .../libTerrainBSD/Channel/Generators/Fracture.cs | 2 +- .../libTerrainBSD/Channel/Generators/Gradient.cs | 2 +- .../Channel/Generators/HillPlanter.cs | 2 +- .../libTerrainBSD/Channel/Generators/Noise.cs | 2 +- .../libTerrainBSD/Channel/Generators/Spiral.cs | 2 +- .../libTerrainBSD/Channel/Generators/Voronoi.cs | 2 +- .../libTerrainBSD/Channel/Generators/Worms.cs | 2 +- .../libTerrainBSD/Channel/Grid.cs | 2 +- .../Channel/Manipulators/AerobicErosion.cs | 2 +- .../Channel/Manipulators/HydraulicErosion.cs | 2 +- .../Channel/Manipulators/NavierStokes.cs | 2 +- .../Channel/Manipulators/ThermalWeathering.cs | 2 +- .../libTerrainBSD/Channel/Neighbours.cs | 2 +- .../libTerrainBSD/Channel/Operators.cs | 2 +- 143 files changed, 3143 insertions(+), 2902 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 130199d..cb3bd40 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -77,4 +77,4 @@ namespace OpenSim } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs index 17c81e1..4f81354 100644 --- a/OpenSim/Region/Application/IApplicationPlugin.cs +++ b/OpenSim/Region/Application/IApplicationPlugin.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -26,13 +26,10 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using Mono.Addins; -using Mono.Addins.Description; -[assembly: AddinRoot("OpenSim", "0.4")] +[assembly : AddinRoot("OpenSim", "0.4")] + namespace OpenSim { [TypeExtensionPoint("/OpenSim/Startup")] @@ -41,4 +38,4 @@ namespace OpenSim void Initialise(OpenSimMain openSim); void Close(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index b3daf0c..fa2a989 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -30,6 +30,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Text; +using System.Threading; +using System.Timers; +using libsecondlife; +using Mono.Addins; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -42,9 +46,7 @@ using OpenSim.Region.Environment; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Physics.Manager; -using libsecondlife; -using Mono.Addins; -using Mono.Addins.Description; +using Timer=System.Timers.Timer; namespace OpenSim { @@ -86,7 +88,7 @@ namespace OpenSim private string m_assetStorage = "sqlite"; private string m_timedScript = "disabled"; - private System.Timers.Timer m_scriptTimer; + private Timer m_scriptTimer; public ConsoleCommand CreateAccount = null; private bool m_dumpAssetsToFile; @@ -238,7 +240,7 @@ namespace OpenSim m_permissions = startupConfig.GetBoolean("serverside_object_permissions", false); m_storageDll = startupConfig.GetString("storage_plugin", "OpenSim.DataStore.MonoSqlite.dll"); - m_storageConnectionString + m_storageConnectionString = startupConfig.GetString("storage_connection_string", "URI=file:OpenSim.db,version=3"); m_startupCommandsFile = startupConfig.GetString("startup_console_commands_file", ""); @@ -268,7 +270,7 @@ namespace OpenSim if (!m_sandbox) m_SendChildAgentTaskData = false; - + m_networkServersInfo.loadFromConfiguration(m_config); } @@ -327,16 +329,16 @@ namespace OpenSim MainLog.Instance.Verbose("Plugins", "Loading OpenSim application plugins"); foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/Startup")) { - IApplicationPlugin plugin = (IApplicationPlugin)node.CreateInstance(); + IApplicationPlugin plugin = (IApplicationPlugin) node.CreateInstance(); plugin.Initialise(this); m_plugins.Add(plugin); } - + // Start UDP servers //for (int i = 0; i < m_udpServers.Count; i++) //{ - // m_udpServers[i].ServerListener(); - // } + // m_udpServers[i].ServerListener(); + // } //Run Startup Commands if (m_startupCommandsFile != "") @@ -353,10 +355,10 @@ namespace OpenSim if (m_timedScript != "disabled") { - m_scriptTimer = new System.Timers.Timer(); + m_scriptTimer = new Timer(); m_scriptTimer.Enabled = true; - m_scriptTimer.Interval = (int)(1200 * 1000); - m_scriptTimer.Elapsed += new System.Timers.ElapsedEventHandler(RunAutoTimerScript); + m_scriptTimer.Interval = (int) (1200*1000); + m_scriptTimer.Elapsed += new ElapsedEventHandler(RunAutoTimerScript); } } @@ -402,11 +404,13 @@ namespace OpenSim SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); if (m_SendChildAgentTaskData) { - MainLog.Instance.Error("WARNING", "Send Child Agent Task Updates is enabled. This is for testing only. It doesn't work on grid mode!"); - System.Threading.Thread.Sleep(12000); + MainLog.Instance.Error("WARNING", + "Send Child Agent Task Updates is enabled. This is for testing only. It doesn't work on grid mode!"); + Thread.Sleep(12000); } return - new Scene(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, + new Scene(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache, + storageManager, m_httpServer, m_moduleLoader, m_dumpAssetsToFile, m_physicalPrim, m_SendChildAgentTaskData); } @@ -440,16 +444,15 @@ namespace OpenSim m_assetCache = new AssetCache(assetServer, m_log); // m_assetCache = new assetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey); m_sceneManager.OnRestartSim += handleRestartRegion; - } - public void handleRestartRegion(RegionInfo whichRegion) + public void handleRestartRegion(RegionInfo whichRegion) { MainLog.Instance.Error("MAIN", "Got restart signal from SceneManager"); // Shutting down the UDP server bool foundUDPServer = false; int UDPServerElement = 0; - + for (int i = 0; i < m_udpServers.Count; i++) { if (m_udpServers[i].RegionHandle == whichRegion.RegionHandle) @@ -459,9 +462,9 @@ namespace OpenSim break; } } - if (foundUDPServer) + if (foundUDPServer) { - // m_udpServers[UDPServerElement].Server.End + // m_udpServers[UDPServerElement].Server.End m_udpServers[UDPServerElement].Server.Close(); m_udpServers.RemoveAt(UDPServerElement); } @@ -479,7 +482,7 @@ namespace OpenSim { m_regionData.RemoveAt(RegionHandleElement); } - + CreateRegion(whichRegion); //UDPServer restartingRegion = CreateRegion(whichRegion); //restartingRegion.ServerListener(); @@ -537,7 +540,7 @@ namespace OpenSim { RunCommandScript(m_shutdownCommandsFile); } - + m_log.Verbose("SHUTDOWN", "Closing all threads"); m_log.Verbose("SHUTDOWN", "Killing listener thread"); m_log.Verbose("SHUTDOWN", "Killing clients"); @@ -557,6 +560,7 @@ namespace OpenSim RunCommandScript(m_timedScript); } } + #region Console Commands /// @@ -679,10 +683,17 @@ namespace OpenSim } if (cmdparams.Length > 2) { - loadOffset.X = (float)Convert.ToDecimal(cmdparams[2]); - if (cmdparams.Length > 3) { loadOffset.Y = (float)Convert.ToDecimal(cmdparams[3]); } - if (cmdparams.Length > 4) { loadOffset.Z = (float)Convert.ToDecimal(cmdparams[4]); } - m_log.Error("loadOffsets = <" + loadOffset.X + "," + loadOffset.Y + "," + loadOffset.Z + ">"); + loadOffset.X = (float) Convert.ToDecimal(cmdparams[2]); + if (cmdparams.Length > 3) + { + loadOffset.Y = (float) Convert.ToDecimal(cmdparams[3]); + } + if (cmdparams.Length > 4) + { + loadOffset.Z = (float) Convert.ToDecimal(cmdparams[4]); + } + m_log.Error("loadOffsets = <" + loadOffset.X + "," + loadOffset.Y + "," + + loadOffset.Z + ">"); } } m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); @@ -795,12 +806,13 @@ namespace OpenSim if (m_sceneManager.CurrentScene == null) { - MainLog.Instance.Verbose("CONSOLE", - "Currently at Root level. To change region please use 'change-region '"); + MainLog.Instance.Verbose("CONSOLE", + "Currently at Root level. To change region please use 'change-region '"); } else { - MainLog.Instance.Verbose("CONSOLE", "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + + MainLog.Instance.Verbose("CONSOLE", + "Current Region: " + m_sceneManager.CurrentScene.RegionInfo.RegionName + ". To change region please use 'change-region '"); } @@ -901,10 +913,13 @@ namespace OpenSim break; case "regions": - m_sceneManager.ForEachScene(delegate(Scene scene) - { - m_log.Error("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + scene.RegionInfo.RegionLocX + " , Region YLoc: " + scene.RegionInfo.RegionLocY); - }); + m_sceneManager.ForEachScene( + delegate(Scene scene) + { + m_log.Error("Region Name: " + scene.RegionInfo.RegionName + " , Region XLoc: " + + scene.RegionInfo.RegionLocX + " , Region YLoc: " + + scene.RegionInfo.RegionLocY); + }); break; } } @@ -922,4 +937,4 @@ namespace OpenSim #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Application/VersionInfo.cs b/OpenSim/Region/Application/VersionInfo.cs index 8d8217f..0f798e4 100644 --- a/OpenSim/Region/Application/VersionInfo.cs +++ b/OpenSim/Region/Application/VersionInfo.cs @@ -33,4 +33,4 @@ namespace OpenSim { public static string Version = "0.4, SVN build "; } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs index 7bfadea..b3af1cc 100644 --- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs +++ b/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs @@ -35,4 +35,4 @@ namespace OpenSim.Region.ClientStack void RemoveClientCircuit(uint circuitcode); void RegisterPacketServer(PacketServer server); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index f29d2f9..b232ed6 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -38,6 +38,7 @@ using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack @@ -71,9 +72,10 @@ namespace OpenSim.Region.ClientStack private readonly uint m_circuitCode; private int m_moneyBalance; - private readonly byte[] m_channelVersion=new byte[] { 0x00} ; // Dummy value needed by libSL + private readonly byte[] m_channelVersion = new byte[] {0x00}; // Dummy value needed by libSL /* protected variables */ + protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients @@ -94,7 +96,7 @@ namespace OpenSim.Region.ClientStack protected const int RESEND_TIMEOUT = 4000; protected const int MAX_SEQUENCE = 0xFFFFFF; protected PacketServer m_networkServer; - + /* public variables */ protected string m_firstName; protected string m_lastName; @@ -103,11 +105,12 @@ namespace OpenSim.Region.ClientStack protected EndPoint m_userEndPoint; /* Properties */ + public LLUUID SecureSessionId { get { return m_secureSessionId; } } - + public IScene Scene { get { return m_scene; } @@ -144,7 +147,7 @@ namespace OpenSim.Region.ClientStack { get { return m_lastName; } } - + /// /// Full name of the client (first name and last name) /// @@ -162,10 +165,11 @@ namespace OpenSim.Region.ClientStack { get { return m_moneyBalance; } } - + /* METHODS */ - public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) + public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, + AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) { m_moneyBalance = 1000; @@ -209,7 +213,6 @@ namespace OpenSim.Region.ClientStack private void CloseCleanup() { - m_scene.RemoveClient(AgentId); // Send the STOP packet DisableSimulatorPacket disable = new DisableSimulatorPacket(); @@ -222,9 +225,6 @@ namespace OpenSim.Region.ClientStack Thread.Sleep(2000); - - - // Shut down timers m_ackTimer.Stop(); @@ -243,18 +243,15 @@ namespace OpenSim.Region.ClientStack public void Close(bool ShutdownCircult) { - // Pull Client out of Region MainLog.Instance.Verbose("CLIENT", "Close has been called"); //raiseevent on the packet server to Shutdown the circuit if (ShutdownCircult) OnConnectionClosed(this); - - CloseCleanup(); - + CloseCleanup(); } public void Kick(string message) @@ -262,8 +259,8 @@ namespace OpenSim.Region.ClientStack KickUserPacket kupack = new KickUserPacket(); kupack.UserInfo.AgentID = AgentId; kupack.UserInfo.SessionID = SessionId; - kupack.TargetBlock.TargetIP = (uint)0; - kupack.TargetBlock.TargetPort = (ushort)0; + kupack.TargetBlock.TargetIP = (uint) 0; + kupack.TargetBlock.TargetPort = (ushort) 0; kupack.UserInfo.Reason = Helpers.StringToField(message); OutPacket(kupack, ThrottleOutPacketType.Task); } @@ -340,9 +337,9 @@ namespace OpenSim.Region.ClientStack if (m_debug < 254 && packet.Type == PacketType.ViewerEffect) return; if (m_debug < 253 && ( - packet.Type == PacketType.CompletePingCheck || - packet.Type == PacketType.StartPingCheck - )) + packet.Type == PacketType.CompletePingCheck || + packet.Type == PacketType.StartPingCheck + )) return; if (m_debug < 252 && packet.Type == PacketType.PacketAck) return; @@ -552,7 +549,7 @@ namespace OpenSim.Region.ClientStack public event EstateOwnerMessageRequest OnEstateOwnerMessage; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; - + #region Scene/Avatar to Client /// @@ -561,7 +558,8 @@ namespace OpenSim.Region.ClientStack /// public void SendRegionHandshake(RegionInfo regionInfo) { - RegionHandshakePacket handshake = (RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake); + RegionHandshakePacket handshake = + (RegionHandshakePacket) PacketPool.Instance.GetPacket(PacketType.RegionHandshake); handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor; handshake.RegionInfo.IsEstateManager = false; @@ -645,7 +643,7 @@ namespace OpenSim.Region.ClientStack OutPacket(reply, ThrottleOutPacketType.Task); } - + /// /// /// @@ -861,7 +859,7 @@ namespace OpenSim.Region.ClientStack public void SendTeleportFailed() { TeleportFailedPacket tpFailed = new TeleportFailedPacket(); - tpFailed.Info.AgentID = this.AgentId; + tpFailed.Info.AgentID = AgentId; tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport"); OutPacket(tpFailed, ThrottleOutPacketType.Task); } @@ -914,8 +912,8 @@ namespace OpenSim.Region.ClientStack /// The items contained in the folder identified by folderID /// Do we need to send folder information? /// Do we need to send item information? - public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items, - List folders, + public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items, + List folders, bool fetchFolders, bool fetchItems) { // An inventory descendents packet consists of a single agent section and an inventory details @@ -929,14 +927,14 @@ namespace OpenSim.Region.ClientStack // for one example of this kind of thing. So we'll go for a cautious max // items of 20 which gives a packet size of about 11k int MAX_ITEMS_PER_PACKET = 20; - + Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; - + if (fetchItems) { - InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - + InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); + if (items.Count < MAX_ITEMS_PER_PACKET) { descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; @@ -947,7 +945,7 @@ namespace OpenSim.Region.ClientStack descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; } - + // Even if we aren't fetching the folders, we still need to include the folder count // in the total number of descendents. Failure to do so will cause subtle bugs such // as the failure of textures which haven't been expanded in inventory to show up @@ -956,7 +954,7 @@ namespace OpenSim.Region.ClientStack { descend.AgentData.Descendents += folders.Count; } - + int count = 0; int i = 0; foreach (InventoryItemBase item in items) @@ -973,28 +971,31 @@ namespace OpenSim.Region.ClientStack descend.ItemData[i].FolderID = item.parentFolderID; descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); descend.ItemData[i].GroupMask = 0; - descend.ItemData[i].InvType = (sbyte)item.invType; + descend.ItemData[i].InvType = (sbyte) item.invType; descend.ItemData[i].Name = Helpers.StringToField(item.inventoryName); descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions; descend.ItemData[i].OwnerID = item.avatarID; descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions; descend.ItemData[i].SalePrice = 0; descend.ItemData[i].SaleType = 0; - descend.ItemData[i].Type = (sbyte)item.assetType; + descend.ItemData[i].Type = (sbyte) item.assetType; descend.ItemData[i].CRC = Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, descend.ItemData[i].InvType, descend.ItemData[i].Type, - descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice, + descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, + descend.ItemData[i].SalePrice, descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, - descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, descend.ItemData[i].EveryoneMask, - descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); - + descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, + descend.ItemData[i].EveryoneMask, + descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, + descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); + i++; count++; if (i == MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); - + if ((items.Count - count) > 0) { descend = CreateInventoryDescendentsPacket(ownerID, folderID); @@ -1012,7 +1013,7 @@ namespace OpenSim.Region.ClientStack } } } - + if (i < MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); @@ -1023,7 +1024,7 @@ namespace OpenSim.Region.ClientStack if (fetchFolders) { InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - + if (folders.Count < MAX_ITEMS_PER_PACKET) { descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; @@ -1034,14 +1035,14 @@ namespace OpenSim.Region.ClientStack descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; } - + // Not sure if this scenario ever actually occurs, but nonetheless we include the items // count even if we're not sending item data for the same reasons as above. if (!fetchItems) { descend.AgentData.Descendents += items.Count; - } - + } + int i = 0; int count = 0; foreach (InventoryFolderBase folder in folders) @@ -1050,32 +1051,34 @@ namespace OpenSim.Region.ClientStack descend.FolderData[i].FolderID = folder.folderID; descend.FolderData[i].Name = Helpers.StringToField(folder.name); descend.FolderData[i].ParentID = folder.parentID; - descend.FolderData[i].Type = (sbyte)folder.type; + descend.FolderData[i].Type = (sbyte) folder.type; i++; count++; if (i == MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); - + if ((folders.Count - count) > 0) { descend = CreateInventoryDescendentsPacket(ownerID, folderID); if ((folders.Count - count) < MAX_ITEMS_PER_PACKET) { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; + descend.FolderData = + new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; descend.AgentData.Descendents = folders.Count - count; } else { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; + descend.FolderData = + new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; } i = 0; } } } - + if (i < MAX_ITEMS_PER_PACKET) { OutPacket(descend, ThrottleOutPacketType.Asset); @@ -1204,6 +1207,7 @@ namespace OpenSim.Region.ClientStack sendXfer.DataPacket.Data = data; OutPacket(sendXfer, ThrottleOutPacketType.Task); } + public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket) { OutPacket(replyPacket, ThrottleOutPacketType.Task); @@ -1272,7 +1276,7 @@ namespace OpenSim.Region.ClientStack OutPacket(sound, ThrottleOutPacketType.Task); } - public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) + public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) { SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); viewertime.TimeInfo.SunDirection = sunPos; @@ -1524,12 +1528,13 @@ namespace OpenSim.Region.ClientStack OutPacket(attach, ThrottleOutPacketType.Task); } - + public void SendPrimitiveToClient( ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, - LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction) + LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, + LLQuaternion rotation, byte clickAction) { ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); outPacket.RegionData.RegionHandle = regionHandle; @@ -1572,8 +1577,8 @@ namespace OpenSim.Region.ClientStack public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) { - LLVector3 velocity = new LLVector3(0f,0f,0f); - LLVector3 rotationalvelocity = new LLVector3(0f,0f,0f); + LLVector3 velocity = new LLVector3(0f, 0f, 0f); + LLVector3 rotationalvelocity = new LLVector3(0f, 0f, 0f); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; @@ -1582,10 +1587,10 @@ namespace OpenSim.Region.ClientStack OutPacket(terse, ThrottleOutPacketType.Task); } + public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) { - ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; @@ -1594,7 +1599,6 @@ namespace OpenSim.Region.ClientStack OutPacket(terse, ThrottleOutPacketType.Task); } - #endregion @@ -1696,7 +1700,9 @@ namespace OpenSim.Region.ClientStack /// protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, - LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) + LLQuaternion rotation, + LLVector3 velocity, + LLVector3 rotationalvelocity) { uint ID = localID; byte[] bytes = new byte[60]; @@ -1724,16 +1730,16 @@ namespace OpenSim.Region.ClientStack vel.y += 1; vel.z += 1; //vel - velx = (ushort)(32768 * (vel.x)); - vely = (ushort)(32768 * (vel.y)); - velz = (ushort)(32768 * (vel.z)); + velx = (ushort) (32768*(vel.x)); + vely = (ushort) (32768*(vel.y)); + velz = (ushort) (32768*(vel.z)); - bytes[i++] = (byte) (velx % 256); - bytes[i++] = (byte) ((velx >> 8) % 256); - bytes[i++] = (byte) (vely % 256); - bytes[i++] = (byte) ((vely >> 8) % 256); - bytes[i++] = (byte) (velz % 256); - bytes[i++] = (byte) ((velz >> 8) % 256); + bytes[i++] = (byte) (velx%256); + bytes[i++] = (byte) ((velx >> 8)%256); + bytes[i++] = (byte) (vely%256); + bytes[i++] = (byte) ((vely >> 8)%256); + bytes[i++] = (byte) (velz%256); + bytes[i++] = (byte) ((velz >> 8)%256); //accel bytes[i++] = (byte) (ac%256); @@ -1763,21 +1769,21 @@ namespace OpenSim.Region.ClientStack ushort rvelx, rvely, rvelz; Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z); - rvel = rvel / 128.0f; + rvel = rvel/128.0f; rvel.x += 1; rvel.y += 1; rvel.z += 1; //vel - rvelx = (ushort)(32768 * (rvel.x)); - rvely = (ushort)(32768 * (rvel.y)); - rvelz = (ushort)(32768 * (rvel.z)); + rvelx = (ushort) (32768*(rvel.x)); + rvely = (ushort) (32768*(rvel.y)); + rvelz = (ushort) (32768*(rvel.z)); - bytes[i++] = (byte)(rvelx % 256); - bytes[i++] = (byte)((rvelx >> 8) % 256); - bytes[i++] = (byte)(rvely % 256); - bytes[i++] = (byte)((rvely >> 8) % 256); - bytes[i++] = (byte)(rvelz % 256); - bytes[i++] = (byte)((rvelz >> 8) % 256); + bytes[i++] = (byte) (rvelx%256); + bytes[i++] = (byte) ((rvelx >> 8)%256); + bytes[i++] = (byte) (rvely%256); + bytes[i++] = (byte) ((rvely >> 8)%256); + bytes[i++] = (byte) (rvelz%256); + bytes[i++] = (byte) ((rvelz >> 8)%256); dat.Data = bytes; return dat; @@ -1906,7 +1912,7 @@ namespace OpenSim.Region.ClientStack objdata.Sound = LLUUID.Zero; LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); objdata.TextureEntry = ntex.ToBytes(); - + objdata.State = 0; objdata.Data = new byte[0]; @@ -1993,13 +1999,13 @@ namespace OpenSim.Region.ClientStack { MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket) packet; // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); - OpenSim.Region.Environment.Scenes.Scene tScene = (OpenSim.Region.Environment.Scenes.Scene)this.m_scene; + Scene tScene = (Scene) m_scene; for (int i = 0; i < multipleupdate.ObjectData.Length; i++) { // Can't act on Null Data if (multipleupdate.ObjectData[i].Data != null) - { + { LLUUID editobj = tScene.GetSceneObjectPart(multipleupdate.ObjectData[i].ObjectLocalID).UUID; if (editobj != null) { @@ -2024,8 +2030,8 @@ namespace OpenSim.Region.ClientStack OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); } } - #endregion position - #region rotation + #endregion position + #region rotation else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab { @@ -2062,11 +2068,12 @@ namespace OpenSim.Region.ClientStack LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); - OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); + OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, + this); } } - #endregion - #region scale + #endregion + #region scale else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab { @@ -2118,9 +2125,9 @@ namespace OpenSim.Region.ClientStack else { // It's a ghost! tell the client to delete it from view. - simClient.SendKillObject(this.Scene.RegionInfo.RegionHandle, multipleupdate.ObjectData[i].ObjectLocalID); + simClient.SendKillObject(Scene.RegionInfo.RegionHandle, + multipleupdate.ObjectData[i].ObjectLocalID); } - } } return true; @@ -2173,10 +2180,12 @@ namespace OpenSim.Region.ClientStack this.OutPacket(mbReply, ThrottleOutPacketType.Land); */ } + public void SetChildAgentThrottle(byte[] throttles) { m_packetQueue.SetThrottleFromClient(throttles); } + // Previously ClientView.m_packetQueue // A thread safe sequence number allocator. @@ -2198,7 +2207,7 @@ namespace OpenSim.Region.ClientStack } return seq; } - + protected void AddAck(Packet Pack) { lock (m_needAck) @@ -2236,13 +2245,13 @@ namespace OpenSim.Region.ClientStack { Pack.Header.AckList = new uint[m_pendingAcks.Count]; int i = 0; - + foreach (uint ack in m_pendingAcks.Values) { Pack.Header.AckList[i] = ack; i++; } - + m_pendingAcks.Clear(); Pack.Header.AppendedAcks = true; } @@ -2272,22 +2281,22 @@ namespace OpenSim.Region.ClientStack // Actually make the byte array and send it try { - byte[] sendbuffer = Pack.ToBytes(); - if (Pack is RegionHandshakePacket) - { - PacketPool.Instance.ReturnPacket(Pack); - } - - if (Pack.Header.Zerocoded) - { - byte[] ZeroOutBuffer = new byte[4096]; - int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); - m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); - } - else - { - m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); - } + byte[] sendbuffer = Pack.ToBytes(); + if (Pack is RegionHandshakePacket) + { + PacketPool.Instance.ReturnPacket(Pack); + } + + if (Pack.Header.Zerocoded) + { + byte[] ZeroOutBuffer = new byte[4096]; + int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); + m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); + } + else + { + m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); + } } catch (Exception e) { @@ -2298,7 +2307,7 @@ namespace OpenSim.Region.ClientStack Close(true); } } - + public virtual void InPacket(Packet NewPack) { // Handle appended ACKs @@ -2314,7 +2323,7 @@ namespace OpenSim.Region.ClientStack } } } - + // Handle PacketAck packets if (NewPack.Type == PacketType.PacketAck) @@ -2353,7 +2362,7 @@ namespace OpenSim.Region.ClientStack item.Packet = NewPack; item.Incoming = false; item.throttleType = throttlePacketType; // Packet throttle type - m_packetQueue.Enqueue(item); + m_packetQueue.Enqueue(item); } # region Low Level Packet Methods @@ -2392,7 +2401,7 @@ namespace OpenSim.Region.ClientStack if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) { MainLog.Instance.Verbose("NETWORK", "Resending " + packet.Type.ToString() + " packet, " + - (now - packet.TickCount) + "ms have passed"); + (now - packet.TickCount) + "ms have passed"); packet.Header.Resent = true; OutPacket(packet, ThrottleOutPacketType.Resend); @@ -2442,6 +2451,7 @@ namespace OpenSim.Region.ClientStack } #endregion + // Previously ClientView.ProcessPackets public bool AddMoney(int debit) @@ -2539,12 +2549,13 @@ namespace OpenSim.Region.ClientStack { if (OnModifyTerrain != null) { - for (int i=0; i < modify.ParcelData.Length; i++) + for (int i = 0; i < modify.ParcelData.Length; i++) { OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, modify.ModifyBlock.Action, modify.ParcelData[i].North, - modify.ParcelData[i].West, modify.ParcelData[i].South, modify.ParcelData[i].East, this); + modify.ParcelData[i].West, modify.ParcelData[i].South, + modify.ParcelData[i].East, this); } } } @@ -2558,7 +2569,7 @@ namespace OpenSim.Region.ClientStack case PacketType.AgentWearablesRequest: if (OnRequestWearables != null) { - OnRequestWearables( ); + OnRequestWearables(); } if (OnRequestAvatarsData != null) { @@ -2575,21 +2586,23 @@ namespace OpenSim.Region.ClientStack case PacketType.AgentIsNowWearing: if (OnAvatarNowWearing != null) { - AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack; + AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket) Pack; AvatarWearingArgs wearingArgs = new AvatarWearingArgs(); for (int i = 0; i < nowWearing.WearableData.Length; i++) { - AvatarWearingArgs.Wearable wearable = new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, nowWearing.WearableData[i].WearableType); + AvatarWearingArgs.Wearable wearable = + new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, + nowWearing.WearableData[i].WearableType); wearingArgs.NowWearing.Add(wearable); } OnAvatarNowWearing(this, wearingArgs); } break; case PacketType.SetAlwaysRun: - SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; + SetAlwaysRunPacket run = (SetAlwaysRunPacket) Pack; if (OnSetAlwaysRun != null) - OnSetAlwaysRun(this,run.AgentData.AlwaysRun); + OnSetAlwaysRun(this, run.AgentData.AlwaysRun); break; case PacketType.CompleteAgentMovement: @@ -2603,7 +2616,8 @@ namespace OpenSim.Region.ClientStack { AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; - OnAgentUpdate(this, agenUpdate); //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); + OnAgentUpdate(this, agenUpdate); + //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); } break; case PacketType.AgentAnimation: @@ -2642,15 +2656,17 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.AvatarPickerRequest: - AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; - AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; - AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; - //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); + AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket) Pack; + AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; + AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; + //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); if (OnAvatarPickerRequest != null) { - OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, Helpers.FieldToUTF8String(querydata.Name)); + OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, + Helpers.FieldToUTF8String(querydata.Name)); } break; + #endregion #region Objects/m_sceneObjects @@ -2675,7 +2691,7 @@ namespace OpenSim.Region.ClientStack break; case PacketType.ObjectDelink: ObjectDelinkPacket delink = (ObjectDelinkPacket) Pack; - + // It appears the prim at index 0 is not always the root prim (for // instance, when one prim of a link set has been edited independently // of the others). Therefore, we'll pass all the ids onto the delink @@ -2683,11 +2699,11 @@ namespace OpenSim.Region.ClientStack List prims = new List(); for (int i = 0; i < delink.ObjectData.Length; i++) { - prims.Add(delink.ObjectData[i].ObjectLocalID); + prims.Add(delink.ObjectData[i].ObjectLocalID); } - + if (OnDelinkObjects != null) - { + { OnDelinkObjects(prims); } @@ -2706,7 +2722,8 @@ namespace OpenSim.Region.ClientStack { if (OnUpdatePrimShape != null) { - OnUpdatePrimShape(this.m_agentId, shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); + OnUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID, + shapePacket.ObjectData[i]); } } break; @@ -2714,7 +2731,8 @@ namespace OpenSim.Region.ClientStack ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack; if (OnUpdateExtraParams != null) { - OnUpdateExtraParams(this.m_agentId, extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, + OnUpdateExtraParams(m_agentId, extraPar.ObjectData[0].ObjectLocalID, + extraPar.ObjectData[0].ParamType, extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); } break; @@ -2726,7 +2744,8 @@ namespace OpenSim.Region.ClientStack if (OnObjectDuplicate != null) { OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, - dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, AgentandGroupData.GroupID); + dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, + AgentandGroupData.GroupID); } } @@ -2809,21 +2828,23 @@ namespace OpenSim.Region.ClientStack { if (OnObjectName != null) { - OnObjectName(this, objName.ObjectData[i].LocalID, m_encoding.GetString(objName.ObjectData[i].Name)); + OnObjectName(this, objName.ObjectData[i].LocalID, + m_encoding.GetString(objName.ObjectData[i].Name)); } } break; case PacketType.ObjectPermissions: MainLog.Instance.Warn("CLIENT", "unhandled packet " + PacketType.ObjectPermissions.ToString()); - ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; + ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket) Pack; + + List permChanges = + new List(); - List permChanges = new List(); - for (int i = 0; i < newobjPerms.ObjectData.Length; i++) { permChanges.Add(newobjPerms.ObjectData[i]); } - + // Here's our data, // PermField contains the field the info goes into // PermField determines which mask we're changing @@ -2847,16 +2868,15 @@ namespace OpenSim.Region.ClientStack case PacketType.RequestObjectPropertiesFamily: //This powers the little tooltip that appears when you move your mouse over an object - RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; - + RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket) Pack; + RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; if (OnRequestObjectPropertiesFamily != null) { - OnRequestObjectPropertiesFamily(this, this.m_agentId, packObjBlock.RequestFlags, packObjBlock.ObjectID); - - + OnRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags, + packObjBlock.ObjectID); } break; @@ -2882,7 +2902,7 @@ namespace OpenSim.Region.ClientStack OnRequestTexture(this, args); } - // m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, + // m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, // imageRequest.RequestImage[i].Packet, // imageRequest.RequestImage[i].DiscardLevel); } @@ -2898,10 +2918,11 @@ namespace OpenSim.Region.ClientStack // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); if (OnAssetUploadRequest != null) { - LLUUID temp=libsecondlife.LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); + LLUUID temp = LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); OnAssetUploadRequest(this, temp, request.AssetBlock.TransactionID, request.AssetBlock.Type, - request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, request.AssetBlock.Tempfile); + request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, + request.AssetBlock.Tempfile); } break; case PacketType.RequestXfer: @@ -2938,24 +2959,24 @@ namespace OpenSim.Region.ClientStack case PacketType.UpdateInventoryFolder: if (OnUpdateInventoryFolder != null) { - UpdateInventoryFolderPacket invFolder = (UpdateInventoryFolderPacket)Pack; + UpdateInventoryFolderPacket invFolder = (UpdateInventoryFolderPacket) Pack; for (int i = 0; i < invFolder.FolderData.Length; i++) { OnUpdateInventoryFolder(this, invFolder.FolderData[i].FolderID, - (ushort)invFolder.FolderData[i].Type, - Util.FieldToString(invFolder.FolderData[i].Name), - invFolder.FolderData[i].ParentID); + (ushort) invFolder.FolderData[i].Type, + Util.FieldToString(invFolder.FolderData[i].Name), + invFolder.FolderData[i].ParentID); } } break; case PacketType.MoveInventoryFolder: if (OnMoveInventoryFolder != null) { - MoveInventoryFolderPacket invFolder = (MoveInventoryFolderPacket)Pack; + MoveInventoryFolderPacket invFolder = (MoveInventoryFolderPacket) Pack; for (int i = 0; i < invFolder.InventoryData.Length; i++) { OnMoveInventoryFolder(this, invFolder.InventoryData[i].FolderID, - invFolder.InventoryData[i].ParentID); + invFolder.InventoryData[i].ParentID); } } break; @@ -2997,7 +3018,7 @@ namespace OpenSim.Region.ClientStack case PacketType.PurgeInventoryDescendents: if (OnPurgeInventoryDescendents != null) { - PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; + PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket) Pack; OnPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); } break; @@ -3007,11 +3028,11 @@ namespace OpenSim.Region.ClientStack { for (int i = 0; i < update.InventoryData.Length; i++) { - OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, + OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, update.InventoryData[i].ItemID, - Util.FieldToString(update.InventoryData[i].Name), + Util.FieldToString(update.InventoryData[i].Name), Util.FieldToString(update.InventoryData[i].Description), - update.InventoryData[i].NextOwnerMask); + update.InventoryData[i].NextOwnerMask); } } //Console.WriteLine(Pack.ToString()); @@ -3051,17 +3072,20 @@ namespace OpenSim.Region.ClientStack { foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) { - OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, datablock.OldItemID, datablock.NewFolderID, Util.FieldToString(datablock.NewName)); + OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, + datablock.OldItemID, datablock.NewFolderID, + Util.FieldToString(datablock.NewName)); } } break; case PacketType.MoveInventoryItem: - MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; + MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket) Pack; if (OnMoveInventoryItem != null) { foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) { - OnMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, Util.FieldToString(datablock.NewName)); + OnMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, + Util.FieldToString(datablock.NewName)); } } break; @@ -3115,7 +3139,7 @@ namespace OpenSim.Region.ClientStack case PacketType.MapNameRequest: MapNameRequestPacket map = (MapNameRequestPacket) Pack; string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0, - map.NameData.Name.Length - 1); + map.NameData.Name.Length - 1); if (OnMapNameRequest != null) { OnMapNameRequest(this, mapName); @@ -3202,29 +3226,34 @@ namespace OpenSim.Region.ClientStack break; #region Parcel related packets + case PacketType.ParcelAccessListRequest: - ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; + ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket) Pack; if (OnParcelAccessListRequest != null) { - OnParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, requestPacket.Data.Flags, requestPacket.Data.SequenceID, requestPacket.Data.LocalID,this); + OnParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, + requestPacket.Data.Flags, requestPacket.Data.SequenceID, + requestPacket.Data.LocalID, this); } - break; + break; case PacketType.ParcelAccessListUpdate: - ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; + ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket) Pack; List entries = new List(); foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = block.ID; - entry.Flags = (ParcelManager.AccessList)block.Flags; + entry.Flags = (ParcelManager.AccessList) block.Flags; entry.Time = new DateTime(); entries.Add(entry); } if (OnParcelAccessListUpdateRequest != null) { - OnParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, updatePacket.AgentData.SessionID, updatePacket.Data.Flags, updatePacket.Data.LocalID, entries, this); + OnParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, + updatePacket.AgentData.SessionID, updatePacket.Data.Flags, + updatePacket.Data.LocalID, entries, this); } break; case PacketType.ParcelPropertiesRequest: @@ -3296,28 +3325,30 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.RequestRegionInfo: - RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; - if (OnRegionInfoRequest != null) + RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket) Pack).AgentData; + if (OnRegionInfoRequest != null) { OnRegionInfoRequest(this, mPacket.SessionID); } break; case PacketType.EstateCovenantRequest: // TODO: handle this packet - EstateCovenantRequestPacket.AgentDataBlock epack = ((EstateCovenantRequestPacket)Pack).AgentData; + EstateCovenantRequestPacket.AgentDataBlock epack = + ((EstateCovenantRequestPacket) Pack).AgentData; if (OnEstateCovenantRequest != null) { OnEstateCovenantRequest(this, epack.SessionID); } break; case PacketType.AgentThrottle: - AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; + AgentThrottlePacket atpack = (AgentThrottlePacket) Pack; m_packetQueue.SetThrottleFromClient(atpack.Throttle.Throttles); break; #endregion #region unimplemented handlers + case PacketType.RequestGodlikePowers: RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket) Pack; RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; @@ -3325,16 +3356,17 @@ namespace OpenSim.Region.ClientStack RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; OnRequestGodlikePowers(ablock.AgentID, ablock.SessionID, token, this); - + break; case PacketType.GodKickUser: MainLog.Instance.Warn("CLIENT", "unhandled GodKickUser packet"); - + GodKickUserPacket gkupack = (GodKickUserPacket) Pack; - - if (gkupack.UserInfo.GodSessionID == SessionId && this.AgentId == gkupack.UserInfo.GodID) + + if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) { - OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); + OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, + gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); } else { @@ -3404,7 +3436,7 @@ namespace OpenSim.Region.ClientStack // TODO: handle this packet MainLog.Instance.Warn("CLIENT", "unhandled AgentDataUpdateRequest packet"); break; - + case PacketType.ParcelDwellRequest: // TODO: handle this packet MainLog.Instance.Warn("CLIENT", "unhandled ParcelDwellRequest packet"); @@ -3440,7 +3472,7 @@ namespace OpenSim.Region.ClientStack default: MainLog.Instance.Warn("CLIENT", "unhandled packet " + Pack.ToString()); break; - + #endregion } } @@ -3490,4 +3522,4 @@ namespace OpenSim.Region.ClientStack OutPacket(logReply, ThrottleOutPacketType.Task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs index 4c9295e..1065f63 100644 --- a/OpenSim/Region/ClientStack/PacketQueue.cs +++ b/OpenSim/Region/ClientStack/PacketQueue.cs @@ -27,17 +27,10 @@ */ using System; using System.Collections.Generic; -using System.Net; -using System.Net.Sockets; -using System.Text; using System.Threading; using System.Timers; -using Axiom.Math; -using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack @@ -47,7 +40,7 @@ namespace OpenSim.Region.ClientStack private bool m_enabled = true; private BlockingQueue SendQueue; - + private Queue IncomingPacketQueue; private Queue OutgoingPacketQueue; private Queue ResendOutgoingPacketQueue; @@ -57,7 +50,7 @@ namespace OpenSim.Region.ClientStack private Queue TaskOutgoingPacketQueue; private Queue TextureOutgoingPacketQueue; private Queue AssetOutgoingPacketQueue; - + private Dictionary PendingAcks = new Dictionary(); private Dictionary NeedAck = new Dictionary(); @@ -82,15 +75,15 @@ namespace OpenSim.Region.ClientStack // private long ThrottleInterval; private Timer throttleTimer; - public PacketQueue() + public PacketQueue() { // While working on this, the BlockingQueue had me fooled for a bit. // The Blocking queue causes the thread to stop until there's something // in it to process. it's an on-purpose threadlock though because // without it, the clientloop will suck up all sim resources. - + SendQueue = new BlockingQueue(); - + IncomingPacketQueue = new Queue(); OutgoingPacketQueue = new Queue(); ResendOutgoingPacketQueue = new Queue(); @@ -100,7 +93,7 @@ namespace OpenSim.Region.ClientStack TaskOutgoingPacketQueue = new Queue(); TextureOutgoingPacketQueue = new Queue(); AssetOutgoingPacketQueue = new Queue(); - + // Set up the throttle classes (min, max, current) in bytes ResendThrottle = new PacketThrottle(5000, 100000, 50000); @@ -114,14 +107,13 @@ namespace OpenSim.Region.ClientStack // Number of bytes allowed to go out per second. (256kbps per client) TotalThrottle = new PacketThrottle(0, 162144, 1536000); - throttleTimer = new Timer((int)(throttletimems/throttleTimeDivisor)); + throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor)); throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed); throttleTimer.Start(); - + // TIMERS needed for this // LastThrottle = DateTime.Now.Ticks; // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); - } /* STANDARD QUEUE MANIPULATION INTERFACES */ @@ -129,44 +121,48 @@ namespace OpenSim.Region.ClientStack public void Enqueue(QueItem item) { - if (!m_enabled) {return;} + if (!m_enabled) + { + return; + } // We could micro lock, but that will tend to actually // probably be worse than just synchronizing on SendQueue - lock (this) { + lock (this) + { switch (item.throttleType) { - case ThrottleOutPacketType.Resend: - ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Texture: - ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Task: - ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Land: - ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Asset: - ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Cloud: - ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); - break; - case ThrottleOutPacketType.Wind: - ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); - break; - - default: - // Acknowledgements and other such stuff should go directly to the blocking Queue - // Throttling them may and likely 'will' be problematic - SendQueue.Enqueue(item); - break; + case ThrottleOutPacketType.Resend: + ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Texture: + ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Task: + ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Land: + ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Asset: + ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Cloud: + ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); + break; + case ThrottleOutPacketType.Wind: + ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); + break; + + default: + // Acknowledgements and other such stuff should go directly to the blocking Queue + // Throttling them may and likely 'will' be problematic + SendQueue.Enqueue(item); + break; } } } - + public QueItem Dequeue() { return SendQueue.Dequeue(); @@ -174,7 +170,8 @@ namespace OpenSim.Region.ClientStack public void Flush() { - lock(this) { + lock (this) + { while (PacketsWaiting()) { //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. @@ -211,7 +208,7 @@ namespace OpenSim.Region.ClientStack } } - public void Close() + public void Close() { m_enabled = false; throttleTimer.Stop(); @@ -242,22 +239,22 @@ namespace OpenSim.Region.ClientStack public void ProcessThrottle() { - // I was considering this.. Will an event fire if the thread it's on is blocked? - + // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long // The General overhead of the UDP protocol gets sent to the queue un-throttled by this // so This'll pick up about around the right time. - + int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. int throttleLoops = 0; - + // We're going to dequeue all of the saved up packets until // we've hit the throttle limit or there's no more packets to send - lock (this) { + lock (this) + { ResetCounters(); // MainLog.Instance.Verbose("THROTTLE", "Entering Throttle"); - while (TotalThrottle.UnderLimit() && PacketsWaiting() && + while (TotalThrottle.UnderLimit() && PacketsWaiting() && (throttleLoops <= MaxThrottleLoops)) { throttleLoops++; @@ -265,7 +262,7 @@ namespace OpenSim.Region.ClientStack if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) { QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); ResendThrottle.Add(qpack.Packet.ToBytes().Length); @@ -273,7 +270,7 @@ namespace OpenSim.Region.ClientStack if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) { QueItem qpack = LandOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); LandThrottle.Add(qpack.Packet.ToBytes().Length); @@ -281,7 +278,7 @@ namespace OpenSim.Region.ClientStack if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) { QueItem qpack = WindOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); WindThrottle.Add(qpack.Packet.ToBytes().Length); @@ -289,7 +286,7 @@ namespace OpenSim.Region.ClientStack if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) { QueItem qpack = CloudOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); CloudThrottle.Add(qpack.Packet.ToBytes().Length); @@ -297,7 +294,7 @@ namespace OpenSim.Region.ClientStack if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0) { QueItem qpack = TaskOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); TaskThrottle.Add(qpack.Packet.ToBytes().Length); @@ -305,7 +302,7 @@ namespace OpenSim.Region.ClientStack if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) { QueItem qpack = TextureOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); TextureThrottle.Add(qpack.Packet.ToBytes().Length); @@ -313,19 +310,18 @@ namespace OpenSim.Region.ClientStack if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) { QueItem qpack = AssetOutgoingPacketQueue.Dequeue(); - + SendQueue.Enqueue(qpack); TotalThrottle.Add(qpack.Packet.ToBytes().Length); AssetThrottle.Add(qpack.Packet.ToBytes().Length); } } // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets"); - } } - + private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) - { + { // just to change the signature, and that ProcessThrottle // will be used elsewhere possibly ProcessThrottle(); @@ -339,7 +335,7 @@ namespace OpenSim.Region.ClientStack // wait for the timer to fire to put things into the // output queue - if((q.Count == 0) && (throttle.UnderLimit())) + if ((q.Count == 0) && (throttle.UnderLimit())) { Monitor.Enter(this); throttle.Add(item.Packet.ToBytes().Length); @@ -357,31 +353,39 @@ namespace OpenSim.Region.ClientStack private int ScaleThrottle(int value, int curmax, int newmax) { - return (int)(((float)value/(float)curmax) * newmax); + return (int) (((float) value/(float) curmax)*newmax); } + private byte[] GetThrottlesPacked(float multiplier) { int singlefloat = 4; - float tResend = ResendThrottle.Throttle * multiplier; - float tLand = LandThrottle.Throttle * multiplier; - float tWind = WindThrottle.Throttle * multiplier; - float tCloud = CloudThrottle.Throttle * multiplier; - float tTask = TaskThrottle.Throttle * multiplier; - float tTexture = TextureThrottle.Throttle * multiplier; - float tAsset = AssetThrottle.Throttle * multiplier; - - byte[] throttles = new byte[singlefloat * 7]; + float tResend = ResendThrottle.Throttle*multiplier; + float tLand = LandThrottle.Throttle*multiplier; + float tWind = WindThrottle.Throttle*multiplier; + float tCloud = CloudThrottle.Throttle*multiplier; + float tTask = TaskThrottle.Throttle*multiplier; + float tTexture = TextureThrottle.Throttle*multiplier; + float tAsset = AssetThrottle.Throttle*multiplier; + + byte[] throttles = new byte[singlefloat*7]; int i = 0; - Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat * i, singlefloat); i++; - Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat * i, singlefloat); + Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat*i, singlefloat); + i++; + Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat*i, singlefloat); return throttles; } + public void SetThrottleFromClient(byte[] throttle) { int tResend = -1; @@ -401,25 +405,25 @@ namespace OpenSim.Region.ClientStack // it might be smart to do this check more often... if (!BitConverter.IsLittleEndian) for (int i = 0; i < 7; i++) - Array.Reverse(throttle, j + i * singlefloat, singlefloat); - + Array.Reverse(throttle, j + i*singlefloat, singlefloat); + // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_ // bytes // Convert to integer, since.. the full fp space isn't used. - tResend = (int)BitConverter.ToSingle(throttle, j); + tResend = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tLand = (int)BitConverter.ToSingle(throttle, j); + tLand = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tWind = (int)BitConverter.ToSingle(throttle, j); + tWind = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tCloud = (int)BitConverter.ToSingle(throttle, j); + tCloud = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tTask = (int)BitConverter.ToSingle(throttle, j); + tTask = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tTexture = (int)BitConverter.ToSingle(throttle, j); + tTexture = (int) BitConverter.ToSingle(throttle, j); j += singlefloat; - tAsset = (int)BitConverter.ToSingle(throttle, j); - + tAsset = (int) BitConverter.ToSingle(throttle, j); + tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; /* MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend + @@ -431,13 +435,13 @@ namespace OpenSim.Region.ClientStack " Assetbytes=" + tAsset + " Allbytes=" + tall); */ - + // Total Sanity // Make sure that the client sent sane total values. - + // If the client didn't send acceptable values.... // Scale the clients values down until they are acceptable. - + if (tall <= TotalThrottle.Max) { ResendThrottle.Throttle = tResend; @@ -448,7 +452,7 @@ namespace OpenSim.Region.ClientStack TextureThrottle.Throttle = tTexture; AssetThrottle.Throttle = tAsset; TotalThrottle.Throttle = tall; - } + } else if (tall < 1) { // client is stupid, penalize him by minning everything @@ -478,4 +482,4 @@ namespace OpenSim.Region.ClientStack ResetCounters(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index a232db8..7e01adf 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs @@ -68,10 +68,11 @@ namespace OpenSim.Region.ClientStack protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, - PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) + PacketServer packServer, AgentCircuitManager authenSessions, + LLUUID agentId, LLUUID sessionId, uint circuitCode) { return - new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode ); + new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode); } public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, @@ -86,7 +87,8 @@ namespace OpenSim.Region.ClientStack else { newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, - authenticateSessionsClass, useCircuit.CircuitCode.ID, useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code); + authenticateSessionsClass, useCircuit.CircuitCode.ID, + useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code); m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); @@ -123,9 +125,8 @@ namespace OpenSim.Region.ClientStack /// public virtual void CloseCircuit(uint circuitcode) { - m_networkHandler.RemoveClientCircuit(circuitcode); - + //m_scene.ClientManager.CloseAllAgents(circuitcode); } @@ -135,4 +136,4 @@ namespace OpenSim.Region.ClientStack client.Close(false); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/PacketThrottle.cs b/OpenSim/Region/ClientStack/PacketThrottle.cs index f9a5c09..f56f4f8 100644 --- a/OpenSim/Region/ClientStack/PacketThrottle.cs +++ b/OpenSim/Region/ClientStack/PacketThrottle.cs @@ -25,26 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.Sockets; -using System.Text; -using System.Threading; -using System.Timers; -using Axiom.Math; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Console; -using Timer=System.Timers.Timer; - namespace OpenSim.Region.ClientStack { public class PacketThrottle { - private int max; // max allowable throttle private int min; // min allowable throttle private int throttle; // current throttle setting @@ -63,10 +47,10 @@ namespace OpenSim.Region.ClientStack { sent = 0; } - + public bool UnderLimit() { - return (sent < (throttle / divisor)); + return (sent < (throttle/divisor)); } public int Add(int bytes) @@ -78,27 +62,32 @@ namespace OpenSim.Region.ClientStack // Properties public int Max { - get {return max;} + get { return max; } } public int Min { - get {return min;} + get { return min; } } - + public int Throttle { - get {return throttle;} - set + get { return throttle; } + set { - if (value > max) { + if (value > max) + { throttle = max; - } else if (value < min) { + } + else if (value < min) + { throttle = min; - } else { + } + else + { throttle = value; } } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/QueItem.cs b/OpenSim/Region/ClientStack/QueItem.cs index 23b1648..ea0f680 100644 --- a/OpenSim/Region/ClientStack/QueItem.cs +++ b/OpenSim/Region/ClientStack/QueItem.cs @@ -31,14 +31,14 @@ using OpenSim.Framework; namespace OpenSim.Region.ClientStack { - public class QueItem + public class QueItem + { + public QueItem() { - public QueItem() - { - } - - public Packet Packet; - public bool Incoming; - public ThrottleOutPacketType throttleType; } -} + + public Packet Packet; + public bool Incoming; + public ThrottleOutPacketType throttleType; + } +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index f20b132..e9331e9 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Net; using libsecondlife; -using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; @@ -55,7 +54,7 @@ namespace OpenSim.Region.ClientStack protected CommunicationsManager m_commsManager; protected SceneManager m_sceneManager = new SceneManager(); - + protected StorageManager m_storageManager; protected string m_storageConnectionString; @@ -73,7 +72,7 @@ namespace OpenSim.Region.ClientStack { ClientView.TerrainManager = new TerrainManager(new SecondLife()); - m_storageManager = CreateStorageManager(m_storageConnectionString ); + m_storageManager = CreateStorageManager(m_storageConnectionString); Initialize(); @@ -142,7 +141,7 @@ namespace OpenSim.Region.ClientStack m_log.Verbose("PARCEL", "No master avatar found, using null."); scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; } - + scene.LoadPrimsFromStorage(m_permissions); scene.loadAllLandObjectsFromStorage(); scene.performParcelPrimCountUpdate(); @@ -153,4 +152,4 @@ namespace OpenSim.Region.ClientStack protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, AgentCircuitManager circuitManager); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs index 47e0b3c..10435bf 100644 --- a/OpenSim/Region/ClientStack/UDPServer.cs +++ b/OpenSim/Region/ClientStack/UDPServer.cs @@ -30,6 +30,7 @@ using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.Sockets; +using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -44,24 +45,22 @@ namespace OpenSim.Region.ClientStack { } - static readonly PacketPool instance = new PacketPool(); + private static readonly PacketPool instance = new PacketPool(); public static PacketPool Instance { - get - { - return instance; - } + get { return instance; } } private Hashtable pool = new Hashtable(); - public Packet GetPacket(PacketType type) { + public Packet GetPacket(PacketType type) + { Packet packet = null; - lock(pool) + lock (pool) { - if(pool[type] == null || ((Stack) pool[type]).Count == 0) + if (pool[type] == null || ((Stack) pool[type]).Count == 0) { // Creating a new packet if we cannot reuse an old package packet = Packet.BuildPacket(type); @@ -69,30 +68,33 @@ namespace OpenSim.Region.ClientStack else { // Recycle old packages - packet=(Packet) ((Stack) pool[type]).Pop(); + packet = (Packet) ((Stack) pool[type]).Pop(); } } return packet; } - public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer) { + public Packet GetPacket(byte[] bytes, ref int packetEnd, byte[] zeroBuffer) + { Packet packet = GetPacket(GetType(bytes, packetEnd, zeroBuffer)); int i = 0; packet.FromBytes(bytes, ref i, ref packetEnd, zeroBuffer); return packet; } + public PacketType GetType(byte[] bytes, int packetEnd, byte[] zeroBuffer) { //Function removed from LibSL revision 1540 // We're using it.. so Built it into UDP server for now.. - ushort id; libsecondlife.PacketFrequency freq; + ushort id; + PacketFrequency freq; int i = 0, end = packetEnd; Header header = Header.BuildHeader(bytes, ref i, ref end); if (header.Zerocoded) { - end = libsecondlife.Helpers.ZeroDecode(bytes, end + 1, zeroBuffer) - 1; + end = Helpers.ZeroDecode(bytes, end + 1, zeroBuffer) - 1; bytes = zeroBuffer; } @@ -100,25 +102,30 @@ namespace OpenSim.Region.ClientStack { if (bytes[7] == 0xFF) { - id = (ushort)((bytes[8] << 8) + bytes[9]); freq = libsecondlife.PacketFrequency.Low; + id = (ushort) ((bytes[8] << 8) + bytes[9]); + freq = PacketFrequency.Low; } else { - id = (ushort)bytes[7]; freq = libsecondlife.PacketFrequency.Medium; + id = (ushort) bytes[7]; + freq = PacketFrequency.Medium; } } else { - id = (ushort)bytes[6]; freq = libsecondlife.PacketFrequency.High; + id = (ushort) bytes[6]; + freq = PacketFrequency.High; } return Packet.GetType(id, freq); } - public void ReturnPacket(Packet packet) { - lock(pool) + + public void ReturnPacket(Packet packet) + { + lock (pool) { - PacketType type=packet.Type; + PacketType type = packet.Type; - if(pool[type] == null) + if (pool[type] == null) { pool[type] = new Stack(); } @@ -162,15 +169,11 @@ namespace OpenSim.Region.ClientStack m_packetServer.LocalScene = m_localScene; m_regionHandle = m_localScene.RegionInfo.RegionHandle; } - } public ulong RegionHandle { - get - { - return m_regionHandle; - } + get { return m_regionHandle; } } public UDPServer() @@ -212,30 +215,29 @@ namespace OpenSim.Region.ClientStack case SocketError.AlreadyInProgress: case SocketError.NetworkReset: case SocketError.ConnectionReset: - + try { CloseEndPoint(epSender); } - catch (System.Exception a) + catch (Exception a) { MainLog.Instance.Verbose("UDPSERVER", a.ToString()); } try { - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); - + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, + ReceivedData, null); + // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. // so therefore.. we've got to tell the server to BeginReceiveFrom again. // This will happen over and over until we've gone through all packets // sent to and from this particular user. // Stupid I know.. // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. - } catch (SocketException) { - } break; default: @@ -243,13 +245,14 @@ namespace OpenSim.Region.ClientStack { CloseEndPoint(epSender); } - catch (System.Exception) + catch (Exception) { //MainLog.Instance.Verbose("UDPSERVER", a.ToString()); } try { - Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); + Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, + ReceivedData, null); // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. // so therefore.. we've got to tell the server to BeginReceiveFrom again. @@ -257,17 +260,15 @@ namespace OpenSim.Region.ClientStack // sent to and from this particular user. // Stupid I know.. // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. - } catch (SocketException) { - } - + // Here's some reference code! :D // Shutdown and restart the UDP listener! hehe // Shiny - + //Server.Shutdown(SocketShutdown.Both); //CloseEndPoint(epSender); //ServerListener(); @@ -276,7 +277,7 @@ namespace OpenSim.Region.ClientStack return; } - catch (System.ObjectDisposedException) + catch (ObjectDisposedException) { //MainLog.Instance.Debug("UDPSERVER", e.ToString()); return; @@ -288,7 +289,7 @@ namespace OpenSim.Region.ClientStack { packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer); } - catch(Exception) + catch (Exception) { //MainLog.Instance.Debug("UDPSERVER", e.ToString()); } @@ -311,7 +312,6 @@ namespace OpenSim.Region.ClientStack } else { - // invalid client //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now //m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); @@ -326,9 +326,7 @@ namespace OpenSim.Region.ClientStack uint circuit; if (clientCircuits.TryGetValue(sender, out circuit)) { - m_packetServer.CloseCircuit(circuit); - } } @@ -381,14 +379,11 @@ namespace OpenSim.Region.ClientStack EndPoint sendto = null; if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) { - clientCircuits.Remove(sendto); - - + clientCircuits_reverse.Remove(circuitcode); - } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index 937f7c4..575d9d5 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -50,4 +50,4 @@ namespace OpenSim.Region.Communications.Local m_interRegion = interRegionService; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs index f6137f7..4dec884 100644 --- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs +++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs @@ -29,8 +29,8 @@ using System.Collections; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; namespace OpenSim.Region.Communications.Local { @@ -50,21 +50,17 @@ namespace OpenSim.Region.Communications.Local public string gdebugRegionName { get { return _gdebugRegionName; } - set - { - _gdebugRegionName = value; - } + set { _gdebugRegionName = value; } } + public string _rdebugRegionName = ""; public string rdebugRegionName { get { return _rdebugRegionName; } - set - { - _rdebugRegionName = value; - } + set { _rdebugRegionName = value; } } + public LocalBackEndServices() { } @@ -85,7 +81,8 @@ namespace OpenSim.Region.Communications.Local RegionCommsListener regionHost = new RegionCommsListener(); if (m_regionListeners.ContainsKey(regionInfo.RegionHandle)) { - MainLog.Instance.Error("INTERREGION", "Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up."); + MainLog.Instance.Error("INTERREGION", + "Error:Region registered twice as an Events listener for Interregion Communications but not as a listed region. In Standalone mode this will cause BIG issues. In grid mode, it means a region went down and came back up."); m_regionListeners.Remove(regionInfo.RegionHandle); } m_regionListeners.Add(regionInfo.RegionHandle, regionHost); @@ -195,7 +192,7 @@ namespace OpenSim.Region.Communications.Local return mapBlocks; } - + public virtual bool RegionUp(SearializableRegionInfo sregion, ulong regionhandle) { RegionInfo region = new RegionInfo(sregion); @@ -203,7 +200,7 @@ namespace OpenSim.Region.Communications.Local { return m_regionListeners[regionhandle].TriggerRegionUp(region); } - + return false; } @@ -224,7 +221,7 @@ namespace OpenSim.Region.Communications.Local // It never gets called. public virtual Dictionary GetGridSettings() { - Dictionary returnGridSettings = new Dictionary(); + Dictionary returnGridSettings = new Dictionary(); lock (m_queuedGridSettings) { returnGridSettings = m_queuedGridSettings; @@ -237,7 +234,6 @@ namespace OpenSim.Region.Communications.Local public virtual void SetForcefulBanlistsDisallowed(ulong regionHandle) { m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE"); - } public bool TriggerRegionUp(RegionInfo region, ulong regionhandle) @@ -254,7 +250,7 @@ namespace OpenSim.Region.Communications.Local { if (m_regionListeners.ContainsKey(regionHandle)) { - return m_regionListeners[regionHandle].TriggerChildAgentUpdate(regionHandle,cAgentData); + return m_regionListeners[regionHandle].TriggerChildAgentUpdate(regionHandle, cAgentData); } return false; } @@ -282,7 +278,7 @@ namespace OpenSim.Region.Communications.Local return false; } - public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData) + public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData) { if (m_regionListeners.ContainsKey(regionHandle)) { @@ -291,6 +287,7 @@ namespace OpenSim.Region.Communications.Local } return false; } + /// /// /// @@ -308,6 +305,7 @@ namespace OpenSim.Region.Communications.Local } return false; } + public bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { if (m_regionListeners.ContainsKey(regionHandle)) @@ -322,7 +320,7 @@ namespace OpenSim.Region.Communications.Local { if (m_regionListeners.ContainsKey(regionHandle)) { - m_regionListeners[regionHandle].TriggerCloseAgentConnection(regionHandle, agentID); + m_regionListeners[regionHandle].TriggerCloseAgentConnection(regionHandle, agentID); } } @@ -334,6 +332,7 @@ namespace OpenSim.Region.Communications.Local } return false; } + public bool AcknowledgePrimCrossed(ulong regionHandle, LLUUID primID) { if (m_regionListeners.ContainsKey(regionHandle)) @@ -415,14 +414,15 @@ namespace OpenSim.Region.Communications.Local { if (m_regionListeners.ContainsKey(regionHandle)) { - return m_regionListeners[regionHandle].TriggerExpectPrimCrossing(regionHandle, primID, position, isPhysical); + return + m_regionListeners[regionHandle].TriggerExpectPrimCrossing(regionHandle, primID, position, isPhysical); } return false; } public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) { - // MainLog.Instance.Verbose("INTER", rdebugRegionName + ":Local BackEnd: Other local region is sending child agent our way: " + agentData.firstname + " " + agentData.lastname); + // MainLog.Instance.Verbose("INTER", rdebugRegionName + ":Local BackEnd: Other local region is sending child agent our way: " + agentData.firstname + " " + agentData.lastname); if (m_regionListeners.ContainsKey(regionHandle)) { @@ -435,4 +435,4 @@ namespace OpenSim.Region.Communications.Local return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs index 08bd850..730c40f 100644 --- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs @@ -82,14 +82,14 @@ namespace OpenSim.Region.Communications.Local { DeleteItem(item); } - + /// /// Send the given inventory folder and its item contents back to the requester. /// /// /// private InventoryFolderImpl RequestInventoryFolder(LLUUID userID, InventoryFolderBase folder, - InventoryFolderInfo folderCallBack, + InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) { InventoryFolderImpl newFolder = new InventoryFolderImpl(folder); @@ -99,9 +99,9 @@ namespace OpenSim.Region.Communications.Local foreach (InventoryItemBase item in items) { itemCallBack(userID, item); - } - + } + return newFolder; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs index 2c08707..bf5f205 100644 --- a/OpenSim/Region/Communications/Local/LocalLoginService.cs +++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.Communications.Local if (!authUsers) { //no current user account so make one - MainLog.Instance.Notice("LOGIN", "No user account found so creating a new one."); + MainLog.Instance.Notice("LOGIN", "No user account found so creating a new one."); m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); @@ -93,14 +93,14 @@ namespace OpenSim.Region.Communications.Local if (!authUsers) { //for now we will accept any password in sandbox mode - MainLog.Instance.Notice("LOGIN", "Authorising user (no actual password check)"); - + MainLog.Instance.Notice("LOGIN", "Authorising user (no actual password check)"); + return true; } else { MainLog.Instance.Notice( - "LOGIN", "Authenticating " + profile.username + " " + profile.surname); + "LOGIN", "Authenticating " + profile.username + " " + profile.surname); password = password.Remove(0, 3); //remove $1$ @@ -134,7 +134,7 @@ namespace OpenSim.Region.Communications.Local // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; theUser.currentAgent.currentRegion = reg.RegionID; theUser.currentAgent.currentHandle = reg.RegionHandle; - + LoginResponse.BuddyList buddyList = new LoginResponse.BuddyList(); buddyList.AddNewBuddy(new LoginResponse.BuddyList.BuddyInfo("11111111-1111-0000-0000-000100bba000")); response.BuddList = buddyList; @@ -157,7 +157,7 @@ namespace OpenSim.Region.Communications.Local } else { - MainLog.Instance.Warn("LOGIN", "Not found region " + currentRegion); + MainLog.Instance.Warn("LOGIN", "Not found region " + currentRegion); } } @@ -207,4 +207,4 @@ namespace OpenSim.Region.Communications.Local } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index d8c4b1d..6269565 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -27,6 +27,7 @@ */ using System; +using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.UserManagement; @@ -82,7 +83,7 @@ namespace OpenSim.Region.Communications.Local return profile; } - public override UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid) + public override UserProfileData SetupMasterUser(LLUUID uuid) { UserProfileData data = GetUserProfile(uuid); if (data == null) diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 2754c4e..8d52eeb 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -60,23 +60,17 @@ namespace OpenSim.Region.Communications.OGS1 public string gdebugRegionName { get { return _gdebugRegionName; } - set - { - _gdebugRegionName = value; - - } + set { _gdebugRegionName = value; } } + public string _rdebugRegionName = ""; public string rdebugRegionName { get { return _rdebugRegionName; } - set - { - _rdebugRegionName = value; - - } + set { _rdebugRegionName = value; } } + /// /// /// @@ -128,7 +122,7 @@ namespace OpenSim.Region.Communications.OGS1 // Process Response if (GridRespData.ContainsKey("error")) { - string errorstring = (string)GridRespData["error"]; + string errorstring = (string) GridRespData["error"]; MainLog.Instance.Error("Unable to connect to grid: " + errorstring); return null; } @@ -137,14 +131,12 @@ namespace OpenSim.Region.Communications.OGS1 m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY); if (GridRespData.ContainsKey("allow_forceful_banlines")) { - - if ((string)GridRespData["allow_forceful_banlines"] != "TRUE") + if ((string) GridRespData["allow_forceful_banlines"] != "TRUE") { //m_localBackend.SetForcefulBanlistsDisallowed(regionInfo.RegionHandle); m_queuedGridSettings.Add("allow_forceful_banlines", "FALSE"); } } - } return m_localBackend.RegisterRegion(regionInfo); } @@ -153,6 +145,7 @@ namespace OpenSim.Region.Communications.OGS1 { return false; } + public virtual Dictionary GetGridSettings() { Dictionary returnGridSettings = new Dictionary(); @@ -161,15 +154,15 @@ namespace OpenSim.Region.Communications.OGS1 foreach (string Dictkey in m_queuedGridSettings.Keys) { returnGridSettings.Add(Dictkey, m_queuedGridSettings[Dictkey]); - } - + m_queuedGridSettings.Clear(); } return returnGridSettings; } + /// /// /// @@ -223,7 +216,7 @@ namespace OpenSim.Region.Communications.OGS1 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); - Hashtable responseData = (Hashtable)GridResp.Value; + Hashtable responseData = (Hashtable) GridResp.Value; if (responseData.ContainsKey("error")) { @@ -231,29 +224,30 @@ namespace OpenSim.Region.Communications.OGS1 return null; } - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string internalIpStr = (string)responseData["sim_ip"]; + uint regX = Convert.ToUInt32((string) responseData["region_locx"]); + uint regY = Convert.ToUInt32((string) responseData["region_locy"]); + string internalIpStr = (string) responseData["sim_ip"]; uint port = Convert.ToUInt32(responseData["sim_port"]); - string externalUri = (string)responseData["sim_uri"]; + string externalUri = (string) responseData["sim_uri"]; - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); string neighbourExternalUri = externalUri; regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; - regionInfo.RegionID = new LLUUID((string)responseData["region_UUID"]); - regionInfo.RegionName = (string)responseData["region_name"]; + regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); + regionInfo.RegionName = (string) responseData["region_name"]; if (requestData.ContainsKey("regionHandle")) { - m_remoteRegionInfoCache.Add(Convert.ToUInt64((string)requestData["regionHandle"]), regionInfo); + m_remoteRegionInfoCache.Add(Convert.ToUInt64((string) requestData["regionHandle"]), regionInfo); } return regionInfo; } + /// /// /// @@ -283,7 +277,7 @@ namespace OpenSim.Region.Communications.OGS1 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); - Hashtable responseData = (Hashtable)GridResp.Value; + Hashtable responseData = (Hashtable) GridResp.Value; if (responseData.ContainsKey("error")) { @@ -291,27 +285,29 @@ namespace OpenSim.Region.Communications.OGS1 return null; } - uint regX = Convert.ToUInt32((string)responseData["region_locx"]); - uint regY = Convert.ToUInt32((string)responseData["region_locy"]); - string internalIpStr = (string)responseData["sim_ip"]; + uint regX = Convert.ToUInt32((string) responseData["region_locx"]); + uint regY = Convert.ToUInt32((string) responseData["region_locy"]); + string internalIpStr = (string) responseData["sim_ip"]; uint port = Convert.ToUInt32(responseData["sim_port"]); - string externalUri = (string)responseData["sim_uri"]; + string externalUri = (string) responseData["sim_uri"]; - IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port); string neighbourExternalUri = externalUri; regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); - regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + regionInfo.RemotingPort = Convert.ToUInt32((string) responseData["remoting_port"]); regionInfo.RemotingAddress = internalIpStr; - regionInfo.RegionID = new LLUUID((string)responseData["region_UUID"]); - regionInfo.RegionName = (string)responseData["region_name"]; + regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); + regionInfo.RegionName = (string) responseData["region_name"]; m_remoteRegionInfoCache.Add(regionHandle, regionInfo); } - catch (System.Net.WebException) + catch (WebException) { - MainLog.Instance.Error("GRID", "Region lookup failed for: " + regionHandle.ToString() + " - Is the GridServer down?"); + MainLog.Instance.Error("GRID", + "Region lookup failed for: " + regionHandle.ToString() + + " - Is the GridServer down?"); return null; } } @@ -462,12 +458,7 @@ namespace OpenSim.Region.Communications.OGS1 return new XmlRpcResponse(); } - - - - - #region m_interRegion Comms /// @@ -510,8 +501,8 @@ namespace OpenSim.Region.Communications.OGS1 bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof (OGS1InterRegionRemoting), "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); @@ -525,7 +516,10 @@ namespace OpenSim.Region.Communications.OGS1 Console.WriteLine("remoting object not found"); } remObject = null; - MainLog.Instance.Verbose("INTER", gdebugRegionName + ": OGS1 tried to Update Child Agent data on outside region and got " + retValue.ToString()); + MainLog.Instance.Verbose("INTER", + gdebugRegionName + + ": OGS1 tried to Update Child Agent data on outside region and got " + + retValue.ToString()); return retValue; } @@ -534,35 +528,39 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (Exception e) { - MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } - } /// @@ -571,7 +569,6 @@ namespace OpenSim.Region.Communications.OGS1 /// /// /// - public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) { RegionInfo regInfo = null; @@ -604,7 +601,10 @@ namespace OpenSim.Region.Communications.OGS1 Console.WriteLine("remoting object not found"); } remObject = null; - MainLog.Instance.Verbose("INTER", gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " + agentData.firstname + " " + agentData.lastname + " and got " + retValue.ToString()); + MainLog.Instance.Verbose("INTER", + gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " + + agentData.firstname + " " + agentData.lastname + " and got " + + retValue.ToString()); return retValue; } @@ -613,31 +613,36 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (Exception e) { - MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -656,7 +661,7 @@ namespace OpenSim.Region.Communications.OGS1 region = new SearializableRegionInfo(RequestNeighbourInfo(region.RegionHandle)); region.RemotingAddress = region.ExternalHostName; region.RemotingPort = NetworkServersInfo.RemotingListenerPort; - if (m_localBackend.RegionUp(region,regionhandle)) + if (m_localBackend.RegionUp(region, regionhandle)) { return true; } @@ -671,9 +676,11 @@ namespace OpenSim.Region.Communications.OGS1 bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), - "tcp://" + regInfo.RemotingAddress + + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof ( + OGS1InterRegionRemoting), + "tcp://" + + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); @@ -703,33 +710,39 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - Is this neighbor up?"); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + + " - Is this neighbor up?"); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - Is this neighbor up?"); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + + " - Is this neighbor up?"); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - ":" + regInfo.RemotingPort + - "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region using tcp://" + + regInfo.RemotingAddress + + ":" + regInfo.RemotingPort + + "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -737,25 +750,25 @@ namespace OpenSim.Region.Communications.OGS1 { // This line errors with a Null Reference Exception.. Why? @.@ //MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + - // ":" + regInfo.RemotingPort + - //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); + // ":" + regInfo.RemotingPort + + //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); MainLog.Instance.Debug(e.ToString()); return false; } } + /// /// /// /// /// /// - public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData) { RegionInfo regInfo = null; try { - if (m_localBackend.InformRegionOfPrimCrossing(regionHandle,primID, objData)) + if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData)) { return true; } @@ -775,7 +788,7 @@ namespace OpenSim.Region.Communications.OGS1 if (remObject != null) { - retValue = remObject.InformRegionOfPrimCrossing(regionHandle,primID.UUID, objData); + retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.UUID, objData); } else { @@ -791,35 +804,41 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (SocketException e) { - MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Socket Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (InvalidCredentialException e) { - MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Invalid Credentials: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (AuthenticationException e) { - MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Authentication exception: Unable to connect to adjacent region: " + + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } catch (Exception e) { - MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Unknown exception: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } } + /// /// /// @@ -848,7 +867,9 @@ namespace OpenSim.Region.Communications.OGS1 "/InterRegions"); if (remObject != null) { - retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), isFlying); + retValue = + remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), + isFlying); } else { @@ -864,7 +885,8 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -873,6 +895,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool ExpectPrimCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isPhysical) { RegionInfo regInfo = null; @@ -887,14 +910,16 @@ namespace OpenSim.Region.Communications.OGS1 if (regInfo != null) { bool retValue = false; - OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( - typeof(OGS1InterRegionRemoting), + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject( + typeof (OGS1InterRegionRemoting), "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); if (remObject != null) { - retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), isPhysical); + retValue = + remObject.ExpectAvatarCrossing(regionHandle, agentID.UUID, new sLLVector3(position), + isPhysical); } else { @@ -910,7 +935,8 @@ namespace OpenSim.Region.Communications.OGS1 } catch (RemotingException e) { - MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); + MainLog.Instance.Warn("Remoting Error: Unable to connect to adjacent region: " + regInfo.RegionName + + " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); MainLog.Instance.Debug(e.ToString()); return false; } @@ -922,7 +948,6 @@ namespace OpenSim.Region.Communications.OGS1 public void TellRegionToCloseChildConnection(ulong regionHandle, LLUUID agentID) { - } public bool AcknowledgeAgentCrossed(ulong regionHandle, LLUUID agentId) @@ -934,6 +959,7 @@ namespace OpenSim.Region.Communications.OGS1 { return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId); } + #endregion #region Methods triggered by calls from external instances @@ -961,8 +987,9 @@ namespace OpenSim.Region.Communications.OGS1 public bool TriggerRegionUp(SearializableRegionInfo regionData, ulong regionhandle) { - - MainLog.Instance.Verbose("INTER", gdebugRegionName + "Incoming OGS1 RegionUpReport: " + "(" + regionData.RegionLocX + "," + regionData.RegionLocY + ")"); + MainLog.Instance.Verbose("INTER", + gdebugRegionName + "Incoming OGS1 RegionUpReport: " + "(" + regionData.RegionLocX + + "," + regionData.RegionLocY + ")"); try { @@ -975,6 +1002,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { MainLog.Instance.Verbose("INTER", "Incoming OGS1 Child Agent Data Update"); @@ -988,7 +1016,6 @@ namespace OpenSim.Region.Communications.OGS1 MainLog.Instance.Error("Remoting Error: Unable to connect to adjacent region.\n" + e.ToString()); return false; } - } /// @@ -1012,6 +1039,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + /// /// /// @@ -1031,6 +1059,7 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool TriggerExpectPrimCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isPhysical) { try @@ -1048,4 +1077,4 @@ namespace OpenSim.Region.Communications.OGS1 #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs index 683c471..a0da07e 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs @@ -41,7 +41,7 @@ namespace OpenSim.Region.Communications.OGS1 public delegate bool PrimGroupArrival(ulong regionHandle, LLUUID primID, string objData); - public delegate bool RegionUp (SearializableRegionInfo region, ulong regionhandle); + public delegate bool RegionUp(SearializableRegionInfo region, ulong regionhandle); public delegate bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate childUpdate); @@ -81,7 +81,6 @@ namespace OpenSim.Region.Communications.OGS1 public bool RegionUp(SearializableRegionInfo sregion, ulong regionhandle) { - if (OnRegionUp != null) { return OnRegionUp(sregion, regionhandle); @@ -106,6 +105,7 @@ namespace OpenSim.Region.Communications.OGS1 } return false; } + public bool InformRegionPrim(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { if (OnPrimGroupNear != null) @@ -114,6 +114,7 @@ namespace OpenSim.Region.Communications.OGS1 } return false; } + public bool ExpectPrimCrossing(ulong regionHandle, LLUUID primID, string objData) { if (OnPrimGroupArrival != null) @@ -134,7 +135,8 @@ namespace OpenSim.Region.Communications.OGS1 { try { - return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, new AgentCircuitData(agentData)); + return + InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, new AgentCircuitData(agentData)); } catch (RemotingException e) { @@ -142,7 +144,8 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } - public bool RegionUp(SearializableRegionInfo region, ulong regionhandle) + + public bool RegionUp(SearializableRegionInfo region, ulong regionhandle) { try { @@ -155,25 +158,27 @@ namespace OpenSim.Region.Communications.OGS1 } } - public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) + public bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { try { - return InterRegionSingleton.Instance.ChildAgentUpdate(regionHandle,cAgentData); + return InterRegionSingleton.Instance.ChildAgentUpdate(regionHandle, cAgentData); } catch (RemotingException e) { Console.WriteLine("Remoting Error: Unable to send Child agent update to remote region.\n" + e.ToString()); return false; } - } public bool ExpectAvatarCrossing(ulong regionHandle, Guid agentID, sLLVector3 position, bool isFlying) { try { - return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, new LLUUID(agentID), new LLVector3(position.x,position.y,position.z), isFlying); + return + InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, new LLUUID(agentID), + new LLVector3(position.x, position.y, position.z), + isFlying); } catch (RemotingException e) { @@ -181,20 +186,24 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } + public bool InformRegionPrim(ulong regionHandle, Guid SceneObjectGroupID, sLLVector3 position, bool isPhysical) { try { - return InterRegionSingleton.Instance.InformRegionPrim(regionHandle, new LLUUID(SceneObjectGroupID), new LLVector3(position.x,position.y,position.z), isPhysical); + return + InterRegionSingleton.Instance.InformRegionPrim(regionHandle, new LLUUID(SceneObjectGroupID), + new LLVector3(position.x, position.y, position.z), + isPhysical); } catch (RemotingException e) { Console.WriteLine("Remoting Error: Unable to connect to remote region.\n" + e.ToString()); return false; } - } - public bool InformRegionOfPrimCrossing(ulong regionHandle,Guid primID, string objData) + + public bool InformRegionOfPrimCrossing(ulong regionHandle, Guid primID, string objData) { try { @@ -206,6 +215,5 @@ namespace OpenSim.Region.Communications.OGS1 return false; } } - } } \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index 0fb083a..0d97074 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs @@ -29,10 +29,10 @@ using System; using System.Collections.Generic; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Servers; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; namespace OpenSim.Region.Communications.OGS1 { @@ -51,7 +51,7 @@ namespace OpenSim.Region.Communications.OGS1 // See IInventoryServices public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) - { + { if (!m_RequestingInventory.ContainsKey(userID)) { InventoryRequest request = new InventoryRequest(userID, folderCallBack, itemCallBack); @@ -72,10 +72,10 @@ namespace OpenSim.Region.Communications.OGS1 try { MainLog.Instance.Verbose( - "INVENTORY", "Requesting inventory from {0}/GetInventory/ for user {1}", + "INVENTORY", "Requesting inventory from {0}/GetInventory/ for user {1}", _inventoryServerUrl, userID); - - RestObjectPosterResponse requester + + RestObjectPosterResponse requester = new RestObjectPosterResponse(); requester.ResponseCallback = InventoryResponse; @@ -96,10 +96,10 @@ namespace OpenSim.Region.Communications.OGS1 LLUUID userID = response.UserID; if (m_RequestingInventory.ContainsKey(userID)) { - MainLog.Instance.Verbose("INVENTORY", - "Received inventory response for user {0} containing {1} folders and {2} items", + MainLog.Instance.Verbose("INVENTORY", + "Received inventory response for user {0} containing {1} folders and {2} items", userID, response.Folders.Count, response.AllItems.Count); - + InventoryFolderImpl rootFolder = null; InventoryRequest request = m_RequestingInventory[userID]; foreach (InventoryFolderBase folder in response.Folders) @@ -133,8 +133,8 @@ namespace OpenSim.Region.Communications.OGS1 else { MainLog.Instance.Warn( - "INVENTORY", - "Received inventory response for {0} for which we do not have a record of requesting!", + "INVENTORY", + "Received inventory response for {0} for which we do not have a record of requesting!", userID); } } @@ -150,7 +150,7 @@ namespace OpenSim.Region.Communications.OGS1 SynchronousRestObjectPoster.BeginPostObject( "POST", _inventoryServerUrl + "/MoveFolder/", folder); } - + public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) { SynchronousRestObjectPoster.BeginPostObject( @@ -188,4 +188,4 @@ namespace OpenSim.Region.Communications.OGS1 } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index c1e6ba6..3a2e138 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -30,6 +30,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Net; +using System.Text.RegularExpressions; using libsecondlife; using Nwc.XmlRpc; using OpenSim.Framework; @@ -50,7 +51,9 @@ namespace OpenSim.Region.Communications.OGS1 { if (data.Contains("error_type")) { - MainLog.Instance.Warn("GRID", "Error sent by user server when trying to get user profile: (" + data["error_type"] + + MainLog.Instance.Warn("GRID", + "Error sent by user server when trying to get user profile: (" + + data["error_type"] + "): " + data["error_desc"]); return null; } @@ -80,19 +83,19 @@ namespace OpenSim.Region.Communications.OGS1 return userData; } - public List ConvertXMLRPCDataToAvatarPickerList(LLUUID queryID,Hashtable data) + public List ConvertXMLRPCDataToAvatarPickerList(LLUUID queryID, Hashtable data) { List pickerlist = new List(); - int pickercount = Convert.ToInt32((string)data["avcount"]); - LLUUID respqueryID = new LLUUID((string)data["queryid"]); + int pickercount = Convert.ToInt32((string) data["avcount"]); + LLUUID respqueryID = new LLUUID((string) data["queryid"]); if (queryID == respqueryID) { for (int i = 0; i < pickercount; i++) { AvatarPickerAvatar apicker = new AvatarPickerAvatar(); - LLUUID avatarID = new LLUUID((string)data["avatarid" + i.ToString()]); - string firstname = (string)data["firstname" + i.ToString()]; - string lastname = (string)data["lastname" + i.ToString()]; + LLUUID avatarID = new LLUUID((string) data["avatarid" + i.ToString()]); + string firstname = (string) data["firstname" + i.ToString()]; + string lastname = (string) data["lastname" + i.ToString()]; apicker.AvatarID = avatarID; apicker.firstName = firstname; apicker.lastName = lastname; @@ -114,18 +117,18 @@ namespace OpenSim.Region.Communications.OGS1 public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query) { List pickerlist = new List(); - System.Text.RegularExpressions.Regex objAlphaNumericPattern = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 ]"); + Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9 ]"); try { Hashtable param = new Hashtable(); - param["queryid"] = (string)queryID.ToString(); + param["queryid"] = (string) queryID.ToString(); param["avquery"] = objAlphaNumericPattern.Replace(query, ""); IList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest("get_avatar_picker_avatar", parameters); XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); - Hashtable respData = (Hashtable)resp.Value; - pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID,respData); + Hashtable respData = (Hashtable) resp.Value; + pickerlist = ConvertXMLRPCDataToAvatarPickerList(queryID, respData); } catch (WebException e) { @@ -196,7 +199,7 @@ namespace OpenSim.Region.Communications.OGS1 return profile; } - public UserProfileData SetupMasterUser(libsecondlife.LLUUID uuid) + public UserProfileData SetupMasterUser(LLUUID uuid) { UserProfileData data = GetUserProfile(uuid); if (data == null) @@ -211,4 +214,4 @@ namespace OpenSim.Region.Communications.OGS1 throw new Exception("The method or operation is not implemented."); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs index 081a8cd..3ca9796 100644 --- a/OpenSim/Region/Environment/EstateManager.cs +++ b/OpenSim/Region/Environment/EstateManager.cs @@ -334,6 +334,7 @@ namespace OpenSim.Region.Environment } } } + private void estateRestartSim(EstateOwnerMessagePacket packet) { // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart. @@ -341,26 +342,25 @@ namespace OpenSim.Region.Environment { float timeSeconds = 0; timeSeconds = BitConverter.ToInt16(block.Parameter, 1); - timeSeconds = (int)((timeSeconds / 100) - 3); + timeSeconds = (int) ((timeSeconds/100) - 3); m_scene.Restart(timeSeconds); - } } + private void EstateChangeCovenant(EstateOwnerMessagePacket packet) { foreach (EstateOwnerMessagePacket.ParamListBlock block in packet.ParamList) { LLUUID newCovenantID = new LLUUID(Helpers.FieldToUTF8String(block.Parameter)); m_regInfo.CovenantID = newCovenantID; - } - } + public void HandleRegionInfoRequest(IClientAPI client, LLUUID sessionID) { RegionInfoPacket rinfopack = new RegionInfoPacket(); RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock(); - + rinfoblk.BillableFactor = 0; rinfoblk.EstateID = 02; rinfoblk.MaxAgents = 100; @@ -369,20 +369,20 @@ namespace OpenSim.Region.Environment rinfoblk.PricePerMeter = 0; rinfoblk.RedirectGridX = 0; rinfoblk.RedirectGridY = 0; - rinfoblk.RegionFlags = (uint)m_regInfo.EstateSettings.regionFlags; - rinfoblk.SimAccess = (byte)m_regInfo.EstateSettings.simAccess; + rinfoblk.RegionFlags = (uint) m_regInfo.EstateSettings.regionFlags; + rinfoblk.SimAccess = (byte) m_regInfo.EstateSettings.simAccess; rinfoblk.SunHour = m_regInfo.EstateSettings.sunHour; rinfoblk.TerrainLowerLimit = 20; rinfoblk.TerrainRaiseLimit = 20; rinfoblk.UseEstateSun = true; rinfoblk.WaterHeight = m_regInfo.EstateSettings.waterHeight; rinfoblk.SimName = Helpers.StringToField(m_regInfo.RegionName); - + rinfopack.RegionInfo = rinfoblk; client.OutPacket(rinfopack, ThrottleOutPacketType.Task); - } + public void HandleEstateCovenantRequest(IClientAPI client, LLUUID sessionID) { EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket(); @@ -390,10 +390,12 @@ namespace OpenSim.Region.Environment edata.CovenantID = m_regInfo.CovenantID; edata.CovenantTimestamp = 0; edata.EstateOwnerID = m_regInfo.MasterAvatarAssignedUUID; - edata.EstateName = Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName); + edata.EstateName = + Helpers.StringToField(m_regInfo.MasterAvatarFirstName + " " + m_regInfo.MasterAvatarLastName); einfopack.Data = edata; client.OutPacket(einfopack, ThrottleOutPacketType.Task); } + #endregion #region Outgoing Packets @@ -451,4 +453,4 @@ namespace OpenSim.Region.Environment #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs index ee4d8bc..fb83150 100644 --- a/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs +++ b/OpenSim/Region/Environment/Interfaces/IAvatarFactory.cs @@ -27,7 +27,6 @@ */ using libsecondlife; -using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Interfaces diff --git a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs index c974616..6aa8f35 100644 --- a/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Environment/Interfaces/IHttpRequests.cs @@ -26,9 +26,9 @@ * */ +using System.Collections.Generic; using libsecondlife; using OpenSim.Region.Environment.Modules; -using System.Collections.Generic; namespace OpenSim.Region.Environment.Interfaces { diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 91aa5ff..78ad428 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -51,10 +52,10 @@ namespace OpenSim.Region.Environment.Interfaces void StoreTerrain(double[,] terrain, LLUUID regionID); double[,] LoadTerrain(LLUUID regionID); - void StoreLandObject(Land Parcel,LLUUID regionUUID); + void StoreLandObject(Land Parcel, LLUUID regionUUID); void RemoveLandObject(LLUUID globalID); - List LoadLandObjects(LLUUID regionUUID); + List LoadLandObjects(LLUUID regionUUID); void Shutdown(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 7977c78..ff16319 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -32,7 +32,6 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.LandManagement { @@ -98,7 +97,6 @@ namespace OpenSim.Region.Environment.LandManagement return newLand; } - #endregion #region Packet Request Handling @@ -202,7 +200,7 @@ namespace OpenSim.Region.Environment.LandManagement //Needs later group support LandData newData = landData.Copy(); newData.authBuyerID = packet.ParcelData.AuthBuyerID; - newData.category = (Parcel.ParcelCategory)packet.ParcelData.Category; + newData.category = (Parcel.ParcelCategory) packet.ParcelData.Category; newData.landDesc = Helpers.FieldToUTF8String(packet.ParcelData.Desc); newData.groupID = packet.ParcelData.GroupID; newData.landingType = packet.ParcelData.LandingType; @@ -222,8 +220,6 @@ namespace OpenSim.Region.Environment.LandManagement m_scene.LandManager.updateLandObject(landData.localID, newData); sendLandUpdateToAvatarsOverMe(); - - } } @@ -242,13 +238,13 @@ namespace OpenSim.Region.Environment.LandManagement public bool isBannedFromLand(LLUUID avatar) { - if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseBanList) > 0) + if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseBanList) > 0) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = avatar; entry.Flags = ParcelManager.AccessList.Ban; entry.Time = new DateTime(); - if (this.landData.parcelAccessList.Contains(entry)) + if (landData.parcelAccessList.Contains(entry)) { //They are banned, so lets send them a notice about this parcel return true; @@ -259,13 +255,13 @@ namespace OpenSim.Region.Environment.LandManagement public bool isRestrictedFromLand(LLUUID avatar) { - if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseAccessList) > 0) + if ((landData.landFlags & (uint) Parcel.ParcelFlags.UseAccessList) > 0) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); entry.AgentID = avatar; entry.Flags = ParcelManager.AccessList.Access; entry.Time = new DateTime(); - if (!this.landData.parcelAccessList.Contains(entry)) + if (!landData.parcelAccessList.Contains(entry)) { //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel return true; @@ -310,7 +306,7 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); - listBlock.Flags = (uint)0; + listBlock.Flags = (uint) 0; listBlock.ID = entry.AgentID; listBlock.Time = 0; @@ -322,7 +318,7 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock(); - listBlock.Flags = (uint)0; + listBlock.Flags = (uint) 0; listBlock.ID = LLUUID.Zero; listBlock.Time = 0; @@ -331,38 +327,37 @@ namespace OpenSim.Region.Environment.LandManagement return list.ToArray(); } - public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, IClientAPI remote_client) + public void sendAccessList(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, + IClientAPI remote_client) { - ParcelAccessListReplyPacket replyPacket; - if (flags == (uint)ParcelManager.AccessList.Access || flags == (uint)ParcelManager.AccessList.Both) + if (flags == (uint) ParcelManager.AccessList.Access || flags == (uint) ParcelManager.AccessList.Both) { replyPacket = new ParcelAccessListReplyPacket(); replyPacket.Data.AgentID = agentID; - replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Access; - replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Access; + replyPacket.Data.LocalID = landData.localID; replyPacket.Data.SequenceID = 0; replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access); - remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); } - if (flags == (uint)ParcelManager.AccessList.Ban || flags == (uint)ParcelManager.AccessList.Both) + if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both) { replyPacket = new ParcelAccessListReplyPacket(); replyPacket.Data.AgentID = agentID; - replyPacket.Data.Flags = (uint)ParcelManager.AccessList.Ban; - replyPacket.Data.LocalID = this.landData.localID; + replyPacket.Data.Flags = (uint) ParcelManager.AccessList.Ban; + replyPacket.Data.LocalID = landData.localID; replyPacket.Data.SequenceID = 0; replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban); - remote_client.OutPacket((Packet)replyPacket, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task); } - } - public void updateAccessList(uint flags, List entries, IClientAPI remote_client) + public void updateAccessList(uint flags, List entries, IClientAPI remote_client) { LandData newData = landData.Copy(); @@ -370,11 +365,11 @@ namespace OpenSim.Region.Environment.LandManagement { entries.Clear(); } - + List toRemove = new List(); foreach (ParcelManager.ParcelAccessEntry entry in newData.parcelAccessList) { - if (entry.Flags == (ParcelManager.AccessList)flags) + if (entry.Flags == (ParcelManager.AccessList) flags) { toRemove.Add(entry); } @@ -388,8 +383,8 @@ namespace OpenSim.Region.Environment.LandManagement { ParcelManager.ParcelAccessEntry temp = new ParcelManager.ParcelAccessEntry(); temp.AgentID = entry.AgentID; - temp.Time = new DateTime() ; //Pointless? Yes. - temp.Flags = (ParcelManager.AccessList)flags; + temp.Time = new DateTime(); //Pointless? Yes. + temp.Flags = (ParcelManager.AccessList) flags; if (!newData.parcelAccessList.Contains(temp)) { @@ -398,7 +393,6 @@ namespace OpenSim.Region.Environment.LandManagement } m_scene.LandManager.updateLandObject(landData.localID, newData); - } #endregion @@ -437,7 +431,6 @@ namespace OpenSim.Region.Environment.LandManagement new LLVector3((float) (max_x*4), (float) (max_y*4), (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4))); landData.area = tempArea; - } public void updateLandBitmapByteArray() @@ -650,9 +643,9 @@ namespace OpenSim.Region.Environment.LandManagement { resultLocalIDs.Add(obj.LocalId); } - // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support - // { - // } + // else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && ...) // TODO: group support + // { + // } else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.OwnerID != remote_client.AgentId) { @@ -732,10 +725,8 @@ namespace OpenSim.Region.Environment.LandManagement num++; } - + pack.Data = dataBlock; - - } remote_client.OutPacket(pack, ThrottleOutPacketType.Task); } diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index ecd458d..772fe2e 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -27,11 +27,13 @@ */ using System; using System.Collections.Generic; +using Axiom.Math; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.LandManagement { @@ -93,7 +95,7 @@ namespace OpenSim.Region.Environment.LandManagement private readonly RegionInfo m_regInfo; public bool allowedForcefulBans = true; - + #endregion #region Constructors @@ -103,14 +105,13 @@ namespace OpenSim.Region.Environment.LandManagement m_scene = scene; m_regInfo = reginfo; landIDList.Initialize(); - scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); - scene.EventManager.OnClientMovement += new EventManager.ClientMovement(this.handleAnyClientMovement); + scene.EventManager.OnAvatarEnteringNewParcel += + new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); + scene.EventManager.OnClientMovement += new EventManager.ClientMovement(handleAnyClientMovement); } - - #endregion - + #region Member Functions #region Land Object From Storage Functions @@ -147,7 +148,6 @@ namespace OpenSim.Region.Environment.LandManagement /// public Land createBaseLand() { - return new Land(LLUUID.Zero, false, m_scene); } @@ -175,7 +175,7 @@ namespace OpenSim.Region.Environment.LandManagement } } landList[lastLandLocalID].forceUpdateLandInfo(); - m_scene.EventManager.TriggerLandObjectAdded(new_land,m_scene.RegionInfo.RegionID); + m_scene.EventManager.TriggerLandObjectAdded(new_land, m_scene.RegionInfo.RegionID); return new_land; } @@ -207,7 +207,7 @@ namespace OpenSim.Region.Environment.LandManagement if (landList.ContainsKey(local_id)) { landList[local_id].landData = newData.Copy(); - m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); + m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]); } else { @@ -335,7 +335,7 @@ namespace OpenSim.Region.Environment.LandManagement //Now add the new land object Land result = addLandObject(newLand); - updateLandObject(startLandObject.landData.localID,startLandObject.landData); + updateLandObject(startLandObject.landData.localID, startLandObject.landData); result.sendLandUpdateToAvatarsOverMe(); @@ -463,11 +463,11 @@ namespace OpenSim.Region.Environment.LandManagement Land southParcel = null; if (x > 0) { - westParcel = getLandObject((x - 1) * 4, y * 4); + westParcel = getLandObject((x - 1)*4, y*4); } if (y > 0) { - southParcel = getLandObject(x * 4, (y - 1) * 4); + southParcel = getLandObject(x*4, (y - 1)*4); } if (x == 0) @@ -496,14 +496,15 @@ namespace OpenSim.Region.Environment.LandManagement packet = new ParcelOverlayPacket(); packet.ParcelData.Data = byteArray; packet.ParcelData.SequenceID = sequenceID; - remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); + remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task); sequenceID++; byteArray = new byte[LAND_BLOCKS_PER_PACKET]; } } - catch (System.Exception e) + catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Debug("LAND", "Skipped Land checks because avatar is out of bounds: " + e.Message); + MainLog.Instance.Debug("LAND", + "Skipped Land checks because avatar is out of bounds: " + e.Message); } } } @@ -599,7 +600,6 @@ namespace OpenSim.Region.Environment.LandManagement public List parcelsNearPoint(LLVector3 position) { - List parcelsNear = new List(); int x, y; for (x = -4; x <= 4; x += 4) @@ -617,22 +617,25 @@ namespace OpenSim.Region.Environment.LandManagement } } - return parcelsNear; - + return parcelsNear; } public void sendYouAreBannedNotice(ScenePresence avatar) { if (allowedForcefulBans) { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); - avatar.PhysicsActor.Position = new OpenSim.Region.Physics.Manager.PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, avatar.lastKnownAllowedPosition.z); - avatar.PhysicsActor.Velocity = new OpenSim.Region.Physics.Manager.PhysicsVector(0, 0, 0); + avatar.PhysicsActor.Position = + new PhysicsVector(avatar.lastKnownAllowedPosition.x, avatar.lastKnownAllowedPosition.y, + avatar.lastKnownAllowedPosition.z); + avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0); } else { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim! <3 OpenSim Developers"); } } @@ -651,7 +654,8 @@ namespace OpenSim.Region.Environment.LandManagement } else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) { - avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); + avatar.ControllingClient.SendAlertMessage( + "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!). <3 OpenSim Developers"); } else { @@ -668,7 +672,6 @@ namespace OpenSim.Region.Environment.LandManagement public void sendOutNearestBanLine(IClientAPI avatar) { - List avatars = m_scene.GetAvatars(); foreach (ScenePresence presence in avatars) { @@ -679,15 +682,14 @@ namespace OpenSim.Region.Environment.LandManagement { if (checkBan.isBannedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } else if (checkBan.isRestrictedFromLand(avatar.AgentId)) { - checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); + checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar); return; //Only send one } - } return; } @@ -696,8 +698,8 @@ namespace OpenSim.Region.Environment.LandManagement public void sendLandUpdate(ScenePresence avatar) { - Land over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), - (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); + Land over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), + (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); if (over != null) { @@ -705,10 +707,10 @@ namespace OpenSim.Region.Environment.LandManagement if (avatar.currentParcelUUID != over.landData.globalID) { avatar.currentParcelUUID = over.landData.globalID; - m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, this.m_scene.RegionInfo.RegionID); + m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, + m_scene.RegionInfo.RegionID); } } - } public void handleSignificantClientMovement(IClientAPI remote_client) @@ -722,16 +724,18 @@ namespace OpenSim.Region.Environment.LandManagement Land parcel = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); if (parcel != null) { - if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) + if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && + clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) { - - handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); //They are going below the safety line! + handleAvatarChangingParcel(clientAvatar, parcel.landData.localID, m_scene.RegionInfo.RegionID); + //They are going below the safety line! if (!parcel.isBannedFromLand(clientAvatar.UUID)) { clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; } } - else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && parcel.isBannedFromLand(clientAvatar.UUID)) + else if (clientAvatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HIEGHT && + parcel.isBannedFromLand(clientAvatar.UUID)) { sendYouAreBannedNotice(clientAvatar); } @@ -739,30 +743,33 @@ namespace OpenSim.Region.Environment.LandManagement } } - public void handleAnyClientMovement(ScenePresence avatar) //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. + public void handleAnyClientMovement(ScenePresence avatar) + //Like handleSignificantClientMovement, but called with an AgentUpdate regardless of distance. { Land over = getLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); if (over != null) { if (!over.isBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= BAN_LINE_SAFETY_HIEGHT) { - avatar.lastKnownAllowedPosition = new Axiom.Math.Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); - - + avatar.lastKnownAllowedPosition = + new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); } } } - public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client) + public void handleParcelAccessRequest(LLUUID agentID, LLUUID sessionID, uint flags, int sequenceID, + int landLocalID, IClientAPI remote_client) { if (landList.ContainsKey(landLocalID)) { - landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID,remote_client); + landList[landLocalID].sendAccessList(agentID, sessionID, flags, sequenceID, remote_client); } } - public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID,uint flags, int landLocalID, List entries, IClientAPI remote_client) + public void handleParcelAccessUpdateRequest(LLUUID agentID, LLUUID sessionID, uint flags, int landLocalID, + List entries, + IClientAPI remote_client) { if (landList.ContainsKey(landLocalID)) { @@ -849,4 +856,4 @@ namespace OpenSim.Region.Environment.LandManagement } #endregion -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index b1ab330..fcf0f72 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -220,7 +220,7 @@ namespace OpenSim.Region.Environment { if (pluginType.GetInterface("IRegionModule") != null) { - modules.Add((IRegionModule)Activator.CreateInstance(pluginType)); + modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); } } } diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs index 0b95aee..c31a79b 100644 --- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs @@ -27,11 +27,12 @@ */ using System; -using libsecondlife; using System.Collections.Generic; +using libsecondlife; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -59,9 +60,9 @@ namespace OpenSim.Region.Environment.Modules { m_avatarsAppearance[avatarId] = appearance; } - catch (System.NullReferenceException) + catch (NullReferenceException) { - OpenSim.Framework.Console.MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar"); + MainLog.Instance.Error("AVATAR", "Unable to load appearance for uninitialized avatar"); } return true; } @@ -98,17 +99,17 @@ namespace OpenSim.Region.Environment.Modules public void NewClient(IClientAPI client) { - client.OnAvatarNowWearing += AvatarIsWearing; + client.OnAvatarNowWearing += AvatarIsWearing; } public void RemoveClient(IClientAPI client) { - // client.OnAvatarNowWearing -= AvatarIsWearing; + // client.OnAvatarNowWearing -= AvatarIsWearing; } public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { - IClientAPI clientView = (IClientAPI)sender; + IClientAPI clientView = (IClientAPI) sender; CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId); if (profile != null) { @@ -127,7 +128,7 @@ namespace OpenSim.Region.Environment.Modules { assetId = baseItem.assetID; //temporary dictionary storage. This should be storing to a database - + if (m_avatarsAppearance.ContainsKey(clientView.AgentId)) { AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId]; @@ -158,4 +159,4 @@ namespace OpenSim.Region.Environment.Modules return visualParams; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 069eb3f..d6df978 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -176,10 +176,10 @@ namespace OpenSim.Region.Environment.Modules foreach (Scene s in m_scenes) { s.ForEachScenePresence(delegate(ScenePresence presence) - { - TrySendChatMessage(presence, fromPos, regionPos, - fromAgentID, fromName, e.Type, message); - }); + { + TrySendChatMessage(presence, fromPos, regionPos, + fromAgentID, fromName, e.Type, message); + }); } } } @@ -373,4 +373,4 @@ namespace OpenSim.Region.Environment.Modules m_tcp.Close(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs index d47004b..f8798dc 100644 --- a/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/ScriptsHttpRequests.cs @@ -27,18 +27,15 @@ */ using System; +using System.Collections.Generic; using System.IO; using System.Net; using System.Text; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; -using System.Collections; -using System.Collections.Generic; using System.Threading; using libsecondlife; using Nini.Config; -using Nwc.XmlRpc; -using OpenSim.Framework.Servers; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; /***************************************************** * @@ -85,120 +82,120 @@ using OpenSim.Framework.Servers; namespace OpenSim.Region.Environment.Modules { - public class ScriptHTTPRequests : IRegionModule, IHttpRequests - { - private Scene m_scene; - private Queue rpcQueue = new Queue(); - private object HttpListLock = new object(); - private string m_name = "HttpScriptRequests"; - private int httpTimeout = 300; - - // - private Dictionary m_pendingRequests; - - public ScriptHTTPRequests() - { - } - - public void Initialise(Scene scene, IConfigSource config) - { - m_scene = scene; - - m_scene.RegisterModuleInterface(this); - - m_pendingRequests = new Dictionary(); - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return m_name; } - } - - public bool IsSharedModule - { - get { return true; } - } - - public LLUUID MakeHttpRequest(string url, string parameters, string body) { - return LLUUID.Zero; - } - - public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) - { - LLUUID reqID = LLUUID.Random(); - HttpRequestClass htc = new HttpRequestClass(); - - // Parameters are expected in {key, value, ... , key, value} - if( parameters != null ) - { - string[] parms = parameters.ToArray(); - for (int i = 0; i < parms.Length / 2; i += 2) + public class ScriptHTTPRequests : IRegionModule, IHttpRequests + { + private Scene m_scene; + private Queue rpcQueue = new Queue(); + private object HttpListLock = new object(); + private string m_name = "HttpScriptRequests"; + private int httpTimeout = 300; + + // + private Dictionary m_pendingRequests; + + public ScriptHTTPRequests() + { + } + + public void Initialise(Scene scene, IConfigSource config) + { + m_scene = scene; + + m_scene.RegisterModuleInterface(this); + + m_pendingRequests = new Dictionary(); + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return m_name; } + } + + public bool IsSharedModule + { + get { return true; } + } + + public LLUUID MakeHttpRequest(string url, string parameters, string body) + { + return LLUUID.Zero; + } + + public LLUUID StartHttpRequest(uint localID, LLUUID itemID, string url, List parameters, string body) + { + LLUUID reqID = LLUUID.Random(); + HttpRequestClass htc = new HttpRequestClass(); + + // Parameters are expected in {key, value, ... , key, value} + if (parameters != null) + { + string[] parms = parameters.ToArray(); + for (int i = 0; i < parms.Length/2; i += 2) { - switch( Int32.Parse(parms[i]) ) + switch (Int32.Parse(parms[i])) { case HttpRequestClass.HTTP_METHOD: - htc.httpMethod = parms[i + 1]; - break; + htc.httpMethod = parms[i + 1]; + break; case HttpRequestClass.HTTP_MIMETYPE: - - htc.httpMIMEType = parms[i + 1]; - break; + + htc.httpMIMEType = parms[i + 1]; + break; case HttpRequestClass.HTTP_BODY_MAXLENGTH: - - // TODO implement me - break; + + // TODO implement me + break; case HttpRequestClass.HTTP_VERIFY_CERT: - - // TODO implement me - break; + + // TODO implement me + break; } } - } - - htc.localID = localID; - htc.itemID = itemID; - htc.url = url; - htc.reqID = reqID; - htc.httpTimeout = httpTimeout; - htc.outbound_body = body; - - lock (HttpListLock) - { - m_pendingRequests.Add(reqID, htc); - } - - htc.process(); - - return reqID; - } - - public void StopHttpRequest(uint m_localID, LLUUID m_itemID) - { - lock (HttpListLock) - { - - HttpRequestClass tmpReq; - if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq)) - { - tmpReq.Stop(); - m_pendingRequests.Remove(m_itemID); - } - } - } - - /* + } + + htc.localID = localID; + htc.itemID = itemID; + htc.url = url; + htc.reqID = reqID; + htc.httpTimeout = httpTimeout; + htc.outbound_body = body; + + lock (HttpListLock) + { + m_pendingRequests.Add(reqID, htc); + } + + htc.process(); + + return reqID; + } + + public void StopHttpRequest(uint m_localID, LLUUID m_itemID) + { + lock (HttpListLock) + { + HttpRequestClass tmpReq; + if (m_pendingRequests.TryGetValue(m_itemID, out tmpReq)) + { + tmpReq.Stop(); + m_pendingRequests.Remove(m_itemID); + } + } + } + + /* * TODO * Not sure how important ordering is is here - the next first * one completed in the list is returned, based soley on its list @@ -206,10 +203,11 @@ namespace OpenSim.Region.Environment.Modules * finsihed. I thought about setting up a queue for this, but * it will need some refactoring and this works 'enough' right now */ - public HttpRequestClass GetNextCompletedRequest() - { - lock (HttpListLock) - { + + public HttpRequestClass GetNextCompletedRequest() + { + lock (HttpListLock) + { foreach (LLUUID luid in m_pendingRequests.Keys) { HttpRequestClass tmpReq; @@ -225,18 +223,16 @@ namespace OpenSim.Region.Environment.Modules } } return null; - } - - - } + } + } - // - // HTTP REAQUEST - // This class was originally in LSLLongCmdHandler - // - // TODO: setter/getter methods, maybe pass some in - // constructor - // + // + // HTTP REAQUEST + // This class was originally in LSLLongCmdHandler + // + // TODO: setter/getter methods, maybe pass some in + // constructor + // public class HttpRequestClass { @@ -280,9 +276,9 @@ namespace OpenSim.Region.Environment.Modules * TODO: More work on the response codes. Right now * returning 200 for success or 499 for exception */ + public void SendRequest() { - HttpWebResponse response = null; StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; @@ -292,14 +288,14 @@ namespace OpenSim.Region.Environment.Modules try { request = (HttpWebRequest) - WebRequest.Create(url); + WebRequest.Create(url); request.Method = httpMethod; request.ContentType = httpMIMEType; request.Timeout = httpTimeout; // execute the request response = (HttpWebResponse) - request.GetResponse(); + request.GetResponse(); Stream resStream = response.GetResponseStream(); @@ -317,11 +313,9 @@ namespace OpenSim.Region.Environment.Modules // continue building the string sb.Append(tempString); } - } - while (count > 0); // any more data to read? + } while (count > 0); // any more data to read? response_body = sb.ToString(); - } catch (Exception e) { @@ -333,7 +327,6 @@ namespace OpenSim.Region.Environment.Modules status = 200; finished = true; - } public void Stop() @@ -342,8 +335,9 @@ namespace OpenSim.Region.Environment.Modules { httpThread.Abort(); } - catch (Exception) { } + catch (Exception) + { + } } } - - } \ No newline at end of file +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/SunModule.cs b/OpenSim/Region/Environment/Modules/SunModule.cs index 233c83c..bd6cd63 100644 --- a/OpenSim/Region/Environment/Modules/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/SunModule.cs @@ -28,13 +28,12 @@ using System; using System.Collections.Generic; +using libsecondlife; using Nini.Config; -using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Scenes; using OpenSim.Framework; using OpenSim.Framework.Console; -using libsecondlife; - +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules { @@ -55,17 +54,20 @@ namespace OpenSim.Region.Environment.Modules { m_start = DateTime.Now.Ticks; m_frame = 0; - + // Just in case they don't have the stanzas - try { + try + { m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); - } catch (Exception) { + } + catch (Exception) + { m_day_length = m_real_day; m_frame_mod = m_default_frame; } - - m_dilation = (int)(m_real_day / m_day_length); + + m_dilation = (int) (m_real_day/m_day_length); m_scene = scene; m_log = MainLog.Instance; scene.EventManager.OnFrame += SunUpdate; @@ -94,10 +96,11 @@ namespace OpenSim.Region.Environment.Modules { client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); } - + public void SunUpdate() { - if (m_frame < m_frame_mod) { + if (m_frame < m_frame_mod) + { m_frame++; return; } @@ -115,20 +118,20 @@ namespace OpenSim.Region.Environment.Modules // time when the simulator starts, then run time forward // faster based on time dilation factor. This means that // ticks don't get out of hand - private double HourOfTheDay() + private double HourOfTheDay() { - long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; + long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; DateTime dt = new DateTime(m_start + m_addticks); - return (double)dt.Hour + ((double)dt.Minute / 60.0); + return (double) dt.Hour + ((double) dt.Minute/60.0); } - private LLVector3 SunPos(double hour) + private LLVector3 SunPos(double hour) { // now we have our radian position - double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); + double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); double z = Math.Sin(rad); double x = Math.Cos(rad); - return new LLVector3((float)x, 0f, (float)z); + return new LLVector3((float) x, 0f, (float) z); } // TODO: clear this out. This is here so that I remember to diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 0adace1..813be8d 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -32,6 +32,7 @@ using libsecondlife; using libsecondlife.Packets; using Nini.Config; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; @@ -48,7 +49,8 @@ namespace OpenSim.Region.Environment.Modules private BlockingQueue QueueSenders = new BlockingQueue(); - private Dictionary m_userTextureServices = new Dictionary(); + private Dictionary m_userTextureServices = + new Dictionary(); private Thread m_thread; @@ -72,7 +74,6 @@ namespace OpenSim.Region.Environment.Modules m_scene = scene; m_scene.EventManager.OnNewClient += NewClient; } - } public void PostInitialise() @@ -115,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules public void TextureRequest(Object sender, TextureRequestArgs e) { - IClientAPI client = (IClientAPI)sender; + IClientAPI client = (IClientAPI) sender; UserTextureDownloadService textureService; if (TryGetUserTextureService(client.AgentId, out textureService)) { @@ -175,7 +176,8 @@ namespace OpenSim.Region.Environment.Modules { if (!m_textureSenders.ContainsKey(e.RequestedAssetID)) { - TextureSender requestHandler = new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); + TextureSender requestHandler = + new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); m_textureSenders.Add(e.RequestedAssetID, requestHandler); m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); } @@ -183,7 +185,8 @@ namespace OpenSim.Region.Environment.Modules { m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber); m_textureSenders[e.RequestedAssetID].counter = 0; - if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && (m_textureSenders[e.RequestedAssetID].Sending ==false)) + if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && + (m_textureSenders[e.RequestedAssetID].Sending == false)) { m_textureSenders[e.RequestedAssetID].Sending = true; m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]); @@ -256,7 +259,7 @@ namespace OpenSim.Region.Environment.Modules { m_asset = asset; NumPackets = CalculateNumPackets(asset.Data.Length); - PacketCounter = (int)StartPacketNumber; + PacketCounter = (int) StartPacketNumber; ImageLoaded = true; } @@ -264,14 +267,15 @@ namespace OpenSim.Region.Environment.Modules { RequestedDiscardLevel = discardLevel; StartPacketNumber = packetNumber; - PacketCounter = (int)StartPacketNumber; + PacketCounter = (int) StartPacketNumber; } public bool SendTexturePacket() { SendPacket(); counter++; - if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))) ) + if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || + ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) { return true; } @@ -290,7 +294,7 @@ namespace OpenSim.Region.Environment.Modules im.Header.Reliable = false; im.ImageID.Packets = 1; im.ImageID.ID = m_asset.FullID; - im.ImageID.Size = (uint)m_asset.Data.Length; + im.ImageID.Size = (uint) m_asset.Data.Length; im.ImageData.Data = m_asset.Data; im.ImageID.Codec = 2; RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); @@ -300,9 +304,9 @@ namespace OpenSim.Region.Environment.Modules { ImageDataPacket im = new ImageDataPacket(); im.Header.Reliable = false; - im.ImageID.Packets = (ushort)(NumPackets); + im.ImageID.Packets = (ushort) (NumPackets); im.ImageID.ID = m_asset.FullID; - im.ImageID.Size = (uint)m_asset.Data.Length; + im.ImageID.Size = (uint) m_asset.Data.Length; im.ImageData.Data = new byte[600]; Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); im.ImageID.Codec = 2; @@ -314,18 +318,20 @@ namespace OpenSim.Region.Environment.Modules { ImagePacketPacket im = new ImagePacketPacket(); im.Header.Reliable = false; - im.ImageID.Packet = (ushort)(PacketCounter); + im.ImageID.Packet = (ushort) (PacketCounter); im.ImageID.ID = m_asset.FullID; - int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); + int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); if (size > 1000) size = 1000; im.ImageData.Data = new byte[size]; try { - Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); + Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); } - catch (System.ArgumentOutOfRangeException) + catch (ArgumentOutOfRangeException) { - OpenSim.Framework.Console.MainLog.Instance.Warn("TEXTURE", "Unable to separate texture into multiple packets: Array bounds failure on asset:" + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); + MainLog.Instance.Warn("TEXTURE", + "Unable to separate texture into multiple packets: Array bounds failure on asset:" + + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); return; } RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); @@ -342,14 +348,12 @@ namespace OpenSim.Region.Environment.Modules { //over 600 bytes so split up file int restData = (length - 600); - int restPackets = ((restData + 999) / 1000); + int restPackets = ((restData + 999)/1000); numPackets = restPackets; } return numPackets; } } - - } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index 0dad998..6b9ae46 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs @@ -135,7 +135,7 @@ namespace OpenSim.Region.Environment.Modules { m_listenerManager.Remove(handle); } - + // This method scans nearby objects and determines if they are listeners, // and if so if this message fits the filter. If it does, then // enqueue the message for delivery to the objects listen event handler. @@ -490,4 +490,4 @@ namespace OpenSim.Region.Environment.Modules return m_id; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs index f13b2bb..481ba3f 100644 --- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs @@ -33,10 +33,10 @@ using System.Threading; using libsecondlife; using Nini.Config; using Nwc.XmlRpc; +using OpenSim.Framework.Console; using OpenSim.Framework.Servers; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; -using OpenSim.Framework.Console; /***************************************************** * @@ -116,15 +116,16 @@ namespace OpenSim.Region.Environment.Modules public void PostInitialise() { - if ( IsEnabled() ) + if (IsEnabled()) { m_openChannels = new Dictionary(); m_pendingResponse = new Dictionary(); // Start http server // Attach xmlrpc handlers - m_log.Verbose("REMOTE_DATA", "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); - BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); + m_log.Verbose("REMOTE_DATA", + "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); + BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort); httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); httpServer.Start(); } diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 53fa08a..76601ec 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -35,13 +35,13 @@ namespace OpenSim.Region.Environment public class PermissionManager { protected Scene m_scene; - + // These are here for testing. They will be taken out - private uint PERM_ALL = (uint)2147483647; - private uint PERM_COPY = (uint)32768; - private uint PERM_MODIFY = (uint)16384; - private uint PERM_MOVE = (uint)524288; - private uint PERM_TRANS = (uint)8192; + private uint PERM_ALL = (uint) 2147483647; + private uint PERM_COPY = (uint) 32768; + private uint PERM_MODIFY = (uint) 16384; + private uint PERM_MOVE = (uint) 524288; + private uint PERM_TRANS = (uint) 8192; // Bypasses the permissions engine (always returns OK) // disable in any production environment // TODO: Change this to false when permissions are a desired default @@ -109,10 +109,11 @@ namespace OpenSim.Region.Environment string reason = "Insufficient permission"; - Land land = this.m_scene.LandManager.getLandObject(position.X, position.Y); + Land land = m_scene.LandManager.getLandObject(position.X, position.Y); if (land == null) return false; - if ((land.landData.landFlags & ((int)Parcel.ParcelFlags.CreateObjects)) == (int)Parcel.ParcelFlags.CreateObjects) + if ((land.landData.landFlags & ((int) Parcel.ParcelFlags.CreateObjects)) == + (int) Parcel.ParcelFlags.CreateObjects) permission = true; //TODO: check for group rights @@ -143,8 +144,6 @@ namespace OpenSim.Region.Environment #region Object Permissions - - public virtual uint GenerateClientFlags(LLUUID user, LLUUID objID) { if (!m_scene.Entities.ContainsKey(objID)) @@ -158,7 +157,7 @@ namespace OpenSim.Region.Environment return 0; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objID]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[objID]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -274,7 +273,7 @@ namespace OpenSim.Region.Environment public virtual bool CanEditObjectPosition(LLUUID user, LLUUID obj) { - bool permission = GenericObjectPermission(user,obj); + bool permission = GenericObjectPermission(user, obj); if (!permission) { if (!m_scene.Entities.ContainsKey(obj)) @@ -288,7 +287,7 @@ namespace OpenSim.Region.Environment return false; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -298,6 +297,7 @@ namespace OpenSim.Region.Environment } return permission; } + public virtual bool CanCopyObject(LLUUID user, LLUUID obj) { bool permission = GenericObjectPermission(user, obj); @@ -314,7 +314,7 @@ namespace OpenSim.Region.Environment return false; } - SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + SceneObjectGroup task = (SceneObjectGroup) m_scene.Entities[obj]; LLUUID taskOwner = null; // Added this because at this point in time it wouldn't be wise for // the administrator object permissions to take effect. @@ -324,6 +324,7 @@ namespace OpenSim.Region.Environment } return permission; } + public virtual bool CanReturnObject(LLUUID user, LLUUID obj) { return GenericObjectPermission(user, obj); @@ -491,4 +492,4 @@ namespace OpenSim.Region.Environment #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs index cffe846..5466865 100644 --- a/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs +++ b/OpenSim/Region/Environment/Scenes/AvatarAnimations.cs @@ -25,11 +25,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; using System.Collections.Generic; using System.Xml; using libsecondlife; -using libsecondlife.Packets; - +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -37,11 +37,11 @@ namespace OpenSim.Region.Environment.Scenes { public Dictionary AnimsLLUUID = new Dictionary(); public Dictionary AnimsNames = new Dictionary(); - + public AvatarAnimations() { } - + public void LoadAnims() { //MainLog.Instance.Verbose("CLIENT", "Loading avatar animations"); @@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Scenes } } } - + // MainLog.Instance.Verbose("CLIENT", "Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)"); try @@ -68,11 +68,10 @@ namespace OpenSim.Region.Environment.Scenes AnimsNames.Add(kp.Value, kp.Key); } } - catch (System.InvalidOperationException) + catch (InvalidOperationException) { - OpenSim.Framework.Console.MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar"); + MainLog.Instance.Warn("AVATAR", "Unable to load animation names for an Avatar"); } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs index 2ec4dbe..1583124 100644 --- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs +++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -26,15 +26,9 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.Console; -using OpenSim.Framework.Communications; -using OpenSim.Region.Environment.Types; namespace OpenSim.Region.Environment.Scenes { @@ -106,8 +100,8 @@ namespace OpenSim.Region.Environment.Scenes // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. // (float)m_visualParams[25] = Height // (float)m_visualParams[125] = LegLength - m_avatarHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))) - + (((float)m_visualParams[125] / 255.0f) / 1.5f); + m_avatarHeight = (1.50856f + (((float) m_visualParams[25]/255.0f)*(2.525506f - 1.50856f))) + + (((float) m_visualParams[125]/255.0f)/1.5f); } /// @@ -144,4 +138,4 @@ namespace OpenSim.Region.Environment.Scenes return textu; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index 4556c63..18799e4 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -145,7 +145,6 @@ namespace OpenSim.Region.Environment.Scenes return (EntityBase) MemberwiseClone(); } - public abstract void SetText(string text, Vector3 color, double alpha); } @@ -161,15 +160,13 @@ namespace OpenSim.Region.Environment.Scenes public EntityIntersection() { - - } + public EntityIntersection(Vector3 _ipoint, float _normal, bool _HitTF) { ipoint = _ipoint; normal = _normal; HitTF = _HitTF; } - } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs index b9d1232..3e87981 100644 --- a/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs +++ b/OpenSim/Region/Environment/Scenes/IScenePresenceBody.cs @@ -27,7 +27,6 @@ */ using libsecondlife; -using libsecondlife.Packets; using OpenSim.Framework; namespace OpenSim.Region.Environment.Scenes diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 0ca3405..4233853 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -28,7 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; @@ -44,10 +43,13 @@ namespace OpenSim.Region.Environment.Scenes public class InnerScene { #region Events + public event PhysicsCrash UnRecoverableError; + #endregion #region Fields + public Dictionary ScenePresences; public Dictionary SceneObjects; public Dictionary Entities; @@ -65,6 +67,7 @@ namespace OpenSim.Region.Environment.Scenes internal object m_syncRoot = new object(); public PhysicsScene _PhyScene; + #endregion public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) @@ -79,28 +82,27 @@ namespace OpenSim.Region.Environment.Scenes public PhysicsScene PhysicsScene { - get - { return _PhyScene; } + get { return _PhyScene; } set { // If we're not doing the initial set // Then we've got to remove the previous // event handler - try - { - _PhyScene.OnPhysicsCrash -= physicsBasedCrash; - } - catch (System.NullReferenceException) - { - // This occurs when storing to _PhyScene the first time. - // Is there a better way to check the event handler before - // getting here - // This can be safely ignored. We're setting the first inital - // there are no event handler's registered. - } - + try + { + _PhyScene.OnPhysicsCrash -= physicsBasedCrash; + } + catch (NullReferenceException) + { + // This occurs when storing to _PhyScene the first time. + // Is there a better way to check the event handler before + // getting here + // This can be safely ignored. We're setting the first inital + // there are no event handler's registered. + } + _PhyScene = value; - + _PhyScene.OnPhysicsCrash += physicsBasedCrash; } } @@ -113,6 +115,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Update Methods + internal void UpdatePreparePhysics() { // If we are using a threaded physics engine @@ -141,7 +144,7 @@ namespace OpenSim.Region.Environment.Scenes { lock (m_syncRoot) { - return _PhyScene.Simulate((float)elapsed); + return _PhyScene.Simulate((float) elapsed); } } @@ -151,12 +154,14 @@ namespace OpenSim.Region.Environment.Scenes foreach (EntityBase entity in moveEntities) { - entity.UpdateMovement(); + entity.UpdateMovement(); } } + #endregion #region Entity Methods + public void AddEntityFromStorage(SceneObjectGroup sceneObject) { sceneObject.RegionHandle = m_regInfo.RegionHandle; @@ -181,14 +186,17 @@ namespace OpenSim.Region.Environment.Scenes m_numPrim++; } } + public void AddPhysicalPrim(int number) { m_physicalPrim++; } + public void RemovePhysicalPrim(int number) { m_physicalPrim--; } + public void RemovePrim(uint localID, LLUUID avatar_deleter) { List EntityList = GetEntities(); @@ -197,9 +205,9 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - if (((SceneObjectGroup)obj).LocalId == localID) + if (((SceneObjectGroup) obj).LocalId == localID) { - m_parentScene.RemoveEntity((SceneObjectGroup)obj); + m_parentScene.RemoveEntity((SceneObjectGroup) obj); m_numPrim--; return; } @@ -253,7 +261,8 @@ namespace OpenSim.Region.Environment.Scenes return newAvatar; } - public void SwapRootChildAgent(bool direction_RC_CR_T_F) + + public void SwapRootChildAgent(bool direction_RC_CR_T_F) { if (direction_RC_CR_T_F) { @@ -266,25 +275,29 @@ namespace OpenSim.Region.Environment.Scenes m_numRootAgents++; } } + public void removeUserCount(bool TypeRCTF) { if (TypeRCTF) { m_numRootAgents--; } - else + else { m_numChildAgents--; } } + public void RemoveAPrimCount() { m_numPrim--; } + public void AddAPrimCount() { m_numPrim++; } + public int GetChildAgentCount() { return m_numChildAgents; @@ -375,8 +388,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(localID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(localID)) + return (SceneObjectGroup) ent; } } return null; @@ -390,8 +403,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(fullID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(fullID)) + return (SceneObjectGroup) ent; } } return null; @@ -406,7 +419,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectGroup reportingG = (SceneObjectGroup)ent; + SceneObjectGroup reportingG = (SceneObjectGroup) ent; EntityIntersection result = reportingG.TestIntersection(hray); if (result.HitTF) { @@ -417,7 +430,6 @@ namespace OpenSim.Region.Environment.Scenes } } } - } return returnResult; } @@ -531,17 +543,16 @@ namespace OpenSim.Region.Environment.Scenes //float distResult = Vector3Distance(avPosition, objPosition); //if (distResult > 512) //{ - //int x = 0; + //int x = 0; //} //if (distResult < presence.DrawDistance) //{ - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); //} - } - else + else { - ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); + ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence); } } } @@ -554,9 +565,11 @@ namespace OpenSim.Region.Environment.Scenes action(presence.ControllingClient); } } + #endregion #region Client Event handlers + /// /// /// @@ -583,13 +596,12 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, LLUUID ObjectID) + public void RequestObjectPropertiesFamily(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags, + LLUUID ObjectID) { SceneObjectGroup group = GetGroupByPrim(ObjectID); if (group != null) group.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags); - - } /// @@ -708,10 +720,9 @@ namespace OpenSim.Region.Environment.Scenes { if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) { - group.UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); + group.UpdatePrimFlags(localID, (ushort) packet.Type, true, packet.ToBytes()); } } - } public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) @@ -763,7 +774,7 @@ namespace OpenSim.Region.Environment.Scenes public void UpdateExtraParam(LLUUID agentID, uint primLocalID, ushort type, bool inUse, byte[] data) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - + if (group != null) { if (PermissionsMngr.CanEditObject(agentID, group.UUID)) @@ -771,7 +782,6 @@ namespace OpenSim.Region.Environment.Scenes group.UpdateExtraParam(primLocalID, type, inUse, data); } } - } /// @@ -786,7 +796,6 @@ namespace OpenSim.Region.Environment.Scenes { if (PermissionsMngr.CanEditObjectPosition(agentID, group.GetPartsFullID(primLocalID))) { - group.UpdateShape(shapeBlock, primLocalID); } } @@ -806,9 +815,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == parentPrim) + if (((SceneObjectGroup) ent).LocalId == parentPrim) { - parenPrim = (SceneObjectGroup)ent; + parenPrim = (SceneObjectGroup) ent; break; } } @@ -823,9 +832,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == childPrims[i]) + if (((SceneObjectGroup) ent).LocalId == childPrims[i]) { - children.Add((SceneObjectGroup)ent); + children.Add((SceneObjectGroup) ent); } } } @@ -857,7 +866,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectGroup obj = (SceneObjectGroup)ent; + SceneObjectGroup obj = (SceneObjectGroup) ent; sceneObjects.Add(obj.LocalId, obj); } } @@ -882,9 +891,9 @@ namespace OpenSim.Region.Environment.Scenes } else { - MainLog.Instance.Verbose("SCENE", - "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", - primIds); + MainLog.Instance.Verbose("SCENE", + "DelinkObjects(): Could not find a root prim out of {0} as given to a delink request!", + primIds); } } @@ -903,9 +912,9 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).LocalId == originalPrim) + if (((SceneObjectGroup) ent).LocalId == originalPrim) { - originPrim = (SceneObjectGroup)ent; + originPrim = (SceneObjectGroup) ent; break; } } @@ -929,7 +938,6 @@ namespace OpenSim.Region.Environment.Scenes { MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); } - } /// @@ -943,8 +951,11 @@ namespace OpenSim.Region.Environment.Scenes // We don't really need the double floating point precision... // so casting it to a single - return (float)Math.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z)); + return + (float) + Math.Sqrt((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y) + (v1.z - v2.z)*(v1.z - v2.z)); } + #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 0689177..4c6e1c8 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -26,14 +26,12 @@ * */ -using Axiom.Math; +using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Region.Physics.Manager; -using System.Collections.Generic; namespace OpenSim.Region.Environment.Scenes { @@ -41,7 +39,7 @@ namespace OpenSim.Region.Environment.Scenes { //split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete // or at least some of they can be moved somewhere else - + /// /// Add an inventory item to an avatar's inventory. /// @@ -57,7 +55,7 @@ namespace OpenSim.Region.Environment.Scenes remoteClient.SendInventoryItemCreateUpdate(item); } } - + /// /// AddInventoryItem(LLUUID, InventoryItemBase) /// @@ -71,10 +69,10 @@ namespace OpenSim.Region.Environment.Scenes if (!TryGetAvatar(avatarId, out avatar)) { MainLog.Instance.Error( - "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId); + "AGENTINVENTORY", "Could not find avatar {0} to add inventory item", avatarId); return; } - + AddInventoryItem(avatar.ControllingClient, item); } @@ -95,7 +93,9 @@ namespace OpenSim.Region.Environment.Scenes InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); if (item != null) { - AssetBase asset = CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, (sbyte) item.assetType, data); + AssetBase asset = + CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, + (sbyte) item.assetType, data); AssetCache.AddAsset(asset); item.assetID = asset.FullID; @@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes } return LLUUID.Zero; } - + /// /// CapsUpdatedInventoryItemAsset(IClientAPI, LLUUID, byte[]) /// @@ -132,14 +132,14 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Error( - "AGENTINVENTORY", - "Avatar {0} cannot be found to update its inventory item asset", - avatarId); + "AGENTINVENTORY", + "Avatar {0} cannot be found to update its inventory item asset", + avatarId); } return LLUUID.Zero; - } - + } + /// /// Capability originating call to update the asset of a script in a prim's (task's) inventory /// @@ -149,17 +149,17 @@ namespace OpenSim.Region.Environment.Scenes /// Indicates whether the script to update is currently running /// /// Asset LLUID created - public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, - LLUUID primId, bool isScriptRunning, byte[] data) + public void CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, LLUUID itemId, + LLUUID primId, bool isScriptRunning, byte[] data) { // TODO Not currently doing anything with the isScriptRunning bool - + MainLog.Instance.Verbose( "PRIMINVENTORY", "Prim inventory script save functionality not yet implemented." - + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", + + " remoteClient: {0}, itemID: {1}, primID: {2}, isScriptRunning: {3}", remoteClient, itemId, primId, isScriptRunning); - + // TODO // Retrieve client LLUID // Retrieve sog containing primID @@ -170,13 +170,13 @@ namespace OpenSim.Region.Environment.Scenes // Trigger rerunning of script (use TriggerRezScript event, see RezScript) // return new asset id } - + /// /// CapsUpdateTaskInventoryScriptAsset(IClientAPI, LLUUID, LLUUID, bool, byte[]) /// - private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId, + private void CapsUpdateTaskInventoryScriptAsset(LLUUID avatarId, LLUUID itemId, LLUUID primId, bool isScriptRunning, byte[] data) - { + { ScenePresence avatar; if (TryGetAvatar(avatarId, out avatar)) @@ -187,10 +187,10 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Error( - "PRIMINVENTORY", - "Avatar {0} cannot be found to update its prim item asset", - avatarId); - } + "PRIMINVENTORY", + "Avatar {0} cannot be found to update its prim item asset", + avatarId); + } } /// @@ -204,74 +204,75 @@ namespace OpenSim.Region.Environment.Scenes /// The name of the updated item /// The description of the updated item /// The permissions of the updated item - public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, + public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID itemID, string name, string description, uint nextOwnerMask) - { - CachedUserInfo userInfo + { + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); - + if (userInfo != null && userInfo.RootFolder != null) { InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); if (item != null) - { + { if (LLUUID.Zero == transactionID) { item.inventoryName = name; item.inventoryDescription = description; item.inventoryNextPermissions = nextOwnerMask; - + userInfo.UpdateItem(remoteClient.AgentId, item); } - else - { - AgentAssetTransactions transactions + else + { + AgentAssetTransactions transactions = CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); - + if (transactions != null) { - LLUUID assetID = libsecondlife.LLUUID.Combine(transactionID, remoteClient.SecureSessionId); - AssetBase asset + LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); + AssetBase asset = AssetCache.GetAsset( - assetID, (item.assetType == (int)AssetType.Texture ? true : false)); - + assetID, (item.assetType == (int) AssetType.Texture ? true : false)); + if (asset == null) { asset = transactions.GetTransactionAsset(transactionID); } - + if (asset != null && asset.FullID == assetID) { asset.Name = item.inventoryName; asset.Description = item.inventoryDescription; asset.InvType = (sbyte) item.invType; - asset.Type = (sbyte) item.assetType; + asset.Type = (sbyte) item.assetType; item.assetID = asset.FullID; - + AssetCache.AddAsset(asset); } - + userInfo.UpdateItem(remoteClient.AgentId, item); } } } else - { + { MainLog.Instance.Warn( - "AGENTINVENTORY", - "Item ID " + itemID + " not found for an inventory item update."); + "AGENTINVENTORY", + "Item ID " + itemID + " not found for an inventory item update."); } } else { MainLog.Instance.Warn( "AGENTINVENTORY", - "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); + "Agent ID " + remoteClient.AgentId + " not found for an inventory item update."); } } - public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) + public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, + LLUUID newFolderID, string newName) { InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); if (item == null) @@ -308,7 +309,7 @@ namespace OpenSim.Region.Environment.Scenes } asset.Name = (newName.Length == 0) ? item.inventoryName : newName; - + // TODO: preserve current permissions? CreateNewInventoryItem(remoteClient, newFolderID, callbackID, asset, item.inventoryNextPermissions); } @@ -325,12 +326,13 @@ namespace OpenSim.Region.Environment.Scenes return asset; } - public void MoveInventoryItem(IClientAPI remoteClient,LLUUID folderID, LLUUID itemID, int length, string newName) + public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length, + string newName) { MainLog.Instance.Verbose( - "AGENTINVENTORY", + "AGENTINVENTORY", "Moving item for " + remoteClient.AgentId.ToString()); - + CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo == null) { @@ -364,8 +366,6 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn("AGENTINVENTORY", "Failed to find item " + itemID.ToString() + ", no root folder"); return; } - - } private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, @@ -406,7 +406,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, - uint callbackID, string description, string name, sbyte invType, sbyte assetType, + uint callbackID, string description, string name, sbyte invType, + sbyte assetType, byte wearableType, uint nextOwnerMask) { if (transActionID == LLUUID.Zero) @@ -437,8 +438,8 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - if (((SceneObjectGroup)ent).HasChildPrim(localID)) - return (SceneObjectGroup)ent; + if (((SceneObjectGroup) ent).HasChildPrim(localID)) + return (SceneObjectGroup) ent; } } return null; @@ -491,13 +492,13 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Warn( - "PRIMINVENTORY", - "Removal of item {0} requested of prim {1} but this prim does not exist", + "PRIMINVENTORY", + "Removal of item {0} requested of prim {1} but this prim does not exist", itemID, localID); - } + } } - + /// /// Update an item in a prim (task) inventory. /// This method does not handle scripts, RezScript(IClientAPI, LLUUID, unit) @@ -506,7 +507,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, + public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint primLocalID) { SceneObjectGroup group = GetGroupByPrim(primLocalID); @@ -515,17 +516,17 @@ namespace OpenSim.Region.Environment.Scenes // TODO Retrieve itemID from client's inventory to pass on //group.AddInventoryItem(rmoteClient, primLocalID, null); MainLog.Instance.Verbose( - "PRIMINVENTORY", + "PRIMINVENTORY", "UpdateTaskInventory called with script {0}, folder {1}, primLocalID {2}, user {3}", itemID, folderID, primLocalID, remoteClient.Name); - } + } else { MainLog.Instance.Warn( - "PRIMINVENTORY", - "Update with script {0} requested of prim {1} for {2} but this prim does not exist", + "PRIMINVENTORY", + "Update with script {0} requested of prim {1} for {2} but this prim does not exist", itemID, primLocalID, remoteClient.Name); - } + } } /// @@ -551,7 +552,7 @@ namespace OpenSim.Region.Environment.Scenes { isTexture = true; } - + AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture); if (rezAsset != null) @@ -569,18 +570,18 @@ namespace OpenSim.Region.Environment.Scenes // TODO: do we care about the value of this bool? group.AddInventoryItem(remoteClient, localID, item, copyID); group.GetProperites(remoteClient); - + MainLog.Instance.Verbose( - "PRIMINVENTORY", - "Rezzed script {0} (asset {1}) into prim {2} for user {3}", - item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); + "PRIMINVENTORY", + "Rezzed script {0} (asset {1}) into prim {2} for user {3}", + item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); } else { MainLog.Instance.Warn( "PRIMINVENTORY", "Could not rez script {0} into prim {1} for user {2}" - + " because the prim could not be found in the region!", + + " because the prim could not be found in the region!", item.inventoryName, localID, remoteClient.Name); } } @@ -589,7 +590,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn( "PRIMINVENTORY", "Could not rez script {0} into prim {1} for user {2}" - + " because the item asset {3} could not be found!", + + " because the item asset {3} could not be found!", item.inventoryName, localID, item.assetID, remoteClient.Name); } } @@ -638,7 +639,8 @@ namespace OpenSim.Region.Environment.Scenes if (PermissionsMngr.CanDeRezObject(remoteClient.AgentId, ((SceneObjectGroup) selectedEnt).UUID)) { string sceneObjectXml = ((SceneObjectGroup) selectedEnt).ToXmlString(); - CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); if (userInfo != null) { AssetBase asset = CreateAsset( @@ -661,9 +663,10 @@ namespace OpenSim.Region.Environment.Scenes item.parentFolderID = DeRezPacket.AgentBlock.DestinationID; item.inventoryCurrentPermissions = 2147483647; item.inventoryNextPermissions = 2147483647; - item.inventoryEveryOnePermissions = ((SceneObjectGroup)selectedEnt).RootPart.EveryoneMask; - item.inventoryBasePermissions = ((SceneObjectGroup)selectedEnt).RootPart.BaseMask; - item.inventoryCurrentPermissions = ((SceneObjectGroup)selectedEnt).RootPart.OwnerMask; + item.inventoryEveryOnePermissions = + ((SceneObjectGroup) selectedEnt).RootPart.EveryoneMask; + item.inventoryBasePermissions = ((SceneObjectGroup) selectedEnt).RootPart.BaseMask; + item.inventoryCurrentPermissions = ((SceneObjectGroup) selectedEnt).RootPart.OwnerMask; userInfo.AddItem(remoteClient.AgentId, item); remoteClient.SendInventoryItemCreateUpdate(item); @@ -730,20 +733,20 @@ namespace OpenSim.Region.Environment.Scenes //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) //{ - //PrimitiveBaseShape pbs = rootPart.Shape; - //rootPart.PhysActor = PhysicsScene.AddPrimShape( - //rootPart.Name, - //pbs, - //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, - // rootPart.AbsolutePosition.Z), - //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - - // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - - // } + //PrimitiveBaseShape pbs = rootPart.Shape; + //rootPart.PhysActor = PhysicsScene.AddPrimShape( + //rootPart.Name, + //pbs, + //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, + // rootPart.AbsolutePosition.Z), + //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), + //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, + // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); + + // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); + + // } rootPart.ScheduleFullUpdate(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 6a7c266..999b70f 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -29,8 +29,6 @@ using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; -using OpenSim.Framework.UserManagement; -using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -45,7 +43,8 @@ namespace OpenSim.Region.Environment.Scenes /// 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, float south, float east, + public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + float south, float east, IClientAPI remoteUser) { // Do a permissions check before allowing terraforming. @@ -157,7 +156,7 @@ namespace OpenSim.Region.Environment.Scenes } } } - + public void ProcessAvatarPickerRequest(IClientAPI client, LLUUID avatarID, LLUUID RequestID, string query) { //EventManager.TriggerAvatarPickerRequest(); @@ -166,13 +165,14 @@ namespace OpenSim.Region.Environment.Scenes AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); - AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; + AvatarPickerReplyPacket.DataBlock[] searchData = + new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); agentData.AgentID = avatarID; agentData.QueryID = RequestID; replyPacket.AgentData = agentData; - byte[] bytes = new byte[AvatarResponses.Count * 32]; + byte[] bytes = new byte[AvatarResponses.Count*32]; int i = 0; foreach (AvatarPickerAvatar item in AvatarResponses) @@ -180,10 +180,9 @@ namespace OpenSim.Region.Environment.Scenes LLUUID translatedIDtem = item.AvatarID; searchData[i] = new AvatarPickerReplyPacket.DataBlock(); searchData[i].AvatarID = translatedIDtem; - searchData[i].FirstName = Helpers.StringToField((string)item.firstName); - searchData[i].LastName = Helpers.StringToField((string)item.lastName); + searchData[i].FirstName = Helpers.StringToField((string) item.firstName); + searchData[i].LastName = Helpers.StringToField((string) item.lastName); i++; - } if (AvatarResponses.Count == 0) { @@ -193,4 +192,4 @@ namespace OpenSim.Region.Environment.Scenes client.SendAvatarPickerReply(replyPacket); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 0144c4c..c0fda61 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -27,27 +27,28 @@ */ using System; using System.Collections.Generic; -using System.IO; -using System.Net; +using System.Drawing; +using System.Drawing.Imaging; using System.Threading; using System.Timers; -using System.Xml; using Axiom.Math; using libsecondlife; +using libsecondlife.Packets; +using OpenJPEGNet; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Console; -using OpenSim.Region.Environment.LandManagement; using OpenSim.Framework.Servers; -using OpenSim.Region.Capabilities; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Modules; using OpenSim.Region.Environment.Scenes.Scripting; -using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Terrain; -using Timer = System.Timers.Timer; +using Caps=OpenSim.Region.Capabilities.Caps; +using Image=System.Drawing.Image; +using Timer=System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { @@ -56,6 +57,7 @@ namespace OpenSim.Region.Environment.Scenes public partial class Scene : SceneBase { #region Fields + protected Timer m_heartbeatTimer = new Timer(); protected Timer m_restartWaitTimer = new Timer(); @@ -88,7 +90,7 @@ namespace OpenSim.Region.Environment.Scenes protected SceneCommunicationService m_sceneGridService; protected SceneXmlLoader m_sceneXmlLoader; - protected Dictionary m_capsHandlers = new Dictionary(); + protected Dictionary m_capsHandlers = new Dictionary(); protected BaseHttpServer httpListener; protected Dictionary Modules = new Dictionary(); @@ -122,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes private int m_update_terrain = 50; private int m_update_land = 1; private int m_update_avatars = 1; + #endregion #region Properties @@ -145,6 +148,7 @@ namespace OpenSim.Region.Environment.Scenes set { m_innerScene.PhysicsScene = value; } get { return (m_innerScene.PhysicsScene); } } + // This gets locked so things stay thread safe. public object SyncRoot { @@ -204,7 +208,8 @@ namespace OpenSim.Region.Environment.Scenes #region Constructors - public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, + public Scene(RegionInfo regInfo, AgentCircuitManager authen, PermissionManager permissionManager, + CommunicationsManager commsMan, SceneCommunicationService sceneGridService, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, bool SendTasksToChild) { @@ -230,9 +235,11 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager = new LandManager(this, m_regInfo); //Bind Storage Manager functions to some land manager functions for this scene - EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); - EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); - + EventManager.OnLandObjectAdded += + new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); + EventManager.OnLandObjectRemoved += + new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); + m_estateManager = new EstateManager(this, m_regInfo); m_permissionManager = permissionManager; @@ -258,7 +265,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneObjects = new Dictionary(); MainLog.Instance.Verbose("SCENE", "Creating LandMap"); - Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); + Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); ScenePresence.LoadAnims(); @@ -276,7 +283,7 @@ namespace OpenSim.Region.Environment.Scenes protected virtual void RegisterDefaultSceneEvents() { m_eventManager.OnParcelPrimCountAdd += m_LandManager.addPrimToLandPrimCounts; - m_eventManager.OnParcelPrimCountUpdate += this.addPrimsToParcelCounts; + m_eventManager.OnParcelPrimCountUpdate += addPrimsToParcelCounts; m_eventManager.OnPermissionError += SendPermissionAlert; } @@ -295,68 +302,65 @@ namespace OpenSim.Region.Environment.Scenes if (RegionInfo.RegionHandle != otherRegion.RegionHandle) { - for (int i = 0; i < m_neighbours.Count; i++) + for (int i = 0; i < m_neighbours.Count; i++) + { + // The purpose of this loop is to re-update the known neighbors + // when another region comes up on top of another one. + // The latest region in that location ends up in the + // 'known neighbors list' + // Additionally, the commFailTF property gets reset to false. + if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) { - // The purpose of this loop is to re-update the known neighbors - // when another region comes up on top of another one. - // The latest region in that location ends up in the - // 'known neighbors list' - // Additionally, the commFailTF property gets reset to false. - if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle) + lock (m_neighbours) { - lock (m_neighbours) - { - m_neighbours[i] = otherRegion; - } + m_neighbours[i] = otherRegion; } } + } - // If the value isn't in the neighbours, add it. - // If the RegionInfo isn't exact but is for the same XY World location, - // then the above loop will fix that. + // If the value isn't in the neighbours, add it. + // If the RegionInfo isn't exact but is for the same XY World location, + // then the above loop will fix that. - if (!(m_neighbours.Contains(otherRegion))) + if (!(m_neighbours.Contains(otherRegion))) + { + lock (m_neighbours) { - lock (m_neighbours) - { - m_neighbours.Add(otherRegion); - } + m_neighbours.Add(otherRegion); } - if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) + } + if ((Math.Abs(otherRegion.RegionLocX - RegionInfo.RegionLocX) <= 1) && + (Math.Abs(otherRegion.RegionLocY - RegionInfo.RegionLocY) <= 1)) { try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - InformClientOfNeighbor(agent, otherRegion); - } - } - - ); + { + // If agent is a root agent. + if (!agent.IsChildAgent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + InformClientOfNeighbor(agent, otherRegion); + } + } + ); } - catch (System.NullReferenceException) + catch (NullReferenceException) { // This means that we're not booted up completely yet. // This shouldn't happen too often anymore. - MainLog.Instance.Error("SCENE", "Couldn't inform client of regionup because we got a null reference exception"); + MainLog.Instance.Error("SCENE", + "Couldn't inform client of regionup because we got a null reference exception"); } } else { - MainLog.Instance.Verbose("INTERGRID", "Got notice about far away Region: " + otherRegion.RegionName.ToString() + - " at (" + otherRegion.RegionLocX.ToString() + ", " + otherRegion.RegionLocY.ToString() + ")" ); + MainLog.Instance.Verbose("INTERGRID", + "Got notice about far away Region: " + otherRegion.RegionName.ToString() + + " at (" + otherRegion.RegionLocX.ToString() + ", " + + otherRegion.RegionLocY.ToString() + ")"); } - - - - } return true; } @@ -379,11 +383,11 @@ namespace OpenSim.Region.Environment.Scenes { // Now we figure out what to set the timer to that does the notifications and calls, RestartNow() m_restartTimer.Interval = 15000; - m_incrementsof15seconds = (int)seconds / 15; + m_incrementsof15seconds = (int) seconds/15; m_RestartTimerCounter = 0; m_restartTimer.AutoReset = true; m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); - MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds / 60) + " minutes"); + MainLog.Instance.Error("REGION", "Restarting Region in " + (seconds/60) + " minutes"); m_restartTimer.Start(); SendGeneralAlert(RegionInfo.RegionName + ": Restarting in 2 Minutes"); } @@ -399,7 +403,8 @@ namespace OpenSim.Region.Environment.Scenes if (m_RestartTimerCounter <= m_incrementsof15seconds) { if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7) - SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds"); + SendGeneralAlert(RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter)*15) + + " seconds"); } else { @@ -432,21 +437,19 @@ namespace OpenSim.Region.Environment.Scenes { try { - ForEachScenePresence(delegate(ScenePresence agent) - { - // If agent is a root agent. - if (!agent.IsChildAgent) - { - //agent.ControllingClient.new - //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); - InformClientOfNeighbor(agent, region); - } - } - - ); + { + // If agent is a root agent. + if (!agent.IsChildAgent) + { + //agent.ControllingClient.new + //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); + InformClientOfNeighbor(agent, region); + } + } + ); } - catch (System.NullReferenceException) + catch (NullReferenceException) { // This means that we're not booted up completely yet. // This shouldn't happen too often anymore. @@ -464,24 +467,22 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Warn("SCENE", "Closing down the single simulator: " + RegionInfo.RegionName); // Kick all ROOT agents with the message, 'The simulator is going down' ForEachScenePresence(delegate(ScenePresence avatar) - { - if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) - avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); + { + if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) + avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); - if (!avatar.IsChildAgent) - avatar.ControllingClient.Kick("The simulator is going down."); + if (!avatar.IsChildAgent) + avatar.ControllingClient.Kick("The simulator is going down."); - avatar.ControllingClient.OutPacket(new libsecondlife.Packets.DisableSimulatorPacket(), ThrottleOutPacketType.Task); - }); + avatar.ControllingClient.OutPacket(new DisableSimulatorPacket(), + ThrottleOutPacketType.Task); + }); // Wait here, or the kick messages won't actually get to the agents before the scene terminates. Thread.Sleep(500); // Stop all client threads. - ForEachScenePresence(delegate(ScenePresence avatar) - { - avatar.ControllingClient.Close(true); - }); + ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(true); }); // Stop updating the scene objects and agents. m_heartbeatTimer.Close(); // close the inner scene @@ -509,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes public void StartTimer() { m_heartbeatTimer.Enabled = true; - m_heartbeatTimer.Interval = (int)(m_timespan * 1000); + m_heartbeatTimer.Interval = (int) (m_timespan*1000); m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); } @@ -555,30 +556,30 @@ namespace OpenSim.Region.Environment.Scenes if (m_frame == Int32.MaxValue) m_frame = 0; - if (m_frame % m_update_physics == 0) + if (m_frame%m_update_physics == 0) m_innerScene.UpdatePreparePhysics(); - if (m_frame % m_update_entitymovement == 0) + if (m_frame%m_update_entitymovement == 0) m_innerScene.UpdateEntityMovement(); - if (m_frame % m_update_physics == 0) + if (m_frame%m_update_physics == 0) physicsFPS = m_innerScene.UpdatePhysics( Math.Max(SinceLastFrame.TotalSeconds, m_timespan) ); - if (m_frame % m_update_entities == 0) + if (m_frame%m_update_entities == 0) m_innerScene.UpdateEntities(); - if (m_frame % m_update_events == 0) + if (m_frame%m_update_events == 0) UpdateEvents(); - if (m_frame % m_update_backup == 0) + if (m_frame%m_update_backup == 0) UpdateStorageBackup(); - if (m_frame % m_update_terrain == 0) + if (m_frame%m_update_terrain == 0) UpdateTerrain(); - if (m_frame % m_update_land == 0) + if (m_frame%m_update_land == 0) UpdateLand(); // if (m_frame%m_update_avatars == 0) @@ -592,7 +593,6 @@ namespace OpenSim.Region.Environment.Scenes m_statsReporter.SetChildAgents(m_innerScene.GetChildAgentCount()); m_statsReporter.SetObjects(m_innerScene.GetTotalObjects()); m_statsReporter.SetActiveObjects(m_innerScene.GetActiveObjects()); - } catch (NotImplementedException) { @@ -606,10 +606,11 @@ namespace OpenSim.Region.Environment.Scenes { updateLock.ReleaseMutex(); - m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds; + m_timedilation = m_timespan/(float) SinceLastFrame.TotalSeconds; m_lastupdate = DateTime.Now; } } + //Updates the time in the viewer. private void UpdateInWorldTime() { @@ -631,7 +632,7 @@ namespace OpenSim.Region.Environment.Scenes } } - private void SendSimStatsPackets(libsecondlife.Packets.SimStatsPacket pack) + private void SendSimStatsPackets(SimStatsPacket pack) { List StatSendAgents = GetScenePresences(); foreach (ScenePresence agent in StatSendAgents) @@ -639,11 +640,10 @@ namespace OpenSim.Region.Environment.Scenes if (!agent.IsChildAgent) { agent.ControllingClient.OutPacket(pack, ThrottleOutPacketType.Task); - } } - } + private void UpdateLand() { if (m_LandManager.landPrimCountTainted) @@ -676,7 +676,7 @@ namespace OpenSim.Region.Environment.Scenes { for (int y = 0; y < 16; y++) { - if (Terrain.Tainted(x * 16, y * 16)) + if (Terrain.Tainted(x*16, y*16)) { client.SendLayerData(x, y, terData); } @@ -724,13 +724,17 @@ namespace OpenSim.Region.Environment.Scenes public void ExportWorldMap(string fileName) { - List mapBlocks = this.CommsManager.GridService.RequestNeighbourMapBlocks((int)(this.RegionInfo.RegionLocX - 9), (int)(this.RegionInfo.RegionLocY - 9), (int)(this.RegionInfo.RegionLocX + 9), (int)(this.RegionInfo.RegionLocY + 9)); + List mapBlocks = + CommsManager.GridService.RequestNeighbourMapBlocks((int) (RegionInfo.RegionLocX - 9), + (int) (RegionInfo.RegionLocY - 9), + (int) (RegionInfo.RegionLocX + 9), + (int) (RegionInfo.RegionLocY + 9)); List textures = new List(); - List bitImages = new List(); + List bitImages = new List(); foreach (MapBlockData mapBlock in mapBlocks) { - AssetBase texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + AssetBase texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); if (texAsset != null) { @@ -738,7 +742,7 @@ namespace OpenSim.Region.Environment.Scenes } else { - texAsset = this.AssetCache.GetAsset(mapBlock.MapImageId, true); + texAsset = AssetCache.GetAsset(mapBlock.MapImageId, true); if (texAsset != null) { textures.Add(texAsset); @@ -748,22 +752,22 @@ namespace OpenSim.Region.Environment.Scenes foreach (AssetBase asset in textures) { - System.Drawing.Image image = OpenJPEGNet.OpenJPEG.DecodeToImage(asset.Data); + Image image = OpenJPEG.DecodeToImage(asset.Data); bitImages.Add(image); } - System.Drawing.Bitmap mapTexture = new System.Drawing.Bitmap(2560, 2560); - System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mapTexture); - System.Drawing.SolidBrush sea = new System.Drawing.SolidBrush(System.Drawing.Color.DarkBlue); + Bitmap mapTexture = new Bitmap(2560, 2560); + Graphics g = Graphics.FromImage(mapTexture); + SolidBrush sea = new SolidBrush(Color.DarkBlue); g.FillRectangle(sea, 0, 0, 2560, 2560); for (int i = 0; i < mapBlocks.Count; i++) { - ushort x = (ushort)((mapBlocks[i].X - this.RegionInfo.RegionLocX) + 10); - ushort y = (ushort)((mapBlocks[i].Y - this.RegionInfo.RegionLocY) + 10); - g.DrawImage(bitImages[i], (x * 128), (y * 128), 128, 128); + ushort x = (ushort) ((mapBlocks[i].X - RegionInfo.RegionLocX) + 10); + ushort y = (ushort) ((mapBlocks[i].Y - RegionInfo.RegionLocY) + 10); + g.DrawImage(bitImages[i], (x*128), (y*128), 128, 128); } - mapTexture.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg); + mapTexture.Save(fileName, ImageFormat.Jpeg); } /// @@ -861,7 +865,7 @@ namespace OpenSim.Region.Environment.Scenes public void loadAllLandObjectsFromStorage() { MainLog.Instance.Verbose("SCENE", "Loading land objects from storage"); - List landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); + List landData = m_storageManager.DataStore.LoadLandObjects(RegionInfo.RegionID); if (landData.Count == 0) { m_LandManager.NoLandDataFromStorage(); @@ -871,7 +875,7 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager.IncomingLandObjectsFromStorage(landData); } } - + #endregion #region Primitives Methods @@ -889,8 +893,8 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); rootPart.ApplySanePermissions(); - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = PhysicsScene.AddPrimShape( rootPart.Name, rootPart.Shape, @@ -931,9 +935,8 @@ namespace OpenSim.Region.Environment.Scenes if (PermissionsMngr.CanRezObject(ownerID, pos)) { - EntityIntersection rayTracing = null; - ScenePresence presence = ((ScenePresence)GetScenePresence(ownerID)); + ScenePresence presence = ((ScenePresence) GetScenePresence(ownerID)); if (presence != null) { Vector3 CameraPosition = presence.CameraPosition; @@ -941,14 +944,13 @@ namespace OpenSim.Region.Environment.Scenes float raydistance = m_innerScene.Vector3Distance(CameraPosition, rayEnd); - Vector3 rayDirection = new Vector3(rayEnd.x / raydistance, rayEnd.y / raydistance, rayEnd.z / raydistance); + Vector3 rayDirection = new Vector3(rayEnd.x/raydistance, rayEnd.y/raydistance, rayEnd.z/raydistance); Ray rezRay = new Ray(CameraPosition, rayDirection); Vector3 RezDirectionFromCamera = rezRay.Direction; rayTracing = m_innerScene.GetClosestIntersectingPrim(rezRay); - } if ((rayTracing != null) && (rayTracing.HitTF)) @@ -957,7 +959,8 @@ namespace OpenSim.Region.Environment.Scenes // We will rez the object somewhere close to the prim. Better math needed. This is a Stub //Vector3 Newpos = new Vector3(rayTracing.obj.AbsolutePosition.X,rayTracing.obj.AbsolutePosition.Y,rayTracing.obj.AbsolutePosition.Z); Vector3 Newpos = rayTracing.ipoint; - Vector3 NewScale = new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); + Vector3 NewScale = + new Vector3(rayTracing.obj.Scale.X, rayTracing.obj.Scale.Y, rayTracing.obj.Scale.Z); Quaternion ParentRot = rayTracing.obj.ParentGroup.Rotation; //Quaternion ParentRot = new Quaternion(primParentRot.W,primParentRot.X,primParentRot.Y,primParentRot.Z); @@ -965,7 +968,7 @@ namespace OpenSim.Region.Environment.Scenes LLQuaternion primLocalRot = rayTracing.obj.RotationOffset; Quaternion LocalRot = new Quaternion(primLocalRot.W, primLocalRot.X, primLocalRot.Y, primLocalRot.Z); - Quaternion NewRot = LocalRot * ParentRot; + Quaternion NewRot = LocalRot*ParentRot; Vector3 RezPoint = Newpos; @@ -990,8 +993,8 @@ namespace OpenSim.Region.Environment.Scenes //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; } // if not phantom, add to physics - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = PhysicsScene.AddPrimShape( @@ -1007,14 +1010,14 @@ namespace OpenSim.Region.Environment.Scenes } public void AddTree(LLVector3 scale, LLQuaternion rotation, LLVector3 position, - Tree treeType, bool newTree) + Tree treeType, bool newTree) { PrimitiveBaseShape treeShape = new PrimitiveBaseShape(); treeShape.PathCurve = 16; treeShape.PathEnd = 49900; - treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree; + treeShape.PCode = newTree ? (byte) PCode.NewTree : (byte) PCode.Tree; treeShape.Scale = scale; - treeShape.State = (byte)treeType; + treeShape.State = (byte) treeType; AddNewPrim(LLUUID.Random(), position, rotation, treeShape); } @@ -1135,7 +1138,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); client.OnParcelAccessListRequest += new ParcelAccessListRequest(m_LandManager.handleParcelAccessRequest); - client.OnParcelAccessListUpdateRequest += new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); + client.OnParcelAccessListUpdateRequest += + new ParcelAccessListUpdateRequest(m_LandManager.handleParcelAccessUpdateRequest); client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); client.OnRegionInfoRequest += m_estateManager.HandleRegionInfoRequest; @@ -1157,8 +1161,8 @@ namespace OpenSim.Region.Environment.Scenes client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; client.OnRezScript += RezScript; - - client.OnRequestTaskInventory += RequestTaskInventory; + + client.OnRequestTaskInventory += RequestTaskInventory; client.OnRemoveTaskItem += RemoveTaskInventory; client.OnUpdateTaskInventory += UpdateTaskInventory; @@ -1216,23 +1220,23 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } } - catch (System.NullReferenceException) + catch (NullReferenceException) { // We don't know which count to remove it from // Avatar is already disposed :/ } m_eventManager.TriggerOnRemovePresence(agentID); Broadcast(delegate(IClientAPI client) - { - try - { - client.SendKillObject(avatar.RegionHandle, avatar.LocalId); - } - catch (System.NullReferenceException) { - //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. - } - }); + try + { + client.SendKillObject(avatar.RegionHandle, avatar.LocalId); + } + catch (NullReferenceException) + { + //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. + } + }); ForEachScenePresence( delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); @@ -1251,7 +1255,7 @@ namespace OpenSim.Region.Environment.Scenes { avatar.Close(); } - catch (System.NullReferenceException) + catch (NullReferenceException) { //We can safely ignore null reference exceptions. It means the avatar are dead and cleaned up anyway. } @@ -1263,19 +1267,22 @@ namespace OpenSim.Region.Environment.Scenes // Remove client agent from profile, so new logins will work CommsManager.UserService.clearUserAgent(agentID); } - public override void CloseAllAgents(uint circuitcode) + + public override void CloseAllAgents(uint circuitcode) { // Called by ClientView to kill all circuit codes ClientManager.CloseAllAgents(circuitcode); - } + public void NotifyMyCoarseLocationChange() { ForEachScenePresence(delegate(ScenePresence presence) { presence.CoarseLocationChange(); }); } + #endregion #region Entities + /// /// /// @@ -1312,7 +1319,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneGridService.OnCloseAgentConnection += CloseConnection; m_sceneGridService.OnRegionUp += OtherRegionUp; m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - + m_sceneGridService.KillObject = SendKillObject; } @@ -1321,17 +1328,16 @@ namespace OpenSim.Region.Environment.Scenes /// /// public void UnRegisterReginWithComms() - { - + { m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; m_sceneGridService.OnRegionUp -= OtherRegionUp; m_sceneGridService.OnExpectUser -= NewUserConnection; m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; m_sceneGridService.OnCloseAgentConnection -= CloseConnection; - + m_sceneGridService.Close(); } - + /// /// @@ -1344,18 +1350,19 @@ namespace OpenSim.Region.Environment.Scenes { if (agent.CapsPath != "") { - OpenSim.Region.Capabilities.Caps cap = - new OpenSim.Region.Capabilities.Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, + Caps cap = + new Caps(AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, agent.CapsPath, agent.AgentID, m_dumpAssetsToFile); - Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + - "/CAPS/" + agent.CapsPath + "0000/"); + Util.SetCapsURL(agent.AgentID, + "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + + "/CAPS/" + agent.CapsPath + "0000/"); cap.RegisterHandlers(); - + cap.AddNewInventoryItem = AddInventoryItem; cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; - + if (m_capsHandlers.ContainsKey(agent.AgentID)) { //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + @@ -1364,7 +1371,7 @@ namespace OpenSim.Region.Environment.Scenes { m_capsHandlers[agent.AgentID] = cap; } - catch (System.Collections.Generic.KeyNotFoundException) + catch (KeyNotFoundException) { // Fix for a potential race condition. m_capsHandlers.Add(agent.AgentID, cap); @@ -1396,10 +1403,10 @@ namespace OpenSim.Region.Environment.Scenes { m_scenePresences[agentID].MakeRootAgent(position, isFlying); } - catch (System.Exception e) + catch (Exception e) { MainLog.Instance.Verbose("SCENE", "Unable to do Agent Crossing."); - MainLog.Instance.Debug("SCENE",e.ToString()); + MainLog.Instance.Debug("SCENE", e.ToString()); } //m_innerScene.SwapRootChildAgent(false); } @@ -1419,11 +1426,11 @@ namespace OpenSim.Region.Environment.Scenes childAgentUpdate.ChildAgentDataUpdate(cAgentData); // Not Implemented: //TODO: Do we need to pass the message on to one of our neighbors? - } } return true; } + /// /// Tell a single agent to disconnect from the region. /// @@ -1445,7 +1452,7 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } // Tell a single agent to disconnect from the region. - libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); + DisableSimulatorPacket disable = new DisableSimulatorPacket(); presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); } } @@ -1511,7 +1518,8 @@ namespace OpenSim.Region.Environment.Scenes { if (m_scenePresences.ContainsKey(remoteClient.AgentId)) { - m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, position, lookAt, flags); + m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle, + position, lookAt, flags); } } @@ -1551,9 +1559,9 @@ namespace OpenSim.Region.Environment.Scenes /// 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); } } @@ -1563,9 +1571,9 @@ namespace OpenSim.Region.Environment.Scenes /// public T RequestModuleInterface() { - if (ModuleInterfaces.ContainsKey(typeof(T))) + if (ModuleInterfaces.ContainsKey(typeof (T))) { - return (T)ModuleInterfaces[typeof(T)]; + return (T) ModuleInterfaces[typeof (T)]; } else { @@ -1642,7 +1650,7 @@ namespace OpenSim.Region.Environment.Scenes { if (obj is SceneObjectGroup) { - m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj); + m_eventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj); } } } @@ -1650,6 +1658,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Console Commands + #region Alert Methods private void SendPermissionAlert(LLUUID user, string reason) @@ -1692,7 +1701,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, IClientAPI controllingClient) + public void handleRequestGodlikePowers(LLUUID agentID, LLUUID sessionID, LLUUID token, + IClientAPI controllingClient) { // First check that this is the sim owner if (agentID == RegionInfo.MasterAvatarAssignedUUID) @@ -1736,37 +1746,38 @@ namespace OpenSim.Region.Environment.Scenes if (agentID == kickUserID) { ClientManager.ForEachClient(delegate(IClientAPI controller) - { - ScenePresence p = GetScenePresence(controller.AgentId); - bool childagent = !p.Equals(null) && p.IsChildAgent; - if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? { - controller.Kick(Helpers.FieldToUTF8String(reason)); - - if (childagent) + ScenePresence p = GetScenePresence(controller.AgentId); + bool childagent = !p.Equals(null) && p.IsChildAgent; + if (controller.AgentId != godID && !childagent) + // Do we really want to kick the initiator of this madness? { - m_innerScene.removeUserCount(false); + controller.Kick(Helpers.FieldToUTF8String(reason)); + + if (childagent) + { + m_innerScene.removeUserCount(false); + } + else + { + m_innerScene.removeUserCount(true); + } } - else - { - m_innerScene.removeUserCount(true); - } - } - } ); // This is a bit crude. It seems the client will be null before it actually stops the thread // The thread will kill itself eventually :/ // Is there another way to make sure *all* clients get this 'inter region' message? ClientManager.ForEachClient(delegate(IClientAPI controller) - { - ScenePresence p = GetScenePresence(controller.AgentId); - bool childagent = !p.Equals(null) && p.IsChildAgent; - if (controller.AgentId != godID && !childagent) // Do we really want to kick the initiator of this madness? { - controller.Close(true); + ScenePresence p = GetScenePresence(controller.AgentId); + bool childagent = !p.Equals(null) && p.IsChildAgent; + if (controller.AgentId != godID && !childagent) + // Do we really want to kick the initiator of this madness? + { + controller.Close(true); + } } - } ); } else @@ -1799,7 +1810,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, List permChanges) + public void HandleObjectPermissionsUpdate(IClientAPI controller, LLUUID agentID, LLUUID sessionID, + List permChanges) { // Check for spoofing.. since this is permissions we're talking about here! if ((controller.SessionId == sessionID) && (controller.AgentId == agentID)) @@ -1879,7 +1891,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); + ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); } } } @@ -1899,7 +1911,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); + SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID); if (part != null) { if (part.Name == cmdparams[0]) @@ -1967,10 +1979,12 @@ namespace OpenSim.Region.Environment.Scenes { m_eventManager.TriggerOnPluginConsole(args); } + public double GetLandHeight(int x, int y) { return Terrain.GetHeight(x, y); } + public LLUUID GetLandOwner(float x, float y) { Land land = LandManager.getLandObject(x, y); @@ -1983,7 +1997,7 @@ namespace OpenSim.Region.Environment.Scenes return land.landData.ownerID; } } - + public LandData GetLandData(float x, float y) { return LandManager.getLandObject(x, y).landData; @@ -2034,6 +2048,7 @@ namespace OpenSim.Region.Environment.Scenes { return m_innerScene.ConvertLocalIDToFullID(localID); } + public void SwapRootAgentCount(bool rootChildChildRootTF) { m_innerScene.SwapRootChildAgent(rootChildChildRootTF); @@ -2108,13 +2123,16 @@ namespace OpenSim.Region.Environment.Scenes // We don't want to try to send messages if there are no avatar. if (!(m_scenePresences.Equals(null))) { - try { - List presenceList = GetScenePresences(); + try + { + List presenceList = GetScenePresences(); foreach (ScenePresence presence in presenceList) { action(presence); } - } catch (Exception e) { + } + catch (Exception e) + { MainLog.Instance.Verbose("BUG", e.ToString()); } } @@ -2181,4 +2199,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 35d88eb..fe8f8da 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -26,8 +26,6 @@ * */ using System; -using System.Collections.Generic; -using System.Timers; using libsecondlife; using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; @@ -43,8 +41,9 @@ namespace OpenSim.Region.Environment.Scenes public event restart OnRestart; #endregion - + #region Fields + private readonly ClientManager m_clientManager = new ClientManager(); public ClientManager ClientManager @@ -92,8 +91,6 @@ namespace OpenSim.Region.Environment.Scenes /// public abstract void Update(); - - #endregion #region Terrain Methods @@ -163,8 +160,8 @@ namespace OpenSim.Region.Environment.Scenes public abstract bool OtherRegionUp(RegionInfo thisRegion); - #endregion + #region Shutdown /// @@ -184,4 +181,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index b184af2..3942397 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -29,11 +29,10 @@ using System; using System.Collections.Generic; using System.Net; -using System.Text; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -52,7 +51,7 @@ namespace OpenSim.Region.Environment.Scenes public event PrimCrossing OnPrimCrossingIntoRegion; public event RegionUp OnRegionUp; public event ChildAgentUpdate OnChildAgentUpdate; - + public KillObjectDelegate KillObject; public string _debugRegionName = ""; @@ -60,10 +59,7 @@ namespace OpenSim.Region.Environment.Scenes public string debugRegionName { get { return _debugRegionName; } - set - { - _debugRegionName = value; - } + set { _debugRegionName = value; } } public SceneCommunicationService(CommunicationsManager commsMan) @@ -90,7 +86,6 @@ namespace OpenSim.Region.Environment.Scenes regionCommsHost.OnCloseAgentConnection += CloseConnection; regionCommsHost.OnRegionUp += newRegionUp; regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; - } else { @@ -102,7 +97,6 @@ namespace OpenSim.Region.Environment.Scenes { if (regionCommsHost != null) { - regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; regionCommsHost.OnRegionUp -= newRegionUp; regionCommsHost.OnExpectUser -= NewUserConnection; @@ -115,6 +109,7 @@ namespace OpenSim.Region.Environment.Scenes } #region CommsManager Event handlers + /// /// /// @@ -139,6 +134,7 @@ namespace OpenSim.Region.Environment.Scenes } return true; } + protected bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { if (OnChildAgentUpdate != null) @@ -155,6 +151,7 @@ namespace OpenSim.Region.Environment.Scenes OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); } } + protected void PrimCrossing(ulong regionHandle, LLUUID primID, LLVector3 position, bool isPhysical) { if (OnPrimCrossingIntoRegion != null) @@ -174,12 +171,13 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Inform Client of Neighbours + private delegate void InformClientOfNeighbourDelegate( ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); private void InformClientOfNeighbourCompleted(IAsyncResult iar) { - InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; + InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState; icon.EndInvoke(iar); } @@ -215,8 +213,6 @@ namespace OpenSim.Region.Environment.Scenes //blah.Address = region.RemotingAddress; //blah.Port = region.RemotingPort; - - } /// @@ -227,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes { List neighbours = new List(); - //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); for (int i = 0; i < lstneighbours.Count; i++) { // We don't want to keep sending to regions that consistently fail on comms. @@ -245,7 +241,6 @@ namespace OpenSim.Region.Environment.Scenes { for (int i = 0; i < neighbours.Count; i++) { - AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); agent.BaseFolder = LLUUID.Zero; agent.InventoryFolder = LLUUID.Zero; @@ -259,6 +254,7 @@ namespace OpenSim.Region.Environment.Scenes } } } + /// /// This informs a single neighboring region about agent "avatar". /// Calls an asynchronous method to do so.. so it doesn't lag the sim. @@ -278,11 +274,12 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + public delegate void InformNeighbourThatRegionUpDelegate(RegionInfo region, ulong regionhandle); private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) { - InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate)iar.AsyncState; + InformNeighbourThatRegionUpDelegate icon = (InformNeighbourThatRegionUpDelegate) iar.AsyncState; icon.EndInvoke(iar); } @@ -290,7 +287,8 @@ namespace OpenSim.Region.Environment.Scenes private void InformNeighboursThatRegionIsUpAsync(RegionInfo region, ulong regionhandle) { MainLog.Instance.Notice("INTERGRID", "Starting to inform neighbors that I'm here"); - bool regionAccepted = m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); + bool regionAccepted = + m_commsProvider.InterRegion.RegionUp((new SearializableRegionInfo(region)), regionhandle); if (regionAccepted) { @@ -301,6 +299,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Notice("INTERGRID", "Failed to inform neighbors that I'm here"); } } + /// /// Called by scene when region is initialized (not always when it's listening for agents) /// This is an inter-region message that informs the surrounding neighbors that the sim is up. @@ -317,7 +316,6 @@ namespace OpenSim.Region.Environment.Scenes { for (int i = 0; i < neighbours.Count; i++) { - InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; d.BeginInvoke(region, neighbours[i].RegionHandle, @@ -325,9 +323,10 @@ namespace OpenSim.Region.Environment.Scenes d); } } - + //bool val = m_commsProvider.InterRegion.RegionUp(new SearializableRegionInfo(region)); } + public delegate void SendChildAgentDataUpdateDelegate(ulong regionHandle, ChildAgentDataUpdate cAgentData); /// @@ -340,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes private void SendChildAgentDataUpdateAsync(ulong regionHandle, ChildAgentDataUpdate cAgentData) { MainLog.Instance.Notice("INTERGRID", "Informing a neighbor about my agent."); - bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle,cAgentData); + bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); if (regionAccepted) { @@ -351,11 +350,13 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Notice("INTERGRID", "Failed sending a neighbor an update about my agent"); } } + private void SendChildAgentDataUpdateCompleted(IAsyncResult iar) { - SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate)iar.AsyncState; + SendChildAgentDataUpdateDelegate icon = (SendChildAgentDataUpdateDelegate) iar.AsyncState; icon.EndInvoke(iar); } + public void SendChildAgentDataUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { // This assumes that we know what our neighbors are. @@ -363,9 +364,8 @@ namespace OpenSim.Region.Environment.Scenes d.BeginInvoke(regionHandle, cAgentData, SendChildAgentDataUpdateCompleted, d); - } - + /// /// Helper function to request neighbors from grid-comms @@ -401,15 +401,13 @@ namespace OpenSim.Region.Environment.Scenes /// /// public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, - LLVector3 lookAt, uint flags) + LLVector3 lookAt, uint flags) { if (regionHandle == m_regionInfo.RegionHandle) { - avatar.ControllingClient.SendTeleportLocationStart(); avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); avatar.Teleport(position); - } else { @@ -424,20 +422,22 @@ namespace OpenSim.Region.Environment.Scenes agent.child = true; avatar.Close(); m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); - m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); + m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, + position, false); AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); - avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); + avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), + capsPath); avatar.MakeChildAgent(); if (KillObject != null) { KillObject(avatar.LocalId); } - uint newRegionX = (uint)(regionHandle >> 40); - uint newRegionY = (((uint)(regionHandle)) >> 8); - uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); - uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); - if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) + uint newRegionX = (uint) (regionHandle >> 40); + uint newRegionY = (((uint) (regionHandle)) >> 8); + uint oldRegionX = (uint) (m_regionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint) (m_regionInfo.RegionHandle)) >> 8); + if (Util.fast_distance2d((int) (newRegionX - oldRegionX), (int) (newRegionY - oldRegionY)) > 3) { CloseChildAgentConnections(avatar); } @@ -465,7 +465,8 @@ namespace OpenSim.Region.Environment.Scenes { foreach (ulong regionHandle in presence.KnownChildRegions) { - m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, presence.ControllingClient.AgentId); + m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, + presence.ControllingClient.AgentId); presence.RemoveNeighbourRegion(regionHandle); } } @@ -474,6 +475,5 @@ namespace OpenSim.Region.Environment.Scenes { return m_commsProvider.GridService.GetGridSettings(); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 9c8c62b..a6a8fb6 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -105,7 +105,7 @@ namespace OpenSim.Region.Environment.Scenes public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID); public event LandObjectAdded OnLandObjectAdded; - + public delegate void LandObjectRemoved(LLUUID globalID); public event LandObjectRemoved OnLandObjectRemoved; @@ -117,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes public void TriggerOnClientMovement(ScenePresence avatar) { - if(OnClientMovement != null) + if (OnClientMovement != null) OnClientMovement(avatar); } @@ -223,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes { if (OnSceneGroupMove != null) { - return OnSceneGroupMove(groupID, delta); + return OnSceneGroupMove(groupID, delta); } return true; } @@ -236,13 +236,14 @@ namespace OpenSim.Region.Environment.Scenes } } - public void TriggerLandObjectAdded(Land newParcel,LLUUID regionID) + public void TriggerLandObjectAdded(Land newParcel, LLUUID regionID) { if (OnLandObjectAdded != null) { OnLandObjectAdded(newParcel, regionID); } } + public void TriggerLandObjectRemoved(LLUUID globalID) { if (OnLandObjectRemoved != null) @@ -250,10 +251,11 @@ namespace OpenSim.Region.Environment.Scenes OnLandObjectRemoved(globalID); } } + public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel) { //triggerLandObjectRemoved(localParcelID); - TriggerLandObjectAdded(newParcel,newParcel.m_scene.RegionInfo.RegionID); + TriggerLandObjectAdded(newParcel, newParcel.m_scene.RegionInfo.RegionID); } public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID) diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index e822874..1eac61b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -84,7 +84,6 @@ namespace OpenSim.Region.Environment.Scenes { if (m_localScenes[i].Equals(cscene)) { - m_localScenes[i].Close(); } } @@ -99,7 +98,8 @@ namespace OpenSim.Region.Environment.Scenes public void HandleRestart(RegionInfo rdata) { - MainLog.Instance.Error("SCENEMANAGER", "Got Restart message for region:" + rdata.RegionName +" Sending up to main"); + MainLog.Instance.Error("SCENEMANAGER", + "Got Restart message for region:" + rdata.RegionName + " Sending up to main"); int RegionSceneElement = -1; for (int i = 0; i < m_localScenes.Count; i++) { @@ -127,7 +127,6 @@ namespace OpenSim.Region.Environment.Scenes for (int i = 0; i < m_localScenes.Count; i++) { - if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) { // Inform other regions to tell their avatar about me @@ -223,7 +222,7 @@ namespace OpenSim.Region.Environment.Scenes { ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); }); } - + public void HandleAlertCommandOnCurrentScene(string[] cmdparams) { ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); @@ -423,4 +422,4 @@ namespace OpenSim.Region.Environment.Scenes m_localScenes.ForEach(action); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 20d596a..5b74c9b 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; using System.Text; using System.Xml; @@ -38,7 +39,6 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Physics.Manager; -using System.Drawing; namespace OpenSim.Region.Environment.Scenes { @@ -74,11 +74,13 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_rootPart.RotationOffset; } } + public LLUUID GroupID { get { return m_rootPart.GroupID; } set { m_rootPart.GroupID = value; } } + /// /// /// @@ -242,7 +244,7 @@ namespace OpenSim.Region.Environment.Scenes part.ParentID = 0; part.LinkNum = 0; m_parts.Add(part.UUID, part); - + SetPartAsRoot(part); RegionHandle = regionHandle; @@ -295,7 +297,6 @@ namespace OpenSim.Region.Environment.Scenes sr.Close(); - m_rootPart.LocalID = m_scene.PrimIDAllocate(); m_rootPart.ParentID = 0; m_rootPart.RegionHandle = m_regionHandle; @@ -376,9 +377,10 @@ namespace OpenSim.Region.Environment.Scenes foreach (SceneObjectPart part in m_parts.Values) { - - Vector3 partPosition = new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); - Quaternion parentrotation = new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); + Vector3 partPosition = + new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); + Quaternion parentrotation = + new Quaternion(GroupRotation.W, GroupRotation.X, GroupRotation.Y, GroupRotation.Z); // Telling the prim to raytrace. EntityIntersection inter = part.TestIntersection(hRay, parentrotation); @@ -389,14 +391,11 @@ namespace OpenSim.Region.Environment.Scenes float idist = 256f; - - if (inter.HitTF) { // We need to find the closest prim to return to the testcaller along the ray if (inter.distance < idist) { - idist = inter.distance; returnresult.HitTF = true; returnresult.ipoint = inter.ipoint; @@ -405,15 +404,11 @@ namespace OpenSim.Region.Environment.Scenes returnresult.distance = inter.distance; } } - - } return returnresult; - } - /// /// /// @@ -524,7 +519,7 @@ namespace OpenSim.Region.Environment.Scenes /// public SceneObjectGroup Copy(LLUUID cAgentID, LLUUID cGroupID) { - SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); + SceneObjectGroup dupe = (SceneObjectGroup) MemberwiseClone(); dupe.m_parts = new Dictionary(); dupe.m_parts.Clear(); //dupe.OwnerID = AgentID; @@ -549,9 +544,8 @@ namespace OpenSim.Region.Environment.Scenes new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z), - dupe.RootPart.PhysActor.IsPhysical); + dupe.RootPart.PhysActor.IsPhysical); dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); - } // Now we've made a copy that replaces this one, we need to // switch the owner to the person who did the copying @@ -559,8 +553,8 @@ namespace OpenSim.Region.Environment.Scenes // So, we have to make a copy of this one, set it in it's place then set the owner on this one SetRootPartOwner(m_rootPart, cAgentID, cGroupID); - - + + m_rootPart.ScheduleFullUpdate(); List partList = new List(m_parts.Values); @@ -571,7 +565,6 @@ namespace OpenSim.Region.Environment.Scenes dupe.CopyPart(part, OwnerID, GroupID); SetPartOwner(part, cAgentID, cGroupID); part.ScheduleFullUpdate(); - } } dupe.UpdateParentIDs(); @@ -601,7 +594,7 @@ namespace OpenSim.Region.Environment.Scenes part.OwnerID = cAgentID; part.GroupID = cGroupID; - + if (part.OwnerID != cAgentID) { // Apply Next Owner Permissions if we're not bypassing permissions @@ -637,6 +630,7 @@ namespace OpenSim.Region.Environment.Scenes m_parts.Add(part.UUID, part); } } + /// /// /// @@ -666,8 +660,8 @@ namespace OpenSim.Region.Environment.Scenes objPropDB.Description = Helpers.StringToField(RootPart.Description); objPropFamilyPack.ObjectData = objPropDB; remoteClient.OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task); - } + public void SetPartOwner(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID) { part.OwnerID = cAgentID; @@ -884,12 +878,12 @@ namespace OpenSim.Region.Environment.Scenes Quaternion parentRot = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); - axPos = parentRot.Inverse() * axPos; + axPos = parentRot.Inverse()*axPos; linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); Quaternion oldRot = new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); - Quaternion newRot = parentRot.Inverse() * oldRot; + Quaternion newRot = parentRot.Inverse()*oldRot; linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); linkPart.ParentID = m_rootPart.LocalID; linkPart.LinkNum = m_parts.Count; @@ -949,7 +943,7 @@ namespace OpenSim.Region.Environment.Scenes linkPart.OffsetPosition.Y, linkPart.OffsetPosition.Z); - axPos = parentRot * axPos; + axPos = parentRot*axPos; linkPart.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; linkPart.OffsetPosition = new LLVector3(0, 0, 0); @@ -960,7 +954,7 @@ namespace OpenSim.Region.Environment.Scenes linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z); - Quaternion newRot = parentRot * oldRot; + Quaternion newRot = parentRot*oldRot; linkPart.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); // Add physics information back to delinked part if appropriate @@ -978,7 +972,6 @@ namespace OpenSim.Region.Environment.Scenes linkPart.RotationOffset.Y, linkPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true); - } SceneObjectGroup objectGroup = new SceneObjectGroup(m_scene, m_regionHandle, linkPart); @@ -990,8 +983,8 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Verbose("SCENE", - "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", - partID, LocalId); + "DelinkFromGroup(): Child prim local id {0} not found in object with root prim id {1}", + partID, LocalId); } } @@ -1008,7 +1001,7 @@ namespace OpenSim.Region.Environment.Scenes m_parts.Add(part.UUID, part); Vector3 axiomOldPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); - axiomOldPos = oldGroupRotation * axiomOldPos; + axiomOldPos = oldGroupRotation*axiomOldPos; axiomOldPos += oldGroupPosition; LLVector3 oldAbsolutePosition = new LLVector3(axiomOldPos.x, axiomOldPos.y, axiomOldPos.z); part.OffsetPosition = oldAbsolutePosition - AbsolutePosition; @@ -1018,15 +1011,15 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.RotationOffset.Z); Vector3 axiomPos = new Vector3(part.OffsetPosition.X, part.OffsetPosition.Y, part.OffsetPosition.Z); - axiomPos = axiomRootRotation.Inverse() * axiomPos; + axiomPos = axiomRootRotation.Inverse()*axiomPos; part.OffsetPosition = new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z); Quaternion axiomPartRotation = new Quaternion(part.RotationOffset.W, part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z); - axiomPartRotation = oldGroupRotation * axiomPartRotation; - axiomPartRotation = axiomRootRotation.Inverse() * axiomPartRotation; + axiomPartRotation = oldGroupRotation*axiomPartRotation; + axiomPartRotation = axiomRootRotation.Inverse()*axiomPartRotation; part.RotationOffset = new LLQuaternion(axiomPartRotation.x, axiomPartRotation.y, axiomPartRotation.z, axiomPartRotation.w); } @@ -1056,12 +1049,12 @@ namespace OpenSim.Region.Environment.Scenes proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0].ItemID = LLUUID.Zero; - proper.ObjectData[0].CreationDate = (ulong)m_rootPart.CreationDate; + proper.ObjectData[0].CreationDate = (ulong) m_rootPart.CreationDate; proper.ObjectData[0].CreatorID = m_rootPart.CreatorID; proper.ObjectData[0].FolderID = LLUUID.Zero; proper.ObjectData[0].FromTaskID = LLUUID.Zero; proper.ObjectData[0].GroupID = LLUUID.Zero; - proper.ObjectData[0].InventorySerial = (short)m_rootPart.InventorySerial; + proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; proper.ObjectData[0].ObjectID = UUID; proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; @@ -1155,7 +1148,7 @@ namespace OpenSim.Region.Environment.Scenes else { MainLog.Instance.Warn( - "SCENE", + "SCENE", "Couldn't find part {0} in object group {1} ({2}) to retreive prim inventory", localID, LocalId, UUID); } @@ -1272,10 +1265,8 @@ namespace OpenSim.Region.Environment.Scenes public void UpdatePermissions(LLUUID AgentID, byte field, uint localID, uint mask, byte addRemTF) { SceneObjectPart updatePart = GetChildPart(localID); - updatePart.UpdatePermissions(AgentID,field,localID,mask,addRemTF); + updatePart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); } - - #endregion @@ -1304,9 +1295,8 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); - bool UsePhysics = ((m_rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - } } @@ -1350,11 +1340,10 @@ namespace OpenSim.Region.Environment.Scenes if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) { AbsolutePosition = pos; - } //we need to do a terse update even if the move wasn't allowed // so that the position is reset in the client (the object snaps back) - ScheduleGroupForTerseUpdate(); + ScheduleGroupForTerseUpdate(); } /// @@ -1394,7 +1383,7 @@ namespace OpenSim.Region.Environment.Scenes Quaternion partRotation = new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X, m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z); - axDiff = partRotation.Inverse() * axDiff; + axDiff = partRotation.Inverse()*axDiff; diff.X = axDiff.x; diff.Y = axDiff.y; diff.Z = axDiff.z; @@ -1496,14 +1485,14 @@ namespace OpenSim.Region.Environment.Scenes if (prim.UUID != m_rootPart.UUID) { Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z); - axPos = oldParentRot * axPos; - axPos = axRot.Inverse() * axPos; + axPos = oldParentRot*axPos; + axPos = axRot.Inverse()*axPos; prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z); - Quaternion newRot = oldParentRot * primsRot; - newRot = axRot.Inverse() * newRot; + Quaternion newRot = oldParentRot*primsRot; + newRot = axRot.Inverse()*newRot; prim.RotationOffset = new LLQuaternion(newRot.x, newRot.y, newRot.z, newRot.w); prim.ScheduleTerseUpdate(); } @@ -1736,10 +1725,10 @@ namespace OpenSim.Region.Environment.Scenes public override void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int)(alpha * 0xff), - (int)(color.x * 0xff), - (int)(color.y * 0xff), - (int)(color.z * 0xff)); + Color = Color.FromArgb(0xff - (int) (alpha*0xff), + (int) (color.x*0xff), + (int) (color.y*0xff), + (int) (color.z*0xff)); Text = text; } @@ -1748,4 +1737,4 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.ApplyPhysics(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index f226150..90a975c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Xml; using System.Xml.Serialization; using Axiom.Math; @@ -38,23 +39,26 @@ using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Physics.Manager; -using System.Drawing; namespace OpenSim.Region.Environment.Scenes { public class SceneObjectPart : IScriptHost { - private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer; - private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner; + private const LLObject.ObjectFlags OBJFULL_MASK_GENERAL = + LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectTransfer; + + private const LLObject.ObjectFlags OBJFULL_MASK_OWNER = + LLObject.ObjectFlags.ObjectCopy | LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectOwnerModify | + LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectYouOwner; + private const uint OBJNEXT_OWNER = 2147483647; - + private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647; private string m_inventoryFileName = ""; private LLUUID m_folderID = LLUUID.Zero; - [XmlIgnore] - public PhysicsActor PhysActor = null; + [XmlIgnore] public PhysicsActor PhysActor = null; protected Dictionary TaskInventory = new Dictionary(); public LLUUID LastOwnerID; @@ -72,25 +76,20 @@ namespace OpenSim.Region.Environment.Scenes private Quaternion m_sitTargetOrientation = new Quaternion(0, 0, 0, 1); private LLUUID m_SitTargetAvatar = LLUUID.Zero; - - // Main grid has default permissions as follows // public uint OwnerMask = FULL_MASK_PERMISSIONS_OWNER; - public uint NextOwnerMask = OBJNEXT_OWNER; + public uint NextOwnerMask = OBJNEXT_OWNER; public uint GroupMask = (uint) LLObject.ObjectFlags.None; public uint EveryoneMask = (uint) LLObject.ObjectFlags.None; public uint BaseMask = FULL_MASK_PERMISSIONS_OWNER; protected byte[] m_particleSystem = new byte[0]; - [XmlIgnore] - public uint TimeStampFull = 0; - [XmlIgnore] - public uint TimeStampTerse = 0; - [XmlIgnore] - public uint TimeStampLastActivity = 0; // Will be used for AutoReturn + [XmlIgnore] public uint TimeStampFull = 0; + [XmlIgnore] public uint TimeStampTerse = 0; + [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn /// /// Only used internally to schedule client updates @@ -145,16 +144,16 @@ namespace OpenSim.Region.Environment.Scenes public uint ObjectFlags { - get { return (uint)m_flags; } - set { m_flags = (LLObject.ObjectFlags)value; } + get { return (uint) m_flags; } + set { m_flags = (LLObject.ObjectFlags) value; } } protected LLObject.MaterialType m_material = 0; public byte Material { - get { return (byte)m_material; } - set { m_material = (LLObject.MaterialType)value; } + get { return (byte) m_material; } + set { m_material = (LLObject.MaterialType) value; } } protected ulong m_regionHandle; @@ -168,7 +167,6 @@ namespace OpenSim.Region.Environment.Scenes //unkown if this will be kept, added as a way of removing the group position from the group class protected LLVector3 m_groupPosition; - public LLVector3 GroupPosition { @@ -225,7 +223,7 @@ namespace OpenSim.Region.Environment.Scenes if (PhysActor != null) { if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 - || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) + || PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0) { m_rotationOffset.X = PhysActor.Orientation.x; m_rotationOffset.Y = PhysActor.Orientation.y; @@ -281,6 +279,7 @@ namespace OpenSim.Region.Environment.Scenes } set { m_velocity = value; } } + public LLVector3 RotationalVelocity { get @@ -351,6 +350,7 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_sitTargetPosition; } } + public Quaternion SitTargetOrientation { get { return m_sitTargetOrientation; } @@ -383,6 +383,7 @@ namespace OpenSim.Region.Environment.Scenes } private int m_linkNum = 0; + public int LinkNum { get { return m_linkNum; } @@ -390,13 +391,14 @@ namespace OpenSim.Region.Environment.Scenes } private byte m_clickAction = 0; + public byte ClickAction { get { return m_clickAction; } set { m_clickAction = value; - this.ScheduleFullUpdate(); + ScheduleFullUpdate(); } } @@ -423,6 +425,7 @@ namespace OpenSim.Region.Environment.Scenes // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. protected SceneObjectGroup m_parentGroup; + public SceneObjectGroup ParentGroup { get { return m_parentGroup; } @@ -434,7 +437,6 @@ namespace OpenSim.Region.Environment.Scenes set { m_updateFlag = value; } } - #region Constructors /// @@ -469,18 +471,18 @@ namespace OpenSim.Region.Environment.Scenes m_regionHandle = regionHandle; m_parentGroup = parent; - CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; OwnerID = ownerID; CreatorID = OwnerID; LastOwnerID = LLUUID.Zero; UUID = LLUUID.Random(); - LocalID = (uint)(localID); + LocalID = (uint) (localID); Shape = shape; // Todo: Add More Object Parameter from above! OwnershipCost = 0; - ObjectSaleType = (byte)0; + ObjectSaleType = (byte) 0; SalePrice = 0; - Category = (uint)0; + Category = (uint) 0; LastOwnerID = CreatorID; // End Todo: /// GroupPosition = groupPosition; @@ -495,9 +497,9 @@ namespace OpenSim.Region.Environment.Scenes m_folderID = LLUUID.Random(); m_flags = 0; - m_flags |= LLObject.ObjectFlags.Touch | - LLObject.ObjectFlags.AllowInventoryDrop | - LLObject.ObjectFlags.CreateSelected; + m_flags |= LLObject.ObjectFlags.Touch | + LLObject.ObjectFlags.AllowInventoryDrop | + LLObject.ObjectFlags.CreateSelected; ApplySanePermissions(); @@ -520,18 +522,18 @@ namespace OpenSim.Region.Environment.Scenes { m_regionHandle = regionHandle; m_parentGroup = parent; - TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); + TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); CreationDate = creationDate; OwnerID = ownerID; CreatorID = creatorID; LastOwnerID = lastOwnerID; UUID = LLUUID.Random(); - LocalID = (uint)(localID); + LocalID = (uint) (localID); Shape = shape; OwnershipCost = 0; - ObjectSaleType = (byte)0; + ObjectSaleType = (byte) 0; SalePrice = 0; - Category = (uint)0; + Category = (uint) 0; LastOwnerID = CreatorID; OffsetPosition = position; RotationOffset = rotation; @@ -552,18 +554,18 @@ namespace OpenSim.Region.Environment.Scenes /// public static SceneObjectPart FromXml(XmlReader xmlReader) { - XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); - SceneObjectPart newobject = (SceneObjectPart)serializer.Deserialize(xmlReader); + XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); + SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); return newobject; } public void ApplyPhysics() { - bool isPhysical = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); - bool isPhantom = ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) != 0); + bool isPhysical = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); + bool isPhantom = ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) != 0); bool usePhysics = isPhysical && !isPhantom; - + if (usePhysics) { PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( @@ -576,101 +578,102 @@ namespace OpenSim.Region.Environment.Scenes RotationOffset.Y, RotationOffset.Z), usePhysics); } - DoPhysicsPropertyUpdate(usePhysics, true); + DoPhysicsPropertyUpdate(usePhysics, true); } + public void ApplyNextOwnerPermissions() { BaseMask = NextOwnerMask; OwnerMask = NextOwnerMask; } + public void ApplySanePermissions() { // These are some flags that The OwnerMask should never have - OwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; - OwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - OwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - OwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - OwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - OwnerMask &= ~(uint)LLObject.ObjectFlags.Money; - OwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - OwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - OwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - - + OwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Physics; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Touch; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary; + OwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + OwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + OwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + OwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + OwnerMask &= ~(uint) LLObject.ObjectFlags.Money; + OwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + OwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + OwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + + // These are some flags that the next owner mask should never have - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Physics; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Phantom; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Scripted; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Touch; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Temporary; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.Money; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - NextOwnerMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Physics; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Phantom; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Scripted; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Touch; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Temporary; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.Money; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + NextOwnerMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + // These are some flags that the GroupMask should never have - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - GroupMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - GroupMask &= ~(uint)LLObject.ObjectFlags.Physics; - GroupMask &= ~(uint)LLObject.ObjectFlags.Phantom; - GroupMask &= ~(uint)LLObject.ObjectFlags.Scripted; - GroupMask &= ~(uint)LLObject.ObjectFlags.Touch; - GroupMask &= ~(uint)LLObject.ObjectFlags.Temporary; - GroupMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - GroupMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - GroupMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - GroupMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - GroupMask &= ~(uint)LLObject.ObjectFlags.Money; - GroupMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - GroupMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - GroupMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + GroupMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + GroupMask &= ~(uint) LLObject.ObjectFlags.Physics; + GroupMask &= ~(uint) LLObject.ObjectFlags.Phantom; + GroupMask &= ~(uint) LLObject.ObjectFlags.Scripted; + GroupMask &= ~(uint) LLObject.ObjectFlags.Touch; + GroupMask &= ~(uint) LLObject.ObjectFlags.Temporary; + GroupMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + GroupMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + GroupMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + GroupMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + GroupMask &= ~(uint) LLObject.ObjectFlags.Money; + GroupMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + GroupMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + GroupMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; + // These are some flags that EveryoneMask should never have - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectGroupOwned; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Physics; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Phantom; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Scripted; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Touch; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Temporary; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.TemporaryOnRez; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.ZlibCompressed; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.AnimSource; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.Money; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.CastShadows; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.InventoryEmpty; - EveryoneMask &= ~(uint)LLObject.ObjectFlags.CreateSelected; - + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ObjectGroupOwned; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Physics; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Phantom; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Scripted; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Touch; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Temporary; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.TemporaryOnRez; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.ZlibCompressed; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.AllowInventoryDrop; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.AnimSource; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.Money; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.CastShadows; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.InventoryEmpty; + EveryoneMask &= ~(uint) LLObject.ObjectFlags.CreateSelected; - // These are some flags that ObjectFlags (m_flags) should never have - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectOwnerModify; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify; - ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove; + // These are some flags that ObjectFlags (m_flags) should never have + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOwner; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectTransfer; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectOwnerModify; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectYouOfficer; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectCopy; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectModify; + ObjectFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove; } /// @@ -679,13 +682,12 @@ namespace OpenSim.Region.Environment.Scenes /// public void ToXml(XmlWriter xmlWriter) { - XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart)); + XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); serializer.Serialize(xmlWriter, this); } public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot) { - // In this case we're using a sphere with a radius of the largest dimention of the prim // TODO: Change to take shape into account @@ -693,35 +695,34 @@ namespace OpenSim.Region.Environment.Scenes EntityIntersection returnresult = new EntityIntersection(); Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); Vector3 vScale = new Vector3(Scale.X, Scale.Y, Scale.Z); - Quaternion qRotation = new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); - + Quaternion qRotation = + new Quaternion(RotationOffset.W, RotationOffset.X, RotationOffset.Y, RotationOffset.Z); - Quaternion worldRotation = (qRotation * parentrot); + Quaternion worldRotation = (qRotation*parentrot); Matrix3 worldRotM = worldRotation.ToRotationMatrix(); - Vector3 rOrigin = iray.Origin; Vector3 rDirection = iray.Direction; // Buidling the first part of the Quadratic equation - Vector3 r2ndDirection = rDirection * rDirection; + Vector3 r2ndDirection = rDirection*rDirection; float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; // Buidling the second part of the Quadratic equation Vector3 tmVal2 = rOrigin - vAbsolutePosition; - Vector3 r2Direction = rDirection * 2.0f; - Vector3 tmVal3 = r2Direction * tmVal2; + Vector3 r2Direction = rDirection*2.0f; + Vector3 tmVal3 = r2Direction*tmVal2; float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z; // Buidling the third part of the Quadratic equation - Vector3 tmVal4 = rOrigin * rOrigin; - Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition; + Vector3 tmVal4 = rOrigin*rOrigin; + Vector3 tmVal5 = vAbsolutePosition*vAbsolutePosition; - Vector3 tmVal6 = vAbsolutePosition * rOrigin; + Vector3 tmVal6 = vAbsolutePosition*rOrigin; // Set Radius to the largest dimention of the prim @@ -735,21 +736,22 @@ namespace OpenSim.Region.Environment.Scenes //radius = radius; - float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - (2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius))); + float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - + (2.0f*(tmVal6.x + tmVal6.y + tmVal6.z + (radius*radius))); // Yuk Quadradrics.. Solve first - float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3); + float rootsqr = (itestPart2*itestPart2) - (4.0f*itestPart1*itestPart3); if (rootsqr < 0.0f) { // No intersection return returnresult; } - float root = ((-itestPart2) - (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); + float root = ((-itestPart2) - (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); if (root < 0.0f) { // perform second quadratic root solution - root = ((-itestPart2) + (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); + root = ((-itestPart2) + (float) Math.Sqrt((double) rootsqr))/(itestPart1*2.0f); // is there any intersection? if (root < 0.0f) @@ -761,7 +763,9 @@ namespace OpenSim.Region.Environment.Scenes // We got an intersection. putting together an EntityIntersection object with the // intersection information - Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root), iray.Origin.y + (iray.Direction.y * root), iray.Origin.z + (iray.Direction.z * root)); + Vector3 ipoint = + new Vector3(iray.Origin.x + (iray.Direction.x*root), iray.Origin.y + (iray.Direction.y*root), + iray.Origin.z + (iray.Direction.z*root)); returnresult.HitTF = true; returnresult.ipoint = ipoint; @@ -775,7 +779,7 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x, iray.Origin.y, iray.Origin.z); LLVector3 distanceConvert2 = new LLVector3(ipoint.x, ipoint.y, ipoint.z); - float distance = (float)Util.GetDistanceTo(distanceConvert1, distanceConvert2); + float distance = (float) Util.GetDistanceTo(distanceConvert1, distanceConvert2); returnresult.distance = distance; @@ -783,7 +787,6 @@ namespace OpenSim.Region.Environment.Scenes } - /// /// /// @@ -797,6 +800,7 @@ namespace OpenSim.Region.Environment.Scenes m_sitTargetPosition = offset; m_sitTargetOrientation = orientation; } + public LLVector3 GetSitTargetPositionLL() { return new LLVector3(m_sitTargetPosition.x, m_sitTargetPosition.y, m_sitTargetPosition.z); @@ -804,13 +808,17 @@ namespace OpenSim.Region.Environment.Scenes public LLQuaternion GetSitTargetOrientationLL() { - return new LLQuaternion( m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z,m_sitTargetOrientation.w); + return + new LLQuaternion(m_sitTargetOrientation.x, m_sitTargetOrientation.y, m_sitTargetOrientation.z, + m_sitTargetOrientation.w); } // Utility function so the databases don't have to reference axiom.math public void SetSitTargetLL(LLVector3 offset, LLQuaternion orientation) { - if (!(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) && orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0)) + if ( + !(offset.X == 0 && offset.Y == 0 && offset.Z == 0 && (orientation.W == 0 || orientation.W == 1) && + orientation.X == 0 && orientation.Y == 0 && orientation.Z == 0)) { m_sitTargetPosition = new Vector3(offset.X, offset.Y, offset.Z); m_sitTargetOrientation = new Quaternion(orientation.W, orientation.X, orientation.Y, orientation.Z); @@ -869,7 +877,7 @@ namespace OpenSim.Region.Environment.Scenes /// public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID) { - SceneObjectPart dupe = (SceneObjectPart)MemberwiseClone(); + SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone(); dupe.m_shape = m_shape.Copy(); dupe.m_regionHandle = m_regionHandle; dupe.UUID = LLUUID.Random(); @@ -896,7 +904,7 @@ namespace OpenSim.Region.Environment.Scenes byte[] extraP = new byte[Shape.ExtraParams.Length]; Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; - bool UsePhysics = ((dupe.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool UsePhysics = ((dupe.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); dupe.DoPhysicsPropertyUpdate(UsePhysics, true); return dupe; @@ -923,7 +931,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - TimeStampFull = (uint)Util.UnixTimeSinceEpoch(); + TimeStampFull = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 2; } @@ -931,11 +939,10 @@ namespace OpenSim.Region.Environment.Scenes { LLObject.ObjectFlags prevflag = m_flags; //uint objflags = m_flags; - if ((ObjectFlags & (uint)flag) == 0) + if ((ObjectFlags & (uint) flag) == 0) { //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); m_flags |= flag; - } //uint currflag = (uint)m_flags; //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); @@ -945,11 +952,10 @@ namespace OpenSim.Region.Environment.Scenes public void RemFlag(LLObject.ObjectFlags flag) { LLObject.ObjectFlags prevflag = m_flags; - if ((ObjectFlags & (uint)flag) != 0) + if ((ObjectFlags & (uint) flag) != 0) { //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); m_flags &= ~flag; - } //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); //ScheduleFullUpdate(); @@ -966,7 +972,7 @@ namespace OpenSim.Region.Environment.Scenes { m_parentGroup.HasChanged = true; } - TimeStampTerse = (uint)Util.UnixTimeSinceEpoch(); + TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 1; } } @@ -1074,7 +1080,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_inventorySerial > 0) { - client.SendTaskInventory(m_uuid, (short)m_inventorySerial, + client.SendTaskInventory(m_uuid, (short) m_inventorySerial, Helpers.StringToField(m_inventoryFileName)); return true; } @@ -1134,7 +1140,7 @@ namespace OpenSim.Region.Environment.Scenes bool IsTemporary = false; bool IsPhantom = false; bool castsShadows = false; - bool wasUsingPhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + bool wasUsingPhysics = ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); //bool IsLocked = false; int i = 0; @@ -1162,7 +1168,6 @@ namespace OpenSim.Region.Environment.Scenes { DoPhysicsPropertyUpdate(usePhysics, false); } - } else { @@ -1174,9 +1179,6 @@ namespace OpenSim.Region.Environment.Scenes } - - - if (IsPhantom) { AddFlag(LLObject.ObjectFlags.Phantom); @@ -1220,19 +1222,18 @@ namespace OpenSim.Region.Environment.Scenes // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); ScheduleFullUpdate(); } + public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) { - if (PhysActor != null) { if (UsePhysics != PhysActor.IsPhysical || isNew) { - if (PhysActor.IsPhysical) { if (!isNew) - this.ParentGroup.m_scene.RemovePhysicalPrim(1); - + ParentGroup.m_scene.RemovePhysicalPrim(1); + PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; } @@ -1244,7 +1245,7 @@ namespace OpenSim.Region.Environment.Scenes //PhysActor = null; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { //PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape( //Name, @@ -1256,8 +1257,8 @@ namespace OpenSim.Region.Environment.Scenes //RotationOffset.Y, RotationOffset.Z), UsePhysics); if (UsePhysics) { - this.ParentGroup.m_scene.AddPhysicalPrim(1); - + ParentGroup.m_scene.AddPhysicalPrim(1); + PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; PhysActor.OnOutOfBounds += PhysicsOutOfBounds; } @@ -1271,15 +1272,15 @@ namespace OpenSim.Region.Environment.Scenes { m_shape.ExtraParams = new byte[data.Length + 7]; int i = 0; - uint length = (uint)data.Length; + uint length = (uint) data.Length; m_shape.ExtraParams[i++] = 1; - m_shape.ExtraParams[i++] = (byte)(type % 256); - m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); + m_shape.ExtraParams[i++] = (byte) (type%256); + m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256); - m_shape.ExtraParams[i++] = (byte)(length % 256); - m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); - m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); - m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); + m_shape.ExtraParams[i++] = (byte) (length%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 8)%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 16)%256); + m_shape.ExtraParams[i++] = (byte) ((length >> 24)%256); Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length); ScheduleFullUpdate(); @@ -1305,7 +1306,7 @@ namespace OpenSim.Region.Environment.Scenes { if (PhysActor != null) { - return new LLVector3(PhysActor.CenterOfMass.X,PhysActor.CenterOfMass.Y,PhysActor.CenterOfMass.Z); + return new LLVector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); } else { @@ -1323,7 +1324,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdateTextureEntry(byte[] textureEntry) { - m_shape.Textures = new LLObject.TextureEntry( textureEntry, 0, textureEntry.Length ); + m_shape.Textures = new LLObject.TextureEntry(textureEntry, 0, textureEntry.Length); ScheduleFullUpdate(); } @@ -1337,20 +1338,20 @@ namespace OpenSim.Region.Environment.Scenes { if (tex.FaceTextures[i] != null) { - tmpcolor = tex.GetFace((uint)i).RGBA; - tmpcolor.A = tmpcolor.A * 255; - tmpcolor.R = tmpcolor.R * 255; - tmpcolor.G = tmpcolor.G * 255; - tmpcolor.B = tmpcolor.B * 255; + tmpcolor = tex.GetFace((uint) i).RGBA; + tmpcolor.A = tmpcolor.A*255; + tmpcolor.R = tmpcolor.R*255; + tmpcolor.G = tmpcolor.G*255; + tmpcolor.B = tmpcolor.B*255; tex.FaceTextures[i].RGBA = tmpcolor; } } tmpcolor = tex.DefaultTexture.RGBA; - tmpcolor.A = tmpcolor.A * 255; - tmpcolor.R = tmpcolor.R * 255; - tmpcolor.G = tmpcolor.G * 255; - tmpcolor.B = tmpcolor.B * 255; - tex.DefaultTexture.RGBA = tmpcolor; + tmpcolor.A = tmpcolor.A*255; + tmpcolor.R = tmpcolor.R*255; + tmpcolor.G = tmpcolor.G*255; + tmpcolor.B = tmpcolor.B*255; + tex.DefaultTexture.RGBA = tmpcolor; UpdateTextureEntry(tex.ToBytes()); } @@ -1416,34 +1417,33 @@ namespace OpenSim.Region.Environment.Scenes // Are we the owner? if (AgentID == OwnerID) { - MainLog.Instance.Verbose("PERMISSIONS", "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + addRemTF.ToString()); - + MainLog.Instance.Verbose("PERMISSIONS", + "field: " + field.ToString() + ", mask: " + mask.ToString() + " addRemTF: " + + addRemTF.ToString()); + //Field 8 = EveryoneMask - if (field == (byte)8) + if (field == (byte) 8) { MainLog.Instance.Verbose("PERMISSIONS", "Left over: " + (OwnerMask - EveryoneMask)); - if (addRemTF == (byte)0) + if (addRemTF == (byte) 0) { //EveryoneMask = (uint)0; EveryoneMask &= ~mask; //EveryoneMask &= ~(uint)57344; - - } else { //EveryoneMask = (uint)0; EveryoneMask |= mask; //EveryoneMask |= (uint)57344; - } //ScheduleFullUpdate(); SendFullUpdateToAllClients(); } //Field 16 = NextownerMask - if (field == (byte)16) + if (field == (byte) 16) { - if (addRemTF == (byte)0) + if (addRemTF == (byte) 0) { NextOwnerMask &= ~mask; } @@ -1453,7 +1453,6 @@ namespace OpenSim.Region.Environment.Scenes } SendFullUpdateToAllClients(); } - } } @@ -1482,7 +1481,8 @@ namespace OpenSim.Region.Environment.Scenes for (int i = 0; i < avatars.Count; i++) { // Ugly reference :( - m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, avatars[i].GenerateClientFlags(this.UUID)); + m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, + avatars[i].GenerateClientFlags(UUID)); } } @@ -1515,19 +1515,19 @@ namespace OpenSim.Region.Environment.Scenes { LLQuaternion lRot; lRot = RotationOffset; - clientFlags &= ~(uint)LLObject.ObjectFlags.CreateSelected; + clientFlags &= ~(uint) LLObject.ObjectFlags.CreateSelected; - if (remoteClient.AgentId == OwnerID) + if (remoteClient.AgentId == OwnerID) { - if ((uint)(m_flags & LLObject.ObjectFlags.CreateSelected) != 0) + if ((uint) (m_flags & LLObject.ObjectFlags.CreateSelected) != 0) { - clientFlags |= (uint)LLObject.ObjectFlags.CreateSelected; + clientFlags |= (uint) LLObject.ObjectFlags.CreateSelected; m_flags &= ~LLObject.ObjectFlags.CreateSelected; } } - byte[] color = new byte[] { m_color.R, m_color.G, m_color.B, m_color.A }; + byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, clientFlags, m_uuid, OwnerID, m_text, color, ParentID, m_particleSystem, lRot, m_clickAction); @@ -1574,26 +1574,28 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 lPos; lPos = OffsetPosition; LLQuaternion mRot = RotationOffset; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, + RotationalVelocity); } } public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) { LLQuaternion mRot = RotationOffset; - if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, + RotationalVelocity); //System.Console.WriteLine("RVel:" + RotationalVelocity); } } @@ -1603,13 +1605,16 @@ namespace OpenSim.Region.Environment.Scenes public virtual void UpdateMovement() { } + #region Events + public void PhysicsRequestingTerseUpdate() { ScheduleTerseUpdate(); //SendTerseUpdateToAllClients(); } + #endregion public void PhysicsOutOfBounds(PhysicsVector pos) @@ -1626,10 +1631,10 @@ namespace OpenSim.Region.Environment.Scenes public void SetText(string text, Vector3 color, double alpha) { - Color = Color.FromArgb(0xff - (int)(alpha * 0xff), - (int)(color.x * 0xff), - (int)(color.y * 0xff), - (int)(color.z * 0xff)); + Color = Color.FromArgb(0xff - (int) (alpha*0xff), + (int) (color.x*0xff), + (int) (color.y*0xff), + (int) (color.z*0xff)); Text = text; } @@ -1725,7 +1730,6 @@ namespace OpenSim.Region.Environment.Scenes public TaskInventoryItem() { } - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 9a937a2..9454de0 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -32,7 +32,6 @@ using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Framework.Communications; using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; @@ -60,14 +59,14 @@ namespace OpenSim.Region.Environment.Scenes private bool m_setAlwaysRun = false; private Quaternion m_bodyRot; - + public bool IsRestrictedToRegion = false; // Agent moves with a PID controller causing a force to be exerted. private bool m_newForce = false; private bool m_newCoarseLocations = true; private bool m_gotAllObjectsInScene = false; - + // Default AV Height private float m_avHeight = 127.0f; @@ -76,7 +75,7 @@ namespace OpenSim.Region.Environment.Scenes private readonly Vector3[] Dir_Vectors = new Vector3[6]; private LLVector3 lastPhysPos = new LLVector3(); - + // Position of agent's camera in world (region cordinates) protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); @@ -85,17 +84,18 @@ namespace OpenSim.Region.Environment.Scenes protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0); protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0); protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0); - private uint m_AgentControlFlags = (uint)0; + private uint m_AgentControlFlags = (uint) 0; private LLQuaternion m_headrotation = new LLQuaternion(); - private byte m_state = (byte)0; + private byte m_state = (byte) 0; // Agent's Draw distance. protected float m_DrawDistance = 0f; protected AvatarAppearance m_appearance; - private readonly List m_knownChildRegions = new List(); //neighbouring regions we have enabled a child agent in - + private readonly List m_knownChildRegions = new List(); + //neighbouring regions we have enabled a child agent in + /// /// Implemented Control Flags @@ -172,6 +172,7 @@ namespace OpenSim.Region.Environment.Scenes } protected bool m_allowMovement = true; + public bool AllowMovement { get { return m_allowMovement; } @@ -181,8 +182,8 @@ namespace OpenSim.Region.Environment.Scenes /// /// This works out to be the ClientView object associated with this avatar, or it's UDP connection manager /// - private readonly IClientAPI m_controllingClient; + protected PhysicsActor m_physicsActor; public IClientAPI ControllingClient @@ -228,6 +229,7 @@ namespace OpenSim.Region.Environment.Scenes m_pos = value; } } + /// /// Current Velocity of the avatar. /// @@ -294,6 +296,7 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_knownChildRegions; } } + #endregion #region Constructor(s) @@ -336,7 +339,7 @@ namespace OpenSim.Region.Environment.Scenes public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) : this(client, world, reginfo) { - m_appearance = appearance; + m_appearance = appearance; } private void RegisterToEvents() @@ -366,6 +369,7 @@ namespace OpenSim.Region.Environment.Scenes Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge } + #endregion public void QueuePartForUpdate(SceneObjectPart part) @@ -381,7 +385,7 @@ namespace OpenSim.Region.Environment.Scenes public uint GenerateClientFlags(LLUUID ObjectID) { - return m_scene.PermissionsMngr.GenerateClientFlags(this.m_uuid, ObjectID); + return m_scene.PermissionsMngr.GenerateClientFlags(m_uuid, ObjectID); } public void SendPrimUpdates() @@ -461,6 +465,7 @@ namespace OpenSim.Region.Environment.Scenes } #region Status Methods + /// /// This turns a child agent, into a root agent /// This is called when an agent teleports into a region, or if an @@ -531,6 +536,7 @@ namespace OpenSim.Region.Environment.Scenes public void StopMovement() { } + public void StopFlying() { // It turns out to get the agent to stop flying, you have to feed it stop flying velocities @@ -560,9 +566,11 @@ namespace OpenSim.Region.Environment.Scenes m_knownChildRegions.Remove(regionHandle); } } + #endregion #region Event Handlers + /// /// Sets avatar height in the phyiscs plugin /// @@ -603,7 +611,6 @@ namespace OpenSim.Region.Environment.Scenes /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdatePacket agentData) { - //if (m_isChildAgent) //{ // // Console.WriteLine("DEBUG: HandleAgentUpdate: child agent"); @@ -639,7 +646,7 @@ namespace OpenSim.Region.Environment.Scenes // The Agent's Draw distance setting m_DrawDistance = agentData.AgentData.Far; - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); } @@ -649,7 +656,7 @@ namespace OpenSim.Region.Environment.Scenes return; } - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) + if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { // TODO: This doesn't quite work yet -- probably a parent ID problem // m_parentID = (what should this be?) @@ -672,7 +679,7 @@ namespace OpenSim.Region.Environment.Scenes Quaternion q = new Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); bool oldflying = PhysicsActor.Flying; - PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + PhysicsActor.Flying = ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); if (PhysicsActor.Flying != oldflying) { update_movementflag = true; @@ -686,23 +693,23 @@ namespace OpenSim.Region.Environment.Scenes if (m_parentID == 0) { - foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) + foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof (Dir_ControlFlags))) { - if ((flags & (uint)DCF) != 0) + if ((flags & (uint) DCF) != 0) { DCFlagKeyPressed = true; agent_control_v3 += Dir_Vectors[i]; - if ((m_movementflag & (uint)DCF) == 0) + if ((m_movementflag & (uint) DCF) == 0) { - m_movementflag += (byte)(uint)DCF; + m_movementflag += (byte) (uint) DCF; update_movementflag = true; } } else { - if ((m_movementflag & (uint)DCF) != 0) + if ((m_movementflag & (uint) DCF) != 0) { - m_movementflag -= (byte)(uint)DCF; + m_movementflag -= (byte) (uint) DCF; update_movementflag = true; } } @@ -719,8 +726,9 @@ namespace OpenSim.Region.Environment.Scenes if (m_physicsActor.Flying) { // Are the landing controls requirements filled? - bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - + bool controlland = (((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || + ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + // Are the collision requirements fulfilled? bool colliding = (m_physicsActor.IsColliding == true); @@ -748,7 +756,6 @@ namespace OpenSim.Region.Environment.Scenes { if (m_parentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); if (part != null) { @@ -757,7 +764,7 @@ namespace OpenSim.Region.Environment.Scenes part.SetAvatarOnSitTarget(LLUUID.Zero); } - m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + m_pos += m_parentPosition + new LLVector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); m_parentPosition = new LLVector3(); if (m_physicsActor == null) @@ -778,14 +785,14 @@ namespace OpenSim.Region.Environment.Scenes bool autopilot = true; LLVector3 pos = new LLVector3(); - LLQuaternion sitOrientation = new LLQuaternion(0,0,0,1); + LLQuaternion sitOrientation = new LLQuaternion(0, 0, 0, 1); SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); if (part != null) { // TODO: determine position to sit at based on scene geometry; don't trust offset from client // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it - + // Is a sit target available? Vector3 avSitOffSet = part.GetSitTargetPosition(); @@ -793,15 +800,17 @@ namespace OpenSim.Region.Environment.Scenes LLUUID avOnTargetAlready = part.GetAvatarOnSitTarget(); bool SitTargetUnOccupied = (!(avOnTargetAlready != LLUUID.Zero)); - bool SitTargetisSet = (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1)); + bool SitTargetisSet = + (!(avSitOffSet.x == 0 && avSitOffSet.y == 0 && avSitOffSet.z == 0 && avSitOrientation.w == 0 && + avSitOrientation.x == 0 && avSitOrientation.y == 0 && avSitOrientation.z == 1)); if (SitTargetisSet && SitTargetUnOccupied) { part.SetAvatarOnSitTarget(UUID); - offset = new LLVector3(avSitOffSet.x,avSitOffSet.y,avSitOffSet.z); - sitOrientation = new LLQuaternion(avSitOrientation.w,avSitOrientation.x,avSitOrientation.y,avSitOrientation.z); + offset = new LLVector3(avSitOffSet.x, avSitOffSet.y, avSitOffSet.z); + sitOrientation = + new LLQuaternion(avSitOrientation.w, avSitOrientation.x, avSitOrientation.y, avSitOrientation.z); autopilot = false; - } @@ -817,43 +826,37 @@ namespace OpenSim.Region.Environment.Scenes if (autopilot) { - if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) { autopilot = false; - + RemoveFromPhysicalScene(); AbsolutePosition = pos + new LLVector3(0.0f, 0.0f, m_sitAvatarHeight); - } - else + else { - } } else { RemoveFromPhysicalScene(); - - } } // Physactor != null } // part != null - + avatarSitResponse.SitTransform.AutoPilot = autopilot; avatarSitResponse.SitTransform.SitPosition = offset; avatarSitResponse.SitTransform.SitRotation = sitOrientation; remoteClient.OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); - + // This calls HandleAgentSit twice, once from here, and the client calls // HandleAgentSit itself after it gets to the location // It doesn't get to the location until we've moved them there though // which happens in HandleAgentSit :P if (!autopilot) HandleAgentSit(remoteClient, UUID); - } public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset) @@ -863,7 +866,6 @@ namespace OpenSim.Region.Environment.Scenes StandUp(); } - SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); @@ -919,7 +921,6 @@ namespace OpenSim.Region.Environment.Scenes // This may seem stupid, but Our Full updates don't send avatar rotation :P // So we're also sending a terse update (which has avatar rotation) SendTerseUpdateToAllClients(); - } /// @@ -1003,7 +1004,7 @@ namespace OpenSim.Region.Environment.Scenes // We are flying SetMovementAnimation(Animations.AnimsLLUUID["FLY"], 1); } - else if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && + else if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) { // Client is pressing the page down button and moving and is colliding with something @@ -1014,7 +1015,8 @@ namespace OpenSim.Region.Environment.Scenes // Client is moving and falling at a velocity greater then 6 meters per unit SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && + (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { // Client is moving, and colliding and pressing the page up button but isn't flying SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); @@ -1034,7 +1036,7 @@ namespace OpenSim.Region.Environment.Scenes { // Not moving - if (((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && + if (((m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && PhysicsActor.IsColliding) { // Client pressing the page down button @@ -1045,7 +1047,8 @@ namespace OpenSim.Region.Environment.Scenes // Not colliding and not flying, and we're falling at high speed SetMovementAnimation(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && + (m_movementflag & (uint) AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { // This is the standing jump SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); @@ -1063,6 +1066,7 @@ namespace OpenSim.Region.Environment.Scenes } } } + /// /// Adds a new movement /// @@ -1075,10 +1079,10 @@ namespace OpenSim.Region.Environment.Scenes } m_rotation = rotation; NewForce newVelocity = new NewForce(); - Vector3 direc = rotation * vec; + Vector3 direc = rotation*vec; direc.Normalize(); - direc *= 0.03f * 128f; + direc *= 0.03f*128f; if (m_physicsActor.Flying) { direc *= 4; @@ -1108,7 +1112,6 @@ namespace OpenSim.Region.Environment.Scenes SetMovementAnimation(Animations.AnimsLLUUID["JUMP"], 1); } } - } newVelocity.X = direc.x; @@ -1173,7 +1176,7 @@ namespace OpenSim.Region.Environment.Scenes { LLVector3 pos = m_pos; LLVector3 vel = Velocity; - LLQuaternion rot=new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); + LLQuaternion rot = new LLQuaternion(m_bodyRot.x, m_bodyRot.y, m_bodyRot.z, m_bodyRot.w); remoteClient.SendAvatarTerseUpdate(m_regionHandle, 64096, LocalId, new LLVector3(pos.X, pos.Y, pos.Z), new LLVector3(vel.X, vel.Y, vel.Z), rot); } @@ -1213,7 +1216,8 @@ namespace OpenSim.Region.Environment.Scenes public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) { remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, - LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), m_parentID); + LocalId, m_pos, m_appearance.TextureEntry.ToBytes(), + m_parentID); } /// @@ -1303,10 +1307,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAnimPack(LLUUID[] animations, int[] seqs) { - m_scene.Broadcast(delegate(IClientAPI client) - { - client.SendAnimations(animations, seqs, m_controllingClient.AgentId); - }); + m_scene.Broadcast( + delegate(IClientAPI client) { client.SendAnimations(animations, seqs, m_controllingClient.AgentId); }); } /// @@ -1320,6 +1322,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region Significant Movement Method + /// /// This checks for a significant movement and sends a courselocationchange update /// @@ -1349,9 +1352,9 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 vel = Velocity; float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); + pos2.X = pos2.X + (vel.X*timeStep); + pos2.Y = pos2.Y + (vel.Y*timeStep); + pos2.Z = pos2.Z + (vel.Z*timeStep); if ((pos2.X < 0) || (pos2.X > 256)) { @@ -1411,7 +1414,7 @@ namespace OpenSim.Region.Environment.Scenes } LLVector3 vel = m_velocity; - ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * 256), (uint)(neighboury * 256)); + ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256)); SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); if (neighbourRegion != null) { @@ -1432,6 +1435,7 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + /// /// This allows the Sim owner the abiility to kick users from their sim currently. /// It tells the client that the agent has permission to do so. @@ -1445,7 +1449,7 @@ namespace OpenSim.Region.Environment.Scenes adb.AgentID = agentID; adb.SessionID = sessionID; // More security - gdb.GodLevel = (byte)100; + gdb.GodLevel = (byte) 100; gdb.Token = token; //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; respondPacket.GrantData = gdb; @@ -1462,7 +1466,8 @@ namespace OpenSim.Region.Environment.Scenes // m_DrawDistance = cAgentData.drawdistance; m_pos = new LLVector3(cAgentData.Position.x, cAgentData.Position.y, cAgentData.Position.z); - m_CameraCenter = new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); + m_CameraCenter = + new Vector3(cAgentData.cameraPosition.x, cAgentData.cameraPosition.y, cAgentData.cameraPosition.z); m_godlevel = cAgentData.godlevel; ControllingClient.SetChildAgentThrottle(cAgentData.throttles); //cAgentData.AVHeight; @@ -1555,6 +1560,7 @@ namespace OpenSim.Region.Environment.Scenes m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; } + // Event called by the physics plugin to tell the avatar about a collision. private void PhysicsCollisionUpdate(EventArgs e) { @@ -1567,4 +1573,4 @@ namespace OpenSim.Region.Environment.Scenes RemoveFromPhysicalScene(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index aeb9c61..8c4a951 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs @@ -28,17 +28,16 @@ using System; using System.Collections.Generic; -using System.Text; -using System.Xml; using System.IO; -using libsecondlife; +using System.Xml; using Axiom.Math; +using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { - public class SceneXmlLoader // can move to a module? + public class SceneXmlLoader // can move to a module? { protected InnerScene m_innerScene; protected RegionInfo m_regInfo; @@ -78,8 +77,9 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); // Apply loadOffsets for load/import and move combinations rootPart.GroupPosition = rootPart.AbsolutePosition + loadOffset; - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && + m_parentScene.m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( rootPart.Name, @@ -91,7 +91,6 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - } primCount++; } @@ -115,7 +114,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString()); primCount++; } } @@ -152,8 +151,9 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.AddEntityFromStorage(obj); SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); - bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_parentScene.m_physicalPrim); - if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && + m_parentScene.m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) { rootPart.PhysActor = m_innerScene.PhysicsScene.AddPrimShape( rootPart.Name, @@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - stream.WriteLine(((SceneObjectGroup)ent).ToXmlString2()); + stream.WriteLine(((SceneObjectGroup) ent).ToXmlString2()); primCount++; } } @@ -188,6 +188,5 @@ namespace OpenSim.Region.Environment.Scenes stream.Close(); file.Close(); } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs index 294a6c9..d781806 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineInterface.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting void Shutdown(); // void StartScript(string ScriptID, IScriptHost ObjectID); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs index d3fdad6..5dbe500 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptEngineLoader.cs @@ -121,4 +121,4 @@ namespace OpenSim.Region.Environment.Scenes.Scripting return ret; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index bfdacfe..b183c04 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -27,22 +27,19 @@ */ using System; -using System.Collections.Generic; -using System.Text; using System.Timers; using libsecondlife.Packets; using OpenSim.Framework; -using Timer = System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { public class SimStatsReporter { public delegate void SendStatResult(SimStatsPacket pack); - + public event SendStatResult OnSendStatsResult; - private enum Stats : uint + private enum Stats : uint { TimeDilation = 0, SimFPS = 1, @@ -72,7 +69,7 @@ namespace OpenSim.Region.Environment.Scenes private RegionInfo ReportingRegion; private Timer m_report = new Timer(); - + public SimStatsReporter(RegionInfo regionData) { @@ -93,23 +90,24 @@ namespace OpenSim.Region.Environment.Scenes statpack.Region.RegionY = ReportingRegion.RegionLocY; try { - statpack.Region.RegionFlags = (uint)ReportingRegion.EstateSettings.regionFlags; + statpack.Region.RegionFlags = (uint) ReportingRegion.EstateSettings.regionFlags; } - catch(System.Exception) + catch (Exception) { - statpack.Region.RegionFlags = (uint)0; + statpack.Region.RegionFlags = (uint) 0; } - statpack.Region.ObjectCapacity = (uint)15000; + statpack.Region.ObjectCapacity = (uint) 15000; #region various statistic googly moogly - float simfps = (int)(m_fps * 5); + + float simfps = (int) (m_fps*5); if (simfps > 45) simfps = simfps - (simfps - 45); if (simfps < 0) simfps = 0; - float physfps = (m_pfps / statsUpdatesEveryMS); + float physfps = (m_pfps/statsUpdatesEveryMS); if (physfps > 50) physfps = physfps - (physfps - 50); @@ -120,49 +118,49 @@ namespace OpenSim.Region.Environment.Scenes #endregion sb[0] = new SimStatsPacket.StatBlock(); - sb[0].StatID = (uint)Stats.TimeDilation; + sb[0].StatID = (uint) Stats.TimeDilation; sb[0].StatValue = (m_timeDilation); sb[1] = new SimStatsPacket.StatBlock(); - sb[1].StatID = (uint)Stats.SimFPS; + sb[1].StatID = (uint) Stats.SimFPS; sb[1].StatValue = simfps; sb[2] = new SimStatsPacket.StatBlock(); - sb[2].StatID = (uint)Stats.PhysicsFPS; + sb[2].StatID = (uint) Stats.PhysicsFPS; sb[2].StatValue = physfps; sb[3] = new SimStatsPacket.StatBlock(); - sb[3].StatID = (uint)Stats.AgentUpdates; - sb[3].StatValue = (m_agentUpdates / statsUpdatesEveryMS); + sb[3].StatID = (uint) Stats.AgentUpdates; + sb[3].StatValue = (m_agentUpdates/statsUpdatesEveryMS); sb[4] = new SimStatsPacket.StatBlock(); - sb[4].StatID = (uint)Stats.Agents; + sb[4].StatID = (uint) Stats.Agents; sb[4].StatValue = m_rootAgents; sb[5] = new SimStatsPacket.StatBlock(); - sb[5].StatID = (uint)Stats.ChildAgents; + sb[5].StatID = (uint) Stats.ChildAgents; sb[5].StatValue = m_childAgents; sb[6] = new SimStatsPacket.StatBlock(); - sb[6].StatID = (uint)Stats.TotalPrim; + sb[6].StatID = (uint) Stats.TotalPrim; sb[6].StatValue = m_numPrim; sb[7] = new SimStatsPacket.StatBlock(); - sb[7].StatID = (uint)Stats.ActivePrim; + sb[7].StatID = (uint) Stats.ActivePrim; sb[7].StatValue = m_activePrim; sb[8] = new SimStatsPacket.StatBlock(); - sb[8].StatID = (uint)Stats.InPacketsPerSecond; - sb[8].StatValue = (int)(m_inPacketsPerSecond / statsUpdatesEveryMS); + sb[8].StatID = (uint) Stats.InPacketsPerSecond; + sb[8].StatValue = (int) (m_inPacketsPerSecond/statsUpdatesEveryMS); sb[9] = new SimStatsPacket.StatBlock(); - sb[9].StatID = (uint)Stats.OutPacketsPerSecond; - sb[9].StatValue = (int)(m_outPacketsPerSecond / statsUpdatesEveryMS); + sb[9].StatID = (uint) Stats.OutPacketsPerSecond; + sb[9].StatValue = (int) (m_outPacketsPerSecond/statsUpdatesEveryMS); sb[10] = new SimStatsPacket.StatBlock(); - sb[10].StatID = (uint)Stats.UnAckedBytes; - sb[10].StatValue = (int) (m_unAckedBytes / statsUpdatesEveryMS); - + sb[10].StatID = (uint) Stats.UnAckedBytes; + sb[10].StatValue = (int) (m_unAckedBytes/statsUpdatesEveryMS); + statpack.Stat = sb; if (OnSendStatsResult != null) @@ -181,8 +179,8 @@ namespace OpenSim.Region.Environment.Scenes m_inPacketsPerSecond = 0; m_outPacketsPerSecond = 0; m_unAckedBytes = 0; - } + public void SetTimeDilation(float td) { m_timeDilation = td; @@ -191,47 +189,56 @@ namespace OpenSim.Region.Environment.Scenes if (m_timeDilation < 0) m_timeDilation = 0.0f; - } + public void SetRootAgents(int rootAgents) { m_rootAgents = rootAgents; } + public void SetChildAgents(int childAgents) { m_childAgents = childAgents; } + public void SetObjects(int objects) { m_numPrim = objects; } + public void SetActiveObjects(int objects) { m_activePrim = objects; } + public void AddFPS(int frames) { m_fps += frames; } + public void AddPhysicsFPS(float frames) { m_pfps += frames; } + public void AddAgentUpdates(float numUpdates) { m_agentUpdates += numUpdates; } + public void AddInPackets(int numPackets) { m_inPacketsPerSecond += numPackets; } + public void AddOutPackets(int numPackets) { m_outPacketsPerSecond += numPackets; } + public void AddunAckedBytes(int numBytes) { m_unAckedBytes += numBytes; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs index b3084a2..2d8441e 100644 --- a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs @@ -26,7 +26,6 @@ * */ -using System; using System.IO; using libsecondlife; using OpenSim.Framework; diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index ec93362..3e191b4 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.Net; -using System.Text; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; @@ -62,7 +61,7 @@ namespace SimpleApp public event LinkObjects OnLinkObjects; public event DelinkObjects OnDelinkObjects; public event RequestMapBlocks OnRequestMapBlocks; - public event RequestMapName OnMapNameRequest; + public event RequestMapName OnMapNameRequest; public event TeleportLocationRequest OnTeleportLocationRequest; public event DisconnectUser OnDisconnectUser; public event RequestAvatarProperties OnRequestAvatarProperties; @@ -139,7 +138,7 @@ namespace SimpleApp public event EstateOwnerMessageRequest OnEstateOwnerMessage; public event RegionInfoRequest OnRegionInfoRequest; public event EstateCovenantRequest OnEstateCovenantRequest; - + #pragma warning restore 67 @@ -168,7 +167,7 @@ namespace SimpleApp { get { return LLUUID.Zero; } } - + public LLUUID SecureSessionId { get { return LLUUID.Zero; } @@ -185,7 +184,7 @@ namespace SimpleApp { get { return lastName; } } - + public virtual String Name { get { return FirstName + LastName; } @@ -314,7 +313,8 @@ namespace SimpleApp public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, - LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, + LLUUID objectID, LLUUID ownerID, string text, byte[] color, + uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction) { } @@ -323,14 +323,16 @@ namespace SimpleApp LLVector3 position, LLQuaternion rotation) { } + public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, - LLVector3 position, LLQuaternion rotation,LLVector3 velocity, LLVector3 rotationalvelocity) + LLVector3 position, LLQuaternion rotation, LLVector3 velocity, + LLVector3 rotationalvelocity) { } - public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, - List items, - List folders, + public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, + List items, + List folders, bool fetchFolders, bool fetchItems) { @@ -376,9 +378,11 @@ namespace SimpleApp public void SendAgentAlertMessage(string message, bool modal) { } + public void SendSystemAlertMessage(string message) { } + public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { @@ -477,7 +481,6 @@ namespace SimpleApp public void Stop() { - } private uint m_circuitCode; @@ -492,4 +495,4 @@ namespace SimpleApp { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index d5f702d..4c12b3f 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs @@ -41,10 +41,13 @@ namespace SimpleApp { private List m_avatars; - public MyWorld(RegionInfo regionInfo, AgentCircuitManager authen, PermissionManager permissionManager, CommunicationsManager commsMan, SceneCommunicationService sceneGridService, + public MyWorld(RegionInfo regionInfo, AgentCircuitManager authen, PermissionManager permissionManager, + CommunicationsManager commsMan, SceneCommunicationService sceneGridService, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer, ModuleLoader moduleLoader, bool physicalPrim, bool ChildGetTasks) - : base(regionInfo, authen, permissionManager, commsMan, sceneGridService, assetCach, storeMan, httpServer, moduleLoader, false, true, false) + : base( + regionInfo, authen, permissionManager, commsMan, sceneGridService, assetCach, storeMan, httpServer, + moduleLoader, false, true, false) { m_avatars = new List(); } @@ -73,7 +76,7 @@ namespace SimpleApp client.OnCompleteMovementToRegion += delegate() { client.SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero); }; - + client.SendRegionHandshake(m_regInfo); } } diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 02108d0..d872bf6 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -179,7 +179,8 @@ namespace SimpleApp PermissionManager permissionManager = new PermissionManager(); SceneCommunicationService sceneGridService = new SceneCommunicationService(m_commsManager); return - new MyWorld(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, m_assetCache, storageManager, m_httpServer, + new MyWorld(regionInfo, circuitManager, permissionManager, m_commsManager, sceneGridService, + m_assetCache, storageManager, m_httpServer, new ModuleLoader(m_log, m_config), true, false); } @@ -214,4 +215,4 @@ namespace SimpleApp app.Run(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs index 89c3743..b625f43 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs @@ -101,4 +101,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp return LoadDotNetScript(csharpProvider, filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs index 09b7f48..a25d027 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs @@ -91,4 +91,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples return ""; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs index 425c3a4..bc5c413 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs @@ -101,4 +101,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JScript return LoadDotNetScript(jscriptProvider, filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs index 7a2a96b..c12fda5 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs @@ -40,4 +40,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs index adf7d66..b152df2 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs @@ -645,4 +645,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs index 500c991..4308a19 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs index 03e0756..d9f5ce1 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs @@ -616,4 +616,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs index 25bc2a8..fb8a16e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs @@ -99,4 +99,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs index 9580159..60cf8d4 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs @@ -33,4 +33,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs index 3634c24..64e9275 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs @@ -129,4 +129,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs index 9a06cad..6e62d5a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs @@ -38,4 +38,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM HeapArea = new Heap(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs index d73fec6..2d3fc47 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs @@ -41,4 +41,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM MethodBuffer = new byte[20000]; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs index bad71c9..f17bf43 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs @@ -30,4 +30,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public class Object { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs index 88d5af0..ff01307 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs @@ -37,4 +37,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs index a73ebd0..40bec4c 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs @@ -43,4 +43,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM LocalVariables = new BaseType[20]; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs index 50c9c09..7f3af0e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs @@ -108,4 +108,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM return m_Interpreter.Excute(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs index 00c2d1c..449f715 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs @@ -163,4 +163,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Script.cs b/OpenSim/Region/ExtensionsScriptModule/Script.cs index 3a9edfe..0555277 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Script.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Script.cs @@ -61,4 +61,4 @@ namespace OpenSim.Region.ExtensionsScriptModule //script.logger.Verbose("TESTSCRIPT", "Hello World!"); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs index 4fccef1..af54a4e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs @@ -61,4 +61,4 @@ namespace OpenSim.Region.ExtensionsScriptModule api = new ScriptAPI(world, task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index 1f26d22..d080ab8 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -146,4 +146,4 @@ namespace OpenSim.Region.ExtensionsScriptModule Dictionary compile(string filename); string FileExt(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs index 919910c..b76fbbf 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 5ac651f..636cf1a 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -106,18 +106,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { return null; } + public override void AddPhysicsActorTaint(PhysicsActor prim) { - } + public override float Simulate(float timeStep) { float fps = 0; @@ -125,8 +126,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { BasicActor actor = _actors[i]; - actor.Position.X += actor.Velocity.X * timeStep; - actor.Position.Y += actor.Velocity.Y * timeStep; + actor.Position.X += actor.Velocity.X*timeStep; + actor.Position.Y += actor.Velocity.Y*timeStep; if (actor.Position.Y < 0) { @@ -146,18 +147,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin actor.Position.X = 255.9F; } - float height = _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 1.0f; + float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f; if (actor.Flying) { - if (actor.Position.Z + (actor.Velocity.Z * timeStep) < - _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 2) + if (actor.Position.Z + (actor.Velocity.Z*timeStep) < + _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2) { actor.Position.Z = height; actor.Velocity.Z = 0; } else { - actor.Position.Z += actor.Velocity.Z * timeStep; + actor.Position.Z += actor.Velocity.Z*timeStep; } } else @@ -204,31 +205,37 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin _position = new PhysicsVector(); _acceleration = new PhysicsVector(); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } @@ -240,16 +247,19 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get { return _position; } @@ -264,27 +274,29 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } } + public override PhysicsVector Velocity { get { return _velocity; } @@ -321,4 +333,4 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs index 06d4fe3..6b7ce82 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.0.0")] +[assembly : AssemblyVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 5602301..a88299e 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -70,12 +70,11 @@ using XnaDevRu.BulletX; using XnaDevRu.BulletX.Dynamics; using AxiomQuaternion = Axiom.Math.Quaternion; using BoxShape=XnaDevRu.BulletX.BoxShape; -#endregion +#endregion namespace OpenSim.Region.Physics.BulletXPlugin { - /// /// BulletXConversions are called now BulletXMaths /// This Class converts objects and types for BulletX and give some operations @@ -263,25 +262,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin // Class to detect and debug collisions // Mainly used for debugging purposes - class CollisionDispatcherLocal : CollisionDispatcher + internal class CollisionDispatcherLocal : CollisionDispatcher { - - BulletXScene relatedScene; + private BulletXScene relatedScene; public CollisionDispatcherLocal(BulletXScene s) : base() { - relatedScene=s; + relatedScene = s; } public override bool NeedsCollision(CollisionObject bodyA, CollisionObject bodyB) { RigidBody rb; - BulletXCharacter bxcA=null; + BulletXCharacter bxcA = null; BulletXPrim bxpA = null; Type t = bodyA.GetType(); - if (t==typeof(RigidBody)) { - rb = (RigidBody)bodyA; + if (t == typeof (RigidBody)) + { + rb = (RigidBody) bodyA; relatedScene._characters.TryGetValue(rb, out bxcA); relatedScene._prims.TryGetValue(rb, out bxpA); } @@ -296,9 +295,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin BulletXCharacter bxcB = null; BulletXPrim bxpB = null; t = bodyB.GetType(); - if (t == typeof(RigidBody)) + if (t == typeof (RigidBody)) { - rb = (RigidBody)bodyB; + rb = (RigidBody) bodyB; relatedScene._characters.TryGetValue(rb, out bxcB); relatedScene._prims.TryGetValue(rb, out bxpB); } @@ -310,15 +309,16 @@ namespace OpenSim.Region.Physics.BulletXPlugin else nameB = "null"; - bool needsCollision=base.NeedsCollision(bodyA, bodyB); + bool needsCollision = base.NeedsCollision(bodyA, bodyB); - MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB, needsCollision); + MainLog.Instance.Debug("BulletX", "A collision was detected between {0} and {1} --> {2}", nameA, nameB, + needsCollision); return needsCollision; } } - + /// /// PhysicsScene Class for BulletX /// @@ -439,7 +439,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin ((BulletXCharacter) actor).RigidBody.ActivationState = ActivationState.DisableSimulation; AddForgottenRigidBody(((BulletXCharacter) actor).RigidBody); } - _characters.Remove(((BulletXCharacter)actor).RigidBody); + _characters.Remove(((BulletXCharacter) actor).RigidBody); } GC.Collect(); } @@ -448,8 +448,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation) { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation, bool isPhysical) { @@ -514,7 +515,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override void AddPhysicsActorTaint(PhysicsActor prim) { - } public override float Simulate(float timeStep) @@ -526,10 +526,10 @@ namespace OpenSim.Region.Physics.BulletXPlugin RemoveForgottenRigidBodies(); //End of remove MoveAllObjects(timeStep); - - - fps = (timeStep * simulationSubSteps); - + + + fps = (timeStep*simulationSubSteps); + ddWorld.StepSimulation(timeStep, simulationSubSteps, timeStep); //Extra Heightmap Validation: BulletX's HeightFieldTerrain somestimes doesn't work so fine. ValidateHeightForAll(); @@ -768,7 +768,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override PhysicsVector Size { get { return _size; } - set { lock (BulletXScene.BulletXLock) { _size = value; } } + set + { + lock (BulletXScene.BulletXLock) + { + _size = value; + } + } } public override PhysicsVector Force @@ -788,10 +794,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override bool SetAlwaysRun @@ -818,9 +821,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } - public override float Mass - { - get { return ActorMass; } + public override float Mass + { + get { return ActorMass; } } public virtual float ActorMass @@ -841,7 +844,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin public Vector3 RigidBodyPosition { - get { return this.rigidBody.CenterOfMassPosition; } + get { return rigidBody.CenterOfMassPosition; } } public override bool IsPhysical @@ -855,6 +858,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin get { return flying; } set { flying = value; } } + public override bool ThrottleUpdates { get { return false; } @@ -889,19 +893,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin public override bool Kinematic { - get - { - return false; - } - set - { - - } + get { return false; } + set { } } public override void AddForce(PhysicsVector force) { - } public override void SetMomentum(PhysicsVector momentum) @@ -917,31 +914,37 @@ namespace OpenSim.Region.Physics.BulletXPlugin } #region Methods for updating values of RigidBody - internal protected void Translate() + + protected internal void Translate() { - Translate(this._position); + Translate(_position); } - internal protected void Translate(PhysicsVector _newPos) + + protected internal void Translate(PhysicsVector _newPos) { Vector3 _translation; _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; rigidBody.Translate(_translation); } - internal protected void Speed() + + protected internal void Speed() { - Speed(this._velocity); + Speed(_velocity); } - internal protected void Speed(PhysicsVector _newSpeed) + + protected internal void Speed(PhysicsVector _newSpeed) { Vector3 _speed; _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); rigidBody.LinearVelocity = _speed; } - internal protected void ReOrient() + + protected internal void ReOrient() { - ReOrient(this._orientation); + ReOrient(_orientation); } - internal protected void ReOrient(AxiomQuaternion _newOrient) + + protected internal void ReOrient(AxiomQuaternion _newOrient) { Quaternion _newOrientation; _newOrientation = BulletXMaths.AxiomQuaternionToXnaQuaternion(_newOrient); @@ -949,17 +952,21 @@ namespace OpenSim.Region.Physics.BulletXPlugin BulletXMaths.SetRotation(ref _comTransform, _newOrientation); rigidBody.CenterOfMassTransform = _comTransform; } - internal protected void ReSize() + + protected internal void ReSize() { - ReSize(this._size); + ReSize(_size); } - internal protected virtual void ReSize(PhysicsVector _newSize) + + protected internal virtual void ReSize(PhysicsVector _newSize) { } + public virtual void ScheduleTerseUpdate() { base.RequestPhysicsterseUpdate(); } + #endregion } @@ -972,11 +979,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin : this("", parent_scene, pos) { } + public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos) : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(), AxiomQuaternion.Identity) { } + public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, PhysicsVector size, PhysicsVector acceleration, AxiomQuaternion orientation) : base(avName) @@ -1026,45 +1035,54 @@ namespace OpenSim.Region.Physics.BulletXPlugin parent_scene.ddWorld.AddRigidBody(rigidBody); } } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override PhysicsVector Position { get { return base.Position; } set { base.Position = value; } } + public override PhysicsVector Velocity { get { return base.Velocity; } set { base.Velocity = value; } } + public override PhysicsVector Size { get { return base.Size; } set { base.Size = value; } } + public override PhysicsVector Acceleration { get { return base.Acceleration; } } + public override AxiomQuaternion Orientation { get { return base.Orientation; } set { base.Orientation = value; } } + public override bool Flying { get { return base.Flying; } set { base.Flying = value; } } + public override bool IsColliding { get { return base.IsColliding; } set { base.IsColliding = value; } } + public override bool Kinematic { get { return base.Kinematic; } @@ -1075,10 +1093,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin { base.SetAcceleration(accel); } + public override void AddForce(PhysicsVector force) { base.AddForce(force); } + public override void SetMomentum(PhysicsVector momentum) { base.SetMomentum(momentum); @@ -1117,6 +1137,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin } rigidBody.LinearVelocity = vec; } + //This validation is very basic internal override void ValidateHeight(float heighmapPositionValue) { @@ -1131,6 +1152,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); } } + internal override void UpdateKinetics() { _position = BulletXMaths.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition); @@ -1154,12 +1176,15 @@ namespace OpenSim.Region.Physics.BulletXPlugin public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) - : this(primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, isPhysical) + : this( + primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, + isPhysical) { } + public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, PhysicsVector size, - PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, + PhysicsVector acceleration, AxiomQuaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) : base(primName) { @@ -1177,27 +1202,28 @@ namespace OpenSim.Region.Physics.BulletXPlugin CreateRigidBody(parent_scene, mesh, pos, size); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override PhysicsVector Position { get { return base.Position; } set { base.Position = value; } } + public override PhysicsVector Velocity { get { return base.Velocity; } set { base.Velocity = value; } } + public override PhysicsVector Size { - get - { - return _size; - } + get { return _size; } set { lock (BulletXScene.BulletXLock) @@ -1207,29 +1233,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector Acceleration { get { return base.Acceleration; } } + public override AxiomQuaternion Orientation { get { return base.Orientation; } set { base.Orientation = value; } } + public override float ActorMass { get { //For now all prims are boxes - return (_physical ? 1 : 0) * _density * _size.X * _size.Y * _size.Z; + return (_physical ? 1 : 0)*_density*_size.X*_size.Y*_size.Z; } } + public override bool IsPhysical { - get - { - return base.IsPhysical; - } + get { return base.IsPhysical; } set { base.IsPhysical = value; @@ -1238,27 +1265,30 @@ namespace OpenSim.Region.Physics.BulletXPlugin //--- PhysicsPluginManager.PhysicsPluginMessage("Physical - Recreate", true); //--- - ReCreateRigidBody(this._size); + ReCreateRigidBody(_size); } else { //--- PhysicsPluginManager.PhysicsPluginMessage("Physical - SetMassProps", true); //--- - this.rigidBody.SetMassProps(Mass, new Vector3()); + rigidBody.SetMassProps(Mass, new Vector3()); } } } + public override bool Flying { get { return base.Flying; } set { base.Flying = value; } } + public override bool IsColliding { get { return base.IsColliding; } set { base.IsColliding = value; } } + public override bool Kinematic { get { return base.Kinematic; } @@ -1272,10 +1302,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin _acceleration = accel; } } + public override void AddForce(PhysicsVector force) { base.AddForce(force); } + public override void SetMomentum(PhysicsVector momentum) { base.SetMomentum(momentum); @@ -1296,6 +1328,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); } } + internal override void UpdateKinetics() { if (_physical) //Updates properties. Prim updates its properties physically @@ -1320,7 +1353,6 @@ namespace OpenSim.Region.Physics.BulletXPlugin { m_lastUpdateSent = false; base.ScheduleTerseUpdate(); - } m_prev_position = _position; } @@ -1333,7 +1365,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin } #region Methods for updating values of RigidBody - internal protected void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, PhysicsVector size) + + protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, + PhysicsVector size) { //For RigidBody Constructor. The next values might change float _linearDamping = 0.0f; @@ -1349,27 +1383,31 @@ namespace OpenSim.Region.Physics.BulletXPlugin CollisionShape _collisionShape; if (mesh == null) { - _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size) / 2.0f); - } else { + _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(size)/2.0f); + } + else + { int iVertexCount = mesh.getVertexList().Count; int[] indices = mesh.getIndexListAsInt(); Vector3[] v3Vertices = new Vector3[iVertexCount]; for (int i = 0; i < iVertexCount; i++) { - PhysicsVector v=mesh.getVertexList()[i]; + PhysicsVector v = mesh.getVertexList()[i]; if (v != null) // Note, null has special meaning. See meshing code for details v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); else - v3Vertices[i] = MonoXnaCompactMaths.Vector3.Zero; + v3Vertices[i] = Vector3.Zero; } TriangleIndexVertexArray triMesh = new TriangleIndexVertexArray(indices, v3Vertices); - _collisionShape = new XnaDevRu.BulletX.TriangleMeshShape(triMesh); + _collisionShape = new TriangleMeshShape(triMesh); } DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); Vector3 _localInertia = new Vector3(); if (_physical) _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 - rigidBody = new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution); + rigidBody = + new RigidBody(Mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, + _friction, _restitution); //rigidBody.ActivationState = ActivationState.DisableDeactivation; //It's seems that there are a bug with rigidBody constructor and its CenterOfMassPosition Vector3 _vDebugTranslation; @@ -1379,30 +1417,34 @@ namespace OpenSim.Region.Physics.BulletXPlugin parent_scene.ddWorld.AddRigidBody(rigidBody); } } - internal protected void ReCreateRigidBody(PhysicsVector size) + + protected internal void ReCreateRigidBody(PhysicsVector size) { //There is a bug when trying to remove a rigidBody that is colliding with something.. try { - this._parent_scene.ddWorld.RemoveRigidBody(rigidBody); + _parent_scene.ddWorld.RemoveRigidBody(rigidBody); } catch (Exception ex) { - this._parent_scene.BulletXMessage(this._parent_scene.is_ex_message + ex.Message, true); + _parent_scene.BulletXMessage(_parent_scene.is_ex_message + ex.Message, true); rigidBody.ActivationState = ActivationState.DisableSimulation; - this._parent_scene.AddForgottenRigidBody(rigidBody); + _parent_scene.AddForgottenRigidBody(rigidBody); } - CreateRigidBody(this._parent_scene, null, this._position, size); // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler - if (_physical) Speed();//Static objects don't have linear velocity + CreateRigidBody(_parent_scene, null, _position, size); + // Note, null for the meshing definitely is wrong. It's here for the moment to apease the compiler + if (_physical) Speed(); //Static objects don't have linear velocity ReOrient(); GC.Collect(); } - internal protected override void ReSize(PhysicsVector _newSize) + + protected internal override void ReSize(PhysicsVector _newSize) { //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't //so i have to do it manually. That's recreating rigidbody ReCreateRigidBody(_newSize); } + #endregion } @@ -1486,4 +1528,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin return height; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs index 4f63687..e73c953 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/TriangleIndexVertexArray.cs @@ -34,8 +34,8 @@ */ using System; using System.Collections.Generic; -using System.Text; using MonoXnaCompactMaths; +using XnaDevRu.BulletX; namespace OpenSim.Region.Physics.BulletXPlugin { @@ -52,7 +52,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin private Vector3[] _vertexBase; private int _vertexStride; - public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) + public IndexedMesh(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, + Vector3[] vertexBase, int vertexStride) { _numTriangles = numTriangleIndices; _triangleIndexBase = triangleIndexBase; @@ -72,25 +73,57 @@ namespace OpenSim.Region.Physics.BulletXPlugin _vertexStride = 24; } - public int TriangleCount { get { return _numTriangles; } set { _numTriangles = value; } } - public int[] TriangleIndexBase { get { return _triangleIndexBase; } set { _triangleIndexBase = value; } } - public int TriangleIndexStride { get { return _triangleIndexStride; } set { _triangleIndexStride = value; } } - public int VertexCount { get { return _numVertices; } set { _numVertices = value; } } - public Vector3[] VertexBase { get { return _vertexBase; } set { _vertexBase = value; } } - public int VertexStride { get { return _vertexStride; } set { _vertexStride = value; } } + public int TriangleCount + { + get { return _numTriangles; } + set { _numTriangles = value; } + } + + public int[] TriangleIndexBase + { + get { return _triangleIndexBase; } + set { _triangleIndexBase = value; } + } + + public int TriangleIndexStride + { + get { return _triangleIndexStride; } + set { _triangleIndexStride = value; } + } + + public int VertexCount + { + get { return _numVertices; } + set { _numVertices = value; } + } + + public Vector3[] VertexBase + { + get { return _vertexBase; } + set { _vertexBase = value; } + } + + public int VertexStride + { + get { return _vertexStride; } + set { _vertexStride = value; } + } } /// /// TriangleIndexVertexArray allows to use multiple meshes, by indexing into existing triangle/index arrays. /// Additional meshes can be added using addIndexedMesh /// - public class TriangleIndexVertexArray : XnaDevRu.BulletX.StridingMeshInterface + public class TriangleIndexVertexArray : StridingMeshInterface { - List _indexedMeshes = new List(); + private List _indexedMeshes = new List(); - public TriangleIndexVertexArray() { } + public TriangleIndexVertexArray() + { + } - public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, int numVertices, Vector3[] vertexBase, int vertexStride) + public TriangleIndexVertexArray(int numTriangleIndices, int[] triangleIndexBase, int triangleIndexStride, + int numVertices, Vector3[] vertexBase, int vertexStride) { IndexedMesh mesh = new IndexedMesh(); mesh.TriangleCount = numTriangleIndices; @@ -104,19 +137,23 @@ namespace OpenSim.Region.Physics.BulletXPlugin } public TriangleIndexVertexArray(int[] triangleIndexBase, Vector3[] vertexBase) - : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) { } + : this(triangleIndexBase.Length, triangleIndexBase, 32, vertexBase.Length, vertexBase, 24) + { + } public void AddIndexedMesh(IndexedMesh indexedMesh) { _indexedMeshes.Add(indexedMesh); } - public override void GetLockedVertexIndexBase(out List verts, out List indicies, out int numfaces, int subpart) + public override void GetLockedVertexIndexBase(out List verts, out List indicies, out int numfaces, + int subpart) { throw new Exception("The method or operation is not implemented."); } - public override void GetLockedReadOnlyVertexIndexBase(out List verts, out List indicies, out int numfaces, int subpart) + public override void GetLockedReadOnlyVertexIndexBase(out List verts, out List indicies, + out int numfaces, int subpart) { IndexedMesh m = _indexedMeshes[0]; Vector3[] vertexBase = m.VertexBase; @@ -158,4 +195,4 @@ namespace OpenSim.Region.Physics.BulletXPlugin throw new Exception("The method or operation is not implemented."); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs index 3d95d6d..983a2b9 100644 --- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs index 1648a98..80b3320 100644 --- a/OpenSim/Region/Physics/Manager/IMesher.cs +++ b/OpenSim/Region/Physics/Manager/IMesher.cs @@ -28,8 +28,6 @@ using System; using System.Collections.Generic; -using System.Text; - using OpenSim.Framework; namespace OpenSim.Region.Physics.Manager @@ -39,7 +37,8 @@ namespace OpenSim.Region.Physics.Manager IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size); } - public interface IVertex { + public interface IVertex + { } public interface IMesh @@ -48,7 +47,5 @@ namespace OpenSim.Region.Physics.Manager int[] getIndexListAsInt(); int[] getIndexListAsIntLocked(); float[] getVertexListAsFloatLocked(); - - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 5894ab0..d393b62 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -25,10 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using Axiom.Math; -using OpenSim.Framework; using System; using System.Collections.Generic; +using Axiom.Math; +using OpenSim.Framework; namespace OpenSim.Region.Physics.Manager { @@ -37,14 +37,16 @@ namespace OpenSim.Region.Physics.Manager public delegate void VelocityUpdate(PhysicsVector velocity); public delegate void OrientationUpdate(Quaternion orientation); + public enum ActorTypes : int { Unknown = 0, Agent = 1, - Prim = 2, + Prim = 2, Ground = 3 } - public class CollisionEventUpdate : EventArgs + + public class CollisionEventUpdate : EventArgs { // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. @@ -53,52 +55,53 @@ namespace OpenSim.Region.Physics.Manager public bool m_startOrEnd; //public uint m_LocalID; public List m_objCollisionList; + public CollisionEventUpdate(uint localID, int colliderType, bool startOrEnd, List objCollisionList) { m_colliderType = colliderType; m_startOrEnd = startOrEnd; m_objCollisionList = objCollisionList; - } - public CollisionEventUpdate(bool startOrEnd){ - m_colliderType = (int)ActorTypes.Unknown; + + public CollisionEventUpdate(bool startOrEnd) + { + m_colliderType = (int) ActorTypes.Unknown; m_startOrEnd = startOrEnd; m_objCollisionList = null; } - public CollisionEventUpdate() { - m_colliderType = (int)ActorTypes.Unknown; + + public CollisionEventUpdate() + { + m_colliderType = (int) ActorTypes.Unknown; m_startOrEnd = false; m_objCollisionList = null; } - public int collidertype{ - get { - return m_colliderType; - } - set { - m_colliderType = value; - } + + public int collidertype + { + get { return m_colliderType; } + set { m_colliderType = value; } } - public bool startOrEnd { - get { - return m_startOrEnd; - } - set { - m_startOrEnd = value; - } + + public bool startOrEnd + { + get { return m_startOrEnd; } + set { m_startOrEnd = value; } } - public void addCollider(uint localID) { + + public void addCollider(uint localID) + { m_objCollisionList.Add(localID); } } - - - public abstract class PhysicsActor - { + { public delegate void RequestTerseUpdate(); + public delegate void CollisionUpdate(EventArgs e); + public delegate void OutOfBounds(PhysicsVector pos); #pragma warning disable 67 @@ -117,10 +120,8 @@ namespace OpenSim.Region.Physics.Manager public abstract PhysicsVector Size { get; set; } - public abstract PrimitiveBaseShape Shape - { - set; - } + public abstract PrimitiveBaseShape Shape { set; } + public virtual void RequestPhysicsterseUpdate() { // Make a temporary copy of the event to avoid possibility of @@ -131,8 +132,8 @@ namespace OpenSim.Region.Physics.Manager { OnRequestTerseUpdate(); } - } + public virtual void RaiseOutOfBounds(PhysicsVector pos) { // Make a temporary copy of the event to avoid possibility of @@ -143,8 +144,8 @@ namespace OpenSim.Region.Physics.Manager { OnOutOfBounds(pos); } - } + public virtual void SendCollisionUpdate(EventArgs e) { CollisionUpdate handler = OnCollisionUpdate; @@ -159,7 +160,7 @@ namespace OpenSim.Region.Physics.Manager public abstract float Mass { get; } - public abstract PhysicsVector Force { get;} + public abstract PhysicsVector Force { get; } public abstract PhysicsVector GeometricCenter { get; } @@ -172,7 +173,7 @@ namespace OpenSim.Region.Physics.Manager public abstract Quaternion Orientation { get; set; } public abstract int PhysicsActorType { get; set; } - public abstract bool IsPhysical {get; set;} + public abstract bool IsPhysical { get; set; } public abstract bool Flying { get; set; } public abstract bool SetAlwaysRun { get; set; } @@ -198,48 +199,54 @@ namespace OpenSim.Region.Physics.Manager get { return PhysicsVector.Zero; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool CollidingGround { - get {return false;} - set {return;} + get { return false; } + set { return; } } - public override bool CollidingObj + + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Size { get { return PhysicsVector.Zero; } set { return; } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } } + public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity @@ -270,6 +277,7 @@ namespace OpenSim.Region.Physics.Manager get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } @@ -281,9 +289,10 @@ namespace OpenSim.Region.Physics.Manager get { return false; } set { return; } } + public override int PhysicsActorType { - get { return (int)ActorTypes.Unknown; } + get { return (int) ActorTypes.Unknown; } set { return; } } @@ -297,14 +306,16 @@ namespace OpenSim.Region.Physics.Manager { return; } + public override PhysicsVector RotationalVelocity { get { return PhysicsVector.Zero; } set { return; } } + public override void SetMomentum(PhysicsVector momentum) { return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index badcc04..a4ac54f 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs @@ -30,7 +30,6 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using OpenSim.Framework.Console; -using Nini.Config; namespace OpenSim.Region.Physics.Manager { @@ -91,7 +90,7 @@ namespace OpenSim.Region.Physics.Manager plugHard = new ZeroMesherPlugin(); _MeshPlugins.Add(plugHard.GetName(), plugHard); MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plugHard.GetName()); - + // And now walk all assemblies (DLLs effectively) and see if they are home // of a plugin that is of interest for us string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Physics"); @@ -129,7 +128,7 @@ namespace OpenSim.Region.Physics.Manager if (meshTypeInterface != null) { IMeshingPlugin plug = - (IMeshingPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + (IMeshingPlugin) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); _MeshPlugins.Add(plug.GetName(), plug); MainLog.Instance.Verbose("PHYSICS", "Added meshing engine: " + plug.GetName()); } @@ -155,6 +154,7 @@ namespace OpenSim.Region.Physics.Manager MainLog.Instance.Verbose("PHYSICS", message); } } + //--- } @@ -171,4 +171,4 @@ namespace OpenSim.Region.Physics.Manager string GetName(); IMesher GetMesher(); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index c63a66d..37481f1 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -28,7 +28,6 @@ using Axiom.Math; using OpenSim.Framework; using OpenSim.Framework.Console; -using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Manager { @@ -45,6 +44,7 @@ namespace OpenSim.Region.Physics.Manager { get { return new NullPhysicsScene(); } } + public virtual void TriggerPhysicsBasedRestart() { physicsCrash handler = OnPhysicsCrash; @@ -52,9 +52,8 @@ namespace OpenSim.Region.Physics.Manager { OnPhysicsCrash(); } - } - + public abstract void Initialise(IMesher meshmerizer); @@ -68,6 +67,7 @@ namespace OpenSim.Region.Physics.Manager PhysicsVector size, Quaternion rotation); //To be removed public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical); + public abstract void AddPhysicsActorTaint(PhysicsActor prim); public abstract float Simulate(float timeStep); @@ -111,21 +111,24 @@ namespace OpenSim.Region.Physics.Manager return PhysicsActor.Null; } */ + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) //To be removed { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { MainLog.Instance.Verbose("PHYSICS", "NullPhysicsScene : AddPrim({0},{1})", position, size); return PhysicsActor.Null; } + public override void AddPhysicsActorTaint(PhysicsActor prim) { - } + public override float Simulate(float timeStep) { m_workIndicator = (m_workIndicator + 1)%10; @@ -154,4 +157,4 @@ namespace OpenSim.Region.Physics.Manager } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs index be82fca..1f5d0dc 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs @@ -28,7 +28,6 @@ using System; - namespace OpenSim.Region.Physics.Manager { public class PhysicsVector @@ -68,27 +67,27 @@ namespace OpenSim.Region.Physics.Manager public static PhysicsVector cross(PhysicsVector a, PhysicsVector b) { - return new PhysicsVector(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X); + return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X); } public float length() { - return (float)Math.Sqrt(X*X + Y*Y + Z*Z); + return (float) Math.Sqrt(X*X + Y*Y + Z*Z); } - public static PhysicsVector operator / (PhysicsVector v, float f) + public static PhysicsVector operator /(PhysicsVector v, float f) { - return new PhysicsVector(v.X / f, v.Y / f, v.Z / f); + return new PhysicsVector(v.X/f, v.Y/f, v.Z/f); } public static PhysicsVector operator *(PhysicsVector v, float f) { - return new PhysicsVector(v.X * f, v.Y * f, v.Z * f); + return new PhysicsVector(v.X*f, v.Y*f, v.Z*f); } public static PhysicsVector operator *(float f, PhysicsVector v) { - return v * f; + return v*f; } public virtual bool IsIdentical(PhysicsVector v, float tolerance) @@ -101,4 +100,4 @@ namespace OpenSim.Region.Physics.Manager return false; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs index a88656e..7dae4ac 100644 --- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs +++ b/OpenSim/Region/Physics/Manager/ZeroMesher.cs @@ -27,11 +27,8 @@ */ using System; -using System.Collections.Generic; -using System.Text; using OpenSim.Framework; - /* * This is the zero mesher. * Whatever you want him to mesh, he can't, telling you that by responding with a null pointer. @@ -62,13 +59,11 @@ namespace OpenSim.Region.Physics.Manager } } - public class ZeroMesher: IMesher + public class ZeroMesher : IMesher { - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) { return null; } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs index eecac5a..7ef5b5b 100644 --- a/OpenSim/Region/Physics/Meshing/Extruder.cs +++ b/OpenSim/Region/Physics/Meshing/Extruder.cs @@ -26,24 +26,22 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing { - class Extruder + internal class Extruder { public float startParameter; public float stopParameter; - public Manager.PhysicsVector size; + public PhysicsVector size; public Mesh Extrude(Mesh m) { // Currently only works for iSteps=1; Mesh result = new Mesh(); - Mesh workingPlus = m.Clone(); + Mesh workingPlus = m.Clone(); Mesh workingMinus = m.Clone(); foreach (Vertex v in workingPlus.vertices) @@ -80,14 +78,14 @@ namespace OpenSim.Region.Physics.Meshing for (int i = 0; i < workingPlus.vertices.Count; i++) { int iNext = (i + 1); - + if (workingPlus.vertices[i] == null) // Can't make a simplex here { - iLastNull = i+1; + iLastNull = i + 1; continue; } - if (i == workingPlus.vertices.Count-1) // End of list + if (i == workingPlus.vertices.Count - 1) // End of list { iNext = iLastNull; } @@ -101,11 +99,12 @@ namespace OpenSim.Region.Physics.Meshing tSide = new Triangle(workingPlus.vertices[i], workingMinus.vertices[i], workingPlus.vertices[iNext]); result.Add(tSide); - tSide = new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]); + tSide = + new Triangle(workingPlus.vertices[iNext], workingMinus.vertices[i], workingMinus.vertices[iNext]); result.Add(tSide); } return result; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs index be82c32..ac06614 100644 --- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs +++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs @@ -30,9 +30,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; -using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; - using OpenSim.Region.Physics.Meshing; public class Vertex : PhysicsVector, IComparable @@ -54,7 +52,7 @@ public class Vertex : PhysicsVector, IComparable public static Vertex FromAngle(double angle) { - return new Vertex((float)Math.Cos(angle), (float)Math.Sin(angle), 0.0f); + return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f); } @@ -101,6 +99,7 @@ public class Vertex : PhysicsVector, IComparable { return me.CompareTo(other) < 0; } + public String ToRaw() { // Why this stuff with the number formatter? @@ -117,7 +116,6 @@ public class Vertex : PhysicsVector, IComparable return s1; } - } public class Triangle @@ -283,7 +281,7 @@ public class Triangle float l = n.length(); // Normalized "normal" - n = n / l; + n = n/l; return n; } @@ -300,7 +298,7 @@ public class Triangle // debugging purposes public String ToStringRaw() { - String output = v1.ToRaw() + " " + v2.ToRaw() + " " +v3.ToRaw(); + String output = v1.ToRaw() + " " + v2.ToRaw() + " " + v3.ToRaw(); return output; } } \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index 2ebfa1c..9c2667e 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs @@ -26,14 +26,11 @@ * */ + using System; -using System.IO; using System.Collections.Generic; -using System.Text; - +using System.IO; using System.Runtime.InteropServices; - - using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing @@ -66,9 +63,9 @@ namespace OpenSim.Region.Physics.Meshing foreach (Triangle t in triangles) { int iV1, iV2, iV3; - iV1 = this.vertices.IndexOf(t.v1); - iV2 = this.vertices.IndexOf(t.v2); - iV3 = this.vertices.IndexOf(t.v3); + iV1 = vertices.IndexOf(t.v1); + iV2 = vertices.IndexOf(t.v2); + iV3 = vertices.IndexOf(t.v3); Triangle newT = new Triangle(result.vertices[iV1], result.vertices[iV2], result.vertices[iV3]); result.Add(newT); @@ -77,8 +74,7 @@ namespace OpenSim.Region.Physics.Meshing return result; } - - + public void Add(Triangle triangle) { int i; @@ -160,15 +156,15 @@ namespace OpenSim.Region.Physics.Meshing public float[] getVertexListAsFloatLocked() { - float[] result = new float[vertices.Count * 3]; + float[] result = new float[vertices.Count*3]; for (int i = 0; i < vertices.Count; i++) { Vertex v = vertices[i]; if (v == null) continue; - result[3 * i + 0] = v.X; - result[3 * i + 1] = v.Y; - result[3 * i + 2] = v.Z; + result[3*i + 0] = v.X; + result[3*i + 1] = v.Y; + result[3*i + 2] = v.Z; } GCHandle.Alloc(result, GCHandleType.Pinned); return result; @@ -176,13 +172,13 @@ namespace OpenSim.Region.Physics.Meshing public int[] getIndexListAsInt() { - int[] result = new int[triangles.Count * 3]; + int[] result = new int[triangles.Count*3]; for (int i = 0; i < triangles.Count; i++) { Triangle t = triangles[i]; - result[3 * i + 0] = vertices.IndexOf(t.v1); - result[3 * i + 1] = vertices.IndexOf(t.v2); - result[3 * i + 2] = vertices.IndexOf(t.v3); + result[3*i + 0] = vertices.IndexOf(t.v1); + result[3*i + 1] = vertices.IndexOf(t.v2); + result[3*i + 2] = vertices.IndexOf(t.v3); } return result; } @@ -202,7 +198,6 @@ namespace OpenSim.Region.Physics.Meshing foreach (Triangle t in newMesh.triangles) Add(t); - } // Do a linear transformation of mesh. @@ -213,9 +208,9 @@ namespace OpenSim.Region.Physics.Meshing if (v == null) continue; float x, y, z; - x = v.X * matrix[0, 0] + v.Y * matrix[1, 0] + v.Z * matrix[2, 0]; - y = v.X * matrix[0, 1] + v.Y * matrix[1, 1] + v.Z * matrix[2, 1]; - z = v.X * matrix[0, 2] + v.Y * matrix[1, 2] + v.Z * matrix[2, 2]; + x = v.X*matrix[0, 0] + v.Y*matrix[1, 0] + v.Z*matrix[2, 0]; + y = v.X*matrix[0, 1] + v.Y*matrix[1, 1] + v.Z*matrix[2, 1]; + z = v.X*matrix[0, 2] + v.Y*matrix[1, 2] + v.Z*matrix[2, 2]; v.X = x + offset[0]; v.Y = y + offset[1]; v.Z = z + offset[2]; @@ -237,5 +232,4 @@ namespace OpenSim.Region.Physics.Meshing sw.Close(); } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 9c35f81..3217dd8 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -27,18 +27,13 @@ */ using System; -using System.IO; -using System.Globalization; -using System.Diagnostics; using System.Collections.Generic; -using System.Runtime.InteropServices; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing { - public class MeshmerizerPlugin : IMeshingPlugin { public MeshmerizerPlugin() @@ -61,10 +56,11 @@ namespace OpenSim.Region.Physics.Meshing // Setting baseDir to a path will enable the dumping of raw files // raw files can be imported by blender so a visual inspection of the results can be done // const string baseDir = "rawFiles"; - const string baseDir = null; + private const string baseDir = null; - static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, PhysicsVector r2, ref float lambda, ref float mu) - { + private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2, + PhysicsVector r2, ref float lambda, ref float mu) + { // p1, p2, points on the straight // r1, r2, directional vectors of the straight. Not necessarily of length 1! // note, that l, m can be scaled such, that the range 0..1 is mapped to the area between two points, @@ -88,9 +84,8 @@ namespace OpenSim.Region.Physics.Meshing float p1y = p1.Y; float p2x = p2.X; float p2y = p2.Y; - lambda = (-p2x * r2y + p1x * r2y + (p2y - p1y) * r2x) / denom; - mu = (-p2x * r1y + p1x * r1y + (p2y - p1y) * r1x) / denom; - + lambda = (-p2x*r2y + p1x*r2y + (p2y - p1y)*r2x)/denom; + mu = (-p2x*r1y + p1x*r1y + (p2y - p1y)*r1x)/denom; } private static List FindInfluencedTriangles(List triangles, Vertex v) @@ -105,8 +100,8 @@ namespace OpenSim.Region.Physics.Meshing } return influenced; } - - + + private static void InsertVertices(List vertices, int usedForSeed, List triangles) { // This is a variant of the delaunay algorithm @@ -126,10 +121,10 @@ namespace OpenSim.Region.Physics.Meshing // do not fulfill this condition with respect to the new triangle // Find the triangles that are influenced by the new vertex - Vertex v=vertices[iCurrentVertex]; + Vertex v = vertices[iCurrentVertex]; if (v == null) - continue; // Null is polygon stop marker. Ignore it - List influencedTriangles=FindInfluencedTriangles(triangles, v); + continue; // Null is polygon stop marker. Ignore it + List influencedTriangles = FindInfluencedTriangles(triangles, v); List simplices = new List(); @@ -177,12 +172,11 @@ namespace OpenSim.Region.Physics.Meshing } } } - } - - static Mesh CreateBoxMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) - // Builds the z (+ and -) surfaces of a box shaped prim + + private static Mesh CreateBoxMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) + // Builds the z (+ and -) surfaces of a box shaped prim { UInt16 hollowFactor = primShape.ProfileHollow; UInt16 profileBegin = primShape.ProfileBegin; @@ -201,7 +195,7 @@ namespace OpenSim.Region.Physics.Meshing Vertex MP = new Vertex(-0.5f, +0.5f, 0.0f); Vertex PP = new Vertex(+0.5f, +0.5f, 0.0f); - Meshing.SimpleHull outerHull = new SimpleHull(); + SimpleHull outerHull = new SimpleHull(); outerHull.AddVertex(MM); outerHull.AddVertex(PM); outerHull.AddVertex(PP); @@ -210,9 +204,10 @@ namespace OpenSim.Region.Physics.Meshing // Deal with cuts now if ((profileBegin != 0) || (profileEnd != 0)) { - double fProfileBeginAngle = profileBegin / 50000.0 * 360.0; // In degree, for easier debugging and understanding - fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y - double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0 + double fProfileBeginAngle = profileBegin/50000.0*360.0; + // In degree, for easier debugging and understanding + fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y + double fProfileEndAngle = 360.0 - profileEnd/50000.0*360.0; // Pathend comes as complement to 1.0 fProfileEndAngle -= (90.0 + 45.0); if (fProfileBeginAngle < fProfileEndAngle) fProfileEndAngle -= 360.0; @@ -222,20 +217,23 @@ namespace OpenSim.Region.Physics.Meshing // and we approximate this arc by a polygon chain // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space // So it can easily be subtracted from the outer hull - int iSteps = (int)(((fProfileBeginAngle - fProfileEndAngle) / 45.0) + .5); // how many steps do we need with approximately 45 degree - double dStepWidth=(fProfileBeginAngle-fProfileEndAngle)/iSteps; + int iSteps = (int) (((fProfileBeginAngle - fProfileEndAngle)/45.0) + .5); + // how many steps do we need with approximately 45 degree + double dStepWidth = (fProfileBeginAngle - fProfileEndAngle)/iSteps; Vertex origin = new Vertex(0.0f, 0.0f, 0.0f); // Note the sequence of vertices here. It's important to have the other rotational sense than in outerHull SimpleHull cutHull = new SimpleHull(); cutHull.AddVertex(origin); - for (int i=0; i 0) { float hollowFactorF = (float) hollowFactor/(float) 50000; - Vertex IMM = new Vertex(-0.5f * hollowFactorF, -0.5f * hollowFactorF, 0.0f); - Vertex IPM = new Vertex(+0.5f * hollowFactorF, -0.5f * hollowFactorF, 0.0f); - Vertex IMP = new Vertex(-0.5f * hollowFactorF, +0.5f * hollowFactorF, 0.0f); - Vertex IPP = new Vertex(+0.5f * hollowFactorF, +0.5f * hollowFactorF, 0.0f); + Vertex IMM = new Vertex(-0.5f*hollowFactorF, -0.5f*hollowFactorF, 0.0f); + Vertex IPM = new Vertex(+0.5f*hollowFactorF, -0.5f*hollowFactorF, 0.0f); + Vertex IMP = new Vertex(-0.5f*hollowFactorF, +0.5f*hollowFactorF, 0.0f); + Vertex IPP = new Vertex(+0.5f*hollowFactorF, +0.5f*hollowFactorF, 0.0f); SimpleHull holeHull = new SimpleHull(); @@ -263,7 +261,6 @@ namespace OpenSim.Region.Physics.Meshing SimpleHull hollowedHull = SimpleHull.SubtractHull(outerHull, holeHull); outerHull = hollowedHull; - } Mesh m = new Mesh(); @@ -286,7 +283,7 @@ namespace OpenSim.Region.Physics.Meshing m.Remove(Seed2); m.Remove(Seed3); m.DumpRaw(baseDir, primName, "Proto seeds removed"); - + m.RemoveTrianglesOutside(outerHull); m.DumpRaw(baseDir, primName, "Proto outsides removed"); @@ -374,7 +371,7 @@ namespace OpenSim.Region.Physics.Meshing switch (primShape.ProfileShape) { case ProfileShape.Square: - mesh=CreateBoxMesh(primName, primShape, size); + mesh = CreateBoxMesh(primName, primShape, size); CalcNormals(mesh); break; default: @@ -389,5 +386,4 @@ namespace OpenSim.Region.Physics.Meshing return mesh; } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/Meshing/SimpleHull.cs b/OpenSim/Region/Physics/Meshing/SimpleHull.cs index a769053..809f3d5 100644 --- a/OpenSim/Region/Physics/Meshing/SimpleHull.cs +++ b/OpenSim/Region/Physics/Meshing/SimpleHull.cs @@ -28,9 +28,8 @@ using System; using System.Collections.Generic; -using System.Text; - using OpenSim.Framework.Console; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.Meshing { @@ -43,17 +42,18 @@ namespace OpenSim.Region.Physics.Meshing // is defined by the hull lies inside or outside the simplex chain public class SimpleHull { - List vertices = new List(); - List holeVertices = new List(); // Only used, when the hull is hollow + private List vertices = new List(); + private List holeVertices = new List(); // Only used, when the hull is hollow // Adds a vertex to the end of the list - public void AddVertex(Vertex v) { + public void AddVertex(Vertex v) + { vertices.Add(v); } - override public String ToString() + public override String ToString() { - String result=""; + String result = ""; foreach (Vertex v in vertices) { result += "b:" + v.ToString() + "\n"; @@ -63,7 +63,8 @@ namespace OpenSim.Region.Physics.Meshing } - public List getVertices() { + public List getVertices() + { List newVertices = new List(); newVertices.AddRange(vertices); @@ -81,27 +82,27 @@ namespace OpenSim.Region.Physics.Meshing result.AddVertex(v.Clone()); } - foreach (Vertex v in this.holeVertices) + foreach (Vertex v in holeVertices) { result.holeVertices.Add(v.Clone()); } - + return result; } public bool IsPointIn(Vertex v1) { - int iCounter=0; - List simplices=buildSimplexList(); + int iCounter = 0; + List simplices = buildSimplexList(); foreach (Simplex s in simplices) { // Send a ray along the positive X-Direction // Note, that this direction must correlate with the "below" interpretation // of handling for the special cases below - Manager.PhysicsVector intersection = s.RayIntersect(v1, new Manager.PhysicsVector(1.0f, 0.0f, 0.0f), true); + PhysicsVector intersection = s.RayIntersect(v1, new PhysicsVector(1.0f, 0.0f, 0.0f), true); if (intersection == null) - continue; // No intersection. Done. More tests to follow otherwise + continue; // No intersection. Done. More tests to follow otherwise // Did we hit the end of a simplex? // Then this can be one of two special cases: @@ -111,19 +112,21 @@ namespace OpenSim.Region.Physics.Meshing // Solution: If the other vertex is "below" the ray, we don't count it // Thus corners pointing down are counted twice, corners pointing up are not counted // borders are counted once - if (intersection.IsIdentical(s.v1, 0.001f)) { + if (intersection.IsIdentical(s.v1, 0.001f)) + { if (s.v2.Y < v1.Y) continue; } // Do this for the other vertex two - if (intersection.IsIdentical(s.v2, 0.001f)) { - if (s.v1.Y buildSimplexList() { - + private List buildSimplexList() + { List result = new List(); // Not asserted but assumed: at least three vertices - for (int i=0; i simple = buildSimplexList(); foreach (Simplex sTest in simple) { - Manager.PhysicsVector vvTemp = Simplex.Intersect(sTest, s, -.001f, -.001f, 0.999f, .999f); - - Vertex vTemp=null; + PhysicsVector vvTemp = Simplex.Intersect(sTest, s, -.001f, -.001f, 0.999f, .999f); + + Vertex vTemp = null; if (vvTemp != null) vTemp = new Vertex(vvTemp); - if (vTemp!=null) { - - Manager.PhysicsVector diff=(s.v1-vTemp); - float distTemp=diff.length(); + if (vTemp != null) + { + PhysicsVector diff = (s.v1 - vTemp); + float distTemp = diff.length(); - if (bestIntersection==null || distTemp many, many intersections + if (z1 == 0.0f) + { +// Means they are identical -> many, many intersections lambda = Single.NaN; mu = Single.NaN; - } else { + } + else + { lambda = Single.PositiveInfinity; mu = Single.PositiveInfinity; } return; - } - - lambda = z1 / denom; - mu = z2 / denom; - + lambda = z1/denom; + mu = z2/denom; } @@ -145,12 +144,12 @@ namespace OpenSim.Region.Physics.Meshing // upperBorder2 : 1.0 // Set these to values near the given parameters (e.g. 0.001 instead of 1 to exclude simplex starts safely, or to -0.001 to include them safely) public static PhysicsVector Intersect( - Simplex s1, - Simplex s2, - float lowerBorder1, - float lowerBorder2, - float upperBorder1, - float upperBorder2) + Simplex s1, + Simplex s2, + float lowerBorder1, + float lowerBorder2, + float upperBorder1, + float upperBorder2) { PhysicsVector firstSimplexDirection = s1.v2 - s1.v1; PhysicsVector secondSimplexDirection = s2.v2 - s2.v1; @@ -181,8 +180,7 @@ namespace OpenSim.Region.Physics.Meshing if (mu > upperBorder2) // outside simplex 2 return null; - return s1.v1 + lambda * firstSimplexDirection; - + return s1.v1 + lambda*firstSimplexDirection; } // Intersects the simplex with a ray. The ray is defined as all p=origin + lambda*direction @@ -212,15 +210,12 @@ namespace OpenSim.Region.Physics.Meshing return null; if (lambda == 1.0 && !bEndsIncluded) - return null; // The end of the simplices are not included + return null; // The end of the simplices are not included if (lambda < 0.0f) // we're before v1; return null; - return this.v1 + lambda * simplexDirection; - + return v1 + lambda*simplexDirection; } - - } } \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs index 1e5713b..1ea5458 100644 --- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 9676db4..a118e7c 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -27,11 +27,9 @@ */ using System; -using System.Collections.Generic; using Axiom.Math; using Ode.NET; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.OdePlugin @@ -87,7 +85,9 @@ namespace OpenSim.Region.Physics.OdePlugin _acceleration = new PhysicsVector(); _parent_scene = parent_scene; - m_StandUpRotation = new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, -0.004689182f, 0.9998941f); + m_StandUpRotation = + new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, + -0.004689182f, 0.9998941f); for (int i = 0; i < 11; i++) { @@ -105,12 +105,9 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetBody(Shell, Body); - - d.BodySetRotation(Body, ref m_StandUpRotation); - //Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero); //d.JointAttach(Amotor, Body, IntPtr.Zero); //d.JointSetAMotorMode(Amotor, dAMotorEuler); @@ -124,45 +121,47 @@ namespace OpenSim.Region.Physics.OdePlugin //d.JointSetAMotorParam(Amotor, 0, -0); //d.JointSetAMotorParam(Amotor, 0x200, -0); //d.JointSetAMotorParam(Amotor, 0x100, -0); - // d.JointSetAMotorParam(Amotor, 0, 0); - // d.JointSetAMotorParam(Amotor, 3, 0); - // d.JointSetAMotorParam(Amotor, 2, 0); - - - + // d.JointSetAMotorParam(Amotor, 0, 0); + // d.JointSetAMotorParam(Amotor, 3, 0); + // d.JointSetAMotorParam(Amotor, 2, 0); } m_name = avName; parent_scene.geom_name_map[Shell] = avName; - parent_scene.actor_name_map[Shell] = (PhysicsActor)this; + parent_scene.actor_name_map[Shell] = (PhysicsActor) this; } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override bool SetAlwaysRun { get { return m_alwaysRun; } set { m_alwaysRun = value; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } set { flying = value; } } + public override bool IsColliding { - get { return m_iscolliding; } set { @@ -193,24 +192,22 @@ namespace OpenSim.Region.Physics.OdePlugin // Equal truecounts and false counts means we're colliding with something. - if (falsecount > 1.2 * truecount) + if (falsecount > 1.2*truecount) { m_iscolliding = false; } else { m_iscolliding = true; - - } if (m_wascolliding != m_iscolliding) { //base.SendCollisionUpdate(new CollisionEventUpdate()); - } m_wascolliding = m_iscolliding; } } + public override bool CollidingGround { get { return m_iscollidingGround; } @@ -243,7 +240,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Equal truecounts and false counts means we're colliding with something. - if (falsecount > 1.2 * truecount) + if (falsecount > 1.2*truecount) { m_iscollidingGround = false; } @@ -258,10 +255,12 @@ namespace OpenSim.Region.Physics.OdePlugin m_wascollidingGround = m_iscollidingGround; } } + public override bool CollidingObj { get { return m_iscollidingObj; } - set { + set + { m_iscollidingObj = value; if (value) m_pidControllerActive = false; @@ -269,10 +268,12 @@ namespace OpenSim.Region.Physics.OdePlugin m_pidControllerActive = true; } } + public void SetPidStatus(bool status) { m_pidControllerActive = status; } + public override PhysicsVector Position { get { return _position; } @@ -285,14 +286,16 @@ namespace OpenSim.Region.Physics.OdePlugin } } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override PhysicsVector Size { - get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } + get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } set { m_pidControllerActive = true; @@ -303,7 +306,7 @@ namespace OpenSim.Region.Physics.OdePlugin float capsuleradius = CAPSULE_RADIUS; capsuleradius = 0.2f; - CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z * 0.43f))); // subtract 43% of the size + CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.43f))); // subtract 43% of the size d.BodyDestroy(Body); d.GeomDestroy(Shell); //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH)); @@ -311,25 +314,27 @@ namespace OpenSim.Region.Physics.OdePlugin d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); Body = d.BodyCreate(_parent_scene.world); d.BodySetMass(Body, ref ShellMass); - d.BodySetPosition(Body, _position.X, _position.Y, _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); + d.BodySetPosition(Body, _position.X, _position.Y, + _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); d.GeomSetBody(Shell, Body); } _parent_scene.geom_name_map[Shell] = m_name; - _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; + _parent_scene.actor_name_map[Shell] = (PhysicsActor) this; } } + public override float Mass { - get { - - float AVvolume = (float)(Math.PI * Math.Pow(CAPSULE_RADIUS, 2) * CAPSULE_LENGTH); - return m_density * AVvolume; + get + { + float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH); + return m_density*AVvolume; } } public override PhysicsVector Force { - get { return new PhysicsVector(_target_velocity.X,_target_velocity.Y,_target_velocity.Z); } + get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); } } public override PhysicsVector CenterOfMass @@ -344,18 +349,17 @@ namespace OpenSim.Region.Physics.OdePlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity { get { return _velocity; } - set { + set + { m_pidControllerActive = true; - _target_velocity = value; } + _target_velocity = value; + } } public override bool Kinematic @@ -390,6 +394,7 @@ namespace OpenSim.Region.Physics.OdePlugin //m_lastUpdateSent = false; } + public void doForce(PhysicsVector force) { if (!collidelock) @@ -413,13 +418,11 @@ namespace OpenSim.Region.Physics.OdePlugin //d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); //m_lastUpdateSent = false; - } - } + public override void SetMomentum(PhysicsVector momentum) { - } public void Move(float timeStep) @@ -442,7 +445,6 @@ namespace OpenSim.Region.Physics.OdePlugin else { movementdivisor = 0.8f; - } // if velocity is zero, use position control; otherwise, velocity control @@ -457,11 +459,11 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_pidControllerActive) { d.Vector3 pos = d.BodyGetPosition(Body); - vec.X = (_target_velocity.X - vel.X) * PID_D + (_zeroPosition.X - pos.X) * PID_P; - vec.Y = (_target_velocity.Y - vel.Y) * PID_D + (_zeroPosition.Y - pos.Y) * PID_P; + vec.X = (_target_velocity.X - vel.X)*PID_D + (_zeroPosition.X - pos.X)*PID_P; + vec.Y = (_target_velocity.Y - vel.Y)*PID_D + (_zeroPosition.Y - pos.Y)*PID_P; if (flying) { - vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100) + (_zeroPosition.Z - pos.Z) * PID_P; + vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100) + (_zeroPosition.Z - pos.Z)*PID_P; } } //PidStatus = true; @@ -472,21 +474,20 @@ namespace OpenSim.Region.Physics.OdePlugin _zeroFlag = false; if (m_iscolliding || flying) { - - vec.X = ((_target_velocity.X / movementdivisor) - vel.X) * PID_D; - vec.Y = ((_target_velocity.Y / movementdivisor) - vel.Y) * PID_D; + vec.X = ((_target_velocity.X/movementdivisor) - vel.X)*PID_D; + vec.Y = ((_target_velocity.Y/movementdivisor) - vel.Y)*PID_D; } if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) { d.Vector3 pos = d.BodyGetPosition(Body); - vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; + vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P; if (_target_velocity.X > 0) { - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D; } if (_target_velocity.Y > 0) { - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D; } } else if (!m_iscolliding && !flying) @@ -494,19 +495,18 @@ namespace OpenSim.Region.Physics.OdePlugin d.Vector3 pos = d.BodyGetPosition(Body); if (_target_velocity.X > 0) { - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D; } if (_target_velocity.Y > 0) { - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D; } - } if (flying) { - vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100); + vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100); } } if (flying) @@ -546,13 +546,12 @@ namespace OpenSim.Region.Physics.OdePlugin int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); //if (primScenAvatarIn == "0") //{ - //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); + //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); //} //else //{ // MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); //} - } } else @@ -586,12 +585,11 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (OdeScene.OdeLock) { - // d.JointDestroy(Amotor); + // d.JointDestroy(Amotor); d.GeomDestroy(Shell); _parent_scene.geom_name_map.Remove(Shell); d.BodyDestroy(Body); } } } - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 35328b8..5fef47d 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -27,16 +27,13 @@ */ using System; -using System.Collections.Generic; using Axiom.Math; using Ode.NET; using OpenSim.Framework; -using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Physics.OdePlugin { - public class OdePrim : PhysicsActor { public PhysicsVector _position; @@ -57,7 +54,7 @@ namespace OpenSim.Region.Physics.OdePlugin private IMesh _mesh; private PrimitiveBaseShape _pbs; private OdeScene _parent_scene; - public IntPtr m_targetSpace = (IntPtr)0; + public IntPtr m_targetSpace = (IntPtr) 0; public IntPtr prim_geom; public IntPtr _triMeshData; private bool iscolliding = false; @@ -65,18 +62,17 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_throttleUpdates = false; private int throttleCounter = 0; public bool outofBounds = false; - private float m_density = 10.000006836f;// Aluminum g/cm3; + private float m_density = 10.000006836f; // Aluminum g/cm3; - public bool _zeroFlag = false; private bool m_lastUpdateSent = false; - public IntPtr Body = (IntPtr)0; + public IntPtr Body = (IntPtr) 0; private String m_primName; private PhysicsVector _target_velocity; public d.Mass pMass; - + private int debugcounter = 0; public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size, @@ -123,7 +119,6 @@ namespace OpenSim.Region.Physics.OdePlugin // linksets *should* be in a space together.. but are not currently if (m_isphysical) m_targetSpace = _parent_scene.space; - } m_primName = primName; @@ -147,25 +142,28 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetQuaternion(prim_geom, ref myrot); - if (m_isphysical && Body == (IntPtr)0) + if (m_isphysical && Body == (IntPtr) 0) { enableBody(); } parent_scene.geom_name_map[prim_geom] = primName; - parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; + parent_scene.actor_name_map[prim_geom] = (PhysicsActor) this; // don't do .add() here; old geoms get recycled with the same hash } } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public void enableBody() { // Sets the geom to a body @@ -185,13 +183,14 @@ namespace OpenSim.Region.Physics.OdePlugin _parent_scene.addActivePrim(this); } + private float CalculateMass() { float volume = 0; - + // No material is passed to the physics engines yet.. soo.. // we're using the m_density constant in the class definition - + float returnMass = 0; @@ -199,17 +198,17 @@ namespace OpenSim.Region.Physics.OdePlugin { case ProfileShape.Square: // Profile Volume - - volume = _size.X * _size.Y * _size.Z; + + volume = _size.X*_size.Y*_size.Z; // If the user has 'hollowed out' // ProfileHollow is one of those 0 to 50000 values :P // we like percentages better.. so turning into a percentage - if (((float)_pbs.ProfileHollow / 50000f) > 0.0) + if (((float) _pbs.ProfileHollow/50000f) > 0.0) { - float hollowAmount = (float)_pbs.ProfileHollow / 50000f; - + float hollowAmount = (float) _pbs.ProfileHollow/50000f; + // calculate the hollow volume by it's shape compared to the prim shape float hollowVolume = 0; switch (_pbs.HollowShape) @@ -217,29 +216,29 @@ namespace OpenSim.Region.Physics.OdePlugin case HollowShape.Square: case HollowShape.Same: // Cube Hollow volume calculation - float hollowsizex = _size.X * hollowAmount; - float hollowsizey = _size.Y * hollowAmount; - float hollowsizez = _size.Z * hollowAmount; - hollowVolume = hollowsizex * hollowsizey * hollowsizez; + float hollowsizex = _size.X*hollowAmount; + float hollowsizey = _size.Y*hollowAmount; + float hollowsizez = _size.Z*hollowAmount; + hollowVolume = hollowsizex*hollowsizey*hollowsizez; break; case HollowShape.Circle: // Hollow shape is a perfect cyllinder in respect to the cube's scale // Cyllinder hollow volume calculation - float hRadius = _size.X / 2; + float hRadius = _size.X/2; float hLength = _size.Z; // pi * r2 * h - hollowVolume = ((float)(Math.PI * Math.Pow(hRadius, 2) * hLength) * hollowAmount); + hollowVolume = ((float) (Math.PI*Math.Pow(hRadius, 2)*hLength)*hollowAmount); break; case HollowShape.Triangle: // Equilateral Triangular Prism volume hollow calculation // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y - float aLength = _size.Y; + float aLength = _size.Y; // 1/2 abh - hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount); + hollowVolume = (float) ((0.5*aLength*_size.X*_size.Z)*hollowAmount); break; default: @@ -247,15 +246,14 @@ namespace OpenSim.Region.Physics.OdePlugin break; } volume = volume - hollowVolume; - } - + break; default: // we don't have all of the volume formulas yet so // use the common volume formula for all - volume = _size.X * _size.Y * _size.Z; + volume = _size.X*_size.Y*_size.Z; break; } @@ -273,70 +271,70 @@ namespace OpenSim.Region.Physics.OdePlugin float PathCutStartAmount = _pbs.ProfileBegin; if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f) { + float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount)/50000f); - float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount) / 50000f); - // Check the return amount for sanity - if (pathCutAmount >= 0.99f) - pathCutAmount=0.99f; + if (pathCutAmount >= 0.99f) + pathCutAmount = 0.99f; - volume = volume - (volume * pathCutAmount); + volume = volume - (volume*pathCutAmount); } - + // Mass = density * volume - returnMass = m_density * volume; + returnMass = m_density*volume; return returnMass; } public void setMass() - { - if (Body != (IntPtr)0) + { + if (Body != (IntPtr) 0) { d.MassSetBoxTotal(out pMass, CalculateMass(), _size.X, _size.Y, _size.Z); d.BodySetMass(Body, ref pMass); } } - public void disableBody() { //this kills the body so things like 'mesh' can re-create it. - if (Body != (IntPtr)0) + if (Body != (IntPtr) 0) { _parent_scene.remActivePrim(this); d.BodyDestroy(Body); - Body = (IntPtr)0; + Body = (IntPtr) 0; } } + public void setMesh(OdeScene parent_scene, IMesh mesh) { //Kill Body so that mesh can re-make the geom - if (IsPhysical && Body != (IntPtr)0) + if (IsPhysical && Body != (IntPtr) 0) { disableBody(); } float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage - int VertexCount = vertexList.GetLength(0) / 3; + int VertexCount = vertexList.GetLength(0)/3; int IndexCount = indexList.GetLength(0); - + _triMeshData = d.GeomTriMeshDataCreate(); - d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3 * sizeof(float), VertexCount, indexList, IndexCount, - 3 * sizeof(int)); + d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3*sizeof (float), VertexCount, indexList, IndexCount, + 3*sizeof (int)); d.GeomTriMeshDataPreprocess(_triMeshData); prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null); - - if (IsPhysical && Body == (IntPtr)0) + + if (IsPhysical && Body == (IntPtr) 0) { // Recreate the body enableBody(); } } + public void ProcessTaints(float timestep) { if (m_taintposition != _position) @@ -357,14 +355,14 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_taintshape) changeshape(timestep); // - } + public void Move(float timestep) { if (m_isphysical) { // This is a fallback.. May no longer be necessary. - if (Body == (IntPtr)0) + if (Body == (IntPtr) 0) enableBody(); //Prim auto disable after 20 frames, ///if you move it, re-enable the prim manually. @@ -382,35 +380,35 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintposition = _position; } + public void rotate(float timestep) { - d.Quaternion myrot = new d.Quaternion(); myrot.W = _orientation.w; myrot.X = _orientation.x; myrot.Y = _orientation.y; myrot.Z = _orientation.z; d.GeomSetQuaternion(prim_geom, ref myrot); - if (m_isphysical && Body != (IntPtr)0) + if (m_isphysical && Body != (IntPtr) 0) { d.BodySetQuaternion(Body, ref myrot); } m_taintrot = _orientation; } + public void changePhysicsStatus(float timestap) { if (m_isphysical == true) { - if (Body == (IntPtr)0) + if (Body == (IntPtr) 0) { enableBody(); } - } else { - if (Body != (IntPtr)0) + if (Body != (IntPtr) 0) { disableBody(); } @@ -419,6 +417,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintPhysics = m_isphysical; } + public void changesize(float timestamp) { string oldname = _parent_scene.geom_name_map[prim_geom]; @@ -429,7 +428,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Cleanup meshing here } //kill body to rebuild - if (IsPhysical && Body != (IntPtr)0) + if (IsPhysical && Body != (IntPtr) 0) { disableBody(); } @@ -442,10 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin // we don't need to do space calculation because the client sends a position update also. // Construction of new prim - if (this._parent_scene.needsMeshing(_pbs)) + if (_parent_scene.needsMeshing(_pbs)) { - - // Don't need to re-enable body.. it's done in SetMesh IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); // createmesh returns null when it's a shape that isn't a cube. @@ -463,8 +460,6 @@ namespace OpenSim.Region.Physics.OdePlugin myrot.Y = _orientation.y; myrot.Z = _orientation.z; d.GeomSetQuaternion(prim_geom, ref myrot); - - } } else @@ -480,7 +475,7 @@ namespace OpenSim.Region.Physics.OdePlugin //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); - if (IsPhysical && Body == (IntPtr)0) + if (IsPhysical && Body == (IntPtr) 0) { // Re creates body on size. // EnableBody also does setMass() @@ -493,12 +488,13 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintsize = _size; } + public void changeshape(float timestamp) { string oldname = _parent_scene.geom_name_map[prim_geom]; // Cleanup of old prim geometry and Bodies - if (IsPhysical && Body != (IntPtr)0) + if (IsPhysical && Body != (IntPtr) 0) { disableBody(); } @@ -509,7 +505,7 @@ namespace OpenSim.Region.Physics.OdePlugin } // Construction of new prim - if (this._parent_scene.needsMeshing(_pbs)) + if (_parent_scene.needsMeshing(_pbs)) { IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); if (mesh != null) @@ -525,7 +521,7 @@ namespace OpenSim.Region.Physics.OdePlugin { prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); } - if (IsPhysical && Body == (IntPtr)0) + if (IsPhysical && Body == (IntPtr) 0) { //re-create new body enableBody(); @@ -544,11 +540,13 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintshape = false; } + public override bool IsPhysical { get { return m_isphysical; } set { m_isphysical = value; } } + public void setPrimForRemoval() { m_taintremove = true; @@ -556,9 +554,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override bool Flying { - get - { - return false; //no flying prims for you + get { return false; //no flying prims for you } set { } } @@ -568,16 +564,19 @@ namespace OpenSim.Region.Physics.OdePlugin get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return m_throttleUpdates; } @@ -588,20 +587,13 @@ namespace OpenSim.Region.Physics.OdePlugin { get { return _position; } - set - { - _position = value; - - } + set { _position = value; } } public override PhysicsVector Size { get { return _size; } - set - { - _size = value; - } + set { _size = value; } } public override float Mass @@ -626,10 +618,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override PrimitiveBaseShape Shape { - set - { - _pbs = value; - } + set { _pbs = value; } } public override PhysicsVector Velocity @@ -639,9 +628,9 @@ namespace OpenSim.Region.Physics.OdePlugin // Averate previous velocity with the new one so // client object interpolation works a 'little' better PhysicsVector returnVelocity = new PhysicsVector(); - returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2; - returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2; - returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2; + returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; + returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2; + returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2; return returnVelocity; } set { _velocity = value; } @@ -656,11 +645,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override Quaternion Orientation { get { return _orientation; } - set - { - _orientation = value; - - } + set { _orientation = value; } } public override PhysicsVector Acceleration @@ -688,7 +673,7 @@ namespace OpenSim.Region.Physics.OdePlugin { // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! - if (Body != (IntPtr)0) + if (Body != (IntPtr) 0) { d.Vector3 vec = d.BodyGetPosition(Body); d.Quaternion ori = d.BodyGetQuaternion(Body); @@ -715,8 +700,6 @@ namespace OpenSim.Region.Physics.OdePlugin // It's a hack and will generate a console message if it fails. - - //IsPhysical = false; base.RaiseOutOfBounds(_position); _velocity.X = 0; @@ -736,7 +719,6 @@ namespace OpenSim.Region.Physics.OdePlugin && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)) { - _zeroFlag = true; } else @@ -746,7 +728,6 @@ namespace OpenSim.Region.Physics.OdePlugin } - if (_zeroFlag) { // Supposedly this is supposed to tell SceneObjectGroup that @@ -811,10 +792,10 @@ namespace OpenSim.Region.Physics.OdePlugin m_rotationalVelocity.Z = 0; _zeroFlag = true; } - } + public override void SetMomentum(PhysicsVector momentum) { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 8bb822e..f2c9b57 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; +using System.Runtime.InteropServices; using Axiom.Math; using Ode.NET; using OpenSim.Framework; @@ -99,17 +100,17 @@ namespace OpenSim.Region.Physics.OdePlugin private d.Contact TerrainContact; private d.Contact AvatarMovementprimContact; private d.Contact AvatarMovementTerrainContact; - + private int m_physicsiterations = 10; private float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag private PhysicsActor PANull = new NullPhysicsActor(); private float step_time = 0.0f; public IntPtr world; - + public IntPtr space; // split static geometry collision handling into spaces of 30 meters - public IntPtr[,] staticPrimspace = new IntPtr[(int)(300/metersInSpace),(int)(300/metersInSpace)]; - + public IntPtr[,] staticPrimspace = new IntPtr[(int) (300/metersInSpace),(int) (300/metersInSpace)]; + public static Object OdeLock = new Object(); public IMesher mesher; @@ -126,7 +127,7 @@ namespace OpenSim.Region.Physics.OdePlugin contact.surface.soft_erp = 0.005f; contact.surface.soft_cfm = 0.00003f; */ - + contact.surface.mu = 250.0f; contact.surface.bounce = 0.2f; @@ -151,7 +152,7 @@ namespace OpenSim.Region.Physics.OdePlugin contactgroup = d.JointGroupCreate(0); //contactgroup - + d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f); d.WorldSetAutoDisableFlag(world, false); d.WorldSetContactSurfaceLayer(world, 0.001f); @@ -165,10 +166,9 @@ namespace OpenSim.Region.Physics.OdePlugin { for (int j = 0; j < staticPrimspace.GetLength(1); j++) { - staticPrimspace[i,j] = IntPtr.Zero; + staticPrimspace[i, j] = IntPtr.Zero; } } - } public override void Initialise(IMesher meshmerizer) @@ -184,25 +184,25 @@ namespace OpenSim.Region.Physics.OdePlugin private void near(IntPtr space, IntPtr g1, IntPtr g2) { // no lock here! It's invoked from within Simulate(), which is thread-locked - if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2) ) + if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) { // Separating static prim geometry spaces. // We'll be calling near recursivly if one // of them is a space to find all of the // contact points in the space - + d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); //Colliding a space or a geom with a space or a geom. //Collide all geoms in each space.. //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); - } - else + } + else { // Colliding Geom To Geom // This portion of the function 'was' blatantly ripped off from BoxStack.cs - + IntPtr b1 = d.GeomGetBody(g1); IntPtr b2 = d.GeomGetBody(g2); @@ -213,7 +213,7 @@ namespace OpenSim.Region.Physics.OdePlugin return; d.GeomClassID id = d.GeomGetClass(g1); - + String name1 = null; String name2 = null; @@ -228,21 +228,22 @@ namespace OpenSim.Region.Physics.OdePlugin if (id == d.GeomClassID.TriMeshClass) { - // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); + // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); } - + int count = 0; try { count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); } - catch (System.Runtime.InteropServices.SEHException) + catch (SEHException) { - MainLog.Instance.Error("PHYSICS", "The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); + MainLog.Instance.Error("PHYSICS", + "The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); base.TriggerPhysicsBasedRestart(); } - + for (int i = 0; i < count; i++) { IntPtr joint; @@ -263,17 +264,17 @@ namespace OpenSim.Region.Physics.OdePlugin // We only need to test p2 for 'jump crouch purposes' p2.IsColliding = true; - - switch(p1.PhysicsActorType) { - case (int)ActorTypes.Agent: + switch (p1.PhysicsActorType) + { + case (int) ActorTypes.Agent: p2.CollidingObj = true; break; - case (int)ActorTypes.Prim: - if (p2.Velocity.X >0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) + case (int) ActorTypes.Prim: + if (p2.Velocity.X > 0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) p2.CollidingObj = true; break; - case (int)ActorTypes.Unknown: + case (int) ActorTypes.Unknown: p2.CollidingGround = true; break; default: @@ -282,7 +283,9 @@ namespace OpenSim.Region.Physics.OdePlugin } // we don't want prim or avatar to explode + #region InterPenetration Handling - Unintended physics explosions + if (contacts[i].depth >= 0.08f) { if (contacts[i].depth >= 1.00f) @@ -290,30 +293,31 @@ namespace OpenSim.Region.Physics.OdePlugin //MainLog.Instance.Debug("PHYSICS",contacts[i].depth.ToString()); } // If you interpenetrate a prim with an agent - if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Prim) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Prim)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent && + p1.PhysicsActorType == (int) ActorTypes.Prim) || + (p1.PhysicsActorType == (int) ActorTypes.Agent && + p2.PhysicsActorType == (int) ActorTypes.Prim)) { - - if (p2.PhysicsActorType == (int)ActorTypes.Agent) + if (p2.PhysicsActorType == (int) ActorTypes.Agent) { p2.CollidingObj = true; //contacts[i].depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); - OdeCharacter character = (OdeCharacter)p2; + OdeCharacter character = (OdeCharacter) p2; character.SetPidStatus(true); //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); - } else { contacts[i].depth = 0.0000000f; } - if (p1.PhysicsActorType == (int)ActorTypes.Agent) + if (p1.PhysicsActorType == (int) ActorTypes.Agent) { p1.CollidingObj = true; //contacts[i].depth = 0.003f; p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); //contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2)); - OdeCharacter character = (OdeCharacter)p2; + OdeCharacter character = (OdeCharacter) p2; character.SetPidStatus(true); } else @@ -322,39 +326,45 @@ namespace OpenSim.Region.Physics.OdePlugin } } // If you interpenetrate a prim with another prim - if (p1.PhysicsActorType == (int)ActorTypes.Prim && p2.PhysicsActorType == (int)ActorTypes.Prim) + if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim) { // Don't collide, one or both prim will explode. contacts[i].depth = -1f; } if (contacts[i].depth >= 1.00f) { - if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Unknown) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Unknown)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent && + p1.PhysicsActorType == (int) ActorTypes.Unknown) || + (p1.PhysicsActorType == (int) ActorTypes.Agent && + p2.PhysicsActorType == (int) ActorTypes.Unknown)) { - - if (p2.PhysicsActorType == (int)ActorTypes.Agent) + if (p2.PhysicsActorType == (int) ActorTypes.Agent) { - OdeCharacter character = (OdeCharacter)p2; - + OdeCharacter character = (OdeCharacter) p2; + //p2.CollidingObj = true; contacts[i].depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); - contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); + contacts[i].pos = + new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), + contacts[i].pos.Y + (p1.Size.Y/2), + contacts[i].pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); - } else { - } - if (p1.PhysicsActorType == (int)ActorTypes.Agent) + if (p1.PhysicsActorType == (int) ActorTypes.Agent) { - OdeCharacter character = (OdeCharacter)p2; + OdeCharacter character = (OdeCharacter) p2; //p2.CollidingObj = true; contacts[i].depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); - contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); + contacts[i].pos = + new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), + contacts[i].pos.Y + (p1.Size.Y/2), + contacts[i].pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); } else @@ -364,18 +374,18 @@ namespace OpenSim.Region.Physics.OdePlugin } } } + #endregion if (contacts[i].depth >= 0f) { if (name1 == "Terrain" || name2 == "Terrain") { - - if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && + (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) { AvatarMovementTerrainContact.geom = contacts[i]; joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); - } else { @@ -385,11 +395,11 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) + if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && + (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) { AvatarMovementprimContact.geom = contacts[i]; joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); - } else { @@ -399,7 +409,7 @@ namespace OpenSim.Region.Physics.OdePlugin } d.JointAttach(joint, b1, b2); } - + if (count > 3) { p2.ThrottleUpdates = true; @@ -421,7 +431,7 @@ namespace OpenSim.Region.Physics.OdePlugin } // If the sim is running slow this frame, // don't process collision for prim! - if (timeStep < (m_SkipFramesAtms / 3)) + if (timeStep < (m_SkipFramesAtms/3)) { foreach (OdePrim chr in _activeprims) { @@ -432,16 +442,16 @@ namespace OpenSim.Region.Physics.OdePlugin //foreach (OdePrim ch2 in _prims) /// should be a separate space -- lots of avatars will be N**2 slow //{ - //if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body)) - //{ - // Only test prim that are 0.03 meters away in one direction. - // This should be Optimized! - - //if ((Math.Abs(ch2.Position.X - chr.Position.X) < 0.03) || (Math.Abs(ch2.Position.Y - chr.Position.Y) < 0.03) || (Math.Abs(ch2.Position.X - chr.Position.X) < 0.03)) - //{ - //d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback); - //} - //} + //if (ch2.IsPhysical && d.BodyIsEnabled(ch2.Body)) + //{ + // Only test prim that are 0.03 meters away in one direction. + // This should be Optimized! + + //if ((Math.Abs(ch2.Position.X - chr.Position.X) < 0.03) || (Math.Abs(ch2.Position.Y - chr.Position.Y) < 0.03) || (Math.Abs(ch2.Position.X - chr.Position.X) < 0.03)) + //{ + //d.SpaceCollide2(chr.prim_geom, ch2.prim_geom, IntPtr.Zero, nearCallback); + //} + //} //} } } @@ -456,7 +466,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (d.BodyIsEnabled(chr.Body)) { d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback); - } } } @@ -492,7 +501,6 @@ namespace OpenSim.Region.Physics.OdePlugin p.setPrimForRemoval(); AddPhysicsActorTaint(prim); - } } } @@ -519,13 +527,14 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'removeprim from scene':" + + ((OdePrim) prim).m_targetSpace.ToString()); } } } - //If there are no more geometries in the sub-space, we don't need it in the main space anymore if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) { @@ -541,17 +550,18 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'removeprim from scene':" + ((OdePrim)prim).m_targetSpace.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'removeprim from scene':" + + ((OdePrim) prim).m_targetSpace.ToString()); } } - } + } } d.GeomDestroy(prim.prim_geom); _prims.Remove(prim); } - } public void resetSpaceArrayItemToZero(IntPtr space) @@ -566,7 +576,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } - public void resetSpaceArrayItemToZero(int arrayitemX,int arrayitemY) + public void resetSpaceArrayItemToZero(int arrayitemX, int arrayitemY) { staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero; } @@ -582,16 +592,17 @@ namespace OpenSim.Region.Physics.OdePlugin // never be called if the prim is physical(active) if (currentspace != space) { - if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr)0) + if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr) 0) { if (d.GeomIsSpace(currentspace)) { - d.SpaceRemove(currentspace, geom); } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + + " Geom:" + geom.ToString()); } } else @@ -599,7 +610,7 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr sGeomIsIn = d.GeomGetSpace(geom); if (!(sGeomIsIn.Equals(null))) { - if (sGeomIsIn != (IntPtr)0) + if (sGeomIsIn != (IntPtr) 0) { if (d.GeomIsSpace(currentspace)) { @@ -607,7 +618,9 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); } } } @@ -617,7 +630,7 @@ namespace OpenSim.Region.Physics.OdePlugin //If there are no more geometries in the sub-space, we don't need it in the main space anymore if (d.SpaceGetNumGeoms(currentspace) == 0) { - if (currentspace != (IntPtr)0) + if (currentspace != (IntPtr) 0) { if (d.GeomIsSpace(currentspace)) { @@ -628,9 +641,10 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + currentspace.ToString() + " Geom:" + geom.ToString()); } - } } } @@ -639,15 +653,16 @@ namespace OpenSim.Region.Physics.OdePlugin // this is a physical object that got disabled. ;.; if (d.SpaceQuery(currentspace, geom)) { - if (currentspace != (IntPtr)0) + if (currentspace != (IntPtr) 0) if (d.GeomIsSpace(currentspace)) { d.SpaceRemove(currentspace, geom); } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + " Geom:" + geom.ToString()); - + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + currentspace.ToString() + " Geom:" + geom.ToString()); } } else @@ -655,7 +670,7 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr sGeomIsIn = d.GeomGetSpace(geom); if (!(sGeomIsIn.Equals(null))) { - if (sGeomIsIn != (IntPtr)0) + if (sGeomIsIn != (IntPtr) 0) { if (d.GeomIsSpace(sGeomIsIn)) { @@ -663,14 +678,16 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); + MainLog.Instance.Verbose("Physics", + "Invalid Scene passed to 'recalculatespace':" + + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); } } } } } - + // The routines in the Position and Size sections do the 'inserting' into the space, // so all we have to do is make sure that the space that we're putting the prim into // is in the 'main' space. @@ -679,17 +696,18 @@ namespace OpenSim.Region.Physics.OdePlugin if (newspace == IntPtr.Zero) { - newspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]); + newspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); d.HashSpaceSetLevels(newspace, -4, 66); } - + return newspace; } - public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) { + public IntPtr createprimspace(int iprimspaceArrItemX, int iprimspaceArrItemY) + { // creating a new space for prim and inserting it into main space. staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); - d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX,iprimspaceArrItemY]); + d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; } @@ -697,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin { int[] xyspace = calculateSpaceArrayItemFromPos(pos); //MainLog.Instance.Verbose("Physics", "Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); - IntPtr locationbasedspace = staticPrimspace[xyspace[0],xyspace[1]]; + IntPtr locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]]; //locationbasedspace = space; return locationbasedspace; @@ -706,17 +724,17 @@ namespace OpenSim.Region.Physics.OdePlugin public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) { int[] returnint = new int[2]; - - returnint[0] = (int)(pos.X / metersInSpace); - - if (returnint[0] > ((int)(259f / metersInSpace))) - returnint[0] = ((int)(259f / metersInSpace)); + + returnint[0] = (int) (pos.X/metersInSpace); + + if (returnint[0] > ((int) (259f/metersInSpace))) + returnint[0] = ((int) (259f/metersInSpace)); if (returnint[0] < 0) returnint[0] = 0; - returnint[1] = (int)(pos.Y / metersInSpace); - if (returnint[0] > ((int)(259f / metersInSpace))) - returnint[0] = ((int)(259f / metersInSpace)); + returnint[1] = (int) (pos.Y/metersInSpace); + if (returnint[0] > ((int) (259f/metersInSpace))) + returnint[0] = ((int) (259f/metersInSpace)); if (returnint[0] < 0) returnint[0] = 0; @@ -726,7 +744,6 @@ namespace OpenSim.Region.Physics.OdePlugin private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) { - PhysicsVector pos = new PhysicsVector(); pos.X = position.X; pos.Y = position.Y; @@ -741,21 +758,21 @@ namespace OpenSim.Region.Physics.OdePlugin rot.y = rotation.y; rot.z = rotation.z; - + int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); IntPtr targetspace = calculateSpaceForGeom(pos); if (targetspace == IntPtr.Zero) - targetspace = createprimspace(iprimspaceArrItem[0],iprimspaceArrItem[1]); + targetspace = createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); OdePrim newPrim; lock (OdeLock) { newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical); - + _prims.Add(newPrim); } - + return newPrim; } @@ -763,16 +780,14 @@ namespace OpenSim.Region.Physics.OdePlugin { // adds active prim.. (ones that should be iterated over in collisions_optimized - _activeprims.Add(activatePrim); - + _activeprims.Add(activatePrim); } + public void remActivePrim(OdePrim deactivatePrim) { - - _activeprims.Remove(deactivatePrim); - - + _activeprims.Remove(deactivatePrim); } + public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount) { /* String name1 = null; @@ -818,7 +833,7 @@ namespace OpenSim.Region.Physics.OdePlugin return 1; } - + public bool needsMeshing(PrimitiveBaseShape pbs) { if (pbs.ProfileHollow != 0) @@ -833,7 +848,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) //To be removed { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, @@ -848,12 +863,12 @@ namespace OpenSim.Region.Physics.OdePlugin /// support simple box & hollow box now; later, more shapes if (needsMeshing(pbs)) { - mesh = mesher.CreateMesh(primName, pbs, size); + mesh = mesher.CreateMesh(primName, pbs, size); } - + break; } - + result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); @@ -864,10 +879,9 @@ namespace OpenSim.Region.Physics.OdePlugin { if (prim is OdePrim) { - OdePrim taintedprim = ((OdePrim)prim); + OdePrim taintedprim = ((OdePrim) prim); if (!(_taintedPrim.Contains(taintedprim))) _taintedPrim.Add(taintedprim); - } } @@ -877,19 +891,18 @@ namespace OpenSim.Region.Physics.OdePlugin step_time += timeStep; - - // If We're loaded down by something else, - // or debugging with the Visual Studio project on pause - // skip a few frames to catch up gracefully. - // without shooting the physicsactors all over the place - + + // If We're loaded down by something else, + // or debugging with the Visual Studio project on pause + // skip a few frames to catch up gracefully. + // without shooting the physicsactors all over the place if (step_time >= m_SkipFramesAtms) { // Instead of trying to catch up, it'll do one physics frame only step_time = ODE_STEPSIZE; - this.m_physicsiterations = 5; + m_physicsiterations = 5; } else { @@ -897,35 +910,36 @@ namespace OpenSim.Region.Physics.OdePlugin } lock (OdeLock) { - // Process 10 frames if the sim is running normal.. - // process 5 frames if the sim is running slow - try{ + // Process 10 frames if the sim is running normal.. + // process 5 frames if the sim is running slow + try + { d.WorldSetQuickStepNumIterations(world, m_physicsiterations); } - catch (System.StackOverflowException) + catch (StackOverflowException) { - MainLog.Instance.Error("PHYSICS", "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); + MainLog.Instance.Error("PHYSICS", + "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); base.TriggerPhysicsBasedRestart(); } int i = 0; - - + + // Figure out the Frames Per Second we're going at. - - fps = (((step_time / ODE_STEPSIZE * m_physicsiterations)*2)* 10); - + + fps = (((step_time/ODE_STEPSIZE*m_physicsiterations)*2)*10); + while (step_time > 0.0f) { - foreach (OdeCharacter actor in _characters) { - actor.Move(timeStep); - actor.collidelock = true; + actor.Move(timeStep); + actor.collidelock = true; } - + collision_optimized(timeStep); d.WorldQuickStep(world, ODE_STEPSIZE); d.JointGroupEmpty(contactgroup); @@ -933,7 +947,7 @@ namespace OpenSim.Region.Physics.OdePlugin { actor.collidelock = false; } - + step_time -= ODE_STEPSIZE; i++; } @@ -941,7 +955,6 @@ namespace OpenSim.Region.Physics.OdePlugin foreach (OdeCharacter actor in _characters) { actor.UpdatePositionAndVelocity(); - } bool processedtaints = false; foreach (OdePrim prim in _taintedPrim) @@ -963,7 +976,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (actor.IsPhysical && (d.BodyIsEnabled(actor.Body) || !actor._zeroFlag)) { actor.UpdatePositionAndVelocity(); - } } } @@ -984,25 +996,25 @@ namespace OpenSim.Region.Physics.OdePlugin public float[] ResizeTerrain512(float[] heightMap) { float[] returnarr = new float[262144]; - float[,] resultarr = new float[m_regionWidth, m_regionHeight]; + float[,] resultarr = new float[m_regionWidth,m_regionHeight]; // Filling out the array into it's multi-dimentional components for (int y = 0; y < m_regionHeight; y++) { for (int x = 0; x < m_regionWidth; x++) { - resultarr[y,x] = heightMap[y * m_regionWidth + x]; + resultarr[y, x] = heightMap[y*m_regionWidth + x]; } } // Resize using interpolation - + // This particular way is quick but it only works on a multiple of the original // The idea behind this method can be described with the following diagrams // second pass and third pass happen in the same loop really.. just separated // them to show what this does. - + // First Pass // ResultArr: // 1,1,1,1,1,1 @@ -1054,12 +1066,12 @@ namespace OpenSim.Region.Physics.OdePlugin // 4th # // on single loop. - float[,] resultarr2 = new float[512, 512]; + float[,] resultarr2 = new float[512,512]; for (int y = 0; y < m_regionHeight; y++) { for (int x = 0; x < m_regionWidth; x++) { - resultarr2[y*2,x*2] = resultarr[y,x]; + resultarr2[y*2, x*2] = resultarr[y, x]; if (y < m_regionHeight) { @@ -1067,16 +1079,17 @@ namespace OpenSim.Region.Physics.OdePlugin { if (x + 1 < m_regionWidth) { - resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x+1] + resultarr[y+1, x+1])/4); + resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] + + resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); } else { - resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x]) / 2); + resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x])/2); } } else { - resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; + resultarr2[(y*2) + 1, x*2] = resultarr[y, x]; } } if (x < m_regionWidth) @@ -1085,31 +1098,32 @@ namespace OpenSim.Region.Physics.OdePlugin { if (y + 1 < m_regionHeight) { - resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); + resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + + resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); } else { - resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1]) / 2); + resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1])/2); } } else { - resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x]; + resultarr2[y*2, (x*2) + 1] = resultarr[y, x]; } } if (x < m_regionWidth && y < m_regionHeight) { if ((x + 1 < m_regionWidth) && (y + 1 < m_regionHeight)) { - resultarr2[(y * 2) + 1, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); + resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + + resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); } else { - resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x]; + resultarr2[(y*2) + 1, (x*2) + 1] = resultarr[y, x]; } } } - } //Flatten out the array int i = 0; @@ -1119,7 +1133,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (resultarr2[y, x] <= 0) returnarr[i] = 0.0000001f; - else + else returnarr[i] = resultarr2[y, x]; i++; @@ -1127,8 +1141,8 @@ namespace OpenSim.Region.Physics.OdePlugin } return returnarr; - } + public override void SetTerrain(float[] heightMap) { // this._heightmap[i] = (double)heightMap[i]; @@ -1137,8 +1151,8 @@ namespace OpenSim.Region.Physics.OdePlugin const uint heightmapWidth = m_regionWidth + 2; const uint heightmapHeight = m_regionHeight + 2; - const uint heightmapWidthSamples = 2 * m_regionWidth + 2; - const uint heightmapHeightSamples = 2 * m_regionHeight + 2; + const uint heightmapWidthSamples = 2*m_regionWidth + 2; + const uint heightmapHeightSamples = 2*m_regionHeight + 2; const float scale = 1.0f; const float offset = 0.0f; const float thickness = 2.0f; @@ -1166,7 +1180,8 @@ namespace OpenSim.Region.Physics.OdePlugin } IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight, - (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale, offset, thickness, wrap); + (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale, + offset, thickness, wrap); d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); LandGeom = d.CreateHeightfield(space, HeightmapData, 1); geom_name_map[LandGeom] = "Terrain"; @@ -1193,7 +1208,4 @@ namespace OpenSim.Region.Physics.OdePlugin { } } - - - -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs index da9f587..3bb71d4 100644 --- a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 26310f9..1bc3490 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -25,8 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System.Collections.Generic; using System; +using System.Collections.Generic; using Axiom.Math; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; @@ -114,10 +114,10 @@ namespace OpenSim.Region.Physics.POSPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } - public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { POSPrim prim = new POSPrim(); @@ -136,18 +136,20 @@ namespace OpenSim.Region.Physics.POSPlugin " sizeX: " + p.Size.X * 0.5 + 0.5); */ - Vector3 rotatedPos = p.Orientation.Inverse() * new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y, c.Position.Z - p.Position.Z); - Vector3 avatarSize = p.Orientation.Inverse() * new Vector3(c.Size.X, c.Size.Y, c.Size.Z); + Vector3 rotatedPos = p.Orientation.Inverse()* + new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y, + c.Position.Z - p.Position.Z); + Vector3 avatarSize = p.Orientation.Inverse()*new Vector3(c.Size.X, c.Size.Y, c.Size.Z); - if (Math.Abs(rotatedPos.x) >= (p.Size.X * 0.5 + Math.Abs(avatarSize.x))) + if (Math.Abs(rotatedPos.x) >= (p.Size.X*0.5 + Math.Abs(avatarSize.x))) { return false; } - if (Math.Abs(rotatedPos.y) >= (p.Size.Y * 0.5 + Math.Abs(avatarSize.y))) + if (Math.Abs(rotatedPos.y) >= (p.Size.Y*0.5 + Math.Abs(avatarSize.y))) { return false; } - if (Math.Abs(rotatedPos.z) >= (p.Size.Z * 0.5 + Math.Abs(avatarSize.z))) + if (Math.Abs(rotatedPos.z) >= (p.Size.Z*0.5 + Math.Abs(avatarSize.z))) { return false; } @@ -182,12 +184,12 @@ namespace OpenSim.Region.Physics.POSPlugin if (!character.Flying) { - character._target_velocity.Z += gravity * timeStep; + character._target_velocity.Z += gravity*timeStep; } bool forcedZ = false; - character.Position.X += character._target_velocity.X * timeStep; - character.Position.Y += character._target_velocity.Y * timeStep; + character.Position.X += character._target_velocity.X*timeStep; + character.Position.Y += character._target_velocity.Y*timeStep; if (character.Position.Y < 0) { @@ -207,15 +209,15 @@ namespace OpenSim.Region.Physics.POSPlugin character.Position.X = 255.9F; } - float terrainheight = _heightMap[(int)character.Position.Y * 256 + (int)character.Position.X]; - if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) + float terrainheight = _heightMap[(int) character.Position.Y*256 + (int) character.Position.X]; + if (character.Position.Z + (character._target_velocity.Z*timeStep) < terrainheight + 2) { character.Position.Z = terrainheight + 1.0f; forcedZ = true; } else { - character.Position.Z += character._target_velocity.Z * timeStep; + character.Position.Z += character._target_velocity.Z*timeStep; } /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- @@ -224,21 +226,21 @@ namespace OpenSim.Region.Physics.POSPlugin if (check_all_prims(character)) { - character.Position.Z = oldposZ; // first try Z axis + character.Position.Z = oldposZ; // first try Z axis if (check_all_prims(character)) { - character.Position.Z = oldposZ + 0.4f; // try harder + character.Position.Z = oldposZ + 0.4f; // try harder if (check_all_prims(character)) { character.Position.X = oldposX; character.Position.Y = oldposY; character.Position.Z = oldposZ; - character.Position.X = character.Position.X + (character._target_velocity.X * timeStep); + character.Position.X = character.Position.X + (character._target_velocity.X*timeStep); if (check_all_prims(character)) { character.Position.X = oldposX; } - character.Position.Y = character.Position.Y + (character._target_velocity.Y * timeStep); + character.Position.Y = character.Position.Y + (character._target_velocity.Y*timeStep); if (check_all_prims(character)) { character.Position.Y = oldposY; @@ -253,7 +255,7 @@ namespace OpenSim.Region.Physics.POSPlugin { forcedZ = true; } - } + } if (character.Position.Y < 0) { @@ -273,8 +275,8 @@ namespace OpenSim.Region.Physics.POSPlugin character.Position.X = 255.9F; } - character._velocity.X = (character.Position.X - oldposX) / timeStep; - character._velocity.Y = (character.Position.Y - oldposY) / timeStep; + character._velocity.X = (character.Position.X - oldposX)/timeStep; + character._velocity.Y = (character.Position.Y - oldposY)/timeStep; if (forcedZ) { @@ -284,7 +286,7 @@ namespace OpenSim.Region.Physics.POSPlugin } else { - character._velocity.Z = (character.Position.Z - oldposZ) / timeStep; + character._velocity.Z = (character.Position.Z - oldposZ)/timeStep; } } return fps; @@ -326,31 +328,37 @@ namespace OpenSim.Region.Physics.POSPlugin _position = new PhysicsVector(); _acceleration = new PhysicsVector(); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } @@ -362,16 +370,19 @@ namespace OpenSim.Region.Physics.POSPlugin get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get { return _position; } @@ -383,18 +394,22 @@ namespace OpenSim.Region.Physics.POSPlugin get { return new PhysicsVector(0.5f, 0.5f, 1.0f); } set { } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } @@ -402,10 +417,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity @@ -461,41 +473,49 @@ namespace OpenSim.Region.Physics.POSPlugin _position = new PhysicsVector(); _acceleration = new PhysicsVector(); } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool IsColliding { get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get { return _position; } @@ -530,10 +550,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity @@ -571,6 +588,7 @@ namespace OpenSim.Region.Physics.POSPlugin public override void SetMomentum(PhysicsVector momentum) { } + public override bool Flying { get { return false; } @@ -583,4 +601,4 @@ namespace OpenSim.Region.Physics.POSPlugin set { return; } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs index 8e6d2a6..36cb952 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("1.0.*")] +[assembly : AssemblyVersion("1.0.*")] \ No newline at end of file diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 8525e75..20bf358 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -128,17 +128,19 @@ namespace OpenSim.Region.Physics.PhysXPlugin public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) //To be removed { - return this.AddPrimShape(primName, pbs, position, size, rotation, false); + return AddPrimShape(primName, pbs, position, size, rotation, false); } + public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) { return AddPrim(position, size, rotation); } + public override void AddPhysicsActorTaint(PhysicsActor prim) { - } + public override float Simulate(float timeStep) { float fps = 0f; @@ -209,51 +211,61 @@ namespace OpenSim.Region.Physics.PhysXPlugin _acceleration = new PhysicsVector(); _character = character; } + public override int PhysicsActorType { - get { return (int)ActorTypes.Agent; } + get { return (int) ActorTypes.Agent; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override bool Flying { get { return flying; } set { flying = value; } } + public override bool IsColliding { get { return iscolliding; } set { iscolliding = value; } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override PhysicsVector Position { get { return _position; } @@ -273,22 +285,27 @@ namespace OpenSim.Region.Physics.PhysXPlugin get { return PhysicsVector.Zero; } set { } } + public override float Mass { get { return 0f; } } + public override PhysicsVector Force { get { return PhysicsVector.Zero; } } + public override PhysicsVector CenterOfMass { get { return PhysicsVector.Zero; } } + public override PhysicsVector GeometricCenter { get { return PhysicsVector.Zero; } } + public override PhysicsVector Velocity { get { return _velocity; } @@ -345,23 +362,21 @@ namespace OpenSim.Region.Physics.PhysXPlugin gravityAccel = 0; } } + public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } + } + + public void UpdatePosition() + { + Vec3 vec = _character.Position; + _position.X = vec.X; + _position.Y = vec.Y; + _position.Z = vec.Z; } - - public void UpdatePosition() - { - Vec3 vec = this._character.Position; - this._position.X = vec.X; - this._position.Y = vec.Y; - this._position.Z = vec.Z; - } - } - + } + public class PhysXPrim : PhysicsActor { @@ -376,55 +391,62 @@ namespace OpenSim.Region.Physics.PhysXPlugin _acceleration = new PhysicsVector(); _prim = prim; } + public override int PhysicsActorType { - get { return (int)ActorTypes.Prim; } + get { return (int) ActorTypes.Prim; } set { return; } } + public override bool IsPhysical { get { return false; } set { return; } } + public override bool SetAlwaysRun { get { return false; } set { return; } } + public override bool ThrottleUpdates { get { return false; } set { return; } } + public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } set { m_rotationalVelocity = value; } } + public override bool Flying { get { return false; //no flying prims for you } set { } } + public override bool IsColliding { - get - { - return false; - } + get { return false; } set { } } + public override bool CollidingGround { get { return false; } set { return; } } + public override bool CollidingObj { get { return false; } set { return; } } + public override PhysicsVector Position { get @@ -449,75 +471,52 @@ namespace OpenSim.Region.Physics.PhysXPlugin public override PrimitiveBaseShape Shape { - set - { - return; - } + set { return; } } public override PhysicsVector Velocity { - get - { - return _velocity; - } - set - { - _velocity = value; - } + get { return _velocity; } + set { _velocity = value; } } - + public override bool Kinematic { - get - { - return this._prim.Kinematic; - } - set - { - this._prim.Kinematic = value; - } + get { return _prim.Kinematic; } + set { _prim.Kinematic = value; } } - + public override Quaternion Orientation { get { Quaternion res = new Quaternion(); - PhysXWrapper.Quaternion quat = this._prim.GetOrientation(); + PhysXWrapper.Quaternion quat = _prim.GetOrientation(); res.w = quat.W; res.x = quat.X; res.y = quat.Y; res.z = quat.Z; return res; } - set - { - - } + set { } } - + public override PhysicsVector Acceleration { - get - { - return _acceleration; - } - + get { return _acceleration; } } - public void SetAcceleration (PhysicsVector accel) + + public void SetAcceleration(PhysicsVector accel) { - this._acceleration = accel; + _acceleration = accel; } - + public override void AddForce(PhysicsVector force) { - } - + public override void SetMomentum(PhysicsVector momentum) { - } public override PhysicsVector Size @@ -545,6 +544,5 @@ namespace OpenSim.Region.Physics.PhysXPlugin { get { return PhysicsVector.Zero; } } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index 6ba7018..9c595ed 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -634,4 +634,4 @@ namespace OpenSim.Region.ScriptEngine.Common //OpenSim functions string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index 3a0b8ed..232baf8 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (!(o is Vector3)) return false; - Vector3 vector = (Vector3)o; + Vector3 vector = (Vector3) o; return (x == vector.x && x == vector.x && z == vector.z); } @@ -88,11 +88,12 @@ namespace OpenSim.Region.ScriptEngine.Common #endregion #region Vector & Vector Math + // Vector-Vector Math public static Vector3 operator +(Vector3 lhs, Vector3 rhs) { return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); - } + } public static Vector3 operator -(Vector3 lhs, Vector3 rhs) { @@ -101,51 +102,53 @@ namespace OpenSim.Region.ScriptEngine.Common public static Vector3 operator *(Vector3 lhs, Vector3 rhs) { - return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); + return new Vector3(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z); } public static Vector3 operator %(Vector3 v1, Vector3 v2) { //Cross product Vector3 tv; - tv.x = (v1.y * v2.z) - (v1.z * v2.y); - tv.y = (v1.z * v2.x) - (v1.x * v2.z); - tv.z = (v1.x * v2.y) - (v1.y * v2.x); + tv.x = (v1.y*v2.z) - (v1.z*v2.y); + tv.y = (v1.z*v2.x) - (v1.x*v2.z); + tv.z = (v1.x*v2.y) - (v1.y*v2.x); return tv; } #endregion - + #region Vector & Float Math + // Vector-Float and Float-Vector Math public static Vector3 operator *(Vector3 vec, float val) { - return new Vector3(vec.x * val, vec.y * val, vec.z * val); + return new Vector3(vec.x*val, vec.y*val, vec.z*val); } public static Vector3 operator *(float val, Vector3 vec) { - return new Vector3(vec.x * val, vec.y * val, vec.z * val); + return new Vector3(vec.x*val, vec.y*val, vec.z*val); } public static Vector3 operator /(Vector3 v, float f) { - v.x = v.x / f; - v.y = v.y / f; - v.z = v.z / f; + v.x = v.x/f; + v.y = v.y/f; + v.z = v.z/f; return v; } #endregion #region Vector & Rotation Math + // Vector-Rotation Math public static Vector3 operator *(Vector3 v, Quaternion r) { Quaternion vq = new Quaternion(v.x, v.y, v.z, 0); Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s); - Quaternion result = (r * vq) * nq; + Quaternion result = (r*vq)*nq; return new Vector3(result.x, result.y, result.z); } @@ -157,38 +160,41 @@ namespace OpenSim.Region.ScriptEngine.Common Quaternion vq = new Quaternion(vec.x, vec.y, vec.z, 0); Quaternion nq = new Quaternion(-quat.x, -quat.y, -quat.z, quat.s); - Quaternion result = (quat * vq) * nq; + Quaternion result = (quat*vq)*nq; return new Vector3(result.x, result.y, result.z); } + #endregion #region Static Helper Functions + public static double Dot(Vector3 v1, Vector3 v2) { - return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); + return (v1.x*v2.x) + (v1.y*v2.y) + (v1.z*v2.z); } public static Vector3 Cross(Vector3 v1, Vector3 v2) { return new Vector3 - ( - v1.y * v2.z - v1.z * v2.y, - v1.z * v2.x - v1.x * v2.z, - v1.x * v2.y - v1.y * v2.x - ); + ( + v1.y*v2.z - v1.z*v2.y, + v1.z*v2.x - v1.x*v2.z, + v1.x*v2.y - v1.y*v2.x + ); } public static float Mag(Vector3 v) { - return (float)Math.Sqrt(v.x * v.y + v.y * v.y + v.z * v.z); + return (float) Math.Sqrt(v.x*v.y + v.y*v.y + v.z*v.z); } public static Vector3 Norm(Vector3 vector) { float mag = Mag(vector); - return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); + return new Vector3(vector.x/mag, vector.y/mag, vector.z/mag); } + #endregion } @@ -227,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (!(o is Quaternion)) return false; - Quaternion quaternion = (Quaternion)o; + Quaternion quaternion = (Quaternion) o; return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; } @@ -253,10 +259,10 @@ namespace OpenSim.Region.ScriptEngine.Common public static Quaternion operator *(Quaternion a, Quaternion b) { Quaternion c; - c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y; - c.y = a.s * b.y + a.y * b.s + a.z * b.x - a.x * b.z; - c.z = a.s * b.z + a.z * b.s + a.x * b.y - a.y * b.x; - c.s = a.s * b.s - a.x * b.x - a.y * b.y - a.z * b.z; + c.x = a.s*b.x + a.x*b.s + a.y*b.z - a.z*b.y; + c.y = a.s*b.y + a.y*b.s + a.z*b.x - a.x*b.z; + c.z = a.s*b.z + a.z*b.s + a.x*b.y - a.y*b.x; + c.s = a.s*b.s - a.x*b.x - a.y*b.y - a.z*b.z; return c; } } @@ -324,7 +330,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (start >= m_data.Length) { - return this.GetSublist(0, end); + return GetSublist(0, end); } if (end >= m_data.Length) { @@ -334,7 +340,7 @@ namespace OpenSim.Region.ScriptEngine.Common //ret = new object[m_data.Length - Math.Abs(end - start + 1)]; //Array.Copy(m_data, 0, ret, m_data.Length - start, end + 1); //Array.Copy(m_data, start, ret, 0, m_data.Length - start); - return this.GetSublist(0, end) + this.GetSublist(start, this.Data.Length - 1); + return GetSublist(0, end) + GetSublist(start, Data.Length - 1); //return new list(ret); } } @@ -379,4 +385,4 @@ namespace OpenSim.Region.ScriptEngine.Common } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs index e5f7220..4594ad8 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs @@ -52,4 +52,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index c81e6bd..0623cc5 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -39,7 +39,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); private CSharpCodeProvider codeProvider = new CSharpCodeProvider(); private static UInt64 scriptCompileCounter = 0; - private static int instanceID = new Random().Next(0, int.MaxValue); // Implemented due to peer preassure --- will cause garbage in ScriptEngines folder ;) + + private static int instanceID = new Random().Next(0, int.MaxValue); + // Implemented due to peer preassure --- will cause garbage in ScriptEngines folder ;) + //private ICodeCompiler icc = codeProvider.CreateCompiler(); public string CompileFromFile(string LSOFileName) { @@ -83,7 +86,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { // Output assembly name scriptCompileCounter++; - string OutFile = Path.Combine("ScriptEngines", "DotNetScript_" + instanceID.ToString() + "_" + scriptCompileCounter.ToString() + ".dll"); + string OutFile = + Path.Combine("ScriptEngines", + "DotNetScript_" + instanceID.ToString() + "_" + scriptCompileCounter.ToString() + ".dll"); try { File.Delete(OutFile); diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 4063647..8e37798 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -316,8 +316,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL quotes.Clear(); - + return Return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index a9297fd..2796b64 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -1638,7 +1638,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end) { - return m_LSL_Functions.llListReplaceList(dest,src,start,end); + return m_LSL_Functions.llListReplaceList(dest, src, start, end); } public void llLoadURL(string avatar_id, string message, string url) @@ -2025,7 +2025,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public const int REMOTE_DATA_CHANNEL = 1; public const int REMOTE_DATA_REQUEST = 2; public const int REMOTE_DATA_REPLY = 3; - + public const int PRIM_MATERIAL = 2; public const int PRIM_PHYSICS = 3; public const int PRIM_TEMP_ON_REZ = 4; @@ -2041,7 +2041,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public const int PRIM_FLEXIBLE = 21; public const int PRIM_TEXGEN = 22; public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake - public const int PRIM_POINT_LIGHT = 23; // Huh? + public const int PRIM_POINT_LIGHT = 23; // Huh? public const int PRIM_TEXGEN_DEFAULT = 0; public const int PRIM_TEXGEN_PLANAR = 1; public const int PRIM_TYPE_BOX = 0; @@ -2122,4 +2122,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL public vector ZERO_VECTOR = new vector(0, 0, 0); public rotation ZERO_ROTATION = new rotation(0, 0, 0, 0); } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs index bc47241..d5a31fb 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/Server_API/LSL_BuiltIn_Commands.cs @@ -28,13 +28,11 @@ using System; using System.Collections.Generic; -using System.Collections; using System.Runtime.Remoting.Lifetime; using System.Text; using System.Threading; using Axiom.Math; using libsecondlife; -using libsecondlife.StructuredData; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs index 161cedf..8dfd908 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs @@ -217,4 +217,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs index 890335b..2d0d69d 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs @@ -184,9 +184,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { #if DEBUG m_ScriptEngine.Log.Debug("ScriptEngine", "Executing event:\r\n" - + "QIS.localID: " + QIS.localID - + ", QIS.itemID: " + QIS.itemID - + ", QIS.functionName: " + QIS.functionName); + + "QIS.localID: " + QIS.localID + + ", QIS.itemID: " + QIS.itemID + + ", QIS.functionName: " + QIS.functionName); #endif m_ScriptEngine.m_ScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.functionName, QIS.param); @@ -197,14 +197,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine string text = "Error executing script function \"" + QIS.functionName + "\":\r\n"; //if (e.InnerException != null) //{ - // Send inner exception - text += e.InnerException.Message.ToString(); + // Send inner exception + text += e.InnerException.Message.ToString(); //} //else //{ - text += "\r\n"; - // Send normal - text += e.Message.ToString(); + text += "\r\n"; + // Send normal + text += e.Message.ToString(); //} try { @@ -222,7 +222,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //else //{ // T oconsole - m_ScriptEngine.Log.Error("ScriptEngine", "Unable to send text in-world:\r\n" + text); + m_ScriptEngine.Log.Error("ScriptEngine", + "Unable to send text in-world:\r\n" + text); } } finally @@ -338,4 +339,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index fdd7260..e403385 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs @@ -202,17 +202,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public void CheckHttpRequests() { - IHttpRequests iHttpReq = + IHttpRequests iHttpReq = m_ScriptEngine.World.RequestModuleInterface(); HttpRequestClass httpInfo = null; - if( iHttpReq != null ) + if (iHttpReq != null) httpInfo = iHttpReq.GetNextCompletedRequest(); - while ( httpInfo != null ) + while (httpInfo != null) { - //Console.WriteLine("PICKED HTTP REQ:" + httpInfo.response_body + httpInfo.status); // Deliver data to prim's remote_data handler @@ -221,7 +220,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // only returns the byte for HTTP_BODY_TRUNCATED, which is not // implemented here yet anyway. Should be fixed if/when maxsize // is supported - + object[] resobj = new object[] { httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body @@ -254,7 +253,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //Deliver data to prim's remote_data handler object[] resobj = new object[] { - 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", rInfo.GetIntValue(), + 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), "", + rInfo.GetIntValue(), rInfo.GetStrVal() }; m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( @@ -284,4 +284,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index c1c792c..82049f7 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs @@ -121,4 +121,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 6b83dff..e211902 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -224,7 +224,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine #region Start/Stop/Reset script - Object startStopLock = new Object(); + private Object startStopLock = new Object(); /// /// Fetches, loads and hooks up a script to an objects events @@ -261,7 +261,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } // Create a new instance of the compiler (reuse) - Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); + private Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); + private void _StartScript(uint localID, LLUUID itemID, string Script) { lock (startStopLock) @@ -316,7 +317,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine CompiledScript.Start(LSLB); // Fire the first start-event - m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { }); + m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] {}); } catch (Exception e) { @@ -327,12 +328,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine string text = "Error compiling script:\r\n" + e.Message.ToString(); if (text.Length > 1500) text = text.Substring(0, 1500); - World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + World.SimChat(Helpers.StringToField(text), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, + m_host.Name, m_host.UUID); } catch (Exception e2) { m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString()); - m_scriptEngine.Log.Error("ScriptEngine", "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); + m_scriptEngine.Log.Error("ScriptEngine", + "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); } } } @@ -342,39 +345,39 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine { lock (startStopLock) { - // Stop script - Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); + // Stop script + Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); - // Stop long command on script - m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID); + // Stop long command on script + m_scriptEngine.m_LSLLongCmdHandler.RemoveScript(localID, itemID); - LSL_BaseClass LSLBC = GetScript(localID, itemID); - if (LSLBC == null) - return; + LSL_BaseClass LSLBC = GetScript(localID, itemID); + if (LSLBC == null) + return; - // TEMP: First serialize it - //GetSerializedScript(localID, itemID); + // TEMP: First serialize it + //GetSerializedScript(localID, itemID); - try - { - // Get AppDomain - AppDomain ad = LSLBC.Exec.GetAppDomain(); - // Tell script not to accept new requests - GetScript(localID, itemID).Exec.StopScript(); - // Remove from internal structure - RemoveScript(localID, itemID); - // Tell AppDomain that we have stopped script - m_scriptEngine.m_AppDomainManager.StopScript(ad); - } - catch (Exception e) - { - Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + - ": " + e.ToString()); + try + { + // Get AppDomain + AppDomain ad = LSLBC.Exec.GetAppDomain(); + // Tell script not to accept new requests + GetScript(localID, itemID).Exec.StopScript(); + // Remove from internal structure + RemoveScript(localID, itemID); + // Tell AppDomain that we have stopped script + m_scriptEngine.m_AppDomainManager.StopScript(ad); + } + catch (Exception e) + { + Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + + ": " + e.ToString()); + } } } - } private string ProcessYield(string FileName) { @@ -435,4 +438,4 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine #endregion } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs index 60aeb83..5818583 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs @@ -33,8 +33,8 @@ using System.Data.SqlClient; using System.IO; using libsecondlife; using OpenSim.Framework; -using OpenSim.Framework.Data; using OpenSim.Framework.Console; +using OpenSim.Framework.Data; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -62,7 +62,9 @@ namespace OpenSim.DataStore.MSSQL string settingUserId = GridDataMySqlFile.ParseFileReadValue("user_id"); string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); - string connectionString = "Data Source=" + settingDataSource + ";Initial Catalog=" + settingInitialCatalog + ";Persist Security Info=" + settingPersistSecurityInfo + ";User ID=" + settingUserId + ";Password=" + settingPassword + ";"; + string connectionString = "Data Source=" + settingDataSource + ";Initial Catalog=" + settingInitialCatalog + + ";Persist Security Info=" + settingPersistSecurityInfo + ";User ID=" + + settingUserId + ";Password=" + settingPassword + ";"; ds = new DataSet(); @@ -85,11 +87,12 @@ namespace OpenSim.DataStore.MSSQL // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); TestTables(conn); - lock(ds) { + lock (ds) + { ds.Tables.Add(createPrimTable()); setupPrimCommands(primDa, conn); primDa.Fill(ds.Tables["prims"]); - + ds.Tables.Add(createShapeTable()); setupShapeCommands(shapeDa, conn); @@ -122,7 +125,8 @@ namespace OpenSim.DataStore.MSSQL public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) { - lock (ds) { + lock (ds) + { foreach (SceneObjectPart prim in obj.Children.Values) { MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); @@ -140,11 +144,12 @@ namespace OpenSim.DataStore.MSSQL DataTable shapes = ds.Tables["primshapes"]; string selectExp = "SceneGroupID = '" + obj.ToString() + "'"; - lock (ds) { + lock (ds) + { DataRow[] primRows = prims.Select(selectExp); foreach (DataRow row in primRows) { - LLUUID uuid = new LLUUID((string)row["UUID"]); + LLUUID uuid = new LLUUID((string) row["UUID"]); DataRow shapeRow = shapes.Rows.Find(uuid); if (shapeRow != null) { @@ -153,7 +158,7 @@ namespace OpenSim.DataStore.MSSQL row.Delete(); } } - + Commit(); } @@ -169,16 +174,18 @@ namespace OpenSim.DataStore.MSSQL string byRegion = "RegionUUID = '" + regionUUID.ToString() + "'"; string orderByParent = "ParentID ASC"; - lock (ds) { + lock (ds) + { DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); - MainLog.Instance.Verbose("DATASTORE", "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); - + MainLog.Instance.Verbose("DATASTORE", + "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); + foreach (DataRow primRow in primsForRegion) { try { - string uuid = (string)primRow["UUID"]; - string objID = (string)primRow["SceneGroupID"]; + string uuid = (string) primRow["UUID"]; + string objID = (string) primRow["SceneGroupID"]; if (uuid == objID) //is new SceneObjectGroup ? { SceneObjectGroup group = new SceneObjectGroup(); @@ -190,12 +197,13 @@ namespace OpenSim.DataStore.MSSQL } else { - MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape"); + MainLog.Instance.Notice( + "No shape found for prim in storage, so setting default box shape"); prim.Shape = BoxShape.Default; - } + } group.AddPart(prim); group.RootPart = prim; - + createdObjects.Add(group.UUID, group); retvals.Add(group); } @@ -209,7 +217,8 @@ namespace OpenSim.DataStore.MSSQL } else { - MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape"); + MainLog.Instance.Notice( + "No shape found for prim in storage, so setting default box shape"); prim.Shape = BoxShape.Default; } createdObjects[new LLUUID(objID)].AddPart(prim); @@ -249,7 +258,7 @@ namespace OpenSim.DataStore.MSSQL public double[,] LoadTerrain(LLUUID regionID) { - double[,] terret = new double[256, 256]; + double[,] terret = new double[256,256]; terret.Initialize(); DataTable terrain = ds.Tables["terrain"]; @@ -264,16 +273,16 @@ namespace OpenSim.DataStore.MSSQL { DataRow row = rows[0]; - byte[] heightmap = (byte[])row["Heightfield"]; + byte[] heightmap = (byte[]) row["Heightfield"]; for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; y++) { - terret[x, y] = BitConverter.ToDouble(heightmap, ((x * 256) + y) * 8); + terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); } } - rev = (int)row["Revision"]; + rev = (int) row["Revision"]; } else { @@ -290,22 +299,21 @@ namespace OpenSim.DataStore.MSSQL public void RemoveLandObject(LLUUID globalID) { - } public void StoreLandObject(Land parcel, LLUUID regionUUID) { - } - public List LoadLandObjects(LLUUID regionUUID) + public List LoadLandObjects(LLUUID regionUUID) { return new List(); } public void Commit() { - lock (ds) { + lock (ds) + { primDa.Update(ds, "prims"); shapeDa.Update(ds, "primshapes"); terrainDa.Update(ds, "terrain"); @@ -326,7 +334,7 @@ namespace OpenSim.DataStore.MSSQL * **********************************************************************/ - private void createCol(DataTable dt, string name, System.Type type) + private void createCol(DataTable dt, string name, Type type) { DataColumn col = new DataColumn(name, type); dt.Columns.Add(col); @@ -336,9 +344,9 @@ namespace OpenSim.DataStore.MSSQL { DataTable terrain = new DataTable("terrain"); - createCol(terrain, "RegionUUID", typeof(String)); - createCol(terrain, "Revision", typeof(Int32)); - createCol(terrain, "Heightfield", typeof(Byte[])); + createCol(terrain, "RegionUUID", typeof (String)); + createCol(terrain, "Revision", typeof (Int32)); + createCol(terrain, "Heightfield", typeof (Byte[])); return terrain; } @@ -347,62 +355,62 @@ namespace OpenSim.DataStore.MSSQL { DataTable prims = new DataTable("prims"); - createCol(prims, "UUID", typeof(System.String)); - createCol(prims, "RegionUUID", typeof(System.String)); - createCol(prims, "ParentID", typeof(System.Int32)); - createCol(prims, "CreationDate", typeof(System.Int32)); - createCol(prims, "Name", typeof(System.String)); - createCol(prims, "SceneGroupID", typeof(System.String)); + createCol(prims, "UUID", typeof (String)); + createCol(prims, "RegionUUID", typeof (String)); + createCol(prims, "ParentID", typeof (Int32)); + createCol(prims, "CreationDate", typeof (Int32)); + createCol(prims, "Name", typeof (String)); + createCol(prims, "SceneGroupID", typeof (String)); // various text fields - createCol(prims, "Text", typeof(System.String)); - createCol(prims, "Description", typeof(System.String)); - createCol(prims, "SitName", typeof(System.String)); - createCol(prims, "TouchName", typeof(System.String)); + createCol(prims, "Text", typeof (String)); + createCol(prims, "Description", typeof (String)); + createCol(prims, "SitName", typeof (String)); + createCol(prims, "TouchName", typeof (String)); // permissions - createCol(prims, "ObjectFlags", typeof(System.Int32)); - createCol(prims, "CreatorID", typeof(System.String)); - createCol(prims, "OwnerID", typeof(System.String)); - createCol(prims, "GroupID", typeof(System.String)); - createCol(prims, "LastOwnerID", typeof(System.String)); - createCol(prims, "OwnerMask", typeof(System.Int32)); - createCol(prims, "NextOwnerMask", typeof(System.Int32)); - createCol(prims, "GroupMask", typeof(System.Int32)); - createCol(prims, "EveryoneMask", typeof(System.Int32)); - createCol(prims, "BaseMask", typeof(System.Int32)); + createCol(prims, "ObjectFlags", typeof (Int32)); + createCol(prims, "CreatorID", typeof (String)); + createCol(prims, "OwnerID", typeof (String)); + createCol(prims, "GroupID", typeof (String)); + createCol(prims, "LastOwnerID", typeof (String)); + createCol(prims, "OwnerMask", typeof (Int32)); + createCol(prims, "NextOwnerMask", typeof (Int32)); + createCol(prims, "GroupMask", typeof (Int32)); + createCol(prims, "EveryoneMask", typeof (Int32)); + createCol(prims, "BaseMask", typeof (Int32)); // vectors - createCol(prims, "PositionX", typeof(System.Double)); - createCol(prims, "PositionY", typeof(System.Double)); - createCol(prims, "PositionZ", typeof(System.Double)); - createCol(prims, "GroupPositionX", typeof(System.Double)); - createCol(prims, "GroupPositionY", typeof(System.Double)); - createCol(prims, "GroupPositionZ", typeof(System.Double)); - createCol(prims, "VelocityX", typeof(System.Double)); - createCol(prims, "VelocityY", typeof(System.Double)); - createCol(prims, "VelocityZ", typeof(System.Double)); - createCol(prims, "AngularVelocityX", typeof(System.Double)); - createCol(prims, "AngularVelocityY", typeof(System.Double)); - createCol(prims, "AngularVelocityZ", typeof(System.Double)); - createCol(prims, "AccelerationX", typeof(System.Double)); - createCol(prims, "AccelerationY", typeof(System.Double)); - createCol(prims, "AccelerationZ", typeof(System.Double)); + createCol(prims, "PositionX", typeof (Double)); + createCol(prims, "PositionY", typeof (Double)); + createCol(prims, "PositionZ", typeof (Double)); + createCol(prims, "GroupPositionX", typeof (Double)); + createCol(prims, "GroupPositionY", typeof (Double)); + createCol(prims, "GroupPositionZ", typeof (Double)); + createCol(prims, "VelocityX", typeof (Double)); + createCol(prims, "VelocityY", typeof (Double)); + createCol(prims, "VelocityZ", typeof (Double)); + createCol(prims, "AngularVelocityX", typeof (Double)); + createCol(prims, "AngularVelocityY", typeof (Double)); + createCol(prims, "AngularVelocityZ", typeof (Double)); + createCol(prims, "AccelerationX", typeof (Double)); + createCol(prims, "AccelerationY", typeof (Double)); + createCol(prims, "AccelerationZ", typeof (Double)); // quaternions - createCol(prims, "RotationX", typeof(System.Double)); - createCol(prims, "RotationY", typeof(System.Double)); - createCol(prims, "RotationZ", typeof(System.Double)); - createCol(prims, "RotationW", typeof(System.Double)); + createCol(prims, "RotationX", typeof (Double)); + createCol(prims, "RotationY", typeof (Double)); + createCol(prims, "RotationZ", typeof (Double)); + createCol(prims, "RotationW", typeof (Double)); // sit target - createCol(prims, "SitTargetOffsetX", typeof(System.Double)); - createCol(prims, "SitTargetOffsetY", typeof(System.Double)); - createCol(prims, "SitTargetOffsetZ", typeof(System.Double)); + createCol(prims, "SitTargetOffsetX", typeof (Double)); + createCol(prims, "SitTargetOffsetY", typeof (Double)); + createCol(prims, "SitTargetOffsetZ", typeof (Double)); - createCol(prims, "SitTargetOrientW", typeof(System.Double)); - createCol(prims, "SitTargetOrientX", typeof(System.Double)); - createCol(prims, "SitTargetOrientY", typeof(System.Double)); - createCol(prims, "SitTargetOrientZ", typeof(System.Double)); + createCol(prims, "SitTargetOrientW", typeof (Double)); + createCol(prims, "SitTargetOrientX", typeof (Double)); + createCol(prims, "SitTargetOrientY", typeof (Double)); + createCol(prims, "SitTargetOrientZ", typeof (Double)); // Add in contraints - prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; + prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; return prims; } @@ -410,40 +418,40 @@ namespace OpenSim.DataStore.MSSQL private DataTable createShapeTable() { DataTable shapes = new DataTable("primshapes"); - createCol(shapes, "UUID", typeof(System.String)); + createCol(shapes, "UUID", typeof (String)); // shape is an enum - createCol(shapes, "Shape", typeof(System.Int32)); + createCol(shapes, "Shape", typeof (Int32)); // vectors - createCol(shapes, "ScaleX", typeof(System.Double)); - createCol(shapes, "ScaleY", typeof(System.Double)); - createCol(shapes, "ScaleZ", typeof(System.Double)); + createCol(shapes, "ScaleX", typeof (Double)); + createCol(shapes, "ScaleY", typeof (Double)); + createCol(shapes, "ScaleZ", typeof (Double)); // paths - createCol(shapes, "PCode", typeof(System.Int32)); - createCol(shapes, "PathBegin", typeof(System.Int32)); - createCol(shapes, "PathEnd", typeof(System.Int32)); - createCol(shapes, "PathScaleX", typeof(System.Int32)); - createCol(shapes, "PathScaleY", typeof(System.Int32)); - createCol(shapes, "PathShearX", typeof(System.Int32)); - createCol(shapes, "PathShearY", typeof(System.Int32)); - createCol(shapes, "PathSkew", typeof(System.Int32)); - createCol(shapes, "PathCurve", typeof(System.Int32)); - createCol(shapes, "PathRadiusOffset", typeof(System.Int32)); - createCol(shapes, "PathRevolutions", typeof(System.Int32)); - createCol(shapes, "PathTaperX", typeof(System.Int32)); - createCol(shapes, "PathTaperY", typeof(System.Int32)); - createCol(shapes, "PathTwist", typeof(System.Int32)); - createCol(shapes, "PathTwistBegin", typeof(System.Int32)); + createCol(shapes, "PCode", typeof (Int32)); + createCol(shapes, "PathBegin", typeof (Int32)); + createCol(shapes, "PathEnd", typeof (Int32)); + createCol(shapes, "PathScaleX", typeof (Int32)); + createCol(shapes, "PathScaleY", typeof (Int32)); + createCol(shapes, "PathShearX", typeof (Int32)); + createCol(shapes, "PathShearY", typeof (Int32)); + createCol(shapes, "PathSkew", typeof (Int32)); + createCol(shapes, "PathCurve", typeof (Int32)); + createCol(shapes, "PathRadiusOffset", typeof (Int32)); + createCol(shapes, "PathRevolutions", typeof (Int32)); + createCol(shapes, "PathTaperX", typeof (Int32)); + createCol(shapes, "PathTaperY", typeof (Int32)); + createCol(shapes, "PathTwist", typeof (Int32)); + createCol(shapes, "PathTwistBegin", typeof (Int32)); // profile - createCol(shapes, "ProfileBegin", typeof(System.Int32)); - createCol(shapes, "ProfileEnd", typeof(System.Int32)); - createCol(shapes, "ProfileCurve", typeof(System.Int32)); - createCol(shapes, "ProfileHollow", typeof(System.Int32)); + createCol(shapes, "ProfileBegin", typeof (Int32)); + createCol(shapes, "ProfileEnd", typeof (Int32)); + createCol(shapes, "ProfileCurve", typeof (Int32)); + createCol(shapes, "ProfileHollow", typeof (Int32)); // text TODO: this isn't right, but I'm not sure the right // way to specify this as a blob atm - createCol(shapes, "Texture", typeof(System.Byte[])); - createCol(shapes, "ExtraParams", typeof(System.Byte[])); + createCol(shapes, "Texture", typeof (Byte[])); + createCol(shapes, "ExtraParams", typeof (Byte[])); - shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; + shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; return shapes; } @@ -462,23 +470,23 @@ namespace OpenSim.DataStore.MSSQL // interesting has to be done to actually get these values // back out. Not enough time to figure it out yet. SceneObjectPart prim = new SceneObjectPart(); - prim.UUID = new LLUUID((String)row["UUID"]); + prim.UUID = new LLUUID((String) row["UUID"]); // explicit conversion of integers is required, which sort // of sucks. No idea if there is a shortcut here or not. prim.ParentID = Convert.ToUInt32(row["ParentID"]); prim.CreationDate = Convert.ToInt32(row["CreationDate"]); - prim.Name = (String)row["Name"]; + prim.Name = (String) row["Name"]; // various text fields - prim.Text = (String)row["Text"]; - prim.Description = (String)row["Description"]; - prim.SitName = (String)row["SitName"]; - prim.TouchName = (String)row["TouchName"]; + prim.Text = (String) row["Text"]; + prim.Description = (String) row["Description"]; + prim.SitName = (String) row["SitName"]; + prim.TouchName = (String) row["TouchName"]; // permissions prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); - prim.CreatorID = new LLUUID((String)row["CreatorID"]); - prim.OwnerID = new LLUUID((String)row["OwnerID"]); - prim.GroupID = new LLUUID((String)row["GroupID"]); - prim.LastOwnerID = new LLUUID((String)row["LastOwnerID"]); + prim.CreatorID = new LLUUID((String) row["CreatorID"]); + prim.OwnerID = new LLUUID((String) row["OwnerID"]); + prim.GroupID = new LLUUID((String) row["GroupID"]); + prim.LastOwnerID = new LLUUID((String) row["LastOwnerID"]); prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); @@ -521,15 +529,19 @@ namespace OpenSim.DataStore.MSSQL try { prim.SetSitTargetLL(new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( - Convert.ToSingle(row["SitTargetOrientX"]), - Convert.ToSingle(row["SitTargetOrientY"]), - Convert.ToSingle(row["SitTargetOrientZ"]), - Convert.ToSingle(row["SitTargetOrientW"]))); + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"]))); } - catch (System.InvalidCastException) + catch (InvalidCastException) { // Database table was created before we got here and now has null values :P } @@ -598,11 +610,10 @@ namespace OpenSim.DataStore.MSSQL row["SitTargetOrientY"] = sitTargetOrient.Y; row["SitTargetOrientZ"] = sitTargetOrient.Z; } - catch (System.Exception) + catch (Exception) { // TODO: Add Sit Target Rows! } - } private PrimitiveBaseShape buildShape(DataRow row) @@ -634,14 +645,14 @@ namespace OpenSim.DataStore.MSSQL s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); - + // text TODO: this isn't right] = but I'm not sure the right // way to specify this as a blob atm - byte[] textureEntry = (byte[])row["Texture"]; + byte[] textureEntry = (byte[]) row["Texture"]; s.TextureEntry = textureEntry; - - s.ExtraParams = (byte[])row["ExtraParams"]; + + s.ExtraParams = (byte[]) row["ExtraParams"]; // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); // string texture = encoding.GetString((Byte[])row["Texture"]); // if (!texture.StartsWith("<")) @@ -774,7 +785,7 @@ namespace OpenSim.DataStore.MSSQL sql += ") values (@"; sql += String.Join(", @", cols); sql += ")"; - SqlCommand cmd = new SqlCommand(sql); + SqlCommand cmd = new SqlCommand(sql); // this provides the binding for all our parameters, so // much less code than it used to be foreach (DataColumn col in dt.Columns) @@ -791,14 +802,15 @@ namespace OpenSim.DataStore.MSSQL foreach (DataColumn col in dt.Columns) { if (subsql.Length > 0) - { // a map function would rock so much here + { + // a map function would rock so much here subsql += ", "; } subsql += col.ColumnName + "= @" + col.ColumnName; } sql += subsql; sql += " where " + pk; - SqlCommand cmd = new SqlCommand(sql); + SqlCommand cmd = new SqlCommand(sql); // this provides the binding for all our parameters, so // much less code than it used to be @@ -817,7 +829,8 @@ namespace OpenSim.DataStore.MSSQL foreach (DataColumn col in dt.Columns) { if (subsql.Length > 0) - { // a map function would rock so much here + { + // a map function would rock so much here subsql += ",\n"; } subsql += col.ColumnName + " " + SqlType(col.DataType); @@ -828,7 +841,7 @@ namespace OpenSim.DataStore.MSSQL } sql += subsql; sql += ")"; - + return sql; } @@ -837,7 +850,7 @@ namespace OpenSim.DataStore.MSSQL row["RegionUUID"] = regionUUID; row["Revision"] = rev; - MemoryStream str = new MemoryStream(65536 * sizeof(double)); + MemoryStream str = new MemoryStream(65536*sizeof (double)); BinaryWriter bw = new BinaryWriter(str); // TODO: COMPATIBILITY - Add byte-order conversions @@ -868,7 +881,7 @@ namespace OpenSim.DataStore.MSSQL /// for us. /// ///a built Sql parameter - private SqlParameter createSqlParameter(string name, System.Type type) + private SqlParameter createSqlParameter(string name, Type type) { SqlParameter param = new SqlParameter(); param.ParameterName = "@" + name; @@ -887,7 +900,7 @@ namespace OpenSim.DataStore.MSSQL da.UpdateCommand.Connection = conn; SqlCommand delete = new SqlCommand("delete from prims where UUID = @UUID"); - delete.Parameters.Add(createSqlParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqlParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -901,7 +914,7 @@ namespace OpenSim.DataStore.MSSQL da.UpdateCommand.Connection = conn; SqlCommand delete = new SqlCommand("delete from primshapes where UUID = @UUID"); - delete.Parameters.Add(createSqlParameter("UUID", typeof(System.String))); + delete.Parameters.Add(createSqlParameter("UUID", typeof (String))); delete.Connection = conn; da.DeleteCommand = delete; } @@ -957,14 +970,13 @@ namespace OpenSim.DataStore.MSSQL private bool TestTables(SqlConnection conn) { - SqlCommand primSelectCmd = new SqlCommand(primSelect, conn); SqlDataAdapter pDa = new SqlDataAdapter(primSelectCmd); SqlCommand shapeSelectCmd = new SqlCommand(shapeSelect, conn); SqlDataAdapter sDa = new SqlDataAdapter(shapeSelectCmd); SqlCommand terrainSelectCmd = new SqlCommand(terrainSelect, conn); SqlDataAdapter tDa = new SqlDataAdapter(terrainSelectCmd); - + DataSet tmpDS = new DataSet(); try { @@ -978,7 +990,7 @@ namespace OpenSim.DataStore.MSSQL InitDB(conn); } - try + try { if (tmpDS.Tables == null || tmpDS.Tables.Count == 0) { @@ -986,11 +998,10 @@ namespace OpenSim.DataStore.MSSQL sDa.Fill(tmpDS, "primshapes"); tDa.Fill(tmpDS, "terrain"); } - } catch (SqlException e) { - MainLog.Instance.Verbose("DATASTORE", e.ToString()); + MainLog.Instance.Verbose("DATASTORE", e.ToString()); } foreach (DataColumn col in createPrimTable().Columns) @@ -1028,19 +1039,19 @@ namespace OpenSim.DataStore.MSSQL private DbType dbtypeFromType(Type type) { - if (type == typeof(System.String)) + if (type == typeof (String)) { return DbType.String; } - else if (type == typeof(System.Int32)) + else if (type == typeof (Int32)) { return DbType.Int32; } - else if (type == typeof(System.Double)) + else if (type == typeof (Double)) { return DbType.Double; } - else if (type == typeof(System.Byte[])) + else if (type == typeof (Byte[])) { return DbType.Binary; } @@ -1054,19 +1065,19 @@ namespace OpenSim.DataStore.MSSQL // slightly differently. private string SqlType(Type type) { - if (type == typeof(System.String)) + if (type == typeof (String)) { return "varchar(255)"; } - else if (type == typeof(System.Int32)) + else if (type == typeof (Int32)) { return "integer"; } - else if (type == typeof(System.Double)) + else if (type == typeof (Double)) { return "float"; } - else if (type == typeof(System.Byte[])) + else if (type == typeof (Byte[])) { return "image"; } diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index c885310..065d37d 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs @@ -59,7 +59,7 @@ namespace OpenSim.DataStore.MonoSqlite private SqliteConnection m_conn; private String m_connectionString; - + private bool persistPrimInventories; /*********************************************************************** @@ -71,7 +71,7 @@ namespace OpenSim.DataStore.MonoSqlite // see IRegionDataStore public void Initialise(string connectionString, bool persistPrimInventories) { - m_connectionString = connectionString; + m_connectionString = connectionString; this.persistPrimInventories = persistPrimInventories; ds = new DataSet(); @@ -182,20 +182,20 @@ namespace OpenSim.DataStore.MonoSqlite { foreach (SceneObjectPart prim in obj.Children.Values) { - if ((prim.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) + if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); } else if (Stopped(prim)) { - MainLog.Instance.Verbose("DATASTORE", "Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); + MainLog.Instance.Verbose("DATASTORE", + "Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); } else { // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); - } } } @@ -307,18 +307,19 @@ namespace OpenSim.DataStore.MonoSqlite public void StoreTerrain(double[,] ter, LLUUID regionID) { - lock (ds) { + lock (ds) + { int revision = Util.UnixTimeSinceEpoch(); - + // the following is an work around for .NET. The perf // issues associated with it aren't as bad as you think. SqliteConnection conn = new SqliteConnection(m_connectionString); conn.Open(); MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" + - " values(:RegionUUID, :Revision, :Heightfield)"; + " values(:RegionUUID, :Revision, :Heightfield)"; - using(SqliteCommand cmd = new SqliteCommand(sql, conn)) + using (SqliteCommand cmd = new SqliteCommand(sql, conn)) { cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); @@ -333,7 +334,10 @@ namespace OpenSim.DataStore.MonoSqlite // revisions in the database, as this old // implementation is a DOS attack waiting to happen. - using(SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision", conn)) + using ( + SqliteCommand cmd = + new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision", + conn)) { cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); @@ -345,21 +349,22 @@ namespace OpenSim.DataStore.MonoSqlite public double[,] LoadTerrain(LLUUID regionID) { - lock (ds) { + lock (ds) + { double[,] terret = new double[256,256]; terret.Initialize(); // the following is an work around for .NET. The perf // issues associated with it aren't as bad as you think. SqliteConnection conn = new SqliteConnection(m_connectionString); conn.Open(); - String sql = "select RegionUUID, Revision, Heightfield from terrain" + - " where RegionUUID=:RegionUUID order by Revision desc"; - - + String sql = "select RegionUUID, Revision, Heightfield from terrain" + + " where RegionUUID=:RegionUUID order by Revision desc"; + + using (SqliteCommand cmd = new SqliteCommand(sql, conn)) { cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); - + using (IDataReader row = cmd.ExecuteReader()) { int rev = 0; @@ -374,7 +379,7 @@ namespace OpenSim.DataStore.MonoSqlite terret[x, y] = BitConverter.ToDouble(heightmap, ((x*256) + y)*8); } } - rev = (int)row["Revision"]; + rev = (int) row["Revision"]; } else { @@ -382,7 +387,7 @@ namespace OpenSim.DataStore.MonoSqlite conn.Close(); return null; } - + MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); } } @@ -434,7 +439,8 @@ namespace OpenSim.DataStore.MonoSqlite fillLandRow(landRow, parcel.landData, regionUUID); } - using (SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", conn)) + using ( + SqliteCommand cmd = new SqliteCommand("delete from landaccesslist where LandUUID=:LandUUID", conn)) { cmd.Parameters.Add(new SqliteParameter(":LandUUID", Util.ToRawUuidString(parcel.landData.globalID))); cmd.ExecuteNonQuery(); @@ -447,16 +453,15 @@ namespace OpenSim.DataStore.MonoSqlite landaccesslist.Rows.Add(newAccessRow); } conn.Close(); - } Commit(); } - public List LoadLandObjects(LLUUID regionUUID) + public List LoadLandObjects(LLUUID regionUUID) { List landDataForRegion = new List(); - lock(ds) + lock (ds) { DataTable land = ds.Tables["land"]; DataTable landaccesslist = ds.Tables["landaccesslist"]; @@ -570,14 +575,14 @@ namespace OpenSim.DataStore.MonoSqlite createCol(prims, "RotationW", typeof (Double)); // sit target - createCol(prims, "SitTargetOffsetX", typeof(Double)); - createCol(prims, "SitTargetOffsetY", typeof(Double)); - createCol(prims, "SitTargetOffsetZ", typeof(Double)); + createCol(prims, "SitTargetOffsetX", typeof (Double)); + createCol(prims, "SitTargetOffsetY", typeof (Double)); + createCol(prims, "SitTargetOffsetZ", typeof (Double)); - createCol(prims, "SitTargetOrientW", typeof(Double)); - createCol(prims, "SitTargetOrientX", typeof(Double)); - createCol(prims, "SitTargetOrientY", typeof(Double)); - createCol(prims, "SitTargetOrientZ", typeof(Double)); + createCol(prims, "SitTargetOrientW", typeof (Double)); + createCol(prims, "SitTargetOrientX", typeof (Double)); + createCol(prims, "SitTargetOrientY", typeof (Double)); + createCol(prims, "SitTargetOrientZ", typeof (Double)); // Add in contraints prims.PrimaryKey = new DataColumn[] {prims.Columns["UUID"]}; @@ -621,11 +626,11 @@ namespace OpenSim.DataStore.MonoSqlite createCol(shapes, "Texture", typeof (Byte[])); createCol(shapes, "ExtraParams", typeof (Byte[])); - shapes.PrimaryKey = new DataColumn[] { shapes.Columns["UUID"] }; + shapes.PrimaryKey = new DataColumn[] {shapes.Columns["UUID"]}; return shapes; } - + private DataTable createItemsTable() { DataTable items = new DataTable("primitems"); @@ -635,10 +640,10 @@ namespace OpenSim.DataStore.MonoSqlite createCol(items, "assetID", typeof (String)); createCol(items, "assetType", typeof (Int32)); createCol(items, "parentFolderID", typeof (String)); - + createCol(items, "name", typeof (String)); createCol(items, "description", typeof (String)); - + createCol(items, "creationDate", typeof (Int64)); createCol(items, "creatorID", typeof (String)); createCol(items, "ownerID", typeof (String)); @@ -651,50 +656,50 @@ namespace OpenSim.DataStore.MonoSqlite createCol(items, "everyonePermissions", typeof (Int32)); createCol(items, "groupPermissions", typeof (Int32)); - items.PrimaryKey = new DataColumn[] { items.Columns["UUID"] }; - + items.PrimaryKey = new DataColumn[] {items.Columns["UUID"]}; + return items; - } + } private DataTable createLandTable() { DataTable land = new DataTable("land"); - createCol(land, "UUID", typeof(String)); - createCol(land, "RegionUUID", typeof(String)); - createCol(land, "LocalLandID", typeof(UInt32)); + createCol(land, "UUID", typeof (String)); + createCol(land, "RegionUUID", typeof (String)); + createCol(land, "LocalLandID", typeof (UInt32)); // Bitmap is a byte[512] - createCol(land, "Bitmap", typeof(Byte[])); - - createCol(land, "Name", typeof(String)); - createCol(land, "Desc", typeof(String)); - createCol(land, "OwnerUUID", typeof(String)); - createCol(land, "IsGroupOwned", typeof(Boolean)); - createCol(land, "Area", typeof(Int32)); - createCol(land, "AuctionID", typeof(Int32)); //Unemplemented - createCol(land, "Category", typeof(Int32)); //Enum libsecondlife.Parcel.ParcelCategory - createCol(land, "ClaimDate", typeof(Int32)); - createCol(land, "ClaimPrice", typeof(Int32)); - createCol(land, "GroupUUID", typeof(string)); - createCol(land, "SalePrice", typeof(Int32)); - createCol(land, "LandStatus", typeof(Int32)); //Enum. libsecondlife.Parcel.ParcelStatus - createCol(land, "LandFlags", typeof(UInt32)); - createCol(land, "LandingType", typeof(Byte)); - createCol(land, "MediaAutoScale", typeof(Byte)); - createCol(land, "MediaTextureUUID", typeof(String)); - createCol(land, "MediaURL", typeof(String)); - createCol(land, "MusicURL", typeof(String)); - createCol(land, "PassHours", typeof(Double)); - createCol(land, "PassPrice", typeof(UInt32)); - createCol(land, "SnapshotUUID", typeof(String)); - createCol(land, "UserLocationX", typeof(Double)); - createCol(land, "UserLocationY", typeof(Double)); - createCol(land, "UserLocationZ", typeof(Double)); - createCol(land, "UserLookAtX", typeof(Double)); - createCol(land, "UserLookAtY", typeof(Double)); - createCol(land, "UserLookAtZ", typeof(Double)); - - land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; + createCol(land, "Bitmap", typeof (Byte[])); + + createCol(land, "Name", typeof (String)); + createCol(land, "Desc", typeof (String)); + createCol(land, "OwnerUUID", typeof (String)); + createCol(land, "IsGroupOwned", typeof (Boolean)); + createCol(land, "Area", typeof (Int32)); + createCol(land, "AuctionID", typeof (Int32)); //Unemplemented + createCol(land, "Category", typeof (Int32)); //Enum libsecondlife.Parcel.ParcelCategory + createCol(land, "ClaimDate", typeof (Int32)); + createCol(land, "ClaimPrice", typeof (Int32)); + createCol(land, "GroupUUID", typeof (string)); + createCol(land, "SalePrice", typeof (Int32)); + createCol(land, "LandStatus", typeof (Int32)); //Enum. libsecondlife.Parcel.ParcelStatus + createCol(land, "LandFlags", typeof (UInt32)); + createCol(land, "LandingType", typeof (Byte)); + createCol(land, "MediaAutoScale", typeof (Byte)); + createCol(land, "MediaTextureUUID", typeof (String)); + createCol(land, "MediaURL", typeof (String)); + createCol(land, "MusicURL", typeof (String)); + createCol(land, "PassHours", typeof (Double)); + createCol(land, "PassPrice", typeof (UInt32)); + createCol(land, "SnapshotUUID", typeof (String)); + createCol(land, "UserLocationX", typeof (Double)); + createCol(land, "UserLocationY", typeof (Double)); + createCol(land, "UserLocationZ", typeof (Double)); + createCol(land, "UserLookAtX", typeof (Double)); + createCol(land, "UserLookAtY", typeof (Double)); + createCol(land, "UserLookAtZ", typeof (Double)); + + land.PrimaryKey = new DataColumn[] {land.Columns["UUID"]}; return land; } @@ -702,9 +707,9 @@ namespace OpenSim.DataStore.MonoSqlite private DataTable createLandAccessListTable() { DataTable landaccess = new DataTable("landaccesslist"); - createCol(landaccess, "LandUUID", typeof(String)); - createCol(landaccess, "AccessUUID", typeof(String)); - createCol(landaccess, "Flags", typeof(UInt32)); + createCol(landaccess, "LandUUID", typeof (String)); + createCol(landaccess, "AccessUUID", typeof (String)); + createCol(landaccess, "Flags", typeof (UInt32)); return landaccess; } @@ -782,35 +787,43 @@ namespace OpenSim.DataStore.MonoSqlite try { prim.SetSitTargetLL(new LLVector3( - Convert.ToSingle(row["SitTargetOffsetX"]), - Convert.ToSingle(row["SitTargetOffsetY"]), - Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( - Convert.ToSingle(row["SitTargetOrientX"]), - Convert.ToSingle(row["SitTargetOrientY"]), - Convert.ToSingle(row["SitTargetOrientZ"]), - Convert.ToSingle(row["SitTargetOrientW"]))); + Convert.ToSingle(row["SitTargetOffsetX"]), + Convert.ToSingle(row["SitTargetOffsetY"]), + Convert.ToSingle(row["SitTargetOffsetZ"])), new LLQuaternion( + Convert.ToSingle( + row["SitTargetOrientX"]), + Convert.ToSingle( + row["SitTargetOrientY"]), + Convert.ToSingle( + row["SitTargetOrientZ"]), + Convert.ToSingle( + row["SitTargetOrientW"]))); } - catch (System.InvalidCastException) + catch (InvalidCastException) { // Database table was created before we got here and now has null values :P m_conn.Open(); - SqliteCommand cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetX float NOT NULL default 0;", m_conn); + SqliteCommand cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetX float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetY float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetY float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetZ float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOffsetZ float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientW float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientW float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientX float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientX float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientY float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientY float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - cmd = new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientZ float NOT NULL default 0;", m_conn); + cmd = + new SqliteCommand("ALTER TABLE prims ADD COLUMN SitTargetOrientZ float NOT NULL default 0;", m_conn); cmd.ExecuteNonQuery(); - - - } return prim; @@ -820,36 +833,42 @@ namespace OpenSim.DataStore.MonoSqlite { LandData newData = new LandData(); - newData.globalID = new LLUUID((String)row["UUID"]); - newData.localID= Convert.ToInt32(row["LocalLandID"]); + newData.globalID = new LLUUID((String) row["UUID"]); + newData.localID = Convert.ToInt32(row["LocalLandID"]); // Bitmap is a byte[512] newData.landBitmapByteArray = (Byte[]) row["Bitmap"]; - newData.landName= (String) row["Name"]; - newData.landDesc= (String) row["Desc"]; - newData.ownerID= (String) row["OwnerUUID"]; - newData.isGroupOwned= (Boolean) row["IsGroupOwned"]; - newData.area= Convert.ToInt32(row["Area"]); + newData.landName = (String) row["Name"]; + newData.landDesc = (String) row["Desc"]; + newData.ownerID = (String) row["OwnerUUID"]; + newData.isGroupOwned = (Boolean) row["IsGroupOwned"]; + newData.area = Convert.ToInt32(row["Area"]); newData.auctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented - newData.category= (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); //Enum libsecondlife.Parcel.ParcelCategory - newData.claimDate= Convert.ToInt32(row["ClaimDate"]); - newData.claimPrice= Convert.ToInt32(row["ClaimPrice"]); - newData.groupID= new LLUUID((String)row["GroupUUID"]); + newData.category = (Parcel.ParcelCategory) Convert.ToInt32(row["Category"]); + //Enum libsecondlife.Parcel.ParcelCategory + newData.claimDate = Convert.ToInt32(row["ClaimDate"]); + newData.claimPrice = Convert.ToInt32(row["ClaimPrice"]); + newData.groupID = new LLUUID((String) row["GroupUUID"]); newData.salePrice = Convert.ToInt32(row["SalePrice"]); - newData.landStatus= (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); //Enum. libsecondlife.Parcel.ParcelStatus - newData.landFlags= Convert.ToUInt32(row["LandFlags"]); - newData.landingType= (Byte) row["LandingType"]; - newData.mediaAutoScale= (Byte) row["MediaAutoScale"]; - newData.mediaID= new LLUUID((String)row["MediaTextureUUID"]); - newData.mediaURL= (String) row["MediaURL"]; - newData.musicURL= (String) row["MusicURL"]; - newData.passHours= Convert.ToSingle(row["PassHours"]); - newData.passPrice= Convert.ToInt32(row["PassPrice"]); - newData.snapshotID= (String) row["SnapshotUUID"]; - - newData.userLocation = new LLVector3(Convert.ToSingle(row["UserLocationX"]),Convert.ToSingle(row["UserLocationY"]), Convert.ToSingle(row["UserLocationZ"])); - newData.userLookAt = new LLVector3(Convert.ToSingle(row["UserLookAtX"]),Convert.ToSingle(row["UserLookAtY"]), Convert.ToSingle(row["UserLookAtZ"])); + newData.landStatus = (Parcel.ParcelStatus) Convert.ToInt32(row["LandStatus"]); + //Enum. libsecondlife.Parcel.ParcelStatus + newData.landFlags = Convert.ToUInt32(row["LandFlags"]); + newData.landingType = (Byte) row["LandingType"]; + newData.mediaAutoScale = (Byte) row["MediaAutoScale"]; + newData.mediaID = new LLUUID((String) row["MediaTextureUUID"]); + newData.mediaURL = (String) row["MediaURL"]; + newData.musicURL = (String) row["MusicURL"]; + newData.passHours = Convert.ToSingle(row["PassHours"]); + newData.passPrice = Convert.ToInt32(row["PassPrice"]); + newData.snapshotID = (String) row["SnapshotUUID"]; + + newData.userLocation = + new LLVector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), + Convert.ToSingle(row["UserLocationZ"])); + newData.userLookAt = + new LLVector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), + Convert.ToSingle(row["UserLookAtZ"])); newData.parcelAccessList = new List(); return newData; @@ -858,13 +877,13 @@ namespace OpenSim.DataStore.MonoSqlite private ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) { ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = new LLUUID((string)row["AccessUUID"]); - entry.Flags = (ParcelManager.AccessList)row["Flags"]; + entry.AgentID = new LLUUID((string) row["AccessUUID"]); + entry.Flags = (ParcelManager.AccessList) row["Flags"]; entry.Time = new DateTime(); return entry; } - private Array serializeTerrain(double[,] val) + private Array serializeTerrain(double[,] val) { MemoryStream str = new MemoryStream(65536*sizeof (double)); BinaryWriter bw = new BinaryWriter(str); @@ -900,7 +919,8 @@ namespace OpenSim.DataStore.MonoSqlite row["ParentID"] = prim.ParentID; row["CreationDate"] = prim.CreationDate; row["Name"] = prim.Name; - row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); // the UUID of the root part for this SceneObjectGroup + row["SceneGroupID"] = Util.ToRawUuidString(sceneGroupID); + // the UUID of the root part for this SceneObjectGroup // various text fields row["Text"] = prim.Text; row["Description"] = prim.Description; @@ -1028,10 +1048,10 @@ namespace OpenSim.DataStore.MonoSqlite s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); // text TODO: this isn't right] = but I'm not sure the right // way to specify this as a blob atm - - byte[] textureEntry = (byte[])row["Texture"]; + + byte[] textureEntry = (byte[]) row["Texture"]; s.TextureEntry = textureEntry; - + s.ExtraParams = (byte[]) row["ExtraParams"]; // System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); @@ -1278,6 +1298,7 @@ namespace OpenSim.DataStore.MonoSqlite da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); da.InsertCommand.Connection = conn; } + private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) { da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); @@ -1331,7 +1352,7 @@ namespace OpenSim.DataStore.MonoSqlite { MainLog.Instance.Warn("SQLITE", "Shapes Table Already Exists"); } - + if (persistPrimInventories) { try @@ -1341,7 +1362,7 @@ namespace OpenSim.DataStore.MonoSqlite catch (SqliteSyntaxException) { MainLog.Instance.Warn("SQLITE", "Primitives Inventory Table Already Exists"); - } + } } try @@ -1377,32 +1398,31 @@ namespace OpenSim.DataStore.MonoSqlite { SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); SqliteDataAdapter pDa = new SqliteDataAdapter(primSelectCmd); - + SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn); SqliteDataAdapter sDa = new SqliteDataAdapter(shapeSelectCmd); - + SqliteCommand itemsSelectCmd = new SqliteCommand(itemsSelect, conn); SqliteDataAdapter iDa = new SqliteDataAdapter(itemsSelectCmd); - + SqliteCommand terrainSelectCmd = new SqliteCommand(terrainSelect, conn); SqliteDataAdapter tDa = new SqliteDataAdapter(terrainSelectCmd); - + SqliteCommand landSelectCmd = new SqliteCommand(landSelect, conn); SqliteDataAdapter lDa = new SqliteDataAdapter(landSelectCmd); - + SqliteCommand landAccessListSelectCmd = new SqliteCommand(landAccessListSelect, conn); SqliteDataAdapter lalDa = new SqliteDataAdapter(landAccessListSelectCmd); DataSet tmpDS = new DataSet(); try { - pDa.Fill(tmpDS, "prims"); sDa.Fill(tmpDS, "primshapes"); - + if (persistPrimInventories) iDa.Fill(tmpDS, "primitems"); - + tDa.Fill(tmpDS, "terrain"); lDa.Fill(tmpDS, "land"); lalDa.Fill(tmpDS, "landaccesslist"); @@ -1415,13 +1435,13 @@ namespace OpenSim.DataStore.MonoSqlite pDa.Fill(tmpDS, "prims"); sDa.Fill(tmpDS, "primshapes"); - + if (persistPrimInventories) iDa.Fill(tmpDS, "primitems"); - + tDa.Fill(tmpDS, "terrain"); lDa.Fill(tmpDS, "land"); - lalDa.Fill(tmpDS,"landaccesslist"); + lalDa.Fill(tmpDS, "landaccesslist"); foreach (DataColumn col in createPrimTable().Columns) { @@ -1431,7 +1451,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + foreach (DataColumn col in createShapeTable().Columns) { if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) @@ -1440,9 +1460,9 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + // TODO Not restoring prim inventories quite yet - + foreach (DataColumn col in createTerrainTable().Columns) { if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) @@ -1451,7 +1471,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + foreach (DataColumn col in createLandTable().Columns) { if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) @@ -1460,7 +1480,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + foreach (DataColumn col in createLandAccessListTable().Columns) { if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) @@ -1469,7 +1489,7 @@ namespace OpenSim.DataStore.MonoSqlite return false; } } - + return true; } @@ -1526,7 +1546,7 @@ namespace OpenSim.DataStore.MonoSqlite else if (type == typeof (Int64)) { return "integer"; - } + } else if (type == typeof (Double)) { return "float"; @@ -1541,4 +1561,4 @@ namespace OpenSim.DataStore.MonoSqlite } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs index da05018..035c3ba 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using libsecondlife; +using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.Scenes; @@ -71,9 +72,9 @@ namespace OpenSim.DataStore.NullStorage { } - public List LoadLandObjects(LLUUID regionUUID) + public List LoadLandObjects(LLUUID regionUUID) { - return new List(); + return new List(); } public void Shutdown() diff --git a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs index 3c0facb..3195140 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs @@ -62,4 +62,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] +[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index e89ff62..2405e86 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs @@ -159,12 +159,13 @@ namespace OpenSim.Region.Terrain /// 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, float south, float east, + public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, + float south, float east, IClientAPI remoteUser) { // Shiny. double size = (double) (1 << brushsize); - + /* Okay, so here's the deal * This has to handle both when a user draws on the terrain *and* when a user selects * a selection of AABB on terrain and applies whatever routine the client requests @@ -189,8 +190,8 @@ namespace OpenSim.Region.Terrain * Again, libTerrain is yx instead of xy.. so, it's reflected in the function calls * */ - - + + switch (action) { case 0: @@ -199,7 +200,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - FlattenTerrain(y, x, size, (double)seconds / 5.0); + FlattenTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -210,7 +211,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - RaiseTerrain(y, x, size, (double)seconds / 5.0); + RaiseTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -221,7 +222,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - LowerTerrain(y, x, size, (double)seconds / 5.0); + LowerTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -235,13 +236,13 @@ namespace OpenSim.Region.Terrain // //for (float x = south; x <= north; x++) //{ - //for (float y = west; y <= east; y++) - //{ - //SmoothTerrain(y, x , size, (double)seconds / 5.0); - //} + //for (float y = west; y <= east; y++) + //{ + //SmoothTerrain(y, x , size, (double)seconds / 5.0); + //} //} - SmoothTerrain(west, north, size, (double)seconds / 5.0); + SmoothTerrain(west, north, size, (double) seconds/5.0); break; case 4: @@ -250,7 +251,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - NoiseTerrain(y, x, size, (double)seconds / 5.0); + NoiseTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -261,7 +262,7 @@ namespace OpenSim.Region.Terrain { for (float y = west; y <= east; y++) { - RevertTerrain(y, x, size, (double)seconds / 5.0); + RevertTerrain(y, x, size, (double) seconds/5.0); lastEdit = DateTime.Now; } } @@ -1351,16 +1352,16 @@ namespace OpenSim.Region.Terrain } Channel copy = heightmap.Copy(); - for (int y = 0; y