Telehub Support:

Telehub settings now persist to the database and are saved across sim restarts. So-far this only works on MySQL. this is a work in progress, teleport routing is not yet implemented.
This commit is contained in:
BlueWall
2012-01-21 23:26:27 -05:00
parent 590f707c42
commit 32d58d6e3e
6 changed files with 340 additions and 70 deletions

View File

@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
protected EstateManagementCommands m_commands;
private EstateTerrainXferHandler TerrainUploader;
private TelehubManager m_Telehub;
public TelehubManager m_Telehub;
public event ChangeDelegate OnRegionInfoChange;
public event ChangeDelegate OnEstateInfoChange;
@@ -600,22 +600,20 @@ namespace OpenSim.Region.CoreModules.World.Estate
}
}
private void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
public void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
{
uint ObjectLocalID;
SceneObjectPart part;
// UUID EstateID = Scene.RegionInfo.EstateSettings.EstateID;
TelehubManager.Telehub telehub;
switch (cmd)
{
case "info ui":
// Send info:
if (m_Telehub.HasTelehub)
if (Scene.RegionInfo.EstateSettings.HasTelehub)
{
telehub = m_Telehub.TelehubVals();
client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition,
telehub.ObjectRotation, telehub.SpawnPoint);
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
else
{
@@ -626,32 +624,44 @@ namespace OpenSim.Region.CoreModules.World.Estate
case "connect":
// Add the Telehub
part = Scene.GetSceneObjectPart((uint)param1);
telehub = m_Telehub.Connect(part);
client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition,
telehub.ObjectRotation, telehub.SpawnPoint);
if (m_Telehub.Connect(part))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
break;
case "delete":
// Disconnect Telehub
part = Scene.GetSceneObjectPart((uint)param1);
telehub = m_Telehub.DisConnect(part);
client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition,
telehub.ObjectRotation, telehub.SpawnPoint);
if (m_Telehub.DisConnect(part))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
break;
case "spawnpoint add":
// Add SpawnPoint to the Telehub
part = Scene.GetSceneObjectPart((uint)param1);
telehub = m_Telehub.AddSpawnPoint(part.AbsolutePosition);
client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition,
telehub.ObjectRotation, telehub.SpawnPoint);
if( m_Telehub.AddSpawnPoint(part.AbsolutePosition))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
break;
case "spawnpoint remove":
// Remove SpawnPoint from Telehub
telehub = m_Telehub.RemoveSpawnPoint((int)param1);
client.SendTelehubInfo(telehub.ObjectID, telehub.ObjectName, telehub.ObjectPosition,
telehub.ObjectRotation, telehub.SpawnPoint);
if (m_Telehub.RemoveSpawnPoint((int)param1))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
break;
default:

View File

@@ -35,14 +35,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
public class TelehubManager
{
public struct Telehub
{
public UUID ObjectID;
public string ObjectName;
public Vector3 ObjectPosition;
public Quaternion ObjectRotation;
public List<Vector3> SpawnPoint;
};
private UUID ObjectID;
private string ObjectName;
@@ -52,8 +44,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
UUID EstateID;
bool m_HasTelehub = false;
Scene m_Scene;
EstateSettings m_EstateSettings;
// This will get an option...
Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,-3.0f);
Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f);
public bool HasTelehub
{
@@ -63,68 +56,88 @@ namespace OpenSim.Region.CoreModules.World.Estate
public TelehubManager(Scene scene)
{
m_Scene = scene;
m_EstateSettings = m_Scene.RegionInfo.EstateSettings;
}
// Fill our Telehub struct with values
public Telehub TelehubVals()
{
Telehub telehub = new Telehub();
telehub.ObjectID = ObjectID;
telehub.ObjectName = ObjectName;
telehub.ObjectPosition = ObjectPosition;
telehub.ObjectRotation = ObjectRotation;
telehub.SpawnPoint = SpawnPoint;
return telehub;
}
// public Telehub TelehubVals()
// {
// // Telehub telehub = new Telehub();
// EstateSettings telehub = m_EstateSettings;
//
// telehub.TelehubObject = ObjectID;
// telehub.TelehubName = ObjectName;
// telehub.TelehubPos = ObjectPosition;
// telehub.TelehubRot = ObjectRotation;
// telehub. = SpawnPoint;
// return telehub;
// }
// Connect the Telehub
public Telehub Connect(SceneObjectPart part)
public bool Connect(SceneObjectPart part)
{
ObjectID = part.UUID;
ObjectName = part.Name;
ObjectPosition = part.AbsolutePosition;
ObjectRotation = part.GetWorldRotation();
// Clear this for now
SpawnPoint.Clear();
SpawnPoint.Add(InitialSpawnPoint);
m_HasTelehub = true;
m_EstateSettings.ClearSpawnPoints();
return TelehubVals();
m_EstateSettings.TelehubObject = part.UUID;
m_EstateSettings.TelehubName = part.Name;
m_EstateSettings.TelehubPos = part.AbsolutePosition;
m_EstateSettings.TelehubRot = part.GetWorldRotation();
// Clear this for now
m_EstateSettings.AddSpawnPoint(InitialSpawnPoint);
m_EstateSettings.HasTelehub = true;
m_EstateSettings.Save();
return true;
}
// Disconnect the Telehub
public Telehub DisConnect(SceneObjectPart part)
// Disconnect the Telehub: Clear it out for now, look at just disableing
public bool DisConnect(SceneObjectPart part)
{
ObjectID = UUID.Zero;
ObjectName = String.Empty;
ObjectPosition = Vector3.Zero;
ObjectRotation = Quaternion.Identity;
SpawnPoint.Clear();
m_HasTelehub = false;
bool result = false;
return TelehubVals();
try{
m_EstateSettings.TelehubObject = UUID.Zero;
m_EstateSettings.TelehubName = String.Empty;
m_EstateSettings.TelehubPos = Vector3.Zero;
// This is probably wrong! But, HasTelehub will block access
m_EstateSettings.TelehubRot = Quaternion.Identity;
m_EstateSettings.ClearSpawnPoints();
m_EstateSettings.HasTelehub = false;
m_EstateSettings.Save();
result = true;
}
catch (Exception ex)
{
result = false;
}
finally
{
}
return result;
}
// Add a SpawnPoint to the Telehub
public Telehub AddSpawnPoint(Vector3 point)
public bool AddSpawnPoint(Vector3 point)
{
float dist = (float) Util.GetDistanceTo(ObjectPosition, point);
Vector3 nvec = Util.GetNormalizedVector(point - ObjectPosition);
float dist = (float) Util.GetDistanceTo(m_EstateSettings.TelehubPos, point);
Vector3 nvec = Util.GetNormalizedVector(point - m_EstateSettings.TelehubPos);
Vector3 spoint = nvec * dist;
SpawnPoint.Add(spoint);
return TelehubVals();
m_EstateSettings.AddSpawnPoint(spoint);
m_EstateSettings.Save();
return true;
}
// Remove a SpawnPoint from the Telehub
public Telehub RemoveSpawnPoint(int spawnpoint)
public bool RemoveSpawnPoint(int spawnpoint)
{
SpawnPoint.RemoveAt(spawnpoint);
m_EstateSettings.RemoveSpawnPoint(spawnpoint);
m_EstateSettings.Save();
return TelehubVals();
return true;
}
}
}