diff options
author | unknown | 2010-03-08 01:19:45 -0600 |
---|---|---|
committer | Melanie | 2010-03-09 22:38:58 +0000 |
commit | fce9e499e4682edf6db7b4f9c5546524b4a25197 (patch) | |
tree | fc5ef7728a3b7828ba17202244737af1db81e3cb /OpenSim/Region/CoreModules | |
parent | Revert "Adds Land Banning." (diff) | |
download | opensim-SC_OLD-fce9e499e4682edf6db7b4f9c5546524b4a25197.zip opensim-SC_OLD-fce9e499e4682edf6db7b4f9c5546524b4a25197.tar.gz opensim-SC_OLD-fce9e499e4682edf6db7b4f9c5546524b4a25197.tar.bz2 opensim-SC_OLD-fce9e499e4682edf6db7b4f9c5546524b4a25197.tar.xz |
- parcel blocking, region crossing blocking, teleport blocking
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 93 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Land/LandObject.cs | 9 |
2 files changed, 92 insertions, 10 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 8c3d17d..e0cdb36 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Diagnostics; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using log4net; | 33 | using log4net; |
33 | using Nini.Config; | 34 | using Nini.Config; |
@@ -86,6 +87,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
86 | 87 | ||
87 | // caches ExtendedLandData | 88 | // caches ExtendedLandData |
88 | private Cache parcelInfoCache; | 89 | private Cache parcelInfoCache; |
90 | private Vector3? forcedPosition = null; | ||
89 | 91 | ||
90 | #region INonSharedRegionModule Members | 92 | #region INonSharedRegionModule Members |
91 | 93 | ||
@@ -144,6 +146,13 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
144 | { | 146 | { |
145 | } | 147 | } |
146 | 148 | ||
149 | private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason) | ||
150 | { | ||
151 | ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y); | ||
152 | reason = "You are not allowed to enter this sim."; | ||
153 | return nearestParcel != null; | ||
154 | } | ||
155 | |||
147 | void EventManagerOnNewClient(IClientAPI client) | 156 | void EventManagerOnNewClient(IClientAPI client) |
148 | { | 157 | { |
149 | //Register some client events | 158 | //Register some client events |
@@ -161,6 +170,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
161 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; | 170 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; |
162 | client.OnParcelDwellRequest += ClientOnParcelDwellRequest; | 171 | client.OnParcelDwellRequest += ClientOnParcelDwellRequest; |
163 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; | 172 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; |
173 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; | ||
164 | 174 | ||
165 | EntityBase presenceEntity; | 175 | EntityBase presenceEntity; |
166 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | 176 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) |
@@ -170,6 +180,40 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
170 | } | 180 | } |
171 | } | 181 | } |
172 | 182 | ||
183 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | ||
184 | { | ||
185 | //If we are forcing a position for them to go | ||
186 | if( forcedPosition != null ) | ||
187 | { | ||
188 | ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId); | ||
189 | |||
190 | //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND | ||
191 | //When the avatar walks into a ban line on the ground, it prevents getting stuck | ||
192 | agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
193 | |||
194 | |||
195 | //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines | ||
196 | if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition.Value) < .2) | ||
197 | { | ||
198 | Debug.WriteLine(string.Format("Stopping force position because {0} is close enough to position {1}", forcedPosition.Value, clientAvatar.AbsolutePosition)); | ||
199 | forcedPosition = null; | ||
200 | } | ||
201 | //if we are far away, teleport | ||
202 | else if(Vector3.Distance(clientAvatar.AbsolutePosition,forcedPosition.Value) > 3 ) | ||
203 | { | ||
204 | Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}",forcedPosition.Value,clientAvatar.AbsolutePosition)); | ||
205 | clientAvatar.Teleport(forcedPosition.Value); | ||
206 | forcedPosition = null; | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | //Forces them toward the forced position we want if they aren't there yet | ||
211 | agentData.UseClientAgentPosition = true; | ||
212 | agentData.ClientAgentPosition = forcedPosition.Value; | ||
213 | } | ||
214 | } | ||
215 | } | ||
216 | |||
173 | 217 | ||
174 | public void PostInitialise() | 218 | public void PostInitialise() |
175 | { | 219 | { |
@@ -275,9 +319,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
275 | { | 319 | { |
276 | avatar.ControllingClient.SendAlertMessage( | 320 | avatar.ControllingClient.SendAlertMessage( |
277 | "You are not allowed on this parcel because you are banned. Please go away."); | 321 | "You are not allowed on this parcel because you are banned. Please go away."); |
278 | |||
279 | avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition; | ||
280 | avatar.PhysicsActor.Velocity = Vector3.Zero; | ||
281 | } | 322 | } |
282 | else | 323 | else |
283 | { | 324 | { |
@@ -286,6 +327,24 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
286 | } | 327 | } |
287 | } | 328 | } |
288 | 329 | ||
330 | |||
331 | |||
332 | private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) | ||
333 | { | ||
334 | if (m_scene.Permissions.IsGod(avatar.UUID)) return; | ||
335 | if (position.HasValue) | ||
336 | { | ||
337 | forcedPosition = position; | ||
338 | } | ||
339 | } | ||
340 | |||
341 | public void SendYouAreRestrictedNotice(ScenePresence avatar) | ||
342 | { | ||
343 | avatar.ControllingClient.SendAlertMessage( | ||
344 | "You are not allowed on this parcel because the land owner has restricted access."); | ||
345 | |||
346 | } | ||
347 | |||
289 | public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID) | 348 | public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID) |
290 | { | 349 | { |
291 | if (m_scene.RegionInfo.RegionID == regionID) | 350 | if (m_scene.RegionInfo.RegionID == regionID) |
@@ -303,11 +362,12 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
303 | if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) | 362 | if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) |
304 | { | 363 | { |
305 | SendYouAreBannedNotice(avatar); | 364 | SendYouAreBannedNotice(avatar); |
365 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); | ||
306 | } | 366 | } |
307 | else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID)) | 367 | else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID)) |
308 | { | 368 | { |
309 | avatar.ControllingClient.SendAlertMessage( | 369 | SendYouAreRestrictedNotice(avatar); |
310 | "You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!)."); | 370 | ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar)); |
311 | } | 371 | } |
312 | else | 372 | else |
313 | { | 373 | { |
@@ -408,7 +468,26 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
408 | else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && | 468 | else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && |
409 | parcel.IsBannedFromLand(clientAvatar.UUID)) | 469 | parcel.IsBannedFromLand(clientAvatar.UUID)) |
410 | { | 470 | { |
411 | SendYouAreBannedNotice(clientAvatar); | 471 | //once we've sent the message once, keep going toward the target until we are done |
472 | if (forcedPosition == null) | ||
473 | { | ||
474 | SendYouAreBannedNotice(clientAvatar); | ||
475 | ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); | ||
476 | } | ||
477 | } | ||
478 | else if ( parcel.IsRestrictedFromLand(clientAvatar.UUID)) | ||
479 | { | ||
480 | //once we've sent the message once, keep going toward the target until we are done | ||
481 | if (forcedPosition == null) | ||
482 | { | ||
483 | SendYouAreRestrictedNotice(clientAvatar); | ||
484 | ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar)); | ||
485 | } | ||
486 | } | ||
487 | else | ||
488 | { | ||
489 | //when we are finally in a safe place, lets release the forced position lock | ||
490 | forcedPosition = null; | ||
412 | } | 491 | } |
413 | } | 492 | } |
414 | } | 493 | } |
@@ -420,7 +499,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
420 | ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 499 | ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); |
421 | if (over != null) | 500 | if (over != null) |
422 | { | 501 | { |
423 | if (!over.IsBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT) | 502 | if (!over.IsRestrictedFromLand(avatar.UUID) && (!over.IsBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT)) |
424 | { | 503 | { |
425 | avatar.lastKnownAllowedPosition = | 504 | avatar.lastKnownAllowedPosition = |
426 | new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); | 505 | new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 1fa8630..27d9fdb 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
104 | /// <returns>Returns true if the piece of land contains the specified point</returns> | 104 | /// <returns>Returns true if the piece of land contains the specified point</returns> |
105 | public bool ContainsPoint(int x, int y) | 105 | public bool ContainsPoint(int x, int y) |
106 | { | 106 | { |
107 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) | 107 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && y <= Constants.RegionSize) |
108 | { | 108 | { |
109 | return (LandBitmap[x / 4, y / 4] == true); | 109 | return (LandBitmap[x / 4, y / 4] == true); |
110 | } | 110 | } |
@@ -286,7 +286,8 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
286 | entry.AgentID = avatar; | 286 | entry.AgentID = avatar; |
287 | entry.Flags = AccessList.Ban; | 287 | entry.Flags = AccessList.Ban; |
288 | entry.Time = new DateTime(); | 288 | entry.Time = new DateTime(); |
289 | if (LandData.ParcelAccessList.Contains(entry)) | 289 | //See if they are on the list, but make sure the owner isn't banned |
290 | if (LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar ) | ||
290 | { | 291 | { |
291 | //They are banned, so lets send them a notice about this parcel | 292 | //They are banned, so lets send them a notice about this parcel |
292 | return true; | 293 | return true; |
@@ -303,7 +304,9 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
303 | entry.AgentID = avatar; | 304 | entry.AgentID = avatar; |
304 | entry.Flags = AccessList.Access; | 305 | entry.Flags = AccessList.Access; |
305 | entry.Time = new DateTime(); | 306 | entry.Time = new DateTime(); |
306 | if (!LandData.ParcelAccessList.Contains(entry)) | 307 | |
308 | //If they are not on the access list and are not the owner | ||
309 | if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar) | ||
307 | { | 310 | { |
308 | //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel | 311 | //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel |
309 | return true; | 312 | return true; |