diff options
author | UbitUmarov | 2015-12-16 22:16:51 +0000 |
---|---|---|
committer | UbitUmarov | 2015-12-16 22:16:51 +0000 |
commit | 41ae6f06e01e29ae4d9637d6682a47f6d4964f75 (patch) | |
tree | 2c52b24ee50170de1614ba3d33b946b5a5754845 /OpenSim/Region/CoreModules/World | |
parent | make parcel bans do something on vehicles. Just a first code, far from good (diff) | |
download | opensim-SC_OLD-41ae6f06e01e29ae4d9637d6682a47f6d4964f75.zip opensim-SC_OLD-41ae6f06e01e29ae4d9637d6682a47f6d4964f75.tar.gz opensim-SC_OLD-41ae6f06e01e29ae4d9637d6682a47f6d4964f75.tar.bz2 opensim-SC_OLD-41ae6f06e01e29ae4d9637d6682a47f6d4964f75.tar.xz |
several changes to parcels access control and scenepresence updates rates
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 221 |
1 files changed, 106 insertions, 115 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 7b4c724..65aabac 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -98,6 +98,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
98 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; | 98 | private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; |
99 | 99 | ||
100 | private bool m_allowedForcefulBans = true; | 100 | private bool m_allowedForcefulBans = true; |
101 | private bool m_showBansLines = true; | ||
101 | private UUID DefaultGodParcelGroup; | 102 | private UUID DefaultGodParcelGroup; |
102 | private string DefaultGodParcelName; | 103 | private string DefaultGodParcelName; |
103 | 104 | ||
@@ -107,7 +108,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
107 | /// <summary> | 108 | /// <summary> |
108 | /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions. | 109 | /// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions. |
109 | /// </summary> | 110 | /// </summary> |
110 | private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>(); | 111 | private HashSet<UUID> forcedPosition = new HashSet<UUID>(); |
111 | 112 | ||
112 | 113 | ||
113 | // Enables limiting parcel layer info transmission when doing simple updates | 114 | // Enables limiting parcel layer info transmission when doing simple updates |
@@ -133,6 +134,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
133 | parcelLayerViewDistance = landManagementConfig.GetInt("ParcelLayerViewDistance", parcelLayerViewDistance); | 134 | parcelLayerViewDistance = landManagementConfig.GetInt("ParcelLayerViewDistance", parcelLayerViewDistance); |
134 | DefaultGodParcelGroup = new UUID(landManagementConfig.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString())); | 135 | DefaultGodParcelGroup = new UUID(landManagementConfig.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString())); |
135 | DefaultGodParcelName = landManagementConfig.GetString("DefaultAdministratorParcelName", "Default Parcel"); | 136 | DefaultGodParcelName = landManagementConfig.GetString("DefaultAdministratorParcelName", "Default Parcel"); |
137 | bool disablebans = landManagementConfig.GetBoolean("DisableParcelBans", !m_allowedForcefulBans); | ||
138 | m_allowedForcefulBans = !disablebans; | ||
139 | m_showBansLines = landManagementConfig.GetBoolean("ShowParcelBansLines", m_showBansLines); | ||
136 | } | 140 | } |
137 | } | 141 | } |
138 | 142 | ||
@@ -212,15 +216,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
212 | client.OnParcelEjectUser += ClientOnParcelEjectUser; | 216 | client.OnParcelEjectUser += ClientOnParcelEjectUser; |
213 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; | 217 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; |
214 | client.OnSetStartLocationRequest += ClientOnSetHome; | 218 | client.OnSetStartLocationRequest += ClientOnSetHome; |
215 | |||
216 | /* avatar is still a child here position is unknown | ||
217 | EntityBase presenceEntity; | ||
218 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | ||
219 | { | ||
220 | SendLandUpdate((ScenePresence)presenceEntity, true); | ||
221 | SendParcelOverlay(client); | ||
222 | } | ||
223 | */ | ||
224 | } | 219 | } |
225 | 220 | ||
226 | public void EventMakeChildAgent(ScenePresence avatar) | 221 | public void EventMakeChildAgent(ScenePresence avatar) |
@@ -316,9 +311,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
316 | public List<ILandObject> ParcelsNearPoint(Vector3 position) | 311 | public List<ILandObject> ParcelsNearPoint(Vector3 position) |
317 | { | 312 | { |
318 | List<ILandObject> parcelsNear = new List<ILandObject>(); | 313 | List<ILandObject> parcelsNear = new List<ILandObject>(); |
319 | for (int x = -4; x <= 4; x += 4) | 314 | for (int x = -8; x <= 8; x += 4) |
320 | { | 315 | { |
321 | for (int y = -4; y <= 4; y += 4) | 316 | for (int y = -8; y <= 8; y += 4) |
322 | { | 317 | { |
323 | ILandObject check = GetLandObject(position.X + x, position.Y + y); | 318 | ILandObject check = GetLandObject(position.X + x, position.Y + y); |
324 | if (check != null) | 319 | if (check != null) |
@@ -334,17 +329,81 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
334 | return parcelsNear; | 329 | return parcelsNear; |
335 | } | 330 | } |
336 | 331 | ||
337 | public void SendYouAreBannedNotice(ScenePresence avatar) | 332 | // checks and enforces bans or restrictions |
333 | // returns true if enforced | ||
334 | public bool EnforceBans(ILandObject land, ScenePresence avatar) | ||
338 | { | 335 | { |
339 | if (AllowedForcefulBans) | 336 | Vector3 agentpos = avatar.AbsolutePosition; |
337 | float h = m_scene.GetGroundHeight(agentpos.X, agentpos.Y) + LandChannel.BAN_LINE_SAFETY_HEIGHT; | ||
338 | float zdif = avatar.AbsolutePosition.Z - h; | ||
339 | if (zdif > 0 ) | ||
340 | { | ||
341 | forcedPosition.Remove(avatar.UUID); | ||
342 | avatar.lastKnownAllowedPosition = agentpos; | ||
343 | return false; | ||
344 | } | ||
345 | |||
346 | bool ban = false; | ||
347 | string reason = ""; | ||
348 | if (land.IsRestrictedFromLand(avatar.UUID)) | ||
340 | { | 349 | { |
341 | avatar.ControllingClient.SendAlertMessage( | 350 | reason = "You do not have access to the parcel"; |
342 | "You are not allowed on this parcel because you are banned. Please go away."); | 351 | ban = true; |
352 | } | ||
353 | |||
354 | if (land.IsBannedFromLand(avatar.UUID)) | ||
355 | { | ||
356 | if ( m_allowedForcefulBans) | ||
357 | { | ||
358 | reason ="You are banned from parcel"; | ||
359 | ban = true; | ||
360 | } | ||
361 | else if(!ban) | ||
362 | { | ||
363 | if (forcedPosition.Contains(avatar.UUID)) | ||
364 | avatar.ControllingClient.SendAlertMessage("You are banned from parcel, please leave by your own will"); | ||
365 | forcedPosition.Remove(avatar.UUID); | ||
366 | avatar.lastKnownAllowedPosition = agentpos; | ||
367 | return false; | ||
368 | } | ||
369 | } | ||
370 | |||
371 | if(ban) | ||
372 | { | ||
373 | if (!forcedPosition.Contains(avatar.UUID)) | ||
374 | avatar.ControllingClient.SendAlertMessage(reason); | ||
375 | |||
376 | if(zdif > -4f) | ||
377 | { | ||
378 | |||
379 | agentpos.Z = h + 4.0f; | ||
380 | ForceAvatarToPosition(avatar, agentpos); | ||
381 | return true; | ||
382 | } | ||
383 | |||
384 | if (land.ContainsPoint((int)avatar.lastKnownAllowedPosition.X, | ||
385 | (int) avatar.lastKnownAllowedPosition.Y)) | ||
386 | { | ||
387 | Vector3? pos = m_scene.GetNearestAllowedPosition(avatar); | ||
388 | if (pos == null) | ||
389 | { | ||
390 | forcedPosition.Remove(avatar.UUID); | ||
391 | m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient); | ||
392 | } | ||
393 | else | ||
394 | ForceAvatarToPosition(avatar, (Vector3)pos); | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition); | ||
399 | } | ||
400 | return true; | ||
343 | } | 401 | } |
344 | else | 402 | else |
345 | { | 403 | { |
346 | avatar.ControllingClient.SendAlertMessage( | 404 | forcedPosition.Remove(avatar.UUID); |
347 | "You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim!"); | 405 | avatar.lastKnownAllowedPosition = agentpos; |
406 | return false; | ||
348 | } | 407 | } |
349 | } | 408 | } |
350 | 409 | ||
@@ -360,12 +419,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
360 | avatar.Velocity = Vector3.Zero; | 419 | avatar.Velocity = Vector3.Zero; |
361 | if(avatar.IsSatOnObject) | 420 | if(avatar.IsSatOnObject) |
362 | avatar.StandUp(); | 421 | avatar.StandUp(); |
363 | } | 422 | forcedPosition.Add(avatar.UUID); |
364 | |||
365 | public void SendYouAreRestrictedNotice(ScenePresence avatar) | ||
366 | { | ||
367 | avatar.ControllingClient.SendAlertMessage( | ||
368 | "You are not allowed on this parcel because the land owner has restricted access."); | ||
369 | } | 423 | } |
370 | 424 | ||
371 | public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID) | 425 | public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID) |
@@ -378,15 +432,20 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
378 | parcelAvatarIsEntering = m_landList[localLandID]; | 432 | parcelAvatarIsEntering = m_landList[localLandID]; |
379 | } | 433 | } |
380 | 434 | ||
381 | if (parcelAvatarIsEntering != null) | 435 | if (parcelAvatarIsEntering != null && |
436 | avatar.currentParcelUUID != parcelAvatarIsEntering.LandData.GlobalID) | ||
437 | { | ||
438 | SendLandUpdate(avatar, parcelAvatarIsEntering); | ||
439 | avatar.currentParcelUUID = parcelAvatarIsEntering.LandData.GlobalID; | ||
382 | EnforceBans(parcelAvatarIsEntering, avatar); | 440 | EnforceBans(parcelAvatarIsEntering, avatar); |
441 | } | ||
383 | } | 442 | } |
384 | } | 443 | } |
385 | 444 | ||
386 | public void SendOutNearestBanLine(IClientAPI client) | 445 | public void SendOutNearestBanLine(IClientAPI client) |
387 | { | 446 | { |
388 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 447 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
389 | if (sp == null) | 448 | if (sp == null || sp.IsDeleted) |
390 | return; | 449 | return; |
391 | 450 | ||
392 | List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition); | 451 | List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition); |
@@ -413,7 +472,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
413 | if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out avatar)) | 472 | if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out avatar)) |
414 | return; | 473 | return; |
415 | 474 | ||
416 | |||
417 | if (!avatar.IsChildAgent) | 475 | if (!avatar.IsChildAgent) |
418 | { | 476 | { |
419 | ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 477 | ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); |
@@ -426,77 +484,26 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
426 | SendParcelOverlay(remoteClient); | 484 | SendParcelOverlay(remoteClient); |
427 | } | 485 | } |
428 | 486 | ||
429 | public void SendLandUpdate(ScenePresence avatar, bool force) | 487 | public void SendLandUpdate(ScenePresence avatar, ILandObject over) |
430 | { | 488 | { |
431 | if (avatar.IsChildAgent) | 489 | if (avatar.IsChildAgent) |
432 | return; | 490 | return; |
433 | 491 | ||
434 | ILandObject over = GetLandObjectClipedXY(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
435 | |||
436 | if (over != null) | 492 | if (over != null) |
437 | { | 493 | { |
438 | bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID); | 494 | over.SendLandUpdateToClient(avatar.ControllingClient); |
439 | if (force || NotsameID) | ||
440 | { | ||
441 | over.SendLandUpdateToClient(avatar.ControllingClient); | ||
442 | // sl doesnt seem to send this now, as it used 2 | 495 | // sl doesnt seem to send this now, as it used 2 |
443 | // SendParcelOverlay(avatar.ControllingClient); | 496 | // SendParcelOverlay(avatar.ControllingClient); |
444 | avatar.currentParcelUUID = over.LandData.GlobalID; | ||
445 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID, | ||
446 | m_scene.RegionInfo.RegionID); | ||
447 | } | ||
448 | } | 497 | } |
449 | } | 498 | } |
450 | 499 | ||
451 | public void SendLandUpdate(ScenePresence avatar) | 500 | public void EventManagerOnSignificantClientMovement(ScenePresence avatar) |
452 | { | 501 | { |
453 | SendLandUpdate(avatar, false); | 502 | if (avatar.IsChildAgent) |
454 | } | 503 | return; |
455 | 504 | ||
456 | public void EventManagerOnSignificantClientMovement(ScenePresence clientAvatar) | 505 | if ( m_allowedForcefulBans && m_showBansLines) |
457 | { | 506 | SendOutNearestBanLine(avatar.ControllingClient); |
458 | SendLandUpdate(clientAvatar); | ||
459 | SendOutNearestBanLine(clientAvatar.ControllingClient); | ||
460 | ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); | ||
461 | if (parcel != null) | ||
462 | { | ||
463 | if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HEIGHT && | ||
464 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown) | ||
465 | { | ||
466 | EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID, | ||
467 | m_scene.RegionInfo.RegionID); | ||
468 | //They are going under the safety line! | ||
469 | if (!parcel.IsBannedFromLand(clientAvatar.UUID)) | ||
470 | { | ||
471 | clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false; | ||
472 | } | ||
473 | } | ||
474 | else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HEIGHT && | ||
475 | parcel.IsBannedFromLand(clientAvatar.UUID)) | ||
476 | { | ||
477 | //once we've sent the message once, keep going toward the target until we are done | ||
478 | if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) | ||
479 | { | ||
480 | SendYouAreBannedNotice(clientAvatar); | ||
481 | ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); | ||
482 | } | ||
483 | } | ||
484 | else if (parcel.IsRestrictedFromLand(clientAvatar.UUID)) | ||
485 | { | ||
486 | //once we've sent the message once, keep going toward the target until we are done | ||
487 | if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId)) | ||
488 | { | ||
489 | SendYouAreRestrictedNotice(clientAvatar); | ||
490 | ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); | ||
491 | } | ||
492 | } | ||
493 | else | ||
494 | { | ||
495 | //when we are finally in a safe place, lets release the forced position lock | ||
496 | forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); | ||
497 | } | ||
498 | EnforceBans(parcel, clientAvatar); | ||
499 | } | ||
500 | } | 507 | } |
501 | 508 | ||
502 | /// <summary> | 509 | /// <summary> |
@@ -505,12 +512,22 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
505 | /// <param name="avatar"></param> | 512 | /// <param name="avatar"></param> |
506 | public void EventManagerOnClientMovement(ScenePresence avatar) | 513 | public void EventManagerOnClientMovement(ScenePresence avatar) |
507 | { | 514 | { |
515 | if (avatar.IsChildAgent) | ||
516 | return; | ||
517 | |||
508 | Vector3 pos = avatar.AbsolutePosition; | 518 | Vector3 pos = avatar.AbsolutePosition; |
509 | ILandObject over = GetLandObject(pos.X, pos.Y); | 519 | ILandObject over = GetLandObject(pos.X, pos.Y); |
510 | if (over != null) | 520 | if (over != null) |
511 | { | 521 | { |
512 | if (!over.IsRestrictedFromLand(avatar.UUID) && (!over.IsBannedFromLand(avatar.UUID) || pos.Z >= LandChannel.BAN_LINE_SAFETY_HEIGHT)) | 522 | EnforceBans(over, avatar); |
513 | avatar.lastKnownAllowedPosition = pos; | 523 | pos = avatar.AbsolutePosition; |
524 | ILandObject newover = GetLandObject(pos.X, pos.Y); | ||
525 | if(over != newover || avatar.currentParcelUUID != newover.LandData.GlobalID) | ||
526 | { | ||
527 | avatar.currentParcelUUID = newover.LandData.GlobalID; | ||
528 | m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, | ||
529 | newover.LandData.LocalID, m_scene.RegionInfo.RegionID); | ||
530 | } | ||
514 | } | 531 | } |
515 | } | 532 | } |
516 | 533 | ||
@@ -1216,7 +1233,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1216 | } | 1233 | } |
1217 | } | 1234 | } |
1218 | } | 1235 | } |
1219 | |||
1220 | } | 1236 | } |
1221 | 1237 | ||
1222 | if (byteArrayCount > 0) | 1238 | if (byteArrayCount > 0) |
@@ -1965,8 +1981,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1965 | returns.Add(e); | 1981 | returns.Add(e); |
1966 | } | 1982 | } |
1967 | } | 1983 | } |
1968 | } | 1984 | }); |
1969 | ); | ||
1970 | } | 1985 | } |
1971 | if (flags == 4) //not target parcel, scripted object | 1986 | if (flags == 4) //not target parcel, scripted object |
1972 | { | 1987 | { |
@@ -1983,8 +1998,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1983 | } | 1998 | } |
1984 | } | 1999 | } |
1985 | } | 2000 | } |
1986 | } | 2001 | }); |
1987 | ); | ||
1988 | } | 2002 | } |
1989 | foreach (SceneObjectGroup ol in returns) | 2003 | foreach (SceneObjectGroup ol in returns) |
1990 | { | 2004 | { |
@@ -2044,7 +2058,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
2044 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); | 2058 | targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false); |
2045 | } | 2059 | } |
2046 | 2060 | ||
2047 | |||
2048 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | 2061 | public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) |
2049 | { | 2062 | { |
2050 | ScenePresence targetAvatar = null; | 2063 | ScenePresence targetAvatar = null; |
@@ -2247,28 +2260,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
2247 | 2260 | ||
2248 | } | 2261 | } |
2249 | 2262 | ||
2250 | public void EnforceBans(ILandObject land, ScenePresence avatar) | ||
2251 | { | ||
2252 | if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HEIGHT) | ||
2253 | return; | ||
2254 | |||
2255 | if (land.IsEitherBannedOrRestricted(avatar.UUID)) | ||
2256 | { | ||
2257 | if (land.ContainsPoint((int)avatar.lastKnownAllowedPosition.X, (int)avatar.lastKnownAllowedPosition.Y)) | ||
2258 | { | ||
2259 | Vector3? pos = m_scene.GetNearestAllowedPosition(avatar); | ||
2260 | if (pos == null) | ||
2261 | m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient); | ||
2262 | else | ||
2263 | ForceAvatarToPosition(avatar, (Vector3)pos); | ||
2264 | } | ||
2265 | else | ||
2266 | { | ||
2267 | ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition); | ||
2268 | } | ||
2269 | } | ||
2270 | } | ||
2271 | |||
2272 | private void AppendParcelReport(StringBuilder report, ILandObject lo) | 2263 | private void AppendParcelReport(StringBuilder report, ILandObject lo) |
2273 | { | 2264 | { |
2274 | LandData ld = lo.LandData; | 2265 | LandData ld = lo.LandData; |