aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2013-04-25 00:24:48 +0100
committerMelanie2013-04-25 00:24:48 +0100
commit6f3c905744e674f3cca555a4d36ede2139fcb9d7 (patch)
tree52a79ea2f9b6f4c71b9999c128455a629514a06b /OpenSim/Region
parentBulletSim: version of libBulletSim.so for 32 bit systems that doesn't (diff)
downloadopensim-SC-6f3c905744e674f3cca555a4d36ede2139fcb9d7.zip
opensim-SC-6f3c905744e674f3cca555a4d36ede2139fcb9d7.tar.gz
opensim-SC-6f3c905744e674f3cca555a4d36ede2139fcb9d7.tar.bz2
opensim-SC-6f3c905744e674f3cca555a4d36ede2139fcb9d7.tar.xz
Add Avination's support for parcel eject and freeze
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs85
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs40
2 files changed, 110 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index dbf5138..693de1d 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -210,6 +210,9 @@ namespace OpenSim.Region.CoreModules.World.Land
210 client.OnParcelInfoRequest += ClientOnParcelInfoRequest; 210 client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
211 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; 211 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
212 client.OnPreAgentUpdate += ClientOnPreAgentUpdate; 212 client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
213 client.OnParcelEjectUser += ClientOnParcelEjectUser;
214 client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
215
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)
@@ -1738,6 +1741,88 @@ namespace OpenSim.Region.CoreModules.World.Land
1738 UpdateLandObject(localID, land.LandData); 1741 UpdateLandObject(localID, land.LandData);
1739 } 1742 }
1740 1743
1744 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1745
1746 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1747 {
1748 ScenePresence targetAvatar = null;
1749 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1750 ScenePresence parcelManager = null;
1751 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1752 System.Threading.Timer Timer;
1753
1754 if (targetAvatar.UserLevel == 0)
1755 {
1756 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1757 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1758 return;
1759 if (flags == 0)
1760 {
1761 targetAvatar.AllowMovement = false;
1762 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1763 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1764 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1765 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1766 Timers.Add(targetAvatar.UUID, Timer);
1767 }
1768 else
1769 {
1770 targetAvatar.AllowMovement = true;
1771 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1772 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1773 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1774 Timers.Remove(targetAvatar.UUID);
1775 Timer.Dispose();
1776 }
1777 }
1778 }
1779
1780 private void OnEndParcelFrozen(object avatar)
1781 {
1782 ScenePresence targetAvatar = (ScenePresence)avatar;
1783 targetAvatar.AllowMovement = true;
1784 System.Threading.Timer Timer;
1785 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1786 Timers.Remove(targetAvatar.UUID);
1787 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1788 }
1789
1790 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1791 {
1792 ScenePresence targetAvatar = null;
1793 ScenePresence parcelManager = null;
1794
1795 // Must have presences
1796 if (!m_scene.TryGetScenePresence(target, out targetAvatar) ||
1797 !m_scene.TryGetScenePresence(client.AgentId, out parcelManager))
1798 return;
1799
1800 // Cannot eject estate managers or gods
1801 if (m_scene.Permissions.IsAdministrator(target))
1802 return;
1803
1804 // Check if you even have permission to do this
1805 ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1806 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) &&
1807 !m_scene.Permissions.IsAdministrator(client.AgentId))
1808 return;
1809 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
1810
1811 targetAvatar.TeleportWithMomentum(pos, null);
1812 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1813 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1814
1815 if ((flags & 1) != 0) // Ban TODO: Remove magic number
1816 {
1817 LandAccessEntry entry = new LandAccessEntry();
1818 entry.AgentID = targetAvatar.UUID;
1819 entry.Flags = AccessList.Ban;
1820 entry.Expires = 0; // Perm
1821
1822 land.LandData.ParcelAccessList.Add(entry);
1823 }
1824 }
1825
1741 protected void InstallInterfaces() 1826 protected void InstallInterfaces()
1742 { 1827 {
1743 Command clearCommand 1828 Command clearCommand
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f50d3cd..69fe137 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5138,9 +5138,14 @@ namespace OpenSim.Region.Framework.Scenes
5138 get { return m_allowScriptCrossings; } 5138 get { return m_allowScriptCrossings; }
5139 } 5139 }
5140 5140
5141 public Vector3? GetNearestAllowedPosition(ScenePresence avatar) 5141 public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
5142 { 5142 {
5143 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 5143 return GetNearestAllowedPosition(avatar, null);
5144 }
5145
5146 public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
5147 {
5148 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
5144 5149
5145 if (nearestParcel != null) 5150 if (nearestParcel != null)
5146 { 5151 {
@@ -5149,10 +5154,7 @@ namespace OpenSim.Region.Framework.Scenes
5149 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5154 Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5150 if (nearestPoint != null) 5155 if (nearestPoint != null)
5151 { 5156 {
5152// m_log.DebugFormat( 5157 Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString());
5153// "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}",
5154// avatar.Name, nearestPoint, nearestParcel.LandData.Name);
5155
5156 return nearestPoint.Value; 5158 return nearestPoint.Value;
5157 } 5159 }
5158 5160
@@ -5162,24 +5164,27 @@ namespace OpenSim.Region.Framework.Scenes
5162 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); 5164 nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel);
5163 if (nearestPoint != null) 5165 if (nearestPoint != null)
5164 { 5166 {
5165// m_log.DebugFormat( 5167 Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString());
5166// "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint);
5167
5168 return nearestPoint.Value; 5168 return nearestPoint.Value;
5169 } 5169 }
5170 5170
5171 //Ultimate backup if we have no idea where they are 5171 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
5172// m_log.DebugFormat( 5172 if (dest != excludeParcel)
5173// "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); 5173 {
5174 // Ultimate backup if we have no idea where they are and
5175 // the last allowed position was in another parcel
5176 Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString());
5177 return avatar.lastKnownAllowedPosition;
5178 }
5174 5179
5175 return avatar.lastKnownAllowedPosition; 5180 // else fall through to region edge
5176 } 5181 }
5177 5182
5178 //Go to the edge, this happens in teleporting to a region with no available parcels 5183 //Go to the edge, this happens in teleporting to a region with no available parcels
5179 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); 5184 Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar);
5180 5185
5181 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); 5186 //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString());
5182 5187
5183 return nearestRegionEdgePoint; 5188 return nearestRegionEdgePoint;
5184 } 5189 }
5185 5190
@@ -5206,13 +5211,18 @@ namespace OpenSim.Region.Framework.Scenes
5206 5211
5207 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) 5212 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
5208 { 5213 {
5214 return GetNearestAllowedParcel(avatarId, x, y, null);
5215 }
5216
5217 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5218 {
5209 List<ILandObject> all = AllParcels(); 5219 List<ILandObject> all = AllParcels();
5210 float minParcelDistance = float.MaxValue; 5220 float minParcelDistance = float.MaxValue;
5211 ILandObject nearestParcel = null; 5221 ILandObject nearestParcel = null;
5212 5222
5213 foreach (var parcel in all) 5223 foreach (var parcel in all)
5214 { 5224 {
5215 if (!parcel.IsEitherBannedOrRestricted(avatarId)) 5225 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
5216 { 5226 {
5217 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5227 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
5218 if (parcelDistance < minParcelDistance) 5228 if (parcelDistance < minParcelDistance)