diff options
author | Justin Clark-Casey (justincc) | 2010-07-12 20:15:10 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-26 23:34:19 +0100 |
commit | 74bc4f61fd65e67d41918e73390b3fb48df63dd2 (patch) | |
tree | 47edc1f3ecfc5521932a53914f864ef65b82a162 /OpenSim/Region/CoreModules | |
parent | minor: correct a few method names and change accessability (diff) | |
download | opensim-SC_OLD-74bc4f61fd65e67d41918e73390b3fb48df63dd2.zip opensim-SC_OLD-74bc4f61fd65e67d41918e73390b3fb48df63dd2.tar.gz opensim-SC_OLD-74bc4f61fd65e67d41918e73390b3fb48df63dd2.tar.bz2 opensim-SC_OLD-74bc4f61fd65e67d41918e73390b3fb48df63dd2.tar.xz |
factor out common face parameter checking code
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | 56 |
1 files 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 | |||
101 | 101 | ||
102 | public MediaEntry GetMediaEntry(SceneObjectPart part, int face) | 102 | public MediaEntry GetMediaEntry(SceneObjectPart part, int face) |
103 | { | 103 | { |
104 | if (face < 0) | 104 | CheckFaceParam(part, face); |
105 | throw new ArgumentException("Face cannot be less than zero"); | ||
106 | |||
107 | int maxFaces = part.GetNumberOfSides() - 1; | ||
108 | if (face > maxFaces) | ||
109 | throw new ArgumentException( | ||
110 | string.Format("Face argument was {0} but max is {1}", face, maxFaces)); | ||
111 | 105 | ||
112 | List<MediaEntry> media = part.Shape.Media; | 106 | List<MediaEntry> media = part.Shape.Media; |
113 | 107 | ||
@@ -124,16 +118,10 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
124 | 118 | ||
125 | public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) | 119 | public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) |
126 | { | 120 | { |
127 | if (face < 0) | 121 | CheckFaceParam(part, face); |
128 | throw new ArgumentException("Face cannot be less than zero"); | ||
129 | |||
130 | int maxFaces = part.GetNumberOfSides() - 1; | ||
131 | if (face > maxFaces) | ||
132 | throw new ArgumentException( | ||
133 | string.Format("Face argument was {0} but max is {1}", face, maxFaces)); | ||
134 | 122 | ||
135 | if (null == part.Shape.Media) | 123 | if (null == part.Shape.Media) |
136 | part.Shape.Media = new List<MediaEntry>(maxFaces); | 124 | part.Shape.Media = new List<MediaEntry>(part.GetNumberOfSides()); |
137 | 125 | ||
138 | part.Shape.Media[face] = me; | 126 | part.Shape.Media[face] = me; |
139 | 127 | ||
@@ -187,8 +175,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
187 | /// <param name="omr"></param> | 175 | /// <param name="omr"></param> |
188 | /// <returns></returns> | 176 | /// <returns></returns> |
189 | protected string HandleObjectMediaRequest(ObjectMediaRequest omr) | 177 | protected string HandleObjectMediaRequest(ObjectMediaRequest omr) |
190 | { | 178 | { |
191 | //UUID primId = (UUID)osdParams["object_id"]; | ||
192 | UUID primId = omr.PrimID; | 179 | UUID primId = omr.PrimID; |
193 | 180 | ||
194 | SceneObjectPart part = m_scene.GetSceneObjectPart(primId); | 181 | SceneObjectPart part = m_scene.GetSceneObjectPart(primId); |
@@ -200,23 +187,6 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
200 | primId, m_scene.RegionInfo.RegionName); | 187 | primId, m_scene.RegionInfo.RegionName); |
201 | return string.Empty; | 188 | return string.Empty; |
202 | } | 189 | } |
203 | |||
204 | /* | ||
205 | int faces = part.GetNumberOfSides(); | ||
206 | m_log.DebugFormat("[MOAP]: Faces [{0}] for [{1}]", faces, primId); | ||
207 | |||
208 | MediaEntry[] media = new MediaEntry[faces]; | ||
209 | for (int i = 0; i < faces; i++) | ||
210 | { | ||
211 | MediaEntry me = new MediaEntry(); | ||
212 | me.HomeURL = "google.com"; | ||
213 | me.CurrentURL = "google.com"; | ||
214 | me.AutoScale = true; | ||
215 | //me.Height = 300; | ||
216 | //me.Width = 240; | ||
217 | media[i] = me; | ||
218 | } | ||
219 | */ | ||
220 | 190 | ||
221 | if (null == part.Shape.Media) | 191 | if (null == part.Shape.Media) |
222 | return string.Empty; | 192 | return string.Empty; |
@@ -330,6 +300,22 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
330 | // TODO: Persist in database | 300 | // TODO: Persist in database |
331 | 301 | ||
332 | return string.Empty; | 302 | return string.Empty; |
333 | } | 303 | } |
304 | |||
305 | /// <summary> | ||
306 | /// Check that the face number is valid for the given prim. | ||
307 | /// </summary> | ||
308 | /// <param name="part"></param> | ||
309 | /// <param name="face"></param> | ||
310 | protected void CheckFaceParam(SceneObjectPart part, int face) | ||
311 | { | ||
312 | if (face < 0) | ||
313 | throw new ArgumentException("Face cannot be less than zero"); | ||
314 | |||
315 | int maxFaces = part.GetNumberOfSides() - 1; | ||
316 | if (face > maxFaces) | ||
317 | throw new ArgumentException( | ||
318 | string.Format("Face argument was {0} but max is {1}", face, maxFaces)); | ||
319 | } | ||
334 | } | 320 | } |
335 | } \ No newline at end of file | 321 | } \ No newline at end of file |