aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Land
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs359
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs76
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs4
3 files changed, 297 insertions, 142 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 1789d6d..dbc9296 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -89,19 +89,21 @@ namespace OpenSim.Region.CoreModules.World.Land
89 /// <value> 89 /// <value>
90 /// Land objects keyed by local id 90 /// Land objects keyed by local id
91 /// </value> 91 /// </value>
92 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); 92// private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
93
94 //ubit: removed the readonly so i can move it around
95 private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
93 96
94 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 97 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
95 98
96 private bool m_allowedForcefulBans = true; 99 private bool m_allowedForcefulBans = true;
100 private UUID DefaultGodParcelGroup;
101 private string DefaultGodParcelName;
97 102
98 // caches ExtendedLandData 103 // caches ExtendedLandData
99 private Cache parcelInfoCache; 104 private Cache parcelInfoCache;
100 105 private Dictionary<UUID, Vector3> forcedPosition =
101 /// <summary> 106 new Dictionary<UUID, Vector3>();
102 /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions.
103 /// </summary>
104 private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>();
105 107
106 #region INonSharedRegionModule Members 108 #region INonSharedRegionModule Members
107 109
@@ -112,6 +114,12 @@ namespace OpenSim.Region.CoreModules.World.Land
112 114
113 public void Initialise(IConfigSource source) 115 public void Initialise(IConfigSource source)
114 { 116 {
117 IConfig cnf = source.Configs["LandManagement"];
118 if (cnf != null)
119 {
120 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
121 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
122 }
115 } 123 }
116 124
117 public void AddRegion(Scene scene) 125 public void AddRegion(Scene scene)
@@ -165,13 +173,6 @@ namespace OpenSim.Region.CoreModules.World.Land
165 m_scene.UnregisterModuleCommander(m_commander.Name); 173 m_scene.UnregisterModuleCommander(m_commander.Name);
166 } 174 }
167 175
168// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
169// {
170// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
171// reason = "You are not allowed to enter this sim.";
172// return nearestParcel != null;
173// }
174
175 /// <summary> 176 /// <summary>
176 /// Processes commandline input. Do not call directly. 177 /// Processes commandline input. Do not call directly.
177 /// </summary> 178 /// </summary>
@@ -216,7 +217,6 @@ namespace OpenSim.Region.CoreModules.World.Land
216 client.OnParcelFreezeUser += ClientOnParcelFreezeUser; 217 client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
217 client.OnSetStartLocationRequest += ClientOnSetHome; 218 client.OnSetStartLocationRequest += ClientOnSetHome;
218 219
219
220 EntityBase presenceEntity; 220 EntityBase presenceEntity;
221 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) 221 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
222 { 222 {
@@ -232,48 +232,6 @@ namespace OpenSim.Region.CoreModules.World.Land
232 232
233 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 233 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
234 { 234 {
235 //If we are forcing a position for them to go
236 if (forcedPosition.ContainsKey(remoteClient.AgentId))
237 {
238 ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
239
240 //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
241 //When the avatar walks into a ban line on the ground, it prevents getting stuck
242 agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
243
244 //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
245 if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
246 {
247// m_log.DebugFormat(
248// "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}",
249// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
250
251 forcedPosition.Remove(remoteClient.AgentId);
252 }
253 //if we are far away, teleport
254 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
255 {
256 Vector3 forcePosition = forcedPosition[remoteClient.AgentId];
257// m_log.DebugFormat(
258// "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}",
259// clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition);
260
261 m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle,
262 forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect);
263
264 forcedPosition.Remove(remoteClient.AgentId);
265 }
266 else
267 {
268// m_log.DebugFormat(
269// "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}",
270// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
271
272 //Forces them toward the forced position we want if they aren't there yet
273 agentData.UseClientAgentPosition = true;
274 agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
275 }
276 }
277 } 235 }
278 236
279 public void Close() 237 public void Close()
@@ -298,6 +256,7 @@ namespace OpenSim.Region.CoreModules.World.Land
298 { 256 {
299 LandData newData = data.Copy(); 257 LandData newData = data.Copy();
300 newData.LocalID = local_id; 258 newData.LocalID = local_id;
259 ILandObject landobj = null;
301 260
302 ILandObject land; 261 ILandObject land;
303 lock (m_landList) 262 lock (m_landList)
@@ -337,14 +296,14 @@ namespace OpenSim.Region.CoreModules.World.Land
337 protected ILandObject CreateDefaultParcel() 296 protected ILandObject CreateDefaultParcel()
338 { 297 {
339 m_log.DebugFormat( 298 m_log.DebugFormat(
340 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); 299 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
341 300
342 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 301 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
343 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 302 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
344 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 303 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
345 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 304 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
346 305
347 return AddLandObject(fullSimParcel); 306 return AddLandObject(fullSimParcel);
348 } 307 }
349 308
350 public List<ILandObject> AllParcels() 309 public List<ILandObject> AllParcels()
@@ -393,10 +352,16 @@ namespace OpenSim.Region.CoreModules.World.Land
393 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 352 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
394 { 353 {
395 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 354 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
396 if (position.HasValue) 355
397 { 356 if (!position.HasValue)
398 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 357 return;
399 } 358
359 bool isFlying = avatar.PhysicsActor.Flying;
360 avatar.RemoveFromPhysicalScene();
361
362 avatar.AbsolutePosition = (Vector3)position;
363
364 avatar.AddToPhysicalScene(isFlying);
400 } 365 }
401 366
402 public void SendYouAreRestrictedNotice(ScenePresence avatar) 367 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -416,29 +381,7 @@ namespace OpenSim.Region.CoreModules.World.Land
416 } 381 }
417 382
418 if (parcelAvatarIsEntering != null) 383 if (parcelAvatarIsEntering != null)
419 { 384 EnforceBans(parcelAvatarIsEntering, avatar);
420 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
421 {
422 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
423 {
424 SendYouAreBannedNotice(avatar);
425 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
426 }
427 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
428 {
429 SendYouAreRestrictedNotice(avatar);
430 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
431 }
432 else
433 {
434 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
435 }
436 }
437 else
438 {
439 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
440 }
441 }
442 } 385 }
443 } 386 }
444 387
@@ -467,30 +410,51 @@ namespace OpenSim.Region.CoreModules.World.Land
467 410
468 public void SendLandUpdate(ScenePresence avatar, bool force) 411 public void SendLandUpdate(ScenePresence avatar, bool force)
469 { 412 {
413
414 /* stop sendind same data twice
415 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
416 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
417
418 if (over != null)
419 {
420
421 if (force)
422 {
423 if (!avatar.IsChildAgent)
424 {
425 over.SendLandUpdateToClient(avatar.ControllingClient);
426 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
427 m_scene.RegionInfo.RegionID);
428 }
429 }
430
431 if (avatar.currentParcelUUID != over.LandData.GlobalID)
432 {
433 if (!avatar.IsChildAgent)
434 {
435 over.SendLandUpdateToClient(avatar.ControllingClient);
436 avatar.currentParcelUUID = over.LandData.GlobalID;
437 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
438 m_scene.RegionInfo.RegionID);
439 }
440 }
441 */
442 if (avatar.IsChildAgent)
443 return;
444
470 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), 445 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
471 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); 446 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
472 447
473 if (over != null) 448 if (over != null)
474 { 449 {
475 if (force) 450 bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID);
476 { 451 if (force || NotsameID)
477 if (!avatar.IsChildAgent)
478 {
479 over.SendLandUpdateToClient(avatar.ControllingClient);
480 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
481 m_scene.RegionInfo.RegionID);
482 }
483 }
484
485 if (avatar.currentParcelUUID != over.LandData.GlobalID)
486 { 452 {
487 if (!avatar.IsChildAgent) 453 over.SendLandUpdateToClient(avatar.ControllingClient);
488 { 454 if (NotsameID)
489 over.SendLandUpdateToClient(avatar.ControllingClient);
490 avatar.currentParcelUUID = over.LandData.GlobalID; 455 avatar.currentParcelUUID = over.LandData.GlobalID;
491 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, 456 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
492 m_scene.RegionInfo.RegionID); 457 m_scene.RegionInfo.RegionID);
493 }
494 } 458 }
495 } 459 }
496 } 460 }
@@ -542,6 +506,7 @@ namespace OpenSim.Region.CoreModules.World.Land
542 //when we are finally in a safe place, lets release the forced position lock 506 //when we are finally in a safe place, lets release the forced position lock
543 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); 507 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
544 } 508 }
509 EnforceBans(parcel, clientAvatar);
545 } 510 }
546 } 511 }
547 512
@@ -692,27 +657,28 @@ namespace OpenSim.Region.CoreModules.World.Land
692 /// </summary> 657 /// </summary>
693 public void Clear(bool setupDefaultParcel) 658 public void Clear(bool setupDefaultParcel)
694 { 659 {
695 List<ILandObject> parcels; 660 Dictionary<int, ILandObject> landworkList;
661 // move to work pointer since we are deleting it all
696 lock (m_landList) 662 lock (m_landList)
697 { 663 {
698 parcels = new List<ILandObject>(m_landList.Values); 664 landworkList = m_landList;
665 m_landList = new Dictionary<int, ILandObject>();
699 } 666 }
700 667
701 foreach (ILandObject lo in parcels) 668 // this 2 methods have locks (now)
669 ResetSimLandObjects();
670
671 if (setupDefaultParcel)
672 CreateDefaultParcel();
673
674 // fire outside events unlocked
675 foreach (ILandObject lo in landworkList.Values)
702 { 676 {
703 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); 677 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
704 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); 678 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
705 } 679 }
680 landworkList.Clear();
706 681
707 lock (m_landList)
708 {
709 m_landList.Clear();
710
711 ResetSimLandObjects();
712 }
713
714 if (setupDefaultParcel)
715 CreateDefaultParcel();
716 } 682 }
717 683
718 private void performFinalLandJoin(ILandObject master, ILandObject slave) 684 private void performFinalLandJoin(ILandObject master, ILandObject slave)
@@ -759,7 +725,7 @@ namespace OpenSim.Region.CoreModules.World.Land
759 int x; 725 int x;
760 int y; 726 int y;
761 727
762 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 728 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
763 return null; 729 return null;
764 730
765 try 731 try
@@ -809,14 +775,13 @@ namespace OpenSim.Region.CoreModules.World.Land
809 { 775 {
810 try 776 try
811 { 777 {
812 return m_landList[m_landIDList[x / 4, y / 4]]; 778 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
779 return m_landList[m_landIDList[x / 4, y / 4]];
780 //else
781 // return null;
813 } 782 }
814 catch (IndexOutOfRangeException) 783 catch (IndexOutOfRangeException)
815 { 784 {
816// m_log.WarnFormat(
817// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
818// x, y, m_scene.RegionInfo.RegionName);
819
820 return null; 785 return null;
821 } 786 }
822 } 787 }
@@ -975,6 +940,8 @@ namespace OpenSim.Region.CoreModules.World.Land
975 newLand.LandData.Name = newLand.LandData.Name; 940 newLand.LandData.Name = newLand.LandData.Name;
976 newLand.LandData.GlobalID = UUID.Random(); 941 newLand.LandData.GlobalID = UUID.Random();
977 newLand.LandData.Dwell = 0; 942 newLand.LandData.Dwell = 0;
943 // Clear "Show in search" on the cut out parcel to prevent double-charging
944 newLand.LandData.Flags &= ~(uint)ParcelFlags.ShowDirectory;
978 945
979 newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); 946 newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y));
980 947
@@ -1100,6 +1067,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1100 //Owner Flag 1067 //Owner Flag
1101 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 1068 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1102 } 1069 }
1070 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1071 {
1072 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1073 }
1103 else if (currentParcelBlock.LandData.SalePrice > 0 && 1074 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1104 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1075 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1105 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1076 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1180,8 +1151,11 @@ namespace OpenSim.Region.CoreModules.World.Land
1180 { 1151 {
1181 if (!temp.Contains(currentParcel)) 1152 if (!temp.Contains(currentParcel))
1182 { 1153 {
1183 currentParcel.ForceUpdateLandInfo(); 1154 if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId))
1184 temp.Add(currentParcel); 1155 {
1156 currentParcel.ForceUpdateLandInfo();
1157 temp.Add(currentParcel);
1158 }
1185 } 1159 }
1186 } 1160 }
1187 } 1161 }
@@ -1400,8 +1374,26 @@ namespace OpenSim.Region.CoreModules.World.Land
1400 1374
1401 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1375 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1402 { 1376 {
1403// m_log.DebugFormat( 1377 Dictionary<int, ILandObject> landworkList;
1404// "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); 1378 // move to work pointer since we are deleting it all
1379 lock (m_landList)
1380 {
1381 landworkList = m_landList;
1382 m_landList = new Dictionary<int, ILandObject>();
1383 }
1384
1385 //Remove all the land objects in the sim and then process our new data
1386 foreach (int n in landworkList.Keys)
1387 {
1388 m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID);
1389 }
1390 landworkList.Clear();
1391
1392 lock (m_landList)
1393 {
1394 m_landIDList.Initialize();
1395 m_landList.Clear();
1396 }
1405 1397
1406 for (int i = 0; i < data.Count; i++) 1398 for (int i = 0; i < data.Count; i++)
1407 IncomingLandObjectFromStorage(data[i]); 1399 IncomingLandObjectFromStorage(data[i]);
@@ -1409,10 +1401,12 @@ namespace OpenSim.Region.CoreModules.World.Land
1409 1401
1410 public void IncomingLandObjectFromStorage(LandData data) 1402 public void IncomingLandObjectFromStorage(LandData data)
1411 { 1403 {
1404
1412 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1405 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1413 new_land.LandData = data.Copy(); 1406 new_land.LandData = data.Copy();
1414 new_land.SetLandBitmapFromByteArray(); 1407 new_land.SetLandBitmapFromByteArray();
1415 AddLandObject(new_land); 1408 AddLandObject(new_land);
1409 new_land.SendLandUpdateToAvatarsOverMe();
1416 } 1410 }
1417 1411
1418 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1412 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1743,7 +1737,86 @@ namespace OpenSim.Region.CoreModules.World.Land
1743 1737
1744 UpdateLandObject(localID, land.LandData); 1738 UpdateLandObject(localID, land.LandData);
1745 } 1739 }
1746 1740
1741 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1742 {
1743 ILandObject land = null;
1744 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1745 foreach (ILandObject landObject in Land)
1746 {
1747 if (landObject.LandData.LocalID == landID)
1748 {
1749 land = landObject;
1750 }
1751 }
1752 land.DeedToGroup(DefaultGodParcelGroup);
1753 land.LandData.Name = DefaultGodParcelName;
1754 land.SendLandUpdateToAvatarsOverMe();
1755 }
1756
1757 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1758 {
1759 ScenePresence SP;
1760 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1761 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1762 if (SP.UserLevel != 0)
1763 {
1764 if (flags == 0) //All parcels, scripted or not
1765 {
1766 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1767 {
1768 if (e.OwnerID == targetID)
1769 {
1770 returns.Add(e);
1771 }
1772 }
1773 );
1774 }
1775 if (flags == 4) //All parcels, scripted object
1776 {
1777 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1778 {
1779 if (e.OwnerID == targetID)
1780 {
1781 if (e.ContainsScripts())
1782 {
1783 returns.Add(e);
1784 }
1785 }
1786 }
1787 );
1788 }
1789 if (flags == 4) //not target parcel, scripted object
1790 {
1791 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1792 {
1793 if (e.OwnerID == targetID)
1794 {
1795 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1796 if (landobject.LandData.OwnerID != e.OwnerID)
1797 {
1798 if (e.ContainsScripts())
1799 {
1800 returns.Add(e);
1801 }
1802 }
1803 }
1804 }
1805 );
1806 }
1807 foreach (SceneObjectGroup ol in returns)
1808 {
1809 ReturnObject(ol, client);
1810 }
1811 }
1812 }
1813 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1814 {
1815 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1816 objs[0] = obj;
1817 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1818 }
1819
1747 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); 1820 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1748 1821
1749 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) 1822 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
@@ -1779,7 +1852,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1779 } 1852 }
1780 } 1853 }
1781 } 1854 }
1782
1783 private void OnEndParcelFrozen(object avatar) 1855 private void OnEndParcelFrozen(object avatar)
1784 { 1856 {
1785 ScenePresence targetAvatar = (ScenePresence)avatar; 1857 ScenePresence targetAvatar = (ScenePresence)avatar;
@@ -1790,6 +1862,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1790 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); 1862 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1791 } 1863 }
1792 1864
1865
1793 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) 1866 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1794 { 1867 {
1795 ScenePresence targetAvatar = null; 1868 ScenePresence targetAvatar = null;
@@ -1809,12 +1882,13 @@ namespace OpenSim.Region.CoreModules.World.Land
1809 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && 1882 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) &&
1810 !m_scene.Permissions.IsAdministrator(client.AgentId)) 1883 !m_scene.Permissions.IsAdministrator(client.AgentId))
1811 return; 1884 return;
1885
1812 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); 1886 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
1813 1887
1814 targetAvatar.TeleportWithMomentum(pos, null); 1888 targetAvatar.TeleportWithMomentum(pos, null);
1815 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); 1889 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1816 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); 1890 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1817 1891
1818 if ((flags & 1) != 0) // Ban TODO: Remove magic number 1892 if ((flags & 1) != 0) // Ban TODO: Remove magic number
1819 { 1893 {
1820 LandAccessEntry entry = new LandAccessEntry(); 1894 LandAccessEntry entry = new LandAccessEntry();
@@ -1872,7 +1946,6 @@ namespace OpenSim.Region.CoreModules.World.Land
1872 m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel."); 1946 m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel.");
1873 } 1947 }
1874 1948
1875
1876 protected void InstallInterfaces() 1949 protected void InstallInterfaces()
1877 { 1950 {
1878 Command clearCommand 1951 Command clearCommand
@@ -1934,5 +2007,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1934 2007
1935 MainConsole.Instance.Output(report.ToString()); 2008 MainConsole.Instance.Output(report.ToString());
1936 } 2009 }
2010
2011 public void EnforceBans(ILandObject land, ScenePresence avatar)
2012 {
2013 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
2014 return;
2015
2016 if (land.IsEitherBannedOrRestricted(avatar.UUID))
2017 {
2018 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
2019 {
2020 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
2021 if (pos == null)
2022 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
2023 else
2024 ForceAvatarToPosition(avatar, (Vector3)pos);
2025 }
2026 else
2027 {
2028 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
2029 }
2030 }
2031 }
1937 } 2032 }
1938} 2033}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index e55c9ed..ce4bd0f 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land
51 private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax]; 51 private bool[,] m_landBitmap = new bool[landArrayMax,landArrayMax];
52 52
53 private int m_lastSeqId = 0; 53 private int m_lastSeqId = 0;
54 private int m_expiryCounter = 0;
54 55
55 protected LandData m_landData = new LandData(); 56 protected LandData m_landData = new LandData();
56 protected Scene m_scene; 57 protected Scene m_scene;
@@ -136,6 +137,8 @@ namespace OpenSim.Region.CoreModules.World.Land
136 else 137 else
137 LandData.GroupID = UUID.Zero; 138 LandData.GroupID = UUID.Zero;
138 LandData.IsGroupOwned = is_group_owned; 139 LandData.IsGroupOwned = is_group_owned;
140
141 m_scene.EventManager.OnFrame += OnFrame;
139 } 142 }
140 143
141 #endregion 144 #endregion
@@ -194,10 +197,27 @@ namespace OpenSim.Region.CoreModules.World.Land
194 else 197 else
195 { 198 {
196 // Normal Calculations 199 // Normal Calculations
197 int parcelMax = (int)(((float)LandData.Area / 65536.0f) 200 int parcelMax = (int)((long)LandData.Area
198 * (float)m_scene.RegionInfo.ObjectCapacity 201 * (long)m_scene.RegionInfo.ObjectCapacity
199 * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); 202 * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus
200 // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! 203 / 65536L);
204 //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax);
205 return parcelMax;
206 }
207 }
208
209 private int GetParcelBasePrimCount()
210 {
211 if (overrideParcelMaxPrimCount != null)
212 {
213 return overrideParcelMaxPrimCount(this);
214 }
215 else
216 {
217 // Normal Calculations
218 int parcelMax = (int)((long)LandData.Area
219 * (long)m_scene.RegionInfo.ObjectCapacity
220 / 65536L);
201 return parcelMax; 221 return parcelMax;
202 } 222 }
203 } 223 }
@@ -211,8 +231,9 @@ namespace OpenSim.Region.CoreModules.World.Land
211 else 231 else
212 { 232 {
213 //Normal Calculations 233 //Normal Calculations
214 int simMax = (int)(((float)LandData.SimwideArea / 65536.0f) 234 int simMax = (int)((long)LandData.SimwideArea
215 * (float)m_scene.RegionInfo.ObjectCapacity); 235 * (long)m_scene.RegionInfo.ObjectCapacity / 65536L);
236 // m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}", LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax);
216 return simMax; 237 return simMax;
217 } 238 }
218 } 239 }
@@ -242,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Land
242 remote_client.SendLandProperties(seq_id, 263 remote_client.SendLandProperties(seq_id,
243 snap_selection, request_result, this, 264 snap_selection, request_result, this,
244 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 265 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
245 GetParcelMaxPrimCount(), 266 GetParcelBasePrimCount(),
246 GetSimulatorMaxPrimCount(), regionFlags); 267 GetSimulatorMaxPrimCount(), regionFlags);
247 } 268 }
248 269
@@ -302,7 +323,7 @@ namespace OpenSim.Region.CoreModules.World.Land
302 323
303 allowedDelta |= (uint)(ParcelFlags.ShowDirectory | 324 allowedDelta |= (uint)(ParcelFlags.ShowDirectory |
304 ParcelFlags.AllowPublish | 325 ParcelFlags.AllowPublish |
305 ParcelFlags.MaturePublish); 326 ParcelFlags.MaturePublish) | (uint)(1 << 23);
306 } 327 }
307 328
308 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) 329 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity))
@@ -414,6 +435,19 @@ namespace OpenSim.Region.CoreModules.World.Land
414 return false; 435 return false;
415 } 436 }
416 437
438 public bool CanBeOnThisLand(UUID avatar, float posHeight)
439 {
440 if (posHeight < LandChannel.BAN_LINE_SAFETY_HIEGHT && IsBannedFromLand(avatar))
441 {
442 return false;
443 }
444 else if (IsRestrictedFromLand(avatar))
445 {
446 return false;
447 }
448 return true;
449 }
450
417 public bool HasGroupAccess(UUID avatar) 451 public bool HasGroupAccess(UUID avatar)
418 { 452 {
419 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) 453 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
@@ -1178,6 +1212,17 @@ namespace OpenSim.Region.CoreModules.World.Land
1178 1212
1179 #endregion 1213 #endregion
1180 1214
1215 private void OnFrame()
1216 {
1217 m_expiryCounter++;
1218
1219 if (m_expiryCounter >= 50)
1220 {
1221 ExpireAccessList();
1222 m_expiryCounter = 0;
1223 }
1224 }
1225
1181 private void ExpireAccessList() 1226 private void ExpireAccessList()
1182 { 1227 {
1183 List<LandAccessEntry> delete = new List<LandAccessEntry>(); 1228 List<LandAccessEntry> delete = new List<LandAccessEntry>();
@@ -1188,7 +1233,22 @@ namespace OpenSim.Region.CoreModules.World.Land
1188 delete.Add(entry); 1233 delete.Add(entry);
1189 } 1234 }
1190 foreach (LandAccessEntry entry in delete) 1235 foreach (LandAccessEntry entry in delete)
1236 {
1191 LandData.ParcelAccessList.Remove(entry); 1237 LandData.ParcelAccessList.Remove(entry);
1238 ScenePresence presence;
1239
1240 if (m_scene.TryGetScenePresence(entry.AgentID, out presence) && (!presence.IsChildAgent))
1241 {
1242 ILandObject land = m_scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
1243 if (land.LandData.LocalID == LandData.LocalID)
1244 {
1245 Vector3 pos = m_scene.GetNearestAllowedPosition(presence, land);
1246 presence.TeleportWithMomentum(pos, null);
1247 presence.ControllingClient.SendAlertMessage("You have been ejected from this land");
1248 }
1249 }
1250 m_log.DebugFormat("[LAND]: Removing entry {0} because it has expired", entry.AgentID);
1251 }
1192 1252
1193 if (delete.Count > 0) 1253 if (delete.Count > 0)
1194 m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); 1254 m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this);
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 9b51cc8..771fdd2 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.Land
207 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) 207 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
208 { 208 {
209 UUID landOwner = landData.OwnerID; 209 UUID landOwner = landData.OwnerID;
210 int partCount = obj.Parts.Length; 210 int partCount = obj.GetPartCount();
211 211
212 m_SimwideCounts[landOwner] += partCount; 212 m_SimwideCounts[landOwner] += partCount;
213 if (parcelCounts.Users.ContainsKey(obj.OwnerID)) 213 if (parcelCounts.Users.ContainsKey(obj.OwnerID))
@@ -597,4 +597,4 @@ namespace OpenSim.Region.CoreModules.World.Land
597 } 597 }
598 } 598 }
599 } 599 }
600} \ No newline at end of file 600}