dont create terrain map asset for V1 viewers on large regions again, but do create parcel overlay since current viewers seem to use it (or we are missing something elsewhere)
parent
6bca0c9c9c
commit
f4093a04e7
|
@ -1531,12 +1531,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
|
||||
using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile())
|
||||
{
|
||||
// V1 (This Module)
|
||||
// if(m_scene.RegionInfo.RegionSizeX <= Constants.RegionSize &&
|
||||
// m_scene.RegionInfo.RegionSizeY <= Constants.RegionSize)
|
||||
GenerateMaptile(mapbmp);
|
||||
|
||||
// v2/3 (MapImageServiceModule)
|
||||
if (m_mapImageServiceModule != null)
|
||||
m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp);
|
||||
}
|
||||
|
@ -1544,22 +1540,39 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
|
||||
private void GenerateMaptile(Bitmap mapbmp)
|
||||
{
|
||||
byte[] data;
|
||||
bool needRegionSave = false;
|
||||
|
||||
// remove old assets
|
||||
UUID lastID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
|
||||
if (lastID != UUID.Zero)
|
||||
{
|
||||
m_scene.AssetService.Delete(lastID.ToString());
|
||||
m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Zero;
|
||||
needRegionSave = true;
|
||||
}
|
||||
|
||||
lastID = m_scene.RegionInfo.RegionSettings.ParcelImageID;
|
||||
if (lastID != UUID.Zero)
|
||||
{
|
||||
m_scene.AssetService.Delete(lastID.ToString());
|
||||
m_scene.RegionInfo.RegionSettings.ParcelImageID = UUID.Zero;
|
||||
needRegionSave = true;
|
||||
}
|
||||
|
||||
// bypass terrain image for large regions since only V2 viewers work with them
|
||||
if (m_scene.RegionInfo.RegionSizeX <= Constants.RegionSize &&
|
||||
m_scene.RegionInfo.RegionSizeY <= Constants.RegionSize
|
||||
&& mapbmp != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] data;
|
||||
|
||||
data = OpenJPEG.EncodeFromImage(mapbmp, true);
|
||||
}
|
||||
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
||||
|
||||
if (data != null && data.Length > 0)
|
||||
{
|
||||
m_log.Error("[WORLD MAP]: Failed generating terrain map: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] overlay = GenerateOverlay();
|
||||
|
||||
UUID terrainImageID = UUID.Random();
|
||||
UUID parcelImageID = UUID.Zero;
|
||||
|
||||
AssetBase asset = new AssetBase(
|
||||
terrainImageID,
|
||||
|
@ -1576,9 +1589,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
|
||||
m_scene.AssetService.Store(asset);
|
||||
|
||||
m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID;
|
||||
needRegionSave = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[WORLD MAP]: Failed generating terrain map: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
// V2/3 still seem to need this, or we are missing something somewhere
|
||||
byte[] overlay = GenerateOverlay();
|
||||
if (overlay != null)
|
||||
{
|
||||
parcelImageID = UUID.Random();
|
||||
UUID parcelImageID = UUID.Random();
|
||||
|
||||
AssetBase parcels = new AssetBase(
|
||||
parcelImageID,
|
||||
|
@ -1591,20 +1616,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
parcels.Flags = AssetFlags.Maptile;
|
||||
|
||||
m_scene.AssetService.Store(parcels);
|
||||
|
||||
m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID;
|
||||
needRegionSave = true;
|
||||
}
|
||||
|
||||
// Switch to the new one
|
||||
UUID lastTerrainImageID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
|
||||
UUID lastParcelImageID = m_scene.RegionInfo.RegionSettings.ParcelImageID;
|
||||
m_scene.RegionInfo.RegionSettings.TerrainImageID = terrainImageID;
|
||||
m_scene.RegionInfo.RegionSettings.ParcelImageID = parcelImageID;
|
||||
if (needRegionSave)
|
||||
m_scene.RegionInfo.RegionSettings.Save();
|
||||
|
||||
// Delete the old one
|
||||
// m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastTerrainImageID);
|
||||
m_scene.AssetService.Delete(lastTerrainImageID.ToString());
|
||||
if (lastParcelImageID != UUID.Zero)
|
||||
m_scene.AssetService.Delete(lastParcelImageID.ToString());
|
||||
}
|
||||
|
||||
private void MakeRootAgent(ScenePresence avatar)
|
||||
|
@ -1658,42 +1676,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
|
||||
private Byte[] GenerateOverlay()
|
||||
{
|
||||
int landTileSize = LandManagementModule.LandUnit;
|
||||
|
||||
// These need to be ints for bitmap generation
|
||||
int regionSizeX = (int)m_scene.RegionInfo.RegionSizeX;
|
||||
int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY;
|
||||
|
||||
int landTileSize = LandManagementModule.LandUnit;
|
||||
int regionLandTilesX = regionSizeX / landTileSize;
|
||||
|
||||
int regionSizeY = (int)m_scene.RegionInfo.RegionSizeY;
|
||||
int regionLandTilesY = regionSizeY / landTileSize;
|
||||
|
||||
using (Bitmap overlay = new Bitmap(regionSizeX, regionSizeY))
|
||||
{
|
||||
bool[,] saleBitmap = new bool[regionLandTilesX, regionLandTilesY];
|
||||
for (int x = 0; x < regionLandTilesX; x++)
|
||||
{
|
||||
for (int y = 0; y < regionLandTilesY; y++)
|
||||
saleBitmap[x, y] = false;
|
||||
}
|
||||
|
||||
bool landForSale = false;
|
||||
ILandObject land;
|
||||
|
||||
List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
|
||||
// scan terrain avoiding potencial merges of large bitmaps
|
||||
//TODO create the sell bitmap at landchannel / landmaster ?
|
||||
// and auction also, still not suported
|
||||
|
||||
Color background = Color.FromArgb(0, 0, 0, 0);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(overlay))
|
||||
bool[,] saleBitmap = new bool[regionLandTilesX, regionLandTilesY];
|
||||
for (int x = 0, xx = 0; x < regionLandTilesX; x++ ,xx += landTileSize)
|
||||
{
|
||||
using (SolidBrush transparent = new SolidBrush(background))
|
||||
g.FillRectangle(transparent, 0, 0, regionSizeX, regionSizeY);
|
||||
|
||||
foreach (ILandObject land in parcels)
|
||||
for (int y = 0, yy = 0; y < regionLandTilesY; y++, yy += landTileSize)
|
||||
{
|
||||
// m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
|
||||
if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
|
||||
land = m_scene.LandChannel.GetLandObject(xx, yy);
|
||||
if (land != null && (land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
|
||||
{
|
||||
saleBitmap[x, y] = true;
|
||||
landForSale = true;
|
||||
|
||||
saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
|
||||
}
|
||||
else
|
||||
saleBitmap[x, y] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1705,7 +1716,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
|
||||
m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
|
||||
|
||||
using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
|
||||
using (Bitmap overlay = new Bitmap(regionSizeX, regionSizeY))
|
||||
{
|
||||
Color background = Color.FromArgb(0, 0, 0, 0);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(overlay))
|
||||
{
|
||||
using (SolidBrush transparent = new SolidBrush(background))
|
||||
g.FillRectangle(transparent, 0, 0, regionSizeX, regionSizeY);
|
||||
|
||||
// make it a half transparent
|
||||
using (SolidBrush yellow = new SolidBrush(Color.FromArgb(100, 249, 223, 9)))
|
||||
{
|
||||
for (int x = 0; x < regionLandTilesX; x++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue