aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
diff options
context:
space:
mode:
authorUbitUmarov2015-09-17 05:10:24 +0100
committerUbitUmarov2015-09-17 05:10:24 +0100
commitf6c2e6e1a3853e30d251cf7c434ba1b6e2330904 (patch)
tree9f1b8e23747af3b00a3e18efa407677093e19063 /OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
parent remove bad merge code.. (diff)
downloadopensim-SC_OLD-f6c2e6e1a3853e30d251cf7c434ba1b6e2330904.zip
opensim-SC_OLD-f6c2e6e1a3853e30d251cf7c434ba1b6e2330904.tar.gz
opensim-SC_OLD-f6c2e6e1a3853e30d251cf7c434ba1b6e2330904.tar.bz2
opensim-SC_OLD-f6c2e6e1a3853e30d251cf7c434ba1b6e2330904.tar.xz
merge issues and a few more changes
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs268
1 files changed, 116 insertions, 152 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 501f1f1..ea05f1f 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -334,10 +334,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
334 protected static OSDMapLayer GetOSDMapLayerResponse() 334 protected static OSDMapLayer GetOSDMapLayerResponse()
335 { 335 {
336 OSDMapLayer mapLayer = new OSDMapLayer(); 336 OSDMapLayer mapLayer = new OSDMapLayer();
337// mapLayer.Right = 2048; 337 mapLayer.Right = 2048;
338 mapLayer.Right = 5000; 338 mapLayer.Top = 2048;
339// mapLayer.Top = 2048;
340 mapLayer.Top = 5000;
341 mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); 339 mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
342 340
343 return mapLayer; 341 return mapLayer;
@@ -447,66 +445,84 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
447 if (!m_rootAgents.Contains(remoteClient.AgentId)) 445 if (!m_rootAgents.Contains(remoteClient.AgentId))
448 return; 446 return;
449 } 447 }
448
449 // local or remote request?
450 if (regionhandle != 0 && regionhandle != m_scene.RegionInfo.RegionHandle)
451 {
452 // its Remote Map Item Request
453 // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
454 RequestMapItems("", remoteClient.AgentId, flags, EstateID, godlike, itemtype, regionhandle);
455 return;
456 }
457
450 uint xstart = 0; 458 uint xstart = 0;
451 uint ystart = 0; 459 uint ystart = 0;
452 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart); 460 Util.RegionHandleToWorldLoc(m_scene.RegionInfo.RegionHandle, out xstart, out ystart);
453 461
454 if (itemtype == (int)GridItemType.AgentLocations) // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots) 462 // its about this region...
463
464 List<mapItemReply> mapitems = new List<mapItemReply>();
465 mapItemReply mapitem = new mapItemReply();
466
467 bool adultRegion;
468
469 switch (itemtype)
455 { 470 {
456 if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle) 471 case (int)GridItemType.AgentLocations:
457 { 472 // Service 6 right now (MAP_ITEM_AGENTS_LOCATION; green dots)
458 // Just requesting map info about the current, local region 473
459 int tc = Environment.TickCount; 474 int tc = Environment.TickCount;
460 List<mapItemReply> mapitems = new List<mapItemReply>();
461 mapItemReply mapitem = new mapItemReply();
462 if (m_scene.GetRootAgentCount() <= 1) 475 if (m_scene.GetRootAgentCount() <= 1)
463 { 476 {
464 mapitem = new mapItemReply( 477 mapitem = new mapItemReply(
465 xstart + 1, 478 xstart + 1,
466 ystart + 1, 479 ystart + 1,
467 UUID.Zero, 480 UUID.Zero,
468 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()), 481 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()),
469 0, 0); 482 0, 0);
470 mapitems.Add(mapitem); 483 mapitems.Add(mapitem);
471 } 484 }
472 else 485 else
473 { 486 {
474 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 487 m_scene.ForEachRootScenePresence(delegate (ScenePresence sp)
475 { 488 {
476 // Don't send a green dot for yourself 489 // Don't send a green dot for yourself
477 if (sp.UUID != remoteClient.AgentId) 490 if (sp.UUID != remoteClient.AgentId)
478 { 491 {
479 mapitem = new mapItemReply( 492 mapitem = new mapItemReply(
480 xstart + (uint)sp.AbsolutePosition.X, 493 xstart + (uint)sp.AbsolutePosition.X,
481 ystart + (uint)sp.AbsolutePosition.Y, 494 ystart + (uint)sp.AbsolutePosition.Y,
482 UUID.Zero, 495 UUID.Zero,
483 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()), 496 Util.Md5Hash(m_scene.RegionInfo.RegionName + tc.ToString()),
484 1, 0); 497 1, 0);
485 mapitems.Add(mapitem); 498 mapitems.Add(mapitem);
486 } 499 }
487 }); 500 });
488 } 501 }
489 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); 502 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
490 } 503
491 else 504 break;
492 { 505
493 // Remote Map Item Request 506 case (int)GridItemType.AdultLandForSale:
507 case (int)GridItemType.LandForSale:
508 // Service 7 (MAP_ITEM_LAND_FOR_SALE)
509
510 adultRegion = m_scene.RegionInfo.RegionSettings.Maturity == 2;
511 if(adultRegion)
512 {
513 if (itemtype == (int)GridItemType.LandForSale)
514 break;
515 }
516 else
517 {
518 if (itemtype == (int)GridItemType.AdultLandForSale)
519 break;
520 }
494 521
495 // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
496 RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
497 }
498 }
499 else if (itemtype == (int)GridItemType.LandForSale) // Service 7 (MAP_ITEM_LAND_FOR_SALE)
500 {
501 if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
502 {
503 // Parcels 522 // Parcels
504 ILandChannel landChannel = m_scene.LandChannel; 523 ILandChannel landChannel = m_scene.LandChannel;
505 List<ILandObject> parcels = landChannel.AllParcels(); 524 List<ILandObject> parcels = landChannel.AllParcels();
506 525
507 // Local Map Item Request
508 List<mapItemReply> mapitems = new List<mapItemReply>();
509 mapItemReply mapitem = new mapItemReply();
510 if ((parcels != null) && (parcels.Count >= 1)) 526 if ((parcels != null) && (parcels.Count >= 1))
511 { 527 {
512 foreach (ILandObject parcel_interface in parcels) 528 foreach (ILandObject parcel_interface in parcels)
@@ -523,58 +539,56 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
523 { 539 {
524 Vector3 min = parcel.AABBMin; 540 Vector3 min = parcel.AABBMin;
525 Vector3 max = parcel.AABBMax; 541 Vector3 max = parcel.AABBMax;
526 float x = (min.X+max.X)/2; 542 float x = (min.X + max.X) / 2;
527 float y = (min.Y+max.Y)/2; 543 float y = (min.Y + max.Y) / 2;
528 mapitem = new mapItemReply( 544 mapitem = new mapItemReply(
529 xstart + (uint)x, 545 xstart + (uint)x,
530 ystart + (uint)y, 546 ystart + (uint)y,
531 parcel.GlobalID, 547 parcel.GlobalID,
532 parcel.Name, 548 parcel.Name,
533 parcel.Area, 549 parcel.Area,
534 parcel.SalePrice 550 parcel.SalePrice
535 ); 551 );
536 mapitems.Add(mapitem); 552 mapitems.Add(mapitem);
537 } 553 }
538 } 554 }
539 } 555 }
540 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); 556 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
541 } 557 break;
542 else 558
543 { 559 case (int)GridItemType.Telehub:
544 // Remote Map Item Request 560 // Service 1 (MAP_ITEM_TELEHUB)
545
546 // ensures that the blockingqueue doesn't get borked if the GetAgents() timing changes.
547 RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
548 }
549 }
550 else if (itemtype == (int)GridItemType.Telehub) // Service 1 (MAP_ITEM_TELEHUB)
551 {
552 if (regionhandle == 0 || regionhandle == m_scene.RegionInfo.RegionHandle)
553 {
554 List<mapItemReply> mapitems = new List<mapItemReply>();
555 mapItemReply mapitem = new mapItemReply();
556 561
557 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject); 562 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject);
558 if (sog != null) 563 if (sog != null)
559 { 564 {
560 mapitem = new mapItemReply( 565 mapitem = new mapItemReply(
561 xstart + (uint)sog.AbsolutePosition.X, 566 xstart + (uint)sog.AbsolutePosition.X,
562 ystart + (uint)sog.AbsolutePosition.Y, 567 ystart + (uint)sog.AbsolutePosition.Y,
563 UUID.Zero, 568 UUID.Zero,
564 sog.Name, 569 sog.Name,
565 0, // color (not used) 570 0, // color (not used)
566 0 // 0 = telehub / 1 = infohub 571 0 // 0 = telehub / 1 = infohub
567 ); 572 );
568 mapitems.Add(mapitem); 573 mapitems.Add(mapitem);
569 574
570 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); 575 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
571 } 576 }
572 } 577 break;
573 else 578
574 { 579 case (uint)GridItemType.PgEvent:
575 // Remote Map Item Request 580 case (uint)GridItemType.MatureEvent:
576 RequestMapItems("",remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle); 581 case (uint)GridItemType.AdultEvent:
577 } 582 case (uint)GridItemType.Classified:
583 case (uint)GridItemType.Popular:
584 // TODO
585 // just dont not cry about them
586 break;
587
588 default:
589 // unkown map item type
590 m_log.DebugFormat("[WORLD MAP]: Unknown MapItem type {1}", itemtype);
591 break;
578 } 592 }
579 } 593 }
580 594
@@ -838,19 +852,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
838 852
839 string response_mapItems_reply = null; 853 string response_mapItems_reply = null;
840 { // get the response 854 { // get the response
841 StreamReader sr = null;
842 try 855 try
843 { 856 {
844 WebResponse webResponse = mapitemsrequest.GetResponse(); 857 using (WebResponse webResponse = mapitemsrequest.GetResponse())
845 if (webResponse != null)
846 { 858 {
847 sr = new StreamReader(webResponse.GetResponseStream()); 859 if (webResponse != null)
848 response_mapItems_reply = sr.ReadToEnd().Trim(); 860 {
849 } 861 using (StreamReader sr = new StreamReader(webResponse.GetResponseStream()))
850 else 862 {
851 { 863 response_mapItems_reply = sr.ReadToEnd().Trim();
852 Interlocked.Decrement(ref nAsyncRequests); 864 }
853 return; 865 }
866 else
867 {
868 Interlocked.Decrement(ref nAsyncRequests);
869 return;
870 }
854 } 871 }
855 } 872 }
856 catch (WebException) 873 catch (WebException)
@@ -878,11 +895,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
878 Interlocked.Decrement(ref nAsyncRequests); 895 Interlocked.Decrement(ref nAsyncRequests);
879 return; 896 return;
880 } 897 }
881 finally
882 {
883 if (sr != null)
884 sr.Close();
885 }
886 898
887 OSD rezResponse = null; 899 OSD rezResponse = null;
888 try 900 try
@@ -918,6 +930,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
918 930
919 Interlocked.Decrement(ref nAsyncRequests); 931 Interlocked.Decrement(ref nAsyncRequests);
920 932
933 flags &= 0xffff;
934
921 if (id != UUID.Zero) 935 if (id != UUID.Zero)
922 { 936 {
923 ScenePresence av = null; 937 ScenePresence av = null;
@@ -943,6 +957,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
943 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); 957 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
944 } 958 }
945 959
960/* send things viewer didn't ask ?
946 // Service 7 (MAP_ITEM_LAND_FOR_SALE) 961 // Service 7 (MAP_ITEM_LAND_FOR_SALE)
947 itemtype = 7; 962 itemtype = 7;
948 963
@@ -986,6 +1001,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
986 } 1001 }
987 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); 1002 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
988 } 1003 }
1004*/
989 } 1005 }
990 } 1006 }
991 } 1007 }
@@ -1000,63 +1016,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1000 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 1016 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
1001 { 1017 {
1002 m_log.DebugFormat("[WoldMapModule] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); 1018 m_log.DebugFormat("[WoldMapModule] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag);
1003/* this flag does not seem to mean what his says
1004 if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible
1005 {
1006 List<MapBlockData> response = new List<MapBlockData>();
1007
1008 // this should return one mapblock at most. It is triggered by a click
1009 // on an unloaded square.
1010 // But make sure: Look whether the one we requested is in there
1011 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1012 (int)Util.RegionToWorldLoc((uint)minX),
1013 (int)Util.RegionToWorldLoc((uint)maxX),
1014 (int)Util.RegionToWorldLoc((uint)minY),
1015 (int)Util.RegionToWorldLoc((uint)maxY) );
1016
1017 if (regions != null)
1018 {
1019 foreach (GridRegion r in regions)
1020 {
1021 if (r.RegionLocX == Util.RegionToWorldLoc((uint)minX) &&
1022 r.RegionLocY == Util.RegionToWorldLoc((uint)minY))
1023 {
1024 // found it => add it to response
1025 MapBlockData block = new MapBlockData();
1026 if ((flag & 2) == 2)
1027 response.AddRange(Map2BlockFromGridRegion(r, flag));
1028 else
1029 {
1030 MapBlockFromGridRegion(block, r, flag);
1031 response.Add(block);
1032 }
1033 break;
1034 }
1035 }
1036 }
1037 1019
1038 if (response.Count == 0) 1020 GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag);
1039 {
1040 // response still empty => couldn't find the map-tile the user clicked on => tell the client
1041 MapBlockData block = new MapBlockData();
1042 block.X = (ushort)minX;
1043 block.Y = (ushort)minY;
1044 block.Access = (byte)SimAccess.Down; // means 'simulator is offline'
1045<<<<<<< HEAD
1046 // block.Access = (byte)SimAccess.NonExistent;
1047=======
1048>>>>>>> avn/ubitvar
1049 response.Add(block);
1050 }
1051 // The lower 16 bits are an unsigned int16
1052 remoteClient.SendMapBlock(response, flag & 0xffff);
1053 }
1054 else
1055 {
1056 // normal mapblock request. Use the provided values
1057 */
1058 GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag);
1059 // }
1060 } 1021 }
1061 1022
1062 protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 1023 protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
@@ -1125,13 +1086,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1125 maxX * (int)Constants.RegionSize, 1086 maxX * (int)Constants.RegionSize,
1126 minY * (int)Constants.RegionSize, 1087 minY * (int)Constants.RegionSize,
1127 maxY * (int)Constants.RegionSize); 1088 maxY * (int)Constants.RegionSize);
1128// (minX - 4) * (int)Constants.RegionSize,
1129// (maxX + 4) * (int)Constants.RegionSize,
1130// (minY - 4) * (int)Constants.RegionSize,
1131// (maxY + 4) * (int)Constants.RegionSize);
1132 1089
1133 //mb it means this 1090 // only send a negative answer for a single region request
1134 if(regions.Count == 0 && (flag & 0x10000) != 0) 1091 // corresponding to a click on the map. Current viewers
1092 // keep displaying "loading.." without this
1093 if(regions.Count == 0 && (flag & 0x10000) != 0 && minX == maxX && minY == maxY)
1135 { 1094 {
1136 MapBlockData block = new MapBlockData(); 1095 MapBlockData block = new MapBlockData();
1137 block.X = (ushort)minX; 1096 block.X = (ushort)minX;
@@ -1144,8 +1103,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1144 return allBlocks; 1103 return allBlocks;
1145 } 1104 }
1146 1105
1106 flag &= 0xffff;
1107
1147 foreach (GridRegion r in regions) 1108 foreach (GridRegion r in regions)
1148 { 1109 {
1110 if (r == null)
1111 continue;
1149 MapBlockData block = new MapBlockData(); 1112 MapBlockData block = new MapBlockData();
1150 if ((flag & 2) == 2) 1113 if ((flag & 2) == 2)
1151 { 1114 {
@@ -1159,15 +1122,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1159 mapBlocks.Add(block); 1122 mapBlocks.Add(block);
1160 allBlocks.Add(block); 1123 allBlocks.Add(block);
1161 } 1124 }
1125
1162 if (mapBlocks.Count >= 10) 1126 if (mapBlocks.Count >= 10)
1163 { 1127 {
1164 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); 1128 remoteClient.SendMapBlock(mapBlocks, flag);
1165 mapBlocks.Clear(); 1129 mapBlocks.Clear();
1166 Thread.Sleep(50); 1130 Thread.Sleep(50);
1167 } 1131 }
1168 } 1132 }
1169 if (mapBlocks.Count > 0) 1133 if (mapBlocks.Count > 0)
1170 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); 1134 remoteClient.SendMapBlock(mapBlocks, flag);
1171 1135
1172 return allBlocks; 1136 return allBlocks;
1173 } 1137 }
@@ -1175,7 +1139,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1175 public void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) 1139 public void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag)
1176 { 1140 {
1177 block.Access = r.Access; 1141 block.Access = r.Access;
1178 switch (flag & 0xffff) 1142 switch (flag)
1179 { 1143 {
1180 case 0: 1144 case 0:
1181 block.MapImageId = r.TerrainImage; 1145 block.MapImageId = r.TerrainImage;