aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/IClientAPI.cs9
-rw-r--r--OpenSim/Framework/MapItemReplyStruct.cs42
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs34
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs168
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs6
6 files changed, 265 insertions, 0 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index c0d133e..7095387 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -310,6 +310,9 @@ namespace OpenSim.Framework
310 public delegate void TerrainUnacked(IClientAPI remoteClient, int patchX, int patchY); 310 public delegate void TerrainUnacked(IClientAPI remoteClient, int patchX, int patchY);
311 311
312 public delegate void DirPlacesQuery(IClientAPI remoteClient, UUID queryID, string queryText, int queryFlags, int category, string simName, int queryStart); 312 public delegate void DirPlacesQuery(IClientAPI remoteClient, UUID queryID, string queryText, int queryFlags, int category, string simName, int queryStart);
313
314 public delegate void MapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle);
315
313 #endregion 316 #endregion
314 317
315 public struct DirPlacesReplyData 318 public struct DirPlacesReplyData
@@ -546,6 +549,9 @@ namespace OpenSim.Framework
546 549
547 event DirPlacesQuery OnDirPlacesQuery; 550 event DirPlacesQuery OnDirPlacesQuery;
548 551
552 event MapItemRequest OnMapItemRequest;
553
554
549 // void ActivateGesture(UUID assetId, UUID gestureId); 555 // void ActivateGesture(UUID assetId, UUID gestureId);
550 556
551 // [Obsolete("IClientAPI.OutPacket SHOULD NOT EXIST outside of LLClientView please refactor appropriately.")] 557 // [Obsolete("IClientAPI.OutPacket SHOULD NOT EXIST outside of LLClientView please refactor appropriately.")]
@@ -775,6 +781,9 @@ namespace OpenSim.Framework
775 void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt); 781 void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt);
776 782
777 void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data); 783 void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data);
784
785 void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags);
786
778 void KillEndDone(); 787 void KillEndDone();
779 } 788 }
780} 789}
diff --git a/OpenSim/Framework/MapItemReplyStruct.cs b/OpenSim/Framework/MapItemReplyStruct.cs
new file mode 100644
index 0000000..f088085
--- /dev/null
+++ b/OpenSim/Framework/MapItemReplyStruct.cs
@@ -0,0 +1,42 @@
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 OpenSim 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 OpenMetaverse;
30
31namespace OpenSim.Framework
32{
33 public struct mapItemReply
34 {
35 public uint x;
36 public uint y;
37 public UUID id;
38 public int Extra;
39 public int Extra2;
40 public string name;
41 }
42}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 2187bc8..92275e8 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -262,6 +262,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
262 262
263 private DirPlacesQuery handlerDirPlacesQuery = null; 263 private DirPlacesQuery handlerDirPlacesQuery = null;
264 264
265 private MapItemRequest handlerMapItemRequest = null;
266
265 //private TerrainUnacked handlerUnackedTerrain = null; 267 //private TerrainUnacked handlerUnackedTerrain = null;
266 268
267 //** 269 //**
@@ -988,6 +990,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
988 990
989 public event DirPlacesQuery OnDirPlacesQuery; 991 public event DirPlacesQuery OnDirPlacesQuery;
990 992
993 public event MapItemRequest OnMapItemRequest;
991 994
992 // voire si c'est necessaire 995 // voire si c'est necessaire
993 public void ActivateGesture(UUID assetId, UUID gestureId) 996 public void ActivateGesture(UUID assetId, UUID gestureId)
@@ -6215,6 +6218,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6215 //break; 6218 //break;
6216 case PacketType.MapItemRequest: 6219 case PacketType.MapItemRequest:
6217 // TODO: handle this packet 6220 // TODO: handle this packet
6221 MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
6222 //System.Console.WriteLine(mirpk.ToString());
6223 handlerMapItemRequest = OnMapItemRequest;
6224 if (handlerMapItemRequest != null)
6225 {
6226 handlerMapItemRequest(this,mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
6227 mirpk.AgentData.Godlike,mirpk.RequestData.ItemType,
6228 mirpk.RequestData.RegionHandle);
6229
6230 }
6218 //m_log.Warn("[CLIENT]: unhandled MapItemRequest packet"); 6231 //m_log.Warn("[CLIENT]: unhandled MapItemRequest packet");
6219 break; 6232 break;
6220 case PacketType.TransferAbort: 6233 case PacketType.TransferAbort:
@@ -6756,6 +6769,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6756 6769
6757 OutPacket(packet, ThrottleOutPacketType.Task); 6770 OutPacket(packet, ThrottleOutPacketType.Task);
6758 } 6771 }
6772 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
6773 {
6774 MapItemReplyPacket mirplk = new MapItemReplyPacket();
6775 mirplk.AgentData.AgentID = AgentId;
6776 mirplk.RequestData.ItemType = mapitemtype;
6777 mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
6778 for (int i = 0; i < replies.Length; i++ )
6779 {
6780 MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
6781 mrdata.X = replies[i].x;
6782 mrdata.Y = replies[i].y;
6783 mrdata.ID = replies[i].id;
6784 mrdata.Extra = replies[i].Extra;
6785 mrdata.Extra2 = replies[i].Extra2;
6786 mrdata.Name = Utils.StringToBytes(replies[i].name);
6787 mirplk.Data[i] = mrdata;
6788 }
6789 //System.Console.WriteLine(mirplk.ToString());
6790 OutPacket(mirplk, ThrottleOutPacketType.Task);
6791
6792 }
6759 6793
6760 public void KillEndDone() 6794 public void KillEndDone()
6761 { 6795 {
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
index 99c953c..ff54ed3 100644
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
@@ -324,6 +324,8 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
324 324
325 public event DirPlacesQuery OnDirPlacesQuery; 325 public event DirPlacesQuery OnDirPlacesQuery;
326 326
327 public event MapItemRequest OnMapItemRequest;
328
327#pragma warning restore 67 329#pragma warning restore 67
328 330
329 #endregion 331 #endregion
@@ -895,6 +897,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
895 { 897 {
896 } 898 }
897 899
900 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
901 {
902 }
903
898 public void KillEndDone() 904 public void KillEndDone()
899 { 905 {
900 } 906 }
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}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 6fbab0a..60a66aa 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -219,6 +219,8 @@ namespace OpenSim.Region.Examples.SimpleModule
219 219
220 public event DirPlacesQuery OnDirPlacesQuery; 220 public event DirPlacesQuery OnDirPlacesQuery;
221 221
222 public event MapItemRequest OnMapItemRequest;
223
222 224
223#pragma warning restore 67 225#pragma warning restore 67
224 226
@@ -892,6 +894,10 @@ namespace OpenSim.Region.Examples.SimpleModule
892 { 894 {
893 } 895 }
894 896
897 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
898 {
899 }
900
895 public void KillEndDone() 901 public void KillEndDone()
896 { 902 {
897 } 903 }