aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs328
1 files changed, 237 insertions, 91 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 8b7406d..51dcb67 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -91,14 +91,13 @@ namespace OpenSim.Region.CoreModules.World.Land
91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
92 92
93 private bool m_allowedForcefulBans = true; 93 private bool m_allowedForcefulBans = true;
94 private UUID DefaultGodParcelGroup;
95 private string DefaultGodParcelName;
94 96
95 // caches ExtendedLandData 97 // caches ExtendedLandData
96 private Cache parcelInfoCache; 98 private Cache parcelInfoCache;
97 99 private Dictionary<UUID, Vector3> forcedPosition =
98 /// <summary> 100 new Dictionary<UUID, Vector3>();
99 /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions.
100 /// </summary>
101 private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>();
102 101
103 #region INonSharedRegionModule Members 102 #region INonSharedRegionModule Members
104 103
@@ -109,6 +108,12 @@ namespace OpenSim.Region.CoreModules.World.Land
109 108
110 public void Initialise(IConfigSource source) 109 public void Initialise(IConfigSource source)
111 { 110 {
111 IConfig cnf = source.Configs["LandManagement"];
112 if (cnf != null)
113 {
114 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
115 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
116 }
112 } 117 }
113 118
114 public void AddRegion(Scene scene) 119 public void AddRegion(Scene scene)
@@ -160,13 +165,6 @@ namespace OpenSim.Region.CoreModules.World.Land
160 m_scene.UnregisterModuleCommander(m_commander.Name); 165 m_scene.UnregisterModuleCommander(m_commander.Name);
161 } 166 }
162 167
163// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
164// {
165// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
166// reason = "You are not allowed to enter this sim.";
167// return nearestParcel != null;
168// }
169
170 /// <summary> 168 /// <summary>
171 /// Processes commandline input. Do not call directly. 169 /// Processes commandline input. Do not call directly.
172 /// </summary> 170 /// </summary>
@@ -207,6 +205,8 @@ namespace OpenSim.Region.CoreModules.World.Land
207 client.OnParcelInfoRequest += ClientOnParcelInfoRequest; 205 client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
208 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; 206 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
209 client.OnPreAgentUpdate += ClientOnPreAgentUpdate; 207 client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
208 client.OnParcelEjectUser += ClientOnParcelEjectUser;
209 client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
210 210
211 EntityBase presenceEntity; 211 EntityBase presenceEntity;
212 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) 212 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -218,48 +218,6 @@ namespace OpenSim.Region.CoreModules.World.Land
218 218
219 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 219 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
220 { 220 {
221 //If we are forcing a position for them to go
222 if (forcedPosition.ContainsKey(remoteClient.AgentId))
223 {
224 ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
225
226 //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
227 //When the avatar walks into a ban line on the ground, it prevents getting stuck
228 agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
229
230 //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
231 if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
232 {
233// m_log.DebugFormat(
234// "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}",
235// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
236
237 forcedPosition.Remove(remoteClient.AgentId);
238 }
239 //if we are far away, teleport
240 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
241 {
242 Vector3 forcePosition = forcedPosition[remoteClient.AgentId];
243// m_log.DebugFormat(
244// "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}",
245// clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition);
246
247 m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle,
248 forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect);
249
250 forcedPosition.Remove(remoteClient.AgentId);
251 }
252 else
253 {
254// m_log.DebugFormat(
255// "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}",
256// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
257
258 //Forces them toward the forced position we want if they aren't there yet
259 agentData.UseClientAgentPosition = true;
260 agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
261 }
262 }
263 } 221 }
264 222
265 public void Close() 223 public void Close()
@@ -378,10 +336,16 @@ namespace OpenSim.Region.CoreModules.World.Land
378 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 336 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
379 { 337 {
380 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 338 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
381 if (position.HasValue) 339
382 { 340 if (!position.HasValue)
383 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 341 return;
384 } 342
343 bool isFlying = avatar.PhysicsActor.Flying;
344 avatar.RemoveFromPhysicalScene();
345
346 avatar.AbsolutePosition = (Vector3)position;
347
348 avatar.AddToPhysicalScene(isFlying);
385 } 349 }
386 350
387 public void SendYouAreRestrictedNotice(ScenePresence avatar) 351 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -401,29 +365,7 @@ namespace OpenSim.Region.CoreModules.World.Land
401 } 365 }
402 366
403 if (parcelAvatarIsEntering != null) 367 if (parcelAvatarIsEntering != null)
404 { 368 EnforceBans(parcelAvatarIsEntering, avatar);
405 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
406 {
407 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
408 {
409 SendYouAreBannedNotice(avatar);
410 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
411 }
412 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
413 {
414 SendYouAreRestrictedNotice(avatar);
415 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
416 }
417 else
418 {
419 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
420 }
421 }
422 else
423 {
424 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
425 }
426 }
427 } 369 }
428 } 370 }
429 371
@@ -527,6 +469,7 @@ namespace OpenSim.Region.CoreModules.World.Land
527 //when we are finally in a safe place, lets release the forced position lock 469 //when we are finally in a safe place, lets release the forced position lock
528 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); 470 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
529 } 471 }
472 EnforceBans(parcel, clientAvatar);
530 } 473 }
531 } 474 }
532 475
@@ -735,7 +678,7 @@ namespace OpenSim.Region.CoreModules.World.Land
735 int x; 678 int x;
736 int y; 679 int y;
737 680
738 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 681 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
739 return null; 682 return null;
740 683
741 try 684 try
@@ -785,14 +728,13 @@ namespace OpenSim.Region.CoreModules.World.Land
785 { 728 {
786 try 729 try
787 { 730 {
788 return m_landList[m_landIDList[x / 4, y / 4]]; 731 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
732 return m_landList[m_landIDList[x / 4, y / 4]];
733 //else
734 // return null;
789 } 735 }
790 catch (IndexOutOfRangeException) 736 catch (IndexOutOfRangeException)
791 { 737 {
792// m_log.WarnFormat(
793// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
794// x, y, m_scene.RegionInfo.RegionName);
795
796 return null; 738 return null;
797 } 739 }
798 } 740 }
@@ -1075,6 +1017,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1075 //Owner Flag 1017 //Owner Flag
1076 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 1018 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1077 } 1019 }
1020 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1021 {
1022 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1023 }
1078 else if (currentParcelBlock.LandData.SalePrice > 0 && 1024 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1079 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1025 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1080 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1026 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1155,8 +1101,11 @@ namespace OpenSim.Region.CoreModules.World.Land
1155 { 1101 {
1156 if (!temp.Contains(currentParcel)) 1102 if (!temp.Contains(currentParcel))
1157 { 1103 {
1158 currentParcel.ForceUpdateLandInfo(); 1104 if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId))
1159 temp.Add(currentParcel); 1105 {
1106 currentParcel.ForceUpdateLandInfo();
1107 temp.Add(currentParcel);
1108 }
1160 } 1109 }
1161 } 1110 }
1162 } 1111 }
@@ -1375,18 +1324,31 @@ namespace OpenSim.Region.CoreModules.World.Land
1375 1324
1376 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1325 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1377 { 1326 {
1378 for (int i = 0; i < data.Count; i++) 1327 lock (m_landList)
1379 { 1328 {
1380 IncomingLandObjectFromStorage(data[i]); 1329 //Remove all the land objects in the sim and then process our new data
1330 foreach (int n in m_landList.Keys)
1331 {
1332 m_scene.EventManager.TriggerLandObjectRemoved(m_landList[n].LandData.GlobalID);
1333 }
1334 m_landIDList.Initialize();
1335 m_landList.Clear();
1336
1337 for (int i = 0; i < data.Count; i++)
1338 {
1339 IncomingLandObjectFromStorage(data[i]);
1340 }
1381 } 1341 }
1382 } 1342 }
1383 1343
1384 public void IncomingLandObjectFromStorage(LandData data) 1344 public void IncomingLandObjectFromStorage(LandData data)
1385 { 1345 {
1346
1386 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1347 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1387 new_land.LandData = data.Copy(); 1348 new_land.LandData = data.Copy();
1388 new_land.SetLandBitmapFromByteArray(); 1349 new_land.SetLandBitmapFromByteArray();
1389 AddLandObject(new_land); 1350 AddLandObject(new_land);
1351 new_land.SendLandUpdateToAvatarsOverMe();
1390 } 1352 }
1391 1353
1392 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1354 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1669,6 +1631,168 @@ namespace OpenSim.Region.CoreModules.World.Land
1669 1631
1670 UpdateLandObject(localID, land.LandData); 1632 UpdateLandObject(localID, land.LandData);
1671 } 1633 }
1634
1635 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1636 {
1637 ILandObject land = null;
1638 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1639 foreach (ILandObject landObject in Land)
1640 {
1641 if (landObject.LandData.LocalID == landID)
1642 {
1643 land = landObject;
1644 }
1645 }
1646 land.DeedToGroup(DefaultGodParcelGroup);
1647 land.LandData.Name = DefaultGodParcelName;
1648 land.SendLandUpdateToAvatarsOverMe();
1649 }
1650
1651 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1652 {
1653 ScenePresence SP;
1654 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1655 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1656 if (SP.UserLevel != 0)
1657 {
1658 if (flags == 0) //All parcels, scripted or not
1659 {
1660 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1661 {
1662 if (e.OwnerID == targetID)
1663 {
1664 returns.Add(e);
1665 }
1666 }
1667 );
1668 }
1669 if (flags == 4) //All parcels, scripted object
1670 {
1671 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1672 {
1673 if (e.OwnerID == targetID)
1674 {
1675 if (e.ContainsScripts())
1676 {
1677 returns.Add(e);
1678 }
1679 }
1680 }
1681 );
1682 }
1683 if (flags == 4) //not target parcel, scripted object
1684 {
1685 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1686 {
1687 if (e.OwnerID == targetID)
1688 {
1689 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1690 if (landobject.LandData.OwnerID != e.OwnerID)
1691 {
1692 if (e.ContainsScripts())
1693 {
1694 returns.Add(e);
1695 }
1696 }
1697 }
1698 }
1699 );
1700 }
1701 foreach (SceneObjectGroup ol in returns)
1702 {
1703 ReturnObject(ol, client);
1704 }
1705 }
1706 }
1707 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1708 {
1709 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1710 objs[0] = obj;
1711 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1712 }
1713
1714 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1715
1716 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1717 {
1718 ScenePresence targetAvatar = null;
1719 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1720 ScenePresence parcelManager = null;
1721 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1722 System.Threading.Timer Timer;
1723
1724 if (targetAvatar.UserLevel == 0)
1725 {
1726 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1727 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1728 return;
1729 if (flags == 0)
1730 {
1731 targetAvatar.AllowMovement = false;
1732 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1733 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1734 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1735 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1736 Timers.Add(targetAvatar.UUID, Timer);
1737 }
1738 else
1739 {
1740 targetAvatar.AllowMovement = true;
1741 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1742 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1743 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1744 Timers.Remove(targetAvatar.UUID);
1745 Timer.Dispose();
1746 }
1747 }
1748 }
1749 private void OnEndParcelFrozen(object avatar)
1750 {
1751 ScenePresence targetAvatar = (ScenePresence)avatar;
1752 targetAvatar.AllowMovement = true;
1753 System.Threading.Timer Timer;
1754 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1755 Timers.Remove(targetAvatar.UUID);
1756 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1757 }
1758
1759
1760 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1761 {
1762 ScenePresence targetAvatar = null;
1763 ScenePresence parcelManager = null;
1764
1765 // Must have presences
1766 if (!m_scene.TryGetScenePresence(target, out targetAvatar) ||
1767 !m_scene.TryGetScenePresence(client.AgentId, out parcelManager))
1768 return;
1769
1770 // Cannot eject estate managers or gods
1771 if (m_scene.Permissions.IsAdministrator(target))
1772 return;
1773
1774 // Check if you even have permission to do this
1775 ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1776 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) &&
1777 !m_scene.Permissions.IsAdministrator(client.AgentId))
1778 return;
1779
1780 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
1781
1782 targetAvatar.TeleportWithMomentum(pos, null);
1783 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1784 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1785
1786 if ((flags & 1) != 0) // Ban TODO: Remove magic number
1787 {
1788 LandAccessEntry entry = new LandAccessEntry();
1789 entry.AgentID = targetAvatar.UUID;
1790 entry.Flags = AccessList.Ban;
1791 entry.Expires = 0; // Perm
1792
1793 land.LandData.ParcelAccessList.Add(entry);
1794 }
1795 }
1672 1796
1673 protected void InstallInterfaces() 1797 protected void InstallInterfaces()
1674 { 1798 {
@@ -1731,5 +1855,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1731 1855
1732 MainConsole.Instance.Output(report.ToString()); 1856 MainConsole.Instance.Output(report.ToString());
1733 } 1857 }
1858
1859 public void EnforceBans(ILandObject land, ScenePresence avatar)
1860 {
1861 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
1862 return;
1863
1864 if (land.IsEitherBannedOrRestricted(avatar.UUID))
1865 {
1866 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
1867 {
1868 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
1869 if (pos == null)
1870 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
1871 else
1872 ForceAvatarToPosition(avatar, (Vector3)pos);
1873 }
1874 else
1875 {
1876 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
1877 }
1878 }
1879 }
1734 } 1880 }
1735} 1881}