aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs351
1 files changed, 186 insertions, 165 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index fa4378f..d41872fc 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
80 protected Scene m_scene; 80 protected Scene m_scene;
81 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); 81 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
82 private int cachedTime = 0; 82 private int cachedTime = 0;
83 private int blacklistTimeout = 10*60*1000; // 10 minutes 83 private int blacklistTimeout = 10 * 60 * 1000; // 10 minutes
84 private byte[] myMapImageJPEG; 84 private byte[] myMapImageJPEG;
85 protected volatile bool m_Enabled = false; 85 protected volatile bool m_Enabled = false;
86 private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); 86 private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>();
@@ -92,15 +92,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
92 //private int CacheRegionsDistance = 256; 92 //private int CacheRegionsDistance = 256;
93 93
94 #region INonSharedRegionModule Members 94 #region INonSharedRegionModule Members
95 public virtual void Initialise (IConfigSource config) 95 public virtual void Initialise(IConfigSource config)
96 { 96 {
97 string[] configSections = new string[] { "Map", "Startup" }; 97 string[] configSections = new string[] { "Map", "Startup" };
98 98
99 if (Util.GetConfigVarFromSections<string>( 99 if (Util.GetConfigVarFromSections<string>(
100 config, "WorldMapModule", configSections, "WorldMap") == "WorldMap") 100 config, "WorldMapModule", configSections, "WorldMap") == "WorldMap")
101 m_Enabled = true; 101 m_Enabled = true;
102 102
103 blacklistTimeout 103 blacklistTimeout
104 = Util.GetConfigVarFromSections<int>(config, "BlacklistTimeout", configSections, 10 * 60) * 1000; 104 = Util.GetConfigVarFromSections<int>(config, "BlacklistTimeout", configSections, 10 * 60) * 1000;
105 } 105 }
106 106
@@ -129,7 +129,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
129 } 129 }
130 } 130 }
131 131
132 public virtual void RemoveRegion (Scene scene) 132 public virtual void RemoveRegion(Scene scene)
133 { 133 {
134 if (!m_Enabled) 134 if (!m_Enabled)
135 return; 135 return;
@@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
142 } 142 }
143 } 143 }
144 144
145 public virtual void RegionLoaded (Scene scene) 145 public virtual void RegionLoaded(Scene scene)
146 { 146 {
147 if (!m_Enabled) 147 if (!m_Enabled)
148 return; 148 return;
@@ -178,14 +178,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
178 178
179 MainServer.Instance.AddHTTPHandler(regionimage, 179 MainServer.Instance.AddHTTPHandler(regionimage,
180 new GenericHTTPDOSProtector(OnHTTPGetMapImage, OnHTTPThrottled, new BasicDosProtectorOptions() 180 new GenericHTTPDOSProtector(OnHTTPGetMapImage, OnHTTPThrottled, new BasicDosProtectorOptions()
181 { 181 {
182 AllowXForwardedFor = false, 182 AllowXForwardedFor = false,
183 ForgetTimeSpan = TimeSpan.FromMinutes(2), 183 ForgetTimeSpan = TimeSpan.FromMinutes(2),
184 MaxRequestsInTimeframe = 4, 184 MaxRequestsInTimeframe = 4,
185 ReportingName = "MAPDOSPROTECTOR", 185 ReportingName = "MAPDOSPROTECTOR",
186 RequestTimeSpan = TimeSpan.FromSeconds(10), 186 RequestTimeSpan = TimeSpan.FromSeconds(10),
187 ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod 187 ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod
188 }).Process); 188 }).Process);
189 MainServer.Instance.AddLLSDHandler( 189 MainServer.Instance.AddLLSDHandler(
190 "/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest); 190 "/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest);
191 191
@@ -383,7 +383,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
383 if (threadrunning) return; 383 if (threadrunning) return;
384 threadrunning = true; 384 threadrunning = true;
385 385
386// m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread"); 386 // m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread");
387 387
388 WorkManager.StartThread( 388 WorkManager.StartThread(
389 process, 389 process,
@@ -406,11 +406,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
406 { 406 {
407 MapRequestState st = new MapRequestState(); 407 MapRequestState st = new MapRequestState();
408 st.agentID = STOP_UUID; 408 st.agentID = STOP_UUID;
409 st.EstateID=0; 409 st.EstateID = 0;
410 st.flags=0; 410 st.flags = 0;
411 st.godlike=false; 411 st.godlike = false;
412 st.itemtype=0; 412 st.itemtype = 0;
413 st.regionhandle=0; 413 st.regionhandle = 0;
414 414
415 lock (requests) 415 lock (requests)
416 { 416 {
@@ -500,15 +500,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
500 }); 500 });
501 } 501 }
502 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); 502 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
503 503
504 break; 504 break;
505 505
506 case (int)GridItemType.AdultLandForSale: 506 case (int)GridItemType.AdultLandForSale:
507 case (int)GridItemType.LandForSale: 507 case (int)GridItemType.LandForSale:
508 // Service 7 (MAP_ITEM_LAND_FOR_SALE) 508 // Service 7 (MAP_ITEM_LAND_FOR_SALE)
509 509
510 adultRegion = m_scene.RegionInfo.RegionSettings.Maturity == 2; 510 adultRegion = m_scene.RegionInfo.RegionSettings.Maturity == 2;
511 if(adultRegion) 511 if (adultRegion)
512 { 512 {
513 if (itemtype == (int)GridItemType.LandForSale) 513 if (itemtype == (int)GridItemType.LandForSale)
514 break; 514 break;
@@ -555,7 +555,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
555 } 555 }
556 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags); 556 remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
557 break; 557 break;
558 558
559 case (int)GridItemType.Telehub: 559 case (int)GridItemType.Telehub:
560 // Service 1 (MAP_ITEM_TELEHUB) 560 // Service 1 (MAP_ITEM_TELEHUB)
561 561
@@ -583,7 +583,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
583 case (uint)GridItemType.Popular: 583 case (uint)GridItemType.Popular:
584 // TODO 584 // TODO
585 // just dont not cry about them 585 // just dont not cry about them
586 break; 586 break;
587 587
588 default: 588 default:
589 // unkown map item type 589 // unkown map item type
@@ -632,7 +632,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
632 dorequest = false; 632 dorequest = false;
633 } 633 }
634 634
635 if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) 635 if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle))
636 { 636 {
637 while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break 637 while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break
638 Thread.Sleep(100); 638 Thread.Sleep(100);
@@ -711,7 +711,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
711 private void RequestMapItemsAsync(UUID id, uint flags, 711 private void RequestMapItemsAsync(UUID id, uint flags,
712 uint EstateID, bool godlike, uint itemtype, ulong regionhandle) 712 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
713 { 713 {
714// m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); 714 // m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype);
715 715
716 string httpserver = ""; 716 string httpserver = "";
717 bool blacklisted = false; 717 bool blacklisted = false;
@@ -871,7 +871,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
871 } 871 }
872 } 872 }
873 catch (WebException) 873 catch (WebException)
874 { 874 {
875 lock (m_blacklistedurls) 875 lock (m_blacklistedurls)
876 { 876 {
877 if (!m_blacklistedurls.ContainsKey(httpserver)) 877 if (!m_blacklistedurls.ContainsKey(httpserver))
@@ -957,51 +957,51 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
957 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); 957 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
958 } 958 }
959 959
960/* send things viewer didn't ask ? 960 /* send things viewer didn't ask ?
961 // Service 7 (MAP_ITEM_LAND_FOR_SALE) 961 // Service 7 (MAP_ITEM_LAND_FOR_SALE)
962 itemtype = 7; 962 itemtype = 7;
963 963
964 if (responseMap.ContainsKey(itemtype.ToString())) 964 if (responseMap.ContainsKey(itemtype.ToString()))
965 { 965 {
966 List<mapItemReply> returnitems = new List<mapItemReply>(); 966 List<mapItemReply> returnitems = new List<mapItemReply>();
967 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; 967 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
968 for (int i = 0; i < itemarray.Count; i++) 968 for (int i = 0; i < itemarray.Count; i++)
969 { 969 {
970 OSDMap mapitem = (OSDMap)itemarray[i]; 970 OSDMap mapitem = (OSDMap)itemarray[i];
971 mapItemReply mi = new mapItemReply(); 971 mapItemReply mi = new mapItemReply();
972 mi.x = (uint)mapitem["X"].AsInteger(); 972 mi.x = (uint)mapitem["X"].AsInteger();
973 mi.y = (uint)mapitem["Y"].AsInteger(); 973 mi.y = (uint)mapitem["Y"].AsInteger();
974 mi.id = mapitem["ID"].AsUUID(); 974 mi.id = mapitem["ID"].AsUUID();
975 mi.Extra = mapitem["Extra"].AsInteger(); 975 mi.Extra = mapitem["Extra"].AsInteger();
976 mi.Extra2 = mapitem["Extra2"].AsInteger(); 976 mi.Extra2 = mapitem["Extra2"].AsInteger();
977 mi.name = mapitem["Name"].AsString(); 977 mi.name = mapitem["Name"].AsString();
978 returnitems.Add(mi); 978 returnitems.Add(mi);
979 } 979 }
980 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); 980 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
981 } 981 }
982 982
983 // Service 1 (MAP_ITEM_TELEHUB) 983 // Service 1 (MAP_ITEM_TELEHUB)
984 itemtype = 1; 984 itemtype = 1;
985 985
986 if (responseMap.ContainsKey(itemtype.ToString())) 986 if (responseMap.ContainsKey(itemtype.ToString()))
987 { 987 {
988 List<mapItemReply> returnitems = new List<mapItemReply>(); 988 List<mapItemReply> returnitems = new List<mapItemReply>();
989 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()]; 989 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
990 for (int i = 0; i < itemarray.Count; i++) 990 for (int i = 0; i < itemarray.Count; i++)
991 { 991 {
992 OSDMap mapitem = (OSDMap)itemarray[i]; 992 OSDMap mapitem = (OSDMap)itemarray[i];
993 mapItemReply mi = new mapItemReply(); 993 mapItemReply mi = new mapItemReply();
994 mi.x = (uint)mapitem["X"].AsInteger(); 994 mi.x = (uint)mapitem["X"].AsInteger();
995 mi.y = (uint)mapitem["Y"].AsInteger(); 995 mi.y = (uint)mapitem["Y"].AsInteger();
996 mi.id = mapitem["ID"].AsUUID(); 996 mi.id = mapitem["ID"].AsUUID();
997 mi.Extra = mapitem["Extra"].AsInteger(); 997 mi.Extra = mapitem["Extra"].AsInteger();
998 mi.Extra2 = mapitem["Extra2"].AsInteger(); 998 mi.Extra2 = mapitem["Extra2"].AsInteger();
999 mi.name = mapitem["Name"].AsString(); 999 mi.name = mapitem["Name"].AsString();
1000 returnitems.Add(mi); 1000 returnitems.Add(mi);
1001 } 1001 }
1002 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); 1002 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
1003 } 1003 }
1004*/ 1004 */
1005 } 1005 }
1006 } 1006 }
1007 } 1007 }
@@ -1090,7 +1090,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1090 // only send a negative answer for a single region request 1090 // only send a negative answer for a single region request
1091 // corresponding to a click on the map. Current viewers 1091 // corresponding to a click on the map. Current viewers
1092 // keep displaying "loading.." without this 1092 // keep displaying "loading.." without this
1093 if(regions.Count == 0 && (flag & 0x10000) != 0 && minX == maxX && minY == maxY) 1093 if (regions.Count == 0 && (flag & 0x10000) != 0 && minX == maxX && minY == maxY)
1094 { 1094 {
1095 MapBlockData block = new MapBlockData(); 1095 MapBlockData block = new MapBlockData();
1096 block.X = (ushort)minX; 1096 block.X = (ushort)minX;
@@ -1213,7 +1213,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1213 if (myMapImageJPEG.Length == 0) 1213 if (myMapImageJPEG.Length == 0)
1214 { 1214 {
1215 MemoryStream imgstream = null; 1215 MemoryStream imgstream = null;
1216 Bitmap mapTexture = new Bitmap(1,1); 1216 Bitmap mapTexture = new Bitmap(1, 1);
1217 ManagedImage managedImage; 1217 ManagedImage managedImage;
1218 Image image = (Image)mapTexture; 1218 Image image = (Image)mapTexture;
1219 1219
@@ -1328,7 +1328,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1328 foreach (GridRegion r in regions) 1328 foreach (GridRegion r in regions)
1329 { 1329 {
1330 MapBlockData mapBlock = new MapBlockData(); 1330 MapBlockData mapBlock = new MapBlockData();
1331 MapBlockFromGridRegion(mapBlock, r , 0); 1331 MapBlockFromGridRegion(mapBlock, r, 0);
1332 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString()); 1332 AssetBase texAsset = m_scene.AssetService.Get(mapBlock.MapImageId.ToString());
1333 1333
1334 if (texAsset != null) 1334 if (texAsset != null)
@@ -1383,21 +1383,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1383 1383
1384 GenerateMaptile(); 1384 GenerateMaptile();
1385 } 1385 }
1386/* 1386 /*
1387 if (m_mapImageGenerator == null) 1387 if (m_mapImageGenerator == null)
1388 { 1388 {
1389 Console.WriteLine("No map image generator available for {0}", m_scene.Name); 1389 Console.WriteLine("No map image generator available for {0}", m_scene.Name);
1390 return; 1390 return;
1391 } 1391 }
1392 1392
1393 using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile()) 1393 using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile())
1394 { 1394 {
1395 GenerateMaptile(mapbmp); 1395 GenerateMaptile(mapbmp);
1396 if(m_mapImageServiceModule != null) 1396 if(m_mapImageServiceModule != null)
1397 m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp); 1397 m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp);
1398 } 1398 }
1399 } 1399 }
1400*/ 1400 */
1401 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) 1401 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
1402 { 1402 {
1403 uint xstart = 0; 1403 uint xstart = 0;
@@ -1426,7 +1426,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1426 else 1426 else
1427 { 1427 {
1428 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount()); 1428 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1429 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 1429 m_scene.ForEachRootScenePresence(delegate (ScenePresence sp)
1430 { 1430 {
1431 OSDMap responsemapdata = new OSDMap(); 1431 OSDMap responsemapdata = new OSDMap();
1432 responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X)); 1432 responsemapdata["X"] = OSD.FromInteger((int)(xstart + sp.AbsolutePosition.X));
@@ -1476,8 +1476,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1476 { 1476 {
1477 Vector3 min = parcel.AABBMin; 1477 Vector3 min = parcel.AABBMin;
1478 Vector3 max = parcel.AABBMax; 1478 Vector3 max = parcel.AABBMax;
1479 float x = (min.X+max.X)/2; 1479 float x = (min.X + max.X) / 2;
1480 float y = (min.Y+max.Y)/2; 1480 float y = (min.Y + max.Y) / 2;
1481 1481
1482 OSDMap responsemapdata = new OSDMap(); 1482 OSDMap responsemapdata = new OSDMap();
1483 responsemapdata["X"] = OSD.FromInteger((int)(xstart + x)); 1483 responsemapdata["X"] = OSD.FromInteger((int)(xstart + x));
@@ -1531,54 +1531,79 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1531 1531
1532 using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile()) 1532 using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile())
1533 { 1533 {
1534 // V1 (This Module) 1534 GenerateMaptile(mapbmp);
1535// if(m_scene.RegionInfo.RegionSizeX <= Constants.RegionSize &&
1536// m_scene.RegionInfo.RegionSizeY <= Constants.RegionSize)
1537 GenerateMaptile(mapbmp);
1538 1535
1539 // v2/3 (MapImageServiceModule) 1536 if (m_mapImageServiceModule != null)
1540 if(m_mapImageServiceModule !=null)
1541 m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp); 1537 m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp);
1542 } 1538 }
1543 } 1539 }
1544 1540
1545 private void GenerateMaptile(Bitmap mapbmp) 1541 private void GenerateMaptile(Bitmap mapbmp)
1546 { 1542 {
1547 byte[] data; 1543 bool needRegionSave = false;
1548 1544
1549 try 1545 // remove old assets
1546 UUID lastID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
1547 if (lastID != UUID.Zero)
1550 { 1548 {
1551 data = OpenJPEG.EncodeFromImage(mapbmp, true); 1549 m_scene.AssetService.Delete(lastID.ToString());
1550 m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Zero;
1551 needRegionSave = true;
1552 } 1552 }
1553 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke 1553
1554 lastID = m_scene.RegionInfo.RegionSettings.ParcelImageID;
1555 if (lastID != UUID.Zero)
1554 { 1556 {
1555 m_log.Error("[WORLD MAP]: Failed generating terrain map: " + e); 1557 m_scene.AssetService.Delete(lastID.ToString());
1556 return; 1558 m_scene.RegionInfo.RegionSettings.ParcelImageID = UUID.Zero;
1559 needRegionSave = true;
1557 } 1560 }
1558 1561
1559 byte[] overlay = GenerateOverlay(); 1562 // bypass terrain image for large regions since only V2 viewers work with them
1563 if (m_scene.RegionInfo.RegionSizeX <= Constants.RegionSize &&
1564 m_scene.RegionInfo.RegionSizeY <= Constants.RegionSize
1565 && mapbmp != null)
1566 {
1567 try
1568 {
1569 byte[] data;
1560 1570
1561 UUID terrainImageID = UUID.Random(); 1571 data = OpenJPEG.EncodeFromImage(mapbmp, true);
1562 UUID parcelImageID = UUID.Zero; 1572
1573 if (data != null && data.Length > 0)
1574 {
1575 UUID terrainImageID = UUID.Random();
1563 1576
1564 AssetBase asset = new AssetBase( 1577 AssetBase asset = new AssetBase(
1565 terrainImageID, 1578 terrainImageID,
1566 "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(), 1579 "terrainImage_" + m_scene.RegionInfo.RegionID.ToString(),
1567 (sbyte)AssetType.Texture, 1580 (sbyte)AssetType.Texture,
1568 m_scene.RegionInfo.RegionID.ToString()); 1581 m_scene.RegionInfo.RegionID.ToString());
1569 asset.Data = data; 1582 asset.Data = data;
1570 asset.Description = m_scene.RegionInfo.RegionName; 1583 asset.Description = m_scene.RegionInfo.RegionName;
1571 asset.Temporary = false; 1584 asset.Temporary = false;
1572 asset.Flags = AssetFlags.Maptile; 1585 asset.Flags = AssetFlags.Maptile;
1573 1586
1574 // Store the new one 1587 // Store the new one
1575 m_log.DebugFormat("[WORLD MAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName); 1588 m_log.DebugFormat("[WORLD MAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
1576 1589
1577 m_scene.AssetService.Store(asset); 1590 m_scene.AssetService.Store(asset);
1591
1592 m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID;
1593 needRegionSave = true;
1594 }
1595 }
1596 catch (Exception e)
1597 {
1598 m_log.Error("[WORLD MAP]: Failed generating terrain map: " + e);
1599 }
1600 }
1578 1601
1602 // V2/3 still seem to need this, or we are missing something somewhere
1603 byte[] overlay = GenerateOverlay();
1579 if (overlay != null) 1604 if (overlay != null)
1580 { 1605 {
1581 parcelImageID = UUID.Random(); 1606 UUID parcelImageID = UUID.Random();
1582 1607
1583 AssetBase parcels = new AssetBase( 1608 AssetBase parcels = new AssetBase(
1584 parcelImageID, 1609 parcelImageID,
@@ -1591,20 +1616,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1591 parcels.Flags = AssetFlags.Maptile; 1616 parcels.Flags = AssetFlags.Maptile;
1592 1617
1593 m_scene.AssetService.Store(parcels); 1618 m_scene.AssetService.Store(parcels);
1619
1620 m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID;
1621 needRegionSave = true;
1594 } 1622 }
1595 1623
1596 // Switch to the new one 1624 if (needRegionSave)
1597 UUID lastTerrainImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID; 1625 m_scene.RegionInfo.RegionSettings.Save();
1598 UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.ParcelImageID;
1599 m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID;
1600 m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID;
1601 m_scene.RegionInfo.RegionSettings.Save();
1602
1603 // Delete the old one
1604 // m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastTerrainImageID);
1605 m_scene.AssetService.Delete(lastTerrainImageID.ToString());
1606 if (lastParcelImageID != UUID.Zero)
1607 m_scene.AssetService.Delete(lastParcelImageID.ToString());
1608 } 1626 }
1609 1627
1610 private void MakeRootAgent(ScenePresence avatar) 1628 private void MakeRootAgent(ScenePresence avatar)
@@ -1658,27 +1676,48 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1658 1676
1659 private Byte[] GenerateOverlay() 1677 private Byte[] GenerateOverlay()
1660 { 1678 {
1679 int landTileSize = LandManagementModule.LandUnit;
1680
1661 // These need to be ints for bitmap generation 1681 // These need to be ints for bitmap generation
1662 int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX; 1682 int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX;
1663 int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY;
1664
1665 int landTileSize = LandManagementModule.LandUnit;
1666 int regionLandTilesX = regionSizeX / landTileSize; 1683 int regionLandTilesX = regionSizeX / landTileSize;
1684
1685 int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY;
1667 int regionLandTilesY = regionSizeY / landTileSize; 1686 int regionLandTilesY = regionSizeY / landTileSize;
1668 1687
1669 using (Bitmap overlay = new Bitmap(regionSizeX, regionSizeY)) 1688 bool landForSale = false;
1689 ILandObject land;
1690
1691 // scan terrain avoiding potencial merges of large bitmaps
1692 //TODO create the sell bitmap at landchannel / landmaster ?
1693 // and auction also, still not suported
1694
1695 bool[,] saleBitmap = new bool[regionLandTilesX, regionLandTilesY];
1696 for (int x = 0, xx = 0; x < regionLandTilesX; x++ ,xx += landTileSize)
1670 { 1697 {
1671 bool[,] saleBitmap = new bool[regionLandTilesX, regionLandTilesY]; 1698 for (int y = 0, yy = 0; y < regionLandTilesY; y++, yy += landTileSize)
1672 for (int x = 0; x < regionLandTilesX; x++)
1673 { 1699 {
1674 for (int y = 0; y < regionLandTilesY; y++) 1700 land = m_scene.LandChannel.GetLandObject(xx, yy);
1701 if (land != null && (land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1702 {
1703 saleBitmap[x, y] = true;
1704 landForSale = true;
1705 }
1706 else
1675 saleBitmap[x, y] = false; 1707 saleBitmap[x, y] = false;
1676 } 1708 }
1709 }
1677 1710
1678 bool landForSale = false; 1711 if (!landForSale)
1712 {
1713 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
1714 return null;
1715 }
1679 1716
1680 List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); 1717 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
1681 1718
1719 using (Bitmap overlay = new Bitmap(regionSizeX, regionSizeY))
1720 {
1682 Color background = Color.FromArgb(0, 0, 0, 0); 1721 Color background = Color.FromArgb(0, 0, 0, 0);
1683 1722
1684 using (Graphics g = Graphics.FromImage(overlay)) 1723 using (Graphics g = Graphics.FromImage(overlay))
@@ -1686,30 +1725,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1686 using (SolidBrush transparent = new SolidBrush(background)) 1725 using (SolidBrush transparent = new SolidBrush(background))
1687 g.FillRectangle(transparent, 0, 0, regionSizeX, regionSizeY); 1726 g.FillRectangle(transparent, 0, 0, regionSizeX, regionSizeY);
1688 1727
1689 foreach (ILandObject land in parcels) 1728 // make it a half transparent
1690 { 1729 using (SolidBrush yellow = new SolidBrush(Color.FromArgb(100, 249, 223, 9)))
1691 // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
1692 if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1693 {
1694 landForSale = true;
1695
1696 saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
1697 }
1698 }
1699
1700 if (!landForSale)
1701 {
1702 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
1703 return null;
1704 }
1705
1706 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
1707
1708 using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
1709 { 1730 {
1710 for (int x = 0; x < regionLandTilesX ; x++) 1731 for (int x = 0; x < regionLandTilesX; x++)
1711 { 1732 {
1712 for (int y = 0; y < regionLandTilesY ; y++) 1733 for (int y = 0; y < regionLandTilesY; y++)
1713 { 1734 {
1714 if (saleBitmap[x, y]) 1735 if (saleBitmap[x, y])
1715 g.FillRectangle( 1736 g.FillRectangle(