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.cs440
1 files changed, 316 insertions, 124 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index e935462..b5e2bc3 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -86,19 +86,21 @@ namespace OpenSim.Region.CoreModules.World.Land
86 /// <value> 86 /// <value>
87 /// Land objects keyed by local id 87 /// Land objects keyed by local id
88 /// </value> 88 /// </value>
89 private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>(); 89// private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
90
91 //ubit: removed the readonly so i can move it around
92 private Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
90 93
91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 94 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
92 95
93 private bool m_allowedForcefulBans = true; 96 private bool m_allowedForcefulBans = true;
97 private UUID DefaultGodParcelGroup;
98 private string DefaultGodParcelName;
94 99
95 // caches ExtendedLandData 100 // caches ExtendedLandData
96 private Cache parcelInfoCache; 101 private Cache parcelInfoCache;
97 102 private Dictionary<UUID, Vector3> forcedPosition =
98 /// <summary> 103 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 104
103 #region INonSharedRegionModule Members 105 #region INonSharedRegionModule Members
104 106
@@ -109,6 +111,12 @@ namespace OpenSim.Region.CoreModules.World.Land
109 111
110 public void Initialise(IConfigSource source) 112 public void Initialise(IConfigSource source)
111 { 113 {
114 IConfig cnf = source.Configs["LandManagement"];
115 if (cnf != null)
116 {
117 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
118 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
119 }
112 } 120 }
113 121
114 public void AddRegion(Scene scene) 122 public void AddRegion(Scene scene)
@@ -160,13 +168,6 @@ namespace OpenSim.Region.CoreModules.World.Land
160 m_scene.UnregisterModuleCommander(m_commander.Name); 168 m_scene.UnregisterModuleCommander(m_commander.Name);
161 } 169 }
162 170
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> 171 /// <summary>
171 /// Processes commandline input. Do not call directly. 172 /// Processes commandline input. Do not call directly.
172 /// </summary> 173 /// </summary>
@@ -207,6 +208,8 @@ namespace OpenSim.Region.CoreModules.World.Land
207 client.OnParcelInfoRequest += ClientOnParcelInfoRequest; 208 client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
208 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; 209 client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
209 client.OnPreAgentUpdate += ClientOnPreAgentUpdate; 210 client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
211 client.OnParcelEjectUser += ClientOnParcelEjectUser;
212 client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
210 213
211 EntityBase presenceEntity; 214 EntityBase presenceEntity;
212 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) 215 if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -218,48 +221,6 @@ namespace OpenSim.Region.CoreModules.World.Land
218 221
219 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 222 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
220 { 223 {
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 } 224 }
264 225
265 public void Close() 226 public void Close()
@@ -284,15 +245,19 @@ namespace OpenSim.Region.CoreModules.World.Land
284 { 245 {
285 LandData newData = data.Copy(); 246 LandData newData = data.Copy();
286 newData.LocalID = local_id; 247 newData.LocalID = local_id;
248 ILandObject landobj = null;
287 249
288 lock (m_landList) 250 lock (m_landList)
289 { 251 {
290 if (m_landList.ContainsKey(local_id)) 252 if (m_landList.ContainsKey(local_id))
291 { 253 {
292 m_landList[local_id].LandData = newData; 254 m_landList[local_id].LandData = newData;
293 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]); 255 landobj = m_landList[local_id];
256// m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, m_landList[local_id]);
294 } 257 }
295 } 258 }
259 if(landobj != null)
260 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landobj);
296 } 261 }
297 262
298 public bool AllowedForcefulBans 263 public bool AllowedForcefulBans
@@ -322,14 +287,14 @@ namespace OpenSim.Region.CoreModules.World.Land
322 protected ILandObject CreateDefaultParcel() 287 protected ILandObject CreateDefaultParcel()
323 { 288 {
324 m_log.DebugFormat( 289 m_log.DebugFormat(
325 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName); 290 "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
326 291
327 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 292 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
328 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 293 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
329 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 294 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
330 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 295 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch();
331 296
332 return AddLandObject(fullSimParcel); 297 return AddLandObject(fullSimParcel);
333 } 298 }
334 299
335 public List<ILandObject> AllParcels() 300 public List<ILandObject> AllParcels()
@@ -378,10 +343,16 @@ namespace OpenSim.Region.CoreModules.World.Land
378 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 343 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
379 { 344 {
380 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 345 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
381 if (position.HasValue) 346
382 { 347 if (!position.HasValue)
383 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 348 return;
384 } 349
350 bool isFlying = avatar.PhysicsActor.Flying;
351 avatar.RemoveFromPhysicalScene();
352
353 avatar.AbsolutePosition = (Vector3)position;
354
355 avatar.AddToPhysicalScene(isFlying);
385 } 356 }
386 357
387 public void SendYouAreRestrictedNotice(ScenePresence avatar) 358 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -401,29 +372,7 @@ namespace OpenSim.Region.CoreModules.World.Land
401 } 372 }
402 373
403 if (parcelAvatarIsEntering != null) 374 if (parcelAvatarIsEntering != null)
404 { 375 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 } 376 }
428 } 377 }
429 378
@@ -452,30 +401,51 @@ namespace OpenSim.Region.CoreModules.World.Land
452 401
453 public void SendLandUpdate(ScenePresence avatar, bool force) 402 public void SendLandUpdate(ScenePresence avatar, bool force)
454 { 403 {
404
405 /* stop sendind same data twice
406 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
407 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
408
409 if (over != null)
410 {
411
412 if (force)
413 {
414 if (!avatar.IsChildAgent)
415 {
416 over.SendLandUpdateToClient(avatar.ControllingClient);
417 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
418 m_scene.RegionInfo.RegionID);
419 }
420 }
421
422 if (avatar.currentParcelUUID != over.LandData.GlobalID)
423 {
424 if (!avatar.IsChildAgent)
425 {
426 over.SendLandUpdateToClient(avatar.ControllingClient);
427 avatar.currentParcelUUID = over.LandData.GlobalID;
428 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
429 m_scene.RegionInfo.RegionID);
430 }
431 }
432 */
433 if (avatar.IsChildAgent)
434 return;
435
455 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), 436 ILandObject over = GetLandObject((int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
456 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); 437 (int)Math.Min(((int)Constants.RegionSize - 1), Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
457 438
458 if (over != null) 439 if (over != null)
459 { 440 {
460 if (force) 441 bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID);
442 if (force || NotsameID)
461 { 443 {
462 if (!avatar.IsChildAgent) 444 over.SendLandUpdateToClient(avatar.ControllingClient);
463 { 445 if (NotsameID)
464 over.SendLandUpdateToClient(avatar.ControllingClient);
465 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
466 m_scene.RegionInfo.RegionID);
467 }
468 }
469
470 if (avatar.currentParcelUUID != over.LandData.GlobalID)
471 {
472 if (!avatar.IsChildAgent)
473 {
474 over.SendLandUpdateToClient(avatar.ControllingClient);
475 avatar.currentParcelUUID = over.LandData.GlobalID; 446 avatar.currentParcelUUID = over.LandData.GlobalID;
476 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, 447 m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
477 m_scene.RegionInfo.RegionID); 448 m_scene.RegionInfo.RegionID);
478 }
479 } 449 }
480 } 450 }
481 } 451 }
@@ -527,6 +497,7 @@ namespace OpenSim.Region.CoreModules.World.Land
527 //when we are finally in a safe place, lets release the forced position lock 497 //when we are finally in a safe place, lets release the forced position lock
528 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); 498 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
529 } 499 }
500 EnforceBans(parcel, clientAvatar);
530 } 501 }
531 } 502 }
532 503
@@ -674,21 +645,28 @@ namespace OpenSim.Region.CoreModules.World.Land
674 /// </summary> 645 /// </summary>
675 public void Clear(bool setupDefaultParcel) 646 public void Clear(bool setupDefaultParcel)
676 { 647 {
648 Dictionary<int, ILandObject> landworkList;
649 // move to work pointer since we are deleting it all
677 lock (m_landList) 650 lock (m_landList)
678 { 651 {
679 foreach (ILandObject lo in m_landList.Values) 652 landworkList = m_landList;
680 { 653 m_landList = new Dictionary<int, ILandObject>();
681 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID); 654 }
682 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
683 }
684 655
685 m_landList.Clear(); 656 // this 2 methods have locks (now)
657 ResetSimLandObjects();
686 658
687 ResetSimLandObjects(); 659 if (setupDefaultParcel)
660 CreateDefaultParcel();
688 661
689 if (setupDefaultParcel) 662 // fire outside events unlocked
690 CreateDefaultParcel(); 663 foreach (ILandObject lo in landworkList.Values)
664 {
665 //m_scene.SimulationDataService.RemoveLandObject(lo.LandData.GlobalID);
666 m_scene.EventManager.TriggerLandObjectRemoved(lo.LandData.GlobalID);
691 } 667 }
668 landworkList.Clear();
669
692 } 670 }
693 671
694 private void performFinalLandJoin(ILandObject master, ILandObject slave) 672 private void performFinalLandJoin(ILandObject master, ILandObject slave)
@@ -735,7 +713,7 @@ namespace OpenSim.Region.CoreModules.World.Land
735 int x; 713 int x;
736 int y; 714 int y;
737 715
738 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 716 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
739 return null; 717 return null;
740 718
741 try 719 try
@@ -785,14 +763,13 @@ namespace OpenSim.Region.CoreModules.World.Land
785 { 763 {
786 try 764 try
787 { 765 {
788 return m_landList[m_landIDList[x / 4, y / 4]]; 766 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
767 return m_landList[m_landIDList[x / 4, y / 4]];
768 //else
769 // return null;
789 } 770 }
790 catch (IndexOutOfRangeException) 771 catch (IndexOutOfRangeException)
791 { 772 {
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; 773 return null;
797 } 774 }
798 } 775 }
@@ -1076,6 +1053,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1076 //Owner Flag 1053 //Owner Flag
1077 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 1054 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1078 } 1055 }
1056 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1057 {
1058 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1059 }
1079 else if (currentParcelBlock.LandData.SalePrice > 0 && 1060 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1080 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1061 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1081 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1062 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1156,8 +1137,11 @@ namespace OpenSim.Region.CoreModules.World.Land
1156 { 1137 {
1157 if (!temp.Contains(currentParcel)) 1138 if (!temp.Contains(currentParcel))
1158 { 1139 {
1159 currentParcel.ForceUpdateLandInfo(); 1140 if (!currentParcel.IsEitherBannedOrRestricted(remote_client.AgentId))
1160 temp.Add(currentParcel); 1141 {
1142 currentParcel.ForceUpdateLandInfo();
1143 temp.Add(currentParcel);
1144 }
1161 } 1145 }
1162 } 1146 }
1163 } 1147 }
@@ -1376,6 +1360,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1376 1360
1377 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1361 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1378 { 1362 {
1363 Dictionary<int, ILandObject> landworkList;
1364 // move to work pointer since we are deleting it all
1365 lock (m_landList)
1366 {
1367 landworkList = m_landList;
1368 m_landList = new Dictionary<int, ILandObject>();
1369 }
1370
1371 //Remove all the land objects in the sim and then process our new data
1372 foreach (int n in landworkList.Keys)
1373 {
1374 m_scene.EventManager.TriggerLandObjectRemoved(landworkList[n].LandData.GlobalID);
1375 }
1376 landworkList.Clear();
1377
1378 lock (m_landList)
1379 {
1380 m_landIDList.Initialize();
1381 m_landList.Clear();
1382 }
1383
1379 for (int i = 0; i < data.Count; i++) 1384 for (int i = 0; i < data.Count; i++)
1380 { 1385 {
1381 IncomingLandObjectFromStorage(data[i]); 1386 IncomingLandObjectFromStorage(data[i]);
@@ -1384,10 +1389,12 @@ namespace OpenSim.Region.CoreModules.World.Land
1384 1389
1385 public void IncomingLandObjectFromStorage(LandData data) 1390 public void IncomingLandObjectFromStorage(LandData data)
1386 { 1391 {
1392
1387 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1393 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1388 new_land.LandData = data.Copy(); 1394 new_land.LandData = data.Copy();
1389 new_land.SetLandBitmapFromByteArray(); 1395 new_land.SetLandBitmapFromByteArray();
1390 AddLandObject(new_land); 1396 AddLandObject(new_land);
1397 new_land.SendLandUpdateToAvatarsOverMe();
1391 } 1398 }
1392 1399
1393 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1400 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1405,7 +1412,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1405 1412
1406 public void EventManagerOnNoLandDataFromStorage() 1413 public void EventManagerOnNoLandDataFromStorage()
1407 { 1414 {
1408 lock (m_landList) 1415 // called methods already have locks
1416// lock (m_landList)
1409 { 1417 {
1410 ResetSimLandObjects(); 1418 ResetSimLandObjects();
1411 CreateDefaultParcel(); 1419 CreateDefaultParcel();
@@ -1670,6 +1678,168 @@ namespace OpenSim.Region.CoreModules.World.Land
1670 1678
1671 UpdateLandObject(localID, land.LandData); 1679 UpdateLandObject(localID, land.LandData);
1672 } 1680 }
1681
1682 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1683 {
1684 ILandObject land = null;
1685 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1686 foreach (ILandObject landObject in Land)
1687 {
1688 if (landObject.LandData.LocalID == landID)
1689 {
1690 land = landObject;
1691 }
1692 }
1693 land.DeedToGroup(DefaultGodParcelGroup);
1694 land.LandData.Name = DefaultGodParcelName;
1695 land.SendLandUpdateToAvatarsOverMe();
1696 }
1697
1698 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1699 {
1700 ScenePresence SP;
1701 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1702 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1703 if (SP.UserLevel != 0)
1704 {
1705 if (flags == 0) //All parcels, scripted or not
1706 {
1707 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1708 {
1709 if (e.OwnerID == targetID)
1710 {
1711 returns.Add(e);
1712 }
1713 }
1714 );
1715 }
1716 if (flags == 4) //All parcels, scripted object
1717 {
1718 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1719 {
1720 if (e.OwnerID == targetID)
1721 {
1722 if (e.ContainsScripts())
1723 {
1724 returns.Add(e);
1725 }
1726 }
1727 }
1728 );
1729 }
1730 if (flags == 4) //not target parcel, scripted object
1731 {
1732 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1733 {
1734 if (e.OwnerID == targetID)
1735 {
1736 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1737 if (landobject.LandData.OwnerID != e.OwnerID)
1738 {
1739 if (e.ContainsScripts())
1740 {
1741 returns.Add(e);
1742 }
1743 }
1744 }
1745 }
1746 );
1747 }
1748 foreach (SceneObjectGroup ol in returns)
1749 {
1750 ReturnObject(ol, client);
1751 }
1752 }
1753 }
1754 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1755 {
1756 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1757 objs[0] = obj;
1758 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1759 }
1760
1761 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1762
1763 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1764 {
1765 ScenePresence targetAvatar = null;
1766 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1767 ScenePresence parcelManager = null;
1768 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1769 System.Threading.Timer Timer;
1770
1771 if (targetAvatar.UserLevel == 0)
1772 {
1773 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1774 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1775 return;
1776 if (flags == 0)
1777 {
1778 targetAvatar.AllowMovement = false;
1779 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1780 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1781 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1782 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1783 Timers.Add(targetAvatar.UUID, Timer);
1784 }
1785 else
1786 {
1787 targetAvatar.AllowMovement = true;
1788 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1789 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1790 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1791 Timers.Remove(targetAvatar.UUID);
1792 Timer.Dispose();
1793 }
1794 }
1795 }
1796 private void OnEndParcelFrozen(object avatar)
1797 {
1798 ScenePresence targetAvatar = (ScenePresence)avatar;
1799 targetAvatar.AllowMovement = true;
1800 System.Threading.Timer Timer;
1801 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1802 Timers.Remove(targetAvatar.UUID);
1803 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1804 }
1805
1806
1807 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1808 {
1809 ScenePresence targetAvatar = null;
1810 ScenePresence parcelManager = null;
1811
1812 // Must have presences
1813 if (!m_scene.TryGetScenePresence(target, out targetAvatar) ||
1814 !m_scene.TryGetScenePresence(client.AgentId, out parcelManager))
1815 return;
1816
1817 // Cannot eject estate managers or gods
1818 if (m_scene.Permissions.IsAdministrator(target))
1819 return;
1820
1821 // Check if you even have permission to do this
1822 ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1823 if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) &&
1824 !m_scene.Permissions.IsAdministrator(client.AgentId))
1825 return;
1826
1827 Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
1828
1829 targetAvatar.TeleportWithMomentum(pos, null);
1830 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1831 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1832
1833 if ((flags & 1) != 0) // Ban TODO: Remove magic number
1834 {
1835 LandAccessEntry entry = new LandAccessEntry();
1836 entry.AgentID = targetAvatar.UUID;
1837 entry.Flags = AccessList.Ban;
1838 entry.Expires = 0; // Perm
1839
1840 land.LandData.ParcelAccessList.Add(entry);
1841 }
1842 }
1673 1843
1674 protected void InstallInterfaces() 1844 protected void InstallInterfaces()
1675 { 1845 {
@@ -1732,5 +1902,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1732 1902
1733 MainConsole.Instance.Output(report.ToString()); 1903 MainConsole.Instance.Output(report.ToString());
1734 } 1904 }
1905
1906 public void EnforceBans(ILandObject land, ScenePresence avatar)
1907 {
1908 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
1909 return;
1910
1911 if (land.IsEitherBannedOrRestricted(avatar.UUID))
1912 {
1913 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
1914 {
1915 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
1916 if (pos == null)
1917 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
1918 else
1919 ForceAvatarToPosition(avatar, (Vector3)pos);
1920 }
1921 else
1922 {
1923 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
1924 }
1925 }
1926 }
1735 } 1927 }
1736} 1928}