From 7c229c8b812b0975133a2612b34225c7c9403f1b Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 13 May 2012 17:11:44 -0400 Subject: Add configurable SpawnPointRouting Will use one of three selected methods to route avatar landing points when using Telehubs. The setting is in [Startup] using SpawnPointRouting = closest/random/sequence closest: The default setting. Routes avatar to the nearest SpawnPoint to the location. random: Picks random SpawnPoints to land the avatar. sequence: Follows a sequence to place the avatar on the next available SpawnPoint location Conflicts: OpenSim/Region/Framework/Scenes/Scene.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 103 ++++++++++++++++++----- 1 file changed, 84 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b737f91..bdcef71 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3934,28 +3934,93 @@ namespace OpenSim.Region.Framework.Scenes if (spawnPoints.Length == 0) return; - float distance = 9999; - int closest = -1; + int index; + bool selected = false; - for (int i = 0 ; i < spawnPoints.Length ; i++) + switch (m_scene.SpawnPointRouting) { - 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; + case "closest": - pos = spawnPoints[closest].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); + 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 + { + index = Util.RandomClass.Next(spawnPoints.Length - 1); + + Vector3 spawnPosition = spawnPoints[index].GetLocation( + telehub.AbsolutePosition, + telehub.GroupRotation + ); + // SpawnPoint sp = spawnPoints[index]; + + ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); + if (land == null || land.IsEitherBannedOrRestricted(UUID)) + selected = false; + else + selected = true; + + } while ( selected == false); + + pos = spawnPoints[index].GetLocation( + telehub.AbsolutePosition, + telehub.GroupRotation + ); + return; + + case "sequence": + + do + { + index = m_scene.SpawnPoint(); + + Vector3 spawnPosition = spawnPoints[index].GetLocation( + telehub.AbsolutePosition, + telehub.GroupRotation + ); + // SpawnPoint sp = spawnPoints[index]; + + ILandObject land = m_scene.LandChannel.GetLandObject(spawnPosition.X, spawnPosition.Y); + if (land == null || land.IsEitherBannedOrRestricted(UUID)) + selected = false; + else + selected = true; + + } while (selected == false); + + pos = spawnPoints[index].GetLocation(telehub.AbsolutePosition, telehub.GroupRotation); + ; + return; + + default: + return; + } } } } -- cgit v1.1