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.cs433
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs76
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs4
3 files changed, 376 insertions, 137 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index dbf5138..b4f7d51 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -88,19 +88,21 @@ namespace OpenSim.Region.CoreModules.World.Land
88 /// <value> 88 /// <value>
89 /// Land objects keyed by local id 89 /// Land objects keyed by local id
90 /// </value> 90 /// </value>
91 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); 91// private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
92
93 //ubit: removed the readonly so i can move it around
94 private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
92 95
93 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 96 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
94 97
95 private bool m_allowedForcefulBans = true; 98 private bool m_allowedForcefulBans = true;
99 private UUID DefaultGodParcelGroup;
100 private string DefaultGodParcelName;
96 101
97 // caches ExtendedLandData 102 // caches ExtendedLandData
98 private Cache parcelInfoCache; 103 private Cache parcelInfoCache;
99 104 private Dictionary<UUID, Vector3> forcedPosition =
100 /// <summary> 105 new Dictionary<UUID, Vector3>();
101 /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions.
102 /// </summary>
103 private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>();
104 106
105 #region INonSharedRegionModule Members 107 #region INonSharedRegionModule Members
106 108
@@ -111,6 +113,12 @@ namespace OpenSim.Region.CoreModules.World.Land
111 113
112 public void Initialise(IConfigSource source) 114 public void Initialise(IConfigSource source)
113 { 115 {
116 IConfig cnf = source.Configs["LandManagement"];
117 if (cnf != null)
118 {
119 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
120 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
121 }
114 } 122 }
115 123
116 public void AddRegion(Scene scene) 124 public void AddRegion(Scene scene)
@@ -163,13 +171,6 @@ namespace OpenSim.Region.CoreModules.World.Land
163 m_scene.UnregisterModuleCommander(m_commander.Name); 171 m_scene.UnregisterModuleCommander(m_commander.Name);
164 } 172 }
165 173
166// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
167// {
168// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
169// reason = "You are not allowed to enter this sim.";
170// return nearestParcel != null;
171// }
172
173 /// <summary> 174 /// <summary>
174 /// Processes commandline input. Do not call directly. 175 /// Processes commandline input. Do not call directly.
175 /// </summary> 176 /// </summary>
@@ -210,6 +211,8 @@ namespace OpenSim.Region.CoreModules.World.Land
210 client.OnParcelInfoRequest += ClientOnParcelInfoRequest; 211 client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
211 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; 212 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
212 client.OnPreAgentUpdate += ClientOnPreAgentUpdate; 213 client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
214 client.OnParcelEjectUser += ClientOnParcelEjectUser;
215 client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
213 216
214 EntityBase presenceEntity; 217 EntityBase presenceEntity;
215 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) 218 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -226,48 +229,6 @@ namespace OpenSim.Region.CoreModules.World.Land
226 229
227 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 230 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
228 { 231 {
229 //If we are forcing a position for them to go
230 if (forcedPosition.ContainsKey(remoteClient.AgentId))
231 {
232 ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
233
234 //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
235 //When the avatar walks into a ban line on the ground, it prevents getting stuck
236 agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
237
238 //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
239 if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
240 {
241// m_log.DebugFormat(
242// "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}",
243// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
244
245 forcedPosition.Remove(remoteClient.AgentId);
246 }
247 //if we are far away, teleport
248 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
249 {
250 Vector3 forcePosition = forcedPosition[remoteClient.AgentId];
251// m_log.DebugFormat(
252// "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}",
253// clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition);
254
255 m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle,
256 forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect);
257
258 forcedPosition.Remove(remoteClient.AgentId);
259 }
260 else
261 {
262// m_log.DebugFormat(
263// "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}",
264// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
265
266 //Forces them toward the forced position we want if they aren't there yet
267 agentData.UseClientAgentPosition = true;
268 agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
269 }
270 }
271 } 232 }
272 233
273 public void Close() 234 public void Close()
@@ -292,6 +253,7 @@ namespace OpenSim.Region.CoreModules.World.Land
292 { 253 {
293 LandData newData = data.Copy(); 254 LandData newData = data.Copy();
294 newData.LocalID = local_id; 255 newData.LocalID = local_id;
256 ILandObject landobj = null;
295 257
296 ILandObject land; 258 ILandObject land;
297 lock (m_landList) 259 lock (m_landList)
@@ -331,14 +293,14 @@ namespace OpenSim.Region.CoreModules.World.Land
331 protected ILandObject CreateDefaultParcel() 293 protected ILandObject CreateDefaultParcel()
332 { 294 {
333 m_log.DebugFormat( 295 m_log.DebugFormat(
334 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); 296 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
335 297
336 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 298 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
337 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 299 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
338 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 300 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
339 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 301 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
340 302
341 return AddLandObject(fullSimParcel); 303 return AddLandObject(fullSimParcel);
342 } 304 }
343 305
344 public List<ILandObject> AllParcels() 306 public List<ILandObject> AllParcels()
@@ -387,10 +349,16 @@ namespace OpenSim.Region.CoreModules.World.Land
387 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 349 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
388 { 350 {
389 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 351 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
390 if (position.HasValue) 352
391 { 353 if (!position.HasValue)
392 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 354 return;
393 } 355
356 bool isFlying = avatar.PhysicsActor.Flying;
357 avatar.RemoveFromPhysicalScene();
358
359 avatar.AbsolutePosition = (Vector3)position;
360
361 avatar.AddToPhysicalScene(isFlying);
394 } 362 }
395 363
396 public void SendYouAreRestrictedNotice(ScenePresence avatar) 364 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -410,29 +378,7 @@ namespace OpenSim.Region.CoreModules.World.Land
410 } 378 }
411 379
412 if (parcelAvatarIsEntering != null) 380 if (parcelAvatarIsEntering != null)
413 { 381 EnforceBans(parcelAvatarIsEntering, avatar);
414 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
415 {
416 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
417 {
418 SendYouAreBannedNotice(avatar);
419 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
420 }
421 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
422 {
423 SendYouAreRestrictedNotice(avatar);
424 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
425 }
426 else
427 {
428 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
429 }
430 }
431 else
432 {
433 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
434 }
435 }
436 } 382 }
437 } 383 }
438 384
@@ -461,30 +407,51 @@ namespace OpenSim.Region.CoreModules.World.Land
461 407
462 public void SendLandUpdate(ScenePresence avatar, bool force) 408 public void SendLandUpdate(ScenePresence avatar, bool force)
463 { 409 {
410
411 /* stop sendind same data twice
412 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
413 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
414
415 if (over != null)
416 {
417
418 if (force)
419 {
420 if (!avatar.IsChildAgent)
421 {
422 over.SendLandUpdateToClient(avatar.ControllingClient);
423 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
424 m_scene.RegionInfo.RegionID);
425 }
426 }
427
428 if (avatar.currentParcelUUID != over.LandData.GlobalID)
429 {
430 if (!avatar.IsChildAgent)
431 {
432 over.SendLandUpdateToClient(avatar.ControllingClient);
433 avatar.currentParcelUUID = over.LandData.GlobalID;
434 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
435 m_scene.RegionInfo.RegionID);
436 }
437 }
438 */
439 if (avatar.IsChildAgent)
440 return;
441
464 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), 442 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
465 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); 443 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
466 444
467 if (over != null) 445 if (over != null)
468 { 446 {
469 if (force) 447 bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID);
448 if (force || NotsameID)
470 { 449 {
471 if (!avatar.IsChildAgent) 450 over.SendLandUpdateToClient(avatar.ControllingClient);
472 { 451 if (NotsameID)
473 over.SendLandUpdateToClient(avatar.ControllingClient);
474 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
475 m_scene.RegionInfo.RegionID);
476 }
477 }
478
479 if (avatar.currentParcelUUID != over.LandData.GlobalID)
480 {
481 if (!avatar.IsChildAgent)
482 {
483 over.SendLandUpdateToClient(avatar.ControllingClient);
484 avatar.currentParcelUUID = over.LandData.GlobalID; 452 avatar.currentParcelUUID = over.LandData.GlobalID;
485 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, 453 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
486 m_scene.RegionInfo.RegionID); 454 m_scene.RegionInfo.RegionID);
487 }
488 } 455 }
489 } 456 }
490 } 457 }
@@ -536,6 +503,7 @@ namespace OpenSim.Region.CoreModules.World.Land
536 //when we are finally in a safe place, lets release the forced position lock 503 //when we are finally in a safe place, lets release the forced position lock
537 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); 504 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
538 } 505 }
506 EnforceBans(parcel, clientAvatar);
539 } 507 }
540 } 508 }
541 509
@@ -686,27 +654,28 @@ namespace OpenSim.Region.CoreModules.World.Land
686 /// </summary> 654 /// </summary>
687 public void Clear(bool setupDefaultParcel) 655 public void Clear(bool setupDefaultParcel)
688 { 656 {
689 List<ILandObject> parcels; 657 Dictionary<int, ILandObject> landworkList;
658 // move to work pointer since we are deleting it all
690 lock (m_landList) 659 lock (m_landList)
691 { 660 {
692 parcels = new List<ILandObject>(m_landList.Values); 661 landworkList = m_landList;
662 m_landList = new Dictionary<int, ILandObject>();
693 } 663 }
694 664
695 foreach (ILandObject lo in parcels) 665 // this 2 methods have locks (now)
666 ResetSimLandObjects();
667
668 if (setupDefaultParcel)
669 CreateDefaultParcel();
670
671 // fire outside events unlocked
672 foreach (ILandObject lo in landworkList.Values)
696 { 673 {
697 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); 674 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
698 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID); 675 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
699 } 676 }
677 landworkList.Clear();
700 678
701 lock (m_landList)
702 {
703 m_landList.Clear();
704
705 ResetSimLandObjects();
706 }
707
708 if (setupDefaultParcel)
709 CreateDefaultParcel();
710 } 679 }
711 680
712 private void performFinalLandJoin(ILandObject master, ILandObject slave) 681 private void performFinalLandJoin(ILandObject master, ILandObject slave)
@@ -753,7 +722,7 @@ namespace OpenSim.Region.CoreModules.World.Land
753 int x; 722 int x;
754 int y; 723 int y;
755 724
756 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 725 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
757 return null; 726 return null;
758 727
759 try 728 try
@@ -803,14 +772,13 @@ namespace OpenSim.Region.CoreModules.World.Land
803 { 772 {
804 try 773 try
805 { 774 {
806 return m_landList[m_landIDList[x / 4, y / 4]]; 775 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
776 return m_landList[m_landIDList[x / 4, y / 4]];
777 //else
778 // return null;
807 } 779 }
808 catch (IndexOutOfRangeException) 780 catch (IndexOutOfRangeException)
809 { 781 {
810// m_log.WarnFormat(
811// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
812// x, y, m_scene.RegionInfo.RegionName);
813
814 return null; 782 return null;
815 } 783 }
816 } 784 }
@@ -1094,6 +1062,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1094 //Owner Flag 1062 //Owner Flag
1095 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 1063 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1096 } 1064 }
1065 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1066 {
1067 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1068 }
1097 else if (currentParcelBlock.LandData.SalePrice > 0 && 1069 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1098 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1070 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1099 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1071 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1174,8 +1146,11 @@ namespace OpenSim.Region.CoreModules.World.Land
1174 { 1146 {
1175 if (!temp.Contains(currentParcel)) 1147 if (!temp.Contains(currentParcel))
1176 { 1148 {
1177 currentParcel.ForceUpdateLandInfo(); 1149 if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId))
1178 temp.Add(currentParcel); 1150 {
1151 currentParcel.ForceUpdateLandInfo();
1152 temp.Add(currentParcel);
1153 }
1179 } 1154 }
1180 } 1155 }
1181 } 1156 }
@@ -1394,8 +1369,26 @@ namespace OpenSim.Region.CoreModules.World.Land
1394 1369
1395 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1370 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1396 { 1371 {
1397// m_log.DebugFormat( 1372 Dictionary<int, ILandObject> landworkList;
1398// "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); 1373 // move to work pointer since we are deleting it all
1374 lock (m_landList)
1375 {
1376 landworkList = m_landList;
1377 m_landList = new Dictionary<int, ILandObject>();
1378 }
1379
1380 //Remove all the land objects in the sim and then process our new data
1381 foreach (int n in landworkList.Keys)
1382 {
1383 m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID);
1384 }
1385 landworkList.Clear();
1386
1387 lock (m_landList)
1388 {
1389 m_landIDList.Initialize();
1390 m_landList.Clear();
1391 }
1399 1392
1400 for (int i = 0; i < data.Count; i++) 1393 for (int i = 0; i < data.Count; i++)
1401 IncomingLandObjectFromStorage(data[i]); 1394 IncomingLandObjectFromStorage(data[i]);
@@ -1403,10 +1396,12 @@ namespace OpenSim.Region.CoreModules.World.Land
1403 1396
1404 public void IncomingLandObjectFromStorage(LandData data) 1397 public void IncomingLandObjectFromStorage(LandData data)
1405 { 1398 {
1399
1406 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1400 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1407 new_land.LandData = data.Copy(); 1401 new_land.LandData = data.Copy();
1408 new_land.SetLandBitmapFromByteArray(); 1402 new_land.SetLandBitmapFromByteArray();
1409 AddLandObject(new_land); 1403 AddLandObject(new_land);
1404 new_land.SendLandUpdateToAvatarsOverMe();
1410 } 1405 }
1411 1406
1412 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1407 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1737,6 +1732,168 @@ namespace OpenSim.Region.CoreModules.World.Land
1737 1732
1738 UpdateLandObject(localID, land.LandData); 1733 UpdateLandObject(localID, land.LandData);
1739 } 1734 }
1735
1736 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1737 {
1738 ILandObject land = null;
1739 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1740 foreach (ILandObject landObject in Land)
1741 {
1742 if (landObject.LandData.LocalID == landID)
1743 {
1744 land = landObject;
1745 }
1746 }
1747 land.DeedToGroup(DefaultGodParcelGroup);
1748 land.LandData.Name = DefaultGodParcelName;
1749 land.SendLandUpdateToAvatarsOverMe();
1750 }
1751
1752 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1753 {
1754 ScenePresence SP;
1755 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1756 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1757 if (SP.UserLevel != 0)
1758 {
1759 if (flags == 0) //All parcels, scripted or not
1760 {
1761 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1762 {
1763 if (e.OwnerID == targetID)
1764 {
1765 returns.Add(e);
1766 }
1767 }
1768 );
1769 }
1770 if (flags == 4) //All parcels, scripted object
1771 {
1772 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1773 {
1774 if (e.OwnerID == targetID)
1775 {
1776 if (e.ContainsScripts())
1777 {
1778 returns.Add(e);
1779 }
1780 }
1781 }
1782 );
1783 }
1784 if (flags == 4) //not target parcel, scripted object
1785 {
1786 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1787 {
1788 if (e.OwnerID == targetID)
1789 {
1790 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1791 if (landobject.LandData.OwnerID != e.OwnerID)
1792 {
1793 if (e.ContainsScripts())
1794 {
1795 returns.Add(e);
1796 }
1797 }
1798 }
1799 }
1800 );
1801 }
1802 foreach (SceneObjectGroup ol in returns)
1803 {
1804 ReturnObject(ol, client);
1805 }
1806 }
1807 }
1808 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1809 {
1810 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1811 objs[0] = obj;
1812 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1813 }
1814
1815 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1816
1817 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1818 {
1819 ScenePresence targetAvatar = null;
1820 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1821 ScenePresence parcelManager = null;
1822 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1823 System.Threading.Timer Timer;
1824
1825 if (targetAvatar.UserLevel == 0)
1826 {
1827 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1828 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1829 return;
1830 if (flags == 0)
1831 {
1832 targetAvatar.AllowMovement = false;
1833 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1834 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1835 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1836 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1837 Timers.Add(targetAvatar.UUID, Timer);
1838 }
1839 else
1840 {
1841 targetAvatar.AllowMovement = true;
1842 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1843 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1844 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1845 Timers.Remove(targetAvatar.UUID);
1846 Timer.Dispose();
1847 }
1848 }
1849 }
1850 private void OnEndParcelFrozen(object avatar)
1851 {
1852 ScenePresence targetAvatar = (ScenePresence)avatar;
1853 targetAvatar.AllowMovement = true;
1854 System.Threading.Timer Timer;
1855 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1856 Timers.Remove(targetAvatar.UUID);
1857 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1858 }
1859
1860
1861 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1862 {
1863 ScenePresence targetAvatar = null;
1864 ScenePresence parcelManager = null;
1865
1866 // Must have presences
1867 if (!m_scene.TryGetScenePresence(target, out targetAvatar) ||
1868 !m_scene.TryGetScenePresence(client.AgentId, out parcelManager))
1869 return;
1870
1871 // Cannot eject estate managers or gods
1872 if (m_scene.Permissions.IsAdministrator(target))
1873 return;
1874
1875 // Check if you even have permission to do this
1876 ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1877 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) &&
1878 !m_scene.Permissions.IsAdministrator(client.AgentId))
1879 return;
1880
1881 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
1882
1883 targetAvatar.TeleportWithMomentum(pos, null);
1884 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1885 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1886
1887 if ((flags & 1) != 0) // Ban TODO: Remove magic number
1888 {
1889 LandAccessEntry entry = new LandAccessEntry();
1890 entry.AgentID = targetAvatar.UUID;
1891 entry.Flags = AccessList.Ban;
1892 entry.Expires = 0; // Perm
1893
1894 land.LandData.ParcelAccessList.Add(entry);
1895 }
1896 }
1740 1897
1741 protected void InstallInterfaces() 1898 protected void InstallInterfaces()
1742 { 1899 {
@@ -1799,5 +1956,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1799 1956
1800 MainConsole.Instance.Output(report.ToString()); 1957 MainConsole.Instance.Output(report.ToString());
1801 } 1958 }
1959
1960 public void EnforceBans(ILandObject land, ScenePresence avatar)
1961 {
1962 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
1963 return;
1964
1965 if (land.IsEitherBannedOrRestricted(avatar.UUID))
1966 {
1967 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
1968 {
1969 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
1970 if (pos == null)
1971 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
1972 else
1973 ForceAvatarToPosition(avatar, (Vector3)pos);
1974 }
1975 else
1976 {
1977 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
1978 }
1979 }
1980 }
1802 } 1981 }
1803} 1982}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 5969d45..07d00c0 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 }
@@ -249,7 +270,7 @@ namespace OpenSim.Region.CoreModules.World.Land
249 remote_client.SendLandProperties(seq_id, 270 remote_client.SendLandProperties(seq_id,
250 snap_selection, request_result, this, 271 snap_selection, request_result, this,
251 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 272 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
252 GetParcelMaxPrimCount(), 273 GetParcelBasePrimCount(),
253 GetSimulatorMaxPrimCount(), regionFlags); 274 GetSimulatorMaxPrimCount(), regionFlags);
254 } 275 }
255 276
@@ -309,7 +330,7 @@ namespace OpenSim.Region.CoreModules.World.Land
309 330
310 allowedDelta |= (uint)(ParcelFlags.ShowDirectory | 331 allowedDelta |= (uint)(ParcelFlags.ShowDirectory |
311 ParcelFlags.AllowPublish | 332 ParcelFlags.AllowPublish |
312 ParcelFlags.MaturePublish); 333 ParcelFlags.MaturePublish) | (uint)(1 << 23);
313 } 334 }
314 335
315 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) 336 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity))
@@ -421,6 +442,19 @@ namespace OpenSim.Region.CoreModules.World.Land
421 return false; 442 return false;
422 } 443 }
423 444
445 public bool CanBeOnThisLand(UUID avatar, float posHeight)
446 {
447 if (posHeight < LandChannel.BAN_LINE_SAFETY_HIEGHT && IsBannedFromLand(avatar))
448 {
449 return false;
450 }
451 else if (IsRestrictedFromLand(avatar))
452 {
453 return false;
454 }
455 return true;
456 }
457
424 public bool HasGroupAccess(UUID avatar) 458 public bool HasGroupAccess(UUID avatar)
425 { 459 {
426 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup) 460 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
@@ -1185,6 +1219,17 @@ namespace OpenSim.Region.CoreModules.World.Land
1185 1219
1186 #endregion 1220 #endregion
1187 1221
1222 private void OnFrame()
1223 {
1224 m_expiryCounter++;
1225
1226 if (m_expiryCounter >= 50)
1227 {
1228 ExpireAccessList();
1229 m_expiryCounter = 0;
1230 }
1231 }
1232
1188 private void ExpireAccessList() 1233 private void ExpireAccessList()
1189 { 1234 {
1190 List<LandAccessEntry> delete = new List<LandAccessEntry>(); 1235 List<LandAccessEntry> delete = new List<LandAccessEntry>();
@@ -1195,7 +1240,22 @@ namespace OpenSim.Region.CoreModules.World.Land
1195 delete.Add(entry); 1240 delete.Add(entry);
1196 } 1241 }
1197 foreach (LandAccessEntry entry in delete) 1242 foreach (LandAccessEntry entry in delete)
1243 {
1198 LandData.ParcelAccessList.Remove(entry); 1244 LandData.ParcelAccessList.Remove(entry);
1245 ScenePresence presence;
1246
1247 if (m_scene.TryGetScenePresence(entry.AgentID, out presence) && (!presence.IsChildAgent))
1248 {
1249 ILandObject land = m_scene.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
1250 if (land.LandData.LocalID == LandData.LocalID)
1251 {
1252 Vector3 pos = m_scene.GetNearestAllowedPosition(presence, land);
1253 presence.TeleportWithMomentum(pos, null);
1254 presence.ControllingClient.SendAlertMessage("You have been ejected from this land");
1255 }
1256 }
1257 m_log.DebugFormat("[LAND]: Removing entry {0} because it has expired", entry.AgentID);
1258 }
1199 1259
1200 if (delete.Count > 0) 1260 if (delete.Count > 0)
1201 m_scene.EventManager.TriggerLandObjectUpdated((uint)LandData.LocalID, this); 1261 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}