From 0c466b28bbfeac8a4e0c3c61038290621c4f9f4f Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 27 Oct 2009 16:24:43 -0700 Subject: Move the calculation of time dilation from the scene to the physics engine. The scene is still the one reporting dilation so this does not break the API or remove flexibility, but it gets the calculation happening in the right place for the normal OpenSim usage. The actual calculation of physics time dilation probably needs tweaking --- OpenSim/Region/Framework/Scenes/Scene.cs | 19 ++++++------------- OpenSim/Region/Framework/Scenes/SceneBase.cs | 3 +-- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 5 +++++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 11 +++++++++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7c3875d..3b8cd1e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -135,6 +135,11 @@ namespace OpenSim.Region.Framework.Scenes protected SceneCommunicationService m_sceneGridService; public bool loginsdisabled = true; + public float TimeDilation + { + get { return m_sceneGraph.PhysicsScene.TimeDilation; } + } + public SceneCommunicationService SceneGridService { get { return m_sceneGridService; } @@ -1094,7 +1099,7 @@ namespace OpenSim.Region.Framework.Scenes // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); StatsReporter.AddPhysicsFPS(physicsFPS); - StatsReporter.AddTimeDilation(m_timedilation); + StatsReporter.AddTimeDilation(TimeDilation); StatsReporter.AddFPS(1); StatsReporter.AddInPackets(0); StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); @@ -1141,18 +1146,6 @@ namespace OpenSim.Region.Framework.Scenes } finally { - //updateLock.ReleaseMutex(); - // Get actual time dilation - float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds); - - // If actual time dilation is greater then one, we're catching up, so subtract - // the amount that's greater then 1 from the time dilation - if (tmpval > 1.0) - { - tmpval = tmpval - (tmpval - 1.0f); - } - m_timedilation = tmpval; - m_lastupdate = DateTime.UtcNow; } maintc = Environment.TickCount - maintc; diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 82731d1..1547f9a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -106,9 +106,8 @@ namespace OpenSim.Region.Framework.Scenes public float TimeDilation { - get { return m_timedilation; } + get { return 1.0f; } } - protected float m_timedilation = 1.0f; protected ulong m_regionHandle; protected string m_regionName; diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index bb0d18e..6d515e9 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -75,6 +75,11 @@ namespace OpenSim.Region.Physics.Manager public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical); + public virtual float TimeDilation + { + get { return 1.0f; } + } + public virtual bool SupportsNINJAJoints { get { return false; } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 2f42646..9e36020 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -159,6 +159,7 @@ namespace OpenSim.Region.Physics.OdePlugin private float ODE_STEPSIZE = 0.020f; private float metersInSpace = 29.9f; + private float m_timeDilation = 1.0f; public float gravityx = 0f; public float gravityy = 0f; @@ -1750,6 +1751,11 @@ namespace OpenSim.Region.Physics.OdePlugin return result; } + public override float TimeDilation + { + get { return m_timeDilation; } + } + public override bool SupportsNINJAJoints { get { return m_NINJA_physics_joints_enabled; } @@ -2657,8 +2663,9 @@ namespace OpenSim.Region.Physics.OdePlugin // Figure out the Frames Per Second we're going at. //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size - - fps = (step_time/ODE_STEPSIZE) * 1000; + + fps = (step_time / ODE_STEPSIZE) * 1000; + m_timeDilation = (step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE); step_time = 0.09375f; -- cgit v1.1 From 6a6a8df1ba2a0e8d7c59c687aff86cd8f078d2f0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 27 Oct 2009 20:32:48 -0700 Subject: Make map search work also for hyperlinked regions. --- .../CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 046bee5..40ac647 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -322,10 +322,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { List rinfos = new List(); - // Commenting until regionname exists - //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) - // if ((r.RegionName != null) && r.RegionName.StartsWith(name)) - // rinfos.Add(r); + if (name == string.Empty) + return rinfos; + + foreach (GridRegion r in m_HyperlinkRegions.Values) + if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower())) + rinfos.Add(r); rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); return rinfos; -- cgit v1.1 From 79bf906e7d83fab14d091c9dacc8bc1318eca2f4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 27 Oct 2009 20:33:14 -0700 Subject: Changed True to true in OpenSim.ini.example. --- bin/OpenSim.ini.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 927eb7a..43e6c85 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -148,7 +148,7 @@ MaximumTimeBeforePersistenceConsidered = 600 ; Should avatars in neighbor sims see objects in this sim? - see_into_this_sim_from_neighbor = True + see_into_this_sim_from_neighbor = true ; ## ; ## PHYSICS -- cgit v1.1 From 588c5432999d708a7919a03d6e869436f9eb386a Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 00:29:40 -0700 Subject: Updating the OpenJPEG libraries to the versions from libomv 0.8.0 --- bin/OpenMetaverse.dll.config | 6 +++--- bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-i686.so | Bin 128164 -> 124540 bytes bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-x86_64.so | Bin 142584 -> 142616 bytes bin/openjpeg-dotnet-x86_64.dll | Bin 0 -> 843776 bytes bin/openjpeg-dotnet.dll | Bin 187392 -> 187392 bytes 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 bin/openjpeg-dotnet-x86_64.dll diff --git a/bin/OpenMetaverse.dll.config b/bin/OpenMetaverse.dll.config index 489ee6b..13fdc11 100644 --- a/bin/OpenMetaverse.dll.config +++ b/bin/OpenMetaverse.dll.config @@ -1,7 +1,7 @@ - - - + + + diff --git a/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-i686.so b/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-i686.so index 9571b1d..0106b56 100644 Binary files a/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-i686.so and b/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-i686.so differ diff --git a/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-x86_64.so b/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-x86_64.so index c2627e8..be11bb4 100644 Binary files a/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-x86_64.so and b/bin/libopenjpeg-dotnet-2.1.3.0-dotnet-1-x86_64.so differ diff --git a/bin/openjpeg-dotnet-x86_64.dll b/bin/openjpeg-dotnet-x86_64.dll new file mode 100644 index 0000000..97729ff Binary files /dev/null and b/bin/openjpeg-dotnet-x86_64.dll differ diff --git a/bin/openjpeg-dotnet.dll b/bin/openjpeg-dotnet.dll index 1cede1c..64b2557 100644 Binary files a/bin/openjpeg-dotnet.dll and b/bin/openjpeg-dotnet.dll differ -- cgit v1.1 From 8254256fe9eaa66c49ca981d3c8233bcc0c86eed Mon Sep 17 00:00:00 2001 From: Mikko Pallari Date: Tue, 27 Oct 2009 12:51:47 +0200 Subject: Modified visibilities of properties and methods. This is so that SL client based clients can use UDP server that is inherited from LLUDPServer. --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 14 +++++++------- OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f6a7a0c..d6d1a95 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -314,14 +314,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP private readonly LLUDPClient m_udpClient; private readonly UUID m_sessionId; private readonly UUID m_secureSessionId; - private readonly UUID m_agentId; + protected readonly UUID m_agentId; private readonly uint m_circuitCode; private readonly byte[] m_channelVersion = Utils.EmptyBytes; private readonly Dictionary m_defaultAnimations = new Dictionary(); private readonly IGroupsModule m_GroupsModule; private int m_cachedTextureSerial; - private PriorityQueue m_avatarTerseUpdates; + protected PriorityQueue m_avatarTerseUpdates; private PriorityQueue m_primTerseUpdates; private PriorityQueue m_primFullUpdates; private int m_moneyBalance; @@ -3314,7 +3314,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ProcessAvatarTerseUpdates(); } - private void ProcessAvatarTerseUpdates() + protected void ProcessAvatarTerseUpdates() { ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); terse.Header.Reliable = false; @@ -5050,7 +5050,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Packet to send /// Throttling category for the packet - private void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) + protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) { m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); } @@ -10236,7 +10236,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #region PriorityQueue - private class PriorityQueue + public class PriorityQueue { internal delegate bool UpdatePriorityHandler(ref TPriority priority, uint local_id); @@ -10264,7 +10264,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP this.m_comparison = comparison; } - internal object SyncRoot { get { return this.m_syncRoot; } } + public object SyncRoot { get { return this.m_syncRoot; } } internal int Count { get @@ -10276,7 +10276,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - internal bool Enqueue(TPriority priority, TValue value, uint local_id) + public bool Enqueue(TPriority priority, TValue value, uint local_id) { LookupItem item; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 74d3262..dc72939 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -118,13 +118,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// //private UDPClientCollection m_clients = new UDPClientCollection(); /// Bandwidth throttle for this UDP server - private TokenBucket m_throttle; + protected TokenBucket m_throttle; /// Bandwidth throttle rates for this UDP server - private ThrottleRates m_throttleRates; + protected ThrottleRates m_throttleRates; /// Manages authentication for agent circuits private AgentCircuitManager m_circuitManager; /// Reference to the scene this UDP server is attached to - private Scene m_scene; + protected Scene m_scene; /// The X/Y coordinates of the scene this UDP server is attached to private Location m_location; /// The size of the receive buffer for the UDP socket. This value @@ -759,7 +759,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) + protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) { // Create the LLUDPClient LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); @@ -976,7 +976,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - private void LogoutHandler(IClientAPI client) + protected void LogoutHandler(IClientAPI client) { client.SendLogoutPacket(); if (client.IsActive) -- cgit v1.1 From e31024f08bfa2adeb5cab1fa2396c476528359c3 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 01:30:39 -0700 Subject: Print the exception message when CSJ2K decoding fails for sculpty textures --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index fbe1949..ed93b3a 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -299,12 +299,12 @@ namespace OpenSim.Region.Physics.Meshing } catch (IndexOutOfRangeException) { - m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed"); + m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed"); return null; } - catch (Exception) + catch (Exception ex) { - m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!"); + m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); return null; } } -- cgit v1.1 From 2d470f8bde768e97eb9bd031c945b868931221fd Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 01:48:53 -0700 Subject: Switching sculpty from CSJ2K back to OpenJPEG for now until more kinks are ironed out --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index ed93b3a..fded95e 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -284,9 +284,13 @@ namespace OpenSim.Region.Physics.Meshing try { - idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); + OpenMetaverse.Imaging.ManagedImage unusedData; + OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); + unusedData = null; - if (cacheSculptMaps) + //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); + + if (cacheSculptMaps && idata != null) { try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } -- cgit v1.1 From 587c35f6b6e79636bd50f8e650de55239d424b37 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 02:30:16 -0700 Subject: Marking ImprovedTerseObjectUpdate packets for avatars as unthrottled to test --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index d6d1a95..97caf52 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3335,7 +3335,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue(); } - OutPacket(terse, ThrottleOutPacketType.Task); + OutPacket(terse, ThrottleOutPacketType.Unknown); // HACK: Unthrottled for testing } public void SendCoarseLocationUpdate(List users, List CoarseLocations) -- cgit v1.1 From cdbeb8b83b671df1ffb6bf7890c64a27e4a85730 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 03:21:53 -0700 Subject: Track timestamps when terse updates were last sent for a prim or avatar to avoid floating away forever until a key is pressed (deviates from SL behavior in a hopefully good way) --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 6 +++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9b11582..e1588ce 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -253,6 +253,7 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_lastVelocity; protected Vector3 m_lastAcceleration; protected Vector3 m_lastAngularVelocity; + protected int m_lastTerseSent; // TODO: Those have to be changed into persistent properties at some later point, // or sit-camera on vehicles will break on sim-crossing. @@ -2395,6 +2396,7 @@ if (m_shape != null) { { const float VELOCITY_TOLERANCE = 0.01f; const float POSITION_TOLERANCE = 0.1f; + const int TIME_MS_TOLERANCE = 3000; if (m_updateFlag == 1) { @@ -2403,7 +2405,8 @@ if (m_shape != null) { Acceleration != m_lastAcceleration || (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE || - (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE) + (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE || + Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { AddTerseUpdateToAllAvatars(); ClearUpdateSchedule(); @@ -2422,6 +2425,7 @@ if (m_shape != null) { m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; m_lastAngularVelocity = RotationalVelocity; + m_lastTerseSent = Environment.TickCount; } } else diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 87fac0c..92f00c4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -96,6 +96,7 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; + private int m_lastTerseSent; private bool m_updateflag; private byte m_movementflag; @@ -2363,6 +2364,7 @@ namespace OpenSim.Region.Framework.Scenes { const float VELOCITY_TOLERANCE = 0.01f; const float POSITION_TOLERANCE = 10.0f; + const int TIME_MS_TOLERANCE = 3000; SendPrimUpdates(); @@ -2377,7 +2379,8 @@ namespace OpenSim.Region.Framework.Scenes // Throw away duplicate or insignificant updates if (m_bodyRot != m_lastRotation || (m_velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || - (m_pos - m_lastPosition).Length() > POSITION_TOLERANCE) + (m_pos - m_lastPosition).Length() > POSITION_TOLERANCE || + Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { SendTerseUpdateToAllClients(); @@ -2385,6 +2388,7 @@ namespace OpenSim.Region.Framework.Scenes m_lastPosition = m_pos; m_lastRotation = m_bodyRot; m_lastVelocity = m_velocity; + m_lastTerseSent = Environment.TickCount; } // followed suggestion from mic bowman. reversed the two lines below. -- cgit v1.1 From bff0d75e0f369382d8f97c58bf8127ab53b4dc91 Mon Sep 17 00:00:00 2001 From: Fredo Chaplin Date: Fri, 23 Oct 2009 16:11:25 +0200 Subject: patch kill by UUID Signed-off-by: Melanie --- OpenSim/Region/Application/OpenSim.cs | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index b448182..e7ae7bd 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -343,6 +343,10 @@ namespace OpenSim "Add-InventoryHost ", String.Empty, RunCommand); + m_console.Commands.AddCommand("region", false, "killuuid", + "killuuid ", + "kill an object by UUID", KillUUID); + if (ConfigurationSettings.Standalone) { m_console.Commands.AddCommand("region", false, "create user", @@ -1332,6 +1336,60 @@ namespace OpenSim return result; } + /// + /// Kill an object given its UUID. + /// + /// + protected void KillUUID(string module, string[] cmdparams) + { + if (cmdparams.Length > 1) + { + UUID id = UUID.Zero; + SceneObjectGroup grp = null; + Scene sc = null; + + try + { + Guid x = new Guid((string)cmdparams[1]); + id = (UUID)(string)cmdparams[1]; + } + catch (Exception) + { + m_log.Error("[KillUUID]: Error bad UUID formating !"); + return; + } + + m_sceneManager.ForEachScene( + delegate(Scene scene) + { + if (scene.Entities[id] != null) + { + grp = (SceneObjectGroup) scene.Entities[id]; + sc = scene; + } + }); + + if (grp == null) + m_log.ErrorFormat("[KillUUID]: Given UUID {0} not found !", id); + else + { + m_log.InfoFormat("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName); + try + { + sc.DeleteSceneObject(grp, false); + } + catch (Exception e) + { + m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e); + } + } + } + else + { + m_log.Error("[KillUUID]: Usage: killuuid "); + } + } + #endregion } } -- cgit v1.1 From c17359fea51bc6c2dbe610a8e790a463fb9b5e51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 28 Oct 2009 18:25:37 +0000 Subject: Adding changes to previous patch to make it fit into core better --- OpenSim/Region/Application/OpenSim.cs | 36 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index e7ae7bd..60c34df 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -343,9 +343,9 @@ namespace OpenSim "Add-InventoryHost ", String.Empty, RunCommand); - m_console.Commands.AddCommand("region", false, "killuuid", - "killuuid ", - "kill an object by UUID", KillUUID); + m_console.Commands.AddCommand("region", false, "kill uuid", + "kill uuid ", + "Kill an object by UUID", KillUUID); if (ConfigurationSettings.Standalone) { @@ -1342,38 +1342,36 @@ namespace OpenSim /// protected void KillUUID(string module, string[] cmdparams) { - if (cmdparams.Length > 1) + if (cmdparams.Length > 2) { UUID id = UUID.Zero; SceneObjectGroup grp = null; Scene sc = null; - try + if (!UUID.TryParse(cmdparams[2], out id)) { - Guid x = new Guid((string)cmdparams[1]); - id = (UUID)(string)cmdparams[1]; - } - catch (Exception) - { - m_log.Error("[KillUUID]: Error bad UUID formating !"); + MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!"); return; } m_sceneManager.ForEachScene( delegate(Scene scene) { - if (scene.Entities[id] != null) - { - grp = (SceneObjectGroup) scene.Entities[id]; - sc = scene; - } + SceneObjectPart part = scene.GetSceneObjectPart(id); + if (part == null) + return; + + grp = part.ParentGroup; + sc = scene; }); if (grp == null) - m_log.ErrorFormat("[KillUUID]: Given UUID {0} not found !", id); + { + MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id)); + } else { - m_log.InfoFormat("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName); + MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName)); try { sc.DeleteSceneObject(grp, false); @@ -1386,7 +1384,7 @@ namespace OpenSim } else { - m_log.Error("[KillUUID]: Usage: killuuid "); + MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid "); } } -- cgit v1.1 From ee0f7e10c83a38b455fe5729113c6ea7576f4963 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 12:20:34 -0700 Subject: Fixed a bad check on velocity in the ODE near() callback (it was only checking for velocity in certain directions, and was calling the get_Velocity() function three times) --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 9e36020..8382233 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -772,7 +772,7 @@ namespace OpenSim.Region.Physics.OdePlugin lock (contacts) { - count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); + count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); } } catch (SEHException) @@ -830,7 +830,7 @@ namespace OpenSim.Region.Physics.OdePlugin p2.CollidingObj = true; break; case (int)ActorTypes.Prim: - if (p2.Velocity.X > 0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0) + if (p2.Velocity.LengthSquared() > 0.0f) p2.CollidingObj = true; break; case (int)ActorTypes.Unknown: @@ -1014,7 +1014,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (!skipThisContact && checkDupe(contacts[i], p2.PhysicsActorType)) skipThisContact = true; - int maxContactsbeforedeath = 4000; + const int maxContactsbeforedeath = 4000; joint = IntPtr.Zero; -- cgit v1.1 From a65c8cdc38f40a54ad4a14ed2e6168fb432c6e51 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 12:45:40 -0700 Subject: * Reduce the velocity tolerance on sending terse updates to avoid slowly drifting prims/avatars * Added contacts_per_collision to the ODE config section. This allows you to reduce the maximum number of contact points ODE will generate per collision and reduce the size of the array that stores contact structures --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 13 ++++++++++--- bin/OpenSim.ini.example | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e1588ce..a99a802 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2394,7 +2394,7 @@ if (m_shape != null) { /// public void SendScheduledUpdates() { - const float VELOCITY_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.0001f; const float POSITION_TOLERANCE = 0.1f; const int TIME_MS_TOLERANCE = 3000; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 92f00c4..9ba19d3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2362,7 +2362,7 @@ namespace OpenSim.Region.Framework.Scenes public override void Update() { - const float VELOCITY_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.0001f; const float POSITION_TOLERANCE = 10.0f; const int TIME_MS_TOLERANCE = 3000; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 8382233..6ca415b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -178,8 +178,8 @@ namespace OpenSim.Region.Physics.OdePlugin //private int m_returncollisions = 10; private readonly IntPtr contactgroup; - internal IntPtr LandGeom; + internal IntPtr LandGeom; internal IntPtr WaterGeom; private float nmTerrainContactFriction = 255.0f; @@ -251,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_NINJA_physics_joints_enabled = false; //private Dictionary jointpart_name_map = new Dictionary(); private readonly Dictionary> joints_connecting_actor = new Dictionary>(); - private d.ContactGeom[] contacts = new d.ContactGeom[80]; + private d.ContactGeom[] contacts; private readonly List requestedJointsToBeCreated = new List(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active private readonly List pendingJoints = new List(); // can lock for longer. accessed only by OdeScene. private readonly List activeJoints = new List(); // can lock for longer. accessed only by OdeScene. @@ -397,6 +397,8 @@ namespace OpenSim.Region.Physics.OdePlugin avStandupTensor = 550000f; } + int contactsPerCollision = 80; + if (m_config != null) { IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; @@ -439,6 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true); + contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80); + geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); @@ -476,10 +480,11 @@ namespace OpenSim.Region.Physics.OdePlugin m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false); minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); - } } + contacts = new d.ContactGeom[contactsPerCollision]; + staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; // Centeral contact friction and bounce @@ -773,6 +778,8 @@ namespace OpenSim.Region.Physics.OdePlugin lock (contacts) { count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); + if (count > contacts.Length) + m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); } } catch (SEHException) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 43e6c85..63a9e11 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -577,6 +577,9 @@ ; used to control llMove2Target body_pid_derivative = 35 body_pid_gain = 25 + + ; maximum number of contact points to generate per collision + contacts_per_collision = 80 ; amount of time a geom/body will try to cross a region border before it gets disabled geom_crossing_failures_before_outofbounds = 5 -- cgit v1.1 From b81c829576dd916c0a7bf141919f5e13f025d818 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 14:13:17 -0700 Subject: * Standalone logins will now go through the sequence of "requested region, default region, any region" before giving up * Hip offset should have been added not subtracted (it's a negative offset). This puts avatar feet closer to the ground * Improved duplicate checking for terse updates. This should reduce bandwidth and walking through walls --- OpenSim/Client/Linden/LLStandaloneLoginModule.cs | 4 ++++ .../Communications/Services/LoginService.cs | 26 +++++++++------------ .../Hypergrid/HGStandaloneLoginModule.cs | 6 ++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 15 ++++++------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 21 ++++++++++------- bin/OpenMetaverseTypes.dll | Bin 102400 -> 102400 bytes 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs index bb9b623..8739ce5 100644 --- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs +++ b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs @@ -231,6 +231,10 @@ namespace OpenSim.Client.Linden { return scene.RegionInfo; } + else if (m_scenes.Count > 0) + { + return m_scenes[0].RegionInfo; + } return null; } diff --git a/OpenSim/Framework/Communications/Services/LoginService.cs b/OpenSim/Framework/Communications/Services/LoginService.cs index 922cd49..b652299 100644 --- a/OpenSim/Framework/Communications/Services/LoginService.cs +++ b/OpenSim/Framework/Communications/Services/LoginService.cs @@ -1031,30 +1031,26 @@ namespace OpenSim.Framework.Communications.Services return true; } - // StartLocation not available, send him to a nearby region instead - // regionInfo = m_gridService.RequestClosestRegion(""); - //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); + // Get the default region handle + ulong defaultHandle = Utils.UIntsToLong(m_defaultHomeX * Constants.RegionSize, m_defaultHomeY * Constants.RegionSize); - // Send him to default region instead - ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) | - ((ulong)m_defaultHomeY * Constants.RegionSize); + // If we haven't already tried the default region, reset regionInfo + if (regionInfo != null && defaultHandle != regionInfo.RegionHandle) + regionInfo = null; - if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle)) + if (regionInfo == null) { - m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); - return false; + m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); + regionInfo = GetRegionInfo(defaultHandle); } - m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); - regionInfo = GetRegionInfo(defaultHandle); - if (regionInfo == null) { - m_log.ErrorFormat("[LOGIN]: No default region available. Aborting."); - return false; + m_log.ErrorFormat("[LOGIN]: Sending user to any region"); + regionInfo = RequestClosestRegion(String.Empty); } - theUser.CurrentAgent.Position = new Vector3(128, 128, 0); + theUser.CurrentAgent.Position = new Vector3(128f, 128f, 0f); response.StartLocation = "safe"; return PrepareLoginToRegion(regionInfo, theUser, response, client); diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs index 4199c98..46ee3c0 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs @@ -193,6 +193,10 @@ namespace OpenSim.Region.CoreModules.Hypergrid { return scene.RegionInfo; } + else if (m_scenes.Count > 0) + { + return m_scenes[0].RegionInfo; + } return null; } @@ -248,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid { foreach (Scene nextScene in m_scenes) { - if (nextScene.RegionInfo.RegionName == regionName) + if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase)) { scene = nextScene; return true; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a99a802..c16c4fe 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2394,18 +2394,19 @@ if (m_shape != null) { /// public void SendScheduledUpdates() { - const float VELOCITY_TOLERANCE = 0.0001f; - const float POSITION_TOLERANCE = 0.1f; + const float ROTATION_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.001f; + const float POSITION_TOLERANCE = 0.05f; const int TIME_MS_TOLERANCE = 3000; if (m_updateFlag == 1) { // Throw away duplicate or insignificant updates - if (RotationOffset != m_lastRotation || - Acceleration != m_lastAcceleration || - (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || - (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE || - (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE || + if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + !Acceleration.Equals(m_lastAcceleration) || + !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !RotationalVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || + !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { AddTerseUpdateToAllAvatars(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9ba19d3..63c979f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2362,8 +2362,9 @@ namespace OpenSim.Region.Framework.Scenes public override void Update() { - const float VELOCITY_TOLERANCE = 0.0001f; - const float POSITION_TOLERANCE = 10.0f; + const float ROTATION_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.001f; + const float POSITION_TOLERANCE = 0.05f; const int TIME_MS_TOLERANCE = 3000; SendPrimUpdates(); @@ -2377,9 +2378,9 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { // Throw away duplicate or insignificant updates - if (m_bodyRot != m_lastRotation || - (m_velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || - (m_pos - m_lastPosition).Length() > POSITION_TOLERANCE || + if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + !m_velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { SendTerseUpdateToAllClients(); @@ -2415,7 +2416,9 @@ namespace OpenSim.Region.Framework.Scenes m_perfMonMS = Environment.TickCount; Vector3 pos = m_pos; - pos.Z -= m_appearance.HipOffset; + pos.Z += m_appearance.HipOffset; + + //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, pos, m_velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); @@ -2514,7 +2517,7 @@ namespace OpenSim.Region.Framework.Scenes return; Vector3 pos = m_pos; - pos.Z -= m_appearance.HipOffset; + pos.Z += m_appearance.HipOffset; remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, pos, m_appearance.Texture.GetBytes(), @@ -2585,7 +2588,7 @@ namespace OpenSim.Region.Framework.Scenes // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); Vector3 pos = m_pos; - pos.Z -= m_appearance.HipOffset; + pos.Z += m_appearance.HipOffset; m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); @@ -2694,7 +2697,7 @@ namespace OpenSim.Region.Framework.Scenes } Vector3 pos = m_pos; - pos.Z -= m_appearance.HipOffset; + pos.Z += m_appearance.HipOffset; m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); diff --git a/bin/OpenMetaverseTypes.dll b/bin/OpenMetaverseTypes.dll index 331d58b..95d6021 100644 Binary files a/bin/OpenMetaverseTypes.dll and b/bin/OpenMetaverseTypes.dll differ -- cgit v1.1 From a069a1ee683f67405ae66205662bb8129087030b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 14:44:05 -0700 Subject: Limit physics time dilation to 1.0 --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 3b8cd1e..8b0431c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -135,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes protected SceneCommunicationService m_sceneGridService; public bool loginsdisabled = true; - public float TimeDilation + public new float TimeDilation { get { return m_sceneGraph.PhysicsScene.TimeDilation; } } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 6ca415b..3fdf9ea 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -2672,7 +2672,7 @@ namespace OpenSim.Region.Physics.OdePlugin //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size fps = (step_time / ODE_STEPSIZE) * 1000; - m_timeDilation = (step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE); + m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f); step_time = 0.09375f; -- cgit v1.1 From 1c9696a9d2665b72ecde45fdcc43c1cde2abad79 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 15:11:01 -0700 Subject: Always send a time dilation of 1.0 while we debug rubberbanding issues --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 101 --------------------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 4 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 3 +- 4 files changed, 6 insertions(+), 107 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 97caf52..1ff18d4 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3168,107 +3168,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion - #region Prim/Avatar Updates - - /*void SendObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) - { - bool canUseCompressed, canUseImproved; - UpdateFlagsToPacketType(creatorFlags, updateFlags, out canUseCompressed, out canUseImproved); - - if (!canUseImproved && !canUseCompressed) - SendFullObjectUpdate(obj, creatorFlags, updateFlags); - else if (!canUseImproved) - SendObjectUpdateCompressed(obj, creatorFlags, updateFlags); - else - SendImprovedTerseObjectUpdate(obj, creatorFlags, updateFlags); - } - - void SendFullObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) - { - IClientAPI owner; - if (m_scene.ClientManager.TryGetValue(obj.OwnerID, out owner) && owner is LLClientView) - { - LLClientView llOwner = (LLClientView)owner; - - // Send an update out to the owner - ObjectUpdatePacket updateToOwner = new ObjectUpdatePacket(); - updateToOwner.RegionData.RegionHandle = obj.RegionHandle; - //updateToOwner.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue); - updateToOwner.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; - updateToOwner.ObjectData[0] = BuildUpdateBlock(obj, obj.Flags | creatorFlags | PrimFlags.ObjectYouOwner, 0); - - m_udpServer.SendPacket(llOwner.UDPClient, updateToOwner, ThrottleOutPacketType.State, true); - } - - // Send an update out to everyone else - ObjectUpdatePacket updateToOthers = new ObjectUpdatePacket(); - updateToOthers.RegionData.RegionHandle = obj.RegionHandle; - //updateToOthers.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue); - updateToOthers.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; - updateToOthers.ObjectData[0] = BuildUpdateBlock(obj, obj.Flags, 0); - - m_scene.ClientManager.ForEach( - delegate(IClientAPI client) - { - if (client.AgentId != obj.OwnerID && client is LLClientView) - { - LLClientView llClient = (LLClientView)client; - m_udpServer.SendPacket(llClient.UDPClient, updateToOthers, ThrottleOutPacketType.State, true); - } - } - ); - } - - void SendObjectUpdateCompressed(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) - { - } - - void SendImprovedTerseObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags) - { - } - - void UpdateFlagsToPacketType(PrimFlags creatorFlags, PrimUpdateFlags updateFlags, out bool canUseCompressed, out bool canUseImproved) - { - canUseCompressed = true; - canUseImproved = true; - - if ((updateFlags & PrimUpdateFlags.FullUpdate) == PrimUpdateFlags.FullUpdate || creatorFlags != PrimFlags.None) - { - canUseCompressed = false; - canUseImproved = false; - } - else - { - if ((updateFlags & PrimUpdateFlags.Velocity) != 0 || - (updateFlags & PrimUpdateFlags.Acceleration) != 0 || - (updateFlags & PrimUpdateFlags.CollisionPlane) != 0 || - (updateFlags & PrimUpdateFlags.Joint) != 0) - { - canUseCompressed = false; - } - - if ((updateFlags & PrimUpdateFlags.PrimFlags) != 0 || - (updateFlags & PrimUpdateFlags.ParentID) != 0 || - (updateFlags & PrimUpdateFlags.Scale) != 0 || - (updateFlags & PrimUpdateFlags.PrimData) != 0 || - (updateFlags & PrimUpdateFlags.Text) != 0 || - (updateFlags & PrimUpdateFlags.NameValue) != 0 || - (updateFlags & PrimUpdateFlags.ExtraData) != 0 || - (updateFlags & PrimUpdateFlags.TextureAnim) != 0 || - (updateFlags & PrimUpdateFlags.Sound) != 0 || - (updateFlags & PrimUpdateFlags.Particles) != 0 || - (updateFlags & PrimUpdateFlags.Material) != 0 || - (updateFlags & PrimUpdateFlags.ClickAction) != 0 || - (updateFlags & PrimUpdateFlags.MediaURL) != 0 || - (updateFlags & PrimUpdateFlags.Joint) != 0) - { - canUseImproved = false; - } - } - }*/ - - #endregion Prim/Avatar Updates - #region Avatar Packet/Data Sending Methods /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 38a0cff..dbb06f8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1015,9 +1015,9 @@ namespace OpenSim.Region.Framework.Scenes } } - public float GetTimeDilation() + public ushort GetTimeDilation() { - return m_scene.TimeDilation; + return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c16c4fe..cf1c394 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2383,7 +2383,7 @@ if (m_shape != null) { //isattachment = ParentGroup.RootPart.IsAttachment; byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; - remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, + remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape, lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); @@ -3785,8 +3785,7 @@ if (m_shape != null) { // Causes this thread to dig into the Client Thread Data. // Remember your locking here! remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, - (ushort)(m_parentGroup.GetTimeDilation() * - (float)ushort.MaxValue), LocalId, lPos, + m_parentGroup.GetTimeDilation(), LocalId, lPos, RotationOffset, Velocity, Acceleration, RotationalVelocity, state, FromItemID, OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 3fdf9ea..7caaa14 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -2672,7 +2672,8 @@ namespace OpenSim.Region.Physics.OdePlugin //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size fps = (step_time / ODE_STEPSIZE) * 1000; - m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f); + // HACK: Using a time dilation of 1.0 to debug rubberbanding issues + //m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f); step_time = 0.09375f; -- cgit v1.1 From 59eb378d16fd8a9e887560a2744cc798fef08263 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 23:10:16 -0700 Subject: Small performance tweaks to code called by the heartbeat loop --- OpenSim/Region/Framework/Scenes/Scene.cs | 60 +++++++--------- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 ++-- .../Region/Framework/Scenes/SceneObjectGroup.cs | 17 +---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 79 +++++----------------- 4 files changed, 53 insertions(+), 117 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8b0431c..78ccb55 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -257,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes // Central Update Loop protected int m_fps = 10; - protected int m_frame; + protected uint m_frame; protected float m_timespan = 0.089f; protected DateTime m_lastupdate = DateTime.UtcNow; @@ -1018,36 +1018,24 @@ namespace OpenSim.Region.Framework.Scenes /// public override void Update() { - int maintc = 0; + float physicsFPS; + int maintc; + while (!shuttingdown) { -//#if DEBUG -// int w = 0, io = 0; -// ThreadPool.GetAvailableThreads(out w, out io); -// if ((w < 10) || (io < 10)) -// m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); -//#endif - maintc = Environment.TickCount; - TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; - float physicsFPS = 0; + physicsFPS = 0f; - frameMS = Environment.TickCount; + maintc = maintc = frameMS = otherMS = Environment.TickCount; + + // Increment the frame counter + ++m_frame; try { - // Increment the frame counter - m_frame++; - - // Loop it - if (m_frame == Int32.MaxValue) - m_frame = 0; - - otherMS = Environment.TickCount; - // Check if any objects have reached their targets CheckAtTargets(); - + // Update SceneObjectGroups that have scheduled themselves for updates // Objects queue their updates onto all scene presences if (m_frame % m_update_objects == 0) @@ -1067,13 +1055,13 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.UpdateScenePresenceMovement(); physicsMS = Environment.TickCount; - if ((m_frame % m_update_physics == 0) && m_physics_enabled) - physicsFPS = m_sceneGraph.UpdatePhysics( - Math.Max(SinceLastFrame.TotalSeconds, m_timespan) - ); - if (m_frame % m_update_physics == 0 && SynchronizeScene != null) - SynchronizeScene(this); - + if (m_frame % m_update_physics == 0) + { + if (m_physics_enabled) + physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); + if (SynchronizeScene != null) + SynchronizeScene(this); + } physicsMS = Environment.TickCount - physicsMS; physicsMS += physicsMS2; @@ -1095,25 +1083,27 @@ namespace OpenSim.Region.Framework.Scenes if (m_frame % m_update_land == 0) UpdateLand(); - otherMS = Environment.TickCount - otherMS; + int tickCount = Environment.TickCount; + otherMS = tickCount - otherMS; + frameMS = tickCount - frameMS; + // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); StatsReporter.AddPhysicsFPS(physicsFPS); StatsReporter.AddTimeDilation(TimeDilation); StatsReporter.AddFPS(1); - StatsReporter.AddInPackets(0); StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); - frameMS = Environment.TickCount - frameMS; StatsReporter.addFrameMS(frameMS); StatsReporter.addPhysicsMS(physicsMS); StatsReporter.addOtherMS(otherMS); StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); } - if (loginsdisabled && (m_frame > 20)) + + if (loginsdisabled && m_frame > 20) { // In 99.9% of cases it is a bad idea to manually force garbage collection. However, // this is a rare case where we know we have just went through a long cycle of heap @@ -1176,9 +1166,9 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_groupsWithTargets) { - foreach (KeyValuePair kvp in m_groupsWithTargets) + foreach (SceneObjectGroup entry in m_groupsWithTargets.Values) { - kvp.Value.checkAtTargets(); + entry.checkAtTargets(); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index db055f9..2fdb48d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -369,26 +369,30 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void UpdateObjectGroups() { - Dictionary updates; + List updates; + // Some updates add more updates to the updateList. // Get the current list of updates and clear the list before iterating lock (m_updateList) { - updates = new Dictionary(m_updateList); + updates = new List(m_updateList.Values); m_updateList.Clear(); } + // Go through all updates - foreach (KeyValuePair kvp in updates) + for (int i = 0; i < updates.Count; i++) { + SceneObjectGroup sog = updates[i]; + // Don't abort the whole update if one entity happens to give us an exception. try { - kvp.Value.Update(); + sog.Update(); } catch (Exception e) { m_log.ErrorFormat( - "[INNER SCENE]: Failed to update {0}, {1} - {2}", kvp.Value.Name, kvp.Value.UUID, e); + "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index dbb06f8..0b752c9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1857,28 +1857,15 @@ namespace OpenSim.Region.Framework.Scenes { bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - //if (IsAttachment) - //{ - //foreach (SceneObjectPart part in m_parts.Values) - //{ - //part.SendScheduledUpdates(); - //} - //return; - //} - - if (UsePhysics && Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02)) + if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) { m_rootPart.UpdateFlag = 1; lastPhysGroupPos = AbsolutePosition; } - if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) - || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) - || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1) - || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1))) + if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) { m_rootPart.UpdateFlag = 1; - lastPhysGroupRot = GroupRotation; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 63c979f..1ea4585 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -76,8 +76,7 @@ namespace OpenSim.Region.Framework.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; - - public static byte[] DefaultTexture; + public static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); public UUID currentParcelUUID = UUID.Zero; @@ -100,9 +99,9 @@ namespace OpenSim.Region.Framework.Scenes private bool m_updateflag; private byte m_movementflag; - private readonly List m_forcesList = new List(); + private Vector3? m_forceToApply; private uint m_requestedSitTargetID; - private UUID m_requestedSitTargetUUID = UUID.Zero; + private UUID m_requestedSitTargetUUID; private SendCourseLocationsMethod m_sendCourseLocationsMethod; private bool m_startAnimationSet; @@ -456,12 +455,9 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (m_physicsActor != null) - { - m_velocity.X = m_physicsActor.Velocity.X; - m_velocity.Y = m_physicsActor.Velocity.Y; - m_velocity.Z = m_physicsActor.Velocity.Z; - } + PhysicsActor actor = m_physicsActor; + if (actor != null) + m_velocity = m_physicsActor.Velocity; return m_velocity; } @@ -2278,7 +2274,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_isChildAgent) { - m_log.Debug("DEBUG: AddNewMovement: child agent, Making root agent!"); + m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); // we have to reset the user's child agent connections. // Likely, here they've lost the eventqueue for other regions so border @@ -2287,7 +2283,7 @@ namespace OpenSim.Region.Framework.Scenes List regions = new List(KnownChildRegionHandles); regions.Remove(m_scene.RegionInfo.RegionHandle); - MakeRootAgent(new Vector3(127, 127, 127), true); + MakeRootAgent(new Vector3(127f, 127f, 127f), true); // Async command if (m_scene.SceneGridService != null) @@ -2299,28 +2295,24 @@ namespace OpenSim.Region.Framework.Scenes System.Threading.Thread.Sleep(500); } - if (m_scene.SceneGridService != null) { m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List()); } - - return; } m_perfMonMS = Environment.TickCount; m_rotation = rotation; - NewForce newVelocity = new NewForce(); Vector3 direc = vec * rotation; direc.Normalize(); direc *= 0.03f * 128f * m_speedModifier; if (m_physicsActor.Flying) { - direc *= 4; + direc *= 4.0f; //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); //bool colliding = (m_physicsActor.IsColliding==true); //if (controlland) @@ -2348,10 +2340,8 @@ namespace OpenSim.Region.Framework.Scenes } } - newVelocity.X = direc.X; - newVelocity.Y = direc.Y; - newVelocity.Z = direc.Z; - m_forcesList.Add(newVelocity); + // TODO: Add the force instead of only setting it to support multiple forces per frame? + m_forceToApply = direc; m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); } @@ -3298,47 +3288,18 @@ namespace OpenSim.Region.Framework.Scenes /// public override void UpdateMovement() { - lock (m_forcesList) + if (m_forceToApply.HasValue) { - if (m_forcesList.Count > 0) - { - //we are only interested in the last velocity added to the list [Although they are called forces, they are actually velocities] - NewForce force = m_forcesList[m_forcesList.Count - 1]; + Vector3 force = m_forceToApply.Value; - m_updateflag = true; - try - { - movementvector.X = force.X; - movementvector.Y = force.Y; - movementvector.Z = force.Z; - Velocity = movementvector; - } - catch (NullReferenceException) - { - // Under extreme load, this returns a NullReference Exception that we can ignore. - // Ignoring this causes no movement to be sent to the physics engine... - // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! - } + m_updateflag = true; + movementvector = force; + Velocity = force; - m_forcesList.Clear(); - } + m_forceToApply = null; } } - static ScenePresence() - { - Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); - DefaultTexture = textu.GetBytes(); - - } - - public class NewForce - { - public float X; - public float Y; - public float Z; - } - public override void SetText(string text, Vector3 color, double alpha) { throw new Exception("Can't set Text on avatar."); @@ -3349,7 +3310,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void AddToPhysicalScene(bool isFlying) { - PhysicsScene scene = m_scene.PhysicsScene; Vector3 pVec = AbsolutePosition; @@ -3478,11 +3438,6 @@ namespace OpenSim.Region.Framework.Scenes public ScenePresence() { - if (DefaultTexture == null) - { - Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); - DefaultTexture = textu.GetBytes(); - } m_sendCourseLocationsMethod = SendCoarseLocationsDefault; CreateSceneViewer(); } -- cgit v1.1 From 713287707595061d7ce343db73edf3462d2d29fc Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 01:46:58 -0700 Subject: * Log progress messages when loading OAR files with a lot of assets * Change the PhysicsCollision callback for objects to send full contact point information. This will be used to calculate the collision plane for avatars * Send the physics engine velocity in terse updates, not the current force being applied to the avatar. This should fix several issues including crouching through the floor and walking through walls --- .../World/Archiver/ArchiveReadRequest.cs | 3 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 ++-- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 29 +++-- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 4 +- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 4 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 127 +++++++++++---------- 7 files changed, 108 insertions(+), 81 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 54acbc4..c261943 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -129,6 +129,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver successfulAssetRestores++; else failedAssetRestores++; + + if ((successfulAssetRestores + failedAssetRestores) % 250 == 0) + m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets..."); } else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cf1c394..3d41666 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1817,7 +1817,7 @@ if (m_shape != null) { } CollisionEventUpdate a = (CollisionEventUpdate)e; - Dictionary collissionswith = a.m_objCollisionList; + Dictionary collissionswith = a.m_objCollisionList; List thisHitColliders = new List(); List endedColliders = new List(); List startedColliders = new List(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1ea4585..91044be 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2367,9 +2367,11 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { + Vector3 velocity = m_physicsActor.Velocity; + // Throw away duplicate or insignificant updates if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || - !m_velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { @@ -2378,7 +2380,7 @@ namespace OpenSim.Region.Framework.Scenes // Update the "last" values m_lastPosition = m_pos; m_lastRotation = m_bodyRot; - m_lastVelocity = m_velocity; + m_lastVelocity = velocity; m_lastTerseSent = Environment.TickCount; } @@ -2411,7 +2413,7 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, - pos, m_velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); + pos, m_physicsActor.Velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); m_scene.StatsReporter.AddAgentUpdates(1); @@ -3355,15 +3357,17 @@ namespace OpenSim.Region.Framework.Scenes // as of this comment the interval is set in AddToPhysicalScene UpdateMovementAnimations(); + CollisionEventUpdate collisionData = (CollisionEventUpdate)e; + Dictionary coldata = collisionData.m_objCollisionList; + if (m_invulnerable) return; - CollisionEventUpdate collisionData = (CollisionEventUpdate)e; - Dictionary coldata = collisionData.m_objCollisionList; + float starthealth = Health; uint killerObj = 0; foreach (uint localid in coldata.Keys) { - if (coldata[localid] <= 0.10f || m_invulnerable) + if (coldata[localid].PenetrationDepth <= 0.10f || m_invulnerable) continue; //if (localid == 0) //continue; @@ -3373,9 +3377,9 @@ namespace OpenSim.Region.Framework.Scenes if (part != null && part.ParentGroup.Damage != -1.0f) Health -= part.ParentGroup.Damage; else - Health -= coldata[localid] * 5; + Health -= coldata[localid].PenetrationDepth * 5.0f; - if (Health <= 0) + if (Health <= 0.0f) { if (localid != 0) killerObj = localid; diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 6bfdff2..f58129d 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -52,6 +52,20 @@ namespace OpenSim.Region.Physics.Manager , Absolute } + public struct ContactPoint + { + public Vector3 Position; + public Vector3 SurfaceNormal; + public float PenetrationDepth; + + public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) + { + Position = position; + SurfaceNormal = surfaceNormal; + PenetrationDepth = penetrationDepth; + } + } + public class CollisionEventUpdate : EventArgs { // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. @@ -59,9 +73,9 @@ namespace OpenSim.Region.Physics.Manager public int m_colliderType; public int m_GenericStartEnd; //public uint m_LocalID; - public Dictionary m_objCollisionList = new Dictionary(); + public Dictionary m_objCollisionList = new Dictionary(); - public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary objCollisionList) + public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary objCollisionList) { m_colliderType = colliderType; m_GenericStartEnd = GenericStartEnd; @@ -72,8 +86,7 @@ namespace OpenSim.Region.Physics.Manager { m_colliderType = (int) ActorTypes.Unknown; m_GenericStartEnd = 1; - // m_objCollisionList = null; - m_objCollisionList = new Dictionary(); + m_objCollisionList = new Dictionary(); } public int collidertype @@ -88,16 +101,16 @@ namespace OpenSim.Region.Physics.Manager set { m_GenericStartEnd = value; } } - public void addCollider(uint localID, float depth) + public void addCollider(uint localID, ContactPoint contact) { if (!m_objCollisionList.ContainsKey(localID)) { - m_objCollisionList.Add(localID, depth); + m_objCollisionList.Add(localID, contact); } else { - if (m_objCollisionList[localID] < depth) - m_objCollisionList[localID] = depth; + if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) + m_objCollisionList[localID] = contact; } } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index c86bc62..1bc4a25 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1209,11 +1209,11 @@ namespace OpenSim.Region.Physics.OdePlugin m_requestedUpdateFrequency = 0; m_eventsubscription = 0; } - public void AddCollisionEvent(uint CollidedWith, float depth) + public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { if (m_eventsubscription > 0) { - CollisionEventsThisFrame.addCollider(CollidedWith, depth); + CollisionEventsThisFrame.addCollider(CollidedWith, contact); } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 5ff9d32..f4b502a 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -2958,11 +2958,11 @@ Console.WriteLine(" JointCreateFixed"); m_eventsubscription = 0; } - public void AddCollisionEvent(uint CollidedWith, float depth) + public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { if (CollisionEventsThisFrame == null) CollisionEventsThisFrame = new CollisionEventUpdate(); - CollisionEventsThisFrame.addCollider(CollidedWith,depth); + CollisionEventsThisFrame.addCollider(CollidedWith, contact); } public void SendCollisions() diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 7caaa14..a8e006b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -807,7 +807,7 @@ namespace OpenSim.Region.Physics.OdePlugin p2 = PANull; } - float max_collision_depth = 0f; + ContactPoint maxDepthContact = new ContactPoint(); if (p1.CollisionScore + count >= float.MaxValue) p1.CollisionScore = 0; p1.CollisionScore += count; @@ -818,9 +818,17 @@ namespace OpenSim.Region.Physics.OdePlugin for (int i = 0; i < count; i++) { + d.ContactGeom curContact = contacts[i]; + if (curContact.depth > maxDepthContact.PenetrationDepth) + { + maxDepthContact = new ContactPoint( + new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z), + new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z), + curContact.depth + ); + } - max_collision_depth = (contacts[i].depth > max_collision_depth) ? contacts[i].depth : max_collision_depth; //m_log.Warn("[CCOUNT]: " + count); IntPtr joint; // If we're colliding with terrain, use 'TerrainContact' instead of contact. @@ -853,14 +861,14 @@ namespace OpenSim.Region.Physics.OdePlugin #region InterPenetration Handling - Unintended physics explosions # region disabled code1 - if (contacts[i].depth >= 0.08f) + if (curContact.depth >= 0.08f) { //This is disabled at the moment only because it needs more tweaking //It will eventually be uncommented /* - if (contacts[i].depth >= 1.00f) + if (contact.depth >= 1.00f) { - //m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString()); + //m_log.Debug("[PHYSICS]: " + contact.depth.ToString()); } //If you interpenetrate a prim with an agent @@ -870,37 +878,37 @@ namespace OpenSim.Region.Physics.OdePlugin p2.PhysicsActorType == (int) ActorTypes.Prim)) { - //contacts[i].depth = contacts[i].depth * 4.15f; + //contact.depth = contact.depth * 4.15f; /* if (p2.PhysicsActorType == (int) ActorTypes.Agent) { p2.CollidingObj = true; - contacts[i].depth = 0.003f; + contact.depth = 0.003f; p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); 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)); + contact.pos = new d.Vector3(contact.pos.X + (p1.Size.X / 2), contact.pos.Y + (p1.Size.Y / 2), contact.pos.Z + (p1.Size.Z / 2)); } else { - //contacts[i].depth = 0.0000000f; + //contact.depth = 0.0000000f; } if (p1.PhysicsActorType == (int) ActorTypes.Agent) { p1.CollidingObj = true; - contacts[i].depth = 0.003f; + contact.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)); + contact.pos = new d.Vector3(contact.pos.X + (p2.Size.X / 2), contact.pos.Y + (p2.Size.Y / 2), contact.pos.Z + (p2.Size.Z / 2)); OdeCharacter character = (OdeCharacter)p1; character.SetPidStatus(true); } else { - //contacts[i].depth = 0.0000000f; + //contact.depth = 0.0000000f; } @@ -925,7 +933,7 @@ namespace OpenSim.Region.Physics.OdePlugin //AddPhysicsActorTaint(p2); //} - //if (contacts[i].depth >= 0.25f) + //if (contact.depth >= 0.25f) //{ // Don't collide, one or both prim will expld. @@ -943,21 +951,21 @@ namespace OpenSim.Region.Physics.OdePlugin //AddPhysicsActorTaint(p2); //} - //contacts[i].depth = contacts[i].depth / 8f; - //contacts[i].normal = new d.Vector3(0, 0, 1); + //contact.depth = contact.depth / 8f; + //contact.normal = new d.Vector3(0, 0, 1); //} //if (op1.m_disabled || op2.m_disabled) //{ //Manually disabled objects stay disabled - //contacts[i].depth = 0f; + //contact.depth = 0f; //} #endregion } */ #endregion - if (contacts[i].depth >= 1.00f) + if (curContact.depth >= 1.00f) { - //m_log.Info("[P]: " + contacts[i].depth.ToString()); + //m_log.Info("[P]: " + contact.depth.ToString()); if ((p2.PhysicsActorType == (int) ActorTypes.Agent && p1.PhysicsActorType == (int) ActorTypes.Unknown) || (p1.PhysicsActorType == (int) ActorTypes.Agent && @@ -970,12 +978,12 @@ namespace OpenSim.Region.Physics.OdePlugin OdeCharacter character = (OdeCharacter) p2; //p2.CollidingObj = true; - contacts[i].depth = 0.00000003f; + curContact.depth = 0.00000003f; p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 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)); + curContact.pos = + new d.Vector3(curContact.pos.X + (p1.Size.X/2), + curContact.pos.Y + (p1.Size.Y/2), + curContact.pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); } } @@ -988,12 +996,12 @@ namespace OpenSim.Region.Physics.OdePlugin OdeCharacter character = (OdeCharacter) p1; //p2.CollidingObj = true; - contacts[i].depth = 0.00000003f; + curContact.depth = 0.00000003f; p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 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)); + curContact.pos = + new d.Vector3(curContact.pos.X + (p1.Size.X/2), + curContact.pos.Y + (p1.Size.Y/2), + curContact.pos.Z + (p1.Size.Z/2)); character.SetPidStatus(true); } } @@ -1015,16 +1023,15 @@ namespace OpenSim.Region.Physics.OdePlugin if (!skipThisContact && (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect)) skipThisContact = true; // No collision on volume detect prims - if (!skipThisContact && contacts[i].depth < 0f) + if (!skipThisContact && curContact.depth < 0f) skipThisContact = true; - if (!skipThisContact && checkDupe(contacts[i], p2.PhysicsActorType)) + if (!skipThisContact && checkDupe(curContact, p2.PhysicsActorType)) skipThisContact = true; const int maxContactsbeforedeath = 4000; joint = IntPtr.Zero; - if (!skipThisContact) { // If we're colliding against terrain @@ -1035,8 +1042,8 @@ namespace OpenSim.Region.Physics.OdePlugin (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) { // Use the movement terrain contact - AvatarMovementTerrainContact.geom = contacts[i]; - _perloopContact.Add(contacts[i]); + AvatarMovementTerrainContact.geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact); @@ -1048,8 +1055,8 @@ namespace OpenSim.Region.Physics.OdePlugin if (p2.PhysicsActorType == (int)ActorTypes.Agent) { // Use the non moving terrain contact - TerrainContact.geom = contacts[i]; - _perloopContact.Add(contacts[i]); + TerrainContact.geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); @@ -1074,8 +1081,8 @@ namespace OpenSim.Region.Physics.OdePlugin material = ((OdePrim)p2).m_material; //m_log.DebugFormat("Material: {0}", material); - m_materialContacts[material, movintYN].geom = contacts[i]; - _perloopContact.Add(contacts[i]); + m_materialContacts[material, movintYN].geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { @@ -1100,8 +1107,8 @@ namespace OpenSim.Region.Physics.OdePlugin if (p2 is OdePrim) material = ((OdePrim)p2).m_material; //m_log.DebugFormat("Material: {0}", material); - m_materialContacts[material, movintYN].geom = contacts[i]; - _perloopContact.Add(contacts[i]); + m_materialContacts[material, movintYN].geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { @@ -1129,20 +1136,20 @@ namespace OpenSim.Region.Physics.OdePlugin */ //WaterContact.surface.soft_cfm = 0.0000f; //WaterContact.surface.soft_erp = 0.00000f; - if (contacts[i].depth > 0.1f) + if (curContact.depth > 0.1f) { - contacts[i].depth *= 52; - //contacts[i].normal = new d.Vector3(0, 0, 1); - //contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f); + curContact.depth *= 52; + //contact.normal = new d.Vector3(0, 0, 1); + //contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f); } - WaterContact.geom = contacts[i]; - _perloopContact.Add(contacts[i]); + WaterContact.geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { joint = d.JointCreateContact(world, contactgroup, ref WaterContact); m_global_contactcount++; } - //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth); + //m_log.Info("[PHYSICS]: Prim Water Contact" + contact.depth); } else { @@ -1153,8 +1160,8 @@ namespace OpenSim.Region.Physics.OdePlugin if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) { // Use the Movement prim contact - AvatarMovementprimContact.geom = contacts[i]; - _perloopContact.Add(contacts[i]); + AvatarMovementprimContact.geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact); @@ -1164,8 +1171,8 @@ namespace OpenSim.Region.Physics.OdePlugin else { // Use the non movement contact - contact.geom = contacts[i]; - _perloopContact.Add(contacts[i]); + contact.geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { @@ -1183,8 +1190,8 @@ namespace OpenSim.Region.Physics.OdePlugin material = ((OdePrim)p2).m_material; //m_log.DebugFormat("Material: {0}", material); - m_materialContacts[material, 0].geom = contacts[i]; - _perloopContact.Add(contacts[i]); + m_materialContacts[material, 0].geom = curContact; + _perloopContact.Add(curContact); if (m_global_contactcount < maxContactsbeforedeath) { @@ -1202,7 +1209,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } - collision_accounting_events(p1, p2, max_collision_depth); + collision_accounting_events(p1, p2, maxDepthContact); if (count > geomContactPointsStartthrottle) { // If there are more then 3 contact points, it's likely @@ -1286,7 +1293,7 @@ namespace OpenSim.Region.Physics.OdePlugin return result; } - private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth) + private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) { // obj1LocalID = 0; //returncollisions = false; @@ -1307,7 +1314,7 @@ namespace OpenSim.Region.Physics.OdePlugin case ActorTypes.Agent: cc1 = (OdeCharacter)p1; obj2LocalID = cc1.m_localID; - cc1.AddCollisionEvent(cc2.m_localID, collisiondepth); + cc1.AddCollisionEvent(cc2.m_localID, contact); //ctype = (int)CollisionCategories.Character; //if (cc1.CollidingObj) @@ -1322,7 +1329,7 @@ namespace OpenSim.Region.Physics.OdePlugin { cp1 = (OdePrim) p1; obj2LocalID = cp1.m_localID; - cp1.AddCollisionEvent(cc2.m_localID, collisiondepth); + cp1.AddCollisionEvent(cc2.m_localID, contact); } //ctype = (int)CollisionCategories.Geom; @@ -1342,7 +1349,7 @@ namespace OpenSim.Region.Physics.OdePlugin break; } - cc2.AddCollisionEvent(obj2LocalID, collisiondepth); + cc2.AddCollisionEvent(obj2LocalID, contact); break; case ActorTypes.Prim: @@ -1358,7 +1365,7 @@ namespace OpenSim.Region.Physics.OdePlugin { cc1 = (OdeCharacter) p1; obj2LocalID = cc1.m_localID; - cc1.AddCollisionEvent(cp2.m_localID, collisiondepth); + cc1.AddCollisionEvent(cp2.m_localID, contact); //ctype = (int)CollisionCategories.Character; //if (cc1.CollidingObj) @@ -1374,7 +1381,7 @@ namespace OpenSim.Region.Physics.OdePlugin { cp1 = (OdePrim) p1; obj2LocalID = cp1.m_localID; - cp1.AddCollisionEvent(cp2.m_localID, collisiondepth); + cp1.AddCollisionEvent(cp2.m_localID, contact); //ctype = (int)CollisionCategories.Geom; //if (cp1.CollidingObj) @@ -1395,7 +1402,7 @@ namespace OpenSim.Region.Physics.OdePlugin break; } - cp2.AddCollisionEvent(obj2LocalID, collisiondepth); + cp2.AddCollisionEvent(obj2LocalID, contact); } break; } -- cgit v1.1 From fd2c99f184fa192d316222f90ef76ec8b9726ada Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 02:10:48 -0700 Subject: Fixing NullReferenceException regression in the previous commit --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 91044be..7420134 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2367,7 +2367,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { - Vector3 velocity = m_physicsActor.Velocity; + Vector3 velocity = (m_physicsActor != null) ? m_physicsActor.Velocity : Vector3.Zero; // Throw away duplicate or insignificant updates if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || -- cgit v1.1 From 3f2d6fe4707b6fbb40e775e63c4cd7a7137a9814 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 04:13:51 -0700 Subject: Ported the Simian avatar animation system to OpenSim. Landing is currently not working --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 239 +++++++++++++++++++---- 1 file changed, 203 insertions(+), 36 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7420134..c4f4021 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -130,12 +130,14 @@ namespace OpenSim.Region.Framework.Scenes private bool m_setAlwaysRun; private string m_movementAnimation = "DEFAULT"; - private long m_animPersistUntil = 0; - private bool m_allowFalling = false; - private bool m_useFlySlow = false; - private bool m_usePreJump = false; - private bool m_forceFly = false; - private bool m_flyDisabled = false; + private long m_animPersistUntil; + private int m_animTickFall; + private int m_animTickJump; + private bool m_allowFalling; + private bool m_useFlySlow; + private bool m_usePreJump; + private bool m_forceFly; + private bool m_flyDisabled; private float m_speedModifier = 1.0f; @@ -143,7 +145,7 @@ namespace OpenSim.Region.Framework.Scenes public bool IsRestrictedToRegion; - public string JID = string.Empty; + public string JID = String.Empty; // Agent moves with a PID controller causing a force to be exerted. private bool m_newCoarseLocations = true; @@ -158,43 +160,43 @@ namespace OpenSim.Region.Framework.Scenes private readonly Vector3[] Dir_Vectors = new Vector3[6]; // Position of agent's camera in world (region cordinates) - protected Vector3 m_CameraCenter = Vector3.Zero; - protected Vector3 m_lastCameraCenter = Vector3.Zero; + protected Vector3 m_CameraCenter; + protected Vector3 m_lastCameraCenter; protected Timer m_reprioritization_timer; - protected bool m_reprioritizing = false; - protected bool m_reprioritization_called = false; + protected bool m_reprioritizing; + protected bool m_reprioritization_called; // Use these three vectors to figure out what the agent is looking at // Convert it to a Matrix and/or Quaternion - protected Vector3 m_CameraAtAxis = Vector3.Zero; - protected Vector3 m_CameraLeftAxis = Vector3.Zero; - protected Vector3 m_CameraUpAxis = Vector3.Zero; + protected Vector3 m_CameraAtAxis; + protected Vector3 m_CameraLeftAxis; + protected Vector3 m_CameraUpAxis; private uint m_AgentControlFlags; private Quaternion m_headrotation = Quaternion.Identity; private byte m_state; //Reuse the Vector3 instead of creating a new one on the UpdateMovement method - private Vector3 movementvector = Vector3.Zero; + private Vector3 movementvector; private bool m_autopilotMoving; - private Vector3 m_autoPilotTarget = Vector3.Zero; + private Vector3 m_autoPilotTarget; private bool m_sitAtAutoTarget; private string m_nextSitAnimation = String.Empty; //PauPaw:Proper PID Controler for autopilot************ private bool m_moveToPositionInProgress; - private Vector3 m_moveToPositionTarget = Vector3.Zero; + private Vector3 m_moveToPositionTarget; - private bool m_followCamAuto = false; + private bool m_followCamAuto; - private int m_movementUpdateCount = 0; + private int m_movementUpdateCount; private const int NumMovementsBetweenRayCast = 5; - private bool CameraConstraintActive = false; - //private int m_moveToPositionStateStatus = 0; + private bool CameraConstraintActive; + //private int m_moveToPositionStateStatus; //***************************************************** // Agent's Draw distance. @@ -444,7 +446,7 @@ namespace OpenSim.Region.Framework.Scenes } m_pos = value; - m_parentPosition = new Vector3(0, 0, 0); + m_parentPosition = Vector3.Zero; } } @@ -457,22 +459,21 @@ namespace OpenSim.Region.Framework.Scenes { PhysicsActor actor = m_physicsActor; if (actor != null) - m_velocity = m_physicsActor.Velocity; + m_velocity = actor.Velocity; return m_velocity; } set { //m_log.DebugFormat("In {0} setting velocity of {1} to {2}", m_scene.RegionInfo.RegionName, Name, value); - - if (m_physicsActor != null) + + PhysicsActor actor = m_physicsActor; + if (actor != null) { try { lock (m_scene.SyncRoot) - { - m_physicsActor.Velocity = value; - } + actor.Velocity = value; } catch (Exception e) { @@ -934,7 +935,7 @@ namespace OpenSim.Region.Framework.Scenes isFlying = m_physicsActor.Flying; RemoveFromPhysicalScene(); - Velocity = new Vector3(0, 0, 0); + Velocity = Vector3.Zero; AbsolutePosition = pos; AddToPhysicalScene(isFlying); if (m_appearance != null) @@ -982,12 +983,13 @@ namespace OpenSim.Region.Framework.Scenes if (m_avHeight != 127.0f) { - AbsolutePosition = AbsolutePosition + new Vector3(0, 0, (m_avHeight / 6f)); + AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (m_avHeight / 6f)); } else { - AbsolutePosition = AbsolutePosition + new Vector3(0, 0, (1.56f / 6f)); + AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); } + TrySetMovementAnimation("LAND"); SendFullUpdateToAllClients(); } @@ -1534,7 +1536,7 @@ namespace OpenSim.Region.Framework.Scenes if (part != null) { AbsolutePosition = part.AbsolutePosition; - Velocity = new Vector3(0, 0, 0); + Velocity = Vector3.Zero; SendFullUpdateToAllClients(); //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); @@ -1851,7 +1853,7 @@ namespace OpenSim.Region.Framework.Scenes } m_parentID = m_requestedSitTargetID; - Velocity = new Vector3(0, 0, 0); + Velocity = Vector3.Zero; RemoveFromPhysicalScene(); TrySetMovementAnimation(sitAnimation); @@ -2008,7 +2010,7 @@ namespace OpenSim.Region.Framework.Scenes protected void TrySetMovementAnimation(string anim) { //m_log.DebugFormat("Updating movement animation to {0}", anim); - + if (!m_isChildAgent) { if (m_animations.TrySetDefaultAnimation(anim, m_controllingClient.NextAnimationSequenceNumber, UUID.Zero)) @@ -2239,12 +2241,176 @@ namespace OpenSim.Region.Framework.Scenes } } + public string GetMovementAnimation2() + { + const float FALL_DELAY = 0.33f; + const float PREJUMP_DELAY = 0.25f; + + m_allowFalling = true; + + AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_AgentControlFlags; + PhysicsActor actor = m_physicsActor; + + // Create forward and left vectors from the current avatar rotation + Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_bodyRot); + Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); + Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); + + // Check control flags + bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; + bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; + bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; + bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; + //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; + //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; + bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; + bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; + //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; + //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; + + // Direction in which the avatar is trying to move + Vector3 move = Vector3.Zero; + if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } + if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } + if (heldLeft) { move.X += left.X; move.Y += left.Y; } + if (heldRight) { move.X -= left.X; move.Y -= left.Y; } + if (heldUp) { move.Z += 1; } + if (heldDown) { move.Z -= 1; } + + // Is the avatar trying to move? + bool moving = (move != Vector3.Zero); + bool jumping = m_animTickJump != 0; + + #region Flying + + if (actor != null && actor.Flying) + { + m_animTickFall = 0; + m_animTickJump = 0; + + if (move.X != 0f || move.Y != 0f) + { + return (m_useFlySlow ? "FLYSLOW" : "FLY"); + } + else if (move.Z > 0f) + { + return "HOVER_UP"; + } + else if (move.Z < 0f) + { + if (actor != null && actor.IsColliding) + return "LAND"; + else + return "HOVER_DOWN"; + } + else + { + return "HOVER"; + } + } + + #endregion Flying + + #region Falling/Floating/Landing + + if (actor == null || !actor.IsColliding) + { + float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; + + if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && actor.Velocity.Z >= 0.0f)) + { + // Just started falling + m_animTickFall = Environment.TickCount; + } + else if (!jumping && fallElapsed > FALL_DELAY) + { + // Falling long enough to trigger the animation + return "FALLDOWN"; + } + + return m_movementAnimation; + } + + #endregion Falling/Floating/Landing + + #region Ground Movement + + if (m_movementAnimation == "FALLDOWN") + { + m_animTickFall = Environment.TickCount; + + // TODO: SOFT_LAND support + return "LAND"; + } + else if (m_movementAnimation == "LAND") + { + float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; + + if (landElapsed <= FALL_DELAY) + return "LAND"; + } + + m_animTickFall = 0; + + if (move.Z > 0f) + { + // Jumping + if (!jumping) + { + // Begin prejump + m_animTickJump = Environment.TickCount; + return "PREJUMP"; + } + else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f) + { + // Start actual jump + if (m_animTickJump == -1) + { + // Already jumping! End the current jump + m_animTickJump = 0; + return "JUMP"; + } + + m_animTickJump = -1; + return "JUMP"; + } + } + else + { + // Not jumping + m_animTickJump = 0; + + if (move.X != 0f || move.Y != 0f) + { + // Walking / crouchwalking / running + if (move.Z < 0f) + return "CROUCHWALK"; + else if (m_setAlwaysRun) + return "RUN"; + else + return "WALK"; + } + else + { + // Not walking + if (move.Z < 0f) + return "CROUCH"; + else + return "STAND"; + } + } + + #endregion Ground Movement + + return m_movementAnimation; + } + /// /// Update the movement animation of this avatar according to its current state /// protected void UpdateMovementAnimations() { - string movementAnimation = GetMovementAnimation(); + string movementAnimation = GetMovementAnimation2(); if (movementAnimation == "FALLDOWN" && m_allowFalling == false) { @@ -2367,7 +2533,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { - Vector3 velocity = (m_physicsActor != null) ? m_physicsActor.Velocity : Vector3.Zero; + PhysicsActor actor = m_physicsActor; + Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; // Throw away duplicate or insignificant updates if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || -- cgit v1.1 From 5c894dac8bc99c92a806f0ebc882684fdb76da80 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 05:34:40 -0700 Subject: * Implemented foot collision plane for avatars * Fixed a NullReferenceException regression --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 259 ++++------------------- 1 file changed, 44 insertions(+), 215 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c4f4021..e510f75 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -91,6 +91,7 @@ namespace OpenSim.Region.Framework.Scenes //private SceneObjectPart proxyObjectPart = null; public Vector3 lastKnownAllowedPosition; public bool sentMessageAboutRestrictedParcelFlyingDown; + public Vector4 CollisionPlane = Vector4.UnitW; private Vector3 m_lastPosition; private Quaternion m_lastRotation; @@ -130,10 +131,8 @@ namespace OpenSim.Region.Framework.Scenes private bool m_setAlwaysRun; private string m_movementAnimation = "DEFAULT"; - private long m_animPersistUntil; private int m_animTickFall; private int m_animTickJump; - private bool m_allowFalling; private bool m_useFlySlow; private bool m_usePreJump; private bool m_forceFly; @@ -2045,208 +2044,10 @@ namespace OpenSim.Region.Framework.Scenes /// public string GetMovementAnimation() { - if ((m_animPersistUntil > 0) && (m_animPersistUntil > DateTime.Now.Ticks)) - { - //We don't want our existing state to end yet. - return m_movementAnimation; - - } - else if (m_movementflag != 0) - { - //We're moving - m_allowFalling = true; - if (PhysicsActor != null && PhysicsActor.IsColliding) - { - //And colliding. Can you guess what it is yet? - if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) - { - //Down key is being pressed. - if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) + (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0) - { - return "CROUCHWALK"; - } - else - { - return "CROUCH"; - } - } - else if (m_setAlwaysRun) - { - return "RUN"; - } - else - { - //If we're prejumping then inhibit this, it's a problem - //caused by a false positive on IsColliding - if (m_movementAnimation == "PREJUMP") - { - return "PREJUMP"; - } - else - { - return "WALK"; - } - } - - } - else - { - //We're not colliding. Colliding isn't cool these days. - if (PhysicsActor != null && PhysicsActor.Flying) - { - //Are we moving forwards or backwards? - if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) - { - //Then we really are flying - if (m_setAlwaysRun) - { - return "FLY"; - } - else - { - if (m_useFlySlow == false) - { - return "FLY"; - } - else - { - return "FLYSLOW"; - } - } - } - else - { - if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) - { - return "HOVER_UP"; - } - else - { - return "HOVER_DOWN"; - } - } - - } - else if (m_movementAnimation == "JUMP") - { - //If we were already jumping, continue to jump until we collide - return "JUMP"; - - } - else if (m_movementAnimation == "PREJUMP" && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0) - { - //If we were in a prejump, and the UP key is no longer being held down - //then we're not going to fly, so we're jumping - return "JUMP"; - - } - else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) - { - //They're pressing up, so we're either going to fly or jump - return "PREJUMP"; - } - else - { - //If we're moving and not flying and not jumping and not colliding.. - - if (m_movementAnimation == "WALK" || m_movementAnimation == "RUN") - { - //Let's not enter a FALLDOWN state here, since we're probably - //not colliding because we're going down hill. - return m_movementAnimation; - } - //Record the time we enter this state so we know whether to "land" or not - m_animPersistUntil = DateTime.Now.Ticks; - return "FALLDOWN"; - - } - } - } - else - { - //We're not moving. - if (PhysicsActor != null && PhysicsActor.IsColliding) - { - //But we are colliding. - if (m_movementAnimation == "FALLDOWN") - { - //We're re-using the m_animPersistUntil value here to see how long we've been falling - if ((DateTime.Now.Ticks - m_animPersistUntil) > TimeSpan.TicksPerSecond) - { - //Make sure we don't change state for a bit - m_animPersistUntil = DateTime.Now.Ticks + TimeSpan.TicksPerSecond; - return "LAND"; - } - else - { - //We haven't been falling very long, we were probably just walking down hill - return "STAND"; - } - } - else if (m_movementAnimation == "JUMP" || m_movementAnimation == "HOVER_DOWN") - { - //Make sure we don't change state for a bit - m_animPersistUntil = DateTime.Now.Ticks + (1 * TimeSpan.TicksPerSecond); - return "SOFT_LAND"; - - } - else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) - { - return "PREJUMP"; - } - else if (PhysicsActor != null && PhysicsActor.Flying) - { - m_allowFalling = true; - if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) - { - return "HOVER_UP"; - } - else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) - { - return "HOVER_DOWN"; - } - else - { - return "HOVER"; - } - } - else - { - return "STAND"; - } - - } - else - { - //We're not colliding. - if (PhysicsActor != null && PhysicsActor.Flying) - { - - return "HOVER"; - - } - else if ((m_movementAnimation == "JUMP" || m_movementAnimation == "PREJUMP") && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0) - { - - return "JUMP"; - - } - else - { - //Record the time we enter this state so we know whether to "land" or not - m_animPersistUntil = DateTime.Now.Ticks; - return "FALLDOWN"; // this falling animation is invoked too frequently when capsule tilt correction is used - why? - } - } - } - } - - public string GetMovementAnimation2() - { const float FALL_DELAY = 0.33f; const float PREJUMP_DELAY = 0.25f; - m_allowFalling = true; + #region Inputs AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_AgentControlFlags; PhysicsActor actor = m_physicsActor; @@ -2281,6 +2082,8 @@ namespace OpenSim.Region.Framework.Scenes bool moving = (move != Vector3.Zero); bool jumping = m_animTickJump != 0; + #endregion Inputs + #region Flying if (actor != null && actor.Flying) @@ -2410,24 +2213,16 @@ namespace OpenSim.Region.Framework.Scenes /// protected void UpdateMovementAnimations() { - string movementAnimation = GetMovementAnimation2(); - - if (movementAnimation == "FALLDOWN" && m_allowFalling == false) - { - movementAnimation = m_movementAnimation; - } - else - { - m_movementAnimation = movementAnimation; - } - if (movementAnimation == "PREJUMP" && m_usePreJump == false) + m_movementAnimation = GetMovementAnimation(); + + if (m_movementAnimation == "PREJUMP" && !m_usePreJump) { - //This was the previous behavior before PREJUMP + // This was the previous behavior before PREJUMP TrySetMovementAnimation("JUMP"); } else { - TrySetMovementAnimation(movementAnimation); + TrySetMovementAnimation(m_movementAnimation); } } @@ -2574,13 +2369,16 @@ namespace OpenSim.Region.Framework.Scenes { m_perfMonMS = Environment.TickCount; + PhysicsActor actor = m_physicsActor; + Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; + Vector3 pos = m_pos; pos.Z += m_appearance.HipOffset; //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, - pos, m_physicsActor.Velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); + pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); m_scene.StatsReporter.AddAgentUpdates(1); @@ -3527,6 +3325,37 @@ namespace OpenSim.Region.Framework.Scenes CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; + CollisionPlane = Vector4.UnitW; + + if (coldata.Count != 0) + { + switch (m_movementAnimation) + { + case "STAND": + case "WALK": + case "RUN": + case "CROUCH": + case "CROUCHWALK": + { + ContactPoint lowest; + lowest.SurfaceNormal = Vector3.Zero; + lowest.Position = Vector3.Zero; + lowest.Position.Z = Single.NaN; + + foreach (ContactPoint contact in coldata.Values) + { + if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) + { + lowest = contact; + } + } + + CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); + } + break; + } + } + if (m_invulnerable) return; -- cgit v1.1 From 33448e4ba83b590e0e7e340faf3d7f2cef80c611 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Mon, 26 Oct 2009 07:50:25 -0700 Subject: Optimizations --- .../Region/ScriptEngine/Interfaces/ICompiler.cs | 4 +- .../ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 2 +- .../ScriptEngine/Shared/CodeTools/Compiler.cs | 156 ++++++++++----------- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 28 ++-- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 51 ++++--- 5 files changed, 123 insertions(+), 118 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs index f8af902..e4ca635 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/ICompiler.cs @@ -34,9 +34,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces { public interface ICompiler { - object PerformScriptCompile(string source, string asset, UUID ownerID); + void PerformScriptCompile(string source, string asset, UUID ownerID, out string assembly, out Dictionary, KeyValuePair> linemap); string[] GetWarnings(); - Dictionary, KeyValuePair> - LineMap(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 917ca44..121159c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs @@ -113,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return; //ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); - RemotingServices.GetLifetimeService(data as MarshalByRefObject); + //RemotingServices.GetLifetimeService(data as MarshalByRefObject); // lease.Register(m_sponser); MethodInfo mi = inits[api]; diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index fe26429..d781a1a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -74,7 +74,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools private string FilePrefix; private string ScriptEnginesPath = "ScriptEngines"; // mapping between LSL and C# line/column numbers - private Dictionary, KeyValuePair> m_positionMap; private ICodeConverter LSL_Converter; private List m_warnings = new List(); @@ -91,6 +90,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools private static UInt64 scriptCompileCounter = 0; // And a counter public IScriptEngine m_scriptEngine; + private Dictionary, KeyValuePair>> m_lineMaps = + new Dictionary, KeyValuePair>>(); + public Compiler(IScriptEngine scriptEngine) { m_scriptEngine = scriptEngine; @@ -271,16 +273,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// LSL script /// Filename to .dll assembly - public object PerformScriptCompile(string Script, string asset, UUID ownerUUID) + public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, + out string assembly, out Dictionary, KeyValuePair> linemap) { - m_positionMap = null; + linemap = null; m_warnings.Clear(); - - string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( + + assembly = Path.Combine(ScriptEnginesPath, Path.Combine( m_scriptEngine.World.RegionInfo.RegionID.ToString(), FilePrefix + "_compiled_" + asset + ".dll")); -// string OutFile = Path.Combine(ScriptEnginesPath, -// FilePrefix + "_compiled_" + asset + ".dll"); if (!Directory.Exists(ScriptEnginesPath)) { @@ -305,51 +306,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } } - if (Script == String.Empty) + // Don't recompile if we already have it + // Performing 3 file exists tests for every script can still be slow + if (File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map")) { - if (File.Exists(OutFile)) - return OutFile; - - throw new Exception("Cannot find script assembly and no script text present"); + // If we have already read this linemap file, then it will be in our dictionary. + // Don't build another copy of the dictionary (saves memory) and certainly + // don't keep reading the same file from disk multiple times. + if (!m_lineMaps.ContainsKey(assembly)) + m_lineMaps[assembly] = ReadMapFile(assembly + ".map"); + linemap = m_lineMaps[assembly]; + return; } - // Don't recompile if we already have it - // - if (File.Exists(OutFile) && File.Exists(OutFile+".text") && File.Exists(OutFile+".map")) + if (Script == String.Empty) { - ReadMapFile(OutFile+".map"); - return OutFile; + throw new Exception("Cannot find script assembly and no script text present"); } - enumCompileType l = DefaultCompileLanguage; + enumCompileType language = DefaultCompileLanguage; if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture)) - l = enumCompileType.cs; + language = enumCompileType.cs; if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture)) { - l = enumCompileType.vb; + language = enumCompileType.vb; // We need to remove //vb, it won't compile with that Script = Script.Substring(4, Script.Length - 4); } if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) - l = enumCompileType.lsl; + language = enumCompileType.lsl; if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) - l = enumCompileType.js; + language = enumCompileType.js; if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) - l = enumCompileType.yp; + language = enumCompileType.yp; - if (!AllowedCompilers.ContainsKey(l.ToString())) + if (!AllowedCompilers.ContainsKey(language.ToString())) { // Not allowed to compile to this language! string errtext = String.Empty; - errtext += "The compiler for language \"" + l.ToString() + "\" is not in list of allowed compilers. Script will not be executed!"; + errtext += "The compiler for language \"" + language.ToString() + "\" is not in list of allowed compilers. Script will not be executed!"; throw new Exception(errtext); } - if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)l) == false) { + if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false) { // Not allowed to compile to this language! string errtext = String.Empty; errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!"; @@ -358,7 +361,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools string compileScript = Script; - if (l == enumCompileType.lsl) + if (language == enumCompileType.lsl) { // Its LSL, convert it to C# LSL_Converter = (ICodeConverter)new CSCodeGenerator(); @@ -370,16 +373,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools AddWarning(warning); } - m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap; + linemap = ((CSCodeGenerator) LSL_Converter).PositionMap; + // Write the linemap to a file and save it in our dictionary for next time. + m_lineMaps[assembly] = linemap; + WriteMapFile(assembly + ".map", linemap); } - if (l == enumCompileType.yp) + if (language == enumCompileType.yp) { // Its YP, convert it to C# compileScript = YP_Converter.Convert(Script); } - switch (l) + switch (language) { case enumCompileType.cs: case enumCompileType.lsl: @@ -396,7 +402,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools break; } - return CompileFromDotNetText(compileScript, l, asset); + assembly = CompileFromDotNetText(compileScript, language, asset, assembly); + return; } public string[] GetWarnings() @@ -468,18 +475,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// CS script /// Filename to .dll assembly - internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset) + internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) { string ext = "." + lang.ToString(); // Output assembly name scriptCompileCounter++; - string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine( - m_scriptEngine.World.RegionInfo.RegionID.ToString(), - FilePrefix + "_compiled_" + asset + ".dll")); try { - File.Delete(OutFile); + File.Delete(assembly); } catch (Exception e) // NOTLEGIT - Should be just FileIOException { @@ -492,7 +496,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if (WriteScriptSourceToDebugFile) { string srcFileName = FilePrefix + "_source_" + - Path.GetFileNameWithoutExtension(OutFile) + ext; + Path.GetFileNameWithoutExtension(assembly) + ext; try { File.WriteAllText(Path.Combine(Path.Combine( @@ -528,7 +532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } parameters.GenerateExecutable = false; - parameters.OutputAssembly = OutFile; + parameters.OutputAssembly = assembly; parameters.IncludeDebugInformation = CompileWithDebugInformation; //parameters.WarningLevel = 1; // Should be 4? parameters.TreatWarningsAsErrors = false; @@ -609,7 +613,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if (severity == "Error") { - lslPos = FindErrorPosition(CompErr.Line, CompErr.Column); + lslPos = FindErrorPosition(CompErr.Line, CompErr.Column, m_lineMaps[assembly]); string text = CompErr.ErrorText; // Use LSL type names @@ -635,14 +639,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // the compile may not be immediately apparent. Wait a // reasonable amount of time before giving up on it. - if (!File.Exists(OutFile)) + if (!File.Exists(assembly)) { - for (int i=0; i<20 && !File.Exists(OutFile); i++) + for (int i=0; i<20 && !File.Exists(assembly); i++) { System.Threading.Thread.Sleep(250); } // One final chance... - if (!File.Exists(OutFile)) + if (!File.Exists(assembly)) { errtext = String.Empty; errtext += "No compile error. But not able to locate compiled file."; @@ -658,7 +662,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // // Read the binary file into a buffer // - FileInfo fi = new FileInfo(OutFile); + FileInfo fi = new FileInfo(assembly); if (fi == null) { @@ -671,7 +675,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools try { - FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); + FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); fs.Read(data, 0, data.Length); fs.Close(); } @@ -690,34 +694,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools Byte[] buf = enc.GetBytes(filetext); - FileStream sfs = File.Create(OutFile+".text"); + FileStream sfs = File.Create(assembly+".text"); sfs.Write(buf, 0, buf.Length); sfs.Close(); - string posmap = String.Empty; - if (m_positionMap != null) - { - foreach (KeyValuePair, KeyValuePair> kvp in m_positionMap) - { - KeyValuePair k = kvp.Key; - KeyValuePair v = kvp.Value; - posmap += String.Format("{0},{1},{2},{3}\n", - k.Key, k.Value, v.Key, v.Value); - } - } - - buf = enc.GetBytes(posmap); - - FileStream mfs = File.Create(OutFile+".map"); - mfs.Write(buf, 0, buf.Length); - mfs.Close(); - - return OutFile; - } - - public KeyValuePair FindErrorPosition(int line, int col) - { - return FindErrorPosition(line, col, m_positionMap); + return assembly; } private class kvpSorter : IComparer> @@ -791,27 +772,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools return message; } - public Dictionary, KeyValuePair> LineMap() + + private static void WriteMapFile(string filename, Dictionary, KeyValuePair> linemap) { - if (m_positionMap == null) - return null; - - Dictionary, KeyValuePair> ret = - new Dictionary, KeyValuePair>(); - - foreach (KeyValuePair kvp in m_positionMap.Keys) - ret.Add(kvp, m_positionMap[kvp]); - - return ret; + string mapstring = String.Empty; + foreach (KeyValuePair, KeyValuePair> kvp in linemap) + { + KeyValuePair k = kvp.Key; + KeyValuePair v = kvp.Value; + mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); + } + + System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); + Byte[] mapbytes = enc.GetBytes(mapstring); + FileStream mfs = File.Create(filename); + mfs.Write(mapbytes, 0, mapbytes.Length); + mfs.Close(); } - private void ReadMapFile(string filename) + + private static Dictionary, KeyValuePair> ReadMapFile(string filename) { + Dictionary, KeyValuePair> linemap; try { StreamReader r = File.OpenText(filename); - - m_positionMap = new Dictionary, KeyValuePair>(); + linemap = new Dictionary, KeyValuePair>(); string line; while ((line = r.ReadLine()) != null) @@ -825,12 +811,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools KeyValuePair k = new KeyValuePair(kk, kv); KeyValuePair v = new KeyValuePair(vk, vv); - m_positionMap[k] = v; + linemap[k] = v; } } catch { + linemap = new Dictionary, KeyValuePair>(); } + return linemap; } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 2b858ec..37ec5df 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private StateSource m_stateSource; private bool m_postOnRez; private bool m_startedFromSavedState = false; - private string m_CurrentState = String.Empty; + private int m_CurrentStateHash; private UUID m_RegionID = UUID.Zero; private Dictionary, KeyValuePair> @@ -252,16 +252,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { m_Apis[api] = am.CreateApi(api); m_Apis[api].Initialize(engine, part, m_LocalID, itemID); - } + } + + try + { + if (dom != System.AppDomain.CurrentDomain) + m_Script = (IScript)dom.CreateInstanceAndUnwrap( + Path.GetFileNameWithoutExtension(assembly), + "SecondLife.Script"); + else + m_Script = (IScript)Assembly.Load( + Path.GetFileNameWithoutExtension(assembly)).CreateInstance( + "SecondLife.Script"); - try - { - m_Script = (IScript)dom.CreateInstanceAndUnwrap( - Path.GetFileNameWithoutExtension(assembly), - "SecondLife.Script"); //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); - RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); + //RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); // lease.Register(this); } catch (Exception) @@ -893,7 +899,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance string xml = ScriptSerializer.Serialize(this); - if (m_CurrentState != xml) + // Compare hash of the state we just just created with the state last written to disk + // If the state is different, update the disk file. + if(xml.GetHashCode() != m_CurrentStateHash) { try { @@ -911,7 +919,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance //{ // throw new Exception("Completed persistence save, but no file was created"); //} - m_CurrentState = xml; + m_CurrentStateHash = xml.GetHashCode(); } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 7b19ce3..57042e9 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -73,9 +73,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine private bool m_InitialStartup = true; private int m_ScriptFailCount; // Number of script fails since compile queue was last empty private string m_ScriptErrorMessage; + private Dictionary m_uniqueScripts = new Dictionary(); + private bool m_AppDomainLoading; -// disable warning: need to keep a reference to XEngine.EventManager -// alive to avoid it being garbage collected + // disable warning: need to keep a reference to XEngine.EventManager + // alive to avoid it being garbage collected #pragma warning disable 414 private EventManager m_EventManager; #pragma warning restore 414 @@ -201,6 +203,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; + m_AppDomainLoading = m_ScriptConfig.GetBoolean("AppDomainLoading", true); m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); @@ -470,6 +473,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (engine != ScriptEngineName) return; + // If we've seen this exact script text before, use that reference instead + if (m_uniqueScripts.ContainsKey(script)) + script = m_uniqueScripts[script]; + else + m_uniqueScripts[script] = script; + Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; if (stateSource == (int)StateSource.ScriptedRez) @@ -590,14 +599,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine { lock (m_AddingAssemblies) { - assembly = (string)m_Compiler.PerformScriptCompile(script, - assetID.ToString(), item.OwnerID); + m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); if (!m_AddingAssemblies.ContainsKey(assembly)) { m_AddingAssemblies[assembly] = 1; } else { m_AddingAssemblies[assembly]++; } - linemap = m_Compiler.LineMap(); } string[] warnings = m_Compiler.GetWarnings(); @@ -696,19 +703,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; Evidence evidence = new Evidence(baseEvidence); - AppDomain sandbox = - AppDomain.CreateDomain( - m_Scene.RegionInfo.RegionID.ToString(), - evidence, appSetup); -/* - PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); - AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); - PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); - PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); - CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); - sandboxPolicy.RootCodeGroup = sandboxCodeGroup; - sandbox.SetAppDomainPolicy(sandboxPolicy); -*/ + AppDomain sandbox; + if (m_AppDomainLoading) + sandbox = AppDomain.CreateDomain( + m_Scene.RegionInfo.RegionID.ToString(), + evidence, appSetup); + else + sandbox = AppDomain.CurrentDomain; + /* + PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); + AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); + PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); + PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); + CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); + sandboxPolicy.RootCodeGroup = sandboxCodeGroup; + sandbox.SetAppDomainPolicy(sandboxPolicy); + */ m_AppDomains[appDomain] = sandbox; m_AppDomains[appDomain].AssemblyResolve += @@ -905,9 +915,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine AppDomain domain = m_AppDomains[id]; m_AppDomains.Remove(id); - AppDomain.Unload(domain); + if (domain != AppDomain.CurrentDomain) + AppDomain.Unload(domain); domain = null; -// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); + // m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString()); } } -- cgit v1.1 From dd13fa361b12fa2fb1c91c9f74379a305935a87d Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 05:56:37 -0700 Subject: * Misc. formatting cleanup for the previous patch * Added the new AppDomainLoading variable to the [XEngine] section in the example config --- .../ScriptEngine/Shared/CodeTools/Compiler.cs | 51 +++++++++++----------- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 8 ++-- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 18 ++++---- bin/OpenSim.ini.example | 7 +++ 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index d781a1a..3080c71 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -174,8 +174,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools else { #if DEBUG -// m_log.Debug("[Compiler]: " + -// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); + // m_log.Debug("[Compiler]: " + + // "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); #endif // LANGUAGE IS IN ALLOW-LIST DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; @@ -214,12 +214,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools catch (Exception ex) { m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath, - m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString()); + m_scriptEngine.World.RegionInfo.RegionID.ToString()) + "\": " + ex.ToString()); } } foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath, - m_scriptEngine.World.RegionInfo.RegionID.ToString()),FilePrefix + "_compiled*")) + m_scriptEngine.World.RegionInfo.RegionID.ToString()), FilePrefix + "_compiled*")) { try { @@ -273,8 +273,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// /// LSL script /// Filename to .dll assembly - public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, - out string assembly, out Dictionary, KeyValuePair> linemap) + public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, + out string assembly, out Dictionary, KeyValuePair> linemap) { linemap = null; m_warnings.Clear(); @@ -352,13 +352,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools throw new Exception(errtext); } - if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false) { + if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false) + { // Not allowed to compile to this language! string errtext = String.Empty; errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!"; throw new Exception(errtext); } - + string compileScript = Script; if (language == enumCompileType.lsl) @@ -373,7 +374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools AddWarning(warning); } - linemap = ((CSCodeGenerator) LSL_Converter).PositionMap; + linemap = ((CSCodeGenerator)LSL_Converter).PositionMap; // Write the linemap to a file and save it in our dictionary for next time. m_lineMaps[assembly] = linemap; WriteMapFile(assembly + ".map", linemap); @@ -487,7 +488,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } catch (Exception e) // NOTLEGIT - Should be just FileIOException { - throw new Exception("Unable to delete old existing "+ + throw new Exception("Unable to delete old existing " + "script-file before writing new. Compile aborted: " + e.ToString()); } @@ -506,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } catch (Exception ex) //NOTLEGIT - Should be just FileIOException { - m_log.Error("[Compiler]: Exception while "+ + m_log.Error("[Compiler]: Exception while " + "trying to write script source to file \"" + srcFileName + "\": " + ex.ToString()); } @@ -547,7 +548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools case enumCompileType.cs: case enumCompileType.lsl: bool complete = false; - bool retried = false; + bool retried = false; do { lock (CScodeProvider) @@ -588,7 +589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools parameters, Script); break; default: - throw new Exception("Compiler is not able to recongnize "+ + throw new Exception("Compiler is not able to recongnize " + "language type \"" + lang.ToString() + "\""); } @@ -641,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if (!File.Exists(assembly)) { - for (int i=0; i<20 && !File.Exists(assembly); i++) + for (int i = 0; i < 20 && !File.Exists(assembly); i++) { System.Threading.Thread.Sleep(250); } @@ -654,8 +655,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } } -// m_log.DebugFormat("[Compiler] Compiled new assembly "+ -// "for {0}", asset); + // m_log.DebugFormat("[Compiler] Compiled new assembly "+ + // "for {0}", asset); // Because windows likes to perform exclusive locks, we simply // write out a textual representation of the file here @@ -694,17 +695,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools Byte[] buf = enc.GetBytes(filetext); - FileStream sfs = File.Create(assembly+".text"); + FileStream sfs = File.Create(assembly + ".text"); sfs.Write(buf, 0, buf.Length); sfs.Close(); return assembly; } - private class kvpSorter : IComparer> + private class kvpSorter : IComparer> { - public int Compare(KeyValuePair a, - KeyValuePair b) + public int Compare(KeyValuePair a, + KeyValuePair b) { return a.Key.CompareTo(b.Key); } @@ -723,8 +724,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools out ret)) return ret; - List> sorted = - new List>(positionMap.Keys); + List> sorted = + new List>(positionMap.Keys); sorted.Sort(new kvpSorter()); @@ -791,18 +792,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } - private static Dictionary, KeyValuePair> ReadMapFile(string filename) + private static Dictionary, KeyValuePair> ReadMapFile(string filename) { Dictionary, KeyValuePair> linemap; try { StreamReader r = File.OpenText(filename); linemap = new Dictionary, KeyValuePair>(); - + string line; while ((line = r.ReadLine()) != null) { - String[] parts = line.Split(new Char[] {','}); + String[] parts = line.Split(new Char[] { ',' }); int kk = System.Convert.ToInt32(parts[0]); int kv = System.Convert.ToInt32(parts[1]); int vk = System.Convert.ToInt32(parts[2]); diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 37ec5df..f16aefc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private StateSource m_stateSource; private bool m_postOnRez; private bool m_startedFromSavedState = false; - private int m_CurrentStateHash; + private UUID m_CurrentStateHash; private UUID m_RegionID = UUID.Zero; private Dictionary, KeyValuePair> @@ -901,7 +901,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // Compare hash of the state we just just created with the state last written to disk // If the state is different, update the disk file. - if(xml.GetHashCode() != m_CurrentStateHash) + UUID hash = UUID.Parse(Utils.MD5String(xml)); + + if(hash != m_CurrentStateHash) { try { @@ -919,7 +921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance //{ // throw new Exception("Completed persistence save, but no file was created"); //} - m_CurrentStateHash = xml.GetHashCode(); + m_CurrentStateHash = hash; } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 57042e9..b13e0de 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -710,15 +710,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine evidence, appSetup); else sandbox = AppDomain.CurrentDomain; - /* - PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); - AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); - PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); - PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); - CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); - sandboxPolicy.RootCodeGroup = sandboxCodeGroup; - sandbox.SetAppDomainPolicy(sandboxPolicy); - */ + + //PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); + //AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); + //PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); + //PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); + //CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); + //sandboxPolicy.RootCodeGroup = sandboxCodeGroup; + //sandbox.SetAppDomainPolicy(sandboxPolicy); + m_AppDomains[appDomain] = sandbox; m_AppDomains[appDomain].AssemblyResolve += diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 63a9e11..3877164 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -940,6 +940,13 @@ ; Stack size per thread created ThreadStackSize = 262144 + + ; Set this to true (the default) to load each script into a separate + ; AppDomain. Setting this to false will load all script assemblies into the + ; current AppDomain, which will reduce the per-script overhead at the + ; expense of reduced security and the inability to garbage collect the + ; script assemblies + AppDomainLoading = true ; Rate to poll for asynchronous command replies (ms) ; currently unused -- cgit v1.1 From ec7fd8b1f810a13e7f78448e9ef81113ed3c5bf0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 06:42:40 -0700 Subject: More performance improvements to XEngine script loading --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 24 ++++---- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 67 ++++++++-------------- 2 files changed, 37 insertions(+), 54 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index f16aefc..549c038 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -74,27 +74,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private string m_PrimName; private string m_ScriptName; private string m_Assembly; - private int m_StartParam = 0; + private int m_StartParam; private string m_CurrentEvent = String.Empty; - private bool m_InSelfDelete = false; + private bool m_InSelfDelete; private int m_MaxScriptQueue; private bool m_SaveState = true; - private bool m_ShuttingDown = false; - private int m_ControlEventsInQueue = 0; - private int m_LastControlLevel = 0; - private bool m_CollisionInQueue = false; + private bool m_ShuttingDown; + private int m_ControlEventsInQueue; + private int m_LastControlLevel; + private bool m_CollisionInQueue; private TaskInventoryItem m_thisScriptTask; // The following is for setting a minimum delay between events - private double m_minEventDelay = 0; - private long m_eventDelayTicks = 0; - private long m_nextEventTimeTicks = 0; + private double m_minEventDelay; + private long m_eventDelayTicks; + private long m_nextEventTimeTicks; private bool m_startOnInit = true; - private UUID m_AttachedAvatar = UUID.Zero; + private UUID m_AttachedAvatar; private StateSource m_stateSource; private bool m_postOnRez; - private bool m_startedFromSavedState = false; + private bool m_startedFromSavedState; private UUID m_CurrentStateHash; - private UUID m_RegionID = UUID.Zero; + private UUID m_RegionID; private Dictionary, KeyValuePair> m_LineMap; diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b13e0de..b0fce75 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.CodeTools; using OpenSim.Region.ScriptEngine.Shared.Instance; using OpenSim.Region.ScriptEngine.Interfaces; +using ScriptCompileQueue = OpenSim.Framework.LocklessQueue; +using Parallel = OpenSim.Framework.Parallel; + namespace OpenSim.Region.ScriptEngine.XEngine { public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine @@ -116,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine private Dictionary > m_DomainScripts = new Dictionary >(); - private Queue m_CompileQueue = new Queue(100); + private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); IWorkItemResult m_CurrentCompile = null; public string ScriptEngineName @@ -487,16 +490,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine } else { - lock (m_CompileQueue) - { - m_CompileQueue.Enqueue(parms); + m_CompileQueue.Enqueue(parms); - if (m_CurrentCompile == null) - { - m_CurrentCompile = m_ThreadPool.QueueWorkItem( - new WorkItemCallback(this.DoOnRezScriptQueue), - new Object[0]); - } + if (m_CurrentCompile == null) + { + m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); } } } @@ -507,50 +505,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine { m_InitialStartup = false; System.Threading.Thread.Sleep(15000); - lock (m_CompileQueue) + + if (m_CompileQueue.Count == 0) { - if (m_CompileQueue.Count==0) - // No scripts on region, so won't get triggered later - // by the queue becoming empty so we trigger it here - m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); + // No scripts on region, so won't get triggered later + // by the queue becoming empty so we trigger it here + m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); } } - Object o; - lock (m_CompileQueue) + List compiles = new List(); + object[] o; + while (m_CompileQueue.Dequeue(out o)) { - o = m_CompileQueue.Dequeue(); - if (o == null) - { - m_CurrentCompile = null; - return null; - } + compiles.Add(o); } - DoOnRezScript(o); + Parallel.For(0, compiles.Count, delegate(int i) { DoOnRezScript(compiles[i]); }); + + m_CurrentCompile = null; + m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, + m_ScriptErrorMessage); + m_ScriptFailCount = 0; - lock (m_CompileQueue) - { - if (m_CompileQueue.Count > 0) - { - m_CurrentCompile = m_ThreadPool.QueueWorkItem( - new WorkItemCallback(this.DoOnRezScriptQueue), - new Object[0]); - } - else - { - m_CurrentCompile = null; - m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, - m_ScriptErrorMessage); - m_ScriptFailCount = 0; - } - } return null; } - private bool DoOnRezScript(object parm) + private bool DoOnRezScript(object[] parms) { - Object[] p = (Object[])parm; + Object[] p = parms; uint localID = (uint)p[0]; UUID itemID = (UUID)p[1]; string script =(string)p[2]; -- cgit v1.1 From 2913c24c8a5a4a50e9267aa125abcc7956a388d1 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 15:24:31 -0700 Subject: * Commented out two noisy debug lines in the LLUDP server * Misc. cleanup in ScenePresence.HandleAgentUpdate() --- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 4 +- .../Region/Framework/Scenes/Scene.Permissions.cs | 36 +-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 263 ++++++++++----------- 3 files changed, 144 insertions(+), 159 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index dc72939..a211508 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -429,7 +429,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (expiredPackets != null) { - m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); + //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); // Exponential backoff of the retransmission timeout udpClient.BackoffRTO(); @@ -585,7 +585,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP IClientAPI client; if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) { - m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); + //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); return; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d01cef7..d1d6b6a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -35,7 +35,7 @@ using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.Framework.Scenes { #region Delegates - public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectIDID); + public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID); public delegate void SetBypassPermissionsHandler(bool value); public delegate bool BypassPermissionsHandler(); public delegate bool PropagatePermissionsHandler(); @@ -147,28 +147,28 @@ namespace OpenSim.Region.Framework.Scenes public uint GenerateClientFlags(UUID userID, UUID objectID) { - SceneObjectPart part=m_scene.GetSceneObjectPart(objectID); + // libomv will moan about PrimFlags.ObjectYouOfficer being + // obsolete... +#pragma warning disable 0612 + const PrimFlags DEFAULT_FLAGS = + PrimFlags.ObjectModify | + PrimFlags.ObjectCopy | + PrimFlags.ObjectMove | + PrimFlags.ObjectTransfer | + PrimFlags.ObjectYouOwner | + PrimFlags.ObjectAnyOwner | + PrimFlags.ObjectOwnerModify | + PrimFlags.ObjectYouOfficer; +#pragma warning restore 0612 + + SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); if (part == null) return 0; - // libomv will moan about PrimFlags.ObjectYouOfficer being - // obsolete... - #pragma warning disable 0612 - uint perms=part.GetEffectiveObjectFlags() | - (uint)PrimFlags.ObjectModify | - (uint)PrimFlags.ObjectCopy | - (uint)PrimFlags.ObjectMove | - (uint)PrimFlags.ObjectTransfer | - (uint)PrimFlags.ObjectYouOwner | - (uint)PrimFlags.ObjectAnyOwner | - (uint)PrimFlags.ObjectOwnerModify | - (uint)PrimFlags.ObjectYouOfficer; - #pragma warning restore 0612 - - GenerateClientFlagsHandler handlerGenerateClientFlags = - OnGenerateClientFlags; + uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS; + GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags; if (handlerGenerateClientFlags != null) { Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e510f75..04c22d0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -76,7 +76,9 @@ namespace OpenSim.Region.Framework.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; - public static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); + private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); + private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); + private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); public UUID currentParcelUUID = UUID.Zero; @@ -171,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_CameraAtAxis; protected Vector3 m_CameraLeftAxis; protected Vector3 m_CameraUpAxis; - private uint m_AgentControlFlags; + private AgentManager.ControlFlags m_AgentControlFlags; private Quaternion m_headrotation = Quaternion.Identity; private byte m_state; @@ -380,8 +382,8 @@ namespace OpenSim.Region.Framework.Scenes public uint AgentControlFlags { - get { return m_AgentControlFlags; } - set { m_AgentControlFlags = value; } + get { return (uint)m_AgentControlFlags; } + set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } } /// @@ -707,25 +709,25 @@ namespace OpenSim.Region.Framework.Scenes private void SetDirectionVectors() { - Dir_Vectors[0] = new Vector3(1, 0, 0); //FORWARD - Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK - Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT - Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT - Dir_Vectors[4] = new Vector3(0, 0, 1); //UP - Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN - Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge + Dir_Vectors[0] = Vector3.UnitX; //FORWARD + Dir_Vectors[1] = -Vector3.UnitX; //BACK + Dir_Vectors[2] = Vector3.UnitY; //LEFT + Dir_Vectors[3] = -Vector3.UnitY; //RIGHT + Dir_Vectors[4] = Vector3.UnitZ; //UP + Dir_Vectors[5] = -Vector3.UnitZ; //DOWN + Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge } private Vector3[] GetWalkDirectionVectors() { Vector3[] vector = new Vector3[6]; - vector[0] = new Vector3(m_CameraUpAxis.Z, 0, -m_CameraAtAxis.Z); //FORWARD - vector[1] = new Vector3(-m_CameraUpAxis.Z, 0, m_CameraAtAxis.Z); //BACK - vector[2] = new Vector3(0, 1, 0); //LEFT - vector[3] = new Vector3(0, -1, 0); //RIGHT - vector[4] = new Vector3(m_CameraAtAxis.Z, 0, m_CameraUpAxis.Z); //UP - vector[5] = new Vector3(-m_CameraAtAxis.Z, 0, -m_CameraUpAxis.Z); //DOWN - vector[5] = new Vector3(-m_CameraAtAxis.Z, 0, -m_CameraUpAxis.Z); //DOWN_Nudge + vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD + vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK + vector[2] = Vector3.UnitY; //LEFT + vector[3] = -Vector3.UnitY; //RIGHT + vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP + vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN + vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge return vector; } @@ -1074,7 +1076,7 @@ namespace OpenSim.Region.Framework.Scenes } m_isChildAgent = false; - bool m_flying = ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); MakeRootAgent(AbsolutePosition, m_flying); if ((m_callbackURI != null) && !m_callbackURI.Equals("")) @@ -1101,9 +1103,12 @@ namespace OpenSim.Region.Framework.Scenes /// public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) { + const float POSITION_TOLERANCE = 0.02f; + const float VELOCITY_TOLERANCE = 0.02f; + const float ROTATION_TOLERANCE = 0.02f; + if (m_followCamAuto) { - if (hitYN) { CameraConstraintActive = true; @@ -1112,11 +1117,11 @@ namespace OpenSim.Region.Framework.Scenes Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); } - else + else { - if ((m_pos - m_lastPosition).Length() > 0.02f || - (m_velocity - m_lastVelocity).Length() > 0.02f || - m_bodyRot != m_lastRotation) + if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || + !m_velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) { if (CameraConstraintActive) { @@ -1125,13 +1130,11 @@ namespace OpenSim.Region.Framework.Scenes } } } - } + } } - Array m_dirControlFlags = Enum.GetValues(typeof(Dir_ControlFlags)); - /// - /// This is the event handler for client movement. If a client is moving, this event is triggering. + /// This is the event handler for client movement. If a client is moving, this event is triggering. /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { @@ -1147,15 +1150,13 @@ namespace OpenSim.Region.Framework.Scenes if (m_movementUpdateCount < 1) m_movementUpdateCount = 1; - // Must check for standing up even when PhysicsActor is null, - // since sitting currently removes avatar from physical scene - //m_log.Debug("agentPos:" + AbsolutePosition.ToString()); + #region Sanity Checking // This is irritating. Really. if (!AbsolutePosition.IsFinite()) { RemoveFromPhysicalScene(); - m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999902"); + m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); m_pos = m_LastFinitePos; if (!m_pos.IsFinite()) @@ -1163,7 +1164,7 @@ namespace OpenSim.Region.Framework.Scenes m_pos.X = 127f; m_pos.Y = 127f; m_pos.Z = 127f; - m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999903"); + m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); } AddToPhysicalScene(false); @@ -1173,18 +1174,11 @@ namespace OpenSim.Region.Framework.Scenes m_LastFinitePos = m_pos; } - //m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true); + #endregion Sanity Checking - //ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); - //if (land != null) - //{ - //if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero) - //{ - // agent.startpos = land.landData.userLocation; - //} - //} + #region Inputs - uint flags = agentData.ControlFlags; + AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; Quaternion bodyRotation = agentData.BodyRotation; // Camera location in world. We'll need to raytrace @@ -1205,87 +1199,85 @@ namespace OpenSim.Region.Framework.Scenes // The Agent's Draw distance setting m_DrawDistance = agentData.Far; - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) - { - StandUp(); - } - // Check if Client has camera in 'follow cam' or 'build' mode. Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; + m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; + m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; + + #endregion Inputs + + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + { + StandUp(); + } + //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); // Raycast from the avatar's head to the camera to see if there's anything blocking the view if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) { if (m_followCamAuto) { - Vector3 headadjustment = new Vector3(0, 0, 0.3f); - m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - (m_pos + headadjustment)), Vector3.Distance(m_CameraCenter, (m_pos + headadjustment)) + 0.3f, RayCastCameraCallback); + Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; + m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); } } - m_mouseLook = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; - m_leftButtonDown = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; - lock (scriptedcontrols) { if (scriptedcontrols.Count > 0) { - SendControlToScripts(flags); + SendControlToScripts((uint)flags); flags = RemoveIgnoredControls(flags, IgnoredControls); } } - if (PhysicsActor == null) - { - return; - } - if (m_autopilotMoving) CheckAtSitTarget(); - if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { // TODO: This doesn't prevent the user from walking yet. // Setting parent ID would fix this, if we knew what value // to use. Or we could add a m_isSitting variable. - TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); } + // In the future, these values might need to go global. // Here's where you get them. - m_AgentControlFlags = flags; m_headrotation = agentData.HeadRotation; m_state = agentData.State; + PhysicsActor actor = PhysicsActor; + if (actor == null) + { + return; + } + if (m_allowMovement) { int i = 0; bool update_movementflag = false; bool update_rotation = false; bool DCFlagKeyPressed = false; - Vector3 agent_control_v3 = new Vector3(0, 0, 0); + Vector3 agent_control_v3 = Vector3.Zero; Quaternion q = bodyRotation; - if (PhysicsActor != null) - { - bool oldflying = PhysicsActor.Flying; - if (m_forceFly) - PhysicsActor.Flying = true; - else if (m_flyDisabled) - PhysicsActor.Flying = false; - else - PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + bool oldflying = PhysicsActor.Flying; - if (PhysicsActor.Flying != oldflying) - { - update_movementflag = true; - } - } + if (m_forceFly) + actor.Flying = true; + else if (m_flyDisabled) + actor.Flying = false; + else + actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); + + if (actor.Flying != oldflying) + update_movementflag = true; if (q != m_bodyRot) { @@ -1307,10 +1299,9 @@ namespace OpenSim.Region.Framework.Scenes else dirVectors = Dir_Vectors; - - foreach (Dir_ControlFlags DCF in m_dirControlFlags) + foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) { - if ((flags & (uint)DCF) != 0) + if (((uint)flags & (uint)DCF) != 0) { bResetMoveToPosition = true; DCFlagKeyPressed = true; @@ -1356,7 +1347,7 @@ namespace OpenSim.Region.Framework.Scenes if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) { //Check the error term of the current position in relation to the target position - if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 1.5) + if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 1.5f) { // we are close enough to the target m_moveToPositionTarget = Vector3.Zero; @@ -1437,8 +1428,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) { // 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 & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || + ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); // Are the collision requirements fulfilled? bool colliding = (m_physicsActor.IsColliding == true); @@ -1605,7 +1596,7 @@ namespace OpenSim.Region.Framework.Scenes } m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); - m_parentPosition = new Vector3(); + m_parentPosition = Vector3.Zero; m_parentID = 0; SendFullUpdateToAllClients(); @@ -2776,11 +2767,8 @@ namespace OpenSim.Region.Framework.Scenes agentpos.CopyFrom(cadu); m_scene.SendOutChildAgentUpdates(agentpos, this); - - m_LastChildAgentUpdatePosition.X = AbsolutePosition.X; - m_LastChildAgentUpdatePosition.Y = AbsolutePosition.Y; - m_LastChildAgentUpdatePosition.Z = AbsolutePosition.Z; + m_LastChildAgentUpdatePosition = AbsolutePosition; } } @@ -2905,9 +2893,9 @@ namespace OpenSim.Region.Framework.Scenes m_inTransit = true; if ((m_physicsActor != null) && m_physicsActor.Flying) - m_AgentControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; - else if ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) - m_AgentControlFlags &= ~(uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; + m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; + else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) + m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; } public void NotInTransit() @@ -2923,7 +2911,7 @@ namespace OpenSim.Region.Framework.Scenes public void Reset() { // Put the child agent back at the center - AbsolutePosition = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 70); + AbsolutePosition = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); ResetAnimations(); } @@ -3093,7 +3081,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = m_bodyRot; - cAgent.ControlFlags = m_AgentControlFlags; + cAgent.ControlFlags = (uint)m_AgentControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) cAgent.GodLevel = (byte)m_godlevel; @@ -3181,7 +3169,7 @@ namespace OpenSim.Region.Framework.Scenes m_headrotation = cAgent.HeadRotation; m_bodyRot = cAgent.BodyRotation; - m_AgentControlFlags = cAgent.ControlFlags; + m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) m_godlevel = cAgent.GodLevel; @@ -3594,19 +3582,10 @@ namespace OpenSim.Region.Framework.Scenes IgnoredControls &= ~(ScriptControlled)controls; if (scriptedcontrols.ContainsKey(Script_item_UUID)) scriptedcontrols.Remove(Script_item_UUID); - } else { - - if (scriptedcontrols.ContainsKey(Script_item_UUID)) - { - scriptedcontrols[Script_item_UUID] = obj; - } - else - { - scriptedcontrols.Add(Script_item_UUID, obj); - } + scriptedcontrols[Script_item_UUID] = obj; } } ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); @@ -3624,12 +3603,14 @@ namespace OpenSim.Region.Framework.Scenes public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) { + ScriptControllers takecontrols; + lock (scriptedcontrols) { - if (scriptedcontrols.ContainsKey(Script_item_UUID)) + if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) { - ScriptControllers takecontrolls = scriptedcontrols[Script_item_UUID]; - ScriptControlled sctc = takecontrolls.eventControls; + ScriptControlled sctc = takecontrols.eventControls; + ControllingClient.SendTakeControls((int)sctc, false, false); ControllingClient.SendTakeControls((int)sctc, true, false); @@ -3640,7 +3621,6 @@ namespace OpenSim.Region.Framework.Scenes IgnoredControls |= scData.ignoreControls; } } - } } @@ -3707,9 +3687,11 @@ namespace OpenSim.Region.Framework.Scenes { lock (scriptedcontrols) { - foreach (UUID scriptUUID in scriptedcontrols.Keys) + foreach (KeyValuePair kvp in scriptedcontrols) { - ScriptControllers scriptControlData = scriptedcontrols[scriptUUID]; + UUID scriptUUID = kvp.Key; + ScriptControllers scriptControlData = kvp.Value; + ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle ScriptControlled localChange = localHeld ^ localLast; // the changed bits @@ -3725,37 +3707,40 @@ namespace OpenSim.Region.Framework.Scenes LastCommands = allflags; } - internal static uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored) + internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) { - if (Ignored == ScriptControlled.CONTROL_ZERO) + if (ignored == ScriptControlled.CONTROL_ZERO) return flags; - if ((Ignored & ScriptControlled.CONTROL_BACK) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); - if ((Ignored & ScriptControlled.CONTROL_FWD) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); - if ((Ignored & ScriptControlled.CONTROL_DOWN) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); - if ((Ignored & ScriptControlled.CONTROL_UP) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); - if ((Ignored & ScriptControlled.CONTROL_LEFT) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); - if ((Ignored & ScriptControlled.CONTROL_RIGHT) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); - if ((Ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); - if ((Ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); - if ((Ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); - if ((Ignored & ScriptControlled.CONTROL_LBUTTON) != 0) - flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); - //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, - //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, - //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, - //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, - //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, - //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, - //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG + + if ((ignored & ScriptControlled.CONTROL_BACK) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); + if ((ignored & ScriptControlled.CONTROL_FWD) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); + if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); + if ((ignored & ScriptControlled.CONTROL_UP) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); + if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); + if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); + if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); + if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); + if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); + if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) + flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); + + //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, + //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, + //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, + //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, + //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, + //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, + //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG + return flags; } -- cgit v1.1 From aecaa5106394ea55b2442da74b72094f934a491c Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 29 Oct 2009 16:31:48 -0700 Subject: * Fixed a NullReferenceException in GetMovementAnimation() and added more protection against NREs in AddNewMovement() * Removed the three second limit on ImprovedTerseObjectUpdate. With the latest fixes I don't think this is necessary, and it generates a lot of unnecessary updates in a crowded sim --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 64 +++++++++++++----------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 04c22d0..9730cd5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; - private int m_lastTerseSent; + //private int m_lastTerseSent; private bool m_updateflag; private byte m_movementflag; @@ -1120,7 +1120,7 @@ namespace OpenSim.Region.Framework.Scenes else { if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - !m_velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) { if (CameraConstraintActive) @@ -2110,8 +2110,9 @@ namespace OpenSim.Region.Framework.Scenes if (actor == null || !actor.IsColliding) { float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; + float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; - if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && actor.Velocity.Z >= 0.0f)) + if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) { // Just started falling m_animTickFall = Environment.TickCount; @@ -2262,28 +2263,30 @@ namespace OpenSim.Region.Framework.Scenes direc.Normalize(); direc *= 0.03f * 128f * m_speedModifier; - if (m_physicsActor.Flying) - { - direc *= 4.0f; - //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - //bool colliding = (m_physicsActor.IsColliding==true); - //if (controlland) - // m_log.Info("[AGENT]: landCommand"); - //if (colliding) - // m_log.Info("[AGENT]: colliding"); - //if (m_physicsActor.Flying && colliding && controlland) - //{ - // StopFlying(); - // m_log.Info("[AGENT]: Stop FLying"); - //} - } - else - { - if (!m_physicsActor.Flying && m_physicsActor.IsColliding) + + PhysicsActor actor = m_physicsActor; + if (actor != null) + { + if (actor.Flying) + { + direc *= 4.0f; + //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + //bool colliding = (m_physicsActor.IsColliding==true); + //if (controlland) + // m_log.Info("[AGENT]: landCommand"); + //if (colliding) + // m_log.Info("[AGENT]: colliding"); + //if (m_physicsActor.Flying && colliding && controlland) + //{ + // StopFlying(); + // m_log.Info("[AGENT]: Stop FLying"); + //} + } + else if (!actor.Flying && actor.IsColliding) { if (direc.Z > 2.0f) { - direc.Z *= 3; + direc.Z *= 3.0f; // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. TrySetMovementAnimation("PREJUMP"); @@ -2307,7 +2310,7 @@ namespace OpenSim.Region.Framework.Scenes const float ROTATION_TOLERANCE = 0.01f; const float VELOCITY_TOLERANCE = 0.001f; const float POSITION_TOLERANCE = 0.05f; - const int TIME_MS_TOLERANCE = 3000; + //const int TIME_MS_TOLERANCE = 3000; SendPrimUpdates(); @@ -2320,21 +2323,24 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { PhysicsActor actor = m_physicsActor; - Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; + + // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to + // grab the latest PhysicsActor velocity, whereas m_velocity is often + // storing a requested force instead of an actual traveling velocity // Throw away duplicate or insignificant updates if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || - !velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) + !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || + !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) + //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { SendTerseUpdateToAllClients(); // Update the "last" values m_lastPosition = m_pos; m_lastRotation = m_bodyRot; - m_lastVelocity = velocity; - m_lastTerseSent = Environment.TickCount; + m_lastVelocity = Velocity; + //m_lastTerseSent = Environment.TickCount; } // followed suggestion from mic bowman. reversed the two lines below. -- cgit v1.1 From a05c67bebb8a504858706619335c035948907158 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 30 Oct 2009 00:08:41 -0700 Subject: * Fixes issue #4329 "llDialog fails silently" by updating OpenMetaverse.dll * Prints a warning for any future packet splitting failures --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 12 ++++++------ .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 8 ++++---- OpenSim/TestSuite/PhysicsBot.cs | 19 +++++++++++-------- OpenSim/Tools/pCampBot/PhysicsBot.cs | 19 +++++++++++-------- bin/OpenMetaverse.dll | Bin 1642496 -> 1650688 bytes bin/OpenSim.ini.example | 2 +- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 1ff18d4..992d06f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4329,11 +4329,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// protected virtual void RegisterLocalPacketHandlers() { - AddLocalPacketHandler(PacketType.LogoutRequest, Logout); + AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout); AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate); AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); - AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); - AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); + AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached); + AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate); AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest); AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest); AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest); @@ -4602,7 +4602,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// /// - protected virtual bool Logout(IClientAPI client, Packet packet) + protected virtual bool HandleLogout(IClientAPI client, Packet packet) { if (packet.Type == PacketType.LogoutRequest) { @@ -4640,7 +4640,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// /// - protected bool AgentTextureCached(IClientAPI simclient, Packet packet) + protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet) { //m_log.Debug("texture cached: " + packet.ToString()); AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; @@ -4670,7 +4670,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } - protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet) + protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet) { MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; if (multipleupdate.AgentData.SessionID != SessionId) return false; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index a211508..9792bcd 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -256,8 +256,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP byte[][] datas = packet.ToBytesMultiple(); int packetCount = datas.Length; - //if (packetCount > 1) - // m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); + if (packetCount < 1) + m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length); for (int i = 0; i < packetCount; i++) { @@ -295,8 +295,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP byte[][] datas = packet.ToBytesMultiple(); int packetCount = datas.Length; - //if (packetCount > 1) - // m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); + if (packetCount < 1) + m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length); for (int i = 0; i < packetCount; i++) { diff --git a/OpenSim/TestSuite/PhysicsBot.cs b/OpenSim/TestSuite/PhysicsBot.cs index 9c9c1ea..fac4275 100644 --- a/OpenSim/TestSuite/PhysicsBot.cs +++ b/OpenSim/TestSuite/PhysicsBot.cs @@ -130,9 +130,9 @@ namespace OpenSim.TestSuite public void startup() { client.Settings.LOGIN_SERVER = loginURI; - client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected); - client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected); - client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected); + client.Network.LoginProgress += this.Network_LoginProgress; + client.Network.SimConnected += this.Network_SimConnected; + client.Network.Disconnected += this.Network_OnDisconnected; if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) { @@ -155,19 +155,22 @@ namespace OpenSim.TestSuite } } - public void Network_OnConnected(object sender) + public void Network_LoginProgress(object sender, LoginProgressEventArgs args) { - if (OnConnected != null) + if (args.Status == LoginStatus.Success) { - OnConnected(this, EventType.CONNECTED); + if (OnConnected != null) + { + OnConnected(this, EventType.CONNECTED); + } } } - public void Simulator_Connected(object sender) + public void Network_SimConnected(object sender, SimConnectedEventArgs args) { } - public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) + public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) { if (OnDisconnected != null) { diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 38986a2..5d4af31 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs @@ -151,9 +151,9 @@ namespace pCampBot client.Throttle.Texture = 100000; client.Throttle.Wind = 100000; client.Throttle.Total = 400000; - client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected); - client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected); - client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected); + client.Network.LoginProgress += this.Network_LoginProgress; + client.Network.SimConnected += this.Network_SimConnected; + client.Network.Disconnected += this.Network_OnDisconnected; client.Objects.ObjectUpdate += Objects_NewPrim; //client.Assets.OnAssetReceived += Asset_ReceivedCallback; if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) @@ -349,19 +349,22 @@ namespace pCampBot return clothfolder; } - public void Network_OnConnected(object sender) + public void Network_LoginProgress(object sender, LoginProgressEventArgs args) { - if (OnConnected != null) + if (args.Status == LoginStatus.Success) { - OnConnected(this, EventType.CONNECTED); + if (OnConnected != null) + { + OnConnected(this, EventType.CONNECTED); + } } } - public void Simulator_Connected(object sender) + public void Network_SimConnected(object sender, SimConnectedEventArgs args) { } - public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) + public void Network_OnDisconnected(object sender, DisconnectedEventArgs args) { if (OnDisconnected != null) { diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll index 8b07942..edbf3ce 100644 Binary files a/bin/OpenMetaverse.dll and b/bin/OpenMetaverse.dll differ diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 3877164..3952e2d 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -42,7 +42,7 @@ ; SmartThreadPool is reported to work well on Mono/Linux, but ; UnsafeQueueUserWorkItem has been benchmarked with better ; performance on .NET/Windows - ;async_call_method = SmartThreadPool + async_call_method = SmartThreadPool ; There are several operations on large collections (such as ; the current avatar list) that can be run synchronously or -- cgit v1.1 From 7965b6eb611be5f1a3cc75b2f8e3f3b76c87ffa0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 30 Oct 2009 00:43:46 -0700 Subject: * Moving parcel media and avatar update packets from the unthrottled category to task * Fixing a bug where the max burst rate for the state category was being set as unlimited, causing connections to child agents to saturate bandwidth * Upped the example default drip rates to 1000 bytes/sec, the minimum granularity for the token buckets --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 11 +++++++---- OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 3 --- OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 12 ++++++++---- .../Region/ClientStack/LindenUDP/ThrottleRates.cs | 21 ++++++++++----------- bin/OpenSim.ini.example | 14 +++++++------- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 992d06f..b8c99cf 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1856,7 +1856,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP economyData.Info.TeleportMinPrice = TeleportMinPrice; economyData.Info.TeleportPriceExponent = TeleportPriceExponent; economyData.Header.Reliable = true; - OutPacket(economyData, ThrottleOutPacketType.Unknown); + OutPacket(economyData, ThrottleOutPacketType.Task); } public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List Data) @@ -3234,7 +3234,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue(); } - OutPacket(terse, ThrottleOutPacketType.Unknown); // HACK: Unthrottled for testing + // HACK: Using the task category until the tiered reprioritization code is in + OutPacket(terse, ThrottleOutPacketType.Task); } public void SendCoarseLocationUpdate(List users, List CoarseLocations) @@ -4951,6 +4952,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Throttling category for the packet protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) { + if (ChildAgentStatus()) + Thread.Sleep(200); m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); } @@ -9843,7 +9846,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP commandMessagePacket.CommandBlock.Command = (uint)command; commandMessagePacket.CommandBlock.Time = time; - OutPacket(commandMessagePacket, ThrottleOutPacketType.Unknown); + OutPacket(commandMessagePacket, ThrottleOutPacketType.Task); } public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, @@ -9861,7 +9864,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP updatePacket.DataBlockExtended.MediaHeight = mediaHeight; updatePacket.DataBlockExtended.MediaLoop = mediaLoop; - OutPacket(updatePacket, ThrottleOutPacketType.Unknown); + OutPacket(updatePacket, ThrottleOutPacketType.Task); } #endregion diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 84a4959..6619dcb 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -135,8 +135,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP private readonly TokenBucket m_throttle; /// Throttle buckets for each packet category private readonly TokenBucket[] m_throttleCategories; - /// Throttle rate defaults and limits - private readonly ThrottleRates m_defaultThrottleRates; /// Outgoing queues for throttled packets private readonly OpenSim.Framework.LocklessQueue[] m_packetOutboxes = new OpenSim.Framework.LocklessQueue[THROTTLE_CATEGORY_COUNT]; /// A container that can hold one packet for each outbox, used to store @@ -161,7 +159,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP RemoteEndPoint = remoteEndPoint; CircuitCode = circuitCode; m_udpServer = server; - m_defaultThrottleRates = rates; // Create a token bucket throttle for this client that has the scene token bucket as a parent m_throttle = new TokenBucket(parentThrottle, rates.TotalLimit, rates.Total); // Create an array of token buckets for this clients different throttle categories diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 9792bcd..cc06a85 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -409,6 +409,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false); } + public void CompletePing(LLUDPClient udpClient, byte pingID) + { + CompletePingCheckPacket completePing = new CompletePingCheckPacket(); + completePing.PingID.PingID = pingID; + SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false); + } + public void ResendUnacked(LLUDPClient udpClient) { if (!udpClient.IsConnected) @@ -669,10 +676,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { // We don't need to do anything else with ping checks StartPingCheckPacket startPing = (StartPingCheckPacket)packet; - - CompletePingCheckPacket completePing = new CompletePingCheckPacket(); - completePing.PingID.PingID = startPing.PingID.PingID; - SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false); + CompletePing(udpClient, startPing.PingID.PingID); return; } else if (packet.Type == PacketType.CompletePingCheck) diff --git a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs index 008d827..aaf6e26 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs @@ -87,15 +87,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"]; Resend = throttleConfig.GetInt("resend_default", 12500); - Land = throttleConfig.GetInt("land_default", 500); - Wind = throttleConfig.GetInt("wind_default", 500); - Cloud = throttleConfig.GetInt("cloud_default", 500); - Task = throttleConfig.GetInt("task_default", 500); - Texture = throttleConfig.GetInt("texture_default", 500); - Asset = throttleConfig.GetInt("asset_default", 500); - State = throttleConfig.GetInt("state_default", 500); - - Total = throttleConfig.GetInt("client_throttle_max_bps", 0); + Land = throttleConfig.GetInt("land_default", 1000); + Wind = throttleConfig.GetInt("wind_default", 1000); + Cloud = throttleConfig.GetInt("cloud_default", 1000); + Task = throttleConfig.GetInt("task_default", 1000); + Texture = throttleConfig.GetInt("texture_default", 1000); + Asset = throttleConfig.GetInt("asset_default", 1000); + State = throttleConfig.GetInt("state_default", 1000); ResendLimit = throttleConfig.GetInt("resend_limit", 18750); LandLimit = throttleConfig.GetInt("land_limit", 29750); @@ -104,9 +102,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP TaskLimit = throttleConfig.GetInt("task_limit", 18750); TextureLimit = throttleConfig.GetInt("texture_limit", 55750); AssetLimit = throttleConfig.GetInt("asset_limit", 27500); - State = throttleConfig.GetInt("state_limit", 37000); + StateLimit = throttleConfig.GetInt("state_limit", 37000); - TotalLimit = throttleConfig.GetInt("client_throttle_max_bps", 0); + Total = throttleConfig.GetInt("client_throttle_max_bps", 0); + TotalLimit = Total; } catch (Exception) { } } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 3952e2d..6606270 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -399,13 +399,13 @@ ; These are default values that will be overriden by clients ; ;resend_default = 12500 - ;land_default = 500 - ;wind_default = 500 - ;cloud_default = 50 - ;task_default = 500 - ;texture_default = 500 - ;asset_default = 500 - ;state_default = 500 + ;land_default = 1000 + ;wind_default = 1000 + ;cloud_default = 1000 + ;task_default = 1000 + ;texture_default = 1000 + ;asset_default = 1000 + ;state_default = 1000 ; Per-client maximum burst rates in bytes per second for the various ; throttle categories. These are default values that will be overriden by -- cgit v1.1 From 8a73dc0f8a3a8606439b6f7217d2d14c22bfd43e Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 30 Oct 2009 03:01:15 -0700 Subject: * Fix for a potential race condition in ScenePresence.AbsolutePosition * Unified the way region handles are stored and used in ScenePresence * Fixed camera position for child agents * CheckForSignificantMovement now checks avatar and camera position (both are important for scene prioritization) * Removing debug code from the previous commit --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 2 - OpenSim/Region/Framework/Scenes/ScenePresence.cs | 78 +++++++++++----------- .../Framework/Scenes/Tests/ScenePresenceTests.cs | 4 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index b8c99cf..bd75f0c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4952,8 +4952,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Throttling category for the packet protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) { - if (ChildAgentStatus()) - Thread.Sleep(200); m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9730cd5..6c0d9f2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -79,6 +79,15 @@ namespace OpenSim.Region.Framework.Scenes private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); + /// + /// Experimentally determined "fudge factor" to make sit-target positions + /// the same as in SecondLife. Fudge factor was tested for 36 different + /// test cases including prims of type box, sphere, cylinder, and torus, + /// with varying parameters for sit target location, prim size, prim + /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis + /// issue #1716 + /// + private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); public UUID currentParcelUUID = UUID.Zero; @@ -115,18 +124,12 @@ namespace OpenSim.Region.Framework.Scenes private float m_sitAvatarHeight = 2.0f; - // experimentally determined "fudge factor" to make sit-target positions - // the same as in SecondLife. Fudge factor was tested for 36 different - // test cases including prims of type box, sphere, cylinder, and torus, - // with varying parameters for sit target location, prim size, prim - // rotation, prim cut, prim twist, prim taper, and prim shear. See mantis - // issue #1716 - private static readonly Vector3 m_sitTargetCorrectionOffset = new Vector3(0.1f, 0.0f, 0.3f); private float m_godlevel; private bool m_invulnerable = true; - private Vector3 m_LastChildAgentUpdatePosition; + private Vector3 m_lastChildAgentUpdatePosition; + private Vector3 m_lastChildAgentUpdateCamPosition; private int m_perfMonMS; @@ -271,11 +274,9 @@ namespace OpenSim.Region.Framework.Scenes get { return m_godlevel; } } - private readonly ulong m_regionHandle; - public ulong RegionHandle { - get { return m_regionHandle; } + get { return m_rootRegionHandle; } } public Vector3 CameraPosition @@ -414,31 +415,27 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Absolute position of this avatar in 'region cordinates' + /// Position of this avatar relative to the region the avatar is in /// public override Vector3 AbsolutePosition { get { - if (m_physicsActor != null) - { - m_pos.X = m_physicsActor.Position.X; - m_pos.Y = m_physicsActor.Position.Y; - m_pos.Z = m_physicsActor.Position.Z; - } + PhysicsActor actor = m_physicsActor; + if (actor != null) + m_pos = actor.Position; return m_parentPosition + m_pos; } set { - if (m_physicsActor != null) + PhysicsActor actor = m_physicsActor; + if (actor != null) { try { lock (m_scene.SyncRoot) - { m_physicsActor.Position = value; - } } catch (Exception e) { @@ -466,8 +463,6 @@ namespace OpenSim.Region.Framework.Scenes } set { - //m_log.DebugFormat("In {0} setting velocity of {1} to {2}", m_scene.RegionInfo.RegionName, Name, value); - PhysicsActor actor = m_physicsActor; if (actor != null) { @@ -626,7 +621,7 @@ namespace OpenSim.Region.Framework.Scenes { m_sendCourseLocationsMethod = SendCoarseLocationsDefault; CreateSceneViewer(); - m_regionHandle = reginfo.RegionHandle; + m_rootRegionHandle = reginfo.RegionHandle; m_controllingClient = client; m_firstname = m_controllingClient.FirstName; m_lastname = m_controllingClient.LastName; @@ -780,6 +775,8 @@ namespace OpenSim.Region.Framework.Scenes if (gm != null) m_grouptitle = gm.GetGroupTitle(m_uuid); + m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; + m_scene.SetRootAgentScene(m_uuid); // Moved this from SendInitialData to ensure that m_appearance is initialized @@ -810,7 +807,6 @@ namespace OpenSim.Region.Framework.Scenes pos = emergencyPos; } - float localAVHeight = 1.56f; if (m_avHeight != 127.0f) { @@ -905,6 +901,8 @@ namespace OpenSim.Region.Framework.Scenes m_isChildAgent = true; m_scene.SwapRootAgentCount(true); RemoveFromPhysicalScene(); + + // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into m_scene.EventManager.TriggerOnMakeChildAgent(this); } @@ -1823,7 +1821,7 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); - m_pos += m_sitTargetCorrectionOffset; + m_pos += SIT_TARGET_ADJUSTMENT; m_bodyRot = sitTargetOrient; //Rotation = sitTargetOrient; m_parentPosition = part.AbsolutePosition; @@ -2374,7 +2372,7 @@ namespace OpenSim.Region.Framework.Scenes //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); - remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, + remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); @@ -2739,7 +2737,8 @@ namespace OpenSim.Region.Framework.Scenes } // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m - if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance) + if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || + Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) { ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); cadu.ActiveGroupID = UUID.Zero.Guid; @@ -2753,7 +2752,7 @@ namespace OpenSim.Region.Framework.Scenes cadu.godlevel = m_godlevel; cadu.GroupAccess = 0; cadu.Position = new sLLVector3(AbsolutePosition); - cadu.regionHandle = m_scene.RegionInfo.RegionHandle; + cadu.regionHandle = m_rootRegionHandle; float multiplier = 1; int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); if (innacurateNeighbors != 0) @@ -2774,7 +2773,8 @@ namespace OpenSim.Region.Framework.Scenes m_scene.SendOutChildAgentUpdates(agentpos, this); - m_LastChildAgentUpdatePosition = AbsolutePosition; + m_lastChildAgentUpdatePosition = AbsolutePosition; + m_lastChildAgentUpdateCamPosition = CameraPosition; } } @@ -3027,9 +3027,11 @@ namespace OpenSim.Region.Framework.Scenes int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; + Vector3 offset = new Vector3(shiftx, shifty, 0f); + m_DrawDistance = cAgentData.Far; - if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!! - m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z); + if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! + m_pos = cAgentData.Position + offset; if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) { @@ -3037,8 +3039,7 @@ namespace OpenSim.Region.Framework.Scenes ReprioritizeUpdates(); } - // It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region - m_CameraCenter = cAgentData.Center; + m_CameraCenter = cAgentData.Center + offset; m_avHeight = cAgentData.Size.Z; //SetHeight(cAgentData.AVHeight); @@ -3051,16 +3052,16 @@ namespace OpenSim.Region.Framework.Scenes m_sceneViewer.Reset(); //cAgentData.AVHeight; - //cAgentData.regionHandle; + m_rootRegionHandle = cAgentData.RegionHandle; //m_velocity = cAgentData.Velocity; } public void CopyTo(AgentData cAgent) { cAgent.AgentID = UUID; - cAgent.RegionHandle = m_scene.RegionInfo.RegionHandle; + cAgent.RegionHandle = m_rootRegionHandle; - cAgent.Position = m_pos; + cAgent.Position = AbsolutePosition; cAgent.Velocity = m_velocity; cAgent.Center = m_CameraCenter; // Don't copy the size; it is inferred from apearance parameters @@ -3157,7 +3158,8 @@ namespace OpenSim.Region.Framework.Scenes public void CopyFrom(AgentData cAgent) { - m_rootRegionHandle= cAgent.RegionHandle; + m_rootRegionHandle = cAgent.RegionHandle; + m_callbackURI = cAgent.CallbackURI; m_pos = cAgent.Position; diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index 19c0fea..f495022 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs @@ -219,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); // Accepts 0 but rejects Constants.RegionSize - Vector3 pos = new Vector3(0,Constants.RegionSize-1,0); + Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); presence.MakeRootAgent(pos,true); Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); @@ -246,7 +246,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests scene2.AddNewClient(testclient); ScenePresence presence = scene.GetScenePresence(agent1); - presence.MakeRootAgent(new Vector3(0,Constants.RegionSize-1,0), true); + presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); ScenePresence presence2 = scene2.GetScenePresence(agent1); -- cgit v1.1 From 8a6442173589a0e267dbacb50f8d22c6b57280c1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 30 Oct 2009 18:08:58 +0000 Subject: Squelch an error message on sim shutdown when not using MXP --- OpenSim/Client/MXP/MXPModule.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenSim/Client/MXP/MXPModule.cs b/OpenSim/Client/MXP/MXPModule.cs index a6b0396..0b442cc 100644 --- a/OpenSim/Client/MXP/MXPModule.cs +++ b/OpenSim/Client/MXP/MXPModule.cs @@ -110,8 +110,11 @@ namespace OpenSim.Client.MXP public void Close() { m_shutdown = true; - lock (m_ticker) - m_ticker.Stop(); + if (m_ticker != null) + { + lock (m_ticker) + m_ticker.Stop(); + } } public string Name -- cgit v1.1 From 5d5d0e699af34b9300ed2f60c0c59b256be3dd89 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 30 Oct 2009 11:12:32 -0700 Subject: * Disables automatic packet splitting on AvatarGroupsReply packets. This packet is a mess and shouldn't be used at all (in favor of the event queue message) * Clean up the way we send AvatarGroupsReply packets, including clamping the group name and group title --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 26 ++++++++++++---------- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 4 ++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index bd75f0c..f33d2fa 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -2793,20 +2793,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP p.AgentData.AvatarID = avatarID; p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; - int i = 0; - foreach (GroupMembershipData m in data) - { - p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock(); - p.GroupData[i].GroupPowers = m.GroupPowers; - p.GroupData[i].AcceptNotices = m.AcceptNotices; - p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle); - p.GroupData[i].GroupID = m.GroupID; - p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName); - p.GroupData[i].GroupInsigniaID = m.GroupPicture; - i++; + + for (int i = 0; i < data.Length; i++) + { + GroupMembershipData m = data[i]; + + AvatarGroupsReplyPacket.GroupDataBlock block = new AvatarGroupsReplyPacket.GroupDataBlock(); + block.GroupPowers = m.GroupPowers; + block.AcceptNotices = m.AcceptNotices; + block.GroupTitle = Util.StringToBytes256(m.GroupTitle.Substring(0, 20)); + block.GroupID = m.GroupID; + block.GroupName = Util.StringToBytes256(m.GroupName.Substring(0, 35)); + block.GroupInsigniaID = m.GroupPicture; + + p.GroupData[i] = block; } - p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock(); p.NewGroupData.ListInProfile = true; OutPacket(p, ThrottleOutPacketType.Task); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index cc06a85..6f94921 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -247,8 +247,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) { - // CoarseLocationUpdate packets cannot be split in an automated way - if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) + // CoarseLocationUpdate and AvatarGroupsReply packets cannot be split in an automated way + if ((packet.Type == PacketType.CoarseLocationUpdate || packet.Type == PacketType.AvatarGroupsReply) && allowSplitting) allowSplitting = false; if (allowSplitting && packet.HasVariableBlocks) -- cgit v1.1 From 39f95e8cf0b18c25c4225336619048ef9fee9707 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 30 Oct 2009 19:44:01 +0000 Subject: Add a using for OSD to the client view --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index e513249..83b763e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -37,6 +37,7 @@ using System.Xml; using log4net; using OpenMetaverse; using OpenMetaverse.Packets; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Client; using OpenSim.Framework.Communications.Cache; -- cgit v1.1 From 92f4835ba612a184cd46462f7eac76d4dd19ae7f Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 30 Oct 2009 19:54:56 +0000 Subject: Convert the AvatarGroupsReply message to the event queue. --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 65 +++++++++++++--------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 83b763e..db0c3b8 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -2787,32 +2787,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) { - AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply); - - p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock(); - p.AgentData.AgentID = AgentId; - p.AgentData.AvatarID = avatarID; - - p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; - - for (int i = 0; i < data.Length; i++) - { - GroupMembershipData m = data[i]; - - AvatarGroupsReplyPacket.GroupDataBlock block = new AvatarGroupsReplyPacket.GroupDataBlock(); - block.GroupPowers = m.GroupPowers; - block.AcceptNotices = m.AcceptNotices; - block.GroupTitle = Util.StringToBytes256(m.GroupTitle.Length > 20 ? m.GroupTitle.Substring(0, 20) : m.GroupTitle); - block.GroupID = m.GroupID; - block.GroupName = Util.StringToBytes256(m.GroupName.Length > 35 ? m.GroupName.Substring(0, 35) : m.GroupName); - block.GroupInsigniaID = m.GroupPicture; - - p.GroupData[i] = block; - } - - p.NewGroupData.ListInProfile = true; - - OutPacket(p, ThrottleOutPacketType.Task); + OSDMap llsd = new OSDMap(3); + OSDArray AgentData = new OSDArray(1); + OSDMap AgentDataMap = new OSDMap(1); + AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId)); + AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID)); + AgentData.Add(AgentDataMap); + llsd.Add("AgentData", AgentData); + OSDArray GroupData = new OSDArray(data.Length); + OSDArray NewGroupData = new OSDArray(data.Length); + foreach (GroupMembershipData m in data) + { + OSDMap GroupDataMap = new OSDMap(6); + OSDMap NewGroupDataMap = new OSDMap(1); + GroupDataMap.Add("GroupPowers", OSD.FromBinary(m.GroupPowers)); + GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices)); + GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle)); + GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID)); + GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName)); + GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture)); + NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile)); + GroupData.Add(GroupDataMap); + NewGroupData.Add(NewGroupDataMap); + } + llsd.Add("GroupData", GroupData); + llsd.Add("NewGroupData", NewGroupData); + + IEventQueue eq = this.Scene.RequestModuleInterface(); + if (eq != null) + { + eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId); + } } public void SendJoinGroupReply(UUID groupID, bool success) @@ -10299,5 +10304,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion + public static OSD BuildEvent(string eventName, OSD eventBody) + { + OSDMap osdEvent = new OSDMap(2); + osdEvent.Add("message", new OSDString(eventName)); + osdEvent.Add("body", eventBody); + + return osdEvent; + } } } -- cgit v1.1 From cb1492aaf0aae074753d0d4f5766fa4cd1292536 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 30 Oct 2009 13:18:18 -0700 Subject: Fixed a regression in SendAvatarGroupsReply() --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index f33d2fa..e513249 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -2801,9 +2801,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP AvatarGroupsReplyPacket.GroupDataBlock block = new AvatarGroupsReplyPacket.GroupDataBlock(); block.GroupPowers = m.GroupPowers; block.AcceptNotices = m.AcceptNotices; - block.GroupTitle = Util.StringToBytes256(m.GroupTitle.Substring(0, 20)); + block.GroupTitle = Util.StringToBytes256(m.GroupTitle.Length > 20 ? m.GroupTitle.Substring(0, 20) : m.GroupTitle); block.GroupID = m.GroupID; - block.GroupName = Util.StringToBytes256(m.GroupName.Substring(0, 35)); + block.GroupName = Util.StringToBytes256(m.GroupName.Length > 35 ? m.GroupName.Substring(0, 35) : m.GroupName); block.GroupInsigniaID = m.GroupPicture; p.GroupData[i] = block; -- cgit v1.1 From 120c731a3b3e055cd6786deef2bf3a1ca0fceb8c Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 30 Oct 2009 17:04:10 -0400 Subject: * Moving A test from the OpenSim.Framework.ACL object to the OpenSim.Framework.Tests assembly. Fixing the test. --- OpenSim/Framework/Tests/ACLTest.cs | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 OpenSim/Framework/Tests/ACLTest.cs diff --git a/OpenSim/Framework/Tests/ACLTest.cs b/OpenSim/Framework/Tests/ACLTest.cs new file mode 100644 index 0000000..2428b64 --- /dev/null +++ b/OpenSim/Framework/Tests/ACLTest.cs @@ -0,0 +1,41 @@ +using System; +using NUnit.Framework; + + +namespace OpenSim.Framework.Tests +{ + [TestFixture] + public class ACLTest + { + #region Tests + + /// + /// ACL Test class + /// + [Test] + public void ACLTest01() + { + ACL acl = new ACL(); + + Role Guests = new Role("Guests"); + acl.AddRole(Guests); + + Role[] parents = new Role[1]; + parents[0] = Guests; + + Role JoeGuest = new Role("JoeGuest", parents); + acl.AddRole(JoeGuest); + + Resource CanBuild = new Resource("CanBuild"); + acl.AddResource(CanBuild); + + + acl.GrantPermission("Guests", "CanBuild"); + + acl.HasPermission("JoeGuest", "CanBuild"); + + } + + #endregion + } +} -- cgit v1.1 From 4563f00852e9a393b28bd98925b14bbbf699e8ae Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 30 Oct 2009 17:27:44 -0400 Subject: * Another ACL Test --- OpenSim/Framework/Tests/ACLTest.cs | 59 +++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Tests/ACLTest.cs b/OpenSim/Framework/Tests/ACLTest.cs index 2428b64..d11f307 100644 --- a/OpenSim/Framework/Tests/ACLTest.cs +++ b/OpenSim/Framework/Tests/ACLTest.cs @@ -1,5 +1,6 @@ using System; using NUnit.Framework; +using System.Collections.Generic; namespace OpenSim.Framework.Tests @@ -32,8 +33,64 @@ namespace OpenSim.Framework.Tests acl.GrantPermission("Guests", "CanBuild"); - acl.HasPermission("JoeGuest", "CanBuild"); + Permission perm = acl.HasPermission("JoeGuest", "CanBuild"); + Assert.That(perm == Permission.Allow, "JoeGuest should have permission to build"); + perm = Permission.None; + try + { + perm = acl.HasPermission("unknownGuest", "CanBuild"); + + } + catch (KeyNotFoundException) + { + + + } + catch (Exception) + { + Assert.That(false,"Exception thrown should have been KeyNotFoundException"); + } + Assert.That(perm == Permission.None,"Permission None should be set because exception should have been thrown"); + + } + + [Test] + public void KnownButPermissionDenyAndPermissionNoneUserTest() + { + ACL acl = new ACL(); + + Role Guests = new Role("Guests"); + acl.AddRole(Guests); + Role Administrators = new Role("Administrators"); + acl.AddRole(Administrators); + Role[] Guestparents = new Role[1]; + Role[] Adminparents = new Role[1]; + + Guestparents[0] = Guests; + Adminparents[0] = Administrators; + + Role JoeGuest = new Role("JoeGuest", Guestparents); + acl.AddRole(JoeGuest); + + Resource CanBuild = new Resource("CanBuild"); + acl.AddResource(CanBuild); + + Resource CanScript = new Resource("CanScript"); + acl.AddResource(CanScript); + + Resource CanRestart = new Resource("CanRestart"); + acl.AddResource(CanRestart); + + acl.GrantPermission("Guests", "CanBuild"); + acl.DenyPermission("Guests", "CanRestart"); + + acl.GrantPermission("Administrators", "CanScript"); + acl.GrantPermission("Administrators", "CanRestart"); + Permission setPermission = acl.HasPermission("JoeGuest", "CanRestart"); + Assert.That(setPermission == Permission.Deny, "Guests Should not be able to restart"); + Assert.That(acl.HasPermission("JoeGuest", "CanScript") == Permission.None, + "No Explicit Permissions set so should be Permission.None"); } #endregion -- cgit v1.1 From c6246050d9237293cc6b72e3adf6267617603259 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 30 Oct 2009 22:07:56 +0000 Subject: Make the default and max RTO configurable int he linden client stack --- OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 16 ++++++++++++---- OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 8 +++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index 6619dcb..9856a1c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs @@ -143,6 +143,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// A reference to the LLUDPServer that is managing this client private readonly LLUDPServer m_udpServer; + private int m_defaultRTO = 3000; + private int m_maxRTO = 60000; + /// /// Default constructor /// @@ -153,12 +156,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Circuit code for this connection /// AgentID for the connected agent /// Remote endpoint for this connection - public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint) + public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint, int defaultRTO, int maxRTO) { AgentID = agentID; RemoteEndPoint = remoteEndPoint; CircuitCode = circuitCode; m_udpServer = server; + if (defaultRTO != 0) + m_defaultRTO = defaultRTO; + if (maxRTO != 0) + m_maxRTO = maxRTO; + // Create a token bucket throttle for this client that has the scene token bucket as a parent m_throttle = new TokenBucket(parentThrottle, rates.TotalLimit, rates.Total); // Create an array of token buckets for this clients different throttle categories @@ -175,7 +183,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } // Default the retransmission timeout to three seconds - RTO = 3000; + RTO = m_defaultRTO; // Initialize this to a sane value to prevent early disconnects TickLastPacketReceived = Environment.TickCount & Int32.MaxValue; @@ -497,7 +505,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); // Clamp the retransmission timeout to manageable values - rto = Utils.Clamp(RTO, 3000, 60000); + rto = Utils.Clamp(RTO, m_defaultRTO, m_maxRTO); RTO = rto; @@ -517,7 +525,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP RTTVAR = 0.0f; // Double the retransmission timeout - RTO = Math.Min(RTO * 2, 60000); + RTO = Math.Min(RTO * 2, m_maxRTO); } /// diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 6f94921..93946ae 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -153,6 +153,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Flag to signal when clients should send pings private bool m_sendPing; + private int m_defaultRTO = 0; + private int m_maxRTO = 0; + public Socket Server { get { return null; } } public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) @@ -189,6 +192,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP AvatarTerseUpdatesPerPacket = config.GetInt("AvatarTerseUpdatesPerPacket", 10); PrimFullUpdatesPerPacket = config.GetInt("PrimFullUpdatesPerPacket", 100); TextureSendLimit = config.GetInt("TextureSendLimit", 20); + + m_defaultRTO = config.GetInt("DefaultRTO", 0); + m_maxRTO = config.GetInt("MaxRTO", 0); } else { @@ -766,7 +772,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) { // Create the LLUDPClient - LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); + LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); IClientAPI existingClient; if (!m_scene.TryGetClient(agentID, out existingClient)) -- cgit v1.1 From 2e81acec48c02e54843b2a33ce9c542d0a0fb68d Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 30 Oct 2009 18:13:58 -0400 Subject: * Adding Tests for OpenSim.Framework.Cache. Some test cases disabled until mantis resolutions. --- OpenSim/Framework/Tests/CacheTests.cs | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 OpenSim/Framework/Tests/CacheTests.cs diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs new file mode 100644 index 0000000..8e97232 --- /dev/null +++ b/OpenSim/Framework/Tests/CacheTests.cs @@ -0,0 +1,75 @@ +using System; +using NUnit.Framework; +using OpenMetaverse; + +namespace OpenSim.Framework.Tests +{ + [TestFixture] + public class CacheTests + { + private Cache cache; + private UUID cacheItemUUID; + [SetUp] + public void Build() + { + cache = new Cache(); + cacheItemUUID = UUID.Random(); + MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); + byte[] foo = new byte[1]; + foo[0] = 255; + cachedItem.Store(foo); + cache.Store(cacheItemUUID.ToString(), cachedItem); + } + [Test] + public void TestRetreive() + { + CacheItemBase citem = (CacheItemBase)cache.Get(cacheItemUUID.ToString()); + byte[] data = (byte[]) citem.Retrieve(); + Assert.That(data.Length == 1, "Cached Item should have one byte element"); + Assert.That(data[0] == 255, "Cached Item element should be 255"); + } + + [Test] + public void TestNotInCache() + { + UUID randomNotIn = UUID.Random(); + while (randomNotIn == cacheItemUUID) + { + randomNotIn = UUID.Random(); + } + object citem = cache.Get(randomNotIn.ToString()); + Assert.That(citem == null, "Item should not be in Cache" ); + } + + //NOTE: Test Case disabled until Cache is fixed + [Test] + public void TestTTLExpiredEntry() + { + UUID ImmediateExpiryUUID = UUID.Random(); + MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(-1)); + byte[] foo = new byte[1]; + foo[0] = 1; + cachedItem.Store(foo); + cache.Store(cacheItemUUID.ToString(), cachedItem); + + object citem = cache.Get(cacheItemUUID.ToString()); + //Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now"); + } + + //NOTE: Test Case disabled until Cache is fixed + [Test] + public void ExpireItemManually() + { + UUID ImmediateExpiryUUID = UUID.Random(); + MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1)); + byte[] foo = new byte[1]; + foo[0] = 1; + cachedItem.Store(foo); + cache.Store(cacheItemUUID.ToString(), cachedItem); + cache.Invalidate(ImmediateExpiryUUID.ToString()); + object citem = cache.Get(cacheItemUUID.ToString()); + //Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); + } + + } +} -- cgit v1.1 From 5101f688ee887d5fa67a573591ec3b6a43c4e50b Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 30 Oct 2009 19:13:57 -0400 Subject: * Add LocklessQueueTests. One Test is commented out because it fails. It should probably work.. but I'm awaiting clarification. --- OpenSim/Framework/ACL.cs | 32 +----- OpenSim/Framework/Tests/LocklessQueueTests.cs | 147 ++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 31 deletions(-) create mode 100644 OpenSim/Framework/Tests/LocklessQueueTests.cs diff --git a/OpenSim/Framework/ACL.cs b/OpenSim/Framework/ACL.cs index 3b1c0f0..f76e8b7 100644 --- a/OpenSim/Framework/ACL.cs +++ b/OpenSim/Framework/ACL.cs @@ -248,35 +248,5 @@ namespace OpenSim.Framework #endregion - #region Tests - - /// - /// ACL Test class - /// - internal class ACLTester - { - public ACLTester() - { - ACL acl = new ACL(); - - Role Guests = new Role("Guests"); - acl.AddRole(Guests); - - Role[] parents = new Role[0]; - parents[0] = Guests; - - Role JoeGuest = new Role("JoeGuest", parents); - acl.AddRole(JoeGuest); - - Resource CanBuild = new Resource("CanBuild"); - acl.AddResource(CanBuild); - - - acl.GrantPermission("Guests", "CanBuild"); - - acl.HasPermission("JoeGuest", "CanBuild"); - } - } - - #endregion + } \ No newline at end of file diff --git a/OpenSim/Framework/Tests/LocklessQueueTests.cs b/OpenSim/Framework/Tests/LocklessQueueTests.cs new file mode 100644 index 0000000..e34f767 --- /dev/null +++ b/OpenSim/Framework/Tests/LocklessQueueTests.cs @@ -0,0 +1,147 @@ +using System; +using NUnit.Framework; +using System.Threading; + +namespace OpenSim.Framework.Tests +{ + [TestFixture] + public class LocklessQueueTests + { + public LocklessQueue sharedQueue; + [SetUp] + public void build() + { + sharedQueue = new LocklessQueue(); + + } + + [Test] + public void EnqueueDequeueTest() + { + sharedQueue.Enqueue(1); + int dequeue; + sharedQueue.Dequeue(out dequeue); + Assert.That(dequeue == 1, "Enqueued 1. Dequeue should also be 1"); + Assert.That(sharedQueue.Count == 0, "We Dequeued the last item, count should be 0"); + + } + + [Test] + public void ThreadedSimpleEnqueueDequeueTest() + { + int loopamountA = 5000; + int loopamountB = 5000; + int loopamountC = 5000; + int loopamountD = 5000; + + threadObject1 obj1 = new threadObject1(this, loopamountA); + threadObject1 obj2 = new threadObject1(this, loopamountB); + threadObject1 obj3 = new threadObject1(this, loopamountC); + threadObject1 obj4 = new threadObject1(this, loopamountD); + for (int i=0;i<1;i++) + { + sharedQueue.Enqueue(i); + } + + Thread thr = new Thread(obj1.thread1Action); + Thread thr2 = new Thread(obj2.thread1Action); + Thread thr3 = new Thread(obj3.thread1Action); + Thread thr4 = new Thread(obj4.thread1Action); + thr.Start(); + thr2.Start(); + thr3.Start(); + thr4.Start(); + + thr.Join(); + thr2.Join(); + thr3.Join(); + thr4.Join(); + + Assert.That(sharedQueue.Count == 1); + int result = 0; + sharedQueue.Dequeue(out result); + Assert.That(result == loopamountD + loopamountC + loopamountB + loopamountA, "Threaded Result test failed. Expected the sum of all of the threads adding to the item in the queue. Got {0}, Expected {1}", result, loopamountD + loopamountC + loopamountB + loopamountA); + + } + + /* This test fails. Need clarification if this should work + [Test] + public void ThreadedAdvancedEnqueueDequeueTest() + { + int loopamountA = 5000; + int loopamountB = 5000; + int loopamountC = 5000; + int loopamountD = 5000; + + threadObject1 obj1 = new threadObject1(this, loopamountA); + threadObject2 obj2 = new threadObject2(this, loopamountB); + threadObject1 obj3 = new threadObject1(this, loopamountC); + threadObject2 obj4 = new threadObject2(this, loopamountD); + for (int i = 0; i < 1; i++) + { + sharedQueue.Enqueue(i); + } + + Thread thr = new Thread(obj1.thread1Action); + Thread thr2 = new Thread(obj2.thread1Action); + Thread thr3 = new Thread(obj3.thread1Action); + Thread thr4 = new Thread(obj4.thread1Action); + thr.Start(); + thr2.Start(); + thr3.Start(); + thr4.Start(); + + thr.Join(); + thr2.Join(); + thr3.Join(); + thr4.Join(); + + Assert.That(sharedQueue.Count == 1); + int result = 0; + sharedQueue.Dequeue(out result); + Assert.That(result == loopamountA - loopamountB + loopamountC - loopamountD, "Threaded Result test failed. Expected the sum of all of the threads adding to the item in the queue. Got {0}, Expected {1}", result, loopamountA - loopamountB + loopamountC - loopamountD); + + } + */ + } + // Dequeue one from the locklessqueue add one to it and enqueue it again. + public class threadObject1 + { + private LocklessQueueTests m_tests; + private int m_loopamount = 0; + public threadObject1(LocklessQueueTests tst, int loopamount) + { + m_tests = tst; + m_loopamount = loopamount; + } + public void thread1Action(object o) + { + for (int i=0;i sharedQueue; - [SetUp] - public void build() - { - sharedQueue = new LocklessQueue(); - - } - - [Test] - public void EnqueueDequeueTest() - { - sharedQueue.Enqueue(1); - int dequeue; - sharedQueue.Dequeue(out dequeue); - Assert.That(dequeue == 1, "Enqueued 1. Dequeue should also be 1"); - Assert.That(sharedQueue.Count == 0, "We Dequeued the last item, count should be 0"); - - } - - [Test] - public void ThreadedSimpleEnqueueDequeueTest() - { - int loopamountA = 5000; - int loopamountB = 5000; - int loopamountC = 5000; - int loopamountD = 5000; - - threadObject1 obj1 = new threadObject1(this, loopamountA); - threadObject1 obj2 = new threadObject1(this, loopamountB); - threadObject1 obj3 = new threadObject1(this, loopamountC); - threadObject1 obj4 = new threadObject1(this, loopamountD); - for (int i=0;i<1;i++) - { - sharedQueue.Enqueue(i); - } - - Thread thr = new Thread(obj1.thread1Action); - Thread thr2 = new Thread(obj2.thread1Action); - Thread thr3 = new Thread(obj3.thread1Action); - Thread thr4 = new Thread(obj4.thread1Action); - thr.Start(); - thr2.Start(); - thr3.Start(); - thr4.Start(); - - thr.Join(); - thr2.Join(); - thr3.Join(); - thr4.Join(); - - Assert.That(sharedQueue.Count == 1); - int result = 0; - sharedQueue.Dequeue(out result); - Assert.That(result == loopamountD + loopamountC + loopamountB + loopamountA, "Threaded Result test failed. Expected the sum of all of the threads adding to the item in the queue. Got {0}, Expected {1}", result, loopamountD + loopamountC + loopamountB + loopamountA); - - } - - /* This test fails. Need clarification if this should work - [Test] - public void ThreadedAdvancedEnqueueDequeueTest() - { - int loopamountA = 5000; - int loopamountB = 5000; - int loopamountC = 5000; - int loopamountD = 5000; - - threadObject1 obj1 = new threadObject1(this, loopamountA); - threadObject2 obj2 = new threadObject2(this, loopamountB); - threadObject1 obj3 = new threadObject1(this, loopamountC); - threadObject2 obj4 = new threadObject2(this, loopamountD); - for (int i = 0; i < 1; i++) - { - sharedQueue.Enqueue(i); - } - - Thread thr = new Thread(obj1.thread1Action); - Thread thr2 = new Thread(obj2.thread1Action); - Thread thr3 = new Thread(obj3.thread1Action); - Thread thr4 = new Thread(obj4.thread1Action); - thr.Start(); - thr2.Start(); - thr3.Start(); - thr4.Start(); - - thr.Join(); - thr2.Join(); - thr3.Join(); - thr4.Join(); - - Assert.That(sharedQueue.Count == 1); - int result = 0; - sharedQueue.Dequeue(out result); - Assert.That(result == loopamountA - loopamountB + loopamountC - loopamountD, "Threaded Result test failed. Expected the sum of all of the threads adding to the item in the queue. Got {0}, Expected {1}", result, loopamountA - loopamountB + loopamountC - loopamountD); - - } - */ - } - // Dequeue one from the locklessqueue add one to it and enqueue it again. - public class threadObject1 - { - private LocklessQueueTests m_tests; - private int m_loopamount = 0; - public threadObject1(LocklessQueueTests tst, int loopamount) - { - m_tests = tst; - m_loopamount = loopamount; - } - public void thread1Action(object o) - { - for (int i=0;i m_monitors = new List(); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public void DebugMonitors(string module, string[] args) + { + foreach (IMonitor monitor in m_monitors) + { + m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetValue()); + } + } + + #region Implementation of IRegionModule + + public void Initialise(Scene scene, IConfigSource source) + { + m_scene = scene; + + + m_scene.AddCommand(this, "monitor report", + "monitor report", + "Returns a variety of statistics about the current region and/or simulator", + DebugMonitors); + } + + public void PostInitialise() + { + m_monitors.Add(new AgentCountMonitor(m_scene)); + m_monitors.Add(new ChildAgentCountMonitor(m_scene)); + m_monitors.Add(new GCMemoryMonitor()); + m_monitors.Add(new ObjectCountMonitor(m_scene)); + m_monitors.Add(new PhysicsFrameMonitor(m_scene)); + m_monitors.Add(new PhysicsUpdateFrameMonitor(m_scene)); + m_monitors.Add(new PWSMemoryMonitor()); + m_monitors.Add(new ThreadCountMonitor()); + m_monitors.Add(new TotalFrameMonitor(m_scene)); + m_monitors.Add(new EventFrameMonitor(m_scene)); + m_monitors.Add(new LandFrameMonitor(m_scene)); + } + + public void Close() + { + + } + + public string Name + { + get { return "Region Health Monitoring Module"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs new file mode 100644 index 0000000..edc6e6b --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/AgentCountMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class AgentCountMonitor : IMonitor + { + private readonly Scene m_scene; + + public AgentCountMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.SceneGraph.GetRootAgentCount(); + } + + public string GetName() + { + return "Root Agent Count"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + " agent(s)"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs new file mode 100644 index 0000000..afe6b79 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ChildAgentCountMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class ChildAgentCountMonitor : IMonitor + { + private readonly Scene m_scene; + + public ChildAgentCountMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.SceneGraph.GetChildAgentCount(); + } + + public string GetName() + { + return "Child Agent Count"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + " child agent(s)"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs new file mode 100644 index 0000000..dec5a9e --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/EventFrameMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class EventFrameMonitor : IMonitor + { + private readonly Scene m_scene; + + public EventFrameMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.MonitorEventTime; + } + + public string GetName() + { + return "Total Event Frame Time"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + "ms"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs new file mode 100644 index 0000000..cd67fea --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/GCMemoryMonitor.cs @@ -0,0 +1,26 @@ +using System; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class GCMemoryMonitor : IMonitor + { + #region Implementation of IMonitor + + public double GetValue() + { + return GC.GetTotalMemory(false); + } + + public string GetName() + { + return "GC Reported Memory"; + } + + public string GetFriendlyValue() + { + return (int)(GetValue() / (1024*1024)) + "MB (Global)"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs new file mode 100644 index 0000000..d883fc7 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LandFrameMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class LandFrameMonitor : IMonitor + { + private readonly Scene m_scene; + + public LandFrameMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.MonitorLandTime; + } + + public string GetName() + { + return "Land Frame Time"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + "ms"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs new file mode 100644 index 0000000..dd9b19d --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ObjectCountMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class ObjectCountMonitor : IMonitor + { + private readonly Scene m_scene; + + public ObjectCountMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.SceneGraph.GetTotalObjectsCount(); + } + + public string GetName() + { + return "Total Objects Count"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + " Object(s)"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs new file mode 100644 index 0000000..88f2938 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PWSMemoryMonitor.cs @@ -0,0 +1,26 @@ +using System; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class PWSMemoryMonitor : IMonitor + { + #region Implementation of IMonitor + + public double GetValue() + { + return System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64; + } + + public string GetName() + { + return "Private Working Set Memory"; + } + + public string GetFriendlyValue() + { + return (int)(GetValue() / (1024 * 1024)) + "MB (Global)"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs new file mode 100644 index 0000000..4d62e4f --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsFrameMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class PhysicsFrameMonitor : IMonitor + { + private readonly Scene m_scene; + + public PhysicsFrameMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.MonitorPhysicsSyncTime + m_scene.MonitorPhysicsUpdateTime; + } + + public string GetName() + { + return "Total Physics Frame Time"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + "ms"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs new file mode 100644 index 0000000..91ac282 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/PhysicsUpdateFrameMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class PhysicsUpdateFrameMonitor : IMonitor + { + private readonly Scene m_scene; + + public PhysicsUpdateFrameMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.MonitorPhysicsUpdateTime; + } + + public string GetName() + { + return "Physics Update Frame Time"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + "ms"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs new file mode 100644 index 0000000..9300a93 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/ThreadCountMonitor.cs @@ -0,0 +1,25 @@ + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class ThreadCountMonitor : IMonitor + { + #region Implementation of IMonitor + + public double GetValue() + { + return System.Diagnostics.Process.GetCurrentProcess().Threads.Count; + } + + public string GetName() + { + return "Total Threads"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + " Thread(s) (Global)"; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs new file mode 100644 index 0000000..dea1f94 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/TotalFrameMonitor.cs @@ -0,0 +1,33 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class TotalFrameMonitor : IMonitor + { + private readonly Scene m_scene; + + public TotalFrameMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return m_scene.MonitorFrameTime; + } + + public string GetName() + { + return "Total Frame Time"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + "ms"; + } + + #endregion + } +} diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 78ccb55..07fdc9f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -274,6 +274,21 @@ namespace OpenSim.Region.Framework.Scenes private int physicsMS2; private int physicsMS; private int otherMS; + private int tempOnRezMS; + private int eventMS; + private int backupMS; + private int terrainMS; + private int landMS; + + public int MonitorFrameTime { get { return frameMS; } } + public int MonitorPhysicsUpdateTime { get { return physicsMS; } } + public int MonitorPhysicsSyncTime { get { return physicsMS2; } } + public int MonitorOtherTime { get { return otherMS; } } + public int MonitorTempOnRezTime { get { return tempOnRezMS; } } + public int MonitorEventTime { get { return eventMS; } } // This may need to be divided into each event? + public int MonitorBackupTime { get { return backupMS; } } + public int MonitorTerrainTime { get { return terrainMS; } } + public int MonitorLandTime { get { return landMS; } } private bool m_physics_enabled = true; private bool m_scripts_enabled = true; @@ -1026,7 +1041,8 @@ namespace OpenSim.Region.Framework.Scenes TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; physicsFPS = 0f; - maintc = maintc = frameMS = otherMS = Environment.TickCount; + maintc = maintc = otherMS = Environment.TickCount; + int tmpFrameMS = maintc; // Increment the frame counter ++m_frame; @@ -1046,15 +1062,16 @@ namespace OpenSim.Region.Framework.Scenes if (m_frame % m_update_presences == 0) m_sceneGraph.UpdatePresences(); - physicsMS2 = Environment.TickCount; + int TempPhysicsMS2 = Environment.TickCount; if ((m_frame % m_update_physics == 0) && m_physics_enabled) m_sceneGraph.UpdatePreparePhysics(); - physicsMS2 = Environment.TickCount - physicsMS2; + TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2; + physicsMS2 = TempPhysicsMS2; if (m_frame % m_update_entitymovement == 0) m_sceneGraph.UpdateScenePresenceMovement(); - physicsMS = Environment.TickCount; + int TempPhysicsMS = Environment.TickCount; if (m_frame % m_update_physics == 0) { if (m_physics_enabled) @@ -1062,30 +1079,56 @@ namespace OpenSim.Region.Framework.Scenes if (SynchronizeScene != null) SynchronizeScene(this); } - physicsMS = Environment.TickCount - physicsMS; - physicsMS += physicsMS2; + TempPhysicsMS = Environment.TickCount - TempPhysicsMS; + physicsMS = TempPhysicsMS; // Delete temp-on-rez stuff if (m_frame % m_update_backup == 0) + { + int tozMS = Environment.TickCount; CleanTempObjects(); + tozMS -= Environment.TickCount; + tempOnRezMS = tozMS; + } if (RegionStatus != RegionStatus.SlaveScene) { if (m_frame % m_update_events == 0) + { + int evMS = Environment.TickCount; UpdateEvents(); + evMS -= Environment.TickCount; + eventMS = evMS; + } if (m_frame % m_update_backup == 0) + { + int backMS = Environment.TickCount; UpdateStorageBackup(); + backMS -= Environment.TickCount; + backupMS = backMS; + } if (m_frame % m_update_terrain == 0) + { + int terMS = Environment.TickCount; UpdateTerrain(); + terMS -= Environment.TickCount; + terrainMS = terMS; + } if (m_frame % m_update_land == 0) + { + int ldMS = Environment.TickCount; UpdateLand(); + ldMS -= Environment.TickCount; + landMS = ldMS; + } int tickCount = Environment.TickCount; otherMS = tickCount - otherMS; - frameMS = tickCount - frameMS; + tmpFrameMS -= tickCount; + frameMS = tmpFrameMS; // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); @@ -1097,7 +1140,7 @@ namespace OpenSim.Region.Framework.Scenes StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); StatsReporter.addFrameMS(frameMS); - StatsReporter.addPhysicsMS(physicsMS); + StatsReporter.addPhysicsMS(physicsMS + physicsMS2); StatsReporter.addOtherMS(otherMS); StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); -- cgit v1.1 From 838bc80ab9273c2834794535886a86c7574bb0d3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 2 Nov 2009 00:05:49 +1100 Subject: * Implemented some tweaks to monitoring module. * Output is prettier & more useful. * Added 'Alerts' to allow rules to be constructed using Monitors to detect for events such as deadlocks. This will be translated to SNMP Traps when I get SNMP implemented. --- .../Framework/Monitoring/Alerts/DeadlockAlert.cs | 37 ++++++++++++++++++++++ .../Framework/Monitoring/MonitorModule.cs | 25 ++++++++++++++- .../Monitoring/Monitors/LastFrameTimeMonitor.cs | 34 ++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 3 ++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs create mode 100644 OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs new file mode 100644 index 0000000..b546ccb --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Alerts/DeadlockAlert.cs @@ -0,0 +1,37 @@ +using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Alerts +{ + class DeadlockAlert : IAlert + { + private LastFrameTimeMonitor m_monitor; + + public DeadlockAlert(LastFrameTimeMonitor m_monitor) + { + this.m_monitor = m_monitor; + } + + #region Implementation of IAlert + + public string GetName() + { + return "Potential Deadlock Alert"; + } + + public void Test() + { + if (m_monitor.GetValue() > 60 * 1000) + { + if(OnTriggerAlert != null) + { + OnTriggerAlert(typeof (DeadlockAlert), + (int) (m_monitor.GetValue()/1000) + " second(s) since last frame processed.", true); + } + } + } + + public event Alert OnTriggerAlert; + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index d4a7692..769af8d 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -2,6 +2,7 @@ using System.Reflection; using log4net; using Nini.Config; +using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts; using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -12,13 +13,22 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring { private Scene m_scene; private readonly List m_monitors = new List(); + private readonly List m_alerts = new List(); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public void DebugMonitors(string module, string[] args) { foreach (IMonitor monitor in m_monitors) { - m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetValue()); + m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetFriendlyValue()); + } + } + + public void TestAlerts() + { + foreach (IAlert alert in m_alerts) + { + alert.Test(); } } @@ -48,6 +58,19 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring m_monitors.Add(new TotalFrameMonitor(m_scene)); m_monitors.Add(new EventFrameMonitor(m_scene)); m_monitors.Add(new LandFrameMonitor(m_scene)); + m_monitors.Add(new LastFrameTimeMonitor(m_scene)); + + m_alerts.Add(new DeadlockAlert(m_monitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor)); + + foreach (IAlert alert in m_alerts) + { + alert.OnTriggerAlert += OnTriggerAlert; + } + } + + void OnTriggerAlert(System.Type reporter, string reason, bool fatal) + { + m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")"); } public void Close() diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs new file mode 100644 index 0000000..36363f8 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/Monitors/LastFrameTimeMonitor.cs @@ -0,0 +1,34 @@ +using System; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors +{ + class LastFrameTimeMonitor : IMonitor + { + private readonly Scene m_scene; + + public LastFrameTimeMonitor(Scene scene) + { + m_scene = scene; + } + + #region Implementation of IMonitor + + public double GetValue() + { + return Environment.TickCount - m_scene.MonitorLastFrameTick; + } + + public string GetName() + { + return "Last Completed Frame At"; + } + + public string GetFriendlyValue() + { + return (int)GetValue() + "ms ago"; + } + + #endregion + } +} diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 07fdc9f..1e7803f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -279,6 +279,7 @@ namespace OpenSim.Region.Framework.Scenes private int backupMS; private int terrainMS; private int landMS; + private int lastCompletedFrame; public int MonitorFrameTime { get { return frameMS; } } public int MonitorPhysicsUpdateTime { get { return physicsMS; } } @@ -289,6 +290,7 @@ namespace OpenSim.Region.Framework.Scenes public int MonitorBackupTime { get { return backupMS; } } public int MonitorTerrainTime { get { return terrainMS; } } public int MonitorLandTime { get { return landMS; } } + public int MonitorLastFrameTick { get { return lastCompletedFrame; } } private bool m_physics_enabled = true; private bool m_scripts_enabled = true; @@ -1129,6 +1131,7 @@ namespace OpenSim.Region.Framework.Scenes otherMS = tickCount - otherMS; tmpFrameMS -= tickCount; frameMS = tmpFrameMS; + lastCompletedFrame = tickCount; // if (m_frame%m_update_avatars == 0) // UpdateInWorldTime(); -- cgit v1.1 From 3c0881c83c18489ca1887658adfa8a61c5fdd806 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 2 Nov 2009 00:20:41 +1100 Subject: * Committing missing file from last commit. --- OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs new file mode 100644 index 0000000..b533df9 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/IAlert.cs @@ -0,0 +1,13 @@ +using System; + +namespace OpenSim.Region.CoreModules.Framework.Monitoring +{ + internal delegate void Alert(Type reporter, string reason, bool fatal); + + interface IAlert + { + string GetName(); + void Test(); + event Alert OnTriggerAlert; + } +} -- cgit v1.1 From f4e9809b7d83024e5bf05b25ffe3ffd8bcd5c63d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 2 Nov 2009 06:13:05 +0000 Subject: Fix an invalid argument exception in the remote admin module when. Patch from CasperW --- OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index f4e1db4..3c7727f 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -360,7 +360,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController && ((string) requestData["shutdown"] == "delayed") && requestData.ContainsKey("milliseconds")) { - timeout = (Int32) requestData["milliseconds"]; + timeout = Int32.Parse(requestData["milliseconds"].ToString()); message = "Region is going down in " + ((int) (timeout/1000)).ToString() -- cgit v1.1 From 6309fcc5b4b42102b5bb901dbbdf44846f5643f2 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:19:55 -0800 Subject: Reverting the memory leak patch for MySQL. Problems have been reported with the grid server after running for several hours --- OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs | 15 +- OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 2 + OpenSim/Data/MSSQL/MSSQLManager.cs | 4 + OpenSim/Data/MSSQL/MSSQLMigration.cs | 1 + OpenSim/Data/Migration.cs | 79 +++--- OpenSim/Data/MySQL/MySQLAssetData.cs | 102 +++---- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 18 +- OpenSim/Data/MySQL/MySQLEstateData.cs | 310 ++++++++++----------- OpenSim/Data/MySQL/MySQLFramework.cs | 13 +- OpenSim/Data/MySQL/MySQLGridData.cs | 171 ++++++------ OpenSim/Data/MySQL/MySQLInventoryData.cs | 335 +++++++++++------------ OpenSim/Data/MySQL/MySQLManager.cs | 60 +++-- OpenSim/Data/MySQL/MySQLRegionData.cs | 228 ++++++++-------- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 87 +++--- OpenSim/Data/MySQL/MySQLUserData.cs | 370 +++++++++++++------------- 15 files changed, 917 insertions(+), 878 deletions(-) diff --git a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs index 0e21880..93e48cd 100644 --- a/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs +++ b/OpenSim/Data/MSSQL/AutoClosingSqlCommand.cs @@ -197,11 +197,20 @@ namespace OpenSim.Data.MSSQL public void Dispose() { SqlConnection conn = realCommand.Connection; - try { realCommand.Dispose(); } + try + { + realCommand.Dispose(); + } finally { - try { conn.Dispose(); } - finally { } + try + { + conn.Close(); + } + finally + { + conn.Dispose(); + } } } diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index d49c2b3..1482184 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs @@ -348,6 +348,8 @@ namespace OpenSim.Data.MSSQL //Delete the actual row DeleteOneFolder(folderID, connection); DeleteItemsInFolder(folderID, connection); + + connection.Close(); } } diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/MSSQL/MSSQLManager.cs index 992ce02..3d7a768 100644 --- a/OpenSim/Data/MSSQL/MSSQLManager.cs +++ b/OpenSim/Data/MSSQL/MSSQLManager.cs @@ -340,6 +340,8 @@ namespace OpenSim.Data.MSSQL MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore); migration.Update(); + + connection.Close(); } } @@ -383,7 +385,9 @@ namespace OpenSim.Data.MSSQL m_log.Error(e.ToString()); } } + tables.Close(); } + } /// diff --git a/OpenSim/Data/MSSQL/MSSQLMigration.cs b/OpenSim/Data/MSSQL/MSSQLMigration.cs index 549bcb3..aea31c9 100644 --- a/OpenSim/Data/MSSQL/MSSQLMigration.cs +++ b/OpenSim/Data/MSSQL/MSSQLMigration.cs @@ -56,6 +56,7 @@ namespace OpenSim.Data.MSSQL { version = Convert.ToInt32(reader["version"]); } + reader.Close(); } } catch diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index 7a99d4a..e51dc22 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs @@ -131,26 +131,25 @@ namespace OpenSim.Data m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type); m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!"); - using (DbCommand cmd = _conn.CreateCommand()) + DbCommand cmd = _conn.CreateCommand(); + foreach (KeyValuePair kvp in migrations) { - foreach (KeyValuePair kvp in migrations) - { - int newversion = kvp.Key; - cmd.CommandText = kvp.Value; - // we need to up the command timeout to infinite as we might be doing long migrations. - cmd.CommandTimeout = 0; - cmd.ExecuteNonQuery(); + int newversion = kvp.Key; + cmd.CommandText = kvp.Value; + // we need to up the command timeout to infinite as we might be doing long migrations. + cmd.CommandTimeout = 0; + cmd.ExecuteNonQuery(); - if (version == 0) - { - InsertVersion(_type, newversion); - } - else - { - UpdateVersion(_type, newversion); - } - version = newversion; + if (version == 0) + { + InsertVersion(_type, newversion); } + else + { + UpdateVersion(_type, newversion); + } + version = newversion; + cmd.Dispose(); } } @@ -190,45 +189,43 @@ namespace OpenSim.Data protected virtual int FindVersion(DbConnection conn, string type) { int version = 0; - - using (DbCommand cmd = conn.CreateCommand()) + DbCommand cmd = conn.CreateCommand(); + try { - try + cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc"; + using (IDataReader reader = cmd.ExecuteReader()) { - cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc"; - using (IDataReader reader = cmd.ExecuteReader()) + if (reader.Read()) { - if (reader.Read()) - version = Convert.ToInt32(reader["version"]); + version = Convert.ToInt32(reader["version"]); } - } - catch - { - // Something went wrong, so we're version 0 + reader.Close(); } } - + catch + { + // Something went wrong, so we're version 0 + } + cmd.Dispose(); return version; } private void InsertVersion(string type, int version) { - using (DbCommand cmd = _conn.CreateCommand()) - { - cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; - m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); - cmd.ExecuteNonQuery(); - } + DbCommand cmd = _conn.CreateCommand(); + cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; + m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); + cmd.ExecuteNonQuery(); + cmd.Dispose(); } private void UpdateVersion(string type, int version) { - using (DbCommand cmd = _conn.CreateCommand()) - { - cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; - m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); - cmd.ExecuteNonQuery(); - } + DbCommand cmd = _conn.CreateCommand(); + cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; + m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); + cmd.ExecuteNonQuery(); + cmd.Dispose(); } // private SortedList GetAllMigrations() diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 4d49733..1fe6d29 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -139,42 +139,45 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", - _dbConnection.Connection)) - { - cmd.Parameters.AddWithValue("?id", assetID.ToString()); + MySqlCommand cmd = + new MySqlCommand( + "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", + _dbConnection.Connection); + cmd.Parameters.AddWithValue("?id", assetID.ToString()); - try + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - asset = new AssetBase(); - asset.Data = (byte[])dbReader["data"]; - asset.Description = (string)dbReader["description"]; - asset.FullID = assetID; - - string local = dbReader["local"].ToString(); - if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) - asset.Local = true; - else - asset.Local = false; - - asset.Name = (string)dbReader["name"]; - asset.Type = (sbyte)dbReader["assetType"]; - asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); - } + asset = new AssetBase(); + asset.Data = (byte[]) dbReader["data"]; + asset.Description = (string) dbReader["description"]; + asset.FullID = assetID; + + string local = dbReader["local"].ToString(); + if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) + asset.Local = true; + else + asset.Local = false; + + asset.Name = (string) dbReader["name"]; + asset.Type = (sbyte) dbReader["assetType"]; + asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } + dbReader.Close(); + cmd.Dispose(); } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Reconnecting", assetID); - _dbConnection.Reconnect(); - } + if (asset != null) + UpdateAccessTime(asset); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Reconnecting", assetID); + _dbConnection.Reconnect(); } } return asset; @@ -291,27 +294,32 @@ namespace OpenSim.Data.MySQL { _dbConnection.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand( - "SELECT id FROM assets WHERE id=?id", - _dbConnection.Connection)) - { - cmd.Parameters.AddWithValue("?id", uuid.ToString()); + MySqlCommand cmd = + new MySqlCommand( + "SELECT id FROM assets WHERE id=?id", + _dbConnection.Connection); + + cmd.Parameters.AddWithValue("?id", uuid.ToString()); - try + try + { + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - assetExists = true; + assetExists = true; } + + dbReader.Close(); + cmd.Dispose(); } - catch (Exception e) - { - m_log.ErrorFormat( - "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() - + Environment.NewLine + "Attempting reconnection", uuid); - _dbConnection.Reconnect(); - } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString() + + Environment.NewLine + "Attempting reconnection", uuid); + _dbConnection.Reconnect(); } } diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 0780936..e508b52 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -55,7 +55,9 @@ namespace OpenSim.Data.MySQL AuthenticationData ret = new AuthenticationData(); ret.Data = new Dictionary(); - MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"); + MySqlCommand cmd = new MySqlCommand( + "select * from `"+m_Realm+"` where UUID = ?principalID" + ); cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); @@ -82,14 +84,16 @@ namespace OpenSim.Data.MySQL ret.Data[s] = result[s].ToString(); } - CloseDBConnection(result, cmd); + result.Close(); + CloseReaderCommand(cmd); + return ret; } - else - { - CloseDBConnection(result, cmd); - return null; - } + + result.Close(); + CloseReaderCommand(cmd); + + return null; } public bool Store(AuthenticationData data) diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs index 7166b29..e8694fc 100644 --- a/OpenSim/Data/MySQL/MySQLEstateData.cs +++ b/OpenSim/Data/MySQL/MySQLEstateData.cs @@ -95,17 +95,21 @@ namespace OpenSim.Data.MySQL protected void GetWaitTimeout() { - using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection)) + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, + m_connection); + + using (MySqlDataReader dbReader = + cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * - TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * + TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; } + + dbReader.Close(); + cmd.Dispose(); } m_lastConnectionUse = DateTime.Now.Ticks; @@ -143,103 +147,110 @@ namespace OpenSim.Data.MySQL CheckConnection(); - bool migration = true; + MySqlCommand cmd = m_connection.CreateCommand(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = sql; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.CommandText = sql; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + + IDataReader r = cmd.ExecuteReader(); - using (IDataReader r = cmd.ExecuteReader()) + if (r.Read()) + { + foreach (string name in FieldList) { - if (r.Read()) + if (m_FieldMap[name].GetValue(es) is bool) { - migration = false; - - foreach (string name in FieldList) - { - if (m_FieldMap[name].GetValue(es) is bool) - { - int v = Convert.ToInt32(r[name]); - if (v != 0) - m_FieldMap[name].SetValue(es, true); - else - m_FieldMap[name].SetValue(es, false); - } - else if (m_FieldMap[name].GetValue(es) is UUID) - { - UUID uuid = UUID.Zero; - - UUID.TryParse(r[name].ToString(), out uuid); - m_FieldMap[name].SetValue(es, uuid); - } - else - { - m_FieldMap[name].SetValue(es, r[name]); - } - } + int v = Convert.ToInt32(r[name]); + if (v != 0) + m_FieldMap[name].SetValue(es, true); + else + m_FieldMap[name].SetValue(es, false); + } + else if (m_FieldMap[name].GetValue(es) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(r[name].ToString(), out uuid); + m_FieldMap[name].SetValue(es, uuid); + } + else + { + m_FieldMap[name].SetValue(es, r[name]); } } + r.Close(); } - - if (migration) + else { // Migration case + // + r.Close(); + List names = new List(FieldList); names.Remove("EstateID"); sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")"; - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = sql; - cmd.Parameters.Clear(); + cmd.CommandText = sql; + cmd.Parameters.Clear(); - foreach (string name in FieldList) + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); - else - cmd.Parameters.AddWithValue("?" + name, "0"); - } + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); else - { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); - } + cmd.Parameters.AddWithValue("?" + name, "0"); } + else + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); + } + } - cmd.ExecuteNonQuery(); + cmd.ExecuteNonQuery(); - cmd.CommandText = "select LAST_INSERT_ID() as id"; - cmd.Parameters.Clear(); + cmd.CommandText = "select LAST_INSERT_ID() as id"; + cmd.Parameters.Clear(); - using (IDataReader r = cmd.ExecuteReader()) - { - r.Read(); - es.EstateID = Convert.ToUInt32(r["id"]); - } + r = cmd.ExecuteReader(); + + r.Read(); - cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; - cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + es.EstateID = Convert.ToUInt32(r["id"]); - // This will throw on dupe key - try { cmd.ExecuteNonQuery(); } - catch (Exception) { } + r.Close(); + + cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - // Munge and transfer the ban list - cmd.Parameters.Clear(); - cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + // This will throw on dupe key + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { + } - try { cmd.ExecuteNonQuery(); } - catch (Exception) { } + // Munge and transfer the ban list + // + cmd.Parameters.Clear(); + cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID"; + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); - es.Save(); + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception) + { } + + es.Save(); } LoadBanList(es); @@ -256,28 +267,27 @@ namespace OpenSim.Data.MySQL CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = sql; + MySqlCommand cmd = m_connection.CreateCommand(); - foreach (string name in FieldList) + cmd.CommandText = sql; + + foreach (string name in FieldList) + { + if (m_FieldMap[name].GetValue(es) is bool) { - if (m_FieldMap[name].GetValue(es) is bool) - { - if ((bool)m_FieldMap[name].GetValue(es)) - cmd.Parameters.AddWithValue("?" + name, "1"); - else - cmd.Parameters.AddWithValue("?" + name, "0"); - } + if ((bool)m_FieldMap[name].GetValue(es)) + cmd.Parameters.AddWithValue("?" + name, "1"); else - { - cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); - } + cmd.Parameters.AddWithValue("?" + name, "0"); + } + else + { + cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString()); } - - cmd.ExecuteNonQuery(); } + cmd.ExecuteNonQuery(); + SaveBanList(es); SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers); SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess); @@ -290,52 +300,50 @@ namespace OpenSim.Data.MySQL CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID); + MySqlCommand cmd = m_connection.CreateCommand(); - using (IDataReader r = cmd.ExecuteReader()) - { - while (r.Read()) - { - EstateBan eb = new EstateBan(); + cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID); - UUID uuid = new UUID(); - UUID.TryParse(r["bannedUUID"].ToString(), out uuid); + IDataReader r = cmd.ExecuteReader(); - eb.BannedUserID = uuid; - eb.BannedHostAddress = "0.0.0.0"; - eb.BannedHostIPMask = "0.0.0.0"; - es.AddBan(eb); - } - } + while (r.Read()) + { + EstateBan eb = new EstateBan(); + + UUID uuid = new UUID(); + UUID.TryParse(r["bannedUUID"].ToString(), out uuid); + + eb.BannedUserID = uuid; + eb.BannedHostAddress = "0.0.0.0"; + eb.BannedHostIPMask = "0.0.0.0"; + es.AddBan(eb); } + r.Close(); } private void SaveBanList(EstateSettings es) { CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + MySqlCommand cmd = m_connection.CreateCommand(); - cmd.ExecuteNonQuery(); + cmd.CommandText = "delete from estateban where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.Clear(); + cmd.ExecuteNonQuery(); - cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; + cmd.Parameters.Clear(); - foreach (EstateBan b in es.EstateBans) - { - cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); - cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); + cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )"; - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } + foreach (EstateBan b in es.EstateBans) + { + cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString()); + cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); } } @@ -343,25 +351,24 @@ namespace OpenSim.Data.MySQL { CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + MySqlCommand cmd = m_connection.CreateCommand(); - cmd.ExecuteNonQuery(); + cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - cmd.Parameters.Clear(); + cmd.ExecuteNonQuery(); - cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; + cmd.Parameters.Clear(); - foreach (UUID uuid in data) - { - cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); - cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); + cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )"; - cmd.ExecuteNonQuery(); - cmd.Parameters.Clear(); - } + foreach (UUID uuid in data) + { + cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString()); + cmd.Parameters.AddWithValue("?uuid", uuid.ToString()); + + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); } } @@ -371,24 +378,23 @@ namespace OpenSim.Data.MySQL CheckConnection(); - using (MySqlCommand cmd = m_connection.CreateCommand()) - { - cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; - cmd.Parameters.AddWithValue("?EstateID", EstateID); + MySqlCommand cmd = m_connection.CreateCommand(); - using (IDataReader r = cmd.ExecuteReader()) - { - while (r.Read()) - { - // EstateBan eb = new EstateBan(); + cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID"; + cmd.Parameters.AddWithValue("?EstateID", EstateID); - UUID uuid = new UUID(); - UUID.TryParse(r["uuid"].ToString(), out uuid); + IDataReader r = cmd.ExecuteReader(); - uuids.Add(uuid); - } - } + while (r.Read()) + { + // EstateBan eb = new EstateBan(); + + UUID uuid = new UUID(); + UUID.TryParse(r["uuid"].ToString(), out uuid); + + uuids.Add(uuid); } + r.Close(); return uuids.ToArray(); } diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index ccd1ab0..fd428ae 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -40,10 +40,6 @@ namespace OpenSim.Data.MySQL /// public class MySqlFramework { - private static readonly log4net.ILog m_log = - log4net.LogManager.GetLogger( - System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - protected MySqlConnection m_Connection; protected MySqlFramework(string connectionString) @@ -73,11 +69,12 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { - m_log.Error(e.Message, e); +Console.WriteLine(e.ToString()); if (errorSeen) throw; // This is "Server has gone away" and "Server lost" + // if (e.Number == 2006 || e.Number == 2013) { errorSeen = true; @@ -96,7 +93,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error(e.Message, e); +Console.WriteLine(e.ToString()); return 0; } } @@ -113,11 +110,11 @@ namespace OpenSim.Data.MySQL return cmd.ExecuteReader(); } - protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd) + protected void CloseReaderCommand(MySqlCommand cmd) { - reader.Close(); cmd.Connection.Close(); cmd.Connection.Dispose(); + cmd.Dispose(); } } } diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs index 38cb3b7..1ec2609 100644 --- a/OpenSim/Data/MySQL/MySQLGridData.cs +++ b/OpenSim/Data/MySQL/MySQLGridData.cs @@ -197,27 +197,29 @@ namespace OpenSim.Data.MySQL param["?xmax"] = xmax.ToString(); param["?ymax"] = ymax.ToString(); - using (IDbCommand result = dbm.Manager.Query( + IDbCommand result = + dbm.Manager.Query( "SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; + param); + IDataReader reader = result.ExecuteReader(); - List rows = new List(); + RegionProfileData row; - while ((row = dbm.Manager.readSimRow(reader)) != null) - rows.Add(row); + List rows = new List(); - return rows.ToArray(); - } + while ((row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); } + reader.Close(); + result.Dispose(); + + return rows.ToArray(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -241,27 +243,29 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?name"] = namePrefix + "%"; - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName LIKE ?name", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row; + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName LIKE ?name", + param); + IDataReader reader = result.ExecuteReader(); - List rows = new List(); + RegionProfileData row; - while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) - rows.Add(row); + List rows = new List(); - return rows; - } + while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null) + { + rows.Add(row); } + reader.Close(); + result.Dispose(); + + return rows; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -282,21 +286,21 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?handle"] = handle.ToString(); + param["?handle"] = handle.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } - } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -317,24 +321,23 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?uuid"] = uuid.ToString(); + param["?uuid"] = uuid.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } - } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; - } - finally + } finally { dbm.Release(); } @@ -356,21 +359,22 @@ namespace OpenSim.Data.MySQL // Add % because this is a like query. param["?regionName"] = regionName + "%"; // Order by statement will return shorter matches first. Only returns one record or no record. - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - RegionProfileData row = dbm.Manager.readSimRow(reader); - return row; - } - } + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1", + param); + IDataReader reader = result.ExecuteReader(); + + RegionProfileData row = dbm.Manager.readSimRow(reader); + reader.Close(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -378,7 +382,6 @@ namespace OpenSim.Data.MySQL dbm.Release(); } } - m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters"); return null; } @@ -391,12 +394,12 @@ namespace OpenSim.Data.MySQL override public DataResponse StoreProfile(RegionProfileData profile) { MySQLSuperManager dbm = GetLockedConnection(); - try - { + try { if (dbm.Manager.insertRegion(profile)) + { return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; + } + return DataResponse.RESPONSE_ERROR; } finally { @@ -414,14 +417,14 @@ namespace OpenSim.Data.MySQL { MySQLSuperManager dbm = GetLockedConnection(); - try - { + + try { if (dbm.Manager.deleteRegion(uuid)) + { return DataResponse.RESPONSE_OK; - else - return DataResponse.RESPONSE_ERROR; - } - finally + } + return DataResponse.RESPONSE_ERROR; + } finally { dbm.Release(); } @@ -479,26 +482,26 @@ namespace OpenSim.Data.MySQL try { Dictionary param = new Dictionary(); - param["?x"] = x.ToString(); - param["?y"] = y.ToString(); - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", - param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - ReservationData row = dbm.Manager.readReservationRow(reader); - return row; - } - } + param["?x"] = x.ToString(); + param["?y"] = y.ToString(); + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y", + param); + IDataReader reader = result.ExecuteReader(); + + ReservationData row = dbm.Manager.readReservationRow(reader); + reader.Close(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; - } - finally + } finally { dbm.Release(); } diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs index 598971d..0eecf06 100644 --- a/OpenSim/Data/MySQL/MySQLInventoryData.cs +++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs @@ -135,30 +135,30 @@ namespace OpenSim.Data.MySQL database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", - database.Connection)) + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - result.Parameters.AddWithValue("?uuid", folderID.ToString()); + // A null item (because something went wrong) breaks everything in the folder + InventoryItemBase item = readInventoryItem(reader); + if (item != null) + items.Add(item); + } - using (MySqlDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - // A null item (because something went wrong) breaks everything in the folder - InventoryItemBase item = readInventoryItem(reader); - if (item != null) - items.Add(item); - } + reader.Close(); + result.Dispose(); - return items; - } - } + return items; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -176,28 +176,29 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection)) - { - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - using (MySqlDataReader reader = result.ExecuteReader()) - { - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - return items; - } - } + + reader.Close(); + result.Dispose(); + + return items; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -216,38 +217,41 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand( - "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", - database.Connection)) - { - result.Parameters.AddWithValue("?uuid", user.ToString()); - result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); + MySqlCommand result = + new MySqlCommand( + "SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", user.ToString()); + result.Parameters.AddWithValue("?zero", UUID.Zero.ToString()); - using (MySqlDataReader reader = result.ExecuteReader()) - { - List items = new List(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + MySqlDataReader reader = result.ExecuteReader(); - InventoryFolderBase rootFolder = null; + List items = new List(); + while (reader.Read()) + items.Add(readInventoryFolder(reader)); - // There should only ever be one root folder for a user. However, if there's more - // than one we'll simply use the first one rather than failing. It would be even - // nicer to print some message to this effect, but this feels like it's too low a - // to put such a message out, and it's too minor right now to spare the time to - // suitably refactor. - if (items.Count > 0) - rootFolder = items[0]; + InventoryFolderBase rootFolder = null; - return rootFolder; - } + // There should only ever be one root folder for a user. However, if there's more + // than one we'll simply use the first one rather than failing. It would be even + // nicer to print some message to this effect, but this feels like it's too low a + // to put such a message out, and it's too minor right now to spare the time to + // suitably refactor. + if (items.Count > 0) + { + rootFolder = items[0]; } + + reader.Close(); + result.Dispose(); + + return rootFolder; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -267,26 +271,27 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", - database.Connection)) - { - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - using (MySqlDataReader reader = result.ExecuteReader()) - { - List items = new List(); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - while (reader.Read()) - items.Add(readInventoryFolder(reader)); + List items = new List(); - return items; - } - } + while (reader.Read()) + items.Add(readInventoryFolder(reader)); + + reader.Close(); + result.Dispose(); + + return items; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -365,25 +370,25 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection)) - { - result.Parameters.AddWithValue("?uuid", itemID.ToString()); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection); + result.Parameters.AddWithValue("?uuid", itemID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - using (MySqlDataReader reader = result.ExecuteReader()) - { - InventoryItemBase item = null; - if (reader.Read()) - item = readInventoryItem(reader); + InventoryItemBase item = null; + if (reader.Read()) + item = readInventoryItem(reader); - return item; - } - } + reader.Close(); + result.Dispose(); + + return item; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } return null; } @@ -408,7 +413,7 @@ namespace OpenSim.Data.MySQL } catch (Exception e) { - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } return null; @@ -428,25 +433,24 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) - { - result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlCommand result = + new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection); + result.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlDataReader reader = result.ExecuteReader(); - using (MySqlDataReader reader = result.ExecuteReader()) - { - InventoryFolderBase folder = null; - if (reader.Read()) - folder = readInventoryFolder(reader); + InventoryFolderBase folder = null; + if (reader.Read()) + folder = readInventoryFolder(reader); + reader.Close(); + result.Dispose(); - return folder; - } - } + return folder; } } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -694,73 +698,69 @@ namespace OpenSim.Data.MySQL try { List folders = new List(); - Dictionary> hashtable = new Dictionary>(); ; + Dictionary> hashtable + = new Dictionary>(); ; List parentFolder = new List(); - bool buildResultsFromHashTable = false; - lock (database) { + MySqlCommand result; + MySqlDataReader reader; + bool buildResultsFromHashTable = false; + database.CheckConnection(); /* Fetch the parent folder from the database to determine the agent ID, and if * we're querying the root of the inventory folder tree */ - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection)) - { - result.Parameters.AddWithValue("?uuid", parentID.ToString()); - - using (MySqlDataReader reader = result.ExecuteReader()) - { - // Should be at most 1 result - while (reader.Read()) - parentFolder.Add(readInventoryFolder(reader)); - } - } + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentID.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) // Should be at most 1 result + parentFolder.Add(readInventoryFolder(reader)); + reader.Close(); + result.Dispose(); if (parentFolder.Count >= 1) // No result means parent folder does not exist { if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder { /* Get all of the agent's folders from the database, put them in a list and return it */ - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) { - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - - using (MySqlDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list - folders.Add(curFolder); - } - } + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list + folders.Add(curFolder); } + reader.Close(); + result.Dispose(); } // if we are querying the root folder else // else we are querying a subtree of the inventory folder tree { /* Get all of the agent's folders from the database, put them all in a hash table * indexed by their parent ID */ - using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection)) + result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", + database.Connection); + result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); + reader = result.ExecuteReader(); + while (reader.Read()) { - result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString()); - - using (MySqlDataReader reader = result.ExecuteReader()) + InventoryFolderBase curFolder = readInventoryFolder(reader); + if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling + hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list + else // else current folder has no known (yet) siblings { - while (reader.Read()) - { - InventoryFolderBase curFolder = readInventoryFolder(reader); - if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling - hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list - else // else current folder has no known (yet) siblings - { - List siblingList = new List(); - siblingList.Add(curFolder); - // Current folder has no known (yet) siblings - hashtable.Add(curFolder.ParentID, siblingList); - } - } // while more items to read from the database + List siblingList = new List(); + siblingList.Add(curFolder); + // Current folder has no known (yet) siblings + hashtable.Add(curFolder.ParentID, siblingList); } - } + } // while more items to read from the database + reader.Close(); + result.Dispose(); // Set flag so we know we need to build the results from the hash table after // we unlock the database @@ -781,13 +781,12 @@ namespace OpenSim.Data.MySQL folders.AddRange(hashtable[folders[i].ID]); } } // lock (database) - return folders; } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } } @@ -802,18 +801,19 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection)) - { - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - lock (database) - cmd.ExecuteNonQuery(); + lock (database) + { + cmd.ExecuteNonQuery(); } } catch (MySqlException e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } } @@ -827,12 +827,13 @@ namespace OpenSim.Data.MySQL { database.CheckConnection(); - using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection)) - { - cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); + MySqlCommand cmd = + new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection); + cmd.Parameters.AddWithValue("?uuid", folderID.ToString()); - lock (database) - cmd.ExecuteNonQuery(); + lock (database) + { + cmd.ExecuteNonQuery(); } } catch (MySqlException e) @@ -864,38 +865,40 @@ namespace OpenSim.Data.MySQL public List fetchActiveGestures(UUID avatarID) { + MySqlDataReader result = null; + MySqlCommand sqlCmd = null; lock (database) { try { database.CheckConnection(); - - using (MySqlCommand sqlCmd = new MySqlCommand( + sqlCmd = new MySqlCommand( "SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1", - database.Connection)) - { - sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); - sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + database.Connection); + sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString()); + sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); + result = sqlCmd.ExecuteReader(); - using (MySqlDataReader result = sqlCmd.ExecuteReader()) - { - List list = new List(); - while (result.Read()) - { - InventoryItemBase item = readInventoryItem(result); - if (item != null) - list.Add(item); - } - return list; - } + List list = new List(); + while (result.Read()) + { + InventoryItemBase item = readInventoryItem(result); + if (item != null) + list.Add(item); } + return list; } catch (Exception e) { database.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } + finally + { + if (result != null) result.Close(); + if (sqlCmd != null) sqlCmd.Dispose(); + } } } } diff --git a/OpenSim/Data/MySQL/MySQLManager.cs b/OpenSim/Data/MySQL/MySQLManager.cs index a724a50..a6cce57 100644 --- a/OpenSim/Data/MySQL/MySQLManager.cs +++ b/OpenSim/Data/MySQL/MySQLManager.cs @@ -134,16 +134,18 @@ namespace OpenSim.Data.MySQL /// protected void GetWaitTimeout() { - using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon)) + MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon); + + using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) { - using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) + if (dbReader.Read()) { - if (dbReader.Read()) - { - m_waitTimeout - = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; - } + m_waitTimeout + = Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway; } + + dbReader.Close(); + cmd.Dispose(); } m_lastConnectionUse = DateTime.Now.Ticks; @@ -301,31 +303,31 @@ namespace OpenSim.Data.MySQL { CheckConnection(); - using (MySqlCommand tablesCmd = new MySqlCommand( - "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", - dbcon)) - { - tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); + MySqlCommand tablesCmd = + new MySqlCommand( + "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname", + dbcon); + tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database); - using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + using (MySqlDataReader tables = tablesCmd.ExecuteReader()) + { + while (tables.Read()) { - while (tables.Read()) + try { - try - { - string tableName = (string)tables["TABLE_NAME"]; - string comment = (string)tables["TABLE_COMMENT"]; - if (tableList.ContainsKey(tableName)) - { - tableList[tableName] = comment; - } - } - catch (Exception e) + string tableName = (string) tables["TABLE_NAME"]; + string comment = (string) tables["TABLE_COMMENT"]; + if (tableList.ContainsKey(tableName)) { - m_log.Error(e.Message, e); + tableList[tableName] = comment; } } + catch (Exception e) + { + m_log.Error(e.ToString()); + } } + tables.Close(); } } } @@ -344,19 +346,19 @@ namespace OpenSim.Data.MySQL { CheckConnection(); // Not sure if this one is necessary - MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); + MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand(); dbcommand.CommandText = sql; foreach (KeyValuePair param in parameters) { dbcommand.Parameters.AddWithValue(param.Key, param.Value); } - return (IDbCommand)dbcommand; + return (IDbCommand) dbcommand; } catch (Exception e) { // Return null if it fails. - m_log.Error("Failed during Query generation: " + e.Message, e); + m_log.Error("Failed during Query generation: " + e.ToString()); return null; } } @@ -692,6 +694,8 @@ namespace OpenSim.Data.MySQL ret.Add(attachpoint, item); } + r.Close(); + return ret; } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index f514076..b0075e8 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -56,13 +56,12 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?regionName", regionName); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - return RunCommand(cmd); - } + cmd.Parameters.AddWithValue("?regionName", regionName); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); } public RegionData Get(int posX, int posY, UUID scopeID) @@ -71,18 +70,17 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?posX", posX.ToString()); - cmd.Parameters.AddWithValue("?posY", posY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + cmd.Parameters.AddWithValue("?posX", posX.ToString()); + cmd.Parameters.AddWithValue("?posY", posY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return ret[0]; - } + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; + + return ret[0]; } public RegionData Get(UUID regionID, UUID scopeID) @@ -91,17 +89,16 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - List ret = RunCommand(cmd); - if (ret.Count == 0) - return null; + cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); - return ret[0]; - } + List ret = RunCommand(cmd); + if (ret.Count == 0) + return null; + + return ret[0]; } public List Get(int startX, int startY, int endX, int endY, UUID scopeID) @@ -110,44 +107,43 @@ namespace OpenSim.Data.MySQL if (scopeID != UUID.Zero) command += " and ScopeID = ?scopeID"; - using (MySqlCommand cmd = new MySqlCommand(command)) - { - cmd.Parameters.AddWithValue("?startX", startX.ToString()); - cmd.Parameters.AddWithValue("?startY", startY.ToString()); - cmd.Parameters.AddWithValue("?endX", endX.ToString()); - cmd.Parameters.AddWithValue("?endY", endY.ToString()); - cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + MySqlCommand cmd = new MySqlCommand(command); - return RunCommand(cmd); - } + cmd.Parameters.AddWithValue("?startX", startX.ToString()); + cmd.Parameters.AddWithValue("?startY", startY.ToString()); + cmd.Parameters.AddWithValue("?endX", endX.ToString()); + cmd.Parameters.AddWithValue("?endY", endY.ToString()); + cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); + + return RunCommand(cmd); } public List RunCommand(MySqlCommand cmd) { List retList = new List(); - using (IDataReader result = ExecuteReader(cmd)) + IDataReader result = ExecuteReader(cmd); + + while (result.Read()) { - while (result.Read()) + RegionData ret = new RegionData(); + ret.Data = new Dictionary(); + + UUID regionID; + UUID.TryParse(result["uuid"].ToString(), out regionID); + ret.RegionID = regionID; + UUID scope; + UUID.TryParse(result["ScopeID"].ToString(), out scope); + ret.ScopeID = scope; + ret.RegionName = result["regionName"].ToString(); + ret.posX = Convert.ToInt32(result["locX"]); + ret.posY = Convert.ToInt32(result["locY"]); + ret.sizeX = Convert.ToInt32(result["sizeX"]); + ret.sizeY = Convert.ToInt32(result["sizeY"]); + + if (m_ColumnNames == null) { - RegionData ret = new RegionData(); - ret.Data = new Dictionary(); - - UUID regionID; - UUID.TryParse(result["uuid"].ToString(), out regionID); - ret.RegionID = regionID; - UUID scope; - UUID.TryParse(result["ScopeID"].ToString(), out scope); - ret.ScopeID = scope; - ret.RegionName = result["regionName"].ToString(); - ret.posX = Convert.ToInt32(result["locX"]); - ret.posY = Convert.ToInt32(result["locY"]); - ret.sizeX = Convert.ToInt32(result["sizeX"]); - ret.sizeY = Convert.ToInt32(result["sizeY"]); - - if (m_ColumnNames == null) - { - m_ColumnNames = new List(); + m_ColumnNames = new List(); DataTable schemaTable = result.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) @@ -157,28 +153,28 @@ namespace OpenSim.Data.MySQL } } - foreach (string s in m_ColumnNames) - { - if (s == "uuid") - continue; - if (s == "ScopeID") - continue; - if (s == "regionName") - continue; - if (s == "locX") - continue; - if (s == "locY") - continue; - - ret.Data[s] = result[s].ToString(); - } - - retList.Add(ret); + foreach (string s in m_ColumnNames) + { + if (s == "uuid") + continue; + if (s == "ScopeID") + continue; + if (s == "regionName") + continue; + if (s == "locX") + continue; + if (s == "locY") + continue; + + ret.Data[s] = result[s].ToString(); } - CloseDBConnection(result, cmd); + retList.Add(ret); } + result.Close(); + CloseReaderCommand(cmd); + return retList; } @@ -205,72 +201,76 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - using (MySqlCommand cmd = new MySqlCommand()) + MySqlCommand cmd = new MySqlCommand(); + + string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; + foreach (string field in fields) { - string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; - foreach (string field in fields) - { - update += ", "; - update += "`" + field + "` = ?" + field; + update += ", "; + update += "`" + field + "` = ?"+field; - cmd.Parameters.AddWithValue("?" + field, data.Data[field]); - } + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); + } - update += " where uuid = ?regionID"; + update += " where uuid = ?regionID"; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); - cmd.Parameters.AddWithValue("?regionName", data.RegionName); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); - cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); - cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); - cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); + cmd.Parameters.AddWithValue("?regionName", data.RegionName); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); + cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); + cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); + cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + - String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; + if (ExecuteNonQuery(cmd) < 1) + { + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" + + String.Join("`, `", fields) + + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")"; - cmd.CommandText = insert; + cmd.CommandText = insert; - if (ExecuteNonQuery(cmd) < 1) - { - return false; - } + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; } } + cmd.Dispose(); + return true; } public bool SetDataItem(UUID regionID, string item, string value) { - using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID")) - { - cmd.Parameters.AddWithValue("?" + item, value); - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where uuid = ?UUID"); - if (ExecuteNonQuery(cmd) > 0) - return true; - } + + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } public bool Delete(UUID regionID) { - using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID")) - { - cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + + "` where uuid = ?UUID"); - if (ExecuteNonQuery(cmd) > 0) - return true; - } + + cmd.Parameters.AddWithValue("?UUID", regionID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index 0bbc3f5..d48144d 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -97,14 +97,16 @@ namespace OpenSim.Data.MySQL ret.Data[s] = result[s].ToString(); } - CloseDBConnection(result, cmd); + result.Close(); + CloseReaderCommand(cmd); + return ret; } - else - { - CloseDBConnection(result, cmd); - return null; - } + + result.Close(); + CloseReaderCommand(cmd); + + return null; } public bool Store(UserAccountData data) @@ -116,60 +118,61 @@ namespace OpenSim.Data.MySQL string[] fields = new List(data.Data.Keys).ToArray(); - using (MySqlCommand cmd = new MySqlCommand()) + MySqlCommand cmd = new MySqlCommand(); + + string update = "update `"+m_Realm+"` set "; + bool first = true; + foreach (string field in fields) { - string update = "update `" + m_Realm + "` set "; - bool first = true; - foreach (string field in fields) - { - if (!first) - update += ", "; - update += "`" + field + "` = ?" + field; + if (!first) + update += ", "; + update += "`" + field + "` = ?"+field; - first = false; + first = false; - cmd.Parameters.AddWithValue("?" + field, data.Data[field]); - } + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); + } - update += " where UUID = ?principalID"; + update += " where UUID = ?principalID"; - if (data.ScopeID != UUID.Zero) - update += " and ScopeID = ?scopeID"; + if (data.ScopeID != UUID.Zero) + update += " and ScopeID = ?scopeID"; - cmd.CommandText = update; - cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); - cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.CommandText = update; + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); - if (ExecuteNonQuery(cmd) < 1) - { - string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + - String.Join("`, `", fields) + - "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + if (ExecuteNonQuery(cmd) < 1) + { + string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" + + String.Join("`, `", fields) + + "`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; - cmd.CommandText = insert; + cmd.CommandText = insert; - if (ExecuteNonQuery(cmd) < 1) - { - cmd.Dispose(); - return false; - } + if (ExecuteNonQuery(cmd) < 1) + { + cmd.Dispose(); + return false; } } + cmd.Dispose(); + return true; } public bool SetDataItem(UUID principalID, string item, string value) { - using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + - item + "` = ?" + item + " where UUID = ?UUID")) - { - cmd.Parameters.AddWithValue("?" + item, value); - cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + + "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - if (ExecuteNonQuery(cmd) > 0) - return true; - } + + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index bd46dfc..04f872f 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -181,20 +181,21 @@ namespace OpenSim.Data.MySQL param["?first"] = user; param["?second"] = last; - using (IDbCommand result = dbm.Manager.Query( - "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserProfileData row = dbm.Manager.readUserRow(reader); - return row; - } - } + IDbCommand result = + dbm.Manager.Query( + "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param); + IDataReader reader = result.ExecuteReader(); + + UserProfileData row = dbm.Manager.readUserRow(reader); + + reader.Dispose(); + result.Dispose(); + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -219,30 +220,28 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand adder = dbm.Manager.Query( - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?ownerID,?friendID,?friendPerms,?datetimestamp)", - param)) - { - adder.ExecuteNonQuery(); - } - - using (IDbCommand adder = dbm.Manager.Query( - "INSERT INTO `" + m_userFriendsTableName + "` " + - "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + - "VALUES " + - "(?friendID,?ownerID,?friendPerms,?datetimestamp)", - param)) - { - adder.ExecuteNonQuery(); - } + IDbCommand adder = + dbm.Manager.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?ownerID,?friendID,?friendPerms,?datetimestamp)", + param); + adder.ExecuteNonQuery(); + + adder = + dbm.Manager.Query( + "INSERT INTO `" + m_userFriendsTableName + "` " + + "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " + + "VALUES " + + "(?friendID,?ownerID,?friendPerms,?datetimestamp)", + param); + adder.ExecuteNonQuery(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -261,24 +260,22 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand updater = dbm.Manager.Query( + IDbCommand updater = + dbm.Manager.Query( "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID", - param)) - { - updater.ExecuteNonQuery(); - } + param); + updater.ExecuteNonQuery(); - using (IDbCommand updater = dbm.Manager.Query( + updater = + dbm.Manager.Query( "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID", - param)) - { - updater.ExecuteNonQuery(); - } + param); + updater.ExecuteNonQuery(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -298,19 +295,18 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand updater = dbm.Manager.Query( + IDbCommand updater = + dbm.Manager.Query( "update " + m_userFriendsTableName + " SET friendPerms = ?friendPerms " + "where ownerID = ?ownerID and friendID = ?friendID", - param)) - { - updater.ExecuteNonQuery(); - } + param); + updater.ExecuteNonQuery(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -331,33 +327,34 @@ namespace OpenSim.Data.MySQL try { //Left Join userfriends to itself - using (IDbCommand result = dbm.Manager.Query( - "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + - m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + - " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", - param)) + IDbCommand result = + dbm.Manager.Query( + "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " + + m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" + + " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - FriendListItem fli = new FriendListItem(); - fli.FriendListOwner = new UUID((string)reader["ownerID"]); - fli.Friend = new UUID((string)reader["friendID"]); - fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]); - - // This is not a real column in the database table, it's a joined column from the opposite record - fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]); - - Lfli.Add(fli); - } - } + FriendListItem fli = new FriendListItem(); + fli.FriendListOwner = new UUID((string) reader["ownerID"]); + fli.Friend = new UUID((string) reader["friendID"]); + fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]); + + // This is not a real column in the database table, it's a joined column from the opposite record + fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]); + + Lfli.Add(fli); } + + reader.Dispose(); + result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return Lfli; } finally @@ -379,29 +376,29 @@ namespace OpenSim.Data.MySQL { Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); + IDbCommand result = + dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + + " where UUID = ?uuid", param); - using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName + - " where UUID = ?uuid", param)) + IDataReader reader = result.ExecuteReader(); + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - FriendRegionInfo fri = new FriendRegionInfo(); - fri.isOnline = (sbyte)reader["agentOnline"] != 0; - fri.regionHandle = (ulong)reader["currentHandle"]; - - infos[uuid] = fri; - } - } + FriendRegionInfo fri = new FriendRegionInfo(); + fri.isOnline = (sbyte)reader["agentOnline"] != 0; + fri.regionHandle = (ulong)reader["currentHandle"]; + + infos[uuid] = fri; } + + reader.Dispose(); + result.Dispose(); } } catch (Exception e) { m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e); dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -430,28 +427,28 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand result = dbm.Manager.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first AND lastname like ?second LIMIT 100", - param)) + IDbCommand result = + dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first AND lastname like ?second LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; - returnlist.Add(user); - } - } + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); } + reader.Dispose(); + result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return returnlist; } finally @@ -468,28 +465,28 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%"; - using (IDbCommand result = dbm.Manager.Query( - "SELECT UUID,username,lastname FROM " + m_usersTableName + - " WHERE username like ?first OR lastname like ?first LIMIT 100", - param)) + IDbCommand result = + dbm.Manager.Query( + "SELECT UUID,username,lastname FROM " + m_usersTableName + + " WHERE username like ?first OR lastname like ?first LIMIT 100", + param); + IDataReader reader = result.ExecuteReader(); + + while (reader.Read()) { - using (IDataReader reader = result.ExecuteReader()) - { - while (reader.Read()) - { - AvatarPickerAvatar user = new AvatarPickerAvatar(); - user.AvatarID = new UUID((string)reader["UUID"]); - user.firstName = (string)reader["username"]; - user.lastName = (string)reader["lastname"]; - returnlist.Add(user); - } - } + AvatarPickerAvatar user = new AvatarPickerAvatar(); + user.AvatarID = new UUID((string) reader["UUID"]); + user.firstName = (string) reader["username"]; + user.lastName = (string) reader["lastname"]; + returnlist.Add(user); } + reader.Dispose(); + result.Dispose(); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return returnlist; } finally @@ -513,19 +510,20 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserProfileData row = dbm.Manager.readUserRow(reader); - return row; - } - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + UserProfileData row = dbm.Manager.readUserRow(reader); + + reader.Dispose(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -571,15 +569,15 @@ namespace OpenSim.Data.MySQL try { - dbm.Manager.ExecuteParameterizedSql( - "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + - "where UUID = ?UUID", - param); + dbm.Manager.ExecuteParameterizedSql( + "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " + + "where UUID = ?UUID", + param); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally @@ -602,19 +600,21 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?uuid"] = uuid.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - UserAgentData row = dbm.Manager.readAgentRow(reader); - return row; - } - } + IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", + param); + IDataReader reader = result.ExecuteReader(); + + UserAgentData row = dbm.Manager.readAgentRow(reader); + + reader.Dispose(); + result.Dispose(); + + return row; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -638,20 +638,19 @@ namespace OpenSim.Data.MySQL try { - dbm.Manager.insertUserRow( - user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, - user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, - user.LastLogin, user.UserInventoryURI, user.UserAssetURI, - user.CanDoMask, user.WantDoMask, - user.AboutText, user.FirstLifeAboutText, user.Image, - user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, + user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, + user.LastLogin, user.UserInventoryURI, user.UserAssetURI, + user.CanDoMask, user.WantDoMask, + user.AboutText, user.FirstLifeAboutText, user.Image, + user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -677,7 +676,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -694,15 +693,14 @@ namespace OpenSim.Data.MySQL MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile"); try { - dbm.Manager.updateUserRow( - user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, - user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, - user.HomeLocation.Z, user.HomeLookAt.X, - user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, - user.UserInventoryURI, - user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, - user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, - user.UserFlags, user.GodLevel, user.CustomType, user.Partner); + dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt, + user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y, + user.HomeLocation.Z, user.HomeLookAt.X, + user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin, + user.UserInventoryURI, + user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText, + user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey, + user.UserFlags, user.GodLevel, user.CustomType, user.Partner); } finally { @@ -750,29 +748,29 @@ namespace OpenSim.Data.MySQL Dictionary param = new Dictionary(); param["?owner"] = user.ToString(); - using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param)) + IDbCommand result = dbm.Manager.Query( + "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param); + IDataReader reader = result.ExecuteReader(); + + AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); + + reader.Dispose(); + result.Dispose(); + + if (null == appearance) { - using (IDataReader reader = result.ExecuteReader()) - { - AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader); - - if (appearance == null) - { - m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); - return null; - } - else - { - appearance.SetAttachments(GetUserAttachments(user)); - return appearance; - } - } + m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString()); + return null; } + + appearance.SetAttachments(GetUserAttachments(user)); + + return appearance; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -800,7 +798,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); } finally { @@ -835,20 +833,20 @@ namespace OpenSim.Data.MySQL try { - using (IDbCommand result = dbm.Manager.Query( - "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param)) - { - using (IDataReader reader = result.ExecuteReader()) - { - Hashtable ret = dbm.Manager.readAttachments(reader); - return ret; - } - } + IDbCommand result = dbm.Manager.Query( + "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param); + IDataReader reader = result.ExecuteReader(); + + Hashtable ret = dbm.Manager.readAttachments(reader); + + reader.Dispose(); + result.Dispose(); + return ret; } catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return null; } finally @@ -907,7 +905,7 @@ namespace OpenSim.Data.MySQL catch (Exception e) { dbm.Manager.Reconnect(); - m_log.Error(e.Message, e); + m_log.Error(e.ToString()); return; } finally -- cgit v1.1 From 67ac9881faf2034facfe92613538938695c2cda9 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:28:35 -0800 Subject: Removing duplicate SceneObjectPart.RotationalVelocity property --- OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs | 8 ++++---- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 8 ++++---- OpenSim/Data/SQLite/SQLiteRegionData.cs | 8 ++++---- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 20 +++++++------------- .../ContentManagementSystem/PointMetaEntity.cs | 11 +++++------ .../ContentManagementSystem/SceneObjectGroupDiff.cs | 2 -- .../Shared/Api/Implementation/LSL_Api.cs | 3 +-- 8 files changed, 26 insertions(+), 36 deletions(-) diff --git a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs index cff6b00..6371307 100644 --- a/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLLegacyRegionData.cs @@ -1049,7 +1049,7 @@ VALUES if (!(primRow["ParticleSystem"] is DBNull)) prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; - prim.RotationalVelocity = new Vector3( + prim.AngularVelocity = new Vector3( Convert.ToSingle(primRow["OmegaX"]), Convert.ToSingle(primRow["OmegaY"]), Convert.ToSingle(primRow["OmegaZ"])); @@ -1429,9 +1429,9 @@ VALUES parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); - parameters.Add(_Database.CreateParameter("OmegaX", prim.RotationalVelocity.X)); - parameters.Add(_Database.CreateParameter("OmegaY", prim.RotationalVelocity.Y)); - parameters.Add(_Database.CreateParameter("OmegaZ", prim.RotationalVelocity.Z)); + parameters.Add(_Database.CreateParameter("OmegaX", prim.AngularVelocity.X)); + parameters.Add(_Database.CreateParameter("OmegaY", prim.AngularVelocity.Y)); + parameters.Add(_Database.CreateParameter("OmegaZ", prim.AngularVelocity.Z)); parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a807948..c49153f 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -908,7 +908,7 @@ namespace OpenSim.Data.MySQL if (!(row["ParticleSystem"] is DBNull)) prim.ParticleSystem = (byte[])row["ParticleSystem"]; - prim.RotationalVelocity = new Vector3( + prim.AngularVelocity = new Vector3( (float)(double)row["OmegaX"], (float)(double)row["OmegaY"], (float)(double)row["OmegaZ"] @@ -1240,9 +1240,9 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation); cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem); - cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X); - cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y); - cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z); + cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X); + cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y); + cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z); cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X); cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y); diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 08af7c3..b68de1a 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -1213,7 +1213,7 @@ namespace OpenSim.Data.SQLite if (!row.IsNull("ParticleSystem")) prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString()); - prim.RotationalVelocity = new Vector3( + prim.AngularVelocity = new Vector3( Convert.ToSingle(row["OmegaX"]), Convert.ToSingle(row["OmegaY"]), Convert.ToSingle(row["OmegaZ"]) @@ -1530,9 +1530,9 @@ namespace OpenSim.Data.SQLite row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation); row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem); - row["OmegaX"] = prim.RotationalVelocity.X; - row["OmegaY"] = prim.RotationalVelocity.Y; - row["OmegaZ"] = prim.RotationalVelocity.Z; + row["OmegaX"] = prim.AngularVelocity.X; + row["OmegaY"] = prim.AngularVelocity.Y; + row["OmegaZ"] = prim.AngularVelocity.Z; row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X; row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1e7803f..a6ee40a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4635,7 +4635,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy. jointProxyObject.Velocity = trackedBody.Velocity; - jointProxyObject.RotationalVelocity = trackedBody.RotationalVelocity; + jointProxyObject.AngularVelocity = trackedBody.AngularVelocity; switch (joint.Type) { case PhysicsJointType.Ball: diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3d41666..474ffdd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -683,12 +683,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public Vector3 RotationalVelocity - { - get { return AngularVelocity; } - set { AngularVelocity = value; } - } - /// public Vector3 AngularVelocity { @@ -1552,9 +1546,9 @@ if (m_shape != null) { m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? // make sure client isn't interpolating the joint proxy object - Velocity = new Vector3(0, 0, 0); - RotationalVelocity = new Vector3(0, 0, 0); - Acceleration = new Vector3(0, 0, 0); + Velocity = Vector3.Zero; + AngularVelocity = Vector3.Zero; + Acceleration = Vector3.Zero; } } } @@ -2384,7 +2378,7 @@ if (m_shape != null) { byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape, - lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, + lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID, m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); } @@ -2405,7 +2399,7 @@ if (m_shape != null) { if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Acceleration.Equals(m_lastAcceleration) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || - !RotationalVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || + !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { @@ -2425,7 +2419,7 @@ if (m_shape != null) { m_lastRotation = RotationOffset; m_lastVelocity = Velocity; m_lastAcceleration = Acceleration; - m_lastAngularVelocity = RotationalVelocity; + m_lastAngularVelocity = AngularVelocity; m_lastTerseSent = Environment.TickCount; } } @@ -3787,7 +3781,7 @@ if (m_shape != null) { remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, lPos, RotationOffset, Velocity, Acceleration, - RotationalVelocity, state, FromItemID, + AngularVelocity, state, FromItemID, OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); } diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs index fbe43d6..2c5093f 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/PointMetaEntity.cs @@ -81,12 +81,11 @@ namespace OpenSim.Region.OptionalModules.ContentManagement y.Scale = new Vector3(0.01f,0.01f,0.01f); y.LastOwnerID = UUID.Zero; y.GroupPosition = groupPos; - y.OffsetPosition = new Vector3(0, 0, 0); - y.RotationOffset = new Quaternion(0,0,0,0); - y.Velocity = new Vector3(0, 0, 0); - y.RotationalVelocity = new Vector3(0, 0, 0); - y.AngularVelocity = new Vector3(0, 0, 0); - y.Acceleration = new Vector3(0, 0, 0); + y.OffsetPosition = Vector3.Zero; + y.RotationOffset = Quaternion.Identity; + y.Velocity = Vector3.Zero; + y.AngularVelocity = Vector3.Zero; + y.Acceleration = Vector3.Zero; y.Flags = 0; y.TrimPermissions(); diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs index e185351..a6afa5a 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/SceneObjectGroupDiff.cs @@ -172,8 +172,6 @@ namespace OpenSim.Region.OptionalModules.ContentManagement result |= Diff.ANGULARVELOCITY; if (!AreVectorsEquivalent(first.OffsetPosition, second.OffsetPosition)) result |= Diff.OFFSETPOSITION; - if (!AreVectorsEquivalent(first.RotationalVelocity, second.RotationalVelocity)) - result |= Diff.ROTATIONALVELOCITY; if (!AreVectorsEquivalent(first.Scale, second.Scale)) result |= Diff.SCALE; if (!AreVectorsEquivalent(first.Velocity, second.Velocity)) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 64f7c8d..0ea62d7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2163,7 +2163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetOmega() { m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z); + return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); } public LSL_Float llGetTimeOfDay() @@ -3159,7 +3159,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) { m_host.AddScriptLPS(1); - m_host.RotationalVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); m_host.ScheduleTerseUpdate(); m_host.SendTerseUpdateToAllClients(); -- cgit v1.1 From 0e8b5c7ffa2efa369d4fee9957a36b643cbd7b6b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:40:57 -0800 Subject: Fixing race conditions in the SceneObjectPart properties --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 109 ++++++++++----------- 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 474ffdd..2bc7f66 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -507,20 +507,17 @@ namespace OpenSim.Region.Framework.Scenes get { // If this is a linkset, we don't want the physics engine mucking up our group position here. - if (PhysActor != null && _parentID == 0) + PhysicsActor actor = PhysActor; + if (actor != null && _parentID == 0) { - m_groupPosition.X = PhysActor.Position.X; - m_groupPosition.Y = PhysActor.Position.Y; - m_groupPosition.Z = PhysActor.Position.Z; + m_groupPosition = actor.Position; } if (IsAttachment) { ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); if (sp != null) - { return sp.AbsolutePosition; - } } return m_groupPosition; @@ -531,26 +528,25 @@ namespace OpenSim.Region.Framework.Scenes m_groupPosition = value; - if (PhysActor != null) + PhysicsActor actor = PhysActor; + if (actor != null) { try { // Root prim actually goes at Position if (_parentID == 0) { - PhysActor.Position = value; + actor.Position = value; } else { // To move the child prim in respect to the group position and rotation we have to calculate - Vector3 resultingposition = GetWorldPosition(); - PhysActor.Position = resultingposition; - Quaternion resultingrot = GetWorldRotation(); - PhysActor.Orientation = resultingrot; + actor.Position = GetWorldPosition(); + actor.Orientation = GetWorldRotation(); } // Tell the physics engines that this prim changed. - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } catch (Exception e) { @@ -583,15 +579,14 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup != null && !ParentGroup.IsDeleted) { - if (_parentID != 0 && PhysActor != null) + PhysicsActor actor = PhysActor; + if (_parentID != 0 && actor != null) { - Vector3 resultingposition = GetWorldPosition(); - PhysActor.Position = resultingposition; - Quaternion resultingrot = GetWorldRotation(); - PhysActor.Orientation = resultingrot; + actor.Position = GetWorldPosition(); + actor.Orientation = GetWorldRotation(); // Tell the physics engines that this prim changed. - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } } } @@ -602,12 +597,13 @@ namespace OpenSim.Region.Framework.Scenes get { // We don't want the physics engine mucking up the rotations in a linkset - if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null)) + PhysicsActor actor = PhysActor; + if (_parentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) { - if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0 - || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0) + if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f + || actor.Orientation.Z != 0f || actor.Orientation.W != 0f) { - m_rotationOffset = PhysActor.Orientation; + m_rotationOffset = actor.Orientation; } } @@ -619,24 +615,25 @@ namespace OpenSim.Region.Framework.Scenes StoreUndoState(); m_rotationOffset = value; - if (PhysActor != null) + PhysicsActor actor = PhysActor; + if (actor != null) { try { // Root prim gets value directly if (_parentID == 0) { - PhysActor.Orientation = value; - //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); + actor.Orientation = value; + //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString()); } else { // Child prim we have to calculate it's world rotationwel Quaternion resultingrotation = GetWorldRotation(); - PhysActor.Orientation = resultingrotation; - //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); + actor.Orientation = resultingrotation; + //m_log.Info("[PART]: RO2:" + actor.Orientation.ToString()); } - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); //} } catch (Exception ex) @@ -653,16 +650,12 @@ namespace OpenSim.Region.Framework.Scenes { get { - //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 - //|| PhysActor.Velocity.Z != 0) - //{ - if (PhysActor != null) + PhysicsActor actor = PhysActor; + if (actor != null) { - if (PhysActor.IsPhysical) + if (actor.IsPhysical) { - m_velocity.X = PhysActor.Velocity.X; - m_velocity.Y = PhysActor.Velocity.Y; - m_velocity.Z = PhysActor.Velocity.Z; + m_velocity = actor.Velocity; } } @@ -672,12 +665,14 @@ namespace OpenSim.Region.Framework.Scenes set { m_velocity = value; - if (PhysActor != null) + + PhysicsActor actor = PhysActor; + if (actor != null) { - if (PhysActor.IsPhysical) + if (actor.IsPhysical) { - PhysActor.Velocity = value; - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); + actor.Velocity = value; + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); } } } @@ -688,9 +683,10 @@ namespace OpenSim.Region.Framework.Scenes { get { - if ((PhysActor != null) && PhysActor.IsPhysical) + PhysicsActor actor = PhysActor; + if ((actor != null) && actor.IsPhysical) { - m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); + m_angularVelocity = actor.RotationalVelocity; } return m_angularVelocity; } @@ -710,9 +706,10 @@ namespace OpenSim.Region.Framework.Scenes set { m_description = value; - if (PhysActor != null) + PhysicsActor actor = PhysActor; + if (actor != null) { - PhysActor.SOPDescription = value; + actor.SOPDescription = value; } } } @@ -803,21 +800,23 @@ namespace OpenSim.Region.Framework.Scenes set { StoreUndoState(); -if (m_shape != null) { - m_shape.Scale = value; - - if (PhysActor != null && m_parentGroup != null) + if (m_shape != null) { - if (m_parentGroup.Scene != null) + m_shape.Scale = value; + + PhysicsActor actor = PhysActor; + if (actor != null && m_parentGroup != null) { - if (m_parentGroup.Scene.PhysicsScene != null) + if (m_parentGroup.Scene != null) { - PhysActor.Size = m_shape.Scale; - m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); + if (m_parentGroup.Scene.PhysicsScene != null) + { + actor.Size = m_shape.Scale; + m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); + } } } } -} TriggerScriptChangedEvent(Changed.SCALE); } } @@ -1051,8 +1050,6 @@ if (m_shape != null) { #endregion Public Properties with only Get - - #region Private Methods private uint ApplyMask(uint val, bool set, uint mask) -- cgit v1.1 From de71d23e145de5df080f5a9abfebb367b81b2527 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 11:54:39 -0800 Subject: Removing Console.WriteLine()s that were brought in with the revert --- OpenSim/Data/MySQL/MySQLFramework.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs index fd428ae..fca0ca5 100644 --- a/OpenSim/Data/MySQL/MySQLFramework.cs +++ b/OpenSim/Data/MySQL/MySQLFramework.cs @@ -69,7 +69,6 @@ namespace OpenSim.Data.MySQL } catch (MySqlException e) { -Console.WriteLine(e.ToString()); if (errorSeen) throw; @@ -93,7 +92,6 @@ Console.WriteLine(e.ToString()); } catch (Exception e) { -Console.WriteLine(e.ToString()); return 0; } } -- cgit v1.1 From 19279450537ffffc71bf67f1efb4b50b4c7d5065 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 2 Nov 2009 15:09:07 -0800 Subject: Another race condition fix in SceneObjectGroup --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0b752c9..c65a665 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2946,12 +2946,13 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdateGroupRotationR(Quaternion rot) { - m_rootPart.UpdateRotation(rot); - if (m_rootPart.PhysActor != null) + + PhysicsActor actor = m_rootPart.PhysActor; + if (actor != null) { - m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; - m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + actor.Orientation = m_rootPart.RotationOffset; + m_scene.PhysicsScene.AddPhysicsActorTaint(actor); } HasGroupChanged = true; @@ -2966,11 +2967,14 @@ namespace OpenSim.Region.Framework.Scenes public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) { m_rootPart.UpdateRotation(rot); - if (m_rootPart.PhysActor != null) + + PhysicsActor actor = m_rootPart.PhysActor; + if (actor != null) { - m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; - m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); + actor.Orientation = m_rootPart.RotationOffset; + m_scene.PhysicsScene.AddPhysicsActorTaint(actor); } + AbsolutePosition = pos; HasGroupChanged = true; -- cgit v1.1 From 82554e9a89e4ca39c1522d539862f9fd6a2f2a7e Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 2 Nov 2009 22:24:58 -0800 Subject: Delete depricated extrusion methods and redirect to universal extrude method. Sync with PrimMesher.cs r47 on forge. --- OpenSim/Region/Physics/Meshing/PrimMesher.cs | 855 +-------------------------- 1 file changed, 16 insertions(+), 839 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 47ce615..c7c9160 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs @@ -67,11 +67,6 @@ namespace PrimMesher Normalize(); } - public Quat Identity() - { - return new Quat(0.0f, 0.0f, 0.0f, 1.0f); - } - public float Length() { return (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W); @@ -660,7 +655,7 @@ namespace PrimMesher this.faceNumbers = new List(); Coord center = new Coord(0.0f, 0.0f, 0.0f); - bool hasCenter = false; + //bool hasCenter = false; List hollowCoords = new List(); List hollowNormals = new List(); @@ -727,7 +722,7 @@ namespace PrimMesher else if (!simpleFace) { this.coords.Add(center); - hasCenter = true; + //hasCenter = true; if (this.calcVertexNormals) this.vertexNormals.Add(new Coord(0.0f, 0.0f, 1.0f)); this.us.Add(0.0f); @@ -1541,7 +1536,7 @@ namespace PrimMesher } /// - /// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism. + /// Extrudes a profile along a path. /// public void Extrude(PathType pathType) { @@ -1557,7 +1552,6 @@ namespace PrimMesher if (this.calcVertexNormals) this.normals = new List(); - //int step = 0; int steps = 1; float length = this.pathCutEnd - this.pathCutBegin; @@ -1579,20 +1573,6 @@ namespace PrimMesher if (twistTotalAbs > 0.01f) steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number - //float start = -0.5f; - //float stepSize = length / (float)steps; - //float percentOfPathMultiplier = stepSize; - //float xProfileScale = 1.0f; - //float yProfileScale = 1.0f; - //float xOffset = 0.0f; - //float yOffset = 0.0f; - //float zOffset = start; - //float xOffsetStepIncrement = this.topShearX / steps; - //float yOffsetStepIncrement = this.topShearY / steps; - - //float percentOfPath = this.pathCutBegin; - //zOffset += percentOfPath; - float hollow = this.hollow; // sanity checks @@ -1662,7 +1642,6 @@ namespace PrimMesher cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; } - if (initialProfileRot != 0.0f) { profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); @@ -1693,24 +1672,6 @@ namespace PrimMesher path.stepsPerRevolution = stepsPerRevolution; path.Create(pathType, steps); - /* - public int twistBegin = 0; - public int twistEnd = 0; - public float topShearX = 0.0f; - public float topShearY = 0.0f; - public float pathCutBegin = 0.0f; - public float pathCutEnd = 1.0f; - public float dimpleBegin = 0.0f; - public float dimpleEnd = 1.0f; - public float skew = 0.0f; - public float holeSizeX = 1.0f; // called pathScaleX in pbs - public float holeSizeY = 0.25f; - public float taperX = 0.0f; - public float taperY = 0.0f; - public float radius = 0.0f; - public float revolutions = 1.0f; - public int stepsPerRevolution = 24; - */ bool needEndFaces = false; if (pathType == PathType.Circular) @@ -1796,7 +1757,6 @@ namespace PrimMesher int numVerts = newLayer.coords.Count; Face newFace = new Face(); - //if (step > 0) if (nodeIndex > 0) { int startVert = coordsLen + 1; @@ -1812,7 +1772,6 @@ namespace PrimMesher iNext = startVert; int whichVert = i - startVert; - //int whichVert2 = i - lastCoordsLen; newFace.v1 = i; newFace.v2 = i - numVerts; @@ -1982,808 +1941,26 @@ namespace PrimMesher /// + /// DEPRICATED - use Extrude(PathType.Linear) instead /// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism. /// + /// public void ExtrudeLinear() { - this.coords = new List(); - this.faces = new List(); - - if (this.viewerMode) - { - this.viewerFaces = new List(); - this.calcVertexNormals = true; - } - - if (this.calcVertexNormals) - this.normals = new List(); - - int step = 0; - int steps = 1; - - float length = this.pathCutEnd - this.pathCutBegin; - normalsProcessed = false; - - if (this.viewerMode && this.sides == 3) - { - // prisms don't taper well so add some vertical resolution - // other prims may benefit from this but just do prisms for now - if (Math.Abs(this.taperX) > 0.01 || Math.Abs(this.taperY) > 0.01) - steps = (int)(steps * 4.5 * length); - } - - - float twistBegin = this.twistBegin / 360.0f * twoPi; - float twistEnd = this.twistEnd / 360.0f * twoPi; - float twistTotal = twistEnd - twistBegin; - float twistTotalAbs = Math.Abs(twistTotal); - if (twistTotalAbs > 0.01f) - steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number - - float start = -0.5f; - float stepSize = length / (float)steps; - float percentOfPathMultiplier = stepSize; - float xProfileScale = 1.0f; - float yProfileScale = 1.0f; - float xOffset = 0.0f; - float yOffset = 0.0f; - float zOffset = start; - float xOffsetStepIncrement = this.topShearX / steps; - float yOffsetStepIncrement = this.topShearY / steps; - - float percentOfPath = this.pathCutBegin; - zOffset += percentOfPath; - - float hollow = this.hollow; - - // sanity checks - float initialProfileRot = 0.0f; - if (this.sides == 3) - { - if (this.hollowSides == 4) - { - if (hollow > 0.7f) - hollow = 0.7f; - hollow *= 0.707f; - } - else hollow *= 0.5f; - } - else if (this.sides == 4) - { - initialProfileRot = 1.25f * (float)Math.PI; - if (this.hollowSides != 4) - hollow *= 0.707f; - } - else if (this.sides == 24 && this.hollowSides == 4) - hollow *= 1.414f; - - Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals); - this.errorMessage = profile.errorMessage; - - this.numPrimFaces = profile.numPrimFaces; - - int cut1Vert = -1; - int cut2Vert = -1; - if (hasProfileCut) - { - cut1Vert = hasHollow ? profile.coords.Count - 1 : 0; - cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; - } - - if (initialProfileRot != 0.0f) - { - profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); - if (viewerMode) - profile.MakeFaceUVs(); - } - - Coord lastCutNormal1 = new Coord(); - Coord lastCutNormal2 = new Coord(); - float lastV = 1.0f; - - bool done = false; - while (!done) - { - Profile newLayer = profile.Copy(); - - if (this.taperX == 0.0f) - xProfileScale = 1.0f; - else if (this.taperX > 0.0f) - xProfileScale = 1.0f - percentOfPath * this.taperX; - else xProfileScale = 1.0f + (1.0f - percentOfPath) * this.taperX; - - if (this.taperY == 0.0f) - yProfileScale = 1.0f; - else if (this.taperY > 0.0f) - yProfileScale = 1.0f - percentOfPath * this.taperY; - else yProfileScale = 1.0f + (1.0f - percentOfPath) * this.taperY; - - if (xProfileScale != 1.0f || yProfileScale != 1.0f) - newLayer.Scale(xProfileScale, yProfileScale); - - float twist = twistBegin + twistTotal * percentOfPath; - if (twist != 0.0f) - newLayer.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), twist)); - - newLayer.AddPos(xOffset, yOffset, zOffset); - - if (step == 0) - { - newLayer.FlipNormals(); - - // add the top faces to the viewerFaces list here - if (this.viewerMode) - { - Coord faceNormal = newLayer.faceNormal; - ViewerFace newViewerFace = new ViewerFace(profile.bottomFaceNumber); - int numFaces = newLayer.faces.Count; - List faces = newLayer.faces; - - for (int i = 0; i < numFaces; i++) - { - Face face = faces[i]; - newViewerFace.v1 = newLayer.coords[face.v1]; - newViewerFace.v2 = newLayer.coords[face.v2]; - newViewerFace.v3 = newLayer.coords[face.v3]; - - newViewerFace.coordIndex1 = face.v1; - newViewerFace.coordIndex2 = face.v2; - newViewerFace.coordIndex3 = face.v3; - - newViewerFace.n1 = faceNormal; - newViewerFace.n2 = faceNormal; - newViewerFace.n3 = faceNormal; - - newViewerFace.uv1 = newLayer.faceUVs[face.v1]; - newViewerFace.uv2 = newLayer.faceUVs[face.v2]; - newViewerFace.uv3 = newLayer.faceUVs[face.v3]; - - this.viewerFaces.Add(newViewerFace); - } - } - } - - // append this layer - - int coordsLen = this.coords.Count; - int lastCoordsLen = coordsLen; - newLayer.AddValue2FaceVertexIndices(coordsLen); - - this.coords.AddRange(newLayer.coords); - - if (this.calcVertexNormals) - { - newLayer.AddValue2FaceNormalIndices(this.normals.Count); - this.normals.AddRange(newLayer.vertexNormals); - } - - if (percentOfPath < this.pathCutBegin + 0.01f || percentOfPath > this.pathCutEnd - 0.01f) - this.faces.AddRange(newLayer.faces); - - // fill faces between layers - - int numVerts = newLayer.coords.Count; - Face newFace = new Face(); - - if (step > 0) - { - int startVert = coordsLen + 1; - int endVert = this.coords.Count; - - if (sides < 5 || this.hasProfileCut || hollow > 0.0f) - startVert--; - - for (int i = startVert; i < endVert; i++) - { - int iNext = i + 1; - if (i == endVert - 1) - iNext = startVert; - - int whichVert = i - startVert; - //int whichVert2 = i - lastCoordsLen; - - newFace.v1 = i; - newFace.v2 = i - numVerts; - newFace.v3 = iNext - numVerts; - this.faces.Add(newFace); - - newFace.v2 = iNext - numVerts; - newFace.v3 = iNext; - this.faces.Add(newFace); - - if (this.viewerMode) - { - // add the side faces to the list of viewerFaces here - //int primFaceNum = 1; - //if (whichVert >= sides) - // primFaceNum = 2; - int primFaceNum = profile.faceNumbers[whichVert]; - - ViewerFace newViewerFace1 = new ViewerFace(primFaceNum); - ViewerFace newViewerFace2 = new ViewerFace(primFaceNum); - - float u1 = newLayer.us[whichVert]; - float u2 = 1.0f; - if (whichVert < newLayer.us.Count - 1) - u2 = newLayer.us[whichVert + 1]; - - if (whichVert == cut1Vert || whichVert == cut2Vert) - { - u1 = 0.0f; - u2 = 1.0f; - } - else if (sides < 5) - { // boxes and prisms have one texture face per side of the prim, so the U values have to be scaled - // to reflect the entire texture width - u1 *= sides; - u2 *= sides; - u2 -= (int)u1; - u1 -= (int)u1; - if (u2 < 0.1f) - u2 = 1.0f; - - //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; - } - - newViewerFace1.uv1.U = u1; - newViewerFace1.uv2.U = u1; - newViewerFace1.uv3.U = u2; - - newViewerFace1.uv1.V = 1.0f - percentOfPath; - newViewerFace1.uv2.V = lastV; - newViewerFace1.uv3.V = lastV; - - newViewerFace2.uv1.U = u1; - newViewerFace2.uv2.U = u2; - newViewerFace2.uv3.U = u2; - - newViewerFace2.uv1.V = 1.0f - percentOfPath; - newViewerFace2.uv2.V = lastV; - newViewerFace2.uv3.V = 1.0f - percentOfPath; - - newViewerFace1.v1 = this.coords[i]; - newViewerFace1.v2 = this.coords[i - numVerts]; - newViewerFace1.v3 = this.coords[iNext - numVerts]; - - newViewerFace2.v1 = this.coords[i]; - newViewerFace2.v2 = this.coords[iNext - numVerts]; - newViewerFace2.v3 = this.coords[iNext]; - - newViewerFace1.coordIndex1 = i; - newViewerFace1.coordIndex2 = i - numVerts; - newViewerFace1.coordIndex3 = iNext - numVerts; - - newViewerFace2.coordIndex1 = i; - newViewerFace2.coordIndex2 = iNext - numVerts; - newViewerFace2.coordIndex3 = iNext; - - // profile cut faces - if (whichVert == cut1Vert) - { - newViewerFace1.n1 = newLayer.cutNormal1; - newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal1; + this.Extrude(PathType.Linear); + } - newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal1; - newViewerFace2.n2 = lastCutNormal1; - } - else if (whichVert == cut2Vert) - { - newViewerFace1.n1 = newLayer.cutNormal2; - newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal2; - newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal2; - newViewerFace2.n2 = lastCutNormal2; - } + /// + /// DEPRICATED - use Extrude(PathType.Circular) instead + /// Extrude a profile into a circular path prim mesh. Used for prim types torus, tube, and ring. + /// + /// + public void ExtrudeCircular() + { + this.Extrude(PathType.Circular); + } - else // outer and hollow faces - { - if ((sides < 5 && whichVert < newLayer.numOuterVerts) || (hollowSides < 5 && whichVert >= newLayer.numOuterVerts)) - { - newViewerFace1.CalcSurfaceNormal(); - newViewerFace2.CalcSurfaceNormal(); - } - else - { - newViewerFace1.n1 = this.normals[i]; - newViewerFace1.n2 = this.normals[i - numVerts]; - newViewerFace1.n3 = this.normals[iNext - numVerts]; - - newViewerFace2.n1 = this.normals[i]; - newViewerFace2.n2 = this.normals[iNext - numVerts]; - newViewerFace2.n3 = this.normals[iNext]; - } - } - - //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = newLayer.faceNumbers[whichVert]; - - this.viewerFaces.Add(newViewerFace1); - this.viewerFaces.Add(newViewerFace2); - - } - } - } - - lastCutNormal1 = newLayer.cutNormal1; - lastCutNormal2 = newLayer.cutNormal2; - lastV = 1.0f - percentOfPath; - - // calc the step for the next iteration of the loop - - if (step < steps) - { - step += 1; - percentOfPath += percentOfPathMultiplier; - xOffset += xOffsetStepIncrement; - yOffset += yOffsetStepIncrement; - zOffset += stepSize; - if (percentOfPath > this.pathCutEnd) - done = true; - } - else done = true; - - if (done && viewerMode) - { - // add the top faces to the viewerFaces list here - Coord faceNormal = newLayer.faceNormal; - ViewerFace newViewerFace = new ViewerFace(); - newViewerFace.primFaceNumber = 0; - int numFaces = newLayer.faces.Count; - List faces = newLayer.faces; - - for (int i = 0; i < numFaces; i++) - { - Face face = faces[i]; - newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; - newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen]; - newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen]; - - newViewerFace.coordIndex1 = face.v1 - coordsLen; - newViewerFace.coordIndex2 = face.v2 - coordsLen; - newViewerFace.coordIndex3 = face.v3 - coordsLen; - - newViewerFace.n1 = faceNormal; - newViewerFace.n2 = faceNormal; - newViewerFace.n3 = faceNormal; - - newViewerFace.uv1 = newLayer.faceUVs[face.v1 - coordsLen]; - newViewerFace.uv2 = newLayer.faceUVs[face.v2 - coordsLen]; - newViewerFace.uv3 = newLayer.faceUVs[face.v3 - coordsLen]; - - this.viewerFaces.Add(newViewerFace); - } - } - } - } - - - /// - /// Extrude a profile into a circular path prim mesh. Used for prim types torus, tube, and ring. - /// - public void ExtrudeCircular() - { - this.coords = new List(); - this.faces = new List(); - - if (this.viewerMode) - { - this.viewerFaces = new List(); - this.calcVertexNormals = true; - } - - if (this.calcVertexNormals) - this.normals = new List(); - - int step = 0; - int steps = 24; - - normalsProcessed = false; - - float twistBegin = this.twistBegin / 360.0f * twoPi; - float twistEnd = this.twistEnd / 360.0f * twoPi; - float twistTotal = twistEnd - twistBegin; - - // if the profile has a lot of twist, add more layers otherwise the layers may overlap - // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesn't - // accurately match the viewer - float twistTotalAbs = Math.Abs(twistTotal); - if (twistTotalAbs > 0.01f) - { - if (twistTotalAbs > Math.PI * 1.5f) - steps *= 2; - if (twistTotalAbs > Math.PI * 3.0f) - steps *= 2; - } - - float yPathScale = this.holeSizeY * 0.5f; - float pathLength = this.pathCutEnd - this.pathCutBegin; - float totalSkew = this.skew * 2.0f * pathLength; - float skewStart = this.pathCutBegin * 2.0f * this.skew - this.skew; - float xOffsetTopShearXFactor = this.topShearX * (0.25f + 0.5f * (0.5f - this.holeSizeY)); - float yShearCompensation = 1.0f + Math.Abs(this.topShearY) * 0.25f; - - // It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end - // angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used - // to calculate the sine for generating the path radius appears to approximate it's effects there - // too, but there are some subtle differences in the radius which are noticeable as the prim size - // increases and it may affect megaprims quite a bit. The effect of the Y top shear parameter on - // the meshes generated with this technique appear nearly identical in shape to the same prims when - // displayed by the viewer. - - float startAngle = (twoPi * this.pathCutBegin * this.revolutions) - this.topShearY * 0.9f; - float endAngle = (twoPi * this.pathCutEnd * this.revolutions) - this.topShearY * 0.9f; - float stepSize = twoPi / this.stepsPerRevolution; - - step = (int)(startAngle / stepSize); - int firstStep = step; - float angle = startAngle; - float hollow = this.hollow; - - // sanity checks - float initialProfileRot = 0.0f; - if (this.sides == 3) - { - initialProfileRot = (float)Math.PI; - if (this.hollowSides == 4) - { - if (hollow > 0.7f) - hollow = 0.7f; - hollow *= 0.707f; - } - else hollow *= 0.5f; - } - else if (this.sides == 4) - { - initialProfileRot = 0.25f * (float)Math.PI; - if (this.hollowSides != 4) - hollow *= 0.707f; - } - else if (this.sides > 4) - { - initialProfileRot = (float)Math.PI; - if (this.hollowSides == 4) - { - if (hollow > 0.7f) - hollow = 0.7f; - hollow /= 0.7f; - } - } - - bool needEndFaces = false; - if (this.pathCutBegin != 0.0f || this.pathCutEnd != 1.0f) - needEndFaces = true; - else if (this.taperX != 0.0f || this.taperY != 0.0f) - needEndFaces = true; - else if (this.skew != 0.0f) - needEndFaces = true; - else if (twistTotal != 0.0f) - needEndFaces = true; - else if (this.radius != 0.0f) - needEndFaces = true; - - Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, needEndFaces, calcVertexNormals); - this.errorMessage = profile.errorMessage; - - this.numPrimFaces = profile.numPrimFaces; - - int cut1Vert = -1; - int cut2Vert = -1; - if (hasProfileCut) - { - cut1Vert = hasHollow ? profile.coords.Count - 1 : 0; - cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; - } - - if (initialProfileRot != 0.0f) - { - profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); - if (viewerMode) - profile.MakeFaceUVs(); - } - - Coord lastCutNormal1 = new Coord(); - Coord lastCutNormal2 = new Coord(); - float lastV = 1.0f; - - bool done = false; - while (!done) // loop through the length of the path and add the layers - { - bool isEndLayer = false; - if (angle <= startAngle + .01f || angle >= endAngle - .01f) - isEndLayer = true; - - Profile newLayer = profile.Copy(); - - float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; - float yProfileScale = this.holeSizeY; - - float percentOfPath = angle / (twoPi * this.revolutions); - float percentOfAngles = (angle - startAngle) / (endAngle - startAngle); - - if (this.taperX > 0.01f) - xProfileScale *= 1.0f - percentOfPath * this.taperX; - else if (this.taperX < -0.01f) - xProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperX; - - if (this.taperY > 0.01f) - yProfileScale *= 1.0f - percentOfPath * this.taperY; - else if (this.taperY < -0.01f) - yProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperY; - - if (xProfileScale != 1.0f || yProfileScale != 1.0f) - newLayer.Scale(xProfileScale, yProfileScale); - - float radiusScale = 1.0f; - if (this.radius > 0.001f) - radiusScale = 1.0f - this.radius * percentOfPath; - else if (this.radius < 0.001f) - radiusScale = 1.0f + this.radius * (1.0f - percentOfPath); - - float twist = twistBegin + twistTotal * percentOfPath; - - float xOffset = 0.5f * (skewStart + totalSkew * percentOfAngles); - xOffset += (float)Math.Sin(angle) * xOffsetTopShearXFactor; - - float yOffset = yShearCompensation * (float)Math.Cos(angle) * (0.5f - yPathScale) * radiusScale; - - float zOffset = (float)Math.Sin(angle + this.topShearY) * (0.5f - yPathScale) * radiusScale; - - // next apply twist rotation to the profile layer - if (twistTotal != 0.0f || twistBegin != 0.0f) - newLayer.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), twist)); - - // now orient the rotation of the profile layer relative to it's position on the path - // adding taperY to the angle used to generate the quat appears to approximate the viewer - newLayer.AddRot(new Quat(new Coord(1.0f, 0.0f, 0.0f), angle + this.topShearY)); - newLayer.AddPos(xOffset, yOffset, zOffset); - - if (isEndLayer && angle <= startAngle + .01f) - { - newLayer.FlipNormals(); - - // add the top faces to the viewerFaces list here - if (this.viewerMode && needEndFaces) - { - Coord faceNormal = newLayer.faceNormal; - ViewerFace newViewerFace = new ViewerFace(); - newViewerFace.primFaceNumber = 0; - foreach (Face face in newLayer.faces) - { - newViewerFace.v1 = newLayer.coords[face.v1]; - newViewerFace.v2 = newLayer.coords[face.v2]; - newViewerFace.v3 = newLayer.coords[face.v3]; - - newViewerFace.coordIndex1 = face.v1; - newViewerFace.coordIndex2 = face.v2; - newViewerFace.coordIndex3 = face.v3; - - newViewerFace.n1 = faceNormal; - newViewerFace.n2 = faceNormal; - newViewerFace.n3 = faceNormal; - - newViewerFace.uv1 = newLayer.faceUVs[face.v1]; - newViewerFace.uv2 = newLayer.faceUVs[face.v2]; - newViewerFace.uv3 = newLayer.faceUVs[face.v3]; - - this.viewerFaces.Add(newViewerFace); - } - } - } - - // append the layer and fill in the sides - - int coordsLen = this.coords.Count; - newLayer.AddValue2FaceVertexIndices(coordsLen); - - this.coords.AddRange(newLayer.coords); - - if (this.calcVertexNormals) - { - newLayer.AddValue2FaceNormalIndices(this.normals.Count); - this.normals.AddRange(newLayer.vertexNormals); - } - - if (isEndLayer) - this.faces.AddRange(newLayer.faces); - - // fill faces between layers - - int numVerts = newLayer.coords.Count; - Face newFace = new Face(); - if (step > firstStep) - { - int startVert = coordsLen + 1; - int endVert = this.coords.Count; - - if (sides < 5 || this.hasProfileCut || hollow > 0.0f) - startVert--; - - for (int i = startVert; i < endVert; i++) - { - int iNext = i + 1; - if (i == endVert - 1) - iNext = startVert; - - int whichVert = i - startVert; - - newFace.v1 = i; - newFace.v2 = i - numVerts; - newFace.v3 = iNext - numVerts; - this.faces.Add(newFace); - - newFace.v2 = iNext - numVerts; - newFace.v3 = iNext; - this.faces.Add(newFace); - - if (this.viewerMode) - { - int primFaceNumber = profile.faceNumbers[whichVert]; - if (!needEndFaces) - primFaceNumber -= 1; - - // add the side faces to the list of viewerFaces here - ViewerFace newViewerFace1 = new ViewerFace(primFaceNumber); - ViewerFace newViewerFace2 = new ViewerFace(primFaceNumber); - float u1 = newLayer.us[whichVert]; - float u2 = 1.0f; - if (whichVert < newLayer.us.Count - 1) - u2 = newLayer.us[whichVert + 1]; - - if (whichVert == cut1Vert || whichVert == cut2Vert) - { - u1 = 0.0f; - u2 = 1.0f; - } - else if (sides < 5) - { // boxes and prisms have one texture face per side of the prim, so the U values have to be scaled - // to reflect the entire texture width - u1 *= sides; - u2 *= sides; - u2 -= (int)u1; - u1 -= (int)u1; - if (u2 < 0.1f) - u2 = 1.0f; - - //newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; - } - - newViewerFace1.uv1.U = u1; - newViewerFace1.uv2.U = u1; - newViewerFace1.uv3.U = u2; - - newViewerFace1.uv1.V = 1.0f - percentOfPath; - newViewerFace1.uv2.V = lastV; - newViewerFace1.uv3.V = lastV; - - newViewerFace2.uv1.U = u1; - newViewerFace2.uv2.U = u2; - newViewerFace2.uv3.U = u2; - - newViewerFace2.uv1.V = 1.0f - percentOfPath; - newViewerFace2.uv2.V = lastV; - newViewerFace2.uv3.V = 1.0f - percentOfPath; - - newViewerFace1.v1 = this.coords[i]; - newViewerFace1.v2 = this.coords[i - numVerts]; - newViewerFace1.v3 = this.coords[iNext - numVerts]; - - newViewerFace2.v1 = this.coords[i]; - newViewerFace2.v2 = this.coords[iNext - numVerts]; - newViewerFace2.v3 = this.coords[iNext]; - - newViewerFace1.coordIndex1 = i; - newViewerFace1.coordIndex2 = i - numVerts; - newViewerFace1.coordIndex3 = iNext - numVerts; - - newViewerFace2.coordIndex1 = i; - newViewerFace2.coordIndex2 = iNext - numVerts; - newViewerFace2.coordIndex3 = iNext; - - // profile cut faces - if (whichVert == cut1Vert) - { - newViewerFace1.n1 = newLayer.cutNormal1; - newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal1; - - newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal1; - newViewerFace2.n2 = lastCutNormal1; - } - else if (whichVert == cut2Vert) - { - newViewerFace1.n1 = newLayer.cutNormal2; - newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal2; - - newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal2; - newViewerFace2.n2 = lastCutNormal2; - } - else // periphery faces - { - if (sides < 5 && whichVert < newLayer.numOuterVerts) - { - newViewerFace1.n1 = this.normals[i]; - newViewerFace1.n2 = this.normals[i - numVerts]; - newViewerFace1.n3 = this.normals[i - numVerts]; - - newViewerFace2.n1 = this.normals[i]; - newViewerFace2.n2 = this.normals[i - numVerts]; - newViewerFace2.n3 = this.normals[i]; - } - else if (hollowSides < 5 && whichVert >= newLayer.numOuterVerts) - { - newViewerFace1.n1 = this.normals[iNext]; - newViewerFace1.n2 = this.normals[iNext - numVerts]; - newViewerFace1.n3 = this.normals[iNext - numVerts]; - - newViewerFace2.n1 = this.normals[iNext]; - newViewerFace2.n2 = this.normals[iNext - numVerts]; - newViewerFace2.n3 = this.normals[iNext]; - } - else - { - newViewerFace1.n1 = this.normals[i]; - newViewerFace1.n2 = this.normals[i - numVerts]; - newViewerFace1.n3 = this.normals[iNext - numVerts]; - - newViewerFace2.n1 = this.normals[i]; - newViewerFace2.n2 = this.normals[iNext - numVerts]; - newViewerFace2.n3 = this.normals[iNext]; - } - } - - //newViewerFace1.primFaceNumber = newViewerFace2.primFaceNumber = newLayer.faceNumbers[whichVert]; - this.viewerFaces.Add(newViewerFace1); - this.viewerFaces.Add(newViewerFace2); - - } - } - } - - lastCutNormal1 = newLayer.cutNormal1; - lastCutNormal2 = newLayer.cutNormal2; - lastV = 1.0f - percentOfPath; - - // calculate terms for next iteration - // calculate the angle for the next iteration of the loop - - if (angle >= endAngle - 0.01) - done = true; - else - { - step += 1; - angle = stepSize * step; - if (angle > endAngle) - angle = endAngle; - } - - if (done && viewerMode && needEndFaces) - { - // add the bottom faces to the viewerFaces list here - Coord faceNormal = newLayer.faceNormal; - ViewerFace newViewerFace = new ViewerFace(); - //newViewerFace.primFaceNumber = newLayer.bottomFaceNumber + 1; - newViewerFace.primFaceNumber = newLayer.bottomFaceNumber; - foreach (Face face in newLayer.faces) - { - newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; - newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen]; - newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen]; - - newViewerFace.coordIndex1 = face.v1 - coordsLen; - newViewerFace.coordIndex2 = face.v2 - coordsLen; - newViewerFace.coordIndex3 = face.v3 - coordsLen; - - newViewerFace.n1 = faceNormal; - newViewerFace.n2 = faceNormal; - newViewerFace.n3 = faceNormal; - - newViewerFace.uv1 = newLayer.faceUVs[face.v1 - coordsLen]; - newViewerFace.uv2 = newLayer.faceUVs[face.v2 - coordsLen]; - newViewerFace.uv3 = newLayer.faceUVs[face.v3 - coordsLen]; - - this.viewerFaces.Add(newViewerFace); - } - } - } - } private Coord SurfaceNormal(Coord c1, Coord c2, Coord c3) { -- cgit v1.1 From 9e6f01321e16db768e4ad9e51c72679ab679975a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 3 Nov 2009 10:24:02 -0800 Subject: Fixed a couple of NREs in corner cases. --- .../Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 40ac647..9c04755 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -604,6 +604,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); + if (uinfo == null) + return false; + if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) { @@ -737,6 +740,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Is the user going back to the home region or the home grid? protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) { + if (uinfo == null) + return false; + if (uinfo.UserProfile == null) return false; -- cgit v1.1 From 1d737b010cb39d8fcc0794eae9be90634382e51c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Nov 2009 18:52:20 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs | 26 ++++++++++++------------- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 2 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs index 4a802cd..39cdc0f 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs @@ -67,8 +67,8 @@ namespace OpenSim.Region.Physics.OdePlugin // private OdeScene m_parentScene = null; private IntPtr m_body = IntPtr.Zero; - private IntPtr m_jointGroup = IntPtr.Zero; - private IntPtr m_aMotor = IntPtr.Zero; +// private IntPtr m_jointGroup = IntPtr.Zero; +// private IntPtr m_aMotor = IntPtr.Zero; // Vehicle properties @@ -117,7 +117,7 @@ namespace OpenSim.Region.Physics.OdePlugin //Hover and Buoyancy properties private float m_VhoverHeight = 0f; - private float m_VhoverEfficiency = 0f; +// private float m_VhoverEfficiency = 0f; private float m_VhoverTimescale = 0f; private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. @@ -170,11 +170,11 @@ namespace OpenSim.Region.Physics.OdePlugin if (pValue > 1f) pValue = 1f; m_VehicleBuoyancy = pValue; break; - case Vehicle.HOVER_EFFICIENCY: - if (pValue < 0f) pValue = 0f; - if (pValue > 1f) pValue = 1f; - m_VhoverEfficiency = pValue; - break; +// case Vehicle.HOVER_EFFICIENCY: +// if (pValue < 0f) pValue = 0f; +// if (pValue > 1f) pValue = 1f; +// m_VhoverEfficiency = pValue; +// break; case Vehicle.HOVER_HEIGHT: m_VhoverHeight = pValue; break; @@ -291,7 +291,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_angularMotorTimescale = 1000; m_angularMotorDecayTimescale = 120; m_VhoverHeight = 0; - m_VhoverEfficiency = 1; +// m_VhoverEfficiency = 1; m_VhoverTimescale = 10; m_VehicleBuoyancy = 0; // m_linearDeflectionEfficiency = 1; @@ -317,7 +317,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_angularMotorTimescale = 1; m_angularMotorDecayTimescale = 0.8f; m_VhoverHeight = 0; - m_VhoverEfficiency = 0; +// m_VhoverEfficiency = 0; m_VhoverTimescale = 1000; m_VehicleBuoyancy = 0; // // m_linearDeflectionEfficiency = 1; @@ -344,7 +344,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_angularMotorTimescale = 4; m_angularMotorDecayTimescale = 4; m_VhoverHeight = 0; - m_VhoverEfficiency = 0.5f; +// m_VhoverEfficiency = 0.5f; m_VhoverTimescale = 2; m_VehicleBuoyancy = 1; // m_linearDeflectionEfficiency = 0.5f; @@ -372,7 +372,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_angularMotorTimescale = 4; m_angularMotorDecayTimescale = 4; m_VhoverHeight = 0; - m_VhoverEfficiency = 0.5f; +// m_VhoverEfficiency = 0.5f; m_VhoverTimescale = 1000; m_VehicleBuoyancy = 0; // m_linearDeflectionEfficiency = 0.5f; @@ -399,7 +399,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_angularMotorTimescale = 6; m_angularMotorDecayTimescale = 10; m_VhoverHeight = 5; - m_VhoverEfficiency = 0.8f; +// m_VhoverEfficiency = 0.8f; m_VhoverTimescale = 10; m_VehicleBuoyancy = 1; // m_linearDeflectionEfficiency = 0; diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 5ff9d32..49bbab9 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -2643,7 +2643,7 @@ Console.WriteLine(" JointCreateFixed"); //outofBounds = true; } - float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)); +// float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)); //Console.WriteLine("Adiff " + m_primName + " = " + Adiff); if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 2f42646..73ad15e 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -3519,7 +3519,7 @@ namespace OpenSim.Region.Physics.OdePlugin public override void UnCombine(PhysicsScene pScene) { IntPtr localGround = IntPtr.Zero; - float[] localHeightfield; +// float[] localHeightfield; bool proceed = false; List geomDestroyList = new List(); @@ -3531,7 +3531,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (geom == localGround) { - localHeightfield = TerrainHeightFieldHeights[geom]; +// localHeightfield = TerrainHeightFieldHeights[geom]; proceed = true; } else @@ -3553,7 +3553,7 @@ namespace OpenSim.Region.Physics.OdePlugin // memory corruption if (TerrainHeightFieldHeights.ContainsKey(g)) { - float[] removingHeightField = TerrainHeightFieldHeights[g]; +// float[] removingHeightField = TerrainHeightFieldHeights[g]; TerrainHeightFieldHeights.Remove(g); if (RegionTerrain.ContainsKey(g)) -- cgit v1.1 From 865d3f4b092874b23ff11012fb510721679350b0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Nov 2009 19:35:18 +0000 Subject: minor: remove a few mono compiler warnings --- OpenSim/Framework/Parallel.cs | 6 +++--- OpenSim/Framework/ThreadTracker.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Parallel.cs b/OpenSim/Framework/Parallel.cs index 515852f..a0394f2 100644 --- a/OpenSim/Framework/Parallel.cs +++ b/OpenSim/Framework/Parallel.cs @@ -69,7 +69,7 @@ namespace OpenSim.Framework Util.FireAndForget( delegate(object o) { - int threadIndex = (int)o; +// int threadIndex = (int)o; while (exception == null) { @@ -126,7 +126,7 @@ namespace OpenSim.Framework Util.FireAndForget( delegate(object o) { - int threadIndex = (int)o; +// int threadIndex = (int)o; while (exception == null) { @@ -182,7 +182,7 @@ namespace OpenSim.Framework Util.FireAndForget( delegate(object o) { - int threadIndex = (int)o; +// int threadIndex = (int)o; while (exception == null) { diff --git a/OpenSim/Framework/ThreadTracker.cs b/OpenSim/Framework/ThreadTracker.cs index b68d9b3..069e98b 100644 --- a/OpenSim/Framework/ThreadTracker.cs +++ b/OpenSim/Framework/ThreadTracker.cs @@ -35,7 +35,7 @@ namespace OpenSim.Framework { public static class ThreadTracker { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static ProcessThreadCollection GetThreads() { -- cgit v1.1 From 00130841db6756caf62207dca3b56efc87b5ea0d Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 3 Nov 2009 20:23:50 +0000 Subject: Remove parallel loading from XEngine, but retain the new design where all scripts are loaded from the same thread, rather than launching a new one for each script. This is only marginally slower, but avoids the race condition that led to script engine failure. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 27 ++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b0fce75..a60c0ba 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -51,7 +51,6 @@ using OpenSim.Region.ScriptEngine.Shared.Instance; using OpenSim.Region.ScriptEngine.Interfaces; using ScriptCompileQueue = OpenSim.Framework.LocklessQueue; -using Parallel = OpenSim.Framework.Parallel; namespace OpenSim.Region.ScriptEngine.XEngine { @@ -494,7 +493,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (m_CurrentCompile == null) { - m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); + // NOTE: Although we use a lockless queue, the lock here + // is required. It ensures that there are never two + // compile threads running, which, due to a race + // conndition, might otherwise happen + // + lock (m_CompileQueue) + { + if (m_CurrentCompile == null) + m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); + } } } } @@ -514,16 +522,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine } } - List compiles = new List(); object[] o; while (m_CompileQueue.Dequeue(out o)) + DoOnRezScript(o); + + // NOTE: Despite having a lockless queue, this lock is required + // to make sure there is never no compile thread while there + // are still scripts to compile. This could otherwise happen + // due to a race condition + // + lock (m_CompileQueue) { - compiles.Add(o); + m_CurrentCompile = null; } - - Parallel.For(0, compiles.Count, delegate(int i) { DoOnRezScript(compiles[i]); }); - - m_CurrentCompile = null; m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, m_ScriptErrorMessage); m_ScriptFailCount = 0; -- cgit v1.1 From c72f78215bb3435ee2bbb507746c23eccec4dd34 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 01:56:19 +0000 Subject: Backport the fixes to WebFetchInventoryDescendents to the UDP InventoryDescendents packet. Testing has shown that UDP inventory now works flawlessly and, unlike CAPS inventory, doesn't download the entire agent inventory on start. Neither does it incessantly re-request folder NULL_KEY. Therefore, I have disabled CAPS inventory. --- OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 2 +- .../Client/VWoHTTP/ClientStack/VWHClientView.cs | 2 +- OpenSim/Framework/Capabilities/Caps.cs | 2 +- .../Communications/Cache/CachedUserInfo.cs | 4 +- OpenSim/Framework/IClientAPI.cs | 2 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 246 ++++++++------------- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 +- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 +- .../Server/IRCClientView.cs | 2 +- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Tests/Common/Mock/TestClient.cs | 1 + 12 files changed, 112 insertions(+), 161 deletions(-) diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 204603d..3c3c247 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -1052,7 +1052,7 @@ namespace OpenSim.Client.MXP.ClientStack { } - public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, bool fetchFolders, bool fetchItems) + public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, int version, bool fetchFolders, bool fetchItems) { // Need to translate to MXP somehow } diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index 4a54c67..81ebf31 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -606,7 +606,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack throw new System.NotImplementedException(); } - public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, bool fetchFolders, bool fetchItems) + public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, int version, bool fetchFolders, bool fetchItems) { throw new System.NotImplementedException(); } diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index 1dfb2d4..ccfe800 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -208,7 +208,7 @@ namespace OpenSim.Framework.Capabilities // As of RC 1.22.9 of the Linden client this is // supported - m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); + //m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index aa71536..6648c36 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -679,7 +679,7 @@ namespace OpenSim.Framework.Communications.Cache /// /// /// true if the request was queued or successfully processed, false otherwise - public bool SendInventoryDecendents(IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems) + public bool SendInventoryDecendents(IClientAPI client, UUID folderID, int version, bool fetchFolders, bool fetchItems) { if (m_hasReceivedInventory) { @@ -693,7 +693,7 @@ namespace OpenSim.Framework.Communications.Cache client.SendInventoryFolderDetails( client.AgentId, folderID, folder.RequestListOfItems(), - folder.RequestListOfFolders(), fetchFolders, fetchItems); + folder.RequestListOfFolders(), version, fetchFolders, fetchItems); return true; } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index d304345..0f88b93 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1124,7 +1124,7 @@ namespace OpenSim.Framework void ReprioritizeUpdates(StateUpdateTypes type, UpdatePriorityHandler handler); void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, - List folders, bool fetchFolders, + List folders, int version, bool fetchFolders, bool fetchItems); void FlushPrimUpdates(); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index db0c3b8..bd5df19 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1251,7 +1251,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Do we need to send folder information? /// Do we need to send item information? public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, - List folders, + List folders, int version, bool fetchFolders, bool fetchItems) { // An inventory descendents packet consists of a single agent section and an inventory details @@ -1266,172 +1266,104 @@ namespace OpenSim.Region.ClientStack.LindenUDP // 6 to 7 items at a time, so let's stick with 6 int MAX_ITEMS_PER_PACKET = 6; - //Ckrinke This variable is not used, so comment out to remove the warning from the compiler (3-21-08) - //Ckrinke uint FULL_MASK_PERMISSIONS = 2147483647; - + int totalItems = fetchItems ? items.Count : 0; + int totalFolders = fetchFolders ? folders.Count : 0; int itemsSent = 0; - if (fetchItems) - { - InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - - if (items.Count < MAX_ITEMS_PER_PACKET) - { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; - } - else - { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; - } + int foldersSent = 0; + int foldersToSend = 0; + int itemsToSend = 0; - // Descendents must contain the *total* number of descendents (plus folders, whether we - // fetch them or not), not the number of entries we send in this packet. For consistency, - // I'll use it for folder-requests, too, although I wasn't able to get one with - // FetchFolders = true. - // TODO this should be checked with FetchFolders = true - descend.AgentData.Descendents = items.Count + folders.Count; + InventoryDescendentsPacket currentPacket = null; - int count = 0; - int i = 0; - foreach (InventoryItemBase item in items) + // Handle empty folders + // + if (totalItems == 0 && totalFolders == 0) + currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, 0, 0); + + // To preserve SL compatibility, we will NOT combine folders and items in one packet + // + while(itemsSent < totalItems || foldersSent < totalFolders) + { + if (currentPacket == null) // Start a new packet { - descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); - descend.ItemData[i].ItemID = item.ID; - descend.ItemData[i].AssetID = item.AssetID; - descend.ItemData[i].CreatorID = item.CreatorIdAsUuid; - descend.ItemData[i].BaseMask = item.BasePermissions; - descend.ItemData[i].Description = Util.StringToBytes256(item.Description); - descend.ItemData[i].EveryoneMask = item.EveryOnePermissions; - descend.ItemData[i].OwnerMask = item.CurrentPermissions; - descend.ItemData[i].FolderID = item.Folder; - descend.ItemData[i].InvType = (sbyte)item.InvType; - descend.ItemData[i].Name = Util.StringToBytes256(item.Name); - descend.ItemData[i].NextOwnerMask = item.NextPermissions; - descend.ItemData[i].OwnerID = item.Owner; - descend.ItemData[i].Type = (sbyte)item.AssetType; - - descend.ItemData[i].GroupID = item.GroupID; - descend.ItemData[i].GroupOwned = item.GroupOwned; - descend.ItemData[i].GroupMask = item.GroupPermissions; - descend.ItemData[i].CreationDate = item.CreationDate; - descend.ItemData[i].SalePrice = item.SalePrice; - descend.ItemData[i].SaleType = item.SaleType; - descend.ItemData[i].Flags = item.Flags; - - 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].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.CurrentPermissions); - - i++; - count++; - itemsSent++; - if (i == MAX_ITEMS_PER_PACKET) - { - descend.Header.Zerocoded = true; - AddNullFolderBlockToDecendentsPacket(ref descend); - OutPacket(descend, ThrottleOutPacketType.Asset); - - if ((items.Count - count) > 0) - { - descend = CreateInventoryDescendentsPacket(ownerID, folderID); - if ((items.Count - count) < MAX_ITEMS_PER_PACKET) - { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; - } - else - { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; - } - descend.AgentData.Descendents = items.Count + folders.Count; - i = 0; - } + foldersToSend = totalFolders - foldersSent; + if (foldersToSend > MAX_ITEMS_PER_PACKET) + foldersToSend = MAX_ITEMS_PER_PACKET; + + if (foldersToSend == 0) + { + itemsToSend = totalItems - itemsSent; + if (itemsToSend > MAX_ITEMS_PER_PACKET) + itemsToSend = MAX_ITEMS_PER_PACKET; } - } - if (0 < i && i < MAX_ITEMS_PER_PACKET) - { - AddNullFolderBlockToDecendentsPacket(ref descend); - OutPacket(descend, ThrottleOutPacketType.Asset); + currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, foldersToSend, itemsToSend); } - } - - //send subfolders - if (fetchFolders) - { - InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - if (folders.Count < MAX_ITEMS_PER_PACKET) - { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; - } + if (foldersToSend-- > 0) + currentPacket.FolderData[foldersSent % MAX_ITEMS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]); + else if(itemsToSend-- > 0) + currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]); else { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; + OutPacket(currentPacket, ThrottleOutPacketType.Asset); + currentPacket = null; } - // 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. - descend.AgentData.Descendents = items.Count + folders.Count; + } - int i = 0; - int count = 0; - foreach (InventoryFolderBase folder in folders) - { - descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock(); - descend.FolderData[i].FolderID = folder.ID; - descend.FolderData[i].Name = Util.StringToBytes256(folder.Name); - descend.FolderData[i].ParentID = folder.ParentID; - descend.FolderData[i].Type = (sbyte)folder.Type; + if (currentPacket != null) + OutPacket(currentPacket, ThrottleOutPacketType.Asset); + } - i++; - count++; - itemsSent++; - if (i == MAX_ITEMS_PER_PACKET) - { - AddNullItemBlockToDescendentsPacket(ref descend); - OutPacket(descend, ThrottleOutPacketType.Asset); + private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder) + { + InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock(); + newBlock.FolderID = folder.ID; + newBlock.Name = Util.StringToBytes256(folder.Name); + newBlock.ParentID = folder.ParentID; + newBlock.Type = (sbyte)folder.Type; - 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]; - } - else - { - descend.FolderData = - new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; - } - descend.AgentData.Descendents = items.Count + folders.Count; - i = 0; - } - } - } + return newBlock; + } - if (0 < i && i < MAX_ITEMS_PER_PACKET) - { - AddNullItemBlockToDescendentsPacket(ref descend); - OutPacket(descend, ThrottleOutPacketType.Asset); - } - } + private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item) + { + InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock(); + newBlock.ItemID = item.ID; + newBlock.AssetID = item.AssetID; + newBlock.CreatorID = item.CreatorIdAsUuid; + newBlock.BaseMask = item.BasePermissions; + newBlock.Description = Util.StringToBytes256(item.Description); + newBlock.EveryoneMask = item.EveryOnePermissions; + newBlock.OwnerMask = item.CurrentPermissions; + newBlock.FolderID = item.Folder; + newBlock.InvType = (sbyte)item.InvType; + newBlock.Name = Util.StringToBytes256(item.Name); + newBlock.NextOwnerMask = item.NextPermissions; + newBlock.OwnerID = item.Owner; + newBlock.Type = (sbyte)item.AssetType; - if (itemsSent == 0) - { - // no items found. - InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - descend.AgentData.Descendents = 0; - AddNullItemBlockToDescendentsPacket(ref descend); - AddNullFolderBlockToDecendentsPacket(ref descend); - OutPacket(descend, ThrottleOutPacketType.Asset); - } + newBlock.GroupID = item.GroupID; + newBlock.GroupOwned = item.GroupOwned; + newBlock.GroupMask = item.GroupPermissions; + newBlock.CreationDate = item.CreationDate; + newBlock.SalePrice = item.SalePrice; + newBlock.SaleType = item.SaleType; + newBlock.Flags = item.Flags; + + newBlock.CRC = + Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType, + newBlock.InvType, newBlock.Type, + newBlock.AssetID, newBlock.GroupID, + newBlock.SalePrice, + newBlock.OwnerID, newBlock.CreatorID, + newBlock.ItemID, newBlock.FolderID, + newBlock.EveryoneMask, + newBlock.Flags, newBlock.OwnerMask, + newBlock.GroupMask, newBlock.NextOwnerMask); + + return newBlock; } private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet) @@ -1473,14 +1405,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP // No need to add CRC } - private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID) + private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int folders, int items) { InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents); descend.Header.Zerocoded = true; descend.AgentData.AgentID = AgentId; descend.AgentData.OwnerID = ownerID; descend.AgentData.FolderID = folderID; - descend.AgentData.Version = 1; + descend.AgentData.Version = version; + + if (folders > 0) + descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders]; + else + AddNullFolderBlockToDecendentsPacket(ref descend); + + if (items > 0) + descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items]; + else + AddNullItemBlockToDescendentsPacket(ref descend); return descend; } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 5a5fcfe..5891c7e 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -538,6 +538,7 @@ namespace OpenSim.Region.Examples.SimpleModule public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, + int version, bool fetchFolders, bool fetchItems) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4d76b4ef..00743fc 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1175,7 +1175,13 @@ namespace OpenSim.Region.Framework.Scenes { m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); - client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, fetchFolders, fetchItems); + InventoryFolderBase containingFolder = new InventoryFolderBase(); + containingFolder.ID = folder.ID; + containingFolder.Owner = client.AgentId; + containingFolder = InventoryService.GetFolder(containingFolder); + int version = containingFolder.Version; + + client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); } /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 1a91f0c..47fbeb4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -462,7 +462,7 @@ namespace OpenSim.Region.Framework.Scenes { remoteClient.SendInventoryFolderDetails( fold.Owner, folderID, fold.RequestListOfItems(), - fold.RequestListOfFolders(), fetchFolders, fetchItems); + fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); return; } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 4b0d01a..f1bd705 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1055,7 +1055,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } - public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, bool fetchFolders, bool fetchItems) + public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, int version, bool fetchFolders, bool fetchItems) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index f7cadaa..cf81198 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -627,6 +627,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, + int version, bool fetchFolders, bool fetchItems) { diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 0f642b9..9ec9311 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -631,6 +631,7 @@ namespace OpenSim.Tests.Common.Mock public virtual void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List items, List folders, + int version, bool fetchFolders, bool fetchItems) { -- cgit v1.1 From 4d2ecd1236f36e0ce6307689cac6e35baed3b73b Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 03:07:21 +0000 Subject: Correctly set the totall number of descendents in inventory retrieval --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index bd5df19..479da6d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1278,7 +1278,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Handle empty folders // if (totalItems == 0 && totalFolders == 0) - currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, 0, 0); + currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0); // To preserve SL compatibility, we will NOT combine folders and items in one packet // @@ -1297,7 +1297,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP itemsToSend = MAX_ITEMS_PER_PACKET; } - currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, foldersToSend, itemsToSend); + currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend); } if (foldersToSend-- > 0) @@ -1405,7 +1405,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // No need to add CRC } - private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int folders, int items) + private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items) { InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents); descend.Header.Zerocoded = true; @@ -1413,6 +1413,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP descend.AgentData.OwnerID = ownerID; descend.AgentData.FolderID = folderID; descend.AgentData.Version = version; + descend.AgentData.Descendents = descendents; if (folders > 0) descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders]; -- cgit v1.1 From 5bcc02c97b78f76a274440ca0b62830d820299d9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 03:56:31 +0000 Subject: Prevent autosplitting of inventory descendents packets. Also reduces the number of items per packet to 5 to prevent asserts --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 479da6d..e26d50a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1264,7 +1264,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // // for one example of this kind of thing. In fact, the Linden servers appear to only send about // 6 to 7 items at a time, so let's stick with 6 - int MAX_ITEMS_PER_PACKET = 6; + int MAX_ITEMS_PER_PACKET = 5; int totalItems = fetchItems ? items.Count : 0; int totalFolders = fetchFolders ? folders.Count : 0; @@ -1415,6 +1415,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP descend.AgentData.Version = version; descend.AgentData.Descendents = descendents; + // Disable multiple packets + descend.HasVariableBlocks = false; + if (folders > 0) descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders]; else -- cgit v1.1 From cfcb5faa4e7ff48b486567c32e07253fabdbc8ec Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 04:09:46 +0000 Subject: Bounce the pacjet items limit back up to 6 --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index e26d50a..09c5dfa 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1264,7 +1264,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // // for one example of this kind of thing. In fact, the Linden servers appear to only send about // 6 to 7 items at a time, so let's stick with 6 - int MAX_ITEMS_PER_PACKET = 5; + int MAX_ITEMS_PER_PACKET = 6; int totalItems = fetchItems ? items.Count : 0; int totalFolders = fetchFolders ? folders.Count : 0; -- cgit v1.1 From 535f4597c1de74180f59dd97c5b8888eaf12c01a Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 04:36:19 +0000 Subject: Add an overload to OutPacket as per jhurliman. Switch hacky workaround for InventoryDescendents to the proper way --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 09c5dfa..2da6d98 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1306,14 +1306,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]); else { - OutPacket(currentPacket, ThrottleOutPacketType.Asset); + OutPacket(currentPacket, ThrottleOutPacketType.Asset, false); currentPacket = null; } } if (currentPacket != null) - OutPacket(currentPacket, ThrottleOutPacketType.Asset); + OutPacket(currentPacket, ThrottleOutPacketType.Asset, false); } private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder) @@ -1415,9 +1415,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP descend.AgentData.Version = version; descend.AgentData.Descendents = descendents; - // Disable multiple packets - descend.HasVariableBlocks = false; - if (folders > 0) descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders]; else @@ -4909,6 +4906,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); } + /// + /// This is the starting point for sending a simulator packet out to the client + /// + /// Packet to send + /// Throttling category for the packet + /// True to automatically split oversized + /// packets (the default), or false to disable splitting if the calling code + /// handles splitting manually + protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting) + { + m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting); + } + public bool AddMoney(int debit) { if (m_moneyBalance + debit >= 0) -- cgit v1.1 From 9dd5d63495cac6717057b47f3ac9ef89685281cc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 4 Nov 2009 19:44:28 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | 14 +++++++------- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 244ac3b..7a66d23 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -77,13 +77,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid #region Internal functions - private string UserAssetURL(UUID userID) - { - CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); - if (uinfo != null) - return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; - return null; - } +// private string UserAssetURL(UUID userID) +// { +// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); +// if (uinfo != null) +// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; +// return null; +// } // private string UserInventoryURL(UUID userID) // { diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a6ee40a..093ca3e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1043,7 +1043,7 @@ namespace OpenSim.Region.Framework.Scenes TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; physicsFPS = 0f; - maintc = maintc = otherMS = Environment.TickCount; + maintc = otherMS = Environment.TickCount; int tmpFrameMS = maintc; // Increment the frame counter diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6c0d9f2..124f4c0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.Framework.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; - private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); +// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); /// @@ -181,7 +181,7 @@ namespace OpenSim.Region.Framework.Scenes private byte m_state; //Reuse the Vector3 instead of creating a new one on the UpdateMovement method - private Vector3 movementvector; +// private Vector3 movementvector; private bool m_autopilotMoving; private Vector3 m_autoPilotTarget; @@ -2068,7 +2068,7 @@ namespace OpenSim.Region.Framework.Scenes if (heldDown) { move.Z -= 1; } // Is the avatar trying to move? - bool moving = (move != Vector3.Zero); +// bool moving = (move != Vector3.Zero); bool jumping = m_animTickJump != 0; #endregion Inputs @@ -2320,7 +2320,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { - PhysicsActor actor = m_physicsActor; +// PhysicsActor actor = m_physicsActor; // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to // grab the latest PhysicsActor velocity, whereas m_velocity is often @@ -3256,7 +3256,7 @@ namespace OpenSim.Region.Framework.Scenes Vector3 force = m_forceToApply.Value; m_updateflag = true; - movementvector = force; +// movementvector = force; Velocity = force; m_forceToApply = null; -- cgit v1.1 From 58be90d2b167719267fde18f2983b5a64f8b6f37 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 22:47:40 +0000 Subject: Add some length to the backet buffer for packet sending so oversize inventory packets don't make us barf --- OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 93946ae..93c3270 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -327,7 +327,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting // there are a decent number of packets in the 1000-1140 byte range. We allocate one of two sizes of data here // to accomodate for both common scenarios and provide ample room for ACK appending in both - int bufferSize = (dataLength > 180) ? LLUDPServer.MTU : 200; + int bufferSize = (dataLength > 180) ? LLUDPServer.MTU + 1000 : 200; UDPPacketBuffer buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, bufferSize); -- cgit v1.1 From b6ea7c26ac7653a144b5880e3027fcddabe872e8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 23:12:56 +0000 Subject: Refine oversized packet handling as per jhurliman. Reallocate the buffer to actual packet size only for oversized packets. --- OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 93c3270..6165984 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -327,7 +327,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting // there are a decent number of packets in the 1000-1140 byte range. We allocate one of two sizes of data here // to accomodate for both common scenarios and provide ample room for ACK appending in both - int bufferSize = (dataLength > 180) ? LLUDPServer.MTU + 1000 : 200; + int bufferSize = (dataLength > 180) ? LLUDPServer.MTU : 200; UDPPacketBuffer buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, bufferSize); @@ -359,9 +359,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP } else { - m_log.Error("[LLUDPSERVER]: Packet exceeded buffer size! This could be an indication of packet assembly not obeying the MTU. Type=" + - type + ", DataLength=" + dataLength + ", BufferLength=" + buffer.Data.Length + ". Dropping packet"); - return; + bufferSize = dataLength; + buffer = new UDPPacketBuffer(udpClient.RemoteEndPoint, bufferSize); + + // m_log.Error("[LLUDPSERVER]: Packet exceeded buffer size! This could be an indication of packet assembly not obeying the MTU. Type=" + + // type + ", DataLength=" + dataLength + ", BufferLength=" + buffer.Data.Length + ". Dropping packet"); + Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); } } -- cgit v1.1 From ec2ebf2598028daf4ff2003a53be3ca40ffc8272 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 4 Nov 2009 16:08:10 -0800 Subject: Removing EntityBase.Rotation --- OpenSim/Region/Framework/Scenes/EntityBase.cs | 14 -------------- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 +++++++- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 ++++++++- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs index c2ec6a5..1c76c54 100644 --- a/OpenSim/Region/Framework/Scenes/EntityBase.cs +++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs @@ -94,14 +94,6 @@ namespace OpenSim.Region.Framework.Scenes set { m_velocity = value; } } - protected Quaternion m_rotation = new Quaternion(0f, 0f, 1f, 0f); - - public virtual Quaternion Rotation - { - get { return m_rotation; } - set { m_rotation = value; } - } - protected uint m_localId; public virtual uint LocalId @@ -115,13 +107,7 @@ namespace OpenSim.Region.Framework.Scenes /// public EntityBase() { - m_uuid = UUID.Zero; - - m_pos = Vector3.Zero; - m_velocity = Vector3.Zero; - Rotation = Quaternion.Identity; m_name = "(basic entity)"; - m_rotationalvelocity = Vector3.Zero; } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index c65a665..f938472 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -204,6 +204,14 @@ namespace OpenSim.Region.Framework.Scenes get { return m_parts.Count; } } + protected Quaternion m_rotation = Quaternion.Identity; + + public virtual Quaternion Rotation + { + get { return m_rotation; } + set { m_rotation = value; } + } + public Quaternion GroupRotation { get { return m_rootPart.RotationOffset; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6c0d9f2..b12eea9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -481,6 +481,12 @@ namespace OpenSim.Region.Framework.Scenes } } + public Quaternion Rotation + { + get { return m_bodyRot; } + set { m_bodyRot = value; } + } + /// /// If this is true, agent doesn't have a representation in this scene. /// this is an agent 'looking into' this scene from a nearby scene(region) @@ -2256,7 +2262,7 @@ namespace OpenSim.Region.Framework.Scenes m_perfMonMS = Environment.TickCount; - m_rotation = rotation; + Rotation = rotation; Vector3 direc = vec * rotation; direc.Normalize(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 52396b6..f1ceb80 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -384,7 +384,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (World.Entities.ContainsKey(target)) { - World.Entities[target].Rotation = rotation; + EntityBase entity; + if (World.Entities.TryGetValue(target, out entity)) + { + if (entity is SceneObjectGroup) + ((SceneObjectGroup)entity).Rotation = rotation; + else if (entity is ScenePresence) + ((ScenePresence)entity).Rotation = rotation; + } } else { -- cgit v1.1 From a13e25ebbe766f9fbbc11a20fb42d5076326084f Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 4 Nov 2009 16:19:56 -0800 Subject: Initialize SceneObjectPart.RotationOffset to Quaternion.Identity --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2bc7f66..f47be99 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -243,7 +243,7 @@ namespace OpenSim.Region.Framework.Scenes protected SceneObjectGroup m_parentGroup; protected byte[] m_particleSystem = Utils.EmptyBytes; protected ulong m_regionHandle; - protected Quaternion m_rotationOffset; + protected Quaternion m_rotationOffset = Quaternion.Identity; protected PrimitiveBaseShape m_shape; protected UUID m_uuid; protected Vector3 m_velocity; -- cgit v1.1 From 30a2411e5816b3e0aa421e4537e554aa640c060f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 4 Nov 2009 23:54:19 +0000 Subject: Separate folder and item limit for UDP inventory packets. Folder limit is now 6, as before, item limit is 5. This should avoid most, if not all, oversized packets. --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 2da6d98..70abe77 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1264,7 +1264,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // // for one example of this kind of thing. In fact, the Linden servers appear to only send about // 6 to 7 items at a time, so let's stick with 6 - int MAX_ITEMS_PER_PACKET = 6; + int MAX_ITEMS_PER_PACKET = 5; + int MAX_FOLDERS_PER_PACKET = 6; int totalItems = fetchItems ? items.Count : 0; int totalFolders = fetchFolders ? folders.Count : 0; @@ -1287,8 +1288,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (currentPacket == null) // Start a new packet { foldersToSend = totalFolders - foldersSent; - if (foldersToSend > MAX_ITEMS_PER_PACKET) - foldersToSend = MAX_ITEMS_PER_PACKET; + if (foldersToSend > MAX_FOLDERS_PER_PACKET) + foldersToSend = MAX_FOLDERS_PER_PACKET; if (foldersToSend == 0) { @@ -1301,7 +1302,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } if (foldersToSend-- > 0) - currentPacket.FolderData[foldersSent % MAX_ITEMS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]); + currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]); else if(itemsToSend-- > 0) currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]); else -- cgit v1.1 From 83b4b4440b7becb405840bc69d665e260fdecea0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Nov 2009 02:09:07 +0000 Subject: Patch by revolution, thank you. Mantis #1789 . Implement friends permissions. Applied with major changes. Core functionality commented pending review for possible rights escalation. No user functionality yet. --- OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 1 + .../Client/VWoHTTP/ClientStack/VWHClientView.cs | 2 ++ OpenSim/Framework/IClientAPI.cs | 2 ++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 22 +++++++++++++- .../CoreModules/Avatar/Friends/FriendsModule.cs | 9 ++++-- .../World/Permissions/PermissionsModule.cs | 34 ++++++++++++++++++++++ .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 + .../Server/IRCClientView.cs | 1 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Tests/Common/Mock/TestClient.cs | 1 + 10 files changed, 71 insertions(+), 3 deletions(-) diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 3c3c247..0cae3dd 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -676,6 +676,7 @@ namespace OpenSim.Client.MXP.ClientStack public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event MoneyTransferRequest OnMoneyTransferRequest; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index 81ebf31..fb87c15 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -327,6 +327,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack public event FriendActionDelegate OnApproveFriendRequest = delegate { }; public event FriendActionDelegate OnDenyFriendRequest = delegate { }; public event FriendshipTermination OnTerminateFriendship = delegate { }; + public event GrantUserFriendRights OnGrantUserRights = delegate { }; public event MoneyTransferRequest OnMoneyTransferRequest = delegate { }; public event EconomyDataRequest OnEconomyDataRequest = delegate { }; public event MoneyBalanceRequest OnMoneyBalanceRequest = delegate { }; @@ -406,6 +407,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack public event PlacesQuery OnPlacesQuery = delegate { }; + public void SetDebugPacketLevel(int newDebug) { throw new System.NotImplementedException(); diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 0f88b93..ee7ab87 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -446,6 +446,7 @@ namespace OpenSim.Framework public delegate void AvatarNotesUpdate(IClientAPI client, UUID targetID, string notes); public delegate void MuteListRequest(IClientAPI client, uint muteCRC); public delegate void AvatarInterestUpdate(IClientAPI client, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages); + public delegate void GrantUserFriendRights(IClientAPI client, UUID requester, UUID target, int rights); public delegate void PlacesQuery(UUID QueryID, UUID TransactionID, string QueryText, uint QueryFlags, byte Category, string SimName, IClientAPI client); public delegate void AgentFOV(IClientAPI client, float verticalAngle); @@ -1023,6 +1024,7 @@ namespace OpenSim.Framework event PickInfoUpdate OnPickInfoUpdate; event AvatarNotesUpdate OnAvatarNotesUpdate; event AvatarInterestUpdate OnAvatarInterestUpdate; + event GrantUserFriendRights OnGrantUserRights; event MuteListRequest OnMuteListRequest; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 70abe77..34cad7b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -220,6 +220,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event MoneyTransferRequest OnMoneyTransferRequest; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; @@ -9719,7 +9720,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText), Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText)); break; - + + case PacketType.GrantUserRights: + GrantUserRightsPacket GrantUserRights = + (GrantUserRightsPacket)Pack; + #region Packet Session and User Check + if (m_checkPackets) + { + if (GrantUserRights.AgentData.SessionID != SessionId || + GrantUserRights.AgentData.AgentID != AgentId) + break; + } + #endregion + GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights; + if (GrantUserRightsHandler != null) + GrantUserRightsHandler(this, + GrantUserRights.AgentData.AgentID, + GrantUserRights.Rights[0].AgentRelated, + GrantUserRights.Rights[0].RelatedRights); + break; + case PacketType.PlacesQuery: PlacesQueryPacket placesQueryPacket = (PlacesQueryPacket)Pack; diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fc7d63a..c6fd72e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -395,6 +395,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // if it leaves, we want to know, too client.OnLogout += OnLogout; + client.OnGrantUserRights += GrantUserFriendRights; + } private void ClientClosed(UUID AgentId, Scene scene) @@ -1108,7 +1110,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // tell everyone that we are offline SendPresenceState(remoteClient, fl, false); } - } - + private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) + { + ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); + } + } #endregion } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index fe9de1b..effe1f0 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -476,6 +476,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } + protected bool IsFriendWithPerms(UUID user,UUID objectOwner) + { + + if (user == UUID.Zero) return false; + + List profile = m_scene.CommsManager.GetUserFriendList(user); + foreach (FriendListItem item in profile) + { + m_log.Warn("IsFriendWithPerms called" + item.FriendPerms.ToString()); + if(item.Friend == objectOwner) + { +// if (item.FriendPerms == 3) +// { +// return true; +// } +// if (item.FriendPerms == 4) +// { +// return true; +// } +// if (item.FriendPerms == 5) +// { +// return true; +// } +// if (item.FriendPerms == 7) +// { +// return true; +// } + } + } + return false; + } protected bool IsEstateManager(UUID user) { @@ -565,6 +596,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions // Object owners should be able to edit their own content if (user == objectOwner) return objectOwnerMask; + + if (IsFriendWithPerms(user, objectOwner)) + return objectOwnerMask; // Estate users should be able to edit anything in the sim if (IsEstateManager(user) && m_RegionOwnerIsGod && !IsAdministrator(objectOwner)) diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 5891c7e..9754da3 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -179,6 +179,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index f1bd705..6c3e7eb 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -758,6 +758,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event MoneyTransferRequest OnMoneyTransferRequest; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index cf81198..cf36d08 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -283,6 +283,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 9ec9311..27025d9 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -191,6 +191,7 @@ namespace OpenSim.Tests.Common.Mock public event FriendActionDelegate OnApproveFriendRequest; public event FriendActionDelegate OnDenyFriendRequest; public event FriendshipTermination OnTerminateFriendship; + public event GrantUserFriendRights OnGrantUserRights; public event EconomyDataRequest OnEconomyDataRequest; public event MoneyBalanceRequest OnMoneyBalanceRequest; -- cgit v1.1 From b098572525a73fce0743087a272eac84336c4867 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Nov 2009 16:46:39 +0000 Subject: Remove a spammy debug message from friends list check in the perms module. Replace the integer compares with proper bitflags checking from libOMV. Friends rights are now functional. --- .../World/Permissions/PermissionsModule.cs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index effe1f0..f7675f4 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -484,26 +484,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions List profile = m_scene.CommsManager.GetUserFriendList(user); foreach (FriendListItem item in profile) { - m_log.Warn("IsFriendWithPerms called" + item.FriendPerms.ToString()); - if(item.Friend == objectOwner) - { -// if (item.FriendPerms == 3) -// { -// return true; -// } -// if (item.FriendPerms == 4) -// { -// return true; -// } -// if (item.FriendPerms == 5) -// { -// return true; -// } -// if (item.FriendPerms == 7) -// { -// return true; -// } - } + if(item.Friend == objectOwner && (item.FriendPerms & (uint)FriendRights.CanModifyObjects) != 0) + return true; } return false; } -- cgit v1.1 From ec0d5b408adad5c806cad7b9cbce3ca37069dcaf Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Nov 2009 17:29:52 +0000 Subject: Change the permissions module to use the friend list cache already in the friends module instead of requesting the entire friends list over the network each time a prim is touched. --- .../Region/CoreModules/Avatar/Friends/FriendsModule.cs | 12 ++++++++++++ .../CoreModules/World/Permissions/PermissionsModule.cs | 17 +++++++++++++++-- OpenSim/Region/Framework/Interfaces/IFriendsModule.cs | 2 ++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index c6fd72e..bb4e032 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -1114,6 +1114,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); } + + public List GetUserFriends(UUID agentID) + { + List fl; + lock (m_friendLists) + { + fl = (List)m_friendLists.Get(agentID.ToString(), + m_initialScene.GetFriendList); + } + + return fl; + } } #endregion } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index f7675f4..c790624 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -144,6 +144,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions private Dictionary GrantVB = new Dictionary(); private Dictionary GrantJS = new Dictionary(); private Dictionary GrantYP = new Dictionary(); + private IFriendsModule m_friendsModule = null; + #endregion #region IRegionModule Members @@ -363,6 +365,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions public void PostInitialise() { + m_friendsModule = m_scene.RequestModuleInterface(); + + if (m_friendsModule == null) + m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work"); + else + m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled"); } public void Close() @@ -479,9 +487,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions protected bool IsFriendWithPerms(UUID user,UUID objectOwner) { - if (user == UUID.Zero) return false; + if (user == UUID.Zero) + return false; + + if (m_friendsModule == null) + return false; + + List profile = m_friendsModule.GetUserFriends(user); - List profile = m_scene.CommsManager.GetUserFriendList(user); foreach (FriendListItem item in profile) { if(item.Friend == objectOwner && (item.FriendPerms & (uint)FriendRights.CanModifyObjects) != 0) diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 7a8aba2..8386030 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs @@ -27,6 +27,7 @@ using OpenMetaverse; using OpenSim.Framework; +using System.Collections.Generic; namespace OpenSim.Region.Framework.Interfaces { @@ -45,5 +46,6 @@ namespace OpenSim.Region.Framework.Interfaces /// /// void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage); + List GetUserFriends(UUID agentID); } } -- cgit v1.1 From 345ddcd0d82b15afa790ede4c1e8d93361a0d405 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Nov 2009 18:53:25 +0000 Subject: * Escape / character when saving items and folders in an iar so that the loader doesn't barf --- .../Inventory/Archiver/InventoryArchiveReadRequest.cs | 13 +++++++++++-- .../Inventory/Archiver/InventoryArchiveWriteRequest.cs | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f761bf0..7abaac0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -161,14 +161,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver failedAssetRestores++; } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) - { + { InventoryFolderBase foundFolder = ReplicateArchivePathToUserInventory( filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, rootDestinationFolder, foldersCreated, nodesLoaded); if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) - { + { + // Escape back characters + filePath = filePath.Replace("/", "/"); + filePath = filePath.Replace("&", "&"); + InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); // Don't use the item ID that's in the file @@ -289,6 +293,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); + + // Escape back characters + newFolderName = newFolderName.Replace("/", "/"); + newFolderName = newFolderName.Replace("&", "&"); + UUID newFolderId = UUID.Random(); // Asset type has to be Unknown here rather than Folder, otherwise the created folder can't be diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 499c552..af0b72f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -394,6 +394,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static string CreateArchiveFolderName(string name, UUID id) { + // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). + name = name.Replace("&", "&"); + name = name.Replace("/", "/"); + return string.Format( "{0}{1}{2}/", name, @@ -409,6 +413,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static string CreateArchiveItemName(string name, UUID id) { + name = name.Replace("&", "&"); + name = name.Replace("/", "/"); + return string.Format( "{0}{1}{2}.xml", name, -- cgit v1.1 From 6f4a588397d5e96e9566c9b34f8be2cb3ef421a4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Nov 2009 19:09:32 +0000 Subject: minor test var name tweak --- .../Inventory/Archiver/Tests/InventoryArchiverTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index b0fdcd6..81c3b74 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -136,7 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests InventoryFolderBase objsFolder = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); item1.Folder = objsFolder.ID; - scene.AddInventoryItem(userId, item1); + scene.AddInventoryItem(userId, item1); MemoryStream archiveWriteStream = new MemoryStream(); archiverModule.OnInventoryArchiveSaved += SaveCompleted; @@ -218,14 +218,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests string userItemCreatorLastName = "Lucan"; UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); - string itemName = "b.lsl"; - string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); + string item1Name = "b.lsl"; + string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random()); MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = itemName; + item1.Name = item1Name; item1.AssetID = UUID.Random(); item1.GroupID = UUID.Random(); item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); @@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); Assert.That( @@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); InventoryItemBase foundItem2 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + itemName); + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name); Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); // Now try loading to a more deeply nested folder @@ -286,7 +286,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); InventoryItemBase foundItem3 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName); + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name); Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); } -- cgit v1.1 From f8f1e94cf88fe5894366b1b11ebc3c000078cb2a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Nov 2009 19:32:24 +0000 Subject: add unit test for iar & escaping --- .../Archiver/Tests/InventoryArchiverTests.cs | 96 +++++++++++++++++++++- OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs | 24 +++++- OpenSim/Tests/Common/TestHelper.cs | 1 + 3 files changed, 117 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 81c3b74..c366150 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -290,6 +290,98 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); } + [Test] + public void TestIarV0_1WithEscapedChars() + { + TestHelper.InMethod(); + log4net.Config.XmlConfigurator.Configure(); + + string itemName = "You & you are a mean man"; + string userPassword = "meowfood"; + + InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + + Scene scene = SceneSetupHelpers.SetupScene("Inventory"); + SceneSetupHelpers.SetupSceneModules(scene, archiverModule); + CommunicationsManager cm = scene.CommsManager; + + // Create user + string userFirstName = "Jock"; + string userLastName = "Stirrup"; + UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + + lock (this) + { + UserProfileTestUtils.CreateUserWithInventory( + cm, userFirstName, userLastName, userPassword, userId, InventoryReceived); + Monitor.Wait(this, 60000); + } + + // Create asset + SceneObjectGroup object1; + SceneObjectPart part1; + { + string partName = "part name"; + UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); + PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); + Vector3 groupPosition = new Vector3(10, 20, 30); + Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); + Vector3 offsetPosition = new Vector3(5, 10, 15); + + part1 + = new SceneObjectPart( + ownerId, shape, groupPosition, rotationOffset, offsetPosition); + part1.Name = partName; + + object1 = new SceneObjectGroup(part1); + scene.AddNewSceneObject(object1, false); + } + + UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); + AssetBase asset1 = new AssetBase(); + asset1.FullID = asset1Id; + asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); + scene.AssetService.Store(asset1); + + // Create item + UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = itemName; + item1.AssetID = asset1.FullID; + item1.ID = item1Id; + InventoryFolderBase objsFolder + = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); + item1.Folder = objsFolder.ID; + scene.AddInventoryItem(userId, item1); + + MemoryStream archiveWriteStream = new MemoryStream(); + archiverModule.OnInventoryArchiveSaved += SaveCompleted; + + mre.Reset(); + archiverModule.ArchiveInventory( + Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); + mre.WaitOne(60000, false); + + /// LOAD ITEM + MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); + + archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); + + CachedUserInfo userInfo + = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); + + InventoryItemBase foundItem1 + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userId, "Scripts/Objects/" + itemName); + + Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); +// Assert.That( +// foundItem1.CreatorId, Is.EqualTo(userUuid), +// "Loaded item non-uuid creator doesn't match that of the loading user"); + Assert.That( + foundItem1.Name, Is.EqualTo(itemName), + "Loaded item name doesn't match saved name"); + } + /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// embedded creators do not exist in the system @@ -302,7 +394,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); + //log4net.Config.XmlConfigurator.Configure(); string userFirstName = "Charlie"; string userLastName = "Chan"; @@ -370,7 +462,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); + //log4net.Config.XmlConfigurator.Configure(); string userFirstName = "Dennis"; string userLastName = "Menace"; diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs index 3ca44a1..1b06a46 100644 --- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs +++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs @@ -85,14 +85,34 @@ namespace OpenSim.Tests.Common.Setup CommunicationsManager commsManager, string firstName, string lastName, UUID userId, OnInventoryReceivedDelegate callback) { + return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback); + } + + /// + /// Create a test user with a standard inventory + /// + /// + /// First name of user + /// Last name of user + /// Password + /// User ID + /// + /// Callback to invoke when inventory has been loaded. This is required because + /// loading may be asynchronous, even on standalone + /// + /// + public static CachedUserInfo CreateUserWithInventory( + CommunicationsManager commsManager, string firstName, string lastName, string password, + UUID userId, OnInventoryReceivedDelegate callback) + { LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId); + lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId); CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); userInfo.OnInventoryReceived += callback; userInfo.FetchInventory(); return userInfo; - } + } } } diff --git a/OpenSim/Tests/Common/TestHelper.cs b/OpenSim/Tests/Common/TestHelper.cs index 4abf2e3..9d53063 100644 --- a/OpenSim/Tests/Common/TestHelper.cs +++ b/OpenSim/Tests/Common/TestHelper.cs @@ -54,6 +54,7 @@ namespace OpenSim.Tests.Common public static void InMethod() { StackTrace stackTrace = new StackTrace(); + Console.WriteLine(); Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); } } -- cgit v1.1 From e6d7303b296468a06ada761706e25d49587b308f Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 12:01:40 -0800 Subject: Applying #4332, optional packet statistics logging --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 4 + .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 111 +++++++++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 100 +++++++++++++++++++ 3 files changed, 215 insertions(+) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 34cad7b..101a44b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4905,6 +4905,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Throttling category for the packet protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) { + #region BinaryStats + LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length); + #endregion BinaryStats + m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 6165984..c773c05 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Net; using System.Net.Sockets; using System.Reflection; @@ -204,6 +205,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP TextureSendLimit = 20; } + #region BinaryStats + config = configSource.Configs["Statistics.Binary"]; + m_shouldCollectStats = false; + if (config != null) + { + if (config.Contains("enabled") && config.GetBoolean("enabled")) + { + if (config.Contains("collect_packet_headers")) + m_shouldCollectStats = config.GetBoolean("collect_packet_headers"); + if (config.Contains("packet_headers_period_seconds")) + { + binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds")); + } + if (config.Contains("stats_dir")) + { + binStatsDir = config.GetString("stats_dir"); + } + } + else + { + m_shouldCollectStats = false; + } + } + #endregion BinaryStats + m_throttle = new TokenBucket(null, sceneThrottleBps, sceneThrottleBps); m_throttleRates = new ThrottleRates(configSource); } @@ -679,6 +705,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion Incoming Packet Accounting + #region BinaryStats + LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); + #endregion BinaryStats + #region Ping Check Handling if (packet.Type == PacketType.StartPingCheck) @@ -700,6 +730,87 @@ namespace OpenSim.Region.ClientStack.LindenUDP packetInbox.Enqueue(new IncomingPacket(udpClient, packet)); } + #region BinaryStats + + public class PacketLogger + { + public DateTime StartTime; + public string Path = null; + public System.IO.BinaryWriter Log = null; + } + + public static PacketLogger PacketLog; + + protected static bool m_shouldCollectStats = false; + // Number of seconds to log for + static TimeSpan binStatsMaxFilesize = TimeSpan.FromSeconds(300); + static object binStatsLogLock = new object(); + static string binStatsDir = ""; + + public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size) + { + if (!m_shouldCollectStats) return; + + // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size + + // Put the incoming bit into the least significant bit of the flags byte + if (incoming) + flags |= 0x01; + else + flags &= 0xFE; + + // Put the flags byte into the most significant bits of the type integer + uint type = (uint)packetType; + type |= (uint)flags << 24; + + // m_log.Debug("1 LogPacketHeader(): Outside lock"); + lock (binStatsLogLock) + { + DateTime now = DateTime.Now; + + // m_log.Debug("2 LogPacketHeader(): Inside lock. now is " + now.Ticks); + try + { + if (PacketLog == null || (now > PacketLog.StartTime + binStatsMaxFilesize)) + { + if (PacketLog != null && PacketLog.Log != null) + { + PacketLog.Log.Close(); + } + + // First log file or time has expired, start writing to a new log file + PacketLog = new PacketLogger(); + PacketLog.StartTime = now; + PacketLog.Path = (binStatsDir.Length > 0 ? binStatsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") + + String.Format("packets-{0}.log", now.ToString("yyyyMMddHHmmss")); + PacketLog.Log = new BinaryWriter(File.Open(PacketLog.Path, FileMode.Append, FileAccess.Write)); + } + + // Serialize the data + byte[] output = new byte[18]; + Buffer.BlockCopy(BitConverter.GetBytes(now.Ticks), 0, output, 0, 8); + Buffer.BlockCopy(BitConverter.GetBytes(circuit), 0, output, 8, 4); + Buffer.BlockCopy(BitConverter.GetBytes(type), 0, output, 12, 4); + Buffer.BlockCopy(BitConverter.GetBytes(size), 0, output, 16, 2); + + // Write the serialized data to disk + if (PacketLog != null && PacketLog.Log != null) + PacketLog.Log.Write(output); + } + catch (Exception ex) + { + m_log.Error("Packet statistics gathering failed: " + ex.Message, ex); + if (PacketLog.Log != null) + { + PacketLog.Log.Close(); + } + PacketLog = null; + } + } + } + + #endregion BinaryStats + private void HandleUseCircuitCode(object o) { object[] array = (object[])o; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 093ca3e..6edef11 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -36,6 +36,7 @@ using System.Timers; using System.Xml; using Nini.Config; using OpenMetaverse; +using OpenMetaverse.Packets; using OpenMetaverse.Imaging; using OpenSim.Framework; using OpenSim.Services.Interfaces; @@ -397,6 +398,73 @@ namespace OpenSim.Region.Framework.Scenes #endregion + #region BinaryStats + + public class StatLogger + { + public DateTime StartTime; + public string Path; + public System.IO.BinaryWriter Log; + } + static StatLogger m_statLog = null; + static TimeSpan m_statLogPeriod = TimeSpan.FromSeconds(300); + static string m_statsDir = String.Empty; + static Object m_statLockObject = new Object(); + private void LogSimStats(SimStats stats) + { + SimStatsPacket pack = new SimStatsPacket(); + pack.Region = new SimStatsPacket.RegionBlock(); + pack.Region.RegionX = stats.RegionX; + pack.Region.RegionY = stats.RegionY; + pack.Region.RegionFlags = stats.RegionFlags; + pack.Region.ObjectCapacity = stats.ObjectCapacity; + //pack.Region = //stats.RegionBlock; + pack.Stat = stats.StatsBlock; + pack.Header.Reliable = false; + + // note that we are inside the reporter lock when called + DateTime now = DateTime.Now; + + // hide some time information into the packet + pack.Header.Sequence = (uint)now.Ticks; + + lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here + { + try + { + if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) + { + // First log file or time has expired, start writing to a new log file + if (m_statLog != null && m_statLog.Log != null) + { + m_statLog.Log.Close(); + } + m_statLog = new StatLogger(); + m_statLog.StartTime = now; + m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") + + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); + m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); + } + + // Write the serialized data to disk + if (m_statLog != null && m_statLog.Log != null) + m_statLog.Log.Write(pack.ToBytes()); + } + catch (Exception ex) + { + m_log.Error("statistics gathering failed: " + ex.Message, ex); + if (m_statLog != null && m_statLog.Log != null) + { + m_statLog.Log.Close(); + } + m_statLog = null; + } + } + return; + } + + #endregion + #region Constructors public Scene(RegionInfo regInfo, AgentCircuitManager authen, @@ -582,6 +650,38 @@ namespace OpenSim.Region.Framework.Scenes } m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); + + #region BinaryStats + + try + { + IConfig statConfig = m_config.Configs["Statistics.Binary"]; + if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) + { + if (statConfig.Contains("collect_region_stats")) + { + if (statConfig.GetBoolean("collect_region_stats")) + { + // if enabled, add us to the event. If not enabled, I won't get called + StatsReporter.OnSendStatsResult += LogSimStats; + } + } + if (statConfig.Contains("region_stats_period_seconds")) + { + m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); + } + if (statConfig.Contains("stats_dir")) + { + m_statsDir = statConfig.GetString("stats_dir"); + } + } + } + catch + { + // if it doesn't work, we don't collect anything + } + + #endregion BinaryStats } catch { -- cgit v1.1 From afef1ac191d32e9c1514c294b17e404b1d4ae217 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 13:10:58 -0800 Subject: Changing the AssetBase constructors to avoid initializing assets with an unknown asset type, and log an error if it ever does happen --- .../RemoteController/RemoteAdminPlugin.cs | 5 +-- .../Rest/Inventory/RestAssetServices.cs | 10 ++---- .../Rest/Inventory/RestInventoryServices.cs | 3 +- OpenSim/Data/MSSQL/MSSQLAssetData.cs | 9 ++--- OpenSim/Data/MySQL/MySQLAssetData.cs | 5 +-- OpenSim/Data/SQLite/SQLiteAssetData.cs | 9 ++--- OpenSim/Data/Tests/BasicAssetTest.cs | 6 ++-- OpenSim/Data/Tests/PropertyCompareConstraint.cs | 12 +++---- OpenSim/Data/Tests/PropertyScrambler.cs | 5 ++- OpenSim/Framework/AssetBase.cs | 42 ++++++++++++++++++---- OpenSim/Framework/AssetLandmark.cs | 4 +-- .../Filesystem/AssetLoaderFileSystem.cs | 21 ++++++----- OpenSim/Framework/Capabilities/Caps.cs | 5 +-- OpenSim/Framework/Tests/AssetBaseTest.cs | 3 +- .../Region/ClientStack/LindenUDP/LLFileTransfer.cs | 5 +-- .../Agent/AssetTransaction/AssetXferUploader.cs | 5 +-- .../Agent/TextureSender/J2KDecoderModule.cs | 7 ++-- .../Archiver/InventoryArchiveReadRequest.cs | 7 ++-- .../Archiver/Tests/InventoryArchiverTests.cs | 3 +- .../DynamicTexture/DynamicTextureModule.cs | 5 +-- .../World/Archiver/ArchiveReadRequest.cs | 6 ++-- .../CoreModules/World/Archiver/AssetsDearchiver.cs | 3 +- .../World/Estate/EstateTerrainXferHandler.cs | 7 +--- .../CoreModules/World/WorldMap/WorldMapModule.cs | 10 +++--- .../Framework/Scenes/Hypergrid/HGAssetMapper.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 5 +-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +--- .../Scripting/Minimodule/Graphics.cs | 5 +-- .../Shared/Api/Implementation/OSSL_Api.cs | 7 ++-- .../Connectors/Asset/AssetServiceConnector.cs | 2 +- .../Connectors/Grid/HypergridServiceConnector.cs | 3 +- 31 files changed, 105 insertions(+), 122 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 3c7727f..3149eaa 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -1562,11 +1562,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController assets = doc.GetElementsByTagName("RequiredAsset"); foreach (XmlNode asset in assets) { - AssetBase rass = new AssetBase(); - rass.FullID = UUID.Random(); - rass.Name = GetStringAttribute(asset,"name",""); + AssetBase rass = new AssetBase(UUID.Random(), GetStringAttribute(asset,"name",""), SByte.Parse(GetStringAttribute(asset,"type",""))); rass.Description = GetStringAttribute(asset,"desc",""); - rass.Type = SByte.Parse(GetStringAttribute(asset,"type","")); rass.Local = Boolean.Parse(GetStringAttribute(asset,"local","")); rass.Temporary = Boolean.Parse(GetStringAttribute(asset,"temporary","")); rass.Data = Convert.FromBase64String(asset.InnerText); diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs index f862af1..66572d5 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs @@ -261,11 +261,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory modified = (asset != null); created = !modified; - asset = new AssetBase(); - asset.FullID = uuid; - asset.Name = xml.GetAttribute("name"); + asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type"))); asset.Description = xml.GetAttribute("desc"); - asset.Type = SByte.Parse(xml.GetAttribute("type")); asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); @@ -341,11 +338,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory modified = (asset != null); created = !modified; - asset = new AssetBase(); - asset.FullID = uuid; - asset.Name = xml.GetAttribute("name"); + asset = new AssetBase(uuid, xml.GetAttribute("name"), SByte.Parse(xml.GetAttribute("type"))); asset.Description = xml.GetAttribute("desc"); - asset.Type = SByte.Parse(xml.GetAttribute("type")); asset.Local = Int32.Parse(xml.GetAttribute("local")) != 0; asset.Temporary = Int32.Parse(xml.GetAttribute("temporary")) != 0; asset.Data = Convert.FromBase64String(xml.ReadElementContentAsString("Asset", "")); diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index 4e03e67..01bfe00 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs @@ -1869,10 +1869,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // Create AssetBase entity to hold the inlined asset - asset = new AssetBase(uuid, name); + asset = new AssetBase(uuid, name, type); asset.Description = desc; - asset.Type = type; // type == 0 == texture asset.Local = local; asset.Temporary = temp; diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index 25f7cf0..1ce4abf 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs @@ -132,12 +132,13 @@ namespace OpenSim.Data.MSSQL { if (reader.Read()) { - AssetBase asset = new AssetBase(); + AssetBase asset = new AssetBase( + new UUID((Guid)reader["id"]), + (string)reader["name"], + Convert.ToSByte(reader["assetType"]) + ); // Region Main - asset.FullID = new UUID((Guid)reader["id"]); - asset.Name = (string)reader["name"]; asset.Description = (string)reader["description"]; - asset.Type = Convert.ToSByte(reader["assetType"]); asset.Local = Convert.ToBoolean(reader["local"]); asset.Temporary = Convert.ToBoolean(reader["temporary"]); asset.Data = (byte[])reader["data"]; diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 1fe6d29..6a4ccd7 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -151,10 +151,9 @@ namespace OpenSim.Data.MySQL { if (dbReader.Read()) { - asset = new AssetBase(); + asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["assetType"]); asset.Data = (byte[]) dbReader["data"]; asset.Description = (string) dbReader["description"]; - asset.FullID = assetID; string local = dbReader["local"].ToString(); if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) @@ -162,8 +161,6 @@ namespace OpenSim.Data.MySQL else asset.Local = false; - asset.Name = (string) dbReader["name"]; - asset.Type = (sbyte) dbReader["assetType"]; asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); } dbReader.Close(); diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 49275cb..11be28e 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -231,12 +231,13 @@ namespace OpenSim.Data.SQLite // TODO: this doesn't work yet because something more // interesting has to be done to actually get these values // back out. Not enough time to figure it out yet. - AssetBase asset = new AssetBase(); + AssetBase asset = new AssetBase( + new UUID((String)row["UUID"]), + (String)row["Name"], + Convert.ToSByte(row["Type"]) + ); - asset.FullID = new UUID((String) row["UUID"]); - asset.Name = (String) row["Name"]; asset.Description = (String) row["Description"]; - asset.Type = Convert.ToSByte(row["Type"]); asset.Local = Convert.ToBoolean(row["Local"]); asset.Temporary = Convert.ToBoolean(row["Temporary"]); asset.Data = (byte[]) row["Data"]; diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs index 1969d76..25aed61 100644 --- a/OpenSim/Data/Tests/BasicAssetTest.cs +++ b/OpenSim/Data/Tests/BasicAssetTest.cs @@ -66,9 +66,9 @@ namespace OpenSim.Data.Tests [Test] public void T010_StoreSimpleAsset() { - AssetBase a1 = new AssetBase(uuid1, "asset one"); - AssetBase a2 = new AssetBase(uuid2, "asset two"); - AssetBase a3 = new AssetBase(uuid3, "asset three"); + AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture); + AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture); a1.Data = asset1; a2.Data = asset1; a3.Data = asset1; diff --git a/OpenSim/Data/Tests/PropertyCompareConstraint.cs b/OpenSim/Data/Tests/PropertyCompareConstraint.cs index 06ca53e..5b1f935 100644 --- a/OpenSim/Data/Tests/PropertyCompareConstraint.cs +++ b/OpenSim/Data/Tests/PropertyCompareConstraint.cs @@ -297,8 +297,8 @@ namespace OpenSim.Data.Tests public void AssetShouldMatch() { UUID uuid1 = UUID.Random(); - AssetBase actual = new AssetBase(uuid1, "asset one"); - AssetBase expected = new AssetBase(uuid1, "asset one"); + AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase expected = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); var constraint = Constraints.PropertyCompareConstraint(expected); @@ -309,8 +309,8 @@ namespace OpenSim.Data.Tests public void AssetShouldNotMatch() { UUID uuid1 = UUID.Random(); - AssetBase actual = new AssetBase(uuid1, "asset one"); - AssetBase expected = new AssetBase(UUID.Random(), "asset one"); + AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase expected = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); var constraint = Constraints.PropertyCompareConstraint(expected); @@ -321,8 +321,8 @@ namespace OpenSim.Data.Tests public void AssetShouldNotMatch2() { UUID uuid1 = UUID.Random(); - AssetBase actual = new AssetBase(uuid1, "asset one"); - AssetBase expected = new AssetBase(uuid1, "asset two"); + AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture); + AssetBase expected = new AssetBase(uuid1, "asset two", (sbyte)AssetType.Texture); var constraint = Constraints.PropertyCompareConstraint(expected); diff --git a/OpenSim/Data/Tests/PropertyScrambler.cs b/OpenSim/Data/Tests/PropertyScrambler.cs index 72aaff1..c968364 100644 --- a/OpenSim/Data/Tests/PropertyScrambler.cs +++ b/OpenSim/Data/Tests/PropertyScrambler.cs @@ -165,7 +165,7 @@ namespace OpenSim.Data.Tests [Test] public void TestScramble() { - AssetBase actual = new AssetBase(UUID.Random(), "asset one"); + AssetBase actual = new AssetBase(UUID.Random(), "asset one", (sbyte)AssetType.Texture); new PropertyScrambler().Scramble(actual); } @@ -173,8 +173,7 @@ namespace OpenSim.Data.Tests public void DontScramble() { UUID uuid = UUID.Random(); - AssetBase asset = new AssetBase(); - asset.FullID = uuid; + AssetBase asset = new AssetBase(uuid, "asset", (sbyte)AssetType.Texture); new PropertyScrambler() .DontScramble(x => x.Metadata) .DontScramble(x => x.FullID) diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 9679ff2..eed9703 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -27,6 +27,8 @@ using System; using System.Xml.Serialization; +using System.Reflection; +using log4net; using OpenMetaverse; namespace OpenSim.Framework @@ -37,6 +39,8 @@ namespace OpenSim.Framework [Serializable] public class AssetBase { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// /// Data of the Asset /// @@ -47,16 +51,34 @@ namespace OpenSim.Framework /// private AssetMetadata m_metadata; - public AssetBase() + public AssetBase(UUID assetID, string name, sbyte assetType) { + if (assetType == (sbyte)AssetType.Unknown) + { + System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true); + m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}", + name, assetID, trace.ToString()); + } + m_metadata = new AssetMetadata(); + m_metadata.FullID = assetID; + m_metadata.Name = name; + m_metadata.Type = assetType; } - public AssetBase(UUID assetId, string name) + public AssetBase(string assetID, string name, sbyte assetType) { + if (assetType == (sbyte)AssetType.Unknown) + { + System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true); + m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}", + name, assetID, trace.ToString()); + } + m_metadata = new AssetMetadata(); - m_metadata.FullID = assetId; + m_metadata.ID = assetID; m_metadata.Name = name; + m_metadata.Type = assetType; } public bool ContainsReferences @@ -193,11 +215,11 @@ namespace OpenSim.Framework private string m_name = String.Empty; private string m_description = String.Empty; private DateTime m_creation_date; - private sbyte m_type; + private sbyte m_type = (sbyte)AssetType.Unknown; private string m_content_type; private byte[] m_sha1; - private bool m_local = false; - private bool m_temporary = false; + private bool m_local; + private bool m_temporary; //private Dictionary m_methods = new Dictionary(); //private OSDMap m_extra_data; @@ -211,7 +233,13 @@ namespace OpenSim.Framework { //get { return m_fullid.ToString(); } //set { m_fullid = new UUID(value); } - get { return m_id; } + get + { + if (String.IsNullOrEmpty(m_id)) + m_id = m_fullid.ToString(); + + return m_id; + } set { UUID uuid = UUID.Zero; diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs index fd7a2cd..058b442 100644 --- a/OpenSim/Framework/AssetLandmark.cs +++ b/OpenSim/Framework/AssetLandmark.cs @@ -38,11 +38,9 @@ namespace OpenSim.Framework public int Version; public AssetLandmark(AssetBase a) + : base(a.FullID, a.Name, a.Type) { Data = a.Data; - FullID = a.FullID; - Type = a.Type; - Name = a.Name; Description = a.Description; InternData(); } diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index a394b1a..9497a2e 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs @@ -43,18 +43,15 @@ namespace OpenSim.Framework.AssetLoader.Filesystem { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected static AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage) + protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type) { - AssetBase asset = new AssetBase( - new UUID(assetIdStr), - name - ); + AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type); if (!String.IsNullOrEmpty(path)) { //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path); - LoadAsset(asset, isImage, path); + LoadAsset(asset, path); } else { @@ -64,8 +61,14 @@ namespace OpenSim.Framework.AssetLoader.Filesystem return asset; } - protected static void LoadAsset(AssetBase info, bool image, string path) + protected static void LoadAsset(AssetBase info, string path) { + bool image = + (info.Type == (sbyte)AssetType.Texture || + info.Type == (sbyte)AssetType.TextureTGA || + info.Type == (sbyte)AssetType.ImageJPEG || + info.Type == (sbyte)AssetType.ImageTGA); + FileInfo fInfo = new FileInfo(path); long numBytes = fInfo.Length; if (fInfo.Exists) @@ -138,10 +141,10 @@ namespace OpenSim.Framework.AssetLoader.Filesystem { string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString()); string name = source.Configs[i].GetString("name", String.Empty); - sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); + sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0); string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty)); - AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false); + AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, type); newAsset.Type = type; assets.Add(newAsset); diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index ccfe800..72231ca 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -888,10 +888,7 @@ namespace OpenSim.Framework.Capabilities } AssetBase asset; - asset = new AssetBase(); - asset.FullID = assetID; - asset.Type = assType; - asset.Name = assetName; + asset = new AssetBase(assetID, assetName, assType); asset.Data = data; if (AddNewAsset != null) AddNewAsset(asset); diff --git a/OpenSim/Framework/Tests/AssetBaseTest.cs b/OpenSim/Framework/Tests/AssetBaseTest.cs index 3dc6b4e..18a3e01 100644 --- a/OpenSim/Framework/Tests/AssetBaseTest.cs +++ b/OpenSim/Framework/Tests/AssetBaseTest.cs @@ -67,8 +67,7 @@ namespace OpenSim.Framework.Tests private void CheckContainsReferences(AssetType assetType, bool expected) { - AssetBase asset = new AssetBase(); - asset.Type = (sbyte)assetType; + AssetBase asset = new AssetBase(UUID.Zero, String.Empty, (sbyte)assetType); bool actual = asset.ContainsReferences; Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+"."); } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs index 697bbe6..adf171e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLFileTransfer.cs @@ -197,11 +197,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void Initialise(UUID fileID, string fileName) { - m_asset = new AssetBase(); - m_asset.FullID = fileID; - m_asset.Type = type; + m_asset = new AssetBase(fileID, fileName, type); m_asset.Data = new byte[0]; - m_asset.Name = fileName; m_asset.Description = "empty"; m_asset.Local = true; m_asset.Temporary = true; diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index e192b81..f698ea1 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -112,11 +112,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction bool storeLocal, bool tempFile) { ourClient = remoteClient; - m_asset = new AssetBase(); - m_asset.FullID = assetID; - m_asset.Type = type; + m_asset = new AssetBase(assetID, "blank", type); m_asset.Data = data; - m_asset.Name = "blank"; m_asset.Description = "empty"; m_asset.Local = storeLocal; m_asset.Temporary = tempFile; diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 7456e8c..5fde35f 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -238,12 +238,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender if (m_cache != null) { - AssetBase layerDecodeAsset = new AssetBase(); - layerDecodeAsset.ID = "j2kCache_" + AssetId.ToString(); + string assetID = "j2kCache_" + AssetId.ToString(); + + AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard); layerDecodeAsset.Local = true; - layerDecodeAsset.Name = layerDecodeAsset.ID; layerDecodeAsset.Temporary = true; - layerDecodeAsset.Type = (sbyte)AssetType.Notecard; #region Serialize Layer Data diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f761bf0..a4445eb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -389,11 +389,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; - //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); + if (assetType == (sbyte)AssetType.Unknown) + m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); - AssetBase asset = new AssetBase(new UUID(uuid), "RandomName"); + //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - asset.Type = assetType; + AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType); asset.Data = data; m_scene.AssetService.Store(asset); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index b0fdcd6..8ee9194 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -122,8 +122,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = new AssetBase(); - asset1.FullID = asset1Id; + AssetBase asset1 = new AssetBase(asset1Id, asset1Id.ToString(), (sbyte)AssetType.Object); asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); scene.AssetService.Store(asset1); diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 9a6c49a..43761fc 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -311,11 +311,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } // Create a new asset for user - AssetBase asset = new AssetBase(); - asset.FullID = UUID.Random(); + AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture); asset.Data = assetData; - asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); - asset.Type = 0; asset.Description = String.Format("URL image : {0}", Url); asset.Local = false; asset.Temporary = ((Disp & DISP_TEMP) != 0); diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index c261943..70a225e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -332,10 +332,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; + if (assetType == (sbyte)AssetType.Unknown) + m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); + //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), String.Empty); - asset.Type = assetType; + AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType); asset.Data = data; // We're relying on the asset service to do the sensible thing and not store the asset if it already diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs index 5208e7a..2d2c570 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs @@ -158,9 +158,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); - AssetBase asset = new AssetBase(new UUID(filename), metadata.Name); + AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType); asset.Description = metadata.Description; - asset.Type = metadata.AssetType; asset.Data = data; m_cache.Store(asset); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index ddac515..2ff635b 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs @@ -52,16 +52,11 @@ namespace OpenSim.Region.CoreModules.World.Estate public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) { - - m_asset = new AssetBase(); - m_asset.FullID = UUID.Zero; - m_asset.Type = type; + m_asset = new AssetBase(UUID.Zero, pClientFilename, type); m_asset.Data = new byte[0]; - m_asset.Name = pClientFilename; m_asset.Description = "empty"; m_asset.Local = true; m_asset.Temporary = true; - } public ulong XferID diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index f4b54aa..44a651f 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1077,14 +1077,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scene.RegionInfo.RegionSettings.TerrainImageID = TerrainImageUUID; - AssetBase asset = new AssetBase(); - asset.FullID = m_scene.RegionInfo.RegionSettings.TerrainImageID; + AssetBase asset = new AssetBase( + m_scene.RegionInfo.RegionSettings.TerrainImageID, + "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(), + (sbyte)AssetType.Texture); asset.Data = data; - asset.Name - = "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(); asset.Description = m_scene.RegionInfo.RegionName; - - asset.Type = 0; asset.Temporary = temporary; m_scene.AssetService.Store(asset); } diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 7a66d23..ec50598 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid // HGAssetService dispatches it to the remote grid. // It's not pretty, but the best that can be done while // not having a global naming infrastructure - AssetBase asset1 = new AssetBase(); + AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); Copy(asset, asset1); try { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 00743fc..6b2c7d3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -627,11 +627,8 @@ namespace OpenSim.Region.Framework.Scenes /// private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) { - AssetBase asset = new AssetBase(); - asset.Name = name; + AssetBase asset = new AssetBase(UUID.Random(), name, assetType); asset.Description = description; - asset.Type = assetType; - asset.FullID = UUID.Random(); asset.Data = (data == null) ? new byte[1] : data; return asset; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1e9201e..17026e5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1918,14 +1918,10 @@ namespace OpenSim.Region.Framework.Scenes } - AssetBase Animasset = new AssetBase(); + AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); Animasset.Data = anim.ToBytes(); Animasset.Temporary = true; Animasset.Local = true; - Animasset.FullID = UUID.Random(); - Animasset.ID = Animasset.FullID.ToString(); - Animasset.Name = "Random Animation"; - Animasset.Type = (sbyte)AssetType.Animation; Animasset.Description = "dance"; //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 963cab5..8ea7ad3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -49,11 +49,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) { - AssetBase asset = new AssetBase(); - asset.FullID = UUID.Random(); + AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture); asset.Data = OpenJPEG.EncodeFromImage(data, lossless); - asset.Name = "MRMDynamicImage"; - asset.Type = 0; asset.Description = "MRM Image"; asset.Local = false; asset.Temporary = temporary; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f1ceb80..f7ee3d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1483,12 +1483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); // Create new asset - AssetBase asset = new AssetBase(); - asset.Name = notecardName; + AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard); asset.Description = "Script Generated Notecard"; - asset.Type = 7; - asset.FullID = UUID.Random(); - string notecardData = ""; + string notecardData = String.Empty; for (int i = 0; i < contents.Length; i++) { notecardData += contents.GetLSLStringItem(i) + "\n"; diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index ecda85a..8e311d7 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs @@ -243,7 +243,7 @@ namespace OpenSim.Services.Connectors if (metadata == null) return false; - asset = new AssetBase(); + asset = new AssetBase(metadata.FullID, metadata.Name, metadata.Type); asset.Metadata = metadata; } asset.Data = data; diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs index 3d7f112..2f33bab 100644 --- a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs @@ -140,12 +140,11 @@ namespace OpenSim.Services.Connectors.Grid Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); byte[] imageData = OpenJPEG.EncodeFromImage(m, true); - AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); + AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString(), (sbyte)AssetType.Texture); // !!! for now //info.RegionSettings.TerrainImageID = ass.FullID; - ass.Type = (int)AssetType.Texture; ass.Temporary = true; ass.Local = true; ass.Data = imageData; -- cgit v1.1 From 6ed57814c1db72463acc3c5fca154a289eee433e Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 23:50:17 -0800 Subject: * Clamp the CoarseLocationUpdate packet at a maximum of 60 positions per packet. This is a limitation of LLUDP, nothing we can really do about it * Marking CoarseLocationUpdate as *not* zerocoded. Zerocoding can only save space when a packet contains three or more contiguous zeroes, and will use more space if it contains single zeroes randomly scattered through the packet (which is what you see when you send a long list of UUIDs) --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 101a44b..35ccad9 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -3196,12 +3196,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!IsActive) return; // We don't need to update inactive clients. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); - // TODO: don't create new blocks if recycling an old packet - int total = CoarseLocations.Count; - CoarseLocationUpdatePacket.IndexBlock ib = - new CoarseLocationUpdatePacket.IndexBlock(); + loc.Header.Reliable = false; + + // Each packet can only hold around 62 avatar positions and the client clears the mini-map each time + // a CoarseLocationUpdate packet is received. Oh well. + int total = Math.Min(CoarseLocations.Count, 60); + + CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock(); + loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total]; + int selfindex = -1; for (int i = 0; i < total; i++) { @@ -3211,18 +3216,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP lb.X = (byte)CoarseLocations[i].X; lb.Y = (byte)CoarseLocations[i].Y; - lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25); + lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f); loc.Location[i] = lb; loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock(); loc.AgentData[i].AgentID = users[i]; if (users[i] == AgentId) selfindex = i; } + ib.You = (short)selfindex; ib.Prey = -1; loc.Index = ib; - loc.Header.Reliable = false; - loc.Header.Zerocoded = true; OutPacket(loc, ThrottleOutPacketType.Task); } -- cgit v1.1 From 1cddc850783c4dcf49ca3cd845fdc811ffb20dea Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 6 Nov 2009 00:06:49 -0800 Subject: Fixing the build break --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 41bb9dc..e300eb1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -337,8 +337,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = new AssetBase(); - asset1.FullID = asset1Id; + AssetBase asset1 = new AssetBase(asset1Id, String.Empty, (sbyte)AssetType.Object); asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); scene.AssetService.Store(asset1); -- cgit v1.1 From 5300e8506da657118dbde8c9edc9a00db28bc4ac Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Nov 2009 10:33:49 +0000 Subject: Reintroduce AssetBase's old behavior. A Parameterless constructor is required for .NET serialization and removing it breaks the OpenSim asset server protocol. --- OpenSim/Framework/AssetBase.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index eed9703..212f41d 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -51,6 +51,16 @@ namespace OpenSim.Framework /// private AssetMetadata m_metadata; + // This is needed for .NET serialization!!! + // Do NOT "Optimize" away! + public AssetBase() + { + m_metadata = new AssetMetadata(); + m_metadata.FullID = UUID.Zero; + m_metadata.ID = UUID.Zero.ToString(); + m_metadata.Type = (sbyte)AssetType.Unknown; + } + public AssetBase(UUID assetID, string name, sbyte assetType) { if (assetType == (sbyte)AssetType.Unknown) -- cgit v1.1 From 81c439bcaadee10a89e74cb65217c7910d943741 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Nov 2009 20:36:00 +0000 Subject: Patch from Snoopy2. Fixes Mantis #4342 fixes problems when group owned land was abandoned by the land owner or reclaimed by the estate manager or by god. Beside that this new patch makes it possible, that users can buy land directly for a group, if the buyer has the required permissions. --- .../CoreModules/World/Land/LandManagementModule.cs | 11 ++++-- .../Region/CoreModules/World/Land/LandObject.cs | 40 +++++++++++++++++++--- OpenSim/Region/Framework/Interfaces/ILandObject.cs | 1 + 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 93a949a..968f46a 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -1059,9 +1059,11 @@ namespace OpenSim.Region.CoreModules.World.Land if (m_scene.Permissions.IsGod(remote_client.AgentId)) { land.LandData.OwnerID = ownerID; + land.LandData.GroupID = UUID.Zero; + land.LandData.IsGroupOwned = false; m_scene.ForEachClient(SendParcelOverlay); - land.SendLandUpdateToClient(remote_client); + land.SendLandUpdateToClient(true, remote_client); } } } @@ -1082,8 +1084,10 @@ namespace OpenSim.Region.CoreModules.World.Land land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; else land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + land.LandData.GroupID = UUID.Zero; + land.LandData.IsGroupOwned = false; m_scene.ForEachClient(SendParcelOverlay); - land.SendLandUpdateToClient(remote_client); + land.SendLandUpdateToClient(true, remote_client); } } } @@ -1105,9 +1109,10 @@ namespace OpenSim.Region.CoreModules.World.Land else land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; land.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); + land.LandData.GroupID = UUID.Zero; land.LandData.IsGroupOwned = false; m_scene.ForEachClient(SendParcelOverlay); - land.SendLandUpdateToClient(remote_client); + land.SendLandUpdateToClient(true, remote_client); } } } diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index bfe85f1..0bd225e 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -49,6 +49,8 @@ namespace OpenSim.Region.CoreModules.World.Land #pragma warning restore 0429 private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; + private int m_lastSeqId = 0; + protected LandData m_landData = new LandData(); protected Scene m_scene; protected List primsOverMe = new List(); @@ -81,6 +83,10 @@ namespace OpenSim.Region.CoreModules.World.Land { m_scene = scene; LandData.OwnerID = owner_id; + if (is_group_owned) + LandData.GroupID = owner_id; + else + LandData.GroupID = UUID.Zero; LandData.IsGroupOwned = is_group_owned; } @@ -172,7 +178,19 @@ namespace OpenSim.Region.CoreModules.World.Land // regionFlags |= (uint)RegionFlags.AllowLandmark; // if (landData.OwnerID == remote_client.AgentId) // regionFlags |= (uint)RegionFlags.AllowSetHome; - remote_client.SendLandProperties(sequence_id, + + int seq_id; + if (snap_selection && (sequence_id == 0)) + { + seq_id = m_lastSeqId; + } + else + { + seq_id = sequence_id; + m_lastSeqId = seq_id; + } + + remote_client.SendLandProperties(seq_id, snap_selection, request_result, LandData, (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, GetParcelMaxPrimCount(this), @@ -184,6 +202,7 @@ namespace OpenSim.Region.CoreModules.World.Land if (m_scene.Permissions.CanEditParcel(remote_client.AgentId,this)) { //Needs later group support + bool snap_selection = false; LandData newData = LandData.Copy(); if (args.AuthBuyerID != newData.AuthBuyerID || args.SalePrice != newData.SalePrice) @@ -192,6 +211,7 @@ namespace OpenSim.Region.CoreModules.World.Land { newData.AuthBuyerID = args.AuthBuyerID; newData.SalePrice = args.SalePrice; + snap_selection = true; } } newData.Category = args.Category; @@ -212,7 +232,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - SendLandUpdateToAvatarsOverMe(); + SendLandUpdateToAvatarsOverMe(snap_selection); } } @@ -230,7 +250,7 @@ namespace OpenSim.Region.CoreModules.World.Land newData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects); m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - SendLandUpdateToAvatarsOverMe(); + SendLandUpdateToAvatarsOverMe(true); } public void DeedToGroup(UUID groupID) @@ -242,7 +262,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_scene.LandChannel.UpdateLandObject(LandData.LocalID, newData); - SendLandUpdateToAvatarsOverMe(); + SendLandUpdateToAvatarsOverMe(true); } public bool IsEitherBannedOrRestricted(UUID avatar) @@ -297,8 +317,18 @@ namespace OpenSim.Region.CoreModules.World.Land SendLandProperties(0, false, 0, remote_client); } + public void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client) + { + SendLandProperties(0, snap_selection, 0, remote_client); + } + public void SendLandUpdateToAvatarsOverMe() { + SendLandUpdateToAvatarsOverMe(false); + } + + public void SendLandUpdateToAvatarsOverMe(bool snap_selection) + { List avatars = m_scene.GetAvatars(); ILandObject over = null; for (int i = 0; i < avatars.Count; i++) @@ -325,7 +355,7 @@ namespace OpenSim.Region.CoreModules.World.Land else avatars[i].Invulnerable = true; - SendLandUpdateToClient(avatars[i].ControllingClient); + SendLandUpdateToClient(snap_selection, avatars[i].ControllingClient); } } } diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs index c2b1292..084184f 100644 --- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs +++ b/OpenSim/Region/Framework/Interfaces/ILandObject.cs @@ -54,6 +54,7 @@ namespace OpenSim.Region.Framework.Interfaces bool IsBannedFromLand(UUID avatar); bool IsRestrictedFromLand(UUID avatar); void SendLandUpdateToClient(IClientAPI remote_client); + void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); List CreateAccessListArrayByFlag(AccessList flag); void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); void UpdateAccessList(uint flags, List entries, IClientAPI remote_client); -- cgit v1.1 From aff5fe10b0ad95489909f74f9ee2f6bb85f3d338 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Nov 2009 22:29:36 +0000 Subject: test commit with debug output per folder fetch. NOT FOR PRODUCTION, SPEWY --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 35ccad9..06ce79d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1255,6 +1255,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP List folders, int version, bool fetchFolders, bool fetchItems) { + m_log.DebugFormat("[CLIENT]: Request folder details for folder {0}", folderID.ToString()); // An inventory descendents packet consists of a single agent section and an inventory details // section for each inventory item. The size of each inventory item is approximately 550 bytes. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent -- cgit v1.1 From f8bcbe5492330bd14ecec76f11e3a33ea4fd6ef6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 8 Nov 2009 22:39:00 +0000 Subject: remove the debug stuff --- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 06ce79d..35ccad9 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1255,7 +1255,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP List folders, int version, bool fetchFolders, bool fetchItems) { - m_log.DebugFormat("[CLIENT]: Request folder details for folder {0}", folderID.ToString()); // An inventory descendents packet consists of a single agent section and an inventory details // section for each inventory item. The size of each inventory item is approximately 550 bytes. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent -- cgit v1.1 From 668850b974fba428a527c01249e8e76619461d23 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 15:49:09 +0000 Subject: * for iars, allow item names/folders including "/" to be escaped using "\/" * also, "\" has to be escaped as "\\" * add item name unit test for escaped characters --- .../Inventory/Archiver/InventoryArchiveUtils.cs | 83 +++++++++++++++++++++- .../Archiver/Tests/InventoryArchiverTests.cs | 8 ++- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 1 - 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index a822d10..e297c37 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -27,6 +27,9 @@ using System; using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Services.Interfaces; @@ -38,6 +41,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static class InventoryArchiveUtils { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public static readonly string PATH_DELIMITER = "/"; /// @@ -181,10 +186,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public static InventoryItemBase FindItemByPath( IInventoryService inventoryService, InventoryFolderBase startFolder, string path) { - string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + string[] components = SplitEscapedPath(path); + components[0] = UnescapePath(components[0]); + + //string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); if (components.Length == 1) { +// m_log.DebugFormat("FOUND SINGLE COMPONENT [{0}]", components[0]); + List items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); foreach (InventoryItemBase item in items) { @@ -194,6 +204,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } else { +// m_log.DebugFormat("FOUND COMPONENTS [{0}] and [{1}]", components[0], components[1]); + InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); foreach (InventoryFolderBase folder in contents.Folders) @@ -206,5 +218,74 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // We didn't find an item or intermediate folder with the given name return null; } + + /// + /// Split a human escaped path into two components if it contains an unescaped path delimiter, or one component + /// if no delimiter is present + /// + /// + /// + /// The split path. We leave the components in their originally unescaped state (though we remove the delimiter + /// which originally split them if applicable). + /// + public static string[] SplitEscapedPath(string path) + { +// m_log.DebugFormat("SPLITTING PATH {0}", path); + + bool singleEscapeChar = false; + + for (int i = 0; i < path.Length; i++) + { + if (path[i] == '\\' && !singleEscapeChar) + { + singleEscapeChar = true; + } + else + { + if (PATH_DELIMITER == path[i].ToString() && !singleEscapeChar) + return new string[2] { path.Remove(i), path.Substring(i + 1) }; + else + singleEscapeChar = false; + } + } + + // We didn't find a delimiter + return new string[1] { path }; + } + + /// + /// Unescapes a human escaped path. This means that "\\" goes to "\", and "\/" goes to "/" + /// + /// + /// + public static string UnescapePath(string path) + { +// m_log.DebugFormat("ESCAPING PATH {0}", path); + + StringBuilder sb = new StringBuilder(); + + bool singleEscapeChar = false; + for (int i = 0; i < path.Length; i++) + { + if (path[i] == '\\' && !singleEscapeChar) + singleEscapeChar = true; + else + singleEscapeChar = false; + + if (singleEscapeChar) + { + if (PATH_DELIMITER == path[i].ToString()) + sb.Append(PATH_DELIMITER); + } + else + { + sb.Append(path[i]); + } + } + +// m_log.DebugFormat("ESCAPED PATH TO {0}", sb); + + return sb.ToString(); + } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index c366150..bcae5f5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -296,7 +296,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests TestHelper.InMethod(); log4net.Config.XmlConfigurator.Configure(); - string itemName = "You & you are a mean man"; + string itemName = "You & you are a mean/man/"; + string humanEscapedItemName = @"You & you are a mean\/man\/"; string userPassword = "meowfood"; InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); @@ -362,7 +363,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); mre.WaitOne(60000, false); - /// LOAD ITEM + // LOAD ITEM MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); @@ -371,7 +372,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userId, "Scripts/Objects/" + itemName); + = InventoryArchiveUtils.FindItemByPath( + scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); // Assert.That( diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 00743fc..c689aba 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -93,7 +93,6 @@ namespace OpenSim.Region.Framework.Scenes public void AddInventoryItem(UUID AgentID, InventoryItemBase item) { - if (InventoryService.AddItem(item)) { int userlevel = 0; -- cgit v1.1 From 9b2592a9609edffb132138ce96537f5c7de1a024 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 15:54:43 +0000 Subject: refactor: make human iar escape char a constant rather than a magic char --- .../Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index e297c37..5c31c26 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -42,7 +42,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public static class InventoryArchiveUtils { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + + // Character used for escaping the path delimter ("\/") and itself ("\\") in human escaped strings + public static readonly char ESCAPE_CHARACTER = '\\'; public static readonly string PATH_DELIMITER = "/"; /// @@ -236,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver for (int i = 0; i < path.Length; i++) { - if (path[i] == '\\' && !singleEscapeChar) + if (path[i] == ESCAPE_CHARACTER && !singleEscapeChar) { singleEscapeChar = true; } @@ -267,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver bool singleEscapeChar = false; for (int i = 0; i < path.Length; i++) { - if (path[i] == '\\' && !singleEscapeChar) + if (path[i] == ESCAPE_CHARACTER && !singleEscapeChar) singleEscapeChar = true; else singleEscapeChar = false; -- cgit v1.1 From a7af92d5d025b3d1522be94fea8c0f64237a352e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 16:03:15 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | 4 ++-- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 2 +- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | 2 +- .../ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs | 2 +- .../Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 7456e8c..13fbb60 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -144,8 +144,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender /// JPEG2000 data private void DoJ2KDecode(UUID assetID, byte[] j2kData) { - int DecodeTime = 0; - DecodeTime = Environment.TickCount; +// int DecodeTime = 0; +// DecodeTime = Environment.TickCount; OpenJPEG.J2KLayerInfo[] layers; if (!TryLoadCacheForAsset(assetID, out layers)) diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index c6af806..adcf6bd 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -831,7 +831,7 @@ namespace Flotsam.RegionModules.AssetCache public string Store(AssetBase asset) { - if ((asset.FullID == null) || (asset.FullID == UUID.Zero)) + if (asset.FullID == UUID.Zero) { asset.FullID = UUID.Random(); } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 5c31c26..7e72ca0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -41,7 +41,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static class InventoryArchiveUtils { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // Character used for escaping the path delimter ("\/") and itself ("\\") in human escaped strings public static readonly char ESCAPE_CHARACTER = '\\'; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index 92db15b..b12d778 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid m_log.Info("[HypergridService]: Starting..."); - Object[] args = new Object[] { m_Config, MainServer.Instance }; +// Object[] args = new Object[] { m_Config, MainServer.Instance }; m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface()); //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 9c04755..f2d8579 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -336,7 +336,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; - int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; +// int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; @@ -613,7 +613,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); // Set the position of the region on the remote grid - ulong realHandle = FindRegionHandle(regInfo.RegionHandle); +// ulong realHandle = FindRegionHandle(regInfo.RegionHandle); uint x = 0, y = 0; Utils.LongToUInts(regInfo.RegionHandle, out x, out y); GridRegion clonedRegion = new GridRegion(regInfo); -- cgit v1.1 From 6820cc93ec82bc97e59fda2696f07b046e7006e0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 16:08:17 +0000 Subject: refactor path delimiter in iar utils --- .../Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 7e72ca0..0fb5db2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -45,7 +45,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Character used for escaping the path delimter ("\/") and itself ("\\") in human escaped strings public static readonly char ESCAPE_CHARACTER = '\\'; - public static readonly string PATH_DELIMITER = "/"; + + // The character used to separate inventory path components (different folders and items) + public static readonly char PATH_DELIMITER = '/'; /// /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder @@ -110,10 +112,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver path = path.Trim(); - if (path == PATH_DELIMITER) + if (path == PATH_DELIMITER.ToString()) return startFolder; - string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); + string[] components = path.Split(new string[] { PATH_DELIMITER.ToString() }, 2, StringSplitOptions.None); InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); foreach (InventoryFolderBase folder in contents.Folders) @@ -244,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } else { - if (PATH_DELIMITER == path[i].ToString() && !singleEscapeChar) + if (PATH_DELIMITER == path[i] && !singleEscapeChar) return new string[2] { path.Remove(i), path.Substring(i + 1) }; else singleEscapeChar = false; @@ -276,7 +278,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (singleEscapeChar) { - if (PATH_DELIMITER == path[i].ToString()) + if (PATH_DELIMITER == path[i]) sb.Append(PATH_DELIMITER); } else -- cgit v1.1 From a3105a34cad1571ae6ab875be57a9da032bfbe59 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 16:12:13 +0000 Subject: Implement human / escaping for inventory folders as well as items --- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 0fb5db2..78032d1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -115,7 +115,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (path == PATH_DELIMITER.ToString()) return startFolder; - string[] components = path.Split(new string[] { PATH_DELIMITER.ToString() }, 2, StringSplitOptions.None); + string[] components = SplitEscapedPath(path); + components[0] = UnescapePath(components[0]); + + //string[] components = path.Split(new string[] { PATH_DELIMITER.ToString() }, 2, StringSplitOptions.None); + InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); foreach (InventoryFolderBase folder in contents.Folders) -- cgit v1.1 From 678a74e4f70f0ec6bb21406b829db7ea4f5f4bfc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 16:42:17 +0000 Subject: Tell the user when a 'save iar' has failed because the inventory path could not be found --- .../Archiver/InventoryArchiveWriteRequest.cs | 74 ++++++---------------- 1 file changed, 21 insertions(+), 53 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index af0b72f..6c37198 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -217,37 +217,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver InventoryItemBase inventoryItem = null; InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); - // XXX: Very temporarily, drop and refetch inventory to make sure we have any newly created items in cache - // This will disappear very soon once we stop using the old cached inventory. - /* - m_userInfo.DropInventory(); - m_userInfo.FetchInventory(); - */ - - /* - if (!m_userInfo.HasReceivedInventory) - { - // If the region server has access to the user admin service (by which users are created), - // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the - // server. - // - // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might - // use a remote inventory service, though this is vanishingly rare at the moment. - if (null == m_scene.CommsManager.UserAdminService) - { - m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", - m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); - - return; - } - else - { - m_userInfo.FetchInventory(); - } - } - */ - bool foundStar = false; // Eliminate double slashes and any leading / on the path. @@ -294,34 +263,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_archiveWriter = new TarArchiveWriter(m_saveStream); - if (null == inventoryFolder) - { - if (null == inventoryItem) - { - // We couldn't find the path indicated - m_saveStream.Close(); - m_module.TriggerInventoryArchiveSaved( - m_id, false, m_userInfo, m_invPath, m_saveStream, - new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath))); - return; - } - else - { - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", - inventoryItem.Name, inventoryItem.ID, m_invPath); - - SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); - } - } - else + if (inventoryFolder != null) { m_log.DebugFormat( "[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}", inventoryFolder.Name, inventoryFolder.ID, m_invPath); //recurse through all dirs getting dirs and files - SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); + SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); + } + else if (inventoryItem != null) + { + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", + inventoryItem.Name, inventoryItem.ID, m_invPath); + + SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); + } + else + { + // We couldn't find the path indicated + m_saveStream.Close(); + string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath); + m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage); + m_module.TriggerInventoryArchiveSaved( + m_id, false, m_userInfo, m_invPath, m_saveStream, + new Exception(errorMessage)); + return; } // Don't put all this profile information into the archive right now. -- cgit v1.1 From a0c1836fdecf133f15fa8649d0d4ea91548f9049 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 16:43:35 +0000 Subject: minor: remove some old commented out load iar code --- .../Archiver/InventoryArchiveReadRequest.cs | 30 ---------------------- 1 file changed, 30 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 7abaac0..4023c8f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -99,36 +99,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver int failedAssetRestores = 0; int successfulItemRestores = 0; List nodesLoaded = new List(); - - /* - if (!m_userInfo.HasReceivedInventory) - { - // If the region server has access to the user admin service (by which users are created), - // then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the - // server. - // - // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might - // use a remote inventory service, though this is vanishingly rare at the moment. - if (null == m_scene.CommsManager.UserAdminService) - { - m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", - m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID); - - return nodesLoaded; - } - else - { - m_userInfo.FetchInventory(); - for (int i = 0 ; i < 50 ; i++) - { - if (m_userInfo.HasReceivedInventory == true) - break; - Thread.Sleep(200); - } - } - } - */ //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); InventoryFolderBase rootDestinationFolder -- cgit v1.1 From ae92bbcb95a94b71c74d2ff64e76eb2d0e12af7d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:04:05 +0000 Subject: refactor: break actual item load in iar into separate method --- .../Archiver/InventoryArchiveReadRequest.cs | 74 ++++++++++++++-------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 4023c8f..d82d0e3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -138,35 +138,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver rootDestinationFolder, foldersCreated, nodesLoaded); if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) - { - // Escape back characters - filePath = filePath.Replace("/", "/"); - filePath = filePath.Replace("&", "&"); - - InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); - - // Don't use the item ID that's in the file - item.ID = UUID.Random(); - - UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); - if (UUID.Zero != ospResolvedId) - item.CreatorIdAsUuid = ospResolvedId; - else - item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; - - item.Owner = m_userInfo.UserProfile.ID; - - // Reset folder ID to the one in which we want to load it - item.Folder = foundFolder.ID; - - //m_userInfo.AddItem(item); - m_scene.InventoryService.AddItem(item); - successfulItemRestores++; + { + InventoryItemBase item = LoadItem(data, foundFolder); - // If we're loading an item directly into the given destination folder then we need to record - // it separately from any loaded root folders - if (rootDestinationFolder == foundFolder) - nodesLoaded.Add(item); + if (item != null) + { + successfulItemRestores++; + + // If we're loading an item directly into the given destination folder then we need to record + // it separately from any loaded root folders + if (rootDestinationFolder == foundFolder) + nodesLoaded.Add(item); + } } } } @@ -340,6 +323,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } /// + /// Load an item from the archive + /// + /// The archive path for the item + /// The raw item data + /// The root destination folder for loaded items + /// All the inventory nodes (items and folders) loaded so far + protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder) + { + // Escape back characters +// filePath = filePath.Replace("/", "/"); +// filePath = filePath.Replace("&", "&"); + + InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); + + // Don't use the item ID that's in the file + item.ID = UUID.Random(); + + UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); + if (UUID.Zero != ospResolvedId) + item.CreatorIdAsUuid = ospResolvedId; + else + item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; + + item.Owner = m_userInfo.UserProfile.ID; + + // Reset folder ID to the one in which we want to load it + item.Folder = loadFolder.ID; + + //m_userInfo.AddItem(item); + m_scene.InventoryService.AddItem(item); + + return item; + } + + /// /// Load an asset /// /// -- cgit v1.1 From 1afe5a528ce4c4946841ae874a8bae81b27df291 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:09:56 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs index 552cc4a..d2779ba 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs @@ -270,8 +270,8 @@ namespace OpenMetaverse { try { - UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; - int bytesSent = m_udpSocket.EndSendTo(result); +// UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; + m_udpSocket.EndSendTo(result); } catch (SocketException) { } catch (ObjectDisposedException) { } -- cgit v1.1 From fbcf6ffc18e951dac6f2408190206a2a58383222 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:17:25 +0000 Subject: minor: provide updates on number of assets loaded while executing "load iar" --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index d82d0e3..dfae62c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -129,6 +129,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver successfulAssetRestores++; else failedAssetRestores++; + + if ((successfulAssetRestores) % 50 == 0) + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Loaded {0} assets...", + successfulAssetRestores); } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) { @@ -156,8 +161,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver archive.Close(); - m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores); - m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores); + m_log.DebugFormat( + "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", + successfulAssetRestores, failedAssetRestores); + m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); return nodesLoaded; } -- cgit v1.1 From 3c1f50127ca34d0cb88171ecadc2c584b50260ae Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:20:30 +0000 Subject: minor: tweak load iar messages to be slightly less verbose --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index dfae62c..2896566 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -199,7 +199,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string originalArchivePath = archivePath; m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Loading to folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); + "[INVENTORY ARCHIVER]: Loading to folder {0} {1} {2}", + rootDestFolder.Name, rootDestFolder.Name, rootDestFolder.ID); InventoryFolderBase destFolder = null; @@ -210,9 +211,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (foldersCreated.ContainsKey(archivePath)) { - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); - destFolder = foldersCreated[archivePath]; +// m_log.DebugFormat( +// "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); +// destFolder = foldersCreated[archivePath]; } else { -- cgit v1.1 From 7c5dc94cc8d6e5c4fbd3c8ceb49bc7243108815b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:22:18 +0000 Subject: fix load iar regression accidentally introduced in last commit --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 2896566..f8480d3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { // m_log.DebugFormat( // "[INVENTORY ARCHIVER]: Found previously created folder from archive path {0}", archivePath); -// destFolder = foldersCreated[archivePath]; + destFolder = foldersCreated[archivePath]; } else { -- cgit v1.1 From 1ded7edde2a4d031f1b3d6edfa50bb865fa07fc9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:24:06 +0000 Subject: minor: correct slightly over-enthusiastic load iar logging message --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f8480d3..a535633 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -199,8 +199,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string originalArchivePath = archivePath; m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Loading to folder {0} {1} {2}", - rootDestFolder.Name, rootDestFolder.Name, rootDestFolder.ID); + "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); InventoryFolderBase destFolder = null; -- cgit v1.1 From 716f70cd31e6126f8752cb8843cca104ad91d8f6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:34:07 +0000 Subject: refactor out iar escaping --- .../Archiver/InventoryArchiveReadRequest.cs | 9 +-------- .../Inventory/Archiver/InventoryArchiveUtils.cs | 23 ++++++++++++++++++++++ .../Archiver/InventoryArchiveWriteRequest.cs | 11 ++--------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index a535633..0a2e2e4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -254,10 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); - // Escape back characters - newFolderName = newFolderName.Replace("/", "/"); - newFolderName = newFolderName.Replace("&", "&"); - + newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName); UUID newFolderId = UUID.Random(); // Asset type has to be Unknown here rather than Folder, otherwise the created folder can't be @@ -338,10 +335,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// All the inventory nodes (items and folders) loaded so far protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder) { - // Escape back characters -// filePath = filePath.Replace("/", "/"); -// filePath = filePath.Replace("&", "&"); - InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); // Don't use the item ID that's in the file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 78032d1..247cee4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -295,5 +295,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return sb.ToString(); } + + /// + /// Escape an archive path. + /// + /// This has to be done differently from human paths because we can't leave in any "/" characters (due to + /// problems if the archive is built from or extracted to a filesystem + /// + /// + public static string EscapeArchivePath(string path) + { + // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). + return path.Replace("&", "&").Replace("/", "/"); + } + + /// + /// Unescape an archive path. + /// + /// + /// + public static string UnescapeArchivePath(string path) + { + return path.Replace("/", "/").Replace("&", "&"); + } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 6c37198..bbb49f6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -362,13 +362,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static string CreateArchiveFolderName(string name, UUID id) { - // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). - name = name.Replace("&", "&"); - name = name.Replace("/", "/"); - return string.Format( "{0}{1}{2}/", - name, + InventoryArchiveUtils.EscapeArchivePath(name), ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, id); } @@ -381,12 +377,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static string CreateArchiveItemName(string name, UUID id) { - name = name.Replace("&", "&"); - name = name.Replace("/", "/"); - return string.Format( "{0}{1}{2}.xml", - name, + InventoryArchiveUtils.EscapeArchivePath(name), ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, id); } -- cgit v1.1 From 3274bc39c8e0c477485c03b31acbe3a9bde0c37e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 17:43:32 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | 2 ++ OpenSim/Region/Physics/Meshing/PrimMesher.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index cbe73bb..1e94ee2 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -347,6 +347,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin { indexBase = mesh.getIndexListAsInt(); vertexBase = new Vector3[iVertexCount]; + for (int i = 0; i < iVertexCount; i++) { OpenMetaverse.Vector3 v = mesh.getVertexList()[i]; @@ -355,6 +356,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin else vertexBase[i] = Vector3.Zero; } + for (int ix = 0; ix < iIndexCount; ix += 3) { int ia = indexBase[ix + 0]; diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index c7c9160..2a213c3 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs @@ -1348,7 +1348,7 @@ namespace PrimMesher float stepSize = twoPi / this.stepsPerRevolution; int step = (int)(startAngle / stepSize); - int firstStep = step; +// int firstStep = step; float angle = startAngle; bool done = false; @@ -1738,7 +1738,7 @@ namespace PrimMesher // append this layer int coordsLen = this.coords.Count; - int lastCoordsLen = coordsLen; +// int lastCoordsLen = coordsLen; newLayer.AddValue2FaceVertexIndices(coordsLen); this.coords.AddRange(newLayer.coords); -- cgit v1.1 From a88a463b5021ff6d40a37298f39e58e93dec6cfa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 9 Nov 2009 19:26:42 +0000 Subject: Following various discussions on irc and in the OpenSim dev OSGrid meeting last week, change av_capsule_tilted to false by default This appears to now give better ODE physics response (less sinking into the ground, etc.) Please change it back if this is actually a bad idea for some reason --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 2 +- bin/OpenSim.ini.example | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 3c9a31d..981cf43 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -439,7 +439,7 @@ namespace OpenSim.Region.Physics.OdePlugin avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); - avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true); + avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", false); contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80); diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 6606270..116a8fd 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -543,7 +543,7 @@ ; specifies if the capsule should be tilted (=true; old compatibility mode) ; or straight up-and-down (=false; better and more consistent physics behavior) - av_capsule_tilted = true + av_capsule_tilted = false ; used to calculate mass of avatar. ; float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH); -- cgit v1.1 From 5145dfa53c2fd8ce0c9ece73ae44f36c9cc70931 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 9 Nov 2009 17:13:56 -0800 Subject: * Removing the redundant SendPrimitiveTerseData.State field, it duplicates AttachPoint * LLClientView.CreateImprovedTerseBlock() now uses AttachPoint and does the proper high-low swap (this should fix disappearing attachment pieces) --- OpenSim/Framework/IClientAPI.cs | 4 +--- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 6 +++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index ee7ab87..04ba9c6 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -592,7 +592,6 @@ namespace OpenSim.Framework public readonly Vector3 Velocity; public readonly Vector3 Acceleration; public readonly Vector3 AngularVelocity; - public readonly byte State; public readonly UUID AssetID; public readonly UUID OwnerID; public readonly int AttachPoint; @@ -600,7 +599,7 @@ namespace OpenSim.Framework public readonly double Priority; public SendPrimitiveTerseData(ulong regionHandle, ushort timeDilation, uint localID, Vector3 position, - Quaternion rotation, Vector3 velocity, Vector3 acceleration, Vector3 rotationalvelocity, byte state, + Quaternion rotation, Vector3 velocity, Vector3 acceleration, Vector3 rotationalvelocity, UUID assetID, UUID ownerID, int attachPoint, byte[] textureEntry, double priority) { RegionHandle = regionHandle; @@ -611,7 +610,6 @@ namespace OpenSim.Framework Velocity = velocity; Acceleration = acceleration; AngularVelocity = rotationalvelocity; - State = state; AssetID = assetID; OwnerID = ownerID; AttachPoint = attachPoint; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 35ccad9..7eb829e 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -4037,11 +4037,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(SendPrimitiveTerseData data) { - return CreateImprovedTerseBlock(false, data.LocalID, data.State, Vector4.Zero, data.Position, data.Velocity, + return CreateImprovedTerseBlock(false, data.LocalID, data.AttachPoint, Vector4.Zero, data.Position, data.Velocity, data.Acceleration, data.Rotation, data.AngularVelocity, data.TextureEntry); } - protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(bool avatar, uint localID, byte state, + protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(bool avatar, uint localID, int attachPoint, Vector4 collisionPlane, Vector3 position, Vector3 velocity, Vector3 acceleration, Quaternion rotation, Vector3 angularVelocity, byte[] textureEntry) { @@ -4053,7 +4053,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP pos += 4; // Avatar/CollisionPlane - data[pos++] = state; + data[pos++] = (byte)((attachPoint % 16) * 16 + (attachPoint / 16)); ; if (avatar) { data[pos++] = 1; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f47be99..73d0984 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3758,14 +3758,12 @@ namespace OpenSim.Region.Framework.Scenes Vector3 lPos = OffsetPosition; - byte state = Shape.State; if (IsAttachment) { if (ParentGroup.RootPart != this) return; lPos = ParentGroup.RootPart.AttachedPos; - state = (byte)AttachmentPoint; } else { @@ -3778,7 +3776,7 @@ namespace OpenSim.Region.Framework.Scenes remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, lPos, RotationOffset, Velocity, Acceleration, - AngularVelocity, state, FromItemID, + AngularVelocity, FromItemID, OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); } -- cgit v1.1 From 7df7e6a0bbfcdbc5142028c9c6e8b27d5b82889f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 10 Nov 2009 01:22:14 +0000 Subject: Add modSendCommand function (note, this is a new API module, using the API extension mechanism, it's not a osFunction! --- .../Shared/Api/Implementation/MOD_Api.cs | 121 +++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | 46 ++++++++ .../ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | 66 +++++++++++ ...nSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | 1 + 4 files changed, 234 insertions(+) create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs create mode 100644 OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs new file mode 100644 index 0000000..88b6091 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -0,0 +1,121 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Remoting.Lifetime; +using OpenMetaverse; +using Nini.Config; +using OpenSim; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.ScriptEngine.Shared; +using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; +using OpenSim.Region.ScriptEngine.Shared.ScriptBase; +using OpenSim.Region.ScriptEngine.Interfaces; +using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; + +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; + +namespace OpenSim.Region.ScriptEngine.Shared.Api +{ + [Serializable] + public class MOD_Api : MarshalByRefObject, IMOD_Api, IScriptApi + { + internal IScriptEngine m_ScriptEngine; + internal SceneObjectPart m_host; + internal uint m_localID; + internal UUID m_itemID; + internal bool m_MODFunctionsEnabled = false; + + public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) + { + m_ScriptEngine = ScriptEngine; + m_host = host; + m_localID = localID; + m_itemID = itemID; + + if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) + m_MODFunctionsEnabled = true; + } + + public override Object InitializeLifetimeService() + { + ILease lease = (ILease)base.InitializeLifetimeService(); + + if (lease.CurrentState == LeaseState.Initial) + { + lease.InitialLeaseTime = TimeSpan.FromMinutes(0); +// lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); +// lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); + } + return lease; + } + + public Scene World + { + get { return m_ScriptEngine.World; } + } + + internal void MODError(string msg) + { + throw new Exception("MOD Runtime Error: " + msg); + } + + // + //Dumps an error message on the debug console. + // + + internal void MODShoutError(string message) + { + if (message.Length > 1023) + message = message.Substring(0, 1023); + + World.SimChat(Utils.StringToBytes(message), + ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); + + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); + } + + public string modSendCommand(string modules, string command, string k) + { + if (!m_MODFunctionsEnabled) + return ""; + + return ""; + } + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs new file mode 100644 index 0000000..e08eca5 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs @@ -0,0 +1,46 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections; +using OpenSim.Region.ScriptEngine.Interfaces; + +using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; + +namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces +{ + public interface IMOD_Api + { + //Module functions + string modSendCommand(string modules, string command, string k); + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs new file mode 100644 index 0000000..6525c76 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs @@ -0,0 +1,66 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Runtime.Remoting.Lifetime; +using System.Threading; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.ScriptEngine.Interfaces; +using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; +using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; +using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; + +namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase +{ + public partial class ScriptBaseClass : MarshalByRefObject + { + public IMOD_Api m_MOD_Functions; + + public void ApiTypeMOD(IScriptApi api) + { + if (!(api is IMOD_Api)) + return; + + m_MOD_Functions = (IMOD_Api)api; + } + + public string modSendCommand(string module, string command, string k) + { + return m_MOD_Functions.modSendCommand(module, command, k); + } + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp index feff86a..98bbc68 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp @@ -20,6 +20,7 @@ + -- cgit v1.1 From 3e22bb24f5aa75f568485ed35e644c6a5c37dfe3 Mon Sep 17 00:00:00 2001 From: dahlia Date: Mon, 9 Nov 2009 18:43:09 -0800 Subject: add an overload to _SculptMesh for meshing from a list of coordinates add conditional compilation for System.Drawing dependency --- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 49 ++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index f1dd586..281ba12 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -25,12 +25,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// to build without references to System.Drawing, comment this out +#define SYSTEM_DRAWING + using System; using System.Collections.Generic; using System.Text; using System.IO; + +#if SYSTEM_DRAWING using System.Drawing; using System.Drawing.Imaging; +#endif namespace PrimMesher { @@ -83,6 +89,7 @@ namespace PrimMesher // return scaledImage; // } +#if SYSTEM_DRAWING public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) { Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); @@ -97,6 +104,7 @@ namespace PrimMesher _SculptMesh(bitmap, (SculptType)sculptType, lod, viewerMode != 0, mirror != 0, invert != 0); bitmap.Dispose(); } +#endif /// /// ** Experimental ** May disappear from future versions ** not recommeneded for use in applications @@ -201,6 +209,7 @@ namespace PrimMesher calcVertexNormals(SculptType.plane, numXElements, numYElements); } +#if SYSTEM_DRAWING public SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode) { _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, false, false); @@ -210,9 +219,16 @@ namespace PrimMesher { _SculptMesh(sculptBitmap, sculptType, lod, viewerMode, mirror, invert); } +#endif + + public SculptMesh(List> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) + { + _SculptMesh(rows, sculptType, viewerMode, mirror, invert); + } +#if SYSTEM_DRAWING /// - /// converts a bitmap to a list lists of coords, while scaling the image. + /// converts a bitmap to a list of lists of coords, while scaling the image. /// the scaling is done in floating point so as to allow for reduced vertex position /// quantization as the position will be averaged between pixel values. this routine will /// likely fail if the bitmap width and height are not powers of 2. @@ -267,6 +283,7 @@ namespace PrimMesher return rows; } + void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert) { coords = new List(); @@ -285,13 +302,39 @@ namespace PrimMesher int scale = (int)(1.0f / sourceScaleFactor); if (scale < 1) scale = 1; - List> rows = bitmap2Coords(sculptBitmap, scale, mirror); + _SculptMesh(bitmap2Coords(sculptBitmap, scale, mirror), sculptType, viewerMode, mirror, invert); + } +#endif + + + void _SculptMesh(List> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) + { + coords = new List(); + faces = new List(); + normals = new List(); + uvs = new List(); + + sculptType = (SculptType)(((int)sculptType) & 0x07); + + if (mirror) + if (sculptType == SculptType.plane) + invert = !invert; + + //float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); + + //int scale = (int)(1.0f / sourceScaleFactor); + //if (scale < 1) scale = 1; + + //List> rows = bitmap2Coords(sculptBitmap, scale, mirror); viewerFaces = new List(); - int width = sculptBitmap.Width / scale; + //int width = sculptBitmap.Width / scale; // int height = sculptBitmap.Height / scale; + int width = rows[0].Count; + int height = rows.Count; + int p1, p2, p3, p4; int imageX, imageY; -- cgit v1.1 From ba99081bbe42efa06f8b7a5bedb5db79afa99445 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 10 Nov 2009 03:36:43 +0000 Subject: Add IScriptModuleComms interface and region module to handle dispatch of script messages to region modules and sending back replies. Hook IScriptModuleComms.OnScriptCommand to see commands and use DispatchReply to reply to the script. It is recommended to pass the "id" parameter from the event as the "k" parameter of the reply. The script will receive the reply as a link message from link -1. --- .../Framework/Interfaces/IScriptModuleComms.cs | 44 +++++++++ .../ScriptModuleComms/ScriptModuleCommsModule.cs | 105 +++++++++++++++++++++ .../Shared/Api/Implementation/MOD_Api.cs | 19 +++- 3 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs new file mode 100644 index 0000000..5cdf191 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; + +namespace OpenSim.Region.Framework.Interfaces +{ + public delegate void ScriptCommand(UUID script, string id, string module, string command, string k); + + public interface IScriptModuleComms + { + event ScriptCommand OnScriptCommand; + + void DispatchReply(UUID script, int code, string text, string k); + + // For use ONLY by the script API + void RaiseEvent(UUID script, string id, string module, string command, string k); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs new file mode 100644 index 0000000..44c9ada --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -0,0 +1,105 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using Mono.Addins; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms +{ + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] + class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IScriptModule m_scriptModule = null; + + public event ScriptCommand OnScriptCommand; + + public void Initialise(IConfigSource config) + { + } + + public void AddRegion(Scene scene) + { + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + m_scriptModule = scene.RequestModuleInterface(); + + if (m_scriptModule != null) + m_log.Info("[MODULE COMMANDS]: Script engine found, module active"); + } + + public string Name + { + get { return "ScriptModuleCommsModule"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void Close() + { + } + + public void RaiseEvent(UUID script, string id, string module, string command, string k) + { + ScriptCommand c = OnScriptCommand; + + if (c == null) + return; + + c(script, id, module, command, k); + } + + public void DispatchReply(UUID script, int code, string text, string k) + { + if (m_scriptModule == null) + return; + + Object[] args = new Object[] {-1, code, text, k}; + + m_scriptModule.PostScriptEvent(script, "link_message", args); + } + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 88b6091..d4facdd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -26,6 +26,7 @@ */ using System; +using System.Reflection; using System.Collections; using System.Collections.Generic; using System.Runtime.Remoting.Lifetime; @@ -59,6 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal uint m_localID; internal UUID m_itemID; internal bool m_MODFunctionsEnabled = false; + internal IScriptModuleComms m_comms = null; public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) { @@ -69,6 +71,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false)) m_MODFunctionsEnabled = true; + + m_comms = m_ScriptEngine.World.RequestModuleInterface(); + if (m_comms == null) + m_MODFunctionsEnabled = false; } public override Object InitializeLifetimeService() @@ -110,12 +116,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); } - public string modSendCommand(string modules, string command, string k) + public string modSendCommand(string module, string command, string k) { if (!m_MODFunctionsEnabled) - return ""; + { + MODShoutError("Module command functions not enabled"); + return UUID.Zero.ToString();; + } + + UUID req = UUID.Random(); + + m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k); - return ""; + return req.ToString(); } } } -- cgit v1.1 From 167c15db9d818710f16c65516c724e7ab2757334 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 9 Nov 2009 21:22:02 -0800 Subject: Fixed XMLRPC return params Signed-off-by: Melanie --- OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index 97899a7..27b64bf 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs @@ -689,7 +689,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC } if (respParms.Contains("IntValue")) { - Idata = Convert.ToInt32((string) respParms["IntValue"]); + Idata = Convert.ToInt32(respParms["IntValue"]); } if (respParms.Contains("faultString")) { -- cgit v1.1 From 90b15aa440a6a7d8ddae6df6006aff8010d21405 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 11 Nov 2009 00:22:06 +1100 Subject: * Added HTTP polling for Statistics Monitor Module (access via http://sim.com:httpport/monitorstats/regionUUID/) * Returns simple formatted XML document containing statistical data on the current sim. * Example: 5.0000 ... --- .../Framework/Monitoring/MonitorModule.cs | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index 769af8d..b6a2025 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -1,7 +1,10 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; using System.Reflection; using log4net; using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts; using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; using OpenSim.Region.Framework.Interfaces; @@ -43,6 +46,26 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring "monitor report", "Returns a variety of statistics about the current region and/or simulator", DebugMonitors); + + MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID + "/", StatsPage); + } + + public Hashtable StatsPage(Hashtable request) + { + string xml = ""; + foreach (IMonitor monitor in m_monitors) + { + xml += "<" + monitor.ToString() + ">" + monitor.GetValue() + ""; + } + xml += ""; + + Hashtable ereply = new Hashtable(); + + ereply["int_response_code"] = 200; // 200 OK + ereply["str_response_string"] = xml; + ereply["content_type"] = "text/xml"; + + return ereply; } public void PostInitialise() -- cgit v1.1 From 3294714099bbb49b5c3e19a5b21bf1be89d0873c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 10 Nov 2009 07:57:54 -0800 Subject: Updated HGUserServices with AuthenticateUserByPassword, so that iar works. --- OpenSim/Region/Communications/Hypergrid/HGUserServices.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs index 49a2261..09d8285 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs @@ -204,6 +204,14 @@ namespace OpenSim.Region.Communications.Hypergrid return base.UpdateUserProfile(userProfile); } + public override bool AuthenticateUserByPassword(UUID userID, string password) + { + if (m_localUserServices != null) + return m_localUserServices.AuthenticateUserByPassword(userID, password); + else + return base.AuthenticateUserByPassword(userID, password); + } + #region IUserServices Friend Methods // NOTE: We're still not dealing with foreign user friends -- cgit v1.1 From 05f7fa1543b2da90ceb616a04406e99938329aea Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 10 Nov 2009 10:39:16 -0800 Subject: Broke the monster RegionLoaded method in RegionCombinerModule into 4 smaller methods. Let's see if this avoids a mono bug that is making megaregions not work in mono. Long shot, but worth a try. --- .../CoreModules/World/Land/RegionCombinerModule.cs | 472 +++++++++++---------- 1 file changed, 248 insertions(+), 224 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs index d8c5ed9..ebd8ee7 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs @@ -299,76 +299,13 @@ namespace OpenSim.Region.CoreModules.World.Land //xxy //xxx + if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd >= (regionConnections.X * (int)Constants.RegionSize)) && (((int)conn.Y * (int)Constants.RegionSize) >= (regionConnections.Y * (int)Constants.RegionSize))) { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = conn.YEnd; - extents.X = conn.XEnd + regionConnections.XEnd; - - conn.UpdateExtents(extents); - - m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - scene.BordersLocked = true; - conn.RegionScene.BordersLocked = true; - - RegionData ConnectedRegion = new RegionData(); - ConnectedRegion.Offset = offset; - ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; - ConnectedRegion.RegionScene = scene; - conn.ConnectedRegions.Add(ConnectedRegion); - - // Inform root region Physics about the extents of this region - conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); - - // Inform Child region that it needs to forward it's terrain to the root region - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - - // Extend the borders as appropriate - lock (conn.RegionScene.EastBorders) - conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - - lock (conn.RegionScene.NorthBorders) - conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - lock (conn.RegionScene.SouthBorders) - conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - lock (scene.WestBorders) - { - - - scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West - - // Trigger auto teleport to root region - scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } - - // Reset Terrain.. since terrain loads before we get here, we need to load - // it again so it loads in the root region - - scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); - - // Unlock borders - conn.RegionScene.BordersLocked = false; - scene.BordersLocked = false; - - // Create a client event forwarder and add this region's events to the root region. - if (conn.ClientEventForwarder != null) - conn.ClientEventForwarder.AddSceneToEventForwarding(scene); - connectedYN = true; + connectedYN = DoWorkForOneRegionOverPlusXY(conn, regionConnections, scene); break; } @@ -381,57 +318,8 @@ namespace OpenSim.Region.CoreModules.World.Land && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd >= (regionConnections.Y * (int)Constants.RegionSize))) { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = conn.XEnd; - conn.UpdateExtents(extents); - - scene.BordersLocked = true; - conn.RegionScene.BordersLocked = true; - - RegionData ConnectedRegion = new RegionData(); - ConnectedRegion.Offset = offset; - ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; - ConnectedRegion.RegionScene = scene; - conn.ConnectedRegions.Add(ConnectedRegion); - - m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - - lock (conn.RegionScene.NorthBorders) - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - lock (conn.RegionScene.EastBorders) - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.WestBorders) - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (scene.SouthBorders) - { - scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south - scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } - - // Reset Terrain.. since terrain normally loads first. - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - - scene.BordersLocked = false; - conn.RegionScene.BordersLocked = false; - if (conn.ClientEventForwarder != null) - conn.ClientEventForwarder.AddSceneToEventForwarding(scene); - connectedYN = true; - break; + connectedYN = DoWorkForOneRegionOverXPlusY(conn, regionConnections, scene); + break; } // If we're one region over +x +y @@ -443,140 +331,276 @@ namespace OpenSim.Region.CoreModules.World.Land && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd >= (regionConnections.Y * (int)Constants.RegionSize))) { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); + connectedYN = DoWorkForOneRegionOverPlusXPlusY(conn, regionConnections, scene); + break; - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = regionConnections.XEnd + conn.XEnd; - conn.UpdateExtents(extents); + } + } - scene.BordersLocked = true; - conn.RegionScene.BordersLocked = true; + // If !connectYN means that this region is a root region + if (!connectedYN) + { + DoWorkForRootRegion(regionConnections, scene); - RegionData ConnectedRegion = new RegionData(); - ConnectedRegion.Offset = offset; - ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; - ConnectedRegion.RegionScene = scene; + } + } + // Set up infinite borders around the entire AABB of the combined ConnectedRegions + AdjustLargeRegionBounds(); + } - conn.ConnectedRegions.Add(ConnectedRegion); + private bool DoWorkForOneRegionOverPlusXY(RegionConnections conn, RegionConnections regionConnections, Scene scene) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); - m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + Vector3 extents = Vector3.Zero; + extents.Y = conn.YEnd; + extents.X = conn.XEnd + regionConnections.XEnd; - conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - lock (conn.RegionScene.NorthBorders) - { - if (conn.RegionScene.NorthBorders.Count == 1)// && 2) - { - //compound border - // already locked above - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - - lock (conn.RegionScene.EastBorders) - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.WestBorders) - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - } - } + conn.UpdateExtents(extents); - lock (scene.SouthBorders) - { - scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south - scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } + m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - lock (conn.RegionScene.EastBorders) - { - if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) - { + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; - conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - lock (conn.RegionScene.NorthBorders) - conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.SouthBorders) - conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + RegionData ConnectedRegion = new RegionData(); + ConnectedRegion.Offset = offset; + ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; + ConnectedRegion.RegionScene = scene; + conn.ConnectedRegions.Add(ConnectedRegion); + // Inform root region Physics about the extents of this region + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); - } - } + // Inform Child region that it needs to forward it's terrain to the root region + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - lock (scene.WestBorders) - { - scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West - scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } + // Extend the borders as appropriate + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - /* - else - { - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south - } - */ + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.SouthBorders) + conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - // Reset Terrain.. since terrain normally loads first. - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - scene.BordersLocked = false; - conn.RegionScene.BordersLocked = false; + lock (scene.WestBorders) + { - if (conn.ClientEventForwarder != null) - conn.ClientEventForwarder.AddSceneToEventForwarding(scene); - connectedYN = true; + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West - //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); + // Trigger auto teleport to root region + scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } - break; - } + // Reset Terrain.. since terrain loads before we get here, we need to load + // it again so it loads in the root region + + scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); + + // Unlock borders + conn.RegionScene.BordersLocked = false; + scene.BordersLocked = false; + + // Create a client event forwarder and add this region's events to the root region. + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); + + return true; + } + + private bool DoWorkForOneRegionOverXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = conn.XEnd; + conn.UpdateExtents(extents); + + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; + + RegionData ConnectedRegion = new RegionData(); + ConnectedRegion.Offset = offset; + ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; + ConnectedRegion.RegionScene = scene; + conn.ConnectedRegions.Add(ConnectedRegion); + + m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); + + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.WestBorders) + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (scene.SouthBorders) + { + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south + scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } + + // Reset Terrain.. since terrain normally loads first. + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + + scene.BordersLocked = false; + conn.RegionScene.BordersLocked = false; + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); + return true; + } + + private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = regionConnections.XEnd + conn.XEnd; + conn.UpdateExtents(extents); + + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; + + RegionData ConnectedRegion = new RegionData(); + ConnectedRegion.Offset = offset; + ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; + ConnectedRegion.RegionScene = scene; + + conn.ConnectedRegions.Add(ConnectedRegion); + + m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); + lock (conn.RegionScene.NorthBorders) + { + if (conn.RegionScene.NorthBorders.Count == 1)// && 2) + { + //compound border + // already locked above + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.WestBorders) + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; } + } - // If !connectYN means that this region is a root region - if (!connectedYN) + lock (scene.SouthBorders) + { + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south + scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } + + lock (conn.RegionScene.EastBorders) + { + if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) { - RegionData rdata = new RegionData(); - rdata.Offset = Vector3.Zero; - rdata.RegionId = scene.RegionInfo.originRegionID; - rdata.RegionScene = scene; - // save it's land channel - regionConnections.RegionLandChannel = scene.LandChannel; - - // Substitue our landchannel - RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, - regionConnections.ConnectedRegions); - scene.LandChannel = lnd; - // Forward the permissions modules of each of the connected regions to the root region - lock (m_regions) - { - foreach (RegionData r in regionConnections.ConnectedRegions) - { - ForwardPermissionRequests(regionConnections, r.RegionScene); - } - } - // Create the root region's Client Event Forwarder - regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); - // Sets up the CoarseLocationUpdate forwarder for this root region - scene.EventManager.OnNewPresence += SetCourseLocationDelegate; + conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.SouthBorders) + conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + - // Adds this root region to a dictionary of regions that are connectable - m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); } } - // Set up infinite borders around the entire AABB of the combined ConnectedRegions - AdjustLargeRegionBounds(); + + lock (scene.WestBorders) + { + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West + scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } + + /* + else + { + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south + } + */ + + + // Reset Terrain.. since terrain normally loads first. + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.BordersLocked = false; + conn.RegionScene.BordersLocked = false; + + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); + + return true; + + //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); + + } + + private void DoWorkForRootRegion(RegionConnections regionConnections, Scene scene) + { + RegionData rdata = new RegionData(); + rdata.Offset = Vector3.Zero; + rdata.RegionId = scene.RegionInfo.originRegionID; + rdata.RegionScene = scene; + // save it's land channel + regionConnections.RegionLandChannel = scene.LandChannel; + + // Substitue our landchannel + RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, + regionConnections.ConnectedRegions); + scene.LandChannel = lnd; + // Forward the permissions modules of each of the connected regions to the root region + lock (m_regions) + { + foreach (RegionData r in regionConnections.ConnectedRegions) + { + ForwardPermissionRequests(regionConnections, r.RegionScene); + } + } + // Create the root region's Client Event Forwarder + regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); + + // Sets up the CoarseLocationUpdate forwarder for this root region + scene.EventManager.OnNewPresence += SetCourseLocationDelegate; + + // Adds this root region to a dictionary of regions that are connectable + m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); } private void SetCourseLocationDelegate(ScenePresence presence) -- cgit v1.1 From 9cb0c7c86ec48225710fee940ad5347d48634e46 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 10 Nov 2009 18:58:28 +0000 Subject: Stop OpenSim.Grid.GridServer.exe from building to reduce user/developer confusion, since only the ROBUST grid service now works GridServer dll still building for now due to unresolved dependencies with the remaining OpenSim.Grid.UserServer.exe --- OpenSim/Grid/GridServer/Program.cs | 65 -------------------------------------- prebuild.xml | 2 +- 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 OpenSim/Grid/GridServer/Program.cs diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Grid/GridServer/Program.cs deleted file mode 100644 index 741a01b..0000000 --- a/OpenSim/Grid/GridServer/Program.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using log4net.Config; -using Nini.Config; - -namespace OpenSim.Grid.GridServer -{ - public class Program - { - public static void Main(string[] args) - { - ArgvConfigSource argvSource = new ArgvConfigSource(args); - argvSource.AddSwitch("Startup", "console", "c"); - argvSource.AddSwitch("Startup", "xmlfile", "x"); - - XmlConfigurator.Configure(); - - GridServerBase app = new GridServerBase(); - - IConfig startupConfig = argvSource.Configs["Startup"]; - if (startupConfig != null) - { - app.m_consoleType = startupConfig.GetString("console", "local"); - app.m_configFile = startupConfig.GetString("xmlfile", "GridServer_Config.xml"); - } - - app.m_configSource = argvSource; - -// if (args.Length > 0 && args[0] == "-setuponly") -// { -// app.Config(); -// } -// else -// { - app.Startup(); - app.Work(); -// } - } - } -} diff --git a/prebuild.xml b/prebuild.xml index 33cb647..b7ce93c 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -909,7 +909,7 @@ - + ../../../bin/ -- cgit v1.1 From 2e514bfb1bcc55def804772e00200b44c20d3d7a Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Tue, 10 Nov 2009 22:15:34 -0500 Subject: * Move RegionCombinerModule to it's own project * Moves the mono_metadata_token_from_dor message to a different module on loading. --- .../Resources/CoreModulePlugin.addin.xml | 1 - .../Land/RegionCombinerClientEventForwarder.cs | 94 -- .../Land/RegionCombinerIndividualEventForwarder.cs | 125 --- .../World/Land/RegionCombinerLargeLandChannel.cs | 163 ---- .../CoreModules/World/Land/RegionCombinerModule.cs | 963 -------------------- .../World/Land/RegionCombinerPermissionModule.cs | 275 ------ .../CoreModules/World/Land/RegionConnections.cs | 65 -- .../CoreModules/World/Land/RegionCourseLocation.cs | 43 - .../Region/CoreModules/World/Land/RegionData.cs | 39 - .../RegionCombinerClientEventForwarder.cs | 94 ++ .../RegionCombinerIndividualEventForwarder.cs | 125 +++ .../RegionCombinerLargeLandChannel.cs | 163 ++++ .../RegionCombinerModule/RegionCombinerModule.cs | 964 +++++++++++++++++++++ .../RegionCombinerPermissionModule.cs | 275 ++++++ .../RegionCombinerModule/RegionConnections.cs | 65 ++ .../RegionCombinerModule/RegionCourseLocation.cs | 43 + OpenSim/Region/RegionCombinerModule/RegionData.cs | 39 + .../Resources/RegionCombinerModule.addin.xml | 13 + prebuild.xml | 41 + 19 files changed, 1822 insertions(+), 1768 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionCombinerClientEventForwarder.cs delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionCombinerIndividualEventForwarder.cs delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionCombinerLargeLandChannel.cs delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionCombinerPermissionModule.cs delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionConnections.cs delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionCourseLocation.cs delete mode 100644 OpenSim/Region/CoreModules/World/Land/RegionData.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionConnections.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs create mode 100644 OpenSim/Region/RegionCombinerModule/RegionData.cs create mode 100644 OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 8f82718..9757072 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -13,7 +13,6 @@ - diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerClientEventForwarder.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerClientEventForwarder.cs deleted file mode 100644 index 70d6de3..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerClientEventForwarder.cs +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.World.Land -{ -public class RegionCombinerClientEventForwarder - { - private Scene m_rootScene; - private Dictionary m_virtScene = new Dictionary(); - private Dictionary m_forwarders = new Dictionary(); - - public RegionCombinerClientEventForwarder(RegionConnections rootScene) - { - m_rootScene = rootScene.RegionScene; - } - - public void AddSceneToEventForwarding(Scene virtualScene) - { - lock (m_virtScene) - { - if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID)) - { - m_virtScene[virtualScene.RegionInfo.originRegionID] = virtualScene; - } - else - { - m_virtScene.Add(virtualScene.RegionInfo.originRegionID, virtualScene); - } - } - - lock (m_forwarders) - { - // TODO: Fix this to unregister if this happens - if (m_forwarders.ContainsKey(virtualScene.RegionInfo.originRegionID)) - m_forwarders.Remove(virtualScene.RegionInfo.originRegionID); - - RegionCombinerIndividualEventForwarder forwarder = - new RegionCombinerIndividualEventForwarder(m_rootScene, virtualScene); - m_forwarders.Add(virtualScene.RegionInfo.originRegionID, forwarder); - - virtualScene.EventManager.OnNewClient += forwarder.ClientConnect; - virtualScene.EventManager.OnClientClosed += forwarder.ClientClosed; - } - } - - public void RemoveSceneFromEventForwarding (Scene virtualScene) - { - lock (m_forwarders) - { - RegionCombinerIndividualEventForwarder forwarder = m_forwarders[virtualScene.RegionInfo.originRegionID]; - virtualScene.EventManager.OnNewClient -= forwarder.ClientConnect; - virtualScene.EventManager.OnClientClosed -= forwarder.ClientClosed; - m_forwarders.Remove(virtualScene.RegionInfo.originRegionID); - } - lock (m_virtScene) - { - if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID)) - { - m_virtScene.Remove(virtualScene.RegionInfo.originRegionID); - } - } - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerIndividualEventForwarder.cs deleted file mode 100644 index 2cbaf96..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerIndividualEventForwarder.cs +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.World.Land -{ - public class RegionCombinerIndividualEventForwarder - { - private Scene m_rootScene; - private Scene m_virtScene; - - public RegionCombinerIndividualEventForwarder(Scene rootScene, Scene virtScene) - { - m_rootScene = rootScene; - m_virtScene = virtScene; - } - - public void ClientConnect(IClientAPI client) - { - m_virtScene.UnSubscribeToClientPrimEvents(client); - m_virtScene.UnSubscribeToClientPrimRezEvents(client); - m_virtScene.UnSubscribeToClientInventoryEvents(client); - m_virtScene.UnSubscribeToClientAttachmentEvents(client); - //m_virtScene.UnSubscribeToClientTeleportEvents(client); - m_virtScene.UnSubscribeToClientScriptEvents(client); - m_virtScene.UnSubscribeToClientGodEvents(client); - m_virtScene.UnSubscribeToClientNetworkEvents(client); - - m_rootScene.SubscribeToClientPrimEvents(client); - client.OnAddPrim += LocalAddNewPrim; - client.OnRezObject += LocalRezObject; - m_rootScene.SubscribeToClientInventoryEvents(client); - m_rootScene.SubscribeToClientAttachmentEvents(client); - //m_rootScene.SubscribeToClientTeleportEvents(client); - m_rootScene.SubscribeToClientScriptEvents(client); - m_rootScene.SubscribeToClientGodEvents(client); - m_rootScene.SubscribeToClientNetworkEvents(client); - } - - public void ClientClosed(UUID clientid, Scene scene) - { - } - - /// - /// Fixes position based on the region the Rez event came in on - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, - UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, - UUID fromtaskid) - { - int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; - int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; - rayend.X += differenceX * (int)Constants.RegionSize; - rayend.Y += differenceY * (int)Constants.RegionSize; - raystart.X += differenceX * (int)Constants.RegionSize; - raystart.Y += differenceY * (int)Constants.RegionSize; - - m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast, - rayendisintersection, rezselected, removeitem, fromtaskid); - } - /// - /// Fixes position based on the region the AddPrimShape event came in on - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, - PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, - byte rayendisintersection) - { - int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; - int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; - rayend.X += differenceX * (int)Constants.RegionSize; - rayend.Y += differenceY * (int)Constants.RegionSize; - raystart.X += differenceX * (int)Constants.RegionSize; - raystart.Y += differenceY * (int)Constants.RegionSize; - m_rootScene.AddNewPrim(ownerid, groupid, rayend, rot, shape, bypassraycast, raystart, raytargetid, - rayendisintersection); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerLargeLandChannel.cs deleted file mode 100644 index 7df836c..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerLargeLandChannel.cs +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; - -namespace OpenSim.Region.CoreModules.World.Land -{ -public class RegionCombinerLargeLandChannel : ILandChannel - { - // private static readonly ILog m_log = - // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private RegionData RegData; - private ILandChannel RootRegionLandChannel; - private readonly List RegionConnections; - - #region ILandChannel Members - - public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel, - List regionConnections) - { - RegData = regData; - RootRegionLandChannel = rootRegionLandChannel; - RegionConnections = regionConnections; - } - - public List ParcelsNearPoint(Vector3 position) - { - //m_log.DebugFormat("[LANDPARCELNEARPOINT]: {0}>", position); - return RootRegionLandChannel.ParcelsNearPoint(position - RegData.Offset); - } - - public List AllParcels() - { - return RootRegionLandChannel.AllParcels(); - } - - public ILandObject GetLandObject(int x, int y) - { - //m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y); - - if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) - { - return RootRegionLandChannel.GetLandObject(x, y); - } - else - { - int offsetX = (x / (int)Constants.RegionSize); - int offsetY = (y / (int)Constants.RegionSize); - offsetX *= (int)Constants.RegionSize; - offsetY *= (int)Constants.RegionSize; - - foreach (RegionData regionData in RegionConnections) - { - if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) - { - return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); - } - } - ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); - obj.LandData.Name = "NO LAND"; - return obj; - } - } - - public ILandObject GetLandObject(int localID) - { - return RootRegionLandChannel.GetLandObject(localID); - } - - public ILandObject GetLandObject(float x, float y) - { - //m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y); - - if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) - { - return RootRegionLandChannel.GetLandObject(x, y); - } - else - { - int offsetX = (int)(x/(int) Constants.RegionSize); - int offsetY = (int)(y/(int) Constants.RegionSize); - offsetX *= (int) Constants.RegionSize; - offsetY *= (int) Constants.RegionSize; - - foreach (RegionData regionData in RegionConnections) - { - if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) - { - return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); - } - } - ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); - obj.LandData.Name = "NO LAND"; - return obj; - } - } - - public bool IsLandPrimCountTainted() - { - return RootRegionLandChannel.IsLandPrimCountTainted(); - } - - public bool IsForcefulBansAllowed() - { - return RootRegionLandChannel.IsForcefulBansAllowed(); - } - - public void UpdateLandObject(int localID, LandData data) - { - RootRegionLandChannel.UpdateLandObject(localID, data); - } - - public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) - { - RootRegionLandChannel.ReturnObjectsInParcel(localID, returnType, agentIDs, taskIDs, remoteClient); - } - - public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) - { - RootRegionLandChannel.setParcelObjectMaxOverride(overrideDel); - } - - public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) - { - RootRegionLandChannel.setSimulatorObjectMaxOverride(overrideDel); - } - - public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) - { - RootRegionLandChannel.SetParcelOtherCleanTime(remoteClient, localID, otherCleanTime); - } - - #endregion - } -} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs deleted file mode 100644 index ebd8ee7..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ /dev/null @@ -1,963 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Client; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Framework.Console; - -namespace OpenSim.Region.CoreModules.World.Land -{ - public class RegionCombinerModule : ISharedRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public string Name - { - get { return "RegionCombinerModule"; } - } - - public Type ReplaceableInterface - { - get { return null; } - } - - private Dictionary m_regions = new Dictionary(); - private bool enabledYN = false; - private Dictionary m_startingScenes = new Dictionary(); - - public void Initialise(IConfigSource source) - { - IConfig myConfig = source.Configs["Startup"]; - enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false); - //enabledYN = true; - if (enabledYN) - MainConsole.Instance.Commands.AddCommand("RegionCombinerModule", false, "fix-phantoms", - "Fix phantom objects", "Fixes phantom objects after an import to megaregions", FixPhantoms); - } - - public void Close() - { - } - - public void AddRegion(Scene scene) - { - } - - public void RemoveRegion(Scene scene) - { - } - - public void RegionLoaded(Scene scene) - { - if (enabledYN) - RegionLoadedDoWork(scene); - } - - private void RegionLoadedDoWork(Scene scene) - { -/* - // For testing on a single instance - if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000) - return; - // -*/ - lock (m_startingScenes) - m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); - - // Give each region a standard set of non-infinite borders - Border northBorder = new Border(); - northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- - northBorder.CrossDirection = Cardinals.N; - scene.NorthBorders[0] = northBorder; - - Border southBorder = new Border(); - southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> - southBorder.CrossDirection = Cardinals.S; - scene.SouthBorders[0] = southBorder; - - Border eastBorder = new Border(); - eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- - eastBorder.CrossDirection = Cardinals.E; - scene.EastBorders[0] = eastBorder; - - Border westBorder = new Border(); - westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> - westBorder.CrossDirection = Cardinals.W; - scene.WestBorders[0] = westBorder; - - - - RegionConnections regionConnections = new RegionConnections(); - regionConnections.ConnectedRegions = new List(); - regionConnections.RegionScene = scene; - regionConnections.RegionLandChannel = scene.LandChannel; - regionConnections.RegionId = scene.RegionInfo.originRegionID; - regionConnections.X = scene.RegionInfo.RegionLocX; - regionConnections.Y = scene.RegionInfo.RegionLocY; - regionConnections.XEnd = (int)Constants.RegionSize; - regionConnections.YEnd = (int)Constants.RegionSize; - - - lock (m_regions) - { - bool connectedYN = false; - - foreach (RegionConnections conn in m_regions.Values) - { - #region commented - /* - // If we're one region over +x +y - //xxy - //xxx - //xxx - if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd - == (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd - == (regionConnections.Y * (int)Constants.RegionSize))) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int) Constants.RegionSize)) - - ((conn.X * (int) Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int) Constants.RegionSize)) - - ((conn.Y * (int) Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = conn.XEnd + conn.XEnd; - - m_log.DebugFormat("Scene: {0} to the northwest of Scene{1}. Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, - offset, extents); - - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); - - connectedYN = true; - break; - } - */ - - /* - //If we're one region over x +y - //xxx - //xxx - //xyx - if ((((int)conn.X * (int)Constants.RegionSize) - == (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd - == (regionConnections.Y * (int)Constants.RegionSize))) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = conn.XEnd; - - m_log.DebugFormat("Scene: {0} to the north of Scene{1}. Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); - connectedYN = true; - break; - } - */ - - /* - // If we're one region over -x +y - //xxx - //xxx - //yxx - if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd - == (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd - == (regionConnections.Y * (int)Constants.RegionSize))) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = conn.XEnd + conn.XEnd; - - m_log.DebugFormat("Scene: {0} to the northeast of Scene. Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); - - - connectedYN = true; - break; - } - */ - - /* - // If we're one region over -x y - //xxx - //yxx - //xxx - if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd - == (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) - == (regionConnections.Y * (int)Constants.RegionSize))) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd; - extents.X = conn.XEnd + conn.XEnd; - - m_log.DebugFormat("Scene: {0} to the east of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); - - connectedYN = true; - break; - } - */ - - /* - // If we're one region over -x -y - //yxx - //xxx - //xxx - if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd - == (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd - == (regionConnections.Y * (int)Constants.RegionSize))) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = conn.XEnd + conn.XEnd; - - m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); - - connectedYN = true; - break; - } - */ - #endregion - - // If we're one region over +x y - //xxx - //xxy - //xxx - - - if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd - >= (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) - >= (regionConnections.Y * (int)Constants.RegionSize))) - { - connectedYN = DoWorkForOneRegionOverPlusXY(conn, regionConnections, scene); - break; - } - - // If we're one region over x +y - //xyx - //xxx - //xxx - if ((((int)conn.X * (int)Constants.RegionSize) - >= (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd - >= (regionConnections.Y * (int)Constants.RegionSize))) - { - connectedYN = DoWorkForOneRegionOverXPlusY(conn, regionConnections, scene); - break; - } - - // If we're one region over +x +y - //xxy - //xxx - //xxx - if ((((int)conn.X * (int)Constants.RegionSize) + conn.YEnd - >= (regionConnections.X * (int)Constants.RegionSize)) - && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd - >= (regionConnections.Y * (int)Constants.RegionSize))) - { - connectedYN = DoWorkForOneRegionOverPlusXPlusY(conn, regionConnections, scene); - break; - - } - } - - // If !connectYN means that this region is a root region - if (!connectedYN) - { - DoWorkForRootRegion(regionConnections, scene); - - } - } - // Set up infinite borders around the entire AABB of the combined ConnectedRegions - AdjustLargeRegionBounds(); - } - - private bool DoWorkForOneRegionOverPlusXY(RegionConnections conn, RegionConnections regionConnections, Scene scene) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = conn.YEnd; - extents.X = conn.XEnd + regionConnections.XEnd; - - conn.UpdateExtents(extents); - - m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - scene.BordersLocked = true; - conn.RegionScene.BordersLocked = true; - - RegionData ConnectedRegion = new RegionData(); - ConnectedRegion.Offset = offset; - ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; - ConnectedRegion.RegionScene = scene; - conn.ConnectedRegions.Add(ConnectedRegion); - - // Inform root region Physics about the extents of this region - conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); - - // Inform Child region that it needs to forward it's terrain to the root region - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - - // Extend the borders as appropriate - lock (conn.RegionScene.EastBorders) - conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - - lock (conn.RegionScene.NorthBorders) - conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - lock (conn.RegionScene.SouthBorders) - conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - lock (scene.WestBorders) - { - - - scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West - - // Trigger auto teleport to root region - scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } - - // Reset Terrain.. since terrain loads before we get here, we need to load - // it again so it loads in the root region - - scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); - - // Unlock borders - conn.RegionScene.BordersLocked = false; - scene.BordersLocked = false; - - // Create a client event forwarder and add this region's events to the root region. - if (conn.ClientEventForwarder != null) - conn.ClientEventForwarder.AddSceneToEventForwarding(scene); - - return true; - } - - private bool DoWorkForOneRegionOverXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = conn.XEnd; - conn.UpdateExtents(extents); - - scene.BordersLocked = true; - conn.RegionScene.BordersLocked = true; - - RegionData ConnectedRegion = new RegionData(); - ConnectedRegion.Offset = offset; - ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; - ConnectedRegion.RegionScene = scene; - conn.ConnectedRegions.Add(ConnectedRegion); - - m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - - lock (conn.RegionScene.NorthBorders) - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - lock (conn.RegionScene.EastBorders) - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.WestBorders) - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (scene.SouthBorders) - { - scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south - scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } - - // Reset Terrain.. since terrain normally loads first. - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - - scene.BordersLocked = false; - conn.RegionScene.BordersLocked = false; - if (conn.ClientEventForwarder != null) - conn.ClientEventForwarder.AddSceneToEventForwarding(scene); - return true; - } - - private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) - { - Vector3 offset = Vector3.Zero; - offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - - ((conn.X * (int)Constants.RegionSize))); - offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - - ((conn.Y * (int)Constants.RegionSize))); - - Vector3 extents = Vector3.Zero; - extents.Y = regionConnections.YEnd + conn.YEnd; - extents.X = regionConnections.XEnd + conn.XEnd; - conn.UpdateExtents(extents); - - scene.BordersLocked = true; - conn.RegionScene.BordersLocked = true; - - RegionData ConnectedRegion = new RegionData(); - ConnectedRegion.Offset = offset; - ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; - ConnectedRegion.RegionScene = scene; - - conn.ConnectedRegions.Add(ConnectedRegion); - - m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", - conn.RegionScene.RegionInfo.RegionName, - regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); - - conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); - scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); - lock (conn.RegionScene.NorthBorders) - { - if (conn.RegionScene.NorthBorders.Count == 1)// && 2) - { - //compound border - // already locked above - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - - lock (conn.RegionScene.EastBorders) - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.WestBorders) - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - } - } - - lock (scene.SouthBorders) - { - scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south - scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } - - lock (conn.RegionScene.EastBorders) - { - if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) - { - - conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; - lock (conn.RegionScene.NorthBorders) - conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - lock (conn.RegionScene.SouthBorders) - conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; - - - } - } - - lock (scene.WestBorders) - { - scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West - scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; - scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; - } - - /* - else - { - conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; - conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; - conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; - scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south - } - */ - - - // Reset Terrain.. since terrain normally loads first. - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); - //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); - scene.BordersLocked = false; - conn.RegionScene.BordersLocked = false; - - if (conn.ClientEventForwarder != null) - conn.ClientEventForwarder.AddSceneToEventForwarding(scene); - - return true; - - //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); - - } - - private void DoWorkForRootRegion(RegionConnections regionConnections, Scene scene) - { - RegionData rdata = new RegionData(); - rdata.Offset = Vector3.Zero; - rdata.RegionId = scene.RegionInfo.originRegionID; - rdata.RegionScene = scene; - // save it's land channel - regionConnections.RegionLandChannel = scene.LandChannel; - - // Substitue our landchannel - RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, - regionConnections.ConnectedRegions); - scene.LandChannel = lnd; - // Forward the permissions modules of each of the connected regions to the root region - lock (m_regions) - { - foreach (RegionData r in regionConnections.ConnectedRegions) - { - ForwardPermissionRequests(regionConnections, r.RegionScene); - } - } - // Create the root region's Client Event Forwarder - regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); - - // Sets up the CoarseLocationUpdate forwarder for this root region - scene.EventManager.OnNewPresence += SetCourseLocationDelegate; - - // Adds this root region to a dictionary of regions that are connectable - m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); - } - - private void SetCourseLocationDelegate(ScenePresence presence) - { - presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); - } - - private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence) - { - RegionConnections connectiondata = null; - lock (m_regions) - { - if (m_regions.ContainsKey(sceneId)) - connectiondata = m_regions[sceneId]; - else - return; - } - - List avatars = connectiondata.RegionScene.GetAvatars(); - List CoarseLocations = new List(); - List AvatarUUIDs = new List(); - for (int i = 0; i < avatars.Count; i++) - { - if (avatars[i].UUID != presence.UUID) - { - if (avatars[i].ParentID != 0) - { - // sitting avatar - SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(avatars[i].ParentID); - if (sop != null) - { - CoarseLocations.Add(sop.AbsolutePosition + avatars[i].AbsolutePosition); - AvatarUUIDs.Add(avatars[i].UUID); - } - else - { - // we can't find the parent.. ! arg! - CoarseLocations.Add(avatars[i].AbsolutePosition); - AvatarUUIDs.Add(avatars[i].UUID); - } - } - else - { - CoarseLocations.Add(avatars[i].AbsolutePosition); - AvatarUUIDs.Add(avatars[i].UUID); - } - } - } - DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); - } - - private void DistributeCourseLocationUpdates(List locations, List uuids, - RegionConnections connectiondata, ScenePresence rootPresence) - { - RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); - //List clients = new List(); - Dictionary updates = new Dictionary(); - - // Root Region entry - RegionCourseLocationStruct rootupdatedata = new RegionCourseLocationStruct(); - rootupdatedata.Locations = new List(); - rootupdatedata.Uuids = new List(); - rootupdatedata.Offset = Vector2.Zero; - - rootupdatedata.UserAPI = rootPresence.ControllingClient; - - if (rootupdatedata.UserAPI != null) - updates.Add(Vector2.Zero, rootupdatedata); - - //Each Region needs an entry or we will end up with dead minimap dots - foreach (RegionData regiondata in rdata) - { - Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); - RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); - updatedata.Locations = new List(); - updatedata.Uuids = new List(); - updatedata.Offset = offset; - - if (offset == Vector2.Zero) - updatedata.UserAPI = rootPresence.ControllingClient; - else - updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); - - if (updatedata.UserAPI != null) - updates.Add(offset, updatedata); - } - - // go over the locations and assign them to an IClientAPI - for (int i = 0; i < locations.Count; i++) - //{locations[i]/(int) Constants.RegionSize; - { - Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize, - (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z); - Vector2 offset = new Vector2(pPosition.X*(int) Constants.RegionSize, - pPosition.Y*(int) Constants.RegionSize); - - if (!updates.ContainsKey(offset)) - { - // This shouldn't happen - RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); - updatedata.Locations = new List(); - updatedata.Uuids = new List(); - updatedata.Offset = offset; - - if (offset == Vector2.Zero) - updatedata.UserAPI = rootPresence.ControllingClient; - else - updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); - - updates.Add(offset,updatedata); - } - - updates[offset].Locations.Add(locations[i]); - updates[offset].Uuids.Add(uuids[i]); - } - - // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is - foreach (Vector2 offset in updates.Keys) - { - if (updates[offset].UserAPI != null) - { - updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids,updates[offset].Locations); - } - } - } - - /// - /// Locates a the Client of a particular region in an Array of RegionData based on offset - /// - /// - /// - /// - /// IClientAPI or null - private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata) - { - IClientAPI returnclient = null; - foreach (RegionData r in rdata) - { - if (r.Offset.X == offset.X && r.Offset.Y == offset.Y) - { - return r.RegionScene.SceneGraph.GetControllingClient(uUID); - } - } - - return returnclient; - } - - public void PostInitialise() - { - } - - /// - /// TODO: - /// - /// - public void UnCombineRegion(RegionData rdata) - { - lock (m_regions) - { - if (m_regions.ContainsKey(rdata.RegionId)) - { - // uncombine root region and virtual regions - } - else - { - foreach (RegionConnections r in m_regions.Values) - { - foreach (RegionData rd in r.ConnectedRegions) - { - if (rd.RegionId == rdata.RegionId) - { - // uncombine virtual region - } - } - } - } - } - } - - // Create a set of infinite borders around the whole aabb of the combined island. - private void AdjustLargeRegionBounds() - { - lock (m_regions) - { - foreach (RegionConnections rconn in m_regions.Values) - { - Vector3 offset = Vector3.Zero; - rconn.RegionScene.BordersLocked = true; - foreach (RegionData rdata in rconn.ConnectedRegions) - { - if (rdata.Offset.X > offset.X) offset.X = rdata.Offset.X; - if (rdata.Offset.Y > offset.Y) offset.Y = rdata.Offset.Y; - } - - lock (rconn.RegionScene.NorthBorders) - { - Border northBorder = null; - // If we don't already have an infinite border, create one. - if (!TryGetInfiniteBorder(rconn.RegionScene.NorthBorders, out northBorder)) - { - northBorder = new Border(); - rconn.RegionScene.NorthBorders.Add(northBorder); - } - - northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, - offset.Y + (int) Constants.RegionSize); //<--- - northBorder.CrossDirection = Cardinals.N; - } - - lock (rconn.RegionScene.SouthBorders) - { - Border southBorder = null; - // If we don't already have an infinite border, create one. - if (!TryGetInfiniteBorder(rconn.RegionScene.SouthBorders, out southBorder)) - { - southBorder = new Border(); - rconn.RegionScene.SouthBorders.Add(southBorder); - } - southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> - southBorder.CrossDirection = Cardinals.S; - } - - lock (rconn.RegionScene.EastBorders) - { - Border eastBorder = null; - // If we don't already have an infinite border, create one. - if (!TryGetInfiniteBorder(rconn.RegionScene.EastBorders, out eastBorder)) - { - eastBorder = new Border(); - rconn.RegionScene.EastBorders.Add(eastBorder); - } - eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, offset.X + (int)Constants.RegionSize); - //<--- - eastBorder.CrossDirection = Cardinals.E; - } - - lock (rconn.RegionScene.WestBorders) - { - Border westBorder = null; - // If we don't already have an infinite border, create one. - if (!TryGetInfiniteBorder(rconn.RegionScene.WestBorders, out westBorder)) - { - westBorder = new Border(); - rconn.RegionScene.WestBorders.Add(westBorder); - - } - westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> - westBorder.CrossDirection = Cardinals.W; - } - - rconn.RegionScene.BordersLocked = false; - } - } - } - - /// - /// Try and get an Infinite border out of a listT of borders - /// - /// - /// - /// - public static bool TryGetInfiniteBorder(List borders, out Border oborder) - { - // Warning! Should be locked before getting here! - foreach (Border b in borders) - { - if (b.BorderLine.X == float.MinValue && b.BorderLine.Y == float.MaxValue) - { - oborder = b; - return true; - } - } - oborder = null; - return false; - } - - public RegionData GetRegionFromPosition(Vector3 pPosition) - { - pPosition = pPosition/(int) Constants.RegionSize; - int OffsetX = (int) pPosition.X; - int OffsetY = (int) pPosition.Y; - foreach (RegionConnections regConn in m_regions.Values) - { - foreach (RegionData reg in regConn.ConnectedRegions) - { - if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) - return reg; - } - } - return new RegionData(); - } - - public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion) - { - if (BigRegion.PermissionModule == null) - BigRegion.PermissionModule = new RegionCombinerPermissionModule(BigRegion.RegionScene); - - VirtualRegion.Permissions.OnBypassPermissions += BigRegion.PermissionModule.BypassPermissions; - VirtualRegion.Permissions.OnSetBypassPermissions += BigRegion.PermissionModule.SetBypassPermissions; - VirtualRegion.Permissions.OnPropagatePermissions += BigRegion.PermissionModule.PropagatePermissions; - VirtualRegion.Permissions.OnGenerateClientFlags += BigRegion.PermissionModule.GenerateClientFlags; - VirtualRegion.Permissions.OnAbandonParcel += BigRegion.PermissionModule.CanAbandonParcel; - VirtualRegion.Permissions.OnReclaimParcel += BigRegion.PermissionModule.CanReclaimParcel; - VirtualRegion.Permissions.OnDeedParcel += BigRegion.PermissionModule.CanDeedParcel; - VirtualRegion.Permissions.OnDeedObject += BigRegion.PermissionModule.CanDeedObject; - VirtualRegion.Permissions.OnIsGod += BigRegion.PermissionModule.IsGod; - VirtualRegion.Permissions.OnDuplicateObject += BigRegion.PermissionModule.CanDuplicateObject; - VirtualRegion.Permissions.OnDeleteObject += BigRegion.PermissionModule.CanDeleteObject; //MAYBE FULLY IMPLEMENTED - VirtualRegion.Permissions.OnEditObject += BigRegion.PermissionModule.CanEditObject; //MAYBE FULLY IMPLEMENTED - VirtualRegion.Permissions.OnEditParcel += BigRegion.PermissionModule.CanEditParcel; //MAYBE FULLY IMPLEMENTED - VirtualRegion.Permissions.OnInstantMessage += BigRegion.PermissionModule.CanInstantMessage; - VirtualRegion.Permissions.OnInventoryTransfer += BigRegion.PermissionModule.CanInventoryTransfer; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED - VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED - VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry; - VirtualRegion.Permissions.OnReturnObject += BigRegion.PermissionModule.CanReturnObject; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED - VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand; - VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnCompileScript += BigRegion.PermissionModule.CanCompileScript; - VirtualRegion.Permissions.OnSellParcel += BigRegion.PermissionModule.CanSellParcel; - VirtualRegion.Permissions.OnTakeObject += BigRegion.PermissionModule.CanTakeObject; - VirtualRegion.Permissions.OnTakeCopyObject += BigRegion.PermissionModule.CanTakeCopyObject; - VirtualRegion.Permissions.OnTerraformLand += BigRegion.PermissionModule.CanTerraformLand; - VirtualRegion.Permissions.OnLinkObject += BigRegion.PermissionModule.CanLinkObject; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnDelinkObject += BigRegion.PermissionModule.CanDelinkObject; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnBuyLand += BigRegion.PermissionModule.CanBuyLand; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnViewNotecard += BigRegion.PermissionModule.CanViewNotecard; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnViewScript += BigRegion.PermissionModule.CanViewScript; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnEditNotecard += BigRegion.PermissionModule.CanEditNotecard; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnEditScript += BigRegion.PermissionModule.CanEditScript; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnCreateObjectInventory += BigRegion.PermissionModule.CanCreateObjectInventory; //NOT IMPLEMENTED HERE - VirtualRegion.Permissions.OnEditObjectInventory += BigRegion.PermissionModule.CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED - VirtualRegion.Permissions.OnCopyObjectInventory += BigRegion.PermissionModule.CanCopyObjectInventory; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnDeleteObjectInventory += BigRegion.PermissionModule.CanDeleteObjectInventory; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnResetScript += BigRegion.PermissionModule.CanResetScript; - VirtualRegion.Permissions.OnCreateUserInventory += BigRegion.PermissionModule.CanCreateUserInventory; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnCopyUserInventory += BigRegion.PermissionModule.CanCopyUserInventory; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED - VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED - } - - #region console commands - public void FixPhantoms(string module, string[] cmdparams) - { - List scenes = new List(m_startingScenes.Values); - foreach (Scene s in scenes) - { - s.ForEachSOG(delegate(SceneObjectGroup e) - { - e.AbsolutePosition = e.AbsolutePosition; - } - ); - } - } - #endregion - } -} diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerPermissionModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerPermissionModule.cs deleted file mode 100644 index 76ca5e3..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerPermissionModule.cs +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.World.Land -{ - public class RegionCombinerPermissionModule - { - private Scene m_rootScene; - - public RegionCombinerPermissionModule(Scene RootScene) - { - m_rootScene = RootScene; - } - - #region Permission Override - - public bool BypassPermissions() - { - return m_rootScene.Permissions.BypassPermissions(); - } - - public void SetBypassPermissions(bool value) - { - m_rootScene.Permissions.SetBypassPermissions(value); - } - - public bool PropagatePermissions() - { - return m_rootScene.Permissions.PropagatePermissions(); - } - - public uint GenerateClientFlags(UUID userid, UUID objectidid) - { - return m_rootScene.Permissions.GenerateClientFlags(userid,objectidid); - } - - public bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene) - { - return m_rootScene.Permissions.CanAbandonParcel(user,parcel); - } - - public bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene) - { - return m_rootScene.Permissions.CanReclaimParcel(user, parcel); - } - - public bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene) - { - return m_rootScene.Permissions.CanDeedParcel(user, parcel); - } - - public bool CanDeedObject(UUID user, UUID @group, Scene scene) - { - return m_rootScene.Permissions.CanDeedObject(user,@group); - } - - public bool IsGod(UUID user, Scene requestfromscene) - { - return m_rootScene.Permissions.IsGod(user); - } - - public bool CanDuplicateObject(int objectcount, UUID objectid, UUID owner, Scene scene, Vector3 objectposition) - { - return m_rootScene.Permissions.CanDuplicateObject(objectcount, objectid, owner, objectposition); - } - - public bool CanDeleteObject(UUID objectid, UUID deleter, Scene scene) - { - return m_rootScene.Permissions.CanDeleteObject(objectid, deleter); - } - - public bool CanEditObject(UUID objectid, UUID editorid, Scene scene) - { - return m_rootScene.Permissions.CanEditObject(objectid, editorid); - } - - public bool CanEditParcel(UUID user, ILandObject parcel, Scene scene) - { - return m_rootScene.Permissions.CanEditParcel(user, parcel); - } - - public bool CanInstantMessage(UUID user, UUID target, Scene startscene) - { - return m_rootScene.Permissions.CanInstantMessage(user, target); - } - - public bool CanInventoryTransfer(UUID user, UUID target, Scene startscene) - { - return m_rootScene.Permissions.CanInventoryTransfer(user, target); - } - - public bool CanIssueEstateCommand(UUID user, Scene requestfromscene, bool ownercommand) - { - return m_rootScene.Permissions.CanIssueEstateCommand(user, ownercommand); - } - - public bool CanMoveObject(UUID objectid, UUID moverid, Scene scene) - { - return m_rootScene.Permissions.CanMoveObject(objectid, moverid); - } - - public bool CanObjectEntry(UUID objectid, bool enteringregion, Vector3 newpoint, Scene scene) - { - return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint); - } - - public bool CanReturnObject(UUID objectid, UUID returnerid, Scene scene) - { - return m_rootScene.Permissions.CanReturnObject(objectid, returnerid); - } - - public bool CanRezObject(int objectcount, UUID owner, Vector3 objectposition, Scene scene) - { - return m_rootScene.Permissions.CanRezObject(objectcount, owner, objectposition); - } - - public bool CanRunConsoleCommand(UUID user, Scene requestfromscene) - { - return m_rootScene.Permissions.CanRunConsoleCommand(user); - } - - public bool CanRunScript(UUID script, UUID objectid, UUID user, Scene scene) - { - return m_rootScene.Permissions.CanRunScript(script, objectid, user); - } - - public bool CanCompileScript(UUID owneruuid, int scripttype, Scene scene) - { - return m_rootScene.Permissions.CanCompileScript(owneruuid, scripttype); - } - - public bool CanSellParcel(UUID user, ILandObject parcel, Scene scene) - { - return m_rootScene.Permissions.CanSellParcel(user, parcel); - } - - public bool CanTakeObject(UUID objectid, UUID stealer, Scene scene) - { - return m_rootScene.Permissions.CanTakeObject(objectid, stealer); - } - - public bool CanTakeCopyObject(UUID objectid, UUID userid, Scene inscene) - { - return m_rootScene.Permissions.CanTakeObject(objectid, userid); - } - - public bool CanTerraformLand(UUID user, Vector3 position, Scene requestfromscene) - { - return m_rootScene.Permissions.CanTerraformLand(user, position); - } - - public bool CanLinkObject(UUID user, UUID objectid) - { - return m_rootScene.Permissions.CanLinkObject(user, objectid); - } - - public bool CanDelinkObject(UUID user, UUID objectid) - { - return m_rootScene.Permissions.CanDelinkObject(user, objectid); - } - - public bool CanBuyLand(UUID user, ILandObject parcel, Scene scene) - { - return m_rootScene.Permissions.CanBuyLand(user, parcel); - } - - public bool CanViewNotecard(UUID script, UUID objectid, UUID user, Scene scene) - { - return m_rootScene.Permissions.CanViewNotecard(script, objectid, user); - } - - public bool CanViewScript(UUID script, UUID objectid, UUID user, Scene scene) - { - return m_rootScene.Permissions.CanViewScript(script, objectid, user); - } - - public bool CanEditNotecard(UUID notecard, UUID objectid, UUID user, Scene scene) - { - return m_rootScene.Permissions.CanEditNotecard(notecard, objectid, user); - } - - public bool CanEditScript(UUID script, UUID objectid, UUID user, Scene scene) - { - return m_rootScene.Permissions.CanEditScript(script, objectid, user); - } - - public bool CanCreateObjectInventory(int invtype, UUID objectid, UUID userid) - { - return m_rootScene.Permissions.CanCreateObjectInventory(invtype, objectid, userid); - } - - public bool CanEditObjectInventory(UUID objectid, UUID editorid, Scene scene) - { - return m_rootScene.Permissions.CanEditObjectInventory(objectid, editorid); - } - - public bool CanCopyObjectInventory(UUID itemid, UUID objectid, UUID userid) - { - return m_rootScene.Permissions.CanCopyObjectInventory(itemid, objectid, userid); - } - - public bool CanDeleteObjectInventory(UUID itemid, UUID objectid, UUID userid) - { - return m_rootScene.Permissions.CanDeleteObjectInventory(itemid, objectid, userid); - } - - public bool CanResetScript(UUID prim, UUID script, UUID user, Scene scene) - { - return m_rootScene.Permissions.CanResetScript(prim, script, user); - } - - public bool CanCreateUserInventory(int invtype, UUID userid) - { - return m_rootScene.Permissions.CanCreateUserInventory(invtype, userid); - } - - public bool CanCopyUserInventory(UUID itemid, UUID userid) - { - return m_rootScene.Permissions.CanCopyUserInventory(itemid, userid); - } - - public bool CanEditUserInventory(UUID itemid, UUID userid) - { - return m_rootScene.Permissions.CanEditUserInventory(itemid, userid); - } - - public bool CanDeleteUserInventory(UUID itemid, UUID userid) - { - return m_rootScene.Permissions.CanDeleteUserInventory(itemid, userid); - } - - public bool CanTeleport(UUID userid, Scene scene) - { - return m_rootScene.Permissions.CanTeleport(userid); - } - - public bool CanUseObjectReturn(ILandObject landdata, uint type, IClientAPI client, List retlist, Scene scene) - { - return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist); - } - - #endregion - } -} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Land/RegionConnections.cs b/OpenSim/Region/CoreModules/World/Land/RegionConnections.cs deleted file mode 100644 index 419ed74..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionConnections.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.World.Land -{ - public class RegionConnections - { - /// - /// Root Region ID - /// - public UUID RegionId; - - /// - /// Root Region Scene - /// - public Scene RegionScene; - - /// - /// LargeLandChannel for combined region - /// - public ILandChannel RegionLandChannel; - public uint X; - public uint Y; - public int XEnd; - public int YEnd; - public List ConnectedRegions; - public RegionCombinerPermissionModule PermissionModule; - public RegionCombinerClientEventForwarder ClientEventForwarder; - public void UpdateExtents(Vector3 extents) - { - XEnd = (int)extents.X; - YEnd = (int)extents.Y; - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCourseLocation.cs b/OpenSim/Region/CoreModules/World/Land/RegionCourseLocation.cs deleted file mode 100644 index 175ca89..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionCourseLocation.cs +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; - -namespace OpenSim.Region.CoreModules.World.Land -{ - - struct RegionCourseLocationStruct - { - public List Locations; - public List Uuids; - public IClientAPI UserAPI; - public Vector2 Offset; - } -} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Land/RegionData.cs b/OpenSim/Region/CoreModules/World/Land/RegionData.cs deleted file mode 100644 index 3383527..0000000 --- a/OpenSim/Region/CoreModules/World/Land/RegionData.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using OpenMetaverse; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.World.Land -{ - public class RegionData - { - public UUID RegionId; - public Scene RegionScene; - public Vector3 Offset; - } -} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs new file mode 100644 index 0000000..70d6de3 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs @@ -0,0 +1,94 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Land +{ +public class RegionCombinerClientEventForwarder + { + private Scene m_rootScene; + private Dictionary m_virtScene = new Dictionary(); + private Dictionary m_forwarders = new Dictionary(); + + public RegionCombinerClientEventForwarder(RegionConnections rootScene) + { + m_rootScene = rootScene.RegionScene; + } + + public void AddSceneToEventForwarding(Scene virtualScene) + { + lock (m_virtScene) + { + if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID)) + { + m_virtScene[virtualScene.RegionInfo.originRegionID] = virtualScene; + } + else + { + m_virtScene.Add(virtualScene.RegionInfo.originRegionID, virtualScene); + } + } + + lock (m_forwarders) + { + // TODO: Fix this to unregister if this happens + if (m_forwarders.ContainsKey(virtualScene.RegionInfo.originRegionID)) + m_forwarders.Remove(virtualScene.RegionInfo.originRegionID); + + RegionCombinerIndividualEventForwarder forwarder = + new RegionCombinerIndividualEventForwarder(m_rootScene, virtualScene); + m_forwarders.Add(virtualScene.RegionInfo.originRegionID, forwarder); + + virtualScene.EventManager.OnNewClient += forwarder.ClientConnect; + virtualScene.EventManager.OnClientClosed += forwarder.ClientClosed; + } + } + + public void RemoveSceneFromEventForwarding (Scene virtualScene) + { + lock (m_forwarders) + { + RegionCombinerIndividualEventForwarder forwarder = m_forwarders[virtualScene.RegionInfo.originRegionID]; + virtualScene.EventManager.OnNewClient -= forwarder.ClientConnect; + virtualScene.EventManager.OnClientClosed -= forwarder.ClientClosed; + m_forwarders.Remove(virtualScene.RegionInfo.originRegionID); + } + lock (m_virtScene) + { + if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID)) + { + m_virtScene.Remove(virtualScene.RegionInfo.originRegionID); + } + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs new file mode 100644 index 0000000..2cbaf96 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs @@ -0,0 +1,125 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Land +{ + public class RegionCombinerIndividualEventForwarder + { + private Scene m_rootScene; + private Scene m_virtScene; + + public RegionCombinerIndividualEventForwarder(Scene rootScene, Scene virtScene) + { + m_rootScene = rootScene; + m_virtScene = virtScene; + } + + public void ClientConnect(IClientAPI client) + { + m_virtScene.UnSubscribeToClientPrimEvents(client); + m_virtScene.UnSubscribeToClientPrimRezEvents(client); + m_virtScene.UnSubscribeToClientInventoryEvents(client); + m_virtScene.UnSubscribeToClientAttachmentEvents(client); + //m_virtScene.UnSubscribeToClientTeleportEvents(client); + m_virtScene.UnSubscribeToClientScriptEvents(client); + m_virtScene.UnSubscribeToClientGodEvents(client); + m_virtScene.UnSubscribeToClientNetworkEvents(client); + + m_rootScene.SubscribeToClientPrimEvents(client); + client.OnAddPrim += LocalAddNewPrim; + client.OnRezObject += LocalRezObject; + m_rootScene.SubscribeToClientInventoryEvents(client); + m_rootScene.SubscribeToClientAttachmentEvents(client); + //m_rootScene.SubscribeToClientTeleportEvents(client); + m_rootScene.SubscribeToClientScriptEvents(client); + m_rootScene.SubscribeToClientGodEvents(client); + m_rootScene.SubscribeToClientNetworkEvents(client); + } + + public void ClientClosed(UUID clientid, Scene scene) + { + } + + /// + /// Fixes position based on the region the Rez event came in on + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart, + UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem, + UUID fromtaskid) + { + int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; + int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; + rayend.X += differenceX * (int)Constants.RegionSize; + rayend.Y += differenceY * (int)Constants.RegionSize; + raystart.X += differenceX * (int)Constants.RegionSize; + raystart.Y += differenceY * (int)Constants.RegionSize; + + m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast, + rayendisintersection, rezselected, removeitem, fromtaskid); + } + /// + /// Fixes position based on the region the AddPrimShape event came in on + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot, + PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid, + byte rayendisintersection) + { + int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX; + int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY; + rayend.X += differenceX * (int)Constants.RegionSize; + rayend.Y += differenceY * (int)Constants.RegionSize; + raystart.X += differenceX * (int)Constants.RegionSize; + raystart.Y += differenceY * (int)Constants.RegionSize; + m_rootScene.AddNewPrim(ownerid, groupid, rayend, rot, shape, bypassraycast, raystart, raytargetid, + rayendisintersection); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs new file mode 100644 index 0000000..7df836c --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs @@ -0,0 +1,163 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; + +namespace OpenSim.Region.CoreModules.World.Land +{ +public class RegionCombinerLargeLandChannel : ILandChannel + { + // private static readonly ILog m_log = + // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private RegionData RegData; + private ILandChannel RootRegionLandChannel; + private readonly List RegionConnections; + + #region ILandChannel Members + + public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel, + List regionConnections) + { + RegData = regData; + RootRegionLandChannel = rootRegionLandChannel; + RegionConnections = regionConnections; + } + + public List ParcelsNearPoint(Vector3 position) + { + //m_log.DebugFormat("[LANDPARCELNEARPOINT]: {0}>", position); + return RootRegionLandChannel.ParcelsNearPoint(position - RegData.Offset); + } + + public List AllParcels() + { + return RootRegionLandChannel.AllParcels(); + } + + public ILandObject GetLandObject(int x, int y) + { + //m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y); + + if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) + { + return RootRegionLandChannel.GetLandObject(x, y); + } + else + { + int offsetX = (x / (int)Constants.RegionSize); + int offsetY = (y / (int)Constants.RegionSize); + offsetX *= (int)Constants.RegionSize; + offsetY *= (int)Constants.RegionSize; + + foreach (RegionData regionData in RegionConnections) + { + if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) + { + return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); + } + } + ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); + obj.LandData.Name = "NO LAND"; + return obj; + } + } + + public ILandObject GetLandObject(int localID) + { + return RootRegionLandChannel.GetLandObject(localID); + } + + public ILandObject GetLandObject(float x, float y) + { + //m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y); + + if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize) + { + return RootRegionLandChannel.GetLandObject(x, y); + } + else + { + int offsetX = (int)(x/(int) Constants.RegionSize); + int offsetY = (int)(y/(int) Constants.RegionSize); + offsetX *= (int) Constants.RegionSize; + offsetY *= (int) Constants.RegionSize; + + foreach (RegionData regionData in RegionConnections) + { + if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY) + { + return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY); + } + } + ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene); + obj.LandData.Name = "NO LAND"; + return obj; + } + } + + public bool IsLandPrimCountTainted() + { + return RootRegionLandChannel.IsLandPrimCountTainted(); + } + + public bool IsForcefulBansAllowed() + { + return RootRegionLandChannel.IsForcefulBansAllowed(); + } + + public void UpdateLandObject(int localID, LandData data) + { + RootRegionLandChannel.UpdateLandObject(localID, data); + } + + public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) + { + RootRegionLandChannel.ReturnObjectsInParcel(localID, returnType, agentIDs, taskIDs, remoteClient); + } + + public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel) + { + RootRegionLandChannel.setParcelObjectMaxOverride(overrideDel); + } + + public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel) + { + RootRegionLandChannel.setSimulatorObjectMaxOverride(overrideDel); + } + + public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) + { + RootRegionLandChannel.SetParcelOtherCleanTime(remoteClient, localID, otherCleanTime); + } + + #endregion + } +} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs new file mode 100644 index 0000000..6859d6d --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -0,0 +1,964 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Framework.Console; +using OpenSim.Region.Physics.Manager; + +namespace OpenSim.Region.CoreModules.World.Land +{ + public class RegionCombinerModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public string Name + { + get { return "RegionCombinerModule"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + private Dictionary m_regions = new Dictionary(); + private bool enabledYN = false; + private Dictionary m_startingScenes = new Dictionary(); + + public void Initialise(IConfigSource source) + { + IConfig myConfig = source.Configs["Startup"]; + enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false); + //enabledYN = true; + if (enabledYN) + MainConsole.Instance.Commands.AddCommand("RegionCombinerModule", false, "fix-phantoms", + "Fix phantom objects", "Fixes phantom objects after an import to megaregions", FixPhantoms); + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + if (enabledYN) + RegionLoadedDoWork(scene); + } + + private void RegionLoadedDoWork(Scene scene) + { +/* + // For testing on a single instance + if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000) + return; + // +*/ + lock (m_startingScenes) + m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); + + // Give each region a standard set of non-infinite borders + Border northBorder = new Border(); + northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- + northBorder.CrossDirection = Cardinals.N; + scene.NorthBorders[0] = northBorder; + + Border southBorder = new Border(); + southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> + southBorder.CrossDirection = Cardinals.S; + scene.SouthBorders[0] = southBorder; + + Border eastBorder = new Border(); + eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- + eastBorder.CrossDirection = Cardinals.E; + scene.EastBorders[0] = eastBorder; + + Border westBorder = new Border(); + westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> + westBorder.CrossDirection = Cardinals.W; + scene.WestBorders[0] = westBorder; + + + + RegionConnections regionConnections = new RegionConnections(); + regionConnections.ConnectedRegions = new List(); + regionConnections.RegionScene = scene; + regionConnections.RegionLandChannel = scene.LandChannel; + regionConnections.RegionId = scene.RegionInfo.originRegionID; + regionConnections.X = scene.RegionInfo.RegionLocX; + regionConnections.Y = scene.RegionInfo.RegionLocY; + regionConnections.XEnd = (int)Constants.RegionSize; + regionConnections.YEnd = (int)Constants.RegionSize; + + + lock (m_regions) + { + bool connectedYN = false; + + foreach (RegionConnections conn in m_regions.Values) + { + #region commented + /* + // If we're one region over +x +y + //xxy + //xxx + //xxx + if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd + == (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd + == (regionConnections.Y * (int)Constants.RegionSize))) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int) Constants.RegionSize)) - + ((conn.X * (int) Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int) Constants.RegionSize)) - + ((conn.Y * (int) Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = conn.XEnd + conn.XEnd; + + m_log.DebugFormat("Scene: {0} to the northwest of Scene{1}. Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, + offset, extents); + + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); + + connectedYN = true; + break; + } + */ + + /* + //If we're one region over x +y + //xxx + //xxx + //xyx + if ((((int)conn.X * (int)Constants.RegionSize) + == (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd + == (regionConnections.Y * (int)Constants.RegionSize))) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = conn.XEnd; + + m_log.DebugFormat("Scene: {0} to the north of Scene{1}. Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); + connectedYN = true; + break; + } + */ + + /* + // If we're one region over -x +y + //xxx + //xxx + //yxx + if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd + == (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd + == (regionConnections.Y * (int)Constants.RegionSize))) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = conn.XEnd + conn.XEnd; + + m_log.DebugFormat("Scene: {0} to the northeast of Scene. Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); + + + connectedYN = true; + break; + } + */ + + /* + // If we're one region over -x y + //xxx + //yxx + //xxx + if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd + == (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) + == (regionConnections.Y * (int)Constants.RegionSize))) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd; + extents.X = conn.XEnd + conn.XEnd; + + m_log.DebugFormat("Scene: {0} to the east of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); + + connectedYN = true; + break; + } + */ + + /* + // If we're one region over -x -y + //yxx + //xxx + //xxx + if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd + == (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd + == (regionConnections.Y * (int)Constants.RegionSize))) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = conn.XEnd + conn.XEnd; + + m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents); + + connectedYN = true; + break; + } + */ + #endregion + + // If we're one region over +x y + //xxx + //xxy + //xxx + + + if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd + >= (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) + >= (regionConnections.Y * (int)Constants.RegionSize))) + { + connectedYN = DoWorkForOneRegionOverPlusXY(conn, regionConnections, scene); + break; + } + + // If we're one region over x +y + //xyx + //xxx + //xxx + if ((((int)conn.X * (int)Constants.RegionSize) + >= (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd + >= (regionConnections.Y * (int)Constants.RegionSize))) + { + connectedYN = DoWorkForOneRegionOverXPlusY(conn, regionConnections, scene); + break; + } + + // If we're one region over +x +y + //xxy + //xxx + //xxx + if ((((int)conn.X * (int)Constants.RegionSize) + conn.YEnd + >= (regionConnections.X * (int)Constants.RegionSize)) + && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd + >= (regionConnections.Y * (int)Constants.RegionSize))) + { + connectedYN = DoWorkForOneRegionOverPlusXPlusY(conn, regionConnections, scene); + break; + + } + } + + // If !connectYN means that this region is a root region + if (!connectedYN) + { + DoWorkForRootRegion(regionConnections, scene); + + } + } + // Set up infinite borders around the entire AABB of the combined ConnectedRegions + AdjustLargeRegionBounds(); + } + + private bool DoWorkForOneRegionOverPlusXY(RegionConnections conn, RegionConnections regionConnections, Scene scene) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = conn.YEnd; + extents.X = conn.XEnd + regionConnections.XEnd; + + conn.UpdateExtents(extents); + + m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; + + RegionData ConnectedRegion = new RegionData(); + ConnectedRegion.Offset = offset; + ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; + ConnectedRegion.RegionScene = scene; + conn.ConnectedRegions.Add(ConnectedRegion); + + // Inform root region Physics about the extents of this region + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); + + // Inform Child region that it needs to forward it's terrain to the root region + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); + + // Extend the borders as appropriate + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; + + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + + lock (conn.RegionScene.SouthBorders) + conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + + lock (scene.WestBorders) + { + + + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West + + // Trigger auto teleport to root region + scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } + + // Reset Terrain.. since terrain loads before we get here, we need to load + // it again so it loads in the root region + + scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); + + // Unlock borders + conn.RegionScene.BordersLocked = false; + scene.BordersLocked = false; + + // Create a client event forwarder and add this region's events to the root region. + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); + + return true; + } + + private bool DoWorkForOneRegionOverXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = conn.XEnd; + conn.UpdateExtents(extents); + + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; + + RegionData ConnectedRegion = new RegionData(); + ConnectedRegion.Offset = offset; + ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; + ConnectedRegion.RegionScene = scene; + conn.ConnectedRegions.Add(ConnectedRegion); + + m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); + + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.WestBorders) + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (scene.SouthBorders) + { + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south + scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } + + // Reset Terrain.. since terrain normally loads first. + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + + scene.BordersLocked = false; + conn.RegionScene.BordersLocked = false; + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); + return true; + } + + private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections conn, RegionConnections regionConnections, Scene scene) + { + Vector3 offset = Vector3.Zero; + offset.X = (((regionConnections.X * (int)Constants.RegionSize)) - + ((conn.X * (int)Constants.RegionSize))); + offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) - + ((conn.Y * (int)Constants.RegionSize))); + + Vector3 extents = Vector3.Zero; + extents.Y = regionConnections.YEnd + conn.YEnd; + extents.X = regionConnections.XEnd + conn.XEnd; + conn.UpdateExtents(extents); + + scene.BordersLocked = true; + conn.RegionScene.BordersLocked = true; + + RegionData ConnectedRegion = new RegionData(); + ConnectedRegion.Offset = offset; + ConnectedRegion.RegionId = scene.RegionInfo.originRegionID; + ConnectedRegion.RegionScene = scene; + + conn.ConnectedRegions.Add(ConnectedRegion); + + m_log.DebugFormat("Scene: {0} to the NorthEast of Scene{1} Offset: {2}. Extents:{3}", + conn.RegionScene.RegionInfo.RegionName, + regionConnections.RegionScene.RegionInfo.RegionName, offset, extents); + + conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents); + scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero); + lock (conn.RegionScene.NorthBorders) + { + if (conn.RegionScene.NorthBorders.Count == 1)// && 2) + { + //compound border + // already locked above + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + + lock (conn.RegionScene.EastBorders) + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.WestBorders) + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + } + } + + lock (scene.SouthBorders) + { + scene.SouthBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocY - conn.RegionScene.RegionInfo.RegionLocY) * (int)Constants.RegionSize); //auto teleport south + scene.SouthBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.SouthBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } + + lock (conn.RegionScene.EastBorders) + { + if (conn.RegionScene.EastBorders.Count == 1)// && conn.RegionScene.EastBorders.Count == 2) + { + + conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize; + lock (conn.RegionScene.NorthBorders) + conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + lock (conn.RegionScene.SouthBorders) + conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize; + + + } + } + + lock (scene.WestBorders) + { + scene.WestBorders[0].BorderLine.Z = (int)((scene.RegionInfo.RegionLocX - conn.RegionScene.RegionInfo.RegionLocX) * (int)Constants.RegionSize); //auto teleport West + scene.WestBorders[0].TriggerRegionX = conn.RegionScene.RegionInfo.RegionLocX; + scene.WestBorders[0].TriggerRegionY = conn.RegionScene.RegionInfo.RegionLocY; + } + + /* + else + { + conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize; + conn.RegionScene.EastBorders[0].BorderLine.Y += (int)Constants.RegionSize; + conn.RegionScene.WestBorders[0].BorderLine.Y += (int)Constants.RegionSize; + scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south + } + */ + + + // Reset Terrain.. since terrain normally loads first. + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); + //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised()); + scene.BordersLocked = false; + conn.RegionScene.BordersLocked = false; + + if (conn.ClientEventForwarder != null) + conn.ClientEventForwarder.AddSceneToEventForwarding(scene); + + return true; + + //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents); + + } + + private void DoWorkForRootRegion(RegionConnections regionConnections, Scene scene) + { + RegionData rdata = new RegionData(); + rdata.Offset = Vector3.Zero; + rdata.RegionId = scene.RegionInfo.originRegionID; + rdata.RegionScene = scene; + // save it's land channel + regionConnections.RegionLandChannel = scene.LandChannel; + + // Substitue our landchannel + RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel, + regionConnections.ConnectedRegions); + scene.LandChannel = lnd; + // Forward the permissions modules of each of the connected regions to the root region + lock (m_regions) + { + foreach (RegionData r in regionConnections.ConnectedRegions) + { + ForwardPermissionRequests(regionConnections, r.RegionScene); + } + } + // Create the root region's Client Event Forwarder + regionConnections.ClientEventForwarder = new RegionCombinerClientEventForwarder(regionConnections); + + // Sets up the CoarseLocationUpdate forwarder for this root region + scene.EventManager.OnNewPresence += SetCourseLocationDelegate; + + // Adds this root region to a dictionary of regions that are connectable + m_regions.Add(scene.RegionInfo.originRegionID, regionConnections); + } + + private void SetCourseLocationDelegate(ScenePresence presence) + { + presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); + } + + private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence) + { + RegionConnections connectiondata = null; + lock (m_regions) + { + if (m_regions.ContainsKey(sceneId)) + connectiondata = m_regions[sceneId]; + else + return; + } + + List avatars = connectiondata.RegionScene.GetAvatars(); + List CoarseLocations = new List(); + List AvatarUUIDs = new List(); + for (int i = 0; i < avatars.Count; i++) + { + if (avatars[i].UUID != presence.UUID) + { + if (avatars[i].ParentID != 0) + { + // sitting avatar + SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(avatars[i].ParentID); + if (sop != null) + { + CoarseLocations.Add(sop.AbsolutePosition + avatars[i].AbsolutePosition); + AvatarUUIDs.Add(avatars[i].UUID); + } + else + { + // we can't find the parent.. ! arg! + CoarseLocations.Add(avatars[i].AbsolutePosition); + AvatarUUIDs.Add(avatars[i].UUID); + } + } + else + { + CoarseLocations.Add(avatars[i].AbsolutePosition); + AvatarUUIDs.Add(avatars[i].UUID); + } + } + } + DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); + } + + private void DistributeCourseLocationUpdates(List locations, List uuids, + RegionConnections connectiondata, ScenePresence rootPresence) + { + RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); + //List clients = new List(); + Dictionary updates = new Dictionary(); + + // Root Region entry + RegionCourseLocationStruct rootupdatedata = new RegionCourseLocationStruct(); + rootupdatedata.Locations = new List(); + rootupdatedata.Uuids = new List(); + rootupdatedata.Offset = Vector2.Zero; + + rootupdatedata.UserAPI = rootPresence.ControllingClient; + + if (rootupdatedata.UserAPI != null) + updates.Add(Vector2.Zero, rootupdatedata); + + //Each Region needs an entry or we will end up with dead minimap dots + foreach (RegionData regiondata in rdata) + { + Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); + RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); + updatedata.Locations = new List(); + updatedata.Uuids = new List(); + updatedata.Offset = offset; + + if (offset == Vector2.Zero) + updatedata.UserAPI = rootPresence.ControllingClient; + else + updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); + + if (updatedata.UserAPI != null) + updates.Add(offset, updatedata); + } + + // go over the locations and assign them to an IClientAPI + for (int i = 0; i < locations.Count; i++) + //{locations[i]/(int) Constants.RegionSize; + { + Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize, + (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z); + Vector2 offset = new Vector2(pPosition.X*(int) Constants.RegionSize, + pPosition.Y*(int) Constants.RegionSize); + + if (!updates.ContainsKey(offset)) + { + // This shouldn't happen + RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); + updatedata.Locations = new List(); + updatedata.Uuids = new List(); + updatedata.Offset = offset; + + if (offset == Vector2.Zero) + updatedata.UserAPI = rootPresence.ControllingClient; + else + updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata); + + updates.Add(offset,updatedata); + } + + updates[offset].Locations.Add(locations[i]); + updates[offset].Uuids.Add(uuids[i]); + } + + // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is + foreach (Vector2 offset in updates.Keys) + { + if (updates[offset].UserAPI != null) + { + updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids,updates[offset].Locations); + } + } + } + + /// + /// Locates a the Client of a particular region in an Array of RegionData based on offset + /// + /// + /// + /// + /// IClientAPI or null + private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata) + { + IClientAPI returnclient = null; + foreach (RegionData r in rdata) + { + if (r.Offset.X == offset.X && r.Offset.Y == offset.Y) + { + return r.RegionScene.SceneGraph.GetControllingClient(uUID); + } + } + + return returnclient; + } + + public void PostInitialise() + { + } + + /// + /// TODO: + /// + /// + public void UnCombineRegion(RegionData rdata) + { + lock (m_regions) + { + if (m_regions.ContainsKey(rdata.RegionId)) + { + // uncombine root region and virtual regions + } + else + { + foreach (RegionConnections r in m_regions.Values) + { + foreach (RegionData rd in r.ConnectedRegions) + { + if (rd.RegionId == rdata.RegionId) + { + // uncombine virtual region + } + } + } + } + } + } + + // Create a set of infinite borders around the whole aabb of the combined island. + private void AdjustLargeRegionBounds() + { + lock (m_regions) + { + foreach (RegionConnections rconn in m_regions.Values) + { + Vector3 offset = Vector3.Zero; + rconn.RegionScene.BordersLocked = true; + foreach (RegionData rdata in rconn.ConnectedRegions) + { + if (rdata.Offset.X > offset.X) offset.X = rdata.Offset.X; + if (rdata.Offset.Y > offset.Y) offset.Y = rdata.Offset.Y; + } + + lock (rconn.RegionScene.NorthBorders) + { + Border northBorder = null; + // If we don't already have an infinite border, create one. + if (!TryGetInfiniteBorder(rconn.RegionScene.NorthBorders, out northBorder)) + { + northBorder = new Border(); + rconn.RegionScene.NorthBorders.Add(northBorder); + } + + northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, + offset.Y + (int) Constants.RegionSize); //<--- + northBorder.CrossDirection = Cardinals.N; + } + + lock (rconn.RegionScene.SouthBorders) + { + Border southBorder = null; + // If we don't already have an infinite border, create one. + if (!TryGetInfiniteBorder(rconn.RegionScene.SouthBorders, out southBorder)) + { + southBorder = new Border(); + rconn.RegionScene.SouthBorders.Add(southBorder); + } + southBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> + southBorder.CrossDirection = Cardinals.S; + } + + lock (rconn.RegionScene.EastBorders) + { + Border eastBorder = null; + // If we don't already have an infinite border, create one. + if (!TryGetInfiniteBorder(rconn.RegionScene.EastBorders, out eastBorder)) + { + eastBorder = new Border(); + rconn.RegionScene.EastBorders.Add(eastBorder); + } + eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, offset.X + (int)Constants.RegionSize); + //<--- + eastBorder.CrossDirection = Cardinals.E; + } + + lock (rconn.RegionScene.WestBorders) + { + Border westBorder = null; + // If we don't already have an infinite border, create one. + if (!TryGetInfiniteBorder(rconn.RegionScene.WestBorders, out westBorder)) + { + westBorder = new Border(); + rconn.RegionScene.WestBorders.Add(westBorder); + + } + westBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, 0); //---> + westBorder.CrossDirection = Cardinals.W; + } + + rconn.RegionScene.BordersLocked = false; + } + } + } + + /// + /// Try and get an Infinite border out of a listT of borders + /// + /// + /// + /// + public static bool TryGetInfiniteBorder(List borders, out Border oborder) + { + // Warning! Should be locked before getting here! + foreach (Border b in borders) + { + if (b.BorderLine.X == float.MinValue && b.BorderLine.Y == float.MaxValue) + { + oborder = b; + return true; + } + } + oborder = null; + return false; + } + + public RegionData GetRegionFromPosition(Vector3 pPosition) + { + pPosition = pPosition/(int) Constants.RegionSize; + int OffsetX = (int) pPosition.X; + int OffsetY = (int) pPosition.Y; + foreach (RegionConnections regConn in m_regions.Values) + { + foreach (RegionData reg in regConn.ConnectedRegions) + { + if (reg.Offset.X == OffsetX && reg.Offset.Y == OffsetY) + return reg; + } + } + return new RegionData(); + } + + public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion) + { + if (BigRegion.PermissionModule == null) + BigRegion.PermissionModule = new RegionCombinerPermissionModule(BigRegion.RegionScene); + + VirtualRegion.Permissions.OnBypassPermissions += BigRegion.PermissionModule.BypassPermissions; + VirtualRegion.Permissions.OnSetBypassPermissions += BigRegion.PermissionModule.SetBypassPermissions; + VirtualRegion.Permissions.OnPropagatePermissions += BigRegion.PermissionModule.PropagatePermissions; + VirtualRegion.Permissions.OnGenerateClientFlags += BigRegion.PermissionModule.GenerateClientFlags; + VirtualRegion.Permissions.OnAbandonParcel += BigRegion.PermissionModule.CanAbandonParcel; + VirtualRegion.Permissions.OnReclaimParcel += BigRegion.PermissionModule.CanReclaimParcel; + VirtualRegion.Permissions.OnDeedParcel += BigRegion.PermissionModule.CanDeedParcel; + VirtualRegion.Permissions.OnDeedObject += BigRegion.PermissionModule.CanDeedObject; + VirtualRegion.Permissions.OnIsGod += BigRegion.PermissionModule.IsGod; + VirtualRegion.Permissions.OnDuplicateObject += BigRegion.PermissionModule.CanDuplicateObject; + VirtualRegion.Permissions.OnDeleteObject += BigRegion.PermissionModule.CanDeleteObject; //MAYBE FULLY IMPLEMENTED + VirtualRegion.Permissions.OnEditObject += BigRegion.PermissionModule.CanEditObject; //MAYBE FULLY IMPLEMENTED + VirtualRegion.Permissions.OnEditParcel += BigRegion.PermissionModule.CanEditParcel; //MAYBE FULLY IMPLEMENTED + VirtualRegion.Permissions.OnInstantMessage += BigRegion.PermissionModule.CanInstantMessage; + VirtualRegion.Permissions.OnInventoryTransfer += BigRegion.PermissionModule.CanInventoryTransfer; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED + VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED + VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry; + VirtualRegion.Permissions.OnReturnObject += BigRegion.PermissionModule.CanReturnObject; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED + VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand; + VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnCompileScript += BigRegion.PermissionModule.CanCompileScript; + VirtualRegion.Permissions.OnSellParcel += BigRegion.PermissionModule.CanSellParcel; + VirtualRegion.Permissions.OnTakeObject += BigRegion.PermissionModule.CanTakeObject; + VirtualRegion.Permissions.OnTakeCopyObject += BigRegion.PermissionModule.CanTakeCopyObject; + VirtualRegion.Permissions.OnTerraformLand += BigRegion.PermissionModule.CanTerraformLand; + VirtualRegion.Permissions.OnLinkObject += BigRegion.PermissionModule.CanLinkObject; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnDelinkObject += BigRegion.PermissionModule.CanDelinkObject; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnBuyLand += BigRegion.PermissionModule.CanBuyLand; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnViewNotecard += BigRegion.PermissionModule.CanViewNotecard; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnViewScript += BigRegion.PermissionModule.CanViewScript; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnEditNotecard += BigRegion.PermissionModule.CanEditNotecard; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnEditScript += BigRegion.PermissionModule.CanEditScript; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnCreateObjectInventory += BigRegion.PermissionModule.CanCreateObjectInventory; //NOT IMPLEMENTED HERE + VirtualRegion.Permissions.OnEditObjectInventory += BigRegion.PermissionModule.CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED + VirtualRegion.Permissions.OnCopyObjectInventory += BigRegion.PermissionModule.CanCopyObjectInventory; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnDeleteObjectInventory += BigRegion.PermissionModule.CanDeleteObjectInventory; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnResetScript += BigRegion.PermissionModule.CanResetScript; + VirtualRegion.Permissions.OnCreateUserInventory += BigRegion.PermissionModule.CanCreateUserInventory; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnCopyUserInventory += BigRegion.PermissionModule.CanCopyUserInventory; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED + VirtualRegion.Permissions.OnUseObjectReturn += BigRegion.PermissionModule.CanUseObjectReturn; //NOT YET IMPLEMENTED + } + + #region console commands + public void FixPhantoms(string module, string[] cmdparams) + { + List scenes = new List(m_startingScenes.Values); + foreach (Scene s in scenes) + { + s.ForEachSOG(delegate(SceneObjectGroup e) + { + e.AbsolutePosition = e.AbsolutePosition; + } + ); + } + } + #endregion + } +} diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs new file mode 100644 index 0000000..76ca5e3 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs @@ -0,0 +1,275 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Land +{ + public class RegionCombinerPermissionModule + { + private Scene m_rootScene; + + public RegionCombinerPermissionModule(Scene RootScene) + { + m_rootScene = RootScene; + } + + #region Permission Override + + public bool BypassPermissions() + { + return m_rootScene.Permissions.BypassPermissions(); + } + + public void SetBypassPermissions(bool value) + { + m_rootScene.Permissions.SetBypassPermissions(value); + } + + public bool PropagatePermissions() + { + return m_rootScene.Permissions.PropagatePermissions(); + } + + public uint GenerateClientFlags(UUID userid, UUID objectidid) + { + return m_rootScene.Permissions.GenerateClientFlags(userid,objectidid); + } + + public bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene) + { + return m_rootScene.Permissions.CanAbandonParcel(user,parcel); + } + + public bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene) + { + return m_rootScene.Permissions.CanReclaimParcel(user, parcel); + } + + public bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene) + { + return m_rootScene.Permissions.CanDeedParcel(user, parcel); + } + + public bool CanDeedObject(UUID user, UUID @group, Scene scene) + { + return m_rootScene.Permissions.CanDeedObject(user,@group); + } + + public bool IsGod(UUID user, Scene requestfromscene) + { + return m_rootScene.Permissions.IsGod(user); + } + + public bool CanDuplicateObject(int objectcount, UUID objectid, UUID owner, Scene scene, Vector3 objectposition) + { + return m_rootScene.Permissions.CanDuplicateObject(objectcount, objectid, owner, objectposition); + } + + public bool CanDeleteObject(UUID objectid, UUID deleter, Scene scene) + { + return m_rootScene.Permissions.CanDeleteObject(objectid, deleter); + } + + public bool CanEditObject(UUID objectid, UUID editorid, Scene scene) + { + return m_rootScene.Permissions.CanEditObject(objectid, editorid); + } + + public bool CanEditParcel(UUID user, ILandObject parcel, Scene scene) + { + return m_rootScene.Permissions.CanEditParcel(user, parcel); + } + + public bool CanInstantMessage(UUID user, UUID target, Scene startscene) + { + return m_rootScene.Permissions.CanInstantMessage(user, target); + } + + public bool CanInventoryTransfer(UUID user, UUID target, Scene startscene) + { + return m_rootScene.Permissions.CanInventoryTransfer(user, target); + } + + public bool CanIssueEstateCommand(UUID user, Scene requestfromscene, bool ownercommand) + { + return m_rootScene.Permissions.CanIssueEstateCommand(user, ownercommand); + } + + public bool CanMoveObject(UUID objectid, UUID moverid, Scene scene) + { + return m_rootScene.Permissions.CanMoveObject(objectid, moverid); + } + + public bool CanObjectEntry(UUID objectid, bool enteringregion, Vector3 newpoint, Scene scene) + { + return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint); + } + + public bool CanReturnObject(UUID objectid, UUID returnerid, Scene scene) + { + return m_rootScene.Permissions.CanReturnObject(objectid, returnerid); + } + + public bool CanRezObject(int objectcount, UUID owner, Vector3 objectposition, Scene scene) + { + return m_rootScene.Permissions.CanRezObject(objectcount, owner, objectposition); + } + + public bool CanRunConsoleCommand(UUID user, Scene requestfromscene) + { + return m_rootScene.Permissions.CanRunConsoleCommand(user); + } + + public bool CanRunScript(UUID script, UUID objectid, UUID user, Scene scene) + { + return m_rootScene.Permissions.CanRunScript(script, objectid, user); + } + + public bool CanCompileScript(UUID owneruuid, int scripttype, Scene scene) + { + return m_rootScene.Permissions.CanCompileScript(owneruuid, scripttype); + } + + public bool CanSellParcel(UUID user, ILandObject parcel, Scene scene) + { + return m_rootScene.Permissions.CanSellParcel(user, parcel); + } + + public bool CanTakeObject(UUID objectid, UUID stealer, Scene scene) + { + return m_rootScene.Permissions.CanTakeObject(objectid, stealer); + } + + public bool CanTakeCopyObject(UUID objectid, UUID userid, Scene inscene) + { + return m_rootScene.Permissions.CanTakeObject(objectid, userid); + } + + public bool CanTerraformLand(UUID user, Vector3 position, Scene requestfromscene) + { + return m_rootScene.Permissions.CanTerraformLand(user, position); + } + + public bool CanLinkObject(UUID user, UUID objectid) + { + return m_rootScene.Permissions.CanLinkObject(user, objectid); + } + + public bool CanDelinkObject(UUID user, UUID objectid) + { + return m_rootScene.Permissions.CanDelinkObject(user, objectid); + } + + public bool CanBuyLand(UUID user, ILandObject parcel, Scene scene) + { + return m_rootScene.Permissions.CanBuyLand(user, parcel); + } + + public bool CanViewNotecard(UUID script, UUID objectid, UUID user, Scene scene) + { + return m_rootScene.Permissions.CanViewNotecard(script, objectid, user); + } + + public bool CanViewScript(UUID script, UUID objectid, UUID user, Scene scene) + { + return m_rootScene.Permissions.CanViewScript(script, objectid, user); + } + + public bool CanEditNotecard(UUID notecard, UUID objectid, UUID user, Scene scene) + { + return m_rootScene.Permissions.CanEditNotecard(notecard, objectid, user); + } + + public bool CanEditScript(UUID script, UUID objectid, UUID user, Scene scene) + { + return m_rootScene.Permissions.CanEditScript(script, objectid, user); + } + + public bool CanCreateObjectInventory(int invtype, UUID objectid, UUID userid) + { + return m_rootScene.Permissions.CanCreateObjectInventory(invtype, objectid, userid); + } + + public bool CanEditObjectInventory(UUID objectid, UUID editorid, Scene scene) + { + return m_rootScene.Permissions.CanEditObjectInventory(objectid, editorid); + } + + public bool CanCopyObjectInventory(UUID itemid, UUID objectid, UUID userid) + { + return m_rootScene.Permissions.CanCopyObjectInventory(itemid, objectid, userid); + } + + public bool CanDeleteObjectInventory(UUID itemid, UUID objectid, UUID userid) + { + return m_rootScene.Permissions.CanDeleteObjectInventory(itemid, objectid, userid); + } + + public bool CanResetScript(UUID prim, UUID script, UUID user, Scene scene) + { + return m_rootScene.Permissions.CanResetScript(prim, script, user); + } + + public bool CanCreateUserInventory(int invtype, UUID userid) + { + return m_rootScene.Permissions.CanCreateUserInventory(invtype, userid); + } + + public bool CanCopyUserInventory(UUID itemid, UUID userid) + { + return m_rootScene.Permissions.CanCopyUserInventory(itemid, userid); + } + + public bool CanEditUserInventory(UUID itemid, UUID userid) + { + return m_rootScene.Permissions.CanEditUserInventory(itemid, userid); + } + + public bool CanDeleteUserInventory(UUID itemid, UUID userid) + { + return m_rootScene.Permissions.CanDeleteUserInventory(itemid, userid); + } + + public bool CanTeleport(UUID userid, Scene scene) + { + return m_rootScene.Permissions.CanTeleport(userid); + } + + public bool CanUseObjectReturn(ILandObject landdata, uint type, IClientAPI client, List retlist, Scene scene) + { + return m_rootScene.Permissions.CanUseObjectReturn(landdata, type, client, retlist); + } + + #endregion + } +} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs new file mode 100644 index 0000000..419ed74 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs @@ -0,0 +1,65 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Land +{ + public class RegionConnections + { + /// + /// Root Region ID + /// + public UUID RegionId; + + /// + /// Root Region Scene + /// + public Scene RegionScene; + + /// + /// LargeLandChannel for combined region + /// + public ILandChannel RegionLandChannel; + public uint X; + public uint Y; + public int XEnd; + public int YEnd; + public List ConnectedRegions; + public RegionCombinerPermissionModule PermissionModule; + public RegionCombinerClientEventForwarder ClientEventForwarder; + public void UpdateExtents(Vector3 extents) + { + XEnd = (int)extents.X; + YEnd = (int)extents.Y; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs new file mode 100644 index 0000000..175ca89 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs @@ -0,0 +1,43 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.CoreModules.World.Land +{ + + struct RegionCourseLocationStruct + { + public List Locations; + public List Uuids; + public IClientAPI UserAPI; + public Vector2 Offset; + } +} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/RegionData.cs b/OpenSim/Region/RegionCombinerModule/RegionData.cs new file mode 100644 index 0000000..3383527 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/RegionData.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Land +{ + public class RegionData + { + public UUID RegionId; + public Scene RegionScene; + public Vector3 Offset; + } +} \ No newline at end of file diff --git a/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml b/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml new file mode 100644 index 0000000..8e447d4 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/prebuild.xml b/prebuild.xml index b7ce93c..0d7a7ec 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1721,6 +1721,47 @@ + + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1 From 44012d72e3c64ddc06cd37c17474fa30f4f30e37 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Tue, 10 Nov 2009 23:04:13 -0500 Subject: * Fix prebuild break --- prebuild.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prebuild.xml b/prebuild.xml index 0d7a7ec..047b66d 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1722,7 +1722,7 @@ - + ../../../bin/ @@ -1747,6 +1747,7 @@ + -- cgit v1.1 From 1bb510ab17321762d57120aabe6d4dec31b16e6f Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Tue, 10 Nov 2009 23:43:18 -0500 Subject: * Update namespace in the regioncombinermodule. --- .../Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs | 2 +- .../RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs | 2 +- OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs | 3 ++- OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | 2 +- OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs | 2 +- OpenSim/Region/RegionCombinerModule/RegionConnections.cs | 2 +- OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs | 2 +- OpenSim/Region/RegionCombinerModule/RegionData.cs | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs index 70d6de3..721d396 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerClientEventForwarder.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenMetaverse; using OpenSim.Region.Framework.Scenes; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { public class RegionCombinerClientEventForwarder { diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs index 2cbaf96..9d41c9c 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs @@ -30,7 +30,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { public class RegionCombinerIndividualEventForwarder { diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs index 7df836c..146ec66 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerLargeLandChannel.cs @@ -30,8 +30,9 @@ using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.CoreModules.World.Land; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { public class RegionCombinerLargeLandChannel : ILandChannel { diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 6859d6d..6180751 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { public class RegionCombinerModule : ISharedRegionModule { diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs index 76ca5e3..4d1af57 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerPermissionModule.cs @@ -32,7 +32,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { public class RegionCombinerPermissionModule { diff --git a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs index 419ed74..3aa9f20 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionConnections.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionConnections.cs @@ -31,7 +31,7 @@ using OpenMetaverse; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { public class RegionConnections { diff --git a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs index 175ca89..53a678f 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs @@ -30,7 +30,7 @@ using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { struct RegionCourseLocationStruct diff --git a/OpenSim/Region/RegionCombinerModule/RegionData.cs b/OpenSim/Region/RegionCombinerModule/RegionData.cs index 3383527..bd0e398 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionData.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionData.cs @@ -28,7 +28,7 @@ using OpenMetaverse; using OpenSim.Region.Framework.Scenes; -namespace OpenSim.Region.CoreModules.World.Land +namespace OpenSim.Region.RegionCombinerModule { public class RegionData { -- cgit v1.1 From c8268a270f516c68444ebd6a955129773d2d75b4 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 11 Nov 2009 00:00:21 -0500 Subject: * Fix resources file mapping --- .../RegionCombinerModule/Resources/RegionCombinerModule.addin.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml b/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml index 8e447d4..526574a 100644 --- a/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml +++ b/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml @@ -1,4 +1,4 @@ - + @@ -8,6 +8,6 @@ - + -- cgit v1.1 From 4a2d82e14b4d00671b454d4848b6b4cef26d3e56 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 11 Nov 2009 02:47:17 -0500 Subject: * Thanks to a little help from jhurliman, jradford, diva, mono's brajkovic, miguel, and the fabulous bug reports by our community members.. The workaround fix for the "ERROR:metadata.c:3211:mono_metadata_token_from_dor: code should not be reached" bug in the RegionCombinerModule. --- OpenSim/Region/Framework/Scenes/Scene.cs | 14 ++++++++++++-- .../Region/RegionCombinerModule/RegionCombinerModule.cs | 5 +++++ .../Resources/RegionCombinerModule.addin.xml | 13 ------------- 3 files changed, 17 insertions(+), 15 deletions(-) delete mode 100644 OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6edef11..4531e06 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -88,8 +88,18 @@ namespace OpenSim.Region.Framework.Scenes protected List m_regionRestartNotifyList = new List(); protected List m_neighbours = new List(); - public volatile bool BordersLocked = false; - + private volatile int m_bordersLocked = 0; + public bool BordersLocked + { + get { return m_bordersLocked == 1; } + set + { + if (value == true) + m_bordersLocked = 1; + else + m_bordersLocked = 0; + } + } public List NorthBorders = new List(); public List EastBorders = new List(); public List SouthBorders = new List(); diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 6180751..7ec1d4b 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -37,9 +37,14 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Framework.Console; using OpenSim.Region.Physics.Manager; +using Mono.Addins; +[assembly: Addin("RegionCombinerModule", "0.1")] +[assembly: AddinDependency("OpenSim", "0.5")] namespace OpenSim.Region.RegionCombinerModule { + + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class RegionCombinerModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml b/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml deleted file mode 100644 index 526574a..0000000 --- a/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - -- cgit v1.1 From a8a01e2bc7ed0c6f63694b562b93c4a991ded699 Mon Sep 17 00:00:00 2001 From: dahlia Date: Wed, 11 Nov 2009 02:54:58 -0800 Subject: add a ToOmvPrimitive() method to PrimitiveBaseShape --- OpenSim/Framework/PrimitiveBaseShape.cs | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 5e4d175..f8dac06 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -1066,5 +1066,86 @@ namespace OpenSim.Framework return data; } + + + /// + /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values + /// + /// + public Primitive ToOmvPrimitive() + { + // position and rotation defaults here since they are not available in PrimitiveBaseShape + return ToOmvPrimitive(new Vector3(0.0f, 0.0f, 0.0f), + new Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); + } + + + /// + /// Creates a OpenMetaverse.Primitive and populates it with converted PrimitiveBaseShape values + /// + /// + /// + /// + public Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation) + { + OpenMetaverse.Primitive prim = new OpenMetaverse.Primitive(); + prim.Scale = this.Scale; + prim.Position = position; + prim.Rotation = rotation; + + if (this.SculptEntry) + { + prim.Sculpt = new Primitive.SculptData(); + prim.Sculpt.Type = (OpenMetaverse.SculptType)this.SculptType; + prim.Sculpt.SculptTexture = this.SculptTexture; + + return prim; + } + + prim.PrimData.PathShearX = this.PathShearX < 128 ? (float)this.PathShearX * 0.01f : (float)(this.PathShearX - 256) * 0.01f; + prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (float)(this.PathShearY - 256) * 0.01f; + prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f; + prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f; + prim.PrimData.PathScaleX = (float)(this.PathScaleX - 100) * 0.01f; + prim.PrimData.PathScaleY = (float)(this.PathScaleY - 100) * 0.01f; + + prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f; + prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f; + prim.PrimData.ProfileHollow = (float)this.ProfileHollow * 2.0e-5f; + + prim.PrimData.profileCurve = this.ProfileCurve; + prim.PrimData.ProfileHole = (HoleType)this.HollowShape; + + prim.PrimData.PathTwistBegin = this.PathTwistBegin * 18 / 10; + prim.PrimData.PathTwist = this.PathTwist * 18 / 10; + + prim.PrimData.PathTaperX = this.PathTaperX * 0.01f; + prim.PrimData.PathTaperY = this.PathTaperY * 0.01f; + + if (this.FlexiEntry) + { + prim.Flexible = new Primitive.FlexibleData(); + prim.Flexible.Drag = this.FlexiDrag; + prim.Flexible.Force = new Vector3(this.FlexiForceX, this.FlexiForceY, this.FlexiForceZ); + prim.Flexible.Gravity = this.FlexiGravity; + prim.Flexible.Softness = this.FlexiSoftness; + prim.Flexible.Tension = this.FlexiTension; + prim.Flexible.Wind = this.FlexiWind; + } + + if (this.LightEntry) + { + prim.Light = new Primitive.LightData(); + prim.Light.Color = new Color4(this.LightColorR, this.LightColorG, this.LightColorB, this.LightColorA); + prim.Light.Cutoff = this.LightCutoff; + prim.Light.Falloff = this.LightFalloff; + prim.Light.Intensity = this.LightIntensity; + prim.Light.Radius = this.LightRadius; + } + + prim.Textures = new Primitive.TextureEntry(this.TextureEntry, 0, this.TextureEntry.Length); + + return prim; + } } } -- cgit v1.1 From 1fa037a0c3cf511c735afd369a440d80ec5b8a67 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Nov 2009 15:56:14 +0000 Subject: minor: remove some mono compiler warnings --- .../Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs | 10 +++++----- OpenSim/Framework/Capabilities/Caps.cs | 2 +- OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs index 9497a2e..6ab1b58 100644 --- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs +++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs @@ -63,11 +63,11 @@ namespace OpenSim.Framework.AssetLoader.Filesystem protected static void LoadAsset(AssetBase info, string path) { - bool image = - (info.Type == (sbyte)AssetType.Texture || - info.Type == (sbyte)AssetType.TextureTGA || - info.Type == (sbyte)AssetType.ImageJPEG || - info.Type == (sbyte)AssetType.ImageTGA); +// bool image = +// (info.Type == (sbyte)AssetType.Texture || +// info.Type == (sbyte)AssetType.TextureTGA || +// info.Type == (sbyte)AssetType.ImageJPEG || +// info.Type == (sbyte)AssetType.ImageTGA); FileInfo fInfo = new FileInfo(path); long numBytes = fInfo.Length; diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index 72231ca..1f1ac78 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -89,7 +89,7 @@ namespace OpenSim.Framework.Capabilities //private static readonly string m_requestTexture = "0003/"; private static readonly string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardTaskUpdatePath = "0005/"; - private static readonly string m_fetchInventoryPath = "0006/"; +// private static readonly string m_fetchInventoryPath = "0006/"; // The following entries are in a module, however, they are also here so that we don't re-assign // the path to another cap by mistake. diff --git a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs index dedf876..b9d3f22 100644 --- a/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs +++ b/OpenSim/Grid/MessagingServer.Modules/MessageRegionModule.cs @@ -48,7 +48,7 @@ namespace OpenSim.Grid.MessagingServer.Modules { public class MessageRegionModule : IMessageRegionLookup { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private MessageServerConfig m_cfg; -- cgit v1.1 From 00102e73a657e8a30b323ef68e7cba073c369197 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Nov 2009 18:46:04 +0000 Subject: Add basic new uuid gatherer tests to check behaviour when the gather seed is a missing asset --- .../Framework/Scenes/Tests/UuidGathererTests.cs | 58 ++++++++++++++++++++++ OpenSim/Tests/Common/Mock/TestAssetService.cs | 11 ++-- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs new file mode 100644 index 0000000..50b65f6 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.Framework.Scenes.Tests +{ + [TestFixture] + public class UuidGathererTests + { + /// + /// Test requests made for non-existent assets + /// + [Test] + public void TestMissingAsset() + { + TestHelper.InMethod(); + + UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); + UuidGatherer ug = new UuidGatherer(new TestAssetService()); + IDictionary foundAssetUuids = new Dictionary(); + + ug.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); + + Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); + } + } +} diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs index 317ec06..ff75d86 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetService.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetService.cs @@ -39,9 +39,14 @@ namespace OpenSim.Tests.Common.Mock { private readonly Dictionary Assets = new Dictionary(); - public TestAssetService(IConfigSource config) - { - } + public TestAssetService() {} + + /// + /// This constructor is required if the asset service is being created reflectively (which is the case in some + /// tests). + /// + /// + public TestAssetService(IConfigSource config) {} public AssetBase Get(string id) { -- cgit v1.1 From 6d88c96e01088edc9777a9fb0abfd58ff8c1d8c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Nov 2009 18:49:05 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index 281ba12..a8f9ae5 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -333,7 +333,7 @@ namespace PrimMesher // int height = sculptBitmap.Height / scale; int width = rows[0].Count; - int height = rows.Count; +// int height = rows.Count; int p1, p2, p3, p4; -- cgit v1.1 From 8ae3df22a2b1d235d4ffb04091656b5d16c50e68 Mon Sep 17 00:00:00 2001 From: dahlia Date: Wed, 11 Nov 2009 11:10:42 -0800 Subject: clean up some cruft --- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index a8f9ae5..4dc6e2e 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -52,6 +52,7 @@ namespace PrimMesher public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; +#if SYSTEM_DRAWING // private Bitmap ScaleImage(Bitmap srcImage, float scale) // { // int sourceWidth = srcImage.Width; @@ -89,7 +90,7 @@ namespace PrimMesher // return scaledImage; // } -#if SYSTEM_DRAWING + public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) { Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); @@ -320,20 +321,9 @@ namespace PrimMesher if (sculptType == SculptType.plane) invert = !invert; - //float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); - - //int scale = (int)(1.0f / sourceScaleFactor); - //if (scale < 1) scale = 1; - - //List> rows = bitmap2Coords(sculptBitmap, scale, mirror); - viewerFaces = new List(); - //int width = sculptBitmap.Width / scale; - // int height = sculptBitmap.Height / scale; - int width = rows[0].Count; -// int height = rows.Count; int p1, p2, p3, p4; -- cgit v1.1 From cedd827f7f0174ef152a6e2216a706070792301e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 12 Nov 2009 11:17:04 +1100 Subject: * Added some new syntax options for the Monitor Module's HTTP poll. --- .../Framework/Monitoring/MonitorModule.cs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index b6a2025..11aca99 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs @@ -52,6 +52,36 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring public Hashtable StatsPage(Hashtable request) { + // If request was for a specific monitor + // eg url/?monitor=Monitor.Name + if (request.ContainsKey("monitor")) + { + string monID = (string) request["monitor"]; + + foreach (IMonitor monitor in m_monitors) + { + if (monitor.ToString() == monID) + { + Hashtable ereply3 = new Hashtable(); + + ereply3["int_response_code"] = 404; // 200 OK + ereply3["str_response_string"] = monitor.GetValue().ToString(); + ereply3["content_type"] = "text/plain"; + + return ereply3; + } + } + + // No monitor with that name + Hashtable ereply2 = new Hashtable(); + + ereply2["int_response_code"] = 404; // 200 OK + ereply2["str_response_string"] = "No such monitor"; + ereply2["content_type"] = "text/plain"; + + return ereply2; + } + string xml = ""; foreach (IMonitor monitor in m_monitors) { -- cgit v1.1 From 55a40694e7a0c9cf143b50d0cfa4bc682b35bb48 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 17:42:26 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 1 + .../OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 50b65f6..235d7c5 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -52,6 +52,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests ug.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); + // We count the uuid as gathered even if the asset itself is missing. Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); } } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs index 4c2a4b9..cfe1278 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IRCServer m_server; - private Scene m_scene; +// private Scene m_scene; #region Implementation of IRegionModule @@ -50,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView source.Configs["IRCd"].GetBoolean("Enabled",false)) { int portNo = source.Configs["IRCd"].GetInt("Port",6666); - m_scene = scene; +// m_scene = scene; m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), portNo, scene); m_server.OnNewIRCClient += m_server_OnNewIRCClient; } -- cgit v1.1 From cbe1cc1bc8d0da0a4dac3cc644d9df3bc94941da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 17:50:09 +0000 Subject: minor: refactor common setup in uuid gatherer test --- OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 235d7c5..cf2b3b3 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -38,6 +38,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests [TestFixture] public class UuidGathererTests { + protected UuidGatherer m_ug; + + [SetUp] + public void Init() + { + m_ug = new UuidGatherer(new TestAssetService()); + } + /// /// Test requests made for non-existent assets /// @@ -46,11 +54,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests { TestHelper.InMethod(); - UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); - UuidGatherer ug = new UuidGatherer(new TestAssetService()); + UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); IDictionary foundAssetUuids = new Dictionary(); - ug.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); + m_ug.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); // We count the uuid as gathered even if the asset itself is missing. Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); -- cgit v1.1 From bb92ba97c6952c60f5bdd50b1c6599894bfef501 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 18:26:22 +0000 Subject: Stop iar save failing on corrupt assets Not ideal since one will still have to watch out for big 'corrupt asset' messages in the log, but better than an outright fail --- .../Framework/Scenes/Tests/UuidGathererTests.cs | 31 +++++++++++++++++++--- OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 4 ++- OpenSim/Tests/Common/Mock/TestAssetService.cs | 8 ++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index cf2b3b3..52891f4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -26,10 +26,13 @@ */ using System.Collections.Generic; +using System.Text; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -38,16 +41,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests [TestFixture] public class UuidGathererTests { - protected UuidGatherer m_ug; + protected IAssetService m_assetService; + protected UuidGatherer m_uuidGatherer; [SetUp] public void Init() { - m_ug = new UuidGatherer(new TestAssetService()); + m_assetService = new TestAssetService(); + m_uuidGatherer = new UuidGatherer(m_assetService); + } + + [Test] + public void TestCorruptAsset() + { + TestHelper.InMethod(); + + UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); + AssetBase corruptAsset = new AssetBase(corruptAssetUuid, corruptAssetUuid.ToString(), (sbyte)AssetType.Object); + corruptAsset.Data = Encoding.ASCII.GetBytes("CORRUPT ASSET"); + + m_assetService.Store(corruptAsset); + + IDictionary foundAssetUuids = new Dictionary(); + m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); + + // We count the uuid as gathered even if the asset itself is corrupt. + Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); } /// - /// Test requests made for non-existent assets + /// Test requests made for non-existent assets while we're gathering /// [Test] public void TestMissingAsset() @@ -57,7 +80,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); IDictionary foundAssetUuids = new Dictionary(); - m_ug.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); + m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); // We count the uuid as gathered even if the asset itself is missing. Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 525a93a..930af81 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -273,7 +273,9 @@ namespace OpenSim.Region.Framework.Scenes { string xml = Utils.BytesToString(objectAsset.Data); SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); - GatherAssetUuids(sog, assetUuids); + + if (null != sog) + GatherAssetUuids(sog, assetUuids); } } } diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs index ff75d86..a537b97 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetService.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetService.cs @@ -27,6 +27,8 @@ using System; using System.Collections.Generic; +using System.Reflection; +using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Data; @@ -37,6 +39,8 @@ namespace OpenSim.Tests.Common.Mock { public class TestAssetService : IAssetService { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private readonly Dictionary Assets = new Dictionary(); public TestAssetService() {} @@ -50,6 +54,8 @@ namespace OpenSim.Tests.Common.Mock public AssetBase Get(string id) { + m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id); + AssetBase asset; if (Assets.ContainsKey(id)) asset = Assets[id]; @@ -78,6 +84,8 @@ namespace OpenSim.Tests.Common.Mock public string Store(AssetBase asset) { + m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID); + Assets[asset.ID] = asset; return asset.ID; -- cgit v1.1 From 73b437b7b4e7b88c5b9be6f584019b3cd41df44a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 18:30:32 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Data/SQLite/SQLiteAssetData.cs | 32 ++++++++++++++++---------------- OpenSim/Data/Tests/BasicRegionTest.cs | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 11be28e..23642b3 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -162,22 +162,22 @@ namespace OpenSim.Data.SQLite } } - /// - /// Some... logging functionnality - /// - /// - private static void LogAssetLoad(AssetBase asset) - { - string temporary = asset.Temporary ? "Temporary" : "Stored"; - string local = asset.Local ? "Local" : "Remote"; - - int assetLength = (asset.Data != null) ? asset.Data.Length : 0; - - m_log.Debug("[ASSET DB]: " + - string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)", - asset.FullID, asset.Name, asset.Description, asset.Type, - temporary, local, assetLength)); - } +// /// +// /// Some... logging functionnality +// /// +// /// +// private static void LogAssetLoad(AssetBase asset) +// { +// string temporary = asset.Temporary ? "Temporary" : "Stored"; +// string local = asset.Local ? "Local" : "Remote"; +// +// int assetLength = (asset.Data != null) ? asset.Data.Length : 0; +// +// m_log.Debug("[ASSET DB]: " + +// string.Format("Loaded {5} {4} Asset: [{0}][{3}] \"{1}\":{2} ({6} bytes)", +// asset.FullID, asset.Name, asset.Description, asset.Type, +// temporary, local, assetLength)); +// } /// /// Check if an asset exist in database diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs index 60a8874..f76962c 100644 --- a/OpenSim/Data/Tests/BasicRegionTest.cs +++ b/OpenSim/Data/Tests/BasicRegionTest.cs @@ -252,7 +252,7 @@ namespace OpenSim.Data.Tests regionInfo.RegionLocX = 0; regionInfo.RegionLocY = 0; - Scene scene = new Scene(regionInfo); +// Scene scene = new Scene(regionInfo); SceneObjectPart sop = new SceneObjectPart(); sop.RegionHandle = regionh; -- cgit v1.1 From d21fc1cefb922a44eab5e789cb5ed5e03c04c2bc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 18:33:40 +0000 Subject: minor: for now stop iar tests spewing log messages when running testsuite --- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 99d02c4..ed3ed18 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests public void TestIarV0_1WithEscapedChars() { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); +// log4net.Config.XmlConfigurator.Configure(); string itemName = "You & you are a mean/man/"; string humanEscapedItemName = @"You & you are a mean\/man\/"; -- cgit v1.1 From 2f092d271e80dbc7af47671fbb946de75b6110a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 18:44:03 +0000 Subject: Rename test services to mock services, since this is a more accurate description remove duplicate mock inventory service --- .../Communications/Tests/LoginServiceTests.cs | 151 +--------------- .../Framework/Scenes/Tests/UuidGathererTests.cs | 2 +- OpenSim/Tests/Common/Mock/MockAssetService.cs | 104 +++++++++++ OpenSim/Tests/Common/Mock/MockInventoryService.cs | 190 +++++++++++++++++++++ OpenSim/Tests/Common/Mock/TestAssetService.cs | 104 ----------- OpenSim/Tests/Common/Mock/TestInventoryService.cs | 190 --------------------- OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs | 4 +- 7 files changed, 301 insertions(+), 444 deletions(-) create mode 100644 OpenSim/Tests/Common/Mock/MockAssetService.cs create mode 100644 OpenSim/Tests/Common/Mock/MockInventoryService.cs delete mode 100644 OpenSim/Tests/Common/Mock/TestAssetService.cs delete mode 100644 OpenSim/Tests/Common/Mock/TestInventoryService.cs diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index e891d9c..60f0ba8 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -75,7 +75,7 @@ namespace OpenSim.Framework.Communications.Tests m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName)); - //IInventoryService m_inventoryService = new TestInventoryService(); + //IInventoryService m_inventoryService = new MockInventoryService(); m_localUserServices = (LocalUserServices) m_commsManager.UserService; m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","abc@ftw.com",42,43); @@ -95,7 +95,8 @@ namespace OpenSim.Framework.Communications.Tests TestHelper.InMethod(); // We want to use our own LoginService for this test, one that // doesn't require authentication. - new LLStandaloneLoginService((UserManagerBase)m_commsManager.UserService, "Hello folks", new TestInventoryService(), + new LLStandaloneLoginService( + (UserManagerBase)m_commsManager.UserService, "Hello folks", new MockInventoryService(), m_commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty), m_regionConnector); Hashtable loginParams = new Hashtable(); @@ -457,148 +458,4 @@ namespace OpenSim.Framework.Communications.Tests #endregion } } - - class TestInventoryService : IInventoryService - { - public TestInventoryService() - { - } - - /// - /// - /// - /// - /// - public bool CreateUserInventory(UUID userId) - { - return false; - } - - /// - /// - /// - /// - /// - public List GetInventorySkeleton(UUID userId) - { - List folders = new List(); - InventoryFolderBase folder = new InventoryFolderBase(); - folder.ID = UUID.Random(); - folder.Owner = userId; - folders.Add(folder); - return folders; - } - - /// - /// Returns a list of all the active gestures in a user's inventory. - /// - /// - /// The of the user - /// - /// - /// A flat list of the gesture items. - /// - public List GetActiveGestures(UUID userId) - { - return null; - } - - public InventoryCollection GetUserInventory(UUID userID) - { - return null; - } - - public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback) - { - } - - public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) - { - return null; - } - - public InventoryCollection GetFolderContent(UUID userID, UUID folderID) - { - return null; - } - - public List GetFolderItems(UUID userID, UUID folderID) - { - return null; - } - - public bool AddFolder(InventoryFolderBase folder) - { - return false; - } - - public bool UpdateFolder(InventoryFolderBase folder) - { - return false; - } - - public bool MoveFolder(InventoryFolderBase folder) - { - return false; - } - - public bool DeleteFolders(UUID ownerID, List ids) - { - return false; - } - - public bool PurgeFolder(InventoryFolderBase folder) - { - return false; - } - - public bool AddItem(InventoryItemBase item) - { - return false; - } - - public bool UpdateItem(InventoryItemBase item) - { - return false; - } - - public bool MoveItems(UUID owner, List items) - { - return false; - } - - public bool DeleteItems(UUID owner, List items) - { - return false; - } - - public InventoryItemBase GetItem(InventoryItemBase item) - { - return null; - } - - public InventoryFolderBase GetFolder(InventoryFolderBase folder) - { - return null; - } - - public bool HasInventoryForUser(UUID userID) - { - return false; - } - - public InventoryFolderBase GetRootFolder(UUID userID) - { - InventoryFolderBase root = new InventoryFolderBase(); - root.ID = UUID.Random(); - root.Owner = userID; - root.ParentID = UUID.Zero; - return root; - } - - public int GetAssetPermissions(UUID userID, UUID assetID) - { - return 1; - } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 52891f4..dc98550 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests [SetUp] public void Init() { - m_assetService = new TestAssetService(); + m_assetService = new MockAssetService(); m_uuidGatherer = new UuidGatherer(m_assetService); } diff --git a/OpenSim/Tests/Common/Mock/MockAssetService.cs b/OpenSim/Tests/Common/Mock/MockAssetService.cs new file mode 100644 index 0000000..cb38043 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/MockAssetService.cs @@ -0,0 +1,104 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using Nini.Config; + +namespace OpenSim.Tests.Common.Mock +{ + public class MockAssetService : IAssetService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private readonly Dictionary Assets = new Dictionary(); + + public MockAssetService() {} + + /// + /// This constructor is required if the asset service is being created reflectively (which is the case in some + /// tests). + /// + /// + public MockAssetService(IConfigSource config) {} + + public AssetBase Get(string id) + { + m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id); + + AssetBase asset; + if (Assets.ContainsKey(id)) + asset = Assets[id]; + else + asset = null; + + return asset; + } + + public AssetMetadata GetMetadata(string id) + { + throw new System.NotImplementedException(); + } + + public byte[] GetData(string id) + { + throw new System.NotImplementedException(); + } + + public bool Get(string id, object sender, AssetRetrieved handler) + { + handler(id, sender, Get(id)); + + return true; + } + + public string Store(AssetBase asset) + { + m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID); + + Assets[asset.ID] = asset; + + return asset.ID; + } + + public bool UpdateContent(string id, byte[] data) + { + throw new System.NotImplementedException(); + } + + public bool Delete(string id) + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/MockInventoryService.cs b/OpenSim/Tests/Common/Mock/MockInventoryService.cs new file mode 100644 index 0000000..1ea4bc1 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/MockInventoryService.cs @@ -0,0 +1,190 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework; +using OpenMetaverse; +using OpenSim.Services.Interfaces; +using Nini.Config; + +namespace OpenSim.Tests.Common.Mock +{ + public class MockInventoryService : IInventoryService + { + public MockInventoryService() + { + } + + public MockInventoryService(IConfigSource config) + { + } + + /// + /// + /// + /// + /// + public bool CreateUserInventory(UUID userId) + { + return false; + } + + /// + /// + /// + /// + /// + public List GetInventorySkeleton(UUID userId) + { + List folders = new List(); + InventoryFolderBase folder = new InventoryFolderBase(); + folder.ID = UUID.Random(); + folder.Owner = userId; + folders.Add(folder); + return folders; + } + + public InventoryFolderBase GetRootFolder(UUID userID) + { + return new InventoryFolderBase(); + } + + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + return null; + } + + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + return null; + } + + /// + /// Returns a list of all the active gestures in a user's inventory. + /// + /// + /// The of the user + /// + /// + /// A flat list of the gesture items. + /// + public List GetActiveGestures(UUID userId) + { + return null; + } + + public InventoryCollection GetUserInventory(UUID userID) + { + return null; + } + + public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback) + { + } + + public List GetFolderItems(UUID userID, UUID folderID) + { + return null; + } + + public bool AddFolder(InventoryFolderBase folder) + { + return false; + } + + public bool UpdateFolder(InventoryFolderBase folder) + { + return false; + } + + public bool MoveFolder(InventoryFolderBase folder) + { + return false; + } + + public bool DeleteFolders(UUID ownerID, List ids) + { + return false; + } + + public bool PurgeFolder(InventoryFolderBase folder) + { + return false; + } + + public bool AddItem(InventoryItemBase item) + { + return false; + } + + public bool UpdateItem(InventoryItemBase item) + { + return false; + } + + public bool MoveItems(UUID ownerID, List items) + { + return false; + } + + public bool DeleteItems(UUID ownerID, List itemIDs) + { + return false; + } + + public InventoryItemBase GetItem(InventoryItemBase item) + { + return null; + } + + public InventoryFolderBase GetFolder(InventoryFolderBase folder) + { + return null; + } + + public bool HasInventoryForUser(UUID userID) + { + return false; + } + + public InventoryFolderBase RequestRootFolder(UUID userID) + { + InventoryFolderBase root = new InventoryFolderBase(); + root.ID = UUID.Random(); + root.Owner = userID; + root.ParentID = UUID.Zero; + return root; + } + + public int GetAssetPermissions(UUID userID, UUID assetID) + { + return 1; + } + } +} diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs deleted file mode 100644 index a537b97..0000000 --- a/OpenSim/Tests/Common/Mock/TestAssetService.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Data; -using OpenSim.Services.Interfaces; -using Nini.Config; - -namespace OpenSim.Tests.Common.Mock -{ - public class TestAssetService : IAssetService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private readonly Dictionary Assets = new Dictionary(); - - public TestAssetService() {} - - /// - /// This constructor is required if the asset service is being created reflectively (which is the case in some - /// tests). - /// - /// - public TestAssetService(IConfigSource config) {} - - public AssetBase Get(string id) - { - m_log.DebugFormat("[MOCK ASSET SERVICE]: Getting asset with id {0}", id); - - AssetBase asset; - if (Assets.ContainsKey(id)) - asset = Assets[id]; - else - asset = null; - - return asset; - } - - public AssetMetadata GetMetadata(string id) - { - throw new System.NotImplementedException(); - } - - public byte[] GetData(string id) - { - throw new System.NotImplementedException(); - } - - public bool Get(string id, object sender, AssetRetrieved handler) - { - handler(id, sender, Get(id)); - - return true; - } - - public string Store(AssetBase asset) - { - m_log.DebugFormat("[MOCK ASSET SERVICE]: Storing asset {0}", asset.ID); - - Assets[asset.ID] = asset; - - return asset.ID; - } - - public bool UpdateContent(string id, byte[] data) - { - throw new System.NotImplementedException(); - } - - public bool Delete(string id) - { - throw new System.NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/TestInventoryService.cs deleted file mode 100644 index 5a0ee7c..0000000 --- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Framework; -using OpenMetaverse; -using OpenSim.Services.Interfaces; -using Nini.Config; - -namespace OpenSim.Tests.Common.Mock -{ - public class TestInventoryService : IInventoryService - { - public TestInventoryService() - { - } - - public TestInventoryService(IConfigSource config) - { - } - - /// - /// - /// - /// - /// - public bool CreateUserInventory(UUID userId) - { - return false; - } - - /// - /// - /// - /// - /// - public List GetInventorySkeleton(UUID userId) - { - List folders = new List(); - InventoryFolderBase folder = new InventoryFolderBase(); - folder.ID = UUID.Random(); - folder.Owner = userId; - folders.Add(folder); - return folders; - } - - public InventoryFolderBase GetRootFolder(UUID userID) - { - return new InventoryFolderBase(); - } - - public InventoryCollection GetFolderContent(UUID userID, UUID folderID) - { - return null; - } - - public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) - { - return null; - } - - /// - /// Returns a list of all the active gestures in a user's inventory. - /// - /// - /// The of the user - /// - /// - /// A flat list of the gesture items. - /// - public List GetActiveGestures(UUID userId) - { - return null; - } - - public InventoryCollection GetUserInventory(UUID userID) - { - return null; - } - - public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback) - { - } - - public List GetFolderItems(UUID userID, UUID folderID) - { - return null; - } - - public bool AddFolder(InventoryFolderBase folder) - { - return false; - } - - public bool UpdateFolder(InventoryFolderBase folder) - { - return false; - } - - public bool MoveFolder(InventoryFolderBase folder) - { - return false; - } - - public bool DeleteFolders(UUID ownerID, List ids) - { - return false; - } - - public bool PurgeFolder(InventoryFolderBase folder) - { - return false; - } - - public bool AddItem(InventoryItemBase item) - { - return false; - } - - public bool UpdateItem(InventoryItemBase item) - { - return false; - } - - public bool MoveItems(UUID ownerID, List items) - { - return false; - } - - public bool DeleteItems(UUID ownerID, List itemIDs) - { - return false; - } - - public InventoryItemBase GetItem(InventoryItemBase item) - { - return null; - } - - public InventoryFolderBase GetFolder(InventoryFolderBase folder) - { - return null; - } - - public bool HasInventoryForUser(UUID userID) - { - return false; - } - - public InventoryFolderBase RequestRootFolder(UUID userID) - { - InventoryFolderBase root = new InventoryFolderBase(); - root.ID = UUID.Random(); - root.Owner = userID; - root.ParentID = UUID.Zero; - return root; - } - - public int GetAssetPermissions(UUID userID, UUID assetID) - { - return 1; - } - } -} diff --git a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs index eab5422..8b18d07 100644 --- a/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs +++ b/OpenSim/Tests/Common/Setup/SceneSetupHelpers.cs @@ -219,7 +219,7 @@ namespace OpenSim.Tests.Common.Setup if (real) config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); else - config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestAssetService"); + config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockAssetService"); config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); assetService.Initialise(config); assetService.AddRegion(testScene); @@ -238,7 +238,7 @@ namespace OpenSim.Tests.Common.Setup if (real) config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); else - config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:TestInventoryService"); + config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Tests.Common.dll:MockInventoryService"); config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); inventoryService.Initialise(config); inventoryService.AddRegion(testScene); -- cgit v1.1 From ed1089d892d05c732536be2f870217d673b972d6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 19:08:00 +0000 Subject: refactor some test asset creation into a helper class remove mono compiler warning --- .../Archiver/Tests/InventoryArchiverTests.cs | 10 +---- OpenSim/Tests/Common/Setup/AssetHelpers.cs | 51 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 OpenSim/Tests/Common/Setup/AssetHelpers.cs diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index ed3ed18..f8a010c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -29,7 +29,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Reflection; -using System.Text; using System.Threading; using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; @@ -122,8 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = new AssetBase(asset1Id, asset1Id.ToString(), (sbyte)AssetType.Object); - asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); scene.AssetService.Store(asset1); // Create item @@ -338,8 +336,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = new AssetBase(asset1Id, String.Empty, (sbyte)AssetType.Object); - asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1)); + AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); scene.AssetService.Store(asset1); // Create item @@ -366,9 +363,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); - CachedUserInfo userInfo - = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - InventoryItemBase foundItem1 = InventoryArchiveUtils.FindItemByPath( scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs new file mode 100644 index 0000000..3b3babe --- /dev/null +++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs @@ -0,0 +1,51 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Text; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; + +namespace OpenSim.Tests.Common +{ + public class AssetHelpers + { + /// + /// Create an asset from the given scene object + /// + /// + /// + /// + public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog) + { + AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)AssetType.Object); + asset.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(sog)); + return asset; + } + } +} -- cgit v1.1 From e2b1fb8ff9242b112232446eee4642a2f090f0e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 19:15:08 +0000 Subject: refactor: extract another test asset helper method --- OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | 7 +++---- OpenSim/Tests/Common/Setup/AssetHelpers.cs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index dc98550..b68a044 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -34,6 +34,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Setup; using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.Framework.Scenes.Tests @@ -55,11 +56,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests public void TestCorruptAsset() { TestHelper.InMethod(); - + UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); - AssetBase corruptAsset = new AssetBase(corruptAssetUuid, corruptAssetUuid.ToString(), (sbyte)AssetType.Object); - corruptAsset.Data = Encoding.ASCII.GetBytes("CORRUPT ASSET"); - + AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); m_assetService.Store(corruptAsset); IDictionary foundAssetUuids = new Dictionary(); diff --git a/OpenSim/Tests/Common/Setup/AssetHelpers.cs b/OpenSim/Tests/Common/Setup/AssetHelpers.cs index 3b3babe..df69cd9 100644 --- a/OpenSim/Tests/Common/Setup/AssetHelpers.cs +++ b/OpenSim/Tests/Common/Setup/AssetHelpers.cs @@ -36,6 +36,19 @@ namespace OpenSim.Tests.Common public class AssetHelpers { /// + /// Create an asset from the given data + /// + /// + /// + /// + public static AssetBase CreateAsset(UUID assetUuid, string data) + { + AssetBase asset = new AssetBase(assetUuid, assetUuid.ToString(), (sbyte)AssetType.Object); + asset.Data = Encoding.ASCII.GetBytes(data); + return asset; + } + + /// /// Create an asset from the given scene object /// /// -- cgit v1.1 From d95df603dfc8e6a033649be669c6b54071ccb7d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 19:33:38 +0000 Subject: move fake user service to a separate mock user service class delete asset cache tests shell --- .../Communications/Tests/Cache/AssetCacheTests.cs | 159 --------------------- OpenSim/Tests/Common/Mock/MockUserService.cs | 123 ++++++++++++++++ 2 files changed, 123 insertions(+), 159 deletions(-) delete mode 100644 OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs create mode 100644 OpenSim/Tests/Common/Mock/MockUserService.cs diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs deleted file mode 100644 index caaebd7..0000000 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Threading; -using NUnit.Framework; -using NUnit.Framework.SyntaxHelpers; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Services.Interfaces; -using OpenSim.Tests.Common.Mock; - -namespace OpenSim.Framework.Communications.Tests -{ - /// - /// Asset cache tests - /// - [TestFixture] - public class AssetCacheTests - { - private class FakeUserService : IUserService - { - public void AddTemporaryUserProfile(UserProfileData userProfile) - { - throw new NotImplementedException(); - } - - public UserProfileData GetUserProfile(string firstName, string lastName) - { - throw new NotImplementedException(); - } - - public UserProfileData GetUserProfile(UUID userId) - { - throw new NotImplementedException(); - } - - public UserProfileData GetUserProfile(Uri uri) - { - UserProfileData userProfile = new UserProfileData(); - -// userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret)); - - return userProfile; - } - - public Uri GetUserUri(UserProfileData userProfile) - { - throw new NotImplementedException(); - } - - public UserAgentData GetAgentByUUID(UUID userId) - { - throw new NotImplementedException(); - } - - public void ClearUserAgent(UUID avatarID) - { - throw new NotImplementedException(); - } - - public List GenerateAgentPickerRequestResponse(UUID QueryID, string Query) - { - throw new NotImplementedException(); - } - - public UserProfileData SetupMasterUser(string firstName, string lastName) - { - throw new NotImplementedException(); - } - - public UserProfileData SetupMasterUser(string firstName, string lastName, string password) - { - throw new NotImplementedException(); - } - - public UserProfileData SetupMasterUser(UUID userId) - { - throw new NotImplementedException(); - } - - public bool UpdateUserProfile(UserProfileData data) - { - throw new NotImplementedException(); - } - - public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) - { - throw new NotImplementedException(); - } - - public void RemoveUserFriend(UUID friendlistowner, UUID friend) - { - throw new NotImplementedException(); - } - - public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) - { - throw new NotImplementedException(); - } - - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) - { - throw new NotImplementedException(); - } - - public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) - { - throw new NotImplementedException(); - } - - public List GetUserFriendList(UUID friendlistowner) - { - throw new NotImplementedException(); - } - - public bool VerifySession(UUID userID, UUID sessionID) - { - return true; - } - - public void SetInventoryService(IInventoryService inv) - { - throw new NotImplementedException(); - } - - public virtual bool AuthenticateUserByPassword(UUID userID, string password) - { - throw new NotImplementedException(); - } - } - } -} diff --git a/OpenSim/Tests/Common/Mock/MockUserService.cs b/OpenSim/Tests/Common/Mock/MockUserService.cs new file mode 100644 index 0000000..1e27fb7 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/MockUserService.cs @@ -0,0 +1,123 @@ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Tests.Common +{ + public class MockUserService : IUserService + { + public void AddTemporaryUserProfile(UserProfileData userProfile) + { + throw new NotImplementedException(); + } + + public UserProfileData GetUserProfile(string firstName, string lastName) + { + throw new NotImplementedException(); + } + + public UserProfileData GetUserProfile(UUID userId) + { + throw new NotImplementedException(); + } + + public UserProfileData GetUserProfile(Uri uri) + { + UserProfileData userProfile = new UserProfileData(); + +// userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret)); + + return userProfile; + } + + public Uri GetUserUri(UserProfileData userProfile) + { + throw new NotImplementedException(); + } + + public UserAgentData GetAgentByUUID(UUID userId) + { + throw new NotImplementedException(); + } + + public void ClearUserAgent(UUID avatarID) + { + throw new NotImplementedException(); + } + + public List GenerateAgentPickerRequestResponse(UUID QueryID, string Query) + { + throw new NotImplementedException(); + } + + public UserProfileData SetupMasterUser(string firstName, string lastName) + { + throw new NotImplementedException(); + } + + public UserProfileData SetupMasterUser(string firstName, string lastName, string password) + { + throw new NotImplementedException(); + } + + public UserProfileData SetupMasterUser(UUID userId) + { + throw new NotImplementedException(); + } + + public bool UpdateUserProfile(UserProfileData data) + { + throw new NotImplementedException(); + } + + public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) + { + throw new NotImplementedException(); + } + + public void RemoveUserFriend(UUID friendlistowner, UUID friend) + { + throw new NotImplementedException(); + } + + public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) + { + throw new NotImplementedException(); + } + + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) + { + throw new NotImplementedException(); + } + + public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) + { + throw new NotImplementedException(); + } + + public List GetUserFriendList(UUID friendlistowner) + { + throw new NotImplementedException(); + } + + public bool VerifySession(UUID userID, UUID sessionID) + { + return true; + } + + public void SetInventoryService(IInventoryService inv) + { + throw new NotImplementedException(); + } + + public virtual bool AuthenticateUserByPassword(UUID userID, string password) + { + throw new NotImplementedException(); + } + } +} -- cgit v1.1 From fe82471c2b5ad15ff95aabb1ac18ffa4e5f83b72 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 Nov 2009 19:42:35 +0000 Subject: Apply patch http://opensimulator.org/mantis/view.php?id=4369 Adds osGetMapTexture() and osGetRegionMapTexture() methods to retrieve region map texture uuids --- .../Shared/Api/Implementation/OSSL_Api.cs | 75 ++++++++++++++++------ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 10 +-- .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 28 +++++--- 3 files changed, 81 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f7ee3d9..3ffcff0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -199,7 +199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //Dumps an error message on the debug console. // - internal void OSSLShoutError(string message) + internal void OSSLShoutError(string message) { if (message.Length > 1023) message = message.Substring(0, 1023); @@ -1176,7 +1176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api land.SetMediaUrl(url); } - + public void osSetParcelSIPAddress(string SIPAddress) { // What actually is the difference to the LL function? @@ -1184,7 +1184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); m_host.AddScriptLPS(1); - + ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); @@ -1194,16 +1194,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function"); return; } - + // get the voice module IVoiceModule voiceModule = World.RequestModuleInterface(); - - if (voiceModule != null) + + if (voiceModule != null) voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); else OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); - - + + } public string osGetScriptEngineName() @@ -1525,10 +1525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - /*Instead of using the LSL Dataserver event to pull notecard data, + /*Instead of using the LSL Dataserver event to pull notecard data, this will simply read the requested line and return its data as a string. - - Warning - due to the synchronous method this function uses to fetch assets, its use + + Warning - due to the synchronous method this function uses to fetch assets, its use may be dangerous and unreliable while running in grid mode. */ public string osGetNotecardLine(string name, int line) @@ -1576,10 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - /*Instead of using the LSL Dataserver event to pull notecard data line by line, + /*Instead of using the LSL Dataserver event to pull notecard data line by line, this will simply read the entire notecard and return its data as a string. - - Warning - due to the synchronous method this function uses to fetch assets, its use + + Warning - due to the synchronous method this function uses to fetch assets, its use may be dangerous and unreliable while running in grid mode. */ @@ -1634,10 +1634,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - /*Instead of using the LSL Dataserver event to pull notecard data, + /*Instead of using the LSL Dataserver event to pull notecard data, this will simply read the number of note card lines and return this data as an integer. - - Warning - due to the synchronous method this function uses to fetch assets, its use + + Warning - due to the synchronous method this function uses to fetch assets, its use may be dangerous and unreliable while running in grid mode. */ @@ -1837,7 +1837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return World.RegionInfo.RegionSettings.LoadedCreationID; } - + // Threat level is 'Low' because certain users could possibly be tricked into // dropping an unverified script into one of their own objects, which could // then gather the physical construction details of the object and transmit it @@ -1861,7 +1861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); - //QueueUserWorkItem + //QueueUserWorkItem INPCModule module = World.RequestModuleInterface(); if (module != null) @@ -1910,5 +1910,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api module.DeleteNPC(new UUID(npc.m_string), World); } } + + /// + /// Get current region's map texture UUID + /// + /// + public LSL_Key osGetMapTexture() + { + CheckThreatLevel(ThreatLevel.None, "osGetMapTexture"); + return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString(); + } + + /// + /// Get a region's map texture UUID by region UUID or name. + /// + /// + /// + public LSL_Key osGetRegionMapTexture(string regionName) + { + CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture"); + Scene scene = m_ScriptEngine.World; + UUID key = UUID.Zero; + GridRegion region; + + //If string is a key, use it. Otherwise, try to locate region by name. + if (UUID.TryParse(regionName, out key)) + region = scene.GridService.GetRegionByUUID(UUID.Zero, key); + else + region = scene.GridService.GetRegionByName(UUID.Zero, regionName); + + // If region was found, return the regions map texture key. + if (region != null) + key = region.TerrainImage; + + ScriptSleep(1000); + + return key.ToString(); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index d8d3c31..2a403bf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -79,7 +79,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces // Avatar Info Commands string osGetAgentIP(string agent); - LSL_List osGetAgents(); + LSL_List osGetAgents(); // Teleport commands void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat); @@ -127,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osGetScriptEngineName(); string osGetSimulatorVersion(); Hashtable osParseJSON(string JSON); - + void osMessageObject(key objectUUID,string message); void osMakeNotecard(string notecardName, LSL_Types.list contents); @@ -138,7 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osAvatarName2Key(string firstname, string lastname); string osKey2Name(string id); - + // Grid Info Functions string osGetGridNick(); string osGetGridName(); @@ -151,7 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osLoadedCreationDate(); string osLoadedCreationTime(); string osLoadedCreationID(); - + LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); @@ -160,5 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osNpcSay(key npc, string message); void osNpcRemove(key npc); + key osGetMapTexture(); + key osGetRegionMapTexture(string regionName); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 8dcb1f5..4928e90 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osWindActiveModelPluginName(); } - + // Not yet plugged in as available OSSL functions, so commented out // void osWindParamSet(string plugin, string param, float value) // { @@ -138,14 +138,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, + return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams, blend, disp, timer, alpha, face); } public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, bool blend, int disp, int timer, int alpha, int face) { - return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, + return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams, blend, disp, timer, alpha, face); } @@ -183,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { m_OSSL_Functions.osSetParcelMediaURL(url); } - + public void osSetParcelSIPAddress(string SIPAddress) { m_OSSL_Functions.osSetParcelSIPAddress(SIPAddress); @@ -211,7 +211,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_OSSL_Functions.osTeleportAgent(agent, position, lookat); } - // Avatar info functions + // Avatar info functions public string osGetAgentIP(string agent) { return m_OSSL_Functions.osGetAgentIP(agent); @@ -326,17 +326,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osGetScriptEngineName(); } - + public string osGetSimulatorVersion() { return m_OSSL_Functions.osGetSimulatorVersion(); } - + public Hashtable osParseJSON(string JSON) { return m_OSSL_Functions.osParseJSON(JSON); } - + public void osMessageObject(key objectUUID,string message) { m_OSSL_Functions.osMessageObject(objectUUID,message); @@ -412,7 +412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osLoadedCreationID(); } - + public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) { return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); @@ -622,5 +622,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase } } } + + public key osGetMapTexture() + { + return m_OSSL_Functions.osGetMapTexture(); + } + + public key osGetRegionMapTexture(string regionName) + { + return m_OSSL_Functions.osGetRegionMapTexture(regionName); + } } } -- cgit v1.1 From 89a63c9a8bc97b3be6dcc2576af2e7aa9c3c7543 Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 13 Nov 2009 01:18:52 -0800 Subject: Some corrections to PrimitiveBaseShape.ToOmvPrimitive() --- OpenSim/Framework/PrimitiveBaseShape.cs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index f8dac06..97231ff 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -1089,6 +1089,7 @@ namespace OpenSim.Framework public Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation) { OpenMetaverse.Primitive prim = new OpenMetaverse.Primitive(); + prim.Scale = this.Scale; prim.Position = position; prim.Rotation = rotation; @@ -1106,8 +1107,15 @@ namespace OpenSim.Framework prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (float)(this.PathShearY - 256) * 0.01f; prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f; prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f; - prim.PrimData.PathScaleX = (float)(this.PathScaleX - 100) * 0.01f; - prim.PrimData.PathScaleY = (float)(this.PathScaleY - 100) * 0.01f; + + prim.PrimData.PathScaleX = (200 - this.PathScaleX) * 0.01f; + prim.PrimData.PathScaleY = (200 - this.PathScaleY) * 0.01f; + + prim.PrimData.PathTaperX = this.PathTaperX * 0.01f; + prim.PrimData.PathTaperY = this.PathTaperY * 0.01f; + + prim.PrimData.PathTwistBegin = this.PathTwistBegin * 0.01f; + prim.PrimData.PathTwist = this.PathTwist * 0.01f; prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f; prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f; @@ -1116,11 +1124,13 @@ namespace OpenSim.Framework prim.PrimData.profileCurve = this.ProfileCurve; prim.PrimData.ProfileHole = (HoleType)this.HollowShape; - prim.PrimData.PathTwistBegin = this.PathTwistBegin * 18 / 10; - prim.PrimData.PathTwist = this.PathTwist * 18 / 10; + prim.PrimData.PathCurve = (PathCurve)this.PathCurve; + prim.PrimData.PathRadiusOffset = 0.01f * this.PathRadiusOffset; + prim.PrimData.PathRevolutions = 1.0f + 0.015f * this.PathRevolutions; + prim.PrimData.PathSkew = 0.01f * this.PathSkew; - prim.PrimData.PathTaperX = this.PathTaperX * 0.01f; - prim.PrimData.PathTaperY = this.PathTaperY * 0.01f; + prim.PrimData.PCode = OpenMetaverse.PCode.Prim; + prim.PrimData.State = 0; if (this.FlexiEntry) { @@ -1145,6 +1155,16 @@ namespace OpenSim.Framework prim.Textures = new Primitive.TextureEntry(this.TextureEntry, 0, this.TextureEntry.Length); + prim.Properties = new Primitive.ObjectProperties(); + prim.Properties.Name = "Primitive"; + prim.Properties.Description = ""; + prim.Properties.CreatorID = UUID.Zero; + prim.Properties.GroupID = UUID.Zero; + prim.Properties.OwnerID = UUID.Zero; + prim.Properties.Permissions = new Permissions(); + prim.Properties.SalePrice = 10; + prim.Properties.SaleType = new SaleType(); + return prim; } } -- cgit v1.1 From 8333b2a13893e242817fe0e7bad66cc3078bfedc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Nov 2009 15:49:59 +0000 Subject: minor: amend readme - nant 0.86 beta 1 is required for .NET building, but 0.85 still works for mono various distros (including ubuntu 9.10) still ship 0.85 --- README.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.txt b/README.txt index 3a87fe2..d276c6e 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,5 @@ Welcome to OpenSim! -Version 0.6.x - == OVERVIEW == OpenSim is a BSD Licensed Open Source project to develop a functioning @@ -26,8 +24,8 @@ See configuring OpenSim Prereqs: * Mono >= 2.4.2 - * Nant >= 0.86beta - * sqlite3 or mysql 5.x (you'll need a back end database) + * Nant >= 0.86 beta 1 (if building with the .NET framework on Windows), 0.85 (if building with the mono framework) + * sqlite3 or mysql 5.x (you'll need a backend database) From the distribution type: * ./runprebuild.sh @@ -89,4 +87,3 @@ OpenSim, as well as how to report bugs, and participate in the OpenSim project can always be found at http://opensimulator.org. Thanks for trying OpenSim, we hope it is a pleasant experience. - -- cgit v1.1 From 0712196c262d24e3d4ca0d13abac0bd3fa6964cf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Nov 2009 18:56:23 +0000 Subject: make logging less verbose when loading iars --- OpenSim/Framework/Communications/Osp/OspResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Communications/Osp/OspResolver.cs index 32f0efc..4013896 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Communications/Osp/OspResolver.cs @@ -93,7 +93,7 @@ namespace OpenSim.Framework.Communications.Osp if (!ospa.StartsWith(OSPA_PREFIX)) return UUID.Zero; - m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); +// m_log.DebugFormat("[OSP RESOLVER]: Resolving {0}", ospa); string ospaMeat = ospa.Substring(OSPA_PREFIX.Length); string[] ospaTuples = ospaMeat.Split(OSPA_TUPLE_SEPARATOR_ARRAY); -- cgit v1.1 From 69fba2647d47b289383d40fbe0593be5f303201d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Nov 2009 20:16:49 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Services/PresenceService/PresenceService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 6e59642..ba8eec8 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -41,9 +41,9 @@ namespace OpenSim.Services.PresenceService { public class PresenceService : PresenceServiceBase, IPresenceService { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger( +// MethodBase.GetCurrentMethod().DeclaringType); public PresenceService(IConfigSource config) : base(config) -- cgit v1.1 From 96be5e5a8863e01ab53fd71cfceaa1a0ed3fce45 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Nov 2009 20:24:45 +0000 Subject: minor: A further minor tweak to reduce iar load logging verbosity --- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index ee8b1bf..aafcfa2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -198,8 +198,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string originalArchivePath = archivePath; - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); +// m_log.DebugFormat( +// "[INVENTORY ARCHIVER]: Loading folder {0} {1}", rootDestFolder.Name, rootDestFolder.ID); InventoryFolderBase destFolder = null; -- cgit v1.1 From e7d0aa75ba2ef1982ffd74a14b963d4838a89e5e Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 13 Nov 2009 20:52:03 -0800 Subject: expose SceneGraph.GetGroupByPrim(UUID) --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 2fdb48d..8ff441d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -928,7 +928,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// null if no scene object group containing that prim is found - private SceneObjectGroup GetGroupByPrim(UUID fullID) + public SceneObjectGroup GetGroupByPrim(UUID fullID) { SceneObjectGroup sog; lock (SceneObjectGroupsByFullID) -- cgit v1.1 From 2e24415077ab4febf61e684fec8202a3a3e83b77 Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 13 Nov 2009 22:13:40 -0800 Subject: undo previous changes add a GetGroupByPrim() method to Scene.cs delete a redundant method --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 14 -------------- OpenSim/Region/Framework/Scenes/Scene.cs | 10 ++++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index d790041..66fb918 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -803,20 +803,6 @@ namespace OpenSim.Region.Framework.Scenes InventoryService.DeleteFolders(remoteClient.AgentId, folderIDs); } - private SceneObjectGroup GetGroupByPrim(uint localID) - { - List EntityList = GetEntities(); - - foreach (EntityBase ent in EntityList) - { - if (ent is SceneObjectGroup) - { - if (((SceneObjectGroup) ent).HasChildPrim(localID)) - return (SceneObjectGroup) ent; - } - } - return null; - } /// /// Send the details of a prim's inventory to the client. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4531e06..aeca7df 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4383,6 +4383,16 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.GetSceneObjectPart(fullID); } + /// + /// Get a scene object group that contains the prim with the given local id + /// + /// + /// null if no scene object group containing that prim is found + public SceneObjectGroup GetGroupByPrim(uint localID) + { + return m_sceneGraph.GetGroupByPrim(localID); + } + public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) { return m_sceneGraph.TryGetAvatar(avatarId, out avatar); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 8ff441d..2fdb48d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -928,7 +928,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// null if no scene object group containing that prim is found - public SceneObjectGroup GetGroupByPrim(UUID fullID) + private SceneObjectGroup GetGroupByPrim(UUID fullID) { SceneObjectGroup sog; lock (SceneObjectGroupsByFullID) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 17026e5..08c144a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3907,7 +3907,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - group = Scene.SceneGraph.GetGroupByPrim(data.localID); + group = Scene.GetGroupByPrim(data.localID); if (group != null) return GetSOGUpdatePriority(group); } -- cgit v1.1 From d5c18f6149e26f9ba364339c01e7c8a78ca24d07 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 14 Nov 2009 14:14:08 -0800 Subject: Make GroupRootUpdate be a terse update. This method is not used by opensim (it should), but it's used by external modules. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f938472..bcc9b37 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1967,12 +1967,12 @@ namespace OpenSim.Region.Framework.Scenes /// Note: this may not be cused by opensim (it probably should) but it's used by /// external modules. /// - public void SendGroupRootUpdate() + public void SendGroupRootTerseUpdate() { if (IsDeleted) return; - RootPart.SendFullUpdateToAllClients(); + RootPart.SendTerseUpdateToAllClients(); } public void QueueForUpdateCheck() -- cgit v1.1 From 28aa8010b2b47b73c6b867ff8f6284f98f12f37a Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 15 Nov 2009 21:38:38 +0100 Subject: - Lower TIME_MS_TOLERANCE to 200ms - Allow m_updateFlag to be reset to 0 in the event of a terse update being rejected - Re-add a synchronous SendTo for certain types of packets --- .../Region/ClientStack/LindenUDP/LLUDPServer.cs | 24 ++++++++++++++++++++-- .../Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 18 ++++++++++++++++ .../Region/ClientStack/LindenUDP/OutgoingPacket.cs | 4 +++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 ++++++---------- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index c773c05..0b05ed9 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -399,6 +399,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Queue or Send OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); + outgoingPacket.Type = type; if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) SendPacketFinal(outgoingPacket); @@ -510,6 +511,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP byte flags = buffer.Data[0]; bool isResend = (flags & Helpers.MSG_RESENT) != 0; bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; + bool sendSynchronous = false; LLUDPClient udpClient = outgoingPacket.Client; if (!udpClient.IsConnected) @@ -565,9 +567,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (isReliable) Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength); - // Put the UDP payload on the wire - AsyncBeginSend(buffer); + //Some packet types need to be sent synchonously. + //Sorry, i know it's not optimal, but until the LL client + //manages packets correctly and re-orders them as required, this is necessary. + + if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate + || outgoingPacket.Type == PacketType.ChatFromSimulator + || outgoingPacket.Type == PacketType.ObjectUpdate + || outgoingPacket.Type == PacketType.LayerData) + { + sendSynchronous = true; + } + // Put the UDP payload on the wire + if (sendSynchronous == true) + { + SyncBeginSend(buffer); + } + else + { + AsyncBeginSend(buffer); + } // Keep track of when this packet was sent out (right now) outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; } diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs index d2779ba..63579ac 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs @@ -246,6 +246,24 @@ namespace OpenMetaverse } } + public void SyncBeginSend(UDPPacketBuffer buf) + { + if (!m_shutdownFlag) + { + try + { + m_udpSocket.SendTo( + buf.Data, + 0, + buf.DataLength, + SocketFlags.None, + buf.RemoteEndPoint); + } + catch (SocketException) { } + catch (ObjectDisposedException) { } + } + } + public void AsyncBeginSend(UDPPacketBuffer buf) { if (!m_shutdownFlag) diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs index 1a1a1cb..7dc42d3 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs @@ -28,6 +28,7 @@ using System; using OpenSim.Framework; using OpenMetaverse; +using OpenMetaverse.Packets; namespace OpenSim.Region.ClientStack.LindenUDP { @@ -52,7 +53,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP public int TickCount; /// Category this packet belongs to public ThrottleOutPacketType Category; - + /// The type of packet so its delivery method can be determined + public PacketType Type; /// /// Default constructor /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 73d0984..c0fd437 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1064,14 +1064,6 @@ namespace OpenSim.Region.Framework.Scenes } } - /// - /// Clear all pending updates of parts to clients - /// - private void ClearUpdateSchedule() - { - m_updateFlag = 0; - } - private void SendObjectPropertiesToClient(UUID AgentID) { ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); @@ -2387,8 +2379,8 @@ namespace OpenSim.Region.Framework.Scenes { const float ROTATION_TOLERANCE = 0.01f; const float VELOCITY_TOLERANCE = 0.001f; - const float POSITION_TOLERANCE = 0.05f; - const int TIME_MS_TOLERANCE = 3000; + const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary + const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. if (m_updateFlag == 1) { @@ -2401,7 +2393,7 @@ namespace OpenSim.Region.Framework.Scenes Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) { AddTerseUpdateToAllAvatars(); - ClearUpdateSchedule(); + // This causes the Scene to 'poll' physical objects every couple of frames // bad, so it's been replaced by an event driven method. @@ -2419,13 +2411,15 @@ namespace OpenSim.Region.Framework.Scenes m_lastAngularVelocity = AngularVelocity; m_lastTerseSent = Environment.TickCount; } + //Moved this outside of the if clause so updates don't get blocked.. *sigh* + m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams* } else { if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes { AddFullUpdateToAllAvatars(); - ClearUpdateSchedule(); + m_updateFlag = 0; //Same here } } } -- cgit v1.1 From 99977902119d0bb981f507a5a6a96c1148766e77 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Nov 2009 20:19:19 +0000 Subject: Committing the incomplete table handler to get it into the tree. No user functionality yet --- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 200 +++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 OpenSim/Data/MySQL/MySQLGenericTableHandler.cs diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs new file mode 100644 index 0000000..4eb4a24 --- /dev/null +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -0,0 +1,200 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using log4net; +using MySql.Data.MySqlClient; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; + +namespace OpenSim.Data.MySQL +{ + public class MySQLGenericTableHandler : MySqlFramework where T: struct + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + + protected Dictionary m_Fields = + new Dictionary(); + + protected List m_ColumnNames = null; + protected string m_Realm; + protected FieldInfo m_DataField = null; + + public MySQLGenericTableHandler(string connectionString, + string realm, string storeName) : base(connectionString) + { + m_Realm = realm; + if (storeName != String.Empty) + { + Assembly assem = GetType().Assembly; + + Migration m = new Migration(m_Connection, assem, storeName); + m.Update(); + } + + Type t = typeof(T); + FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | + BindingFlags.Instance | + BindingFlags.DeclaredOnly); + + if (fields.Length == 0) + return; + + foreach (FieldInfo f in fields) + { + if (f.Name != "Data") + m_Fields[f.Name] = f; + else + m_DataField = f; + } + } + + private void CheckColumnNames(IDataReader reader) + { + if (m_ColumnNames != null) + return; + + m_ColumnNames = new List(); + + DataTable schemaTable = reader.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + { + if (row["ColumnName"] != null && + (!m_Fields.ContainsKey(row["ColumnName"].ToString()))) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } + } + + public T[] Get(string field, string key) + { + return Get(new string[] { field }, new string[] { key }); + } + + public T[] Get(string[] fields, string[] keys) + { + if (fields.Length != keys.Length) + return new T[0]; + + List terms = new List(); + + MySqlCommand cmd = new MySqlCommand(); + + for (int i = 0 ; i < fields.Length ; i++) + { + cmd.Parameters.AddWithValue(fields[i], keys[i]); + terms.Add(fields[i] + " = ?" + fields[i]); + } + + string where = String.Join(" and ", terms.ToArray()); + + string query = String.Format("select * from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + return DoQuery(cmd); + } + + protected T[] DoQuery(MySqlCommand cmd) + { + IDataReader reader = ExecuteReader(cmd); + if (reader == null) + return new T[0]; + + CheckColumnNames(reader); + + List result = new List(); + + while(reader.Read()) + { + T row = new T(); + + foreach (string name in m_Fields.Keys) + { + if (m_Fields[name].GetValue(row) is bool) + { + int v = Convert.ToInt32(reader[name]); + m_Fields[name].SetValue(row, v != 0 ? true : false); + } + else if(m_Fields[name].GetValue(row) is UUID) + { + UUID uuid = UUID.Zero; + + UUID.TryParse(reader[name].ToString(), out uuid); + m_Fields[name].SetValue(row, uuid); + } + else + { + m_Fields[name].SetValue(row, reader[name]); + } + } + + if (m_DataField != null) + { + Dictionary data = + new Dictionary(); + + foreach (string col in m_ColumnNames) + data[col] = reader[col].ToString(); + + m_DataField.SetValue(row, data); + } + + result.Add(row); + } + + CloseReaderCommand(cmd); + + return result.ToArray(); + } + + public T[] Get(string where) + { + MySqlCommand cmd = new MySqlCommand(); + + string query = String.Format("select * from {0} where {1}", + m_Realm, where); + + cmd.CommandText = query; + + return DoQuery(cmd); + } + + public void Store(T row) + { + MySqlCommand cmd = new MySqlCommand(); + + string query = ""; + } + } +} -- cgit v1.1 From b7f1fc116eb37a651a80bc09df11fa47540a1df9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Nov 2009 20:21:46 +0000 Subject: Prevent a nullref if a recipient of a group message gas left the scene --- .../Avatar/InstantMessage/OfflineMessageModule.cs | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 1614b70..7f9e5af 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs @@ -164,19 +164,22 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage Listmsglist = SynchronousRestObjectPoster.BeginPostObject>( "POST", m_RestURL+"/RetrieveMessages/", client.AgentId); - foreach (GridInstantMessage im in msglist) + if (msglist != null) { - // client.SendInstantMessage(im); - - // Send through scene event manager so all modules get a chance - // to look at this message before it gets delivered. - // - // Needed for proper state management for stored group - // invitations - // - Scene s = FindScene(client.AgentId); - if (s != null) - s.EventManager.TriggerIncomingInstantMessage(im); + foreach (GridInstantMessage im in msglist) + { + // client.SendInstantMessage(im); + + // Send through scene event manager so all modules get a chance + // to look at this message before it gets delivered. + // + // Needed for proper state management for stored group + // invitations + // + Scene s = FindScene(client.AgentId); + if (s != null) + s.EventManager.TriggerIncomingInstantMessage(im); + } } } -- cgit v1.1 From a49c524c9e93db1409f1f05d7b881922e178927c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Nov 2009 20:22:15 +0000 Subject: Add the ability to send messages to users ir regions via remote admin --- .../RemoteController/RemoteAdminPlugin.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 3149eaa..3bc557d 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -123,6 +123,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController availableMethods["admin_region_query"] = XmlRpcRegionQueryMethod; availableMethods["admin_shutdown"] = XmlRpcShutdownMethod; availableMethods["admin_broadcast"] = XmlRpcAlertMethod; + availableMethods["admin_dialog"] = XmlRpcDialogMethod; availableMethods["admin_restart"] = XmlRpcRestartMethod; availableMethods["admin_load_heightmap"] = XmlRpcLoadHeightmapMethod; // User management @@ -277,6 +278,53 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_log.Info("[RADMIN]: Alert request complete"); return response; } + public XmlRpcResponse XmlRpcDialogMethod(XmlRpcRequest request, IPEndPoint remoteClient) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + m_log.Info("[RADMIN]: Dialog request started"); + + try + { + Hashtable requestData = (Hashtable)request.Params[0]; + + checkStringParameters(request, new string[] { "password", "from", "message" }); + + if (m_requiredPassword != String.Empty && + (!requestData.Contains("password") || (string)requestData["password"] != m_requiredPassword)) + throw new Exception("wrong password"); + + string message = (string)requestData["message"]; + string fromuuid = (string)requestData["from"]; + m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); + + responseData["accepted"] = true; + responseData["success"] = true; + response.Value = responseData; + + m_app.SceneManager.ForEachScene( + delegate(Scene scene) + { + IDialogModule dialogModule = scene.RequestModuleInterface(); + if (dialogModule != null) + dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message); + }); + } + catch (Exception e) + { + m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); + m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); + + responseData["accepted"] = false; + responseData["success"] = false; + responseData["error"] = e.Message; + response.Value = responseData; + } + + m_log.Info("[RADMIN]: Alert request complete"); + return response; + } public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request, IPEndPoint remoteClient) { -- cgit v1.1 From b9546d12f230f4153b2c6e7e71520aa2d35c762b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 15 Nov 2009 21:20:42 +0000 Subject: Change land packet sending back to what the careminster release used to use, remove the silly spiral stuff. Revert to double packets for improved user experience --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 83 +++++++++------------- 1 file changed, 34 insertions(+), 49 deletions(-) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 7eb829e..49b9378 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -785,6 +785,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP public virtual void SendLayerData(float[] map) { Util.FireAndForget(DoSendLayerData, map); + + // Send it sync, and async. It's not that much data + // and it improves user experience just so much! + DoSendLayerData(map); } /// @@ -797,16 +801,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP try { - //for (int y = 0; y < 16; y++) - //{ - // for (int x = 0; x < 16; x++) - // { - // SendLayerData(x, y, map); - // } - //} - - // Send LayerData in a spiral pattern. Fun! - SendLayerTopRight(map, 0, 0, 15, 15); + for (int y = 0; y < 16; y++) + { + for (int x = 0; x < 16; x+=4) + { + SendLayerPacket(x, y, map); + } + } } catch (Exception e) { @@ -814,51 +815,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2) - { - // Row - for (int i = x1; i <= x2; i++) - SendLayerData(i, y1, map); - - // Column - for (int j = y1 + 1; j <= y2; j++) - SendLayerData(x2, j, map); - - if (x2 - x1 > 0) - SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2); - } - - void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2) - { - // Row in reverse - for (int i = x2; i >= x1; i--) - SendLayerData(i, y2, map); - - // Column in reverse - for (int j = y2 - 1; j >= y1; j--) - SendLayerData(x1, j, map); - - if (x2 - x1 > 0) - SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1); - } - /// /// Sends a set of four patches (x, x+1, ..., x+3) to the client /// /// heightmap /// X coordinate for patches 0..12 /// Y coordinate for patches 0..15 - // private void SendLayerPacket(float[] map, int y, int x) - // { - // int[] patches = new int[4]; - // patches[0] = x + 0 + y * 16; - // patches[1] = x + 1 + y * 16; - // patches[2] = x + 2 + y * 16; - // patches[3] = x + 3 + y * 16; - - // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); - // OutPacket(layerpack, ThrottleOutPacketType.Land); - // } + private void SendLayerPacket(int x, int y, float[] map) + { + int[] patches = new int[4]; + patches[0] = x + 0 + y * 16; + patches[1] = x + 1 + y * 16; + patches[2] = x + 2 + y * 16; + patches[3] = x + 3 + y * 16; + + float[] heightmap = (map.Length == 65536) ? + map : + LLHeightFieldMoronize(map); + + try + { + Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); + OutPacket(layerpack, ThrottleOutPacketType.Land); + } + catch + { + for (int px = x ; px < x + 4 ; px++) + SendLayerData(px, y, map); + } + } /// /// Sends a specified patch to a client -- cgit v1.1