aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/ParcelManager.cs
diff options
context:
space:
mode:
authormingchen2007-07-14 15:11:36 +0000
committermingchen2007-07-14 15:11:36 +0000
commit423d03eaefcae1bcaff8e4d16da014d350c91c42 (patch)
tree1caf9a940dc856be765b7b000d4360d954b6741a /OpenSim/Region/Environment/ParcelManager.cs
parentSet up parcel manager and the master avatar in SimpleApp. (diff)
downloadopensim-SC_OLD-423d03eaefcae1bcaff8e4d16da014d350c91c42.zip
opensim-SC_OLD-423d03eaefcae1bcaff8e4d16da014d350c91c42.tar.gz
opensim-SC_OLD-423d03eaefcae1bcaff8e4d16da014d350c91c42.tar.bz2
opensim-SC_OLD-423d03eaefcae1bcaff8e4d16da014d350c91c42.tar.xz
*Added support for prim counting on parcels
**No restrictions yet in place, or total prim count
Diffstat (limited to 'OpenSim/Region/Environment/ParcelManager.cs')
-rw-r--r--OpenSim/Region/Environment/ParcelManager.cs117
1 files changed, 110 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs
index b9c4067..981898f 100644
--- a/OpenSim/Region/Environment/ParcelManager.cs
+++ b/OpenSim/Region/Environment/ParcelManager.cs
@@ -75,6 +75,11 @@ namespace OpenSim.Region.Environment
75 private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; 75 private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1;
76 private int[,] parcelIDList = new int[64, 64]; 76 private int[,] parcelIDList = new int[64, 64];
77 77
78 /// <summary>
79 /// Set to true when a prim is moved, created, added. Performs a prim count update
80 /// </summary>
81 public bool parcelPrimCountTainted = false;
82
78 private Scene m_world; 83 private Scene m_world;
79 private RegionInfo m_regInfo; 84 private RegionInfo m_regInfo;
80 85
@@ -190,6 +195,13 @@ namespace OpenSim.Region.Environment
190 /// <param name="x">Value between 0 - 256 on the x axis of the point</param> 195 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
191 /// <param name="y">Value between 0 - 256 on the y axis of the point</param> 196 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
192 /// <returns>Parcel at the point supplied</returns> 197 /// <returns>Parcel at the point supplied</returns>
198 public Parcel getParcel(float x_float, float y_float)
199 {
200 int x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float)));
201 int y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float)));
202
203 return getParcel(x, y);
204 }
193 public Parcel getParcel(int x, int y) 205 public Parcel getParcel(int x, int y)
194 { 206 {
195 if (x > 256 || y > 256 || x < 0 || y < 0) 207 if (x > 256 || y > 256 || x < 0 || y < 0)
@@ -200,7 +212,6 @@ namespace OpenSim.Region.Environment
200 { 212 {
201 return parcelList[parcelIDList[x / 4, y / 4]]; 213 return parcelList[parcelIDList[x / 4, y / 4]];
202 } 214 }
203
204 } 215 }
205 #endregion 216 #endregion
206 217
@@ -262,9 +273,11 @@ namespace OpenSim.Region.Environment
262 parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false)); 273 parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false));
263 parcelList[startParcelIndex].forceUpdateParcelInfo(); 274 parcelList[startParcelIndex].forceUpdateParcelInfo();
264 275
276
277 this.setPrimsTainted();
278
265 //Now add the new parcel 279 //Now add the new parcel
266 Parcel result = addParcel(newParcel); 280 Parcel result = addParcel(newParcel);
267
268 result.sendParcelUpdateToAvatarsOverMe(); 281 result.sendParcelUpdateToAvatarsOverMe();
269 282
270 283
@@ -326,6 +339,8 @@ namespace OpenSim.Region.Environment
326 } 339 }
327 340
328 341
342 this.setPrimsTainted();
343
329 masterParcel.sendParcelUpdateToAvatarsOverMe(); 344 masterParcel.sendParcelUpdateToAvatarsOverMe();
330 345
331 return true; 346 return true;
@@ -493,13 +508,46 @@ namespace OpenSim.Region.Environment
493 Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId); 508 Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId);
494 if (clientAvatar != null) 509 if (clientAvatar != null)
495 { 510 {
496 Parcel over = getParcel(Convert.ToInt32(clientAvatar.Pos.X), Convert.ToInt32(clientAvatar.Pos.Y)); 511 Parcel over = getParcel(clientAvatar.Pos.X,clientAvatar.Pos.Y);
497 if (over != null) 512 if (over != null)
498 { 513 {
499 over.sendParcelProperties(0, false, 0, remote_client); 514 over.sendParcelProperties(0, false, 0, remote_client);
500 } 515 }
501 } 516 }
502 } 517 }
518
519 public void resetAllParcelPrimCounts()
520 {
521 foreach (Parcel p in parcelList.Values)
522 {
523 p.resetParcelPrimCounts();
524 }
525 }
526
527 public void addPrimToParcelCounts(SceneObject obj)
528 {
529 LLVector3 position = obj.rootPrimitive.Pos;
530 int pos_x = Convert.ToInt32(Math.Round(position.X));
531 int pos_y = Convert.ToInt32(Math.Round(position.Y));
532 Parcel parcelUnderPrim = getParcel(pos_x, pos_y);
533 if (parcelUnderPrim != null)
534 {
535 parcelUnderPrim.addPrimToCount(obj);
536 }
537 }
538
539 public void removePrimFromParcelCounts(SceneObject obj)
540 {
541 foreach (Parcel p in parcelList.Values)
542 {
543 p.removePrimFromCount(obj);
544 }
545 }
546
547 public void setPrimsTainted()
548 {
549 this.parcelPrimCountTainted = true;
550 }
503 #endregion 551 #endregion
504 } 552 }
505 #endregion 553 #endregion
@@ -513,6 +561,8 @@ namespace OpenSim.Region.Environment
513 { 561 {
514 #region Member Variables 562 #region Member Variables
515 public ParcelData parcelData = new ParcelData(); 563 public ParcelData parcelData = new ParcelData();
564 public List<SceneObject> primsOverMe = new List<SceneObject>();
565
516 public Scene m_world; 566 public Scene m_world;
517 567
518 private bool[,] parcelBitmap = new bool[64, 64]; 568 private bool[,] parcelBitmap = new bool[64, 64];
@@ -602,9 +652,9 @@ namespace OpenSim.Region.Environment
602 updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); 652 updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName);
603 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented 653 updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented
604 updatePacket.ParcelData.OtherCount = 0; //unemplemented 654 updatePacket.ParcelData.OtherCount = 0; //unemplemented
605 updatePacket.ParcelData.OtherPrims = 0; //unemplented 655 updatePacket.ParcelData.OtherPrims = parcelData.groupPrims;
606 updatePacket.ParcelData.OwnerID = parcelData.ownerID; 656 updatePacket.ParcelData.OwnerID = parcelData.ownerID;
607 updatePacket.ParcelData.OwnerPrims = 0; //unemplemented 657 updatePacket.ParcelData.OwnerPrims = parcelData.ownerPrims;
608 updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags; 658 updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags;
609 updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor; 659 updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor;
610 updatePacket.ParcelData.PassHours = parcelData.passHours; 660 updatePacket.ParcelData.PassHours = parcelData.passHours;
@@ -616,7 +666,7 @@ namespace OpenSim.Region.Environment
616 updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); 666 updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0);
617 updatePacket.ParcelData.RentPrice = 0; 667 updatePacket.ParcelData.RentPrice = 0;
618 updatePacket.ParcelData.RequestResult = request_result; 668 updatePacket.ParcelData.RequestResult = request_result;
619 updatePacket.ParcelData.SalePrice = parcelData.salePrice; //unemplemented 669 updatePacket.ParcelData.SalePrice = parcelData.salePrice;
620 updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented 670 updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented
621 updatePacket.ParcelData.SelfCount = 0;//unemplemented 671 updatePacket.ParcelData.SelfCount = 0;//unemplemented
622 updatePacket.ParcelData.SequenceID = sequence_id; 672 updatePacket.ParcelData.SequenceID = sequence_id;
@@ -625,7 +675,7 @@ namespace OpenSim.Region.Environment
625 updatePacket.ParcelData.SnapSelection = snap_selection; 675 updatePacket.ParcelData.SnapSelection = snap_selection;
626 updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; 676 updatePacket.ParcelData.SnapshotID = parcelData.snapshotID;
627 updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; 677 updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus;
628 updatePacket.ParcelData.TotalPrims = 0; //unemplemented 678 updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims;
629 updatePacket.ParcelData.UserLocation = parcelData.userLocation; 679 updatePacket.ParcelData.UserLocation = parcelData.userLocation;
630 updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; 680 updatePacket.ParcelData.UserLookAt = parcelData.userLookAt;
631 remote_client.OutPacket((Packet)updatePacket); 681 remote_client.OutPacket((Packet)updatePacket);
@@ -900,6 +950,59 @@ namespace OpenSim.Region.Environment
900 } 950 }
901 #endregion 951 #endregion
902 952
953 public void resetParcelPrimCounts()
954 {
955 parcelData.groupPrims = 0;
956 parcelData.ownerPrims = 0;
957 parcelData.groupPrims = 0;
958 primsOverMe.Clear();
959 }
960
961 public void addPrimToCount(SceneObject obj)
962 {
963 LLUUID prim_owner = obj.rootPrimitive.OwnerID;
964 int prim_count = obj.primCount;
965
966 if(prim_owner == parcelData.ownerID)
967 {
968 parcelData.ownerPrims += prim_count;
969 }
970 else if (prim_owner == parcelData.groupID)
971 {
972 parcelData.groupPrims += prim_count;
973 }
974 else
975 {
976 parcelData.otherPrims += prim_count;
977 }
978 primsOverMe.Add(obj);
979
980 }
981
982 public void removePrimFromCount(SceneObject obj)
983 {
984 if (primsOverMe.Contains(obj))
985 {
986 LLUUID prim_owner = obj.rootPrimitive.OwnerID;
987 int prim_count = obj.primCount;
988
989 if (prim_owner == parcelData.ownerID)
990 {
991 parcelData.ownerPrims -= prim_count;
992 }
993 else if (prim_owner == parcelData.groupID)
994 {
995 parcelData.groupPrims -= prim_count;
996 }
997 else
998 {
999 parcelData.otherPrims -= prim_count;
1000 }
1001
1002 primsOverMe.Remove(obj);
1003 }
1004 }
1005
903 #endregion 1006 #endregion
904 1007
905 1008