diff options
Diffstat (limited to 'OpenSim/Region')
4 files changed, 214 insertions, 0 deletions
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; | |||
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using System.Drawing.Imaging; | 32 | using System.Drawing.Imaging; |
33 | using System.IO; | 33 | using System.IO; |
34 | using System.Net; | ||
34 | using System.Reflection; | 35 | using System.Reflection; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
36 | using OpenMetaverse.Imaging; | 37 | using OpenMetaverse.Imaging; |
38 | using OpenMetaverse.StructuredData; | ||
37 | using log4net; | 39 | using log4net; |
38 | using Nini.Config; | 40 | using Nini.Config; |
39 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
@@ -45,6 +47,9 @@ using OpenSim.Region.Environment.Scenes; | |||
45 | using OpenSim.Region.Environment.Types; | 47 | using OpenSim.Region.Environment.Types; |
46 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; | 48 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; |
47 | 49 | ||
50 | using LLSD = OpenMetaverse.StructuredData.LLSD; | ||
51 | using LLSDMap = OpenMetaverse.StructuredData.LLSDMap; | ||
52 | using LLSDArray = OpenMetaverse.StructuredData.LLSDArray; | ||
48 | 53 | ||
49 | namespace OpenSim.Region.Environment.Modules.World.WorldMap | 54 | namespace 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 | } |