aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/WorldMap
diff options
context:
space:
mode:
authorTeravus Ovares2008-10-06 00:00:55 +0000
committerTeravus Ovares2008-10-06 00:00:55 +0000
commitf8acdeb437ff18762399c519e2416aceb2149609 (patch)
treec24f4290f54c47010e61a8e071273bde0a2877fc /OpenSim/Region/Environment/Modules/World/WorldMap
parentFor symmetry reasons, I think this probably is a bug. (diff)
downloadopensim-SC-f8acdeb437ff18762399c519e2416aceb2149609.zip
opensim-SC-f8acdeb437ff18762399c519e2416aceb2149609.tar.gz
opensim-SC-f8acdeb437ff18762399c519e2416aceb2149609.tar.bz2
opensim-SC-f8acdeb437ff18762399c519e2416aceb2149609.tar.xz
* Green dots on the mainmap for avatar.
* Initial implementation * You'll only be able to seen green dots on regions on the map that have been updated.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/WorldMap')
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs168
1 files changed, 168 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
index bc62e07..8091c59 100644
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
@@ -31,9 +31,11 @@ using System.Collections.Generic;
31using System.Drawing; 31using System.Drawing;
32using System.Drawing.Imaging; 32using System.Drawing.Imaging;
33using System.IO; 33using System.IO;
34using System.Net;
34using System.Reflection; 35using System.Reflection;
35using OpenMetaverse; 36using OpenMetaverse;
36using OpenMetaverse.Imaging; 37using OpenMetaverse.Imaging;
38using OpenMetaverse.StructuredData;
37using log4net; 39using log4net;
38using Nini.Config; 40using Nini.Config;
39using OpenSim.Framework; 41using OpenSim.Framework;
@@ -45,6 +47,9 @@ using OpenSim.Region.Environment.Scenes;
45using OpenSim.Region.Environment.Types; 47using OpenSim.Region.Environment.Types;
46using Caps = OpenSim.Framework.Communications.Capabilities.Caps; 48using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
47 49
50using LLSD = OpenMetaverse.StructuredData.LLSD;
51using LLSDMap = OpenMetaverse.StructuredData.LLSDMap;
52using LLSDArray = OpenMetaverse.StructuredData.LLSDArray;
48 53
49namespace OpenSim.Region.Environment.Modules.World.WorldMap 54namespace OpenSim.Region.Environment.Modules.World.WorldMap
50{ 55{
@@ -85,6 +90,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
85 90
86 91
87 m_scene.AddHTTPHandler(regionimage, OnHTTPGetMapImage); 92 m_scene.AddHTTPHandler(regionimage, OnHTTPGetMapImage);
93 m_scene.AddLLSDHandler("/MAP/MapItems/" + scene.RegionInfo.RegionHandle.ToString(),HandleRemoteMapItemRequest);
88 //QuadTree.Subdivide(); 94 //QuadTree.Subdivide();
89 //QuadTree.Subdivide(); 95 //QuadTree.Subdivide();
90 96
@@ -231,6 +237,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
231 237
232 //doFriendListUpdateOnline(client.AgentId); 238 //doFriendListUpdateOnline(client.AgentId);
233 client.OnRequestMapBlocks += RequestMapBlocks; 239 client.OnRequestMapBlocks += RequestMapBlocks;
240 client.OnMapItemRequest += HandleMapItemRequest;
234 } 241 }
235 private void ClientLoggedOut(UUID AgentId) 242 private void ClientLoggedOut(UUID AgentId)
236 { 243 {
@@ -238,6 +245,109 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
238 } 245 }
239 #endregion 246 #endregion
240 247
248 public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
249 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
250 {
251 if (itemtype == 6) // we only sevice 6 right now (avatar green dots)
252 {
253 RegionInfo mreg = m_scene.SceneGridService.RequestNeighbouringRegionInfo(regionhandle);
254 if (mreg != null)
255 {
256 string httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString();
257 List<mapItemReply> returnitems = new List<mapItemReply>();
258 LLSDMap ramap = RequestMapItems(httpserver);
259 if (ramap.ContainsKey(itemtype.ToString()))
260 {
261 LLSDArray itemarray = (LLSDArray)ramap[itemtype.ToString()];
262 for (int i = 0; i < itemarray.Count; i++)
263 {
264 LLSDMap mapitem = (LLSDMap)itemarray[i];
265 mapItemReply mi = new mapItemReply();
266 mi.x = (uint)mapitem["X"].AsInteger();
267 mi.y = (uint)mapitem["Y"].AsInteger();
268 mi.id = mapitem["ID"].AsUUID();
269 mi.Extra = mapitem["Extra"].AsInteger();
270 mi.Extra2 = mapitem["Extra2"].AsInteger();
271 mi.name = mapitem["Name"].AsString();
272 returnitems.Add(mi);
273 }
274
275 }
276 remoteClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
277 }
278 }
279
280 }
281
282 private LLSDMap RequestMapItems(string httpserver)
283 {
284 WebRequest mapitemsrequest = WebRequest.Create(httpserver);
285 mapitemsrequest.Method = "POST";
286 mapitemsrequest.ContentType = "application/xml+llsd";
287 LLSDMap RAMap = new LLSDMap();
288
289 string RAMapString = RAMap.ToString();
290 LLSD LLSDofRAMap = RAMap; // RENAME if this works
291
292 byte[] buffer = LLSDParser.SerializeXmlBytes(LLSDofRAMap);
293 LLSDMap responseMap = new LLSDMap();
294 Stream os = null;
295 try
296 { // send the Post
297 mapitemsrequest.ContentLength = buffer.Length; //Count bytes to send
298 os = mapitemsrequest.GetRequestStream();
299 os.Write(buffer, 0, buffer.Length); //Send it
300 os.Close();
301 m_log.InfoFormat("[WorldMap]: Getting MapItems from Sim {0}", httpserver);
302 }
303 catch (WebException ex)
304 {
305 m_log.InfoFormat("[WorldMap] Bad send on GetMapItems {0}", ex.Message);
306 responseMap["connect"] = LLSD.FromBoolean(false);
307
308 return responseMap;
309 }
310
311 //m_log.Info("[OGP] waiting for a reply after rez avatar send");
312 string response_mapItems_reply = null;
313 { // get the response
314 try
315 {
316 WebResponse webResponse = mapitemsrequest.GetResponse();
317 if (webResponse == null)
318 {
319 //m_log.Info("[OGP:] Null reply on rez_avatar post");
320 }
321
322 StreamReader sr = new StreamReader(webResponse.GetResponseStream());
323 response_mapItems_reply = sr.ReadToEnd().Trim();
324 //m_log.InfoFormat("[OGP]: rez_avatar reply was {0} ", response_mapItems_reply);
325
326 }
327 catch (WebException ex)
328 {
329 //m_log.InfoFormat("[OGP]: exception on read after send of rez avatar {0}", ex.Message);
330 responseMap["connect"] = LLSD.FromBoolean(false);
331
332 return responseMap;
333 }
334 LLSD rezResponse = null;
335 try
336 {
337 rezResponse = LLSDParser.DeserializeXml(response_mapItems_reply);
338
339 responseMap = (LLSDMap)rezResponse;
340 }
341 catch (Exception ex)
342 {
343 //m_log.InfoFormat("[OGP]: exception on parse of rez reply {0}", ex.Message);
344 responseMap["connect"] = LLSD.FromBoolean(false);
345
346 return responseMap;
347 }
348 }
349 return responseMap;
350 }
241 /// <summary> 351 /// <summary>
242 /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates 352 /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
243 /// </summary> 353 /// </summary>
@@ -378,5 +488,63 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
378 } 488 }
379 return null; 489 return null;
380 } 490 }
491 public LLSD HandleRemoteMapItemRequest(string path, LLSD request, string endpoint)
492 {
493 uint xstart = 0;
494 uint ystart = 0;
495
496 Helpers.LongToUInts(m_scene.RegionInfo.RegionHandle,out xstart,out ystart);
497
498 LLSDMap responsemap = new LLSDMap();
499 List<ScenePresence> avatars = m_scene.GetAvatars();
500 LLSDArray responsearr = new LLSDArray(avatars.Count);
501 LLSDMap responsemapdata = new LLSDMap();
502 int tc = System.Environment.TickCount;
503 /*
504 foreach (ScenePresence av in avatars)
505 {
506 responsemapdata = new LLSDMap();
507 responsemapdata["X"] = LLSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
508 responsemapdata["Y"] = LLSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
509 responsemapdata["ID"] = LLSD.FromUUID(UUID.Zero);
510 responsemapdata["Name"] = LLSD.FromString("TH");
511 responsemapdata["Extra"] = LLSD.FromInteger(0);
512 responsemapdata["Extra2"] = LLSD.FromInteger(0);
513 responsearr.Add(responsemapdata);
514 }
515 responsemap["1"] = responsearr;
516 */
517 if (avatars.Count == 0)
518 {
519 responsemapdata = new LLSDMap();
520 responsemapdata["X"] = LLSD.FromInteger((int)(xstart + 1));
521 responsemapdata["Y"] = LLSD.FromInteger((int)(ystart + 1));
522 responsemapdata["ID"] = LLSD.FromUUID(UUID.Zero);
523 responsemapdata["Name"] = LLSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
524 responsemapdata["Extra"] = LLSD.FromInteger(0);
525 responsemapdata["Extra2"] = LLSD.FromInteger(0);
526 responsearr.Add(responsemapdata);
527
528 responsemap["6"] = responsearr;
529 }
530 else
531 {
532 responsearr = new LLSDArray(avatars.Count);
533 foreach (ScenePresence av in avatars)
534 {
535 responsemapdata = new LLSDMap();
536 responsemapdata["X"] = LLSD.FromInteger((int)(xstart + av.AbsolutePosition.X));
537 responsemapdata["Y"] = LLSD.FromInteger((int)(ystart + av.AbsolutePosition.Y));
538 responsemapdata["ID"] = LLSD.FromUUID(UUID.Zero);
539 responsemapdata["Name"] = LLSD.FromString(Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()));
540 responsemapdata["Extra"] = LLSD.FromInteger(1);
541 responsemapdata["Extra2"] = LLSD.FromInteger(0);
542 responsearr.Add(responsemapdata);
543 }
544 responsemap["6"] = responsearr;
545 }
546 return responsemap;
547 }
381 } 548 }
549
382} 550}