aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs72
1 files changed, 42 insertions, 30 deletions
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
index 34dc552..19d8141 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
@@ -173,11 +173,14 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
173 OSDMap GetMaterial(UUID id) 173 OSDMap GetMaterial(UUID id)
174 { 174 {
175 OSDMap map = null; 175 OSDMap map = null;
176 if (m_knownMaterials.ContainsKey(id)) 176 lock (m_knownMaterials)
177 { 177 {
178 map = new OSDMap(); 178 if (m_knownMaterials.ContainsKey(id))
179 map["ID"] = OSD.FromBinary(id.GetBytes()); 179 {
180 map["Material"] = m_knownMaterials[id]; 180 map = new OSDMap();
181 map["ID"] = OSD.FromBinary(id.GetBytes());
182 map["Material"] = m_knownMaterials[id];
183 }
181 } 184 }
182 return map; 185 return map;
183 } 186 }
@@ -227,7 +230,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
227 { 230 {
228 try 231 try
229 { 232 {
230 m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; 233 lock (m_knownMaterials)
234 m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"];
231 } 235 }
232 catch (Exception e) 236 catch (Exception e)
233 { 237 {
@@ -251,8 +255,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
251 255
252 if (te.DefaultTexture != null) 256 if (te.DefaultTexture != null)
253 { 257 {
254 if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) 258 lock (m_knownMaterials)
255 mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; 259 {
260 if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID))
261 mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID];
262 }
256 } 263 }
257 264
258 if (te.FaceTextures != null) 265 if (te.FaceTextures != null)
@@ -261,8 +268,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
261 { 268 {
262 if (face != null) 269 if (face != null)
263 { 270 {
264 if (m_knownMaterials.ContainsKey(face.MaterialID)) 271 lock (m_knownMaterials)
265 mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; 272 {
273 if (m_knownMaterials.ContainsKey(face.MaterialID))
274 mats[face.MaterialID] = m_knownMaterials[face.MaterialID];
275 }
266 } 276 }
267 } 277 }
268 } 278 }
@@ -323,18 +333,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
323 try 333 try
324 { 334 {
325 UUID id = new UUID(elem.AsBinary(), 0); 335 UUID id = new UUID(elem.AsBinary(), 0);
326 336
327 if (m_knownMaterials.ContainsKey(id)) 337 lock (m_knownMaterials)
328 { 338 {
329 m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString()); 339 if (m_knownMaterials.ContainsKey(id))
330 OSDMap matMap = new OSDMap(); 340 {
331 matMap["ID"] = OSD.FromBinary(id.GetBytes()); 341 m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString());
342 OSDMap matMap = new OSDMap();
343 matMap["ID"] = OSD.FromBinary(id.GetBytes());
332 344
333 matMap["Material"] = m_knownMaterials[id]; 345 matMap["Material"] = m_knownMaterials[id];
334 respArr.Add(matMap); 346 respArr.Add(matMap);
347 }
348 else
349 m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString());
335 } 350 }
336 else
337 m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString());
338 } 351 }
339 catch (Exception e) 352 catch (Exception e)
340 { 353 {
@@ -372,7 +385,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
372 m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); 385 m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat));
373 386
374 UUID id = HashOsd(mat); 387 UUID id = HashOsd(mat);
375 m_knownMaterials[id] = mat; 388 lock (m_knownMaterials)
389 m_knownMaterials[id] = mat;
376 390
377 391
378 var sop = m_scene.GetSceneObjectPart(matLocalID); 392 var sop = m_scene.GetSceneObjectPart(matLocalID);
@@ -480,24 +494,22 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
480 m_log.Debug("[MaterialsDemoModule]: GET cap handler"); 494 m_log.Debug("[MaterialsDemoModule]: GET cap handler");
481 495
482 OSDMap resp = new OSDMap(); 496 OSDMap resp = new OSDMap();
483
484
485 int matsCount = 0; 497 int matsCount = 0;
486
487 OSDArray allOsd = new OSDArray(); 498 OSDArray allOsd = new OSDArray();
488 499
489 foreach (KeyValuePair<UUID, OSDMap> kvp in m_knownMaterials) 500 lock (m_knownMaterials)
490 { 501 {
491 OSDMap matMap = new OSDMap(); 502 foreach (KeyValuePair<UUID, OSDMap> kvp in m_knownMaterials)
492 503 {
493 matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); 504 OSDMap matMap = new OSDMap();
494 505
495 matMap["Material"] = kvp.Value; 506 matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes());
496 allOsd.Add(matMap); 507 matMap["Material"] = kvp.Value;
497 matsCount++; 508 allOsd.Add(matMap);
509 matsCount++;
510 }
498 } 511 }
499 512
500
501 resp["Zipped"] = ZCompressOSD(allOsd, false); 513 resp["Zipped"] = ZCompressOSD(allOsd, false);
502 m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); 514 m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString());
503 515