From 99c0f4c9c7820f6340155f7af30ab91745774c93 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Aug 2010 17:09:20 +0100 Subject: Simplify serialized version string. Change element capitalization for consistency THIS CHANGE ALTERS THE SERIALIZATION FORMAT, HOPEFULLY FOR THE LAST TIME. If you're testing, please start with a new database. This commit also improves locking for manipulation of media entries. --- .../CoreModules/World/Media/Moap/MoapModule.cs | 76 +++++++++++++--------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index d7ce184..8549b36 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -185,13 +185,15 @@ namespace OpenSim.Region.CoreModules.Media.Moap if (original.Shape.Media != null) { PrimitiveBaseShape.MediaList dupeMedia = new PrimitiveBaseShape.MediaList(); - - foreach (MediaEntry me in original.Shape.Media) + lock (original.Shape.Media) { - if (me != null) - dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD())); - else - dupeMedia.Add(null); + foreach (MediaEntry me in original.Shape.Media) + { + if (me != null) + dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD())); + else + dupeMedia.Add(null); + } } copy.Shape.Media = dupeMedia; @@ -211,8 +213,9 @@ namespace OpenSim.Region.CoreModules.Media.Moap me = null; } else - { - me = media[face]; + { + lock (media) + me = media[face]; // TODO: Really need a proper copy constructor down in libopenmetaverse if (me != null) @@ -230,11 +233,13 @@ namespace OpenSim.Region.CoreModules.Media.Moap if (null == part.Shape.Media) part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); - - part.Shape.Media[face] = me; + + lock (part.Shape.Media) + part.Shape.Media[face] = me; + UpdateMediaUrl(part, UUID.Zero); part.ScheduleFullUpdate(); - part.TriggerScriptChangedEvent(Changed.MEDIA); + part.TriggerScriptChangedEvent(Changed.MEDIA); } public void ClearMediaEntry(SceneObjectPart part, int face) @@ -296,7 +301,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap ObjectMediaResponse resp = new ObjectMediaResponse(); resp.PrimID = primId; - resp.FaceMedia = part.Shape.Media.ToArray(); + + lock (part.Shape.Media) + resp.FaceMedia = part.Shape.Media.ToArray(); + resp.Version = part.MediaUrl; string rawResp = OSDParser.SerializeLLSDXmlString(resp.Serialize()); @@ -382,24 +390,27 @@ namespace OpenSim.Region.CoreModules.Media.Moap // directly. Primitive.TextureEntry te = part.Shape.Textures; - for (int i = 0; i < media.Count; i++) - { - if (m_scene.Permissions.CanControlPrimMedia(agentId, part.UUID, i)) - { - media[i] = omu.FaceMedia[i]; - - // When a face is cleared this is done by setting the MediaFlags in the TextureEntry via a normal - // texture update, so we don't need to worry about clearing MediaFlags here. - if (null == media[i]) - continue; - - Primitive.TextureEntryFace face = te.CreateFace((uint)i); - face.MediaFlags = true; - -// m_log.DebugFormat( -// "[MOAP]: Media flags for face {0} is {1}", -// i, face.MediaFlags); -// m_log.DebugFormat("[MOAP]: Set media entry for face {0} on {1}", i, part.Name); + lock (media) + { + for (int i = 0; i < media.Count; i++) + { + if (m_scene.Permissions.CanControlPrimMedia(agentId, part.UUID, i)) + { + media[i] = omu.FaceMedia[i]; + + // When a face is cleared this is done by setting the MediaFlags in the TextureEntry via a normal + // texture update, so we don't need to worry about clearing MediaFlags here. + if (null == media[i]) + continue; + + Primitive.TextureEntryFace face = te.CreateFace((uint)i); + face.MediaFlags = true; + + // m_log.DebugFormat( + // "[MOAP]: Media flags for face {0} is {1}", + // i, face.MediaFlags); + // m_log.DebugFormat("[MOAP]: Set media entry for face {0} on {1}", i, part.Name); + } } } @@ -465,7 +476,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap if (null == part.Shape.Media) return string.Empty; - MediaEntry me = part.Shape.Media[omn.Face]; + MediaEntry me = null; + + lock (part.Shape.Media) + me = part.Shape.Media[omn.Face]; // Do the same if media has not been set up for a specific face if (null == me) -- cgit v1.1