Fix bug where setting a parcel in a varregion for sale would make sale bitmap generation in WorldMapModule throw an exception on next startup.

This commit replaces the hardcoded region sizes in WorldMapModule.GenerateOverlay() with numbers pulled from m_scene.RegionInfo
bullet-2.82
Justin Clark-Casey (justincc) 2014-05-30 19:38:10 +01:00
parent 1efaf0c85c
commit 8656b5e948
2 changed files with 42 additions and 10 deletions

View File

@ -147,8 +147,29 @@ namespace OpenSim.Framework
public uint WorldLocX = 0; public uint WorldLocX = 0;
public uint WorldLocY = 0; public uint WorldLocY = 0;
public uint WorldLocZ = 0; public uint WorldLocZ = 0;
/// <summary>
/// X dimension of the region.
/// </summary>
/// <remarks>
/// If this is a varregion then the default size set here will be replaced when we load the region config.
/// </remarks>
public uint RegionSizeX = Constants.RegionSize; public uint RegionSizeX = Constants.RegionSize;
/// <summary>
/// X dimension of the region.
/// </summary>
/// <remarks>
/// If this is a varregion then the default size set here will be replaced when we load the region config.
/// </remarks>
public uint RegionSizeY = Constants.RegionSize; public uint RegionSizeY = Constants.RegionSize;
/// <summary>
/// Z dimension of the region.
/// </summary>
/// <remarks>
/// XXX: Unknown if this accounts for regions with negative Z.
/// </remarks>
public uint RegionSizeZ = Constants.RegionHeight; public uint RegionSizeZ = Constants.RegionHeight;
private Dictionary<String, String> m_extraSettings = new Dictionary<string, string>(); private Dictionary<String, String> m_extraSettings = new Dictionary<string, string>();

View File

@ -1578,12 +1578,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private Byte[] GenerateOverlay() private Byte[] GenerateOverlay()
{ {
using (Bitmap overlay = new Bitmap(256, 256)) // 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 regionLandTilesY = regionSizeY / landTileSize;
using (Bitmap overlay = new Bitmap(regionSizeX, regionSizeY))
{ {
bool[,] saleBitmap = new bool[64, 64]; bool[,] saleBitmap = new bool[regionLandTilesX, regionLandTilesY];
for (int x = 0 ; x < 64 ; x++) for (int x = 0; x < regionLandTilesX; x++)
{ {
for (int y = 0 ; y < 64 ; y++) for (int y = 0; y < regionLandTilesY; y++)
saleBitmap[x, y] = false; saleBitmap[x, y] = false;
} }
@ -1596,8 +1604,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
using (Graphics g = Graphics.FromImage(overlay)) using (Graphics g = Graphics.FromImage(overlay))
{ {
using (SolidBrush transparent = new SolidBrush(background)) using (SolidBrush transparent = new SolidBrush(background))
g.FillRectangle(transparent, 0, 0, 256, 256); g.FillRectangle(transparent, 0, 0, regionSizeX, regionSizeY);
foreach (ILandObject land in parcels) foreach (ILandObject land in parcels)
{ {
@ -1620,12 +1627,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9))) using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
{ {
for (int x = 0 ; x < 64 ; x++) for (int x = 0 ; x < regionLandTilesX ; x++)
{ {
for (int y = 0 ; y < 64 ; y++) for (int y = 0 ; y < regionLandTilesY ; y++)
{ {
if (saleBitmap[x, y]) if (saleBitmap[x, y])
g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); g.FillRectangle(
yellow, x * landTileSize,
regionSizeX - landTileSize - (y * landTileSize),
landTileSize,
landTileSize);
} }
} }
} }
@ -1654,4 +1665,4 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public uint itemtype; public uint itemtype;
public ulong regionhandle; public ulong regionhandle;
} }
} }