diff options
author | Melanie | 2012-02-02 16:51:39 +0100 |
---|---|---|
committer | Melanie | 2012-02-02 16:51:39 +0100 |
commit | fd7e82ee7237617a8e19b1eede3cf5164a587a67 (patch) | |
tree | e8d276c26bab115b819e82140e893d4d9fc754d4 /OpenSim | |
parent | Rehook the eject and freeze events that had gotten unhooked in the merge (diff) | |
download | opensim-SC-fd7e82ee7237617a8e19b1eede3cf5164a587a67.zip opensim-SC-fd7e82ee7237617a8e19b1eede3cf5164a587a67.tar.gz opensim-SC-fd7e82ee7237617a8e19b1eede3cf5164a587a67.tar.bz2 opensim-SC-fd7e82ee7237617a8e19b1eede3cf5164a587a67.tar.xz |
Streamline banning code using existing methods.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 212 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 16 |
2 files changed, 42 insertions, 186 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 400e453..5db56b0 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -1752,191 +1752,37 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1752 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | 1752 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) |
1753 | { | 1753 | { |
1754 | ScenePresence targetAvatar = null; | 1754 | ScenePresence targetAvatar = null; |
1755 | ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar); | ||
1756 | ScenePresence parcelManager = null; | 1755 | ScenePresence parcelManager = null; |
1757 | ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager); | 1756 | |
1758 | //Just eject | 1757 | // Must have presences |
1759 | if (flags == 0) | 1758 | if (!m_scene.TryGetScenePresence(target, out targetAvatar) || |
1760 | { | 1759 | !m_scene.TryGetScenePresence(client.AgentId, out parcelManager)) |
1761 | if (targetAvatar.UserLevel == 0) | 1760 | return; |
1762 | { | 1761 | |
1763 | ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); | 1762 | // Cannot eject estate managers or gods |
1764 | if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze)) | 1763 | if (m_scene.Permissions.IsAdministrator(target)) |
1765 | return; | 1764 | return; |
1766 | 1765 | ||
1767 | Vector3 position = new Vector3(0, 0, 0); | 1766 | // Check if you even have permission to do this |
1768 | List<ILandObject> allParcels = new List<ILandObject>(); | 1767 | ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); |
1769 | allParcels = AllParcels(); | 1768 | if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) && |
1770 | if (allParcels.Count != 1) | 1769 | !m_scene.Permissions.IsAdministrator(client.AgentId)) |
1771 | { | 1770 | return; |
1772 | foreach (ILandObject parcel in allParcels) | 1771 | |
1773 | { | 1772 | Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land); |
1774 | if (parcel.LandData.GlobalID != land.LandData.GlobalID) | 1773 | |
1775 | { | 1774 | targetAvatar.TeleportWithMomentum(pos); |
1776 | if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true) | 1775 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); |
1777 | { | 1776 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); |
1778 | for (int x = 1; x <= Constants.RegionSize; x += 2) | 1777 | |
1779 | { | 1778 | if ((flags & 1) != 0) // Ban TODO: Remove magic number |
1780 | for (int y = 1; y <= Constants.RegionSize; y += 2) | ||
1781 | { | ||
1782 | if (parcel.ContainsPoint(x, y)) | ||
1783 | { | ||
1784 | position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z); | ||
1785 | targetAvatar.TeleportWithMomentum(position); | ||
1786 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1787 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | ||
1788 | return; | ||
1789 | } | ||
1790 | } | ||
1791 | } | ||
1792 | } | ||
1793 | } | ||
1794 | } | ||
1795 | } | ||
1796 | Vector3 targetVector; | ||
1797 | if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y) | ||
1798 | { | ||
1799 | if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize) | ||
1800 | { | ||
1801 | targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ; | ||
1802 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1803 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1804 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | ||
1805 | return; | ||
1806 | } | ||
1807 | else | ||
1808 | { | ||
1809 | targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ; | ||
1810 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1811 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1812 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | ||
1813 | return; | ||
1814 | } | ||
1815 | } | ||
1816 | else | ||
1817 | { | ||
1818 | if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize) | ||
1819 | { | ||
1820 | targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ; | ||
1821 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1822 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1823 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | ||
1824 | return; | ||
1825 | } | ||
1826 | else | ||
1827 | { | ||
1828 | targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ; | ||
1829 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1830 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1831 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected."); | ||
1832 | return; | ||
1833 | } | ||
1834 | } | ||
1835 | } | ||
1836 | } | ||
1837 | //Eject and ban | ||
1838 | if (flags == 1) | ||
1839 | { | 1779 | { |
1840 | if (targetAvatar.UserLevel == 0) | 1780 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); |
1841 | { | 1781 | entry.AgentID = targetAvatar.UUID; |
1842 | ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y); | 1782 | entry.Flags = AccessList.Ban; |
1843 | if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze)) | 1783 | entry.Time = new DateTime(); |
1844 | return; | 1784 | |
1845 | 1785 | land.LandData.ParcelAccessList.Add(entry); | |
1846 | Vector3 position = new Vector3(0, 0, 0); | ||
1847 | List<ILandObject> allParcels = new List<ILandObject>(); | ||
1848 | allParcels = AllParcels(); | ||
1849 | if (allParcels.Count != 1) | ||
1850 | { | ||
1851 | foreach (ILandObject parcel in allParcels) | ||
1852 | { | ||
1853 | if (parcel.LandData.GlobalID != land.LandData.GlobalID) | ||
1854 | { | ||
1855 | if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true) | ||
1856 | { | ||
1857 | for (int x = 1; x <= Constants.RegionSize; x += 2) | ||
1858 | { | ||
1859 | for (int y = 1; y <= Constants.RegionSize; y += 2) | ||
1860 | { | ||
1861 | if (parcel.ContainsPoint(x, y)) | ||
1862 | { | ||
1863 | position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z); | ||
1864 | targetAvatar.TeleportWithMomentum(position); | ||
1865 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1866 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned."); | ||
1867 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
1868 | entry.AgentID = targetAvatar.UUID; | ||
1869 | entry.Flags = AccessList.Ban; | ||
1870 | entry.Time = new DateTime(); | ||
1871 | land.LandData.ParcelAccessList.Add(entry); | ||
1872 | return; | ||
1873 | } | ||
1874 | } | ||
1875 | } | ||
1876 | } | ||
1877 | } | ||
1878 | } | ||
1879 | } | ||
1880 | Vector3 targetVector; | ||
1881 | if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y) | ||
1882 | { | ||
1883 | if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize) | ||
1884 | { | ||
1885 | targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ; | ||
1886 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1887 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1888 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned."); | ||
1889 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
1890 | entry.AgentID = targetAvatar.UUID; | ||
1891 | entry.Flags = AccessList.Ban; | ||
1892 | entry.Time = new DateTime(); | ||
1893 | land.LandData.ParcelAccessList.Add(entry); | ||
1894 | return; | ||
1895 | } | ||
1896 | else | ||
1897 | { | ||
1898 | targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ; | ||
1899 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1900 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1901 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned."); | ||
1902 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
1903 | entry.AgentID = targetAvatar.UUID; | ||
1904 | entry.Flags = AccessList.Ban; | ||
1905 | entry.Time = new DateTime(); | ||
1906 | land.LandData.ParcelAccessList.Add(entry); | ||
1907 | return; | ||
1908 | } | ||
1909 | } | ||
1910 | else | ||
1911 | { | ||
1912 | if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize) | ||
1913 | { | ||
1914 | targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ; | ||
1915 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1916 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1917 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned."); | ||
1918 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
1919 | entry.AgentID = targetAvatar.UUID; | ||
1920 | entry.Flags = AccessList.Ban; | ||
1921 | entry.Time = new DateTime(); | ||
1922 | land.LandData.ParcelAccessList.Add(entry); | ||
1923 | return; | ||
1924 | } | ||
1925 | else | ||
1926 | { | ||
1927 | targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ; | ||
1928 | targetAvatar.TeleportWithMomentum(targetVector); | ||
1929 | targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname); | ||
1930 | parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned."); | ||
1931 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
1932 | entry.AgentID = targetAvatar.UUID; | ||
1933 | entry.Flags = AccessList.Ban; | ||
1934 | entry.Time = new DateTime(); | ||
1935 | land.LandData.ParcelAccessList.Add(entry); | ||
1936 | return; | ||
1937 | } | ||
1938 | } | ||
1939 | } | ||
1940 | } | 1786 | } |
1941 | } | 1787 | } |
1942 | 1788 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b37df82..128954f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4855,9 +4855,14 @@ Environment.Exit(1); | |||
4855 | get { return m_allowScriptCrossings; } | 4855 | get { return m_allowScriptCrossings; } |
4856 | } | 4856 | } |
4857 | 4857 | ||
4858 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 4858 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4859 | { | 4859 | { |
4860 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 4860 | return GetNearestAllowedPosition(avatar, null); |
4861 | } | ||
4862 | |||
4863 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4864 | { | ||
4865 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
4861 | 4866 | ||
4862 | if (nearestParcel != null) | 4867 | if (nearestParcel != null) |
4863 | { | 4868 | { |
@@ -4916,13 +4921,18 @@ Environment.Exit(1); | |||
4916 | 4921 | ||
4917 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 4922 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4918 | { | 4923 | { |
4924 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
4925 | } | ||
4926 | |||
4927 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
4928 | { | ||
4919 | List<ILandObject> all = AllParcels(); | 4929 | List<ILandObject> all = AllParcels(); |
4920 | float minParcelDistance = float.MaxValue; | 4930 | float minParcelDistance = float.MaxValue; |
4921 | ILandObject nearestParcel = null; | 4931 | ILandObject nearestParcel = null; |
4922 | 4932 | ||
4923 | foreach (var parcel in all) | 4933 | foreach (var parcel in all) |
4924 | { | 4934 | { |
4925 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 4935 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4926 | { | 4936 | { |
4927 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 4937 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4928 | if (parcelDistance < minParcelDistance) | 4938 | if (parcelDistance < minParcelDistance) |