From dc633ee768635799d5b0bf5e2ada79e692a7144e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 29 Jan 2019 21:16:28 +0000 Subject: cosmetics --- .../Framework/DoubleDictionaryThreadAbortSafe.cs | 36 ++++++++++++++++------ .../CoreModules/World/Land/LandManagementModule.cs | 2 +- .../Region/CoreModules/World/Land/LandObject.cs | 18 ++++------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs index 73d0d20..ec26b43 100644 --- a/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs +++ b/OpenSim/Framework/DoubleDictionaryThreadAbortSafe.cs @@ -477,30 +477,48 @@ namespace OpenSim.Framework public TValue[] GetArray() { - TValue[] ret = new TValue[0]; - bool gotLock = false; + bool gotupLock = false; try { try { } finally { - rwLock.EnterWriteLock(); - gotLock = true; + rwLock.EnterUpgradeableReadLock(); + gotupLock = true; + } - if (m_array == null) + if (m_array == null) + { + bool gotwritelock = false; + try { + try { } + finally + { + rwLock.EnterWriteLock(); + gotwritelock = true; + } + m_array = new TValue[Dictionary1.Count]; Dictionary1.Values.CopyTo(m_array, 0); } - ret = m_array; + finally + { + if (gotwritelock) + rwLock.ExitWriteLock(); + } } + return m_array; + } + catch + { + return new TValue[0]; } finally { - if (gotLock) - rwLock.ExitWriteLock(); + if (gotupLock) + rwLock.ExitUpgradeableReadLock(); } - return ret; } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index ae7885b..8c327d8 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -1939,7 +1939,7 @@ namespace OpenSim.Region.CoreModules.World.Land m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID); } - return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); + return LLSDxmlEncode.LLSDEmpty; } // we cheat here: As we don't have (and want) a grid-global parcel-store, we can't return the // "real" parcelID, because we wouldn't be able to map that to the region the parcel belongs to. diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 88ca0c6..26500ab 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -1145,9 +1145,7 @@ namespace OpenSim.Region.CoreModules.World.Land public bool[,] MergeLandBitmaps(bool[,] bitmap_base, bool[,] bitmap_add) { if (bitmap_base.GetLength(0) != bitmap_add.GetLength(0) - || bitmap_base.GetLength(1) != bitmap_add.GetLength(1) - || bitmap_add.Rank != 2 - || bitmap_base.Rank != 2) + || bitmap_base.GetLength(1) != bitmap_add.GetLength(1)) { throw new Exception( String.Format("{0} MergeLandBitmaps. merging maps not same size. baseSizeXY=<{1},{2}>, addSizeXY=<{3},{4}>", @@ -1155,15 +1153,11 @@ namespace OpenSim.Region.CoreModules.World.Land ); } - int x, y; - for (y = 0; y < bitmap_base.GetLength(1); y++) + for (int x = 0; x < bitmap_add.GetLength(0); x++) { - for (x = 0; x < bitmap_add.GetLength(0); x++) + for (int y = 0; y < bitmap_base.GetLength(1); y++) { - if (bitmap_add[x, y]) - { - bitmap_base[x, y] = true; - } + bitmap_base[x, y] |= bitmap_add[x, y]; } } return bitmap_base; @@ -1357,9 +1351,9 @@ namespace OpenSim.Region.CoreModules.World.Land int maxX = 0; int maxY = 0; - for (int y = 0; y < baseY; y++) + for (int x = 0; x < baseX; x++) { - for (int x = 0; x < baseX; x++) + for (int y = 0; y < baseY; y++) { if (bitmap_new[x, y]) bitmap_base[x, y] = false; if (bitmap_base[x, y]) -- cgit v1.1