aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs41
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs579
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs8
6 files changed, 624 insertions, 20 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index dd72cfb..b28d96b 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -660,6 +660,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
660 public event BakeTerrain OnBakeTerrain; 660 public event BakeTerrain OnBakeTerrain;
661 public event EstateChangeInfo OnEstateChangeInfo; 661 public event EstateChangeInfo OnEstateChangeInfo;
662 public event EstateManageTelehub OnEstateManageTelehub; 662 public event EstateManageTelehub OnEstateManageTelehub;
663 public event CachedTextureRequest OnCachedTextureRequest;
663 public event SetAppearance OnSetAppearance; 664 public event SetAppearance OnSetAppearance;
664 public event AvatarNowWearing OnAvatarNowWearing; 665 public event AvatarNowWearing OnAvatarNowWearing;
665 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 666 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@@ -943,13 +944,18 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
943 { 944 {
944 945
945 } 946 }
947
948 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
949 {
946 950
951 }
952
947 public void SendStartPingCheck(byte seq) 953 public void SendStartPingCheck(byte seq)
948 { 954 {
949 955
950 } 956 }
951 957
952 public void SendKillObject(ulong regionHandle, List<uint> localID) 958 public void SendKillObject(List<uint> localID)
953 { 959 {
954 960
955 } 961 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index 018357a..c48e585 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -375,11 +375,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
375 scene.GetRootAgentCount(), scene.RegionInfo.RegionName, 375 scene.GetRootAgentCount(), scene.RegionInfo.RegionName,
376 scene.RegionInfo.RegionID, 376 scene.RegionInfo.RegionID,
377 DateTime.UtcNow.ToString("s"))); 377 DateTime.UtcNow.ToString("s")));
378
378 scene.ForEachRootScenePresence(delegate(ScenePresence sp) 379 scene.ForEachRootScenePresence(delegate(ScenePresence sp)
379 { 380 {
380 list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID)); 381 list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
381 list.Append("</avatars>");
382 }); 382 });
383
384 list.Append("</avatars>");
383 string payload = list.ToString(); 385 string payload = list.ToString();
384 386
385 // post via REST to broker 387 // post via REST to broker
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
index e756c70..2f07c42 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
@@ -117,6 +117,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
117 117
118 private IConfig m_config; 118 private IConfig m_config;
119 119
120 private object m_Lock;
121
120 public void Initialise(IConfigSource config) 122 public void Initialise(IConfigSource config)
121 { 123 {
122 124
@@ -128,6 +130,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
128 if (!m_config.GetBoolean("enabled", false)) 130 if (!m_config.GetBoolean("enabled", false))
129 return; 131 return;
130 132
133 m_Lock = new object();
134
131 try 135 try
132 { 136 {
133 // retrieve configuration variables 137 // retrieve configuration variables
@@ -837,7 +841,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
837 requrl = String.Format("{0}&chan_roll_off={1}", requrl, m_vivoxChannelRollOff); 841 requrl = String.Format("{0}&chan_roll_off={1}", requrl, m_vivoxChannelRollOff);
838 requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel); 842 requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel);
839 requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange); 843 requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange);
840 requrl = String.Format("{0}&chan_ckamping_distance={1}", requrl, m_vivoxChannelClampingDistance); 844 requrl = String.Format("{0}&chan_clamping_distance={1}", requrl, m_vivoxChannelClampingDistance);
841 845
842 XmlElement resp = VivoxCall(requrl, true); 846 XmlElement resp = VivoxCall(requrl, true);
843 if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri)) 847 if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri))
@@ -1118,25 +1122,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1118 1122
1119 doc = new XmlDocument(); 1123 doc = new XmlDocument();
1120 1124
1121 try 1125 // Let's serialize all calls to Vivox. Most of these are driven by
1126 // the clients (CAPs), when the user arrives at the region. We don't
1127 // want to issue many simultaneous http requests to Vivox, because mono
1128 // doesn't like that
1129 lock (m_Lock)
1122 { 1130 {
1123 // Otherwise prepare the request 1131 try
1124// m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); 1132 {
1133 // Otherwise prepare the request
1134 //m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl);
1125 1135
1126 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); 1136 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl);
1127 1137
1128 // We are sending just parameters, no content 1138 // We are sending just parameters, no content
1129 req.ContentLength = 0; 1139 req.ContentLength = 0;
1130 1140
1131 // Send request and retrieve the response 1141 // Send request and retrieve the response
1132 using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) 1142 using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
1133 using (Stream s = rsp.GetResponseStream()) 1143 using (Stream s = rsp.GetResponseStream())
1134 using (XmlTextReader rdr = new XmlTextReader(s)) 1144 using (XmlTextReader rdr = new XmlTextReader(s))
1135 doc.Load(rdr); 1145 doc.Load(rdr);
1136 } 1146 }
1137 catch (Exception e) 1147 catch (Exception e)
1138 { 1148 {
1139 m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message); 1149 m_log.ErrorFormat("[VivoxVoice] Error in admin call : {0}", e.Message);
1150 }
1140 } 1151 }
1141 1152
1142 // If we're debugging server responses, dump the whole 1153 // If we're debugging server responses, dump the whole
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
new file mode 100644
index 0000000..4ab6609
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
@@ -0,0 +1,579 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Security.Cryptography; // for computing md5 hash
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36
37using OpenMetaverse;
38using OpenMetaverse.StructuredData;
39
40using OpenSim.Framework;
41using OpenSim.Framework.Servers;
42using OpenSim.Framework.Servers.HttpServer;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes;
45
46using Ionic.Zlib;
47
48// You will need to uncomment these lines if you are adding a region module to some other assembly which does not already
49// specify its assembly. Otherwise, the region modules in the assembly will not be picked up when OpenSimulator scans
50// the available DLLs
51//[assembly: Addin("MaterialsDemoModule", "1.0")]
52//[assembly: AddinDependency("OpenSim", "0.5")]
53
54namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
55{
56 /// <summary>
57 ///
58 // # # ## ##### # # # # # ####
59 // # # # # # # ## # # ## # # #
60 // # # # # # # # # # # # # # #
61 // # ## # ###### ##### # # # # # # # # ###
62 // ## ## # # # # # ## # # ## # #
63 // # # # # # # # # # # # ####
64 //
65 // THIS MODULE IS FOR EXPERIMENTAL USE ONLY AND MAY CAUSE REGION OR ASSET CORRUPTION!
66 //
67 ////////////// WARNING //////////////////////////////////////////////////////////////////
68 /// This is an *Experimental* module for developing support for materials-capable viewers
69 /// This module should NOT be used in a production environment! It may cause data corruption and
70 /// viewer crashes. It should be only used to evaluate implementations of materials.
71 ///
72 /// Materials are persisted via SceneObjectPart.dynattrs. This is a relatively new feature
73 /// of OpenSimulator and is not field proven at the time this module was written. Persistence
74 /// may fail or become corrupt and this could cause viewer crashes due to erroneous materials
75 /// data being sent to viewers. Materials descriptions might survive IAR, OAR, or other means
76 /// of archiving however the texture resources used by these materials probably will not as they
77 /// may not be adequately referenced to ensure proper archiving.
78 ///
79 ///
80 ///
81 /// To enable this module, add this string at the bottom of OpenSim.ini:
82 /// [MaterialsDemoModule]
83 ///
84 /// </summary>
85 ///
86
87 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MaterialsDemoModule")]
88 public class MaterialsDemoModule : INonSharedRegionModule
89 {
90 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
91
92 public string Name { get { return "MaterialsDemoModule"; } }
93
94 public Type ReplaceableInterface { get { return null; } }
95
96 private Scene m_scene = null;
97 private bool m_enabled = false;
98
99 public Dictionary<UUID, OSDMap> m_knownMaterials = new Dictionary<UUID, OSDMap>();
100
101 public void Initialise(IConfigSource source)
102 {
103 m_enabled = (source.Configs["MaterialsDemoModule"] != null);
104 if (!m_enabled)
105 return;
106
107 m_log.DebugFormat("[MaterialsDemoModule]: INITIALIZED MODULE");
108 }
109
110 public void Close()
111 {
112 if (!m_enabled)
113 return;
114
115 m_log.DebugFormat("[MaterialsDemoModule]: CLOSED MODULE");
116 }
117
118 public void AddRegion(Scene scene)
119 {
120 if (!m_enabled)
121 return;
122
123 m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName);
124 m_scene = scene;
125 m_scene.EventManager.OnRegisterCaps += new EventManager.RegisterCapsEvent(OnRegisterCaps);
126 m_scene.EventManager.OnObjectAddedToScene += new Action<SceneObjectGroup>(EventManager_OnObjectAddedToScene);
127 }
128
129 void EventManager_OnObjectAddedToScene(SceneObjectGroup obj)
130 {
131 foreach (var part in obj.Parts)
132 if (part != null)
133 GetStoredMaterialsForPart(part);
134 }
135
136 void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps)
137 {
138 string capsBase = "/CAPS/" + caps.CapsObjectPath;
139
140 IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap);
141 caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler);
142
143 // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET
144 // and POST handlers, (at least at the time this was originally written), so we first set up a POST
145 // handler normally and then add a GET handler via MainServer
146
147 IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap);
148 MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler);
149
150 // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well
151 IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap);
152 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler);
153 }
154
155 public void RemoveRegion(Scene scene)
156 {
157 if (!m_enabled)
158 return;
159
160 m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
161 }
162
163 public void RegionLoaded(Scene scene)
164 {
165 }
166
167 OSDMap GetMaterial(UUID id)
168 {
169 OSDMap map = null;
170 if (m_knownMaterials.ContainsKey(id))
171 {
172 map = new OSDMap();
173 map["ID"] = OSD.FromBinary(id.GetBytes());
174 map["Material"] = m_knownMaterials[id];
175 }
176 return map;
177 }
178
179 void GetStoredMaterialsForPart(SceneObjectPart part)
180 {
181 OSDMap OSMaterials = null;
182 OSDArray matsArr = null;
183
184 if (part.DynAttrs == null)
185 {
186 m_log.Warn("[MaterialsDemoModule]: NULL DYNATTRS :( ");
187 }
188
189 lock (part.DynAttrs)
190 {
191 if (part.DynAttrs.ContainsKey("OS:Materials"))
192 OSMaterials = part.DynAttrs["OS:Materials"];
193 if (OSMaterials != null && OSMaterials.ContainsKey("Materials"))
194 {
195
196 OSD osd = OSMaterials["Materials"];
197 if (osd is OSDArray)
198 matsArr = osd as OSDArray;
199 }
200 }
201
202 if (OSMaterials == null)
203 return;
204
205 m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials));
206
207
208 if (matsArr == null)
209 {
210 m_log.Info("[MaterialsDemoModule]: matsArr is null :( ");
211 return;
212 }
213
214 foreach (OSD elemOsd in matsArr)
215 {
216 if (elemOsd != null && elemOsd is OSDMap)
217 {
218
219 OSDMap matMap = elemOsd as OSDMap;
220 if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material"))
221 {
222 try
223 {
224 m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"];
225 }
226 catch (Exception e)
227 {
228 m_log.Warn("[MaterialsDemoModule]: exception decoding persisted material: " + e.ToString());
229 }
230 }
231 }
232 }
233 }
234
235
236 void StoreMaterialsForPart(SceneObjectPart part)
237 {
238 try
239 {
240 if (part == null || part.Shape == null)
241 return;
242
243 Dictionary<UUID, OSDMap> mats = new Dictionary<UUID, OSDMap>();
244
245 Primitive.TextureEntry te = part.Shape.Textures;
246
247 if (te.DefaultTexture != null)
248 {
249 if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID))
250 mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID];
251 }
252
253 if (te.FaceTextures != null)
254 {
255 foreach (var face in te.FaceTextures)
256 {
257 if (face != null)
258 {
259 if (m_knownMaterials.ContainsKey(face.MaterialID))
260 mats[face.MaterialID] = m_knownMaterials[face.MaterialID];
261 }
262 }
263 }
264 if (mats.Count == 0)
265 return;
266
267 OSDArray matsArr = new OSDArray();
268 foreach (KeyValuePair<UUID, OSDMap> kvp in mats)
269 {
270 OSDMap matOsd = new OSDMap();
271 matOsd["ID"] = OSD.FromUUID(kvp.Key);
272 matOsd["Material"] = kvp.Value;
273 matsArr.Add(matOsd);
274 }
275
276 OSDMap OSMaterials = new OSDMap();
277 OSMaterials["Materials"] = matsArr;
278
279 lock (part.DynAttrs)
280 part.DynAttrs["OS:Materials"] = OSMaterials;
281 }
282 catch (Exception e)
283 {
284 m_log.Warn("[MaterialsDemoModule]: exception in StoreMaterialsForPart(): " + e.ToString());
285 }
286 }
287
288
289 public string RenderMaterialsPostCap(string request, string path,
290 string param, IOSHttpRequest httpRequest,
291 IOSHttpResponse httpResponse)
292 {
293 m_log.Debug("[MaterialsDemoModule]: POST cap handler");
294
295 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
296 OSDMap resp = new OSDMap();
297
298 OSDMap materialsFromViewer = null;
299
300 OSDArray respArr = new OSDArray();
301
302 if (req.ContainsKey("Zipped"))
303 {
304 OSD osd = null;
305
306 byte[] inBytes = req["Zipped"].AsBinary();
307
308 try
309 {
310 osd = ZDecompressBytesToOsd(inBytes);
311
312 if (osd != null)
313 {
314 if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
315 {
316 foreach (OSD elem in (OSDArray)osd)
317 {
318
319 try
320 {
321 UUID id = new UUID(elem.AsBinary(), 0);
322
323 if (m_knownMaterials.ContainsKey(id))
324 {
325 m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString());
326 OSDMap matMap = new OSDMap();
327 matMap["ID"] = OSD.FromBinary(id.GetBytes());
328
329 matMap["Material"] = m_knownMaterials[id];
330 respArr.Add(matMap);
331 }
332 else
333 m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString());
334 }
335 catch (Exception e)
336 {
337 // report something here?
338 continue;
339 }
340 }
341 }
342 else if (osd is OSDMap) // reqest to assign a material
343 {
344 materialsFromViewer = osd as OSDMap;
345
346 if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
347 {
348 OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
349 if (matsOsd is OSDArray)
350 {
351 OSDArray matsArr = matsOsd as OSDArray;
352
353 try
354 {
355 foreach (OSDMap matsMap in matsArr)
356 {
357 m_log.Debug("[MaterialsDemoModule]: processing matsMap: " + OSDParser.SerializeJsonString(matsMap));
358
359 uint matLocalID = 0;
360 try { matLocalID = matsMap["ID"].AsUInteger(); }
361 catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"ID\" from matsMap: " + e.Message); }
362 m_log.Debug("[MaterialsDemoModule]: matLocalId: " + matLocalID.ToString());
363
364
365 OSDMap mat = null;
366 try { mat = matsMap["Material"] as OSDMap; }
367 catch (Exception e) { m_log.Warn("[MaterialsDemoModule]: cannot decode \"Material\" from matsMap: " + e.Message); }
368 m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat));
369
370 UUID id = HashOsd(mat);
371 m_knownMaterials[id] = mat;
372
373
374 var sop = m_scene.GetSceneObjectPart(matLocalID);
375 if (sop == null)
376 m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString());
377 else
378 {
379 //var te = sop.Shape.Textures;
380 var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
381
382 if (te == null)
383 {
384 m_log.Debug("[MaterialsDemoModule]: null TextureEntry for localId: " + matLocalID.ToString());
385 }
386 else
387 {
388 int face = -1;
389
390 if (matsMap.ContainsKey("Face"))
391 {
392 face = matsMap["Face"].AsInteger();
393 if (te.FaceTextures == null) // && face == 0)
394 {
395 if (te.DefaultTexture == null)
396 m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null");
397 else
398 {
399 if (te.DefaultTexture.MaterialID == null)
400 m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture.MaterialID is null");
401 else
402 {
403 te.DefaultTexture.MaterialID = id;
404 }
405 }
406 }
407 else
408 {
409 if (te.FaceTextures.Length >= face - 1)
410 {
411 if (te.FaceTextures[face] == null)
412 te.DefaultTexture.MaterialID = id;
413 else
414 te.FaceTextures[face].MaterialID = id;
415 }
416 }
417 }
418 else
419 {
420 if (te.DefaultTexture != null)
421 te.DefaultTexture.MaterialID = id;
422 }
423
424 m_log.Debug("[MaterialsDemoModule]: setting material ID for face " + face.ToString() + " to " + id.ToString());
425
426 //we cant use sop.UpdateTextureEntry(te); because it filters so do it manually
427
428 if (sop.ParentGroup != null)
429 {
430 sop.Shape.TextureEntry = te.GetBytes();
431 sop.TriggerScriptChangedEvent(Changed.TEXTURE);
432 sop.UpdateFlag = UpdateRequired.FULL;
433 sop.ParentGroup.HasGroupChanged = true;
434
435 sop.ScheduleFullUpdate();
436
437 StoreMaterialsForPart(sop);
438 }
439 }
440 }
441 }
442 }
443 catch (Exception e)
444 {
445 m_log.Warn("[MaterialsDemoModule]: exception processing received material: " + e.Message);
446 }
447 }
448 }
449 }
450 }
451
452 }
453 catch (Exception e)
454 {
455 m_log.Warn("[MaterialsDemoModule]: exception decoding zipped CAP payload: " + e.Message);
456 //return "";
457 }
458 m_log.Debug("[MaterialsDemoModule]: knownMaterials.Count: " + m_knownMaterials.Count.ToString());
459 }
460
461
462 resp["Zipped"] = ZCompressOSD(respArr, false);
463 string response = OSDParser.SerializeLLSDXmlString(resp);
464
465 //m_log.Debug("[MaterialsDemoModule]: cap request: " + request);
466 m_log.Debug("[MaterialsDemoModule]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
467 m_log.Debug("[MaterialsDemoModule]: cap response: " + response);
468 return response;
469 }
470
471
472 public string RenderMaterialsGetCap(string request, string path,
473 string param, IOSHttpRequest httpRequest,
474 IOSHttpResponse httpResponse)
475 {
476 m_log.Debug("[MaterialsDemoModule]: GET cap handler");
477
478 OSDMap resp = new OSDMap();
479
480
481 int matsCount = 0;
482
483 OSDArray allOsd = new OSDArray();
484
485 foreach (KeyValuePair<UUID, OSDMap> kvp in m_knownMaterials)
486 {
487 OSDMap matMap = new OSDMap();
488
489 matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes());
490
491 matMap["Material"] = kvp.Value;
492 allOsd.Add(matMap);
493 matsCount++;
494 }
495
496
497 resp["Zipped"] = ZCompressOSD(allOsd, false);
498 m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString());
499
500 return OSDParser.SerializeLLSDXmlString(resp);
501 }
502
503 static string ZippedOsdBytesToString(byte[] bytes)
504 {
505 try
506 {
507 return OSDParser.SerializeJsonString(ZDecompressBytesToOsd(bytes));
508 }
509 catch (Exception e)
510 {
511 return "ZippedOsdBytesToString caught an exception: " + e.ToString();
512 }
513 }
514
515 /// <summary>
516 /// computes a UUID by hashing a OSD object
517 /// </summary>
518 /// <param name="osd"></param>
519 /// <returns></returns>
520 private static UUID HashOsd(OSD osd)
521 {
522 using (var md5 = MD5.Create())
523 using (MemoryStream ms = new MemoryStream(OSDParser.SerializeLLSDBinary(osd, false)))
524 return new UUID(md5.ComputeHash(ms), 0);
525 }
526
527 public static OSD ZCompressOSD(OSD inOsd, bool useHeader)
528 {
529 OSD osd = null;
530
531 using (MemoryStream msSinkCompressed = new MemoryStream())
532 {
533 using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed,
534 Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true))
535 {
536 CopyStream(new MemoryStream(OSDParser.SerializeLLSDBinary(inOsd, useHeader)), zOut);
537 zOut.Close();
538 }
539
540 msSinkCompressed.Seek(0L, SeekOrigin.Begin);
541 osd = OSD.FromBinary( msSinkCompressed.ToArray());
542 }
543
544 return osd;
545 }
546
547
548 public static OSD ZDecompressBytesToOsd(byte[] input)
549 {
550 OSD osd = null;
551
552 using (MemoryStream msSinkUnCompressed = new MemoryStream())
553 {
554 using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkUnCompressed, CompressionMode.Decompress, true))
555 {
556 CopyStream(new MemoryStream(input), zOut);
557 zOut.Close();
558 }
559 msSinkUnCompressed.Seek(0L, SeekOrigin.Begin);
560 osd = OSDParser.DeserializeLLSDBinary(msSinkUnCompressed.ToArray());
561 }
562
563 return osd;
564 }
565
566 static void CopyStream(System.IO.Stream input, System.IO.Stream output)
567 {
568 byte[] buffer = new byte[2048];
569 int len;
570 while ((len = input.Read(buffer, 0, 2048)) > 0)
571 {
572 output.Write(buffer, 0, len);
573 }
574
575 output.Flush();
576 }
577
578 }
579} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index 5d10e93..bcb21d0 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -696,7 +696,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
696 /// <param name="agentId"></param> 696 /// <param name="agentId"></param>
697 public void EconomyDataRequestHandler(IClientAPI user) 697 public void EconomyDataRequestHandler(IClientAPI user)
698 { 698 {
699 Scene s = LocateSceneClientIn(user.AgentId); 699 Scene s = (Scene)user.Scene;
700 700
701 user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate, 701 user.SendEconomyData(EnergyEfficiency, s.RegionInfo.ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate,
702 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor, 702 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor,
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 4674489..c8aab54 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -393,6 +393,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
393 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; 393 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
394 public event EstateChangeInfo OnEstateChangeInfo; 394 public event EstateChangeInfo OnEstateChangeInfo;
395 public event EstateManageTelehub OnEstateManageTelehub; 395 public event EstateManageTelehub OnEstateManageTelehub;
396 public event CachedTextureRequest OnCachedTextureRequest;
396 public event ScriptReset OnScriptReset; 397 public event ScriptReset OnScriptReset;
397 public event GetScriptRunning OnGetScriptRunning; 398 public event GetScriptRunning OnGetScriptRunning;
398 public event SetScriptRunning OnSetScriptRunning; 399 public event SetScriptRunning OnSetScriptRunning;
@@ -573,6 +574,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
573 { 574 {
574 } 575 }
575 576
577 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
578 {
579
580 }
581
576 public virtual void Kick(string message) 582 public virtual void Kick(string message)
577 { 583 {
578 } 584 }
@@ -590,7 +596,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
590 596
591 } 597 }
592 598
593 public virtual void SendKillObject(ulong regionHandle, List<uint> localID) 599 public virtual void SendKillObject(List<uint> localID)
594 { 600 {
595 } 601 }
596 602