aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs40
1 files changed, 25 insertions, 15 deletions
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)