diff options
author | UbitUmarov | 2015-08-24 17:05:16 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-24 17:05:16 +0100 |
commit | 3829df10595911de9ed1ce2f7b6cdd205828f8d0 (patch) | |
tree | d95d15c35695f6fa4dc4a6623294b307a7aee493 /OpenSim/Region/CoreModules/World/Land | |
parent | rename ImapTileModule as IMAPImageUploadModule to match core (diff) | |
download | opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.zip opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.tar.gz opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.tar.bz2 opensim-SC_OLD-3829df10595911de9ed1ce2f7b6cdd205828f8d0.tar.xz |
try to implement core load oar options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 198 |
1 files changed, 125 insertions, 73 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 4aee6a5..83bbf79 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -570,17 +570,54 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
570 | new_land.LandData.LocalID = newLandLocalID; | 570 | new_land.LandData.LocalID = newLandLocalID; |
571 | 571 | ||
572 | bool[,] landBitmap = new_land.GetLandBitmap(); | 572 | bool[,] landBitmap = new_land.GetLandBitmap(); |
573 | for (int x = 0; x < landBitmap.GetLength(0); x++) | 573 | if (landBitmap.GetLength(0) != m_landIDList.GetLength(0) || landBitmap.GetLength(1) != m_landIDList.GetLength(1)) |
574 | { | 574 | { |
575 | for (int y = 0; y < landBitmap.GetLength(1); y++) | 575 | // Going to variable sized regions can cause mismatches |
576 | m_log.ErrorFormat("{0} AddLandObject. Added land bitmap different size than region ID map. bitmapSize=({1},{2}), landIDSize=({3},{4})", | ||
577 | LogHeader, landBitmap.GetLength(0), landBitmap.GetLength(1), m_landIDList.GetLength(0), m_landIDList.GetLength(1)); | ||
578 | } | ||
579 | else | ||
580 | { | ||
581 | // If other land objects still believe that they occupy any parts of the same space, | ||
582 | // then do not allow the add to proceed. | ||
583 | for (int x = 0; x < landBitmap.GetLength(0); x++) | ||
584 | { | ||
585 | for (int y = 0; y < landBitmap.GetLength(1); y++) | ||
586 | { | ||
587 | if (landBitmap[x, y]) | ||
588 | { | ||
589 | int lastRecordedLandId = m_landIDList[x, y]; | ||
590 | |||
591 | if (lastRecordedLandId > 0) | ||
592 | { | ||
593 | ILandObject lastRecordedLo = m_landList[lastRecordedLandId]; | ||
594 | |||
595 | if (lastRecordedLo.LandBitmap[x, y]) | ||
596 | { | ||
597 | m_log.ErrorFormat( | ||
598 | "{0}: Cannot add parcel \"{1}\", local ID {2} at tile {3},{4} because this is still occupied by parcel \"{5}\", local ID {6} in {7}", | ||
599 | LogHeader, new_land.LandData.Name, new_land.LandData.LocalID, x, y, | ||
600 | lastRecordedLo.LandData.Name, lastRecordedLo.LandData.LocalID, m_scene.Name); | ||
601 | |||
602 | return null; | ||
603 | } | ||
604 | } | ||
605 | } | ||
606 | } | ||
607 | } | ||
608 | |||
609 | for (int x = 0; x < landBitmap.GetLength(0); x++) | ||
576 | { | 610 | { |
577 | if (landBitmap[x, y]) | 611 | for (int y = 0; y < landBitmap.GetLength(1); y++) |
578 | { | 612 | { |
579 | // m_log.DebugFormat( | 613 | if (landBitmap[x, y]) |
580 | // "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}", | 614 | { |
581 | // new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName); | 615 | // m_log.DebugFormat( |
582 | 616 | // "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}", | |
583 | m_landIDList[x, y] = newLandLocalID; | 617 | // new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName); |
618 | |||
619 | m_landIDList[x, y] = newLandLocalID; | ||
620 | } | ||
584 | } | 621 | } |
585 | } | 622 | } |
586 | } | 623 | } |
@@ -693,47 +730,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
693 | /// <returns>Land object at the point supplied</returns> | 730 | /// <returns>Land object at the point supplied</returns> |
694 | public ILandObject GetLandObject(float x_float, float y_float) | 731 | public ILandObject GetLandObject(float x_float, float y_float) |
695 | { | 732 | { |
696 | int x; | 733 | return GetLandObject((int)x_float, (int)y_float, true); |
697 | int y; | ||
698 | |||
699 | if (x_float >= m_scene.RegionInfo.RegionSizeX || x_float < 0 || y_float >= m_scene.RegionInfo.RegionSizeX || y_float < 0) | ||
700 | return null; | ||
701 | |||
702 | try | ||
703 | { | ||
704 | x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / (float)landUnit)); | ||
705 | y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / (float)landUnit)); | ||
706 | } | ||
707 | catch (OverflowException) | ||
708 | { | ||
709 | return null; | ||
710 | } | ||
711 | |||
712 | if (x >= (m_scene.RegionInfo.RegionSizeX / landUnit) | ||
713 | || y >= (m_scene.RegionInfo.RegionSizeY / landUnit) | ||
714 | || x < 0 | ||
715 | || y < 0) | ||
716 | { | ||
717 | return null; | ||
718 | } | ||
719 | |||
720 | lock (m_landList) | ||
721 | { | ||
722 | // Corner case. If an autoreturn happens during sim startup | ||
723 | // we will come here with the list uninitialized | ||
724 | // | ||
725 | // int landId = m_landIDList[x, y]; | ||
726 | |||
727 | // if (landId == 0) | ||
728 | // m_log.DebugFormat( | ||
729 | // "[LAND MANAGEMENT MODULE]: No land object found at ({0}, {1}) on {2}", | ||
730 | // x, y, m_scene.RegionInfo.RegionName); | ||
731 | |||
732 | if (m_landList.ContainsKey(m_landIDList[x, y])) | ||
733 | return m_landList[m_landIDList[x, y]]; | ||
734 | |||
735 | return null; | ||
736 | } | ||
737 | } | 734 | } |
738 | 735 | ||
739 | // if x,y is off region this will return the parcel at cliped x,y | 736 | // if x,y is off region this will return the parcel at cliped x,y |
@@ -768,29 +765,47 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
768 | 765 | ||
769 | public ILandObject GetLandObject(int x, int y) | 766 | public ILandObject GetLandObject(int x, int y) |
770 | { | 767 | { |
768 | return GetLandObject(x, y, false /* returnNullIfLandObjectNotFound */); | ||
769 | } | ||
770 | |||
771 | public ILandObject GetLandObject(int x, int y, bool returnNullIfLandObjectOutsideBounds) | ||
772 | { | ||
771 | if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0) | 773 | if (x >= m_scene.RegionInfo.RegionSizeX || y >= m_scene.RegionInfo.RegionSizeY || x < 0 || y < 0) |
772 | { | 774 | { |
773 | // These exceptions here will cause a lot of complaints from the users specifically because | 775 | // These exceptions here will cause a lot of complaints from the users specifically because |
774 | // they happen every time at border crossings | 776 | // they happen every time at border crossings |
775 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | 777 | if (returnNullIfLandObjectOutsideBounds) |
778 | return null; | ||
779 | else | ||
780 | throw new Exception("Error: Parcel not found at point " + x + ", " + y); | ||
776 | } | 781 | } |
777 | 782 | ||
778 | lock (m_landIDList) | 783 | lock (m_landIDList) |
779 | { | 784 | { |
780 | try | 785 | try |
781 | { | 786 | { |
782 | //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4])) | ||
783 | return m_landList[m_landIDList[x / 4, y / 4]]; | 787 | return m_landList[m_landIDList[x / 4, y / 4]]; |
784 | //else | ||
785 | // return null; | ||
786 | } | 788 | } |
787 | catch (IndexOutOfRangeException) | 789 | catch (IndexOutOfRangeException) |
788 | { | 790 | { |
789 | return null; | 791 | return null; |
790 | } | 792 | } |
791 | } | 793 | } |
792 | } | 794 | } |
793 | 795 | ||
796 | // Create a 'parcel is here' bitmap for the parcel identified by the passed landID | ||
797 | private bool[,] CreateBitmapForID(int landID) | ||
798 | { | ||
799 | bool[,] ret = new bool[m_landIDList.GetLength(0), m_landIDList.GetLength(1)]; | ||
800 | |||
801 | for (int xx = 0; xx < m_landIDList.GetLength(0); xx++) | ||
802 | for (int yy = 0; yy < m_landIDList.GetLength(0); yy++) | ||
803 | if (m_landIDList[xx, yy] == landID) | ||
804 | ret[xx, yy] = true; | ||
805 | |||
806 | return ret; | ||
807 | } | ||
808 | |||
794 | #endregion | 809 | #endregion |
795 | 810 | ||
796 | #region Parcel Modification | 811 | #region Parcel Modification |
@@ -1432,29 +1447,66 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1432 | 1447 | ||
1433 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) | 1448 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) |
1434 | { | 1449 | { |
1435 | Dictionary<int, ILandObject> landworkList; | ||
1436 | // move to work pointer since we are deleting it all | ||
1437 | lock (m_landList) | 1450 | lock (m_landList) |
1438 | { | 1451 | { |
1439 | landworkList = m_landList; | 1452 | for (int i = 0; i < data.Count; i++) |
1440 | m_landList = new Dictionary<int, ILandObject>(); | 1453 | IncomingLandObjectFromStorage(data[i]); |
1441 | } | ||
1442 | 1454 | ||
1443 | //Remove all the land objects in the sim and then process our new data | 1455 | // Layer data is in landUnit (4m) chunks |
1444 | foreach (int n in landworkList.Keys) | 1456 | for (int y = 0; y < m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / landUnit); y++) |
1445 | { | 1457 | { |
1446 | m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID); | 1458 | for (int x = 0; x < m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize * (Constants.TerrainPatchSize / landUnit); x++) |
1447 | } | 1459 | { |
1448 | landworkList.Clear(); | 1460 | if (m_landIDList[x, y] == 0) |
1461 | { | ||
1462 | if (m_landList.Count == 1) | ||
1463 | { | ||
1464 | m_log.DebugFormat( | ||
1465 | "[{0}]: Auto-extending land parcel as landID at {1},{2} is 0 and only one land parcel is present in {3}", | ||
1466 | LogHeader, x, y, m_scene.Name); | ||
1449 | 1467 | ||
1450 | lock (m_landList) | 1468 | int onlyParcelID = 0; |
1451 | { | 1469 | ILandObject onlyLandObject = null; |
1452 | m_landIDList.Initialize(); | 1470 | foreach (KeyValuePair<int, ILandObject> kvp in m_landList) |
1453 | m_landList.Clear(); | 1471 | { |
1454 | } | 1472 | onlyParcelID = kvp.Key; |
1473 | onlyLandObject = kvp.Value; | ||
1474 | break; | ||
1475 | } | ||
1455 | 1476 | ||
1456 | for (int i = 0; i < data.Count; i++) | 1477 | // There is only one parcel. Grow it to fill all the unallocated spaces. |
1457 | IncomingLandObjectFromStorage(data[i]); | 1478 | for (int xx = 0; xx < m_landIDList.GetLength(0); xx++) |
1479 | for (int yy = 0; yy < m_landIDList.GetLength(1); yy++) | ||
1480 | if (m_landIDList[xx, yy] == 0) | ||
1481 | m_landIDList[xx, yy] = onlyParcelID; | ||
1482 | |||
1483 | onlyLandObject.LandBitmap = CreateBitmapForID(onlyParcelID); | ||
1484 | } | ||
1485 | else if (m_landList.Count > 1) | ||
1486 | { | ||
1487 | m_log.DebugFormat( | ||
1488 | "{0}: Auto-creating land parcel as landID at {1},{2} is 0 and more than one land parcel is present in {3}", | ||
1489 | LogHeader, x, y, m_scene.Name); | ||
1490 | |||
1491 | // There are several other parcels so we must create a new one for the unassigned space | ||
1492 | ILandObject newLand = new LandObject(UUID.Zero, false, m_scene); | ||
1493 | // Claim all the unclaimed "0" ids | ||
1494 | newLand.SetLandBitmap(CreateBitmapForID(0)); | ||
1495 | newLand.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | ||
1496 | newLand.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); | ||
1497 | newLand = AddLandObject(newLand); | ||
1498 | } | ||
1499 | else | ||
1500 | { | ||
1501 | // We should never reach this point as the separate code path when no land data exists should have fired instead. | ||
1502 | m_log.WarnFormat( | ||
1503 | "{0}: Ignoring request to auto-create parcel in {1} as there are no other parcels present", | ||
1504 | LogHeader, m_scene.Name); | ||
1505 | } | ||
1506 | } | ||
1507 | } | ||
1508 | } | ||
1509 | } | ||
1458 | } | 1510 | } |
1459 | 1511 | ||
1460 | public void IncomingLandObjectFromStorage(LandData data) | 1512 | public void IncomingLandObjectFromStorage(LandData data) |
@@ -1464,7 +1516,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1464 | new_land.LandData = data.Copy(); | 1516 | new_land.LandData = data.Copy(); |
1465 | new_land.SetLandBitmapFromByteArray(); | 1517 | new_land.SetLandBitmapFromByteArray(); |
1466 | AddLandObject(new_land); | 1518 | AddLandObject(new_land); |
1467 | new_land.SendLandUpdateToAvatarsOverMe(); | 1519 | // new_land.SendLandUpdateToAvatarsOverMe(); |
1468 | } | 1520 | } |
1469 | 1521 | ||
1470 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) | 1522 | public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) |