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.iar_mods
parent
590f707c42
commit
32d58d6e3e
|
@ -157,6 +157,7 @@ namespace OpenSim.Data.MySQL
|
|||
DoCreate(es);
|
||||
|
||||
LoadBanList(es);
|
||||
LoadSpawnPoints(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
|
@ -210,7 +211,7 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
LoadSpawnPoints(es);
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
@ -297,11 +298,74 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
|
||||
SaveBanList(es);
|
||||
SaveSpawnPoints(es);
|
||||
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
||||
SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess);
|
||||
SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups);
|
||||
}
|
||||
|
||||
private void LoadSpawnPoints(EstateSettings es)
|
||||
{
|
||||
es.ClearSpawnPoints();
|
||||
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
{
|
||||
uint EstateID = es.EstateID;
|
||||
cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID);
|
||||
|
||||
using (IDataReader r = cmd.ExecuteReader())
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
Vector3 point = new Vector3();
|
||||
|
||||
point.X = (float)r["PointX"];
|
||||
point.Y = (float)r["PointY"];
|
||||
point.Z = (float)r["PointZ"];
|
||||
|
||||
es.AddSpawnPoint(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveSpawnPoints(EstateSettings es)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (MySqlCommand cmd = dbcon.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from spawn_points where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into spawn_points (EstateID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)";
|
||||
|
||||
foreach (Vector3 p in es.SpawnPoints())
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue("?PointX", p.X);
|
||||
cmd.Parameters.AddWithValue("?PointY", p.Y);
|
||||
cmd.Parameters.AddWithValue("?PointZ", p.Z);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadBanList(EstateSettings es)
|
||||
{
|
||||
es.ClearBans();
|
||||
|
|
|
@ -78,4 +78,25 @@ ALTER TABLE estate_settings AUTO_INCREMENT = 100;
|
|||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 33 #--------------------- ( Supporting Telehubs
|
||||
|
||||
BEGIN;
|
||||
CREATE TABLE IF NOT EXISTS `spawn_points` (
|
||||
`EstateID` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`PointX` float NOT NULL,
|
||||
`PointY` float NOT NULL,
|
||||
`PointZ` float NOT NULL,
|
||||
KEY `EstateID` (`EstateID`)
|
||||
) ENGINE=Innodb;
|
||||
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubName` varchar(255) NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosX` float NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosY` float NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubPosZ` float NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotX` float NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotY` float NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotZ` float NOT NULL;
|
||||
ALTER TABLE `estate_settings` ADD COLUMN `TelehubRotW` float NOT NULL;
|
||||
COMMIT;
|
|
@ -373,5 +373,155 @@ namespace OpenSim.Framework
|
|||
|
||||
return l_EstateAccess.Contains(user);
|
||||
}
|
||||
|
||||
// Telehub support
|
||||
private bool m_TelehubEnabled = false;
|
||||
public bool HasTelehub
|
||||
{
|
||||
get { return m_TelehubEnabled; }
|
||||
set { m_TelehubEnabled = value; }
|
||||
}
|
||||
|
||||
// Connected Telehub object
|
||||
private UUID m_TelehubObject;
|
||||
public UUID TelehubObject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (HasTelehub)
|
||||
{
|
||||
return m_TelehubObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return UUID.Zero;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
m_TelehubObject = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Connected Telehub name
|
||||
private string m_TelehubName;
|
||||
public string TelehubName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (HasTelehub)
|
||||
{
|
||||
return m_TelehubName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
m_TelehubName = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Connected Telehub position
|
||||
private float m_TelehubPosX;
|
||||
private float m_TelehubPosY;
|
||||
private float m_TelehubPosZ;
|
||||
public Vector3 TelehubPos
|
||||
{
|
||||
get
|
||||
{
|
||||
if (HasTelehub)
|
||||
{
|
||||
Vector3 Pos = new Vector3(m_TelehubPosX, m_TelehubPosY, m_TelehubPosZ);
|
||||
return Pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Vector3.Zero;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
m_TelehubPosX = value.X;
|
||||
m_TelehubPosY = value.Y;
|
||||
m_TelehubPosZ = value.Z;
|
||||
}
|
||||
}
|
||||
|
||||
// Connected Telehub rotation
|
||||
private float m_TelehubRotX;
|
||||
private float m_TelehubRotY;
|
||||
private float m_TelehubRotZ;
|
||||
private float m_TelehubRotW;
|
||||
public Quaternion TelehubRot
|
||||
{
|
||||
get
|
||||
{
|
||||
if (HasTelehub)
|
||||
{
|
||||
Quaternion quat = new Quaternion();
|
||||
|
||||
quat.X = m_TelehubRotX;
|
||||
quat.Y = m_TelehubRotY;
|
||||
quat.Z = m_TelehubRotZ;
|
||||
quat.W = m_TelehubRotW;
|
||||
|
||||
return quat;
|
||||
}
|
||||
else
|
||||
{
|
||||
// What else to do??
|
||||
Quaternion quat = new Quaternion();
|
||||
|
||||
quat.X = m_TelehubRotX;
|
||||
quat.X = m_TelehubRotY;
|
||||
quat.X = m_TelehubRotZ;
|
||||
quat.X = m_TelehubRotW;
|
||||
|
||||
return quat;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
m_TelehubRotX = value.X;
|
||||
m_TelehubRotY = value.Y;
|
||||
m_TelehubRotZ = value.Z;
|
||||
m_TelehubRotW = value.W;
|
||||
}
|
||||
}
|
||||
|
||||
// Our Connected Telehub's SpawnPoints
|
||||
public List<Vector3> l_SpawnPoints = new List<Vector3>();
|
||||
|
||||
// Add a SpawnPoint
|
||||
// ** These are not region coordinates **
|
||||
// They are relative to the Telehub coordinates
|
||||
//
|
||||
public void AddSpawnPoint(Vector3 point)
|
||||
{
|
||||
l_SpawnPoints.Add(point);
|
||||
}
|
||||
|
||||
// Remove a SpawnPoint
|
||||
public void RemoveSpawnPoint(int point_index)
|
||||
{
|
||||
l_SpawnPoints.RemoveAt(point_index);
|
||||
}
|
||||
|
||||
// Return the List of SpawnPoints
|
||||
public List<Vector3> SpawnPoints()
|
||||
{
|
||||
return l_SpawnPoints;
|
||||
|
||||
}
|
||||
|
||||
// Clear the SpawnPoints List of all entries
|
||||
public void ClearSpawnPoints()
|
||||
{
|
||||
l_SpawnPoints.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9242,10 +9242,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
{
|
||||
UUID invoice = messagePacket.MethodData.Invoice;
|
||||
UUID SenderID = messagePacket.AgentData.AgentID;
|
||||
UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
|
||||
UInt32 param1 = 0u;
|
||||
|
||||
string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
|
||||
|
||||
if (command != "info ui")
|
||||
{
|
||||
try
|
||||
{
|
||||
param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
|
||||
if (handlerEstateManageTelehub != null)
|
||||
{
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue