From 295bb3227d0c7d108d73ef7be4fd1dd59f7afc21 Mon Sep 17 00:00:00 2001
From: BlueWall
Date: Thu, 17 May 2012 00:47:19 -0400
Subject: Force the default Telehub router if no matches are found in the
 config.

---
 OpenSim/Region/Framework/Scenes/ScenePresence.cs | 57 ++++++++++++------------
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index bdcef71..0d5c218 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3939,35 +3939,6 @@ namespace OpenSim.Region.Framework.Scenes
 
                     switch (m_scene.SpawnPointRouting)
                     {
-                        case "closest":
-
-                            float distance = 9999;
-                            int closest = -1;
-        
-                            for (int i = 0; i < spawnPoints.Length; i++)
-                            {
-                                Vector3 spawnPosition = spawnPoints[i].GetLocation(
-                                    telehub.AbsolutePosition,
-                                    telehub.GroupRotation
-                                );
-                                Vector3 offset = spawnPosition - pos;
-                                float d = Vector3.Mag(offset);
-                                if (d >= distance)
-                                    continue;
-                                ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
-                                if (land == null)
-                                    continue;
-                                if (land.IsEitherBannedOrRestricted(UUID))
-                                    continue;
-                                distance = d;
-                                closest = i;
-                            }
-                            if (closest == -1)
-                                return;
-                            
-                            pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
-                            return;
-
                         case "random":
 
                             do
@@ -4019,7 +3990,35 @@ namespace OpenSim.Region.Framework.Scenes
                             return;
 
                         default:
+                        case "closest":
+
+                            float distance = 9999;
+                            int closest = -1;
+        
+                            for (int i = 0; i < spawnPoints.Length; i++)
+                            {
+                                Vector3 spawnPosition = spawnPoints[i].GetLocation(
+                                    telehub.AbsolutePosition,
+                                    telehub.GroupRotation
+                                );
+                                Vector3 offset = spawnPosition - pos;
+                                float d = Vector3.Mag(offset);
+                                if (d >= distance)
+                                    continue;
+                                ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y);
+                                if (land == null)
+                                    continue;
+                                if (land.IsEitherBannedOrRestricted(UUID))
+                                    continue;
+                                distance = d;
+                                closest = i;
+                            }
+                            if (closest == -1)
+                                return;
+                            
+                            pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation);
                             return;
+
                     }
                 }
             }
-- 
cgit v1.1