aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Land/LandObject.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandObject.cs227
1 files changed, 106 insertions, 121 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
index 693c55d..368e113 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
@@ -33,7 +33,6 @@ using libsecondlife.Packets;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Modules.World.Land;
37using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
38 37
39namespace OpenSim.Region.Environment.Modules.World.Land 38namespace OpenSim.Region.Environment.Modules.World.Land
@@ -46,23 +45,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
46 #region Member Variables 45 #region Member Variables
47 46
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private bool[,] m_landBitmap = new bool[64,64];
49 49
50 protected LandData m_landData = new LandData(); 50 protected LandData m_landData = new LandData();
51 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
52 protected Scene m_scene; 51 protected Scene m_scene;
53 52 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
54 private bool[,] m_landBitmap = new bool[64,64];
55 53
56 public bool[,] landBitmap 54 public bool[,] landBitmap
57 { 55 {
58 get 56 get { return m_landBitmap; }
59 { 57 set { m_landBitmap = value; }
60 return m_landBitmap;
61 }
62 set
63 {
64 m_landBitmap = value;
65 }
66 } 58 }
67 59
68 #endregion 60 #endregion
@@ -71,25 +63,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
71 63
72 public LandData landData 64 public LandData landData
73 { 65 {
74 get 66 get { return m_landData; }
75 {
76 return m_landData;
77 }
78 67
79 set 68 set { m_landData = value; }
80 {
81 m_landData = value;
82 }
83 } 69 }
84 70
85 public LLUUID regionUUID 71 public LLUUID regionUUID
86 { 72 {
87 get { return m_scene.RegionInfo.RegionID; } 73 get { return m_scene.RegionInfo.RegionID; }
88 } 74 }
89 75
90 #endregion
91
92
93 #region Constructors 76 #region Constructors
94 77
95 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) 78 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
@@ -115,7 +98,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
115 { 98 {
116 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) 99 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
117 { 100 {
118 return (landBitmap[x/4, y/4] == true); 101 return (landBitmap[x / 4, y / 4] == true);
119 } 102 }
120 else 103 else
121 { 104 {
@@ -149,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
149 { 132 {
150 ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); 133 ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties);
151 // TODO: don't create new blocks if recycling an old packet 134 // TODO: don't create new blocks if recycling an old packet
152 135
153 updatePacket.ParcelData.AABBMax = landData.AABBMax; 136 updatePacket.ParcelData.AABBMax = landData.AABBMax;
154 updatePacket.ParcelData.AABBMin = landData.AABBMin; 137 updatePacket.ParcelData.AABBMin = landData.AABBMin;
155 updatePacket.ParcelData.Area = landData.area; 138 updatePacket.ParcelData.Area = landData.area;
@@ -171,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
171 { 154 {
172 updatePacket.ParcelData.MaxPrims = 155 updatePacket.ParcelData.MaxPrims =
173 Convert.ToInt32( 156 Convert.ToInt32(
174 Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*m_scene.objectCapacity* 157 Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity *
175 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); 158 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor)));
176 } 159 }
177 else 160 else
@@ -193,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
193 updatePacket.ParcelData.PassHours = landData.passHours; 176 updatePacket.ParcelData.PassHours = landData.passHours;
194 updatePacket.ParcelData.PassPrice = landData.passPrice; 177 updatePacket.ParcelData.PassPrice = landData.passPrice;
195 updatePacket.ParcelData.PublicCount = 0; //unemplemented 178 updatePacket.ParcelData.PublicCount = 0; //unemplemented
196 179
197 uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; 180 uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags;
198 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > 181 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) >
199 0); 182 0);
@@ -255,12 +238,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
255 newData.snapshotID = packet.ParcelData.SnapshotID; 238 newData.snapshotID = packet.ParcelData.SnapshotID;
256 newData.userLocation = packet.ParcelData.UserLocation; 239 newData.userLocation = packet.ParcelData.UserLocation;
257 newData.userLookAt = packet.ParcelData.UserLookAt; 240 newData.userLookAt = packet.ParcelData.UserLookAt;
258 241
259 m_scene.LandChannel.updateLandObject(landData.localID, newData); 242 m_scene.LandChannel.updateLandObject(landData.localID, newData);
260 243
261 sendLandUpdateToAvatarsOverMe(); 244 sendLandUpdateToAvatarsOverMe();
262 } 245 }
263 } 246 }
247
264 public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) 248 public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
265 { 249 {
266 LandData newData = landData.Copy(); 250 LandData newData = landData.Copy();
@@ -272,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
272 newData.claimPrice = claimprice; 256 newData.claimPrice = claimprice;
273 newData.salePrice = 0; 257 newData.salePrice = 0;
274 newData.authBuyerID = LLUUID.Zero; 258 newData.authBuyerID = LLUUID.Zero;
275 newData.landFlags &= ~(uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); 259 newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
276 m_scene.LandChannel.updateLandObject(landData.localID, newData); 260 m_scene.LandChannel.updateLandObject(landData.localID, newData);
277 261
278 sendLandUpdateToAvatarsOverMe(); 262 sendLandUpdateToAvatarsOverMe();
@@ -339,12 +323,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
339 try 323 try
340 { 324 {
341 over = 325 over =
342 m_scene.LandChannel.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))), 326 m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))),
343 (int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y)))); 327 (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y))));
344 } 328 }
345 catch (Exception) 329 catch (Exception)
346 { 330 {
347 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y)); 331 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " +
332 Math.Round(avatars[i].AbsolutePosition.Y));
348 } 333 }
349 334
350 if (over != null) 335 if (over != null)
@@ -463,6 +448,25 @@ namespace OpenSim.Region.Environment.Modules.World.Land
463 448
464 #region Update Functions 449 #region Update Functions
465 450
451 public void updateLandBitmapByteArray()
452 {
453 landData.landBitmapByteArray = convertLandBitmapToBytes();
454 }
455
456 /// <summary>
457 /// Update all settings in land such as area, bitmap byte array, etc
458 /// </summary>
459 public void forceUpdateLandInfo()
460 {
461 updateAABBAndAreaValues();
462 updateLandBitmapByteArray();
463 }
464
465 public void setLandBitmapFromByteArray()
466 {
467 landBitmap = convertBytesToLandBitmap();
468 }
469
466 /// <summary> 470 /// <summary>
467 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object 471 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object
468 /// </summary> 472 /// </summary>
@@ -495,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
495 if (ty > 255) 499 if (ty > 255)
496 ty = 255; 500 ty = 255;
497 landData.AABBMin = 501 landData.AABBMin =
498 new LLVector3((float)(min_x * 4), (float)(min_y * 4), 502 new LLVector3((float) (min_x * 4), (float) (min_y * 4),
499 (float)m_scene.Heightmap[tx, ty]); 503 (float) m_scene.Heightmap[tx, ty]);
500 504
501 tx = max_x * 4; 505 tx = max_x * 4;
502 if (tx > 255) 506 if (tx > 255)
@@ -505,30 +509,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
505 if (ty > 255) 509 if (ty > 255)
506 ty = 255; 510 ty = 255;
507 landData.AABBMax = 511 landData.AABBMax =
508 new LLVector3((float)(max_x * 4), (float)(max_y * 4), 512 new LLVector3((float) (max_x * 4), (float) (max_y * 4),
509 (float)m_scene.Heightmap[tx, ty]); 513 (float) m_scene.Heightmap[tx, ty]);
510 landData.area = tempArea; 514 landData.area = tempArea;
511 } 515 }
512 516
513 public void updateLandBitmapByteArray()
514 {
515 landData.landBitmapByteArray = convertLandBitmapToBytes();
516 }
517
518 /// <summary>
519 /// Update all settings in land such as area, bitmap byte array, etc
520 /// </summary>
521 public void forceUpdateLandInfo()
522 {
523 updateAABBAndAreaValues();
524 updateLandBitmapByteArray();
525 }
526
527 public void setLandBitmapFromByteArray()
528 {
529 landBitmap = convertBytesToLandBitmap();
530 }
531
532 #endregion 517 #endregion
533 518
534 #region Land Bitmap Functions 519 #region Land Bitmap Functions
@@ -562,63 +547,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land
562 } 547 }
563 548
564 /// <summary> 549 /// <summary>
565 /// Converts the land bitmap to a packet friendly byte array
566 /// </summary>
567 /// <returns></returns>
568 private byte[] convertLandBitmapToBytes()
569 {
570 byte[] tempConvertArr = new byte[512];
571 byte tempByte = 0;
572 int x, y, i, byteNum = 0;
573 i = 0;
574 for (y = 0; y < 64; y++)
575 {
576 for (x = 0; x < 64; x++)
577 {
578 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8));
579 if (i%8 == 0)
580 {
581 tempConvertArr[byteNum] = tempByte;
582 tempByte = (byte) 0;
583 i = 0;
584 byteNum++;
585 }
586 }
587 }
588 return tempConvertArr;
589 }
590
591 private bool[,] convertBytesToLandBitmap()
592 {
593 bool[,] tempConvertMap = new bool[64,64];
594 tempConvertMap.Initialize();
595 byte tempByte = 0;
596 int x = 0, y = 0, i = 0, bitNum = 0;
597 for (i = 0; i < 512; i++)
598 {
599 tempByte = landData.landBitmapByteArray[i];
600 for (bitNum = 0; bitNum < 8; bitNum++)
601 {
602 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
603 tempConvertMap[x, y] = bit;
604 x++;
605 if (x > 63)
606 {
607 x = 0;
608 y++;
609 }
610 }
611 }
612 return tempConvertMap;
613 }
614
615 /// <summary>
616 /// Full sim land object creation 550 /// Full sim land object creation
617 /// </summary> 551 /// </summary>
618 /// <returns></returns> 552 /// <returns></returns>
619 public bool[,] basicFullRegionLandBitmap() 553 public bool[,] basicFullRegionLandBitmap()
620 { 554 {
621 return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); 555 return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize);
622 } 556 }
623 557
624 /// <summary> 558 /// <summary>
@@ -662,8 +596,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
662 { 596 {
663 for (x = 0; x < 64; x++) 597 for (x = 0; x < 64; x++)
664 { 598 {
665 if (x >= start_x/4 && x < end_x/4 599 if (x >= start_x / 4 && x < end_x / 4
666 && y >= start_y/4 && y < end_y/4) 600 && y >= start_y / 4 && y < end_y / 4)
667 { 601 {
668 land_bitmap[x, y] = set_value; 602 land_bitmap[x, y] = set_value;
669 } 603 }
@@ -705,6 +639,57 @@ namespace OpenSim.Region.Environment.Modules.World.Land
705 return bitmap_base; 639 return bitmap_base;
706 } 640 }
707 641
642 /// <summary>
643 /// Converts the land bitmap to a packet friendly byte array
644 /// </summary>
645 /// <returns></returns>
646 private byte[] convertLandBitmapToBytes()
647 {
648 byte[] tempConvertArr = new byte[512];
649 byte tempByte = 0;
650 int x, y, i, byteNum = 0;
651 i = 0;
652 for (y = 0; y < 64; y++)
653 {
654 for (x = 0; x < 64; x++)
655 {
656 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8));
657 if (i % 8 == 0)
658 {
659 tempConvertArr[byteNum] = tempByte;
660 tempByte = (byte) 0;
661 i = 0;
662 byteNum++;
663 }
664 }
665 }
666 return tempConvertArr;
667 }
668
669 private bool[,] convertBytesToLandBitmap()
670 {
671 bool[,] tempConvertMap = new bool[64,64];
672 tempConvertMap.Initialize();
673 byte tempByte = 0;
674 int x = 0, y = 0, i = 0, bitNum = 0;
675 for (i = 0; i < 512; i++)
676 {
677 tempByte = landData.landBitmapByteArray[i];
678 for (bitNum = 0; bitNum < 8; bitNum++)
679 {
680 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
681 tempConvertMap[x, y] = bit;
682 x++;
683 if (x > 63)
684 {
685 x = 0;
686 y++;
687 }
688 }
689 }
690 return tempConvertMap;
691 }
692
708 #endregion 693 #endregion
709 694
710 #region Object Select and Object Owner Listing 695 #region Object Select and Object Owner Listing
@@ -781,7 +766,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
781 public void sendLandObjectOwners(IClientAPI remote_client) 766 public void sendLandObjectOwners(IClientAPI remote_client)
782 { 767 {
783 Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>(); 768 Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>();
784 ParcelObjectOwnersReplyPacket pack 769 ParcelObjectOwnersReplyPacket pack
785 = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); 770 = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
786 // TODO: don't create new blocks if recycling an old packet 771 // TODO: don't create new blocks if recycling an old packet
787 772
@@ -807,21 +792,21 @@ namespace OpenSim.Region.Environment.Modules.World.Land
807 m_log.Error("[LAND]: Unable to match a prim with it's owner."); 792 m_log.Error("[LAND]: Unable to match a prim with it's owner.");
808 } 793 }
809 } 794 }
810 795
811 int notifyCount = primCount.Count; 796 int notifyCount = primCount.Count;
812 797
813 if (notifyCount > 0) 798 if (notifyCount > 0)
814 { 799 {
815 if (notifyCount > 32) 800 if (notifyCount > 32)
816 { 801 {
817 m_log.InfoFormat( 802 m_log.InfoFormat(
818 "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}" 803 "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
819 + " - a developer might want to investigate whether this is a hard limit", 32); 804 + " - a developer might want to investigate whether this is a hard limit", 32);
820 805
821 notifyCount = 32; 806 notifyCount = 32;
822 } 807 }
823 808
824 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock 809 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
825 = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount]; 810 = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
826 811
827 int num = 0; 812 int num = 0;
@@ -834,16 +819,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
834 dataBlock[num].OwnerID = owner; 819 dataBlock[num].OwnerID = owner;
835 820
836 num++; 821 num++;
837 822
838 if (num >= notifyCount) 823 if (num >= notifyCount)
839 { 824 {
840 break; 825 break;
841 } 826 }
842 } 827 }
843 828
844 pack.Data = dataBlock; 829 pack.Data = dataBlock;
845 } 830 }
846 831
847 remote_client.OutPacket(pack, ThrottleOutPacketType.Task); 832 remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
848 } 833 }
849 834
@@ -937,7 +922,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
937 #endregion 922 #endregion
938 923
939 #endregion 924 #endregion
940
941 925
926 #endregion
942 } 927 }
943} \ No newline at end of file 928} \ No newline at end of file