diff options
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 121 |
1 files changed, 51 insertions, 70 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 4e11150..bbb0176 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -865,86 +865,67 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
865 | 865 | ||
866 | lock (m_landIDList) | 866 | lock (m_landIDList) |
867 | { | 867 | { |
868 | try | 868 | int landID = m_landIDList[x / LandUnit, y / LandUnit]; |
869 | if (landID == 0) | ||
869 | { | 870 | { |
870 | int landID = m_landIDList[x / LandUnit, y / LandUnit]; | 871 | // Zero is the uninitialized value saying there is no parcel for this location. |
871 | if (landID == 0) | 872 | // This sometimes happens when terrain is resized. |
873 | if (m_landList.Count == 1) | ||
872 | { | 874 | { |
873 | // Zero is the uninitialized value saying there is no parcel for this location. | 875 | m_log.DebugFormat( |
874 | // This sometimes happens when terrain is resized. | 876 | "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}", |
875 | if (m_landList.Count == 1) | 877 | LogHeader, x, y, m_scene.Name); |
876 | { | ||
877 | m_log.DebugFormat( | ||
878 | "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}", | ||
879 | LogHeader, x, y, m_scene.Name); | ||
880 | 878 | ||
881 | int onlyParcelID = 0; | 879 | int onlyParcelID = 0; |
882 | ILandObject onlyLandObject = null; | 880 | ILandObject onlyLandObject = null; |
883 | foreach (KeyValuePair<int, ILandObject> kvp in m_landList) | 881 | foreach (KeyValuePair<int, ILandObject> kvp in m_landList) |
884 | { | ||
885 | onlyParcelID = kvp.Key; | ||
886 | onlyLandObject = kvp.Value; | ||
887 | break; | ||
888 | } | ||
889 | |||
890 | // There is only one parcel. Grow it to fill all the unallocated spaces. | ||
891 | for (int xx = 0; xx < m_landIDList.GetLength(0); xx++) | ||
892 | for (int yy = 0; yy < m_landIDList.GetLength(1); yy++) | ||
893 | if (m_landIDList[xx, yy] == 0) | ||
894 | m_landIDList[xx, yy] = onlyParcelID; | ||
895 | |||
896 | onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID); | ||
897 | landID = onlyParcelID; | ||
898 | } | ||
899 | else if (m_landList.Count > 1) | ||
900 | { | 882 | { |
901 | m_log.DebugFormat( | 883 | onlyParcelID = kvp.Key; |
902 | "[{0}]: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}", | 884 | onlyLandObject = kvp.Value; |
903 | LogHeader, x, y, m_scene.Name); | 885 | break; |
904 | |||
905 | // There are several other parcels so we must create a new one for the unassigned space | ||
906 | ILandObject newLand = new LandObject(UUID.Zero, false, m_scene); | ||
907 | // Claim all the unclaimed "0" ids | ||
908 | newLand.SetLandBitmap(CreateBitmapForID(0)); | ||
909 | newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | ||
910 | newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | ||
911 | newLand = AddLandObject(newLand); | ||
912 | |||
913 | if (newLand == null) | ||
914 | return null; | ||
915 | |||
916 | landID = m_lastLandLocalID; | ||
917 | } | 886 | } |
918 | else | ||
919 | { | ||
920 | // XXX: We're not currently doing anything if there are no parcels, as this might indicate a race | ||
921 | // condition where this method is being called before land data is loaded. May need to address | ||
922 | // this in another way. | ||
923 | 887 | ||
924 | m_log.WarnFormat( | 888 | // There is only one parcel. Grow it to fill all the unallocated spaces. |
925 | "[{0}]: Ignoring request to auto-create parcel in {1} as there are no other parcels present", | 889 | for (int xx = 0; xx < m_landIDList.GetLength(0); xx++) |
926 | LogHeader, m_scene.Name); | 890 | for (int yy = 0; yy < m_landIDList.GetLength(1); yy++) |
927 | } | 891 | if (m_landIDList[xx, yy] == 0) |
928 | } | 892 | m_landIDList[xx, yy] = onlyParcelID; |
929 | 893 | ||
930 | ret = m_landList[landID]; | 894 | onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID); |
931 | } | 895 | landID = onlyParcelID; |
932 | catch (IndexOutOfRangeException) | 896 | } |
933 | { | 897 | else if (m_landList.Count > 1) |
934 | m_log.ErrorFormat( | 898 | { |
935 | "{0} GetLandObject: Tried to retrieve land object from out of bounds co-ordinate ({1},{2}) in {3}. landListSize=({4},{5})", | 899 | m_log.DebugFormat( |
936 | LogHeader, x, y, m_scene.RegionInfo.RegionName, m_landIDList.GetLength(0), m_landIDList.GetLength(1)); | 900 | "[{0}]: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}", |
901 | LogHeader, x, y, m_scene.Name); | ||
902 | |||
903 | // There are several other parcels so we must create a new one for the unassigned space | ||
904 | ILandObject newLand = new LandObject(UUID.Zero, false, m_scene); | ||
905 | // Claim all the unclaimed "0" ids | ||
906 | newLand.SetLandBitmap(CreateBitmapForID(0)); | ||
907 | newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | ||
908 | newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | ||
909 | newLand = AddLandObject(newLand); | ||
910 | |||
911 | if (newLand == null) | ||
912 | return null; | ||
913 | |||
914 | landID = m_lastLandLocalID; | ||
915 | } | ||
916 | else | ||
917 | { | ||
918 | // XXX: We're not currently doing anything if there are no parcels, as this might indicate a race | ||
919 | // condition where this method is being called before land data is loaded. May need to address | ||
920 | // this in another way. | ||
937 | 921 | ||
938 | return null; | 922 | m_log.WarnFormat( |
923 | "[{0}]: Ignoring request to auto-create parcel in {1} as there are no other parcels present", | ||
924 | LogHeader, m_scene.Name); | ||
925 | } | ||
939 | } | 926 | } |
940 | catch | ||
941 | { | ||
942 | m_log.ErrorFormat( | ||
943 | "{0} GetLandObject: LandID not in landlist. XY=<{1},{2}> in {3}. landID[x,y]={4}", | ||
944 | LogHeader, x, y, m_scene.RegionInfo.RegionName, m_landIDList[x/LandUnit, y/LandUnit]); | ||
945 | 927 | ||
946 | return null; | 928 | ret = m_landList[landID]; |
947 | } | ||
948 | } | 929 | } |
949 | 930 | ||
950 | return ret; | 931 | return ret; |