From 74bc4f61fd65e67d41918e73390b3fb48df63dd2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Jul 2010 20:15:10 +0100 Subject: factor out common face parameter checking code --- .../CoreModules/World/Media/Moap/MoapModule.cs | 56 ++++++++-------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 064047d..9dd46eb 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -101,13 +101,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap public MediaEntry GetMediaEntry(SceneObjectPart part, int face) { - if (face < 0) - throw new ArgumentException("Face cannot be less than zero"); - - int maxFaces = part.GetNumberOfSides() - 1; - if (face > maxFaces) - throw new ArgumentException( - string.Format("Face argument was {0} but max is {1}", face, maxFaces)); + CheckFaceParam(part, face); List media = part.Shape.Media; @@ -124,16 +118,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) { - if (face < 0) - throw new ArgumentException("Face cannot be less than zero"); - - int maxFaces = part.GetNumberOfSides() - 1; - if (face > maxFaces) - throw new ArgumentException( - string.Format("Face argument was {0} but max is {1}", face, maxFaces)); + CheckFaceParam(part, face); if (null == part.Shape.Media) - part.Shape.Media = new List(maxFaces); + part.Shape.Media = new List(part.GetNumberOfSides()); part.Shape.Media[face] = me; @@ -187,8 +175,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap /// /// protected string HandleObjectMediaRequest(ObjectMediaRequest omr) - { - //UUID primId = (UUID)osdParams["object_id"]; + { UUID primId = omr.PrimID; SceneObjectPart part = m_scene.GetSceneObjectPart(primId); @@ -200,23 +187,6 @@ namespace OpenSim.Region.CoreModules.Media.Moap primId, m_scene.RegionInfo.RegionName); return string.Empty; } - - /* - int faces = part.GetNumberOfSides(); - m_log.DebugFormat("[MOAP]: Faces [{0}] for [{1}]", faces, primId); - - MediaEntry[] media = new MediaEntry[faces]; - for (int i = 0; i < faces; i++) - { - MediaEntry me = new MediaEntry(); - me.HomeURL = "google.com"; - me.CurrentURL = "google.com"; - me.AutoScale = true; - //me.Height = 300; - //me.Width = 240; - media[i] = me; - } - */ if (null == part.Shape.Media) return string.Empty; @@ -330,6 +300,22 @@ namespace OpenSim.Region.CoreModules.Media.Moap // TODO: Persist in database return string.Empty; - } + } + + /// + /// Check that the face number is valid for the given prim. + /// + /// + /// + protected void CheckFaceParam(SceneObjectPart part, int face) + { + if (face < 0) + throw new ArgumentException("Face cannot be less than zero"); + + int maxFaces = part.GetNumberOfSides() - 1; + if (face > maxFaces) + throw new ArgumentException( + string.Format("Face argument was {0} but max is {1}", face, maxFaces)); + } } } \ No newline at end of file -- cgit v1.1