aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs106
1 files changed, 64 insertions, 42 deletions
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index a26a5f0..ddaf9fb 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -114,6 +114,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
114 "export-map [<path>]", 114 "export-map [<path>]",
115 "Save an image of the world map", HandleExportWorldMapConsoleCommand); 115 "Save an image of the world map", HandleExportWorldMapConsoleCommand);
116 116
117 m_scene.AddCommand(
118 "Regions", this, "generate map",
119 "generate map",
120 "Generates and stores a new maptile.", HandleGenerateMapConsoleCommand);
121
117 AddHandlers(); 122 AddHandlers();
118 } 123 }
119 } 124 }
@@ -1255,6 +1260,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1255 m_scene.RegionInfo.RegionName, exportPath); 1260 m_scene.RegionInfo.RegionName, exportPath);
1256 } 1261 }
1257 1262
1263 public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams)
1264 {
1265 Scene consoleScene = m_scene.ConsoleScene();
1266
1267 if (consoleScene != null && consoleScene != m_scene)
1268 return;
1269
1270 GenerateMaptile();
1271 }
1272
1258 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) 1273 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
1259 { 1274 {
1260 uint xstart = 0; 1275 uint xstart = 0;
@@ -1486,62 +1501,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1486 1501
1487 private Byte[] GenerateOverlay() 1502 private Byte[] GenerateOverlay()
1488 { 1503 {
1489 Bitmap overlay = new Bitmap(256, 256); 1504 using (Bitmap overlay = new Bitmap(256, 256))
1490
1491 bool[,] saleBitmap = new bool[64, 64];
1492 for (int x = 0 ; x < 64 ; x++)
1493 { 1505 {
1494 for (int y = 0 ; y < 64 ; y++) 1506 bool[,] saleBitmap = new bool[64, 64];
1495 saleBitmap[x, y] = false; 1507 for (int x = 0 ; x < 64 ; x++)
1496 } 1508 {
1497 1509 for (int y = 0 ; y < 64 ; y++)
1498 bool landForSale = false; 1510 saleBitmap[x, y] = false;
1511 }
1499 1512
1500 List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); 1513 bool landForSale = false;
1501 1514
1502 Color background = Color.FromArgb(0, 0, 0, 0); 1515 List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
1503 SolidBrush transparent = new SolidBrush(background);
1504 Graphics g = Graphics.FromImage(overlay);
1505 g.FillRectangle(transparent, 0, 0, 256, 256);
1506 1516
1507 SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); 1517 Color background = Color.FromArgb(0, 0, 0, 0);
1508 1518
1509 foreach (ILandObject land in parcels) 1519 using (Graphics g = Graphics.FromImage(overlay))
1510 {
1511 // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
1512 if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1513 { 1520 {
1514 landForSale = true; 1521 using (SolidBrush transparent = new SolidBrush(background))
1522 g.FillRectangle(transparent, 0, 0, 256, 256);
1515 1523
1516 saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
1517 }
1518 }
1519 1524
1520 if (!landForSale) 1525 foreach (ILandObject land in parcels)
1521 { 1526 {
1522 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName); 1527 // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
1523 return null; 1528 if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1524 } 1529 {
1530 landForSale = true;
1531
1532 saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
1533 }
1534 }
1535
1536 if (!landForSale)
1537 {
1538 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
1539 return null;
1540 }
1525 1541
1526 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); 1542 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
1527 1543
1528 for (int x = 0 ; x < 64 ; x++) 1544 using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
1529 { 1545 {
1530 for (int y = 0 ; y < 64 ; y++) 1546 for (int x = 0 ; x < 64 ; x++)
1547 {
1548 for (int y = 0 ; y < 64 ; y++)
1549 {
1550 if (saleBitmap[x, y])
1551 g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
1552 }
1553 }
1554 }
1555 }
1556
1557 try
1531 { 1558 {
1532 if (saleBitmap[x, y]) 1559 return OpenJPEG.EncodeFromImage(overlay, true);
1533 g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); 1560 }
1561 catch (Exception e)
1562 {
1563 m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
1534 } 1564 }
1535 } 1565 }
1536 1566
1537 try
1538 {
1539 return OpenJPEG.EncodeFromImage(overlay, true);
1540 }
1541 catch (Exception e)
1542 {
1543 m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
1544 }
1545 return null; 1567 return null;
1546 } 1568 }
1547 } 1569 }