Move Telehub tables and data from EstateSettings to RegionSettings.

This is damage control es EstateSettings is not the place this can be put.
EstateSettings is nt unique to a region and therefore would introduce
a hard limit of one telehub per estate, completely shutting off the
option of having SL style telehubs, e.g. one per region. Whole
estate teleport routing can still be implemented id desiresd, this
way all options are open while the other way most options get closed
off.
iar_mods
Melanie 2012-01-22 11:36:04 +00:00
parent 32d58d6e3e
commit 68365c20c0
8 changed files with 273 additions and 267 deletions

View File

@ -157,7 +157,6 @@ namespace OpenSim.Data.MySQL
DoCreate(es);
LoadBanList(es);
LoadSpawnPoints(es);
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
@ -211,7 +210,6 @@ 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");
@ -298,74 +296,11 @@ 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();

View File

@ -846,6 +846,8 @@ namespace OpenSim.Data.MySQL
}
}
LoadSpawnPoints(rs);
return rs;
}
@ -1017,6 +1019,7 @@ namespace OpenSim.Data.MySQL
}
}
}
SaveSpawnPoints(rs);
}
public List<LandData> LoadLandObjects(UUID regionUUID)
@ -1828,5 +1831,72 @@ namespace OpenSim.Data.MySQL
}
}
}
private void LoadSpawnPoints(RegionSettings rs)
{
rs.ClearSpawnPoints();
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
using (MySqlCommand cmd = dbcon.CreateCommand())
{
cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID";
cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
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"];
rs.AddSpawnPoint(point);
}
}
}
}
}
}
private void SaveSpawnPoints(RegionSettings rs)
{
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
using (MySqlCommand cmd = dbcon.CreateCommand())
{
cmd.CommandText = "delete from spawn_points where RegionID = ?RegionID";
cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?EstateID, ?PointX, ?PointY,?PointZ)";
foreach (Vector3 p in rs.SpawnPoints())
{
cmd.Parameters.AddWithValue("?EstateID", rs.RegionUUID.ToString());
cmd.Parameters.AddWithValue("?PointX", p.X);
cmd.Parameters.AddWithValue("?PointY", p.Y);
cmd.Parameters.AddWithValue("?PointZ", p.Z);
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
}
}
}
}
}
}
}

View File

@ -78,25 +78,4 @@ 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;

View File

@ -841,4 +841,28 @@ alter table regionban ENGINE = MyISAM;
alter table regionsettings ENGINE = MyISAM;
alter table terrain ENGINE = MyISAM;
COMMIT;
COMMIT;
:VERSION 39 #--------------- Telehub support
BEGIN;
CREATE TABLE IF NOT EXISTS `spawn_points` (
`RegionID` 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 `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL;
ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL;
COMMIT;

View File

@ -373,155 +373,5 @@ 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();
}
}
}

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using System.IO;
using OpenMetaverse;
@ -397,5 +398,154 @@ namespace OpenSim.Framework
set { m_LoadedCreationID = value; }
}
// 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();
}
}
}

View File

@ -609,9 +609,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
{
case "info ui":
// Send info:
if (Scene.RegionInfo.EstateSettings.HasTelehub)
if (Scene.RegionInfo.RegionSettings.HasTelehub)
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
@ -626,7 +626,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
part = Scene.GetSceneObjectPart((uint)param1);
if (m_Telehub.Connect(part))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
@ -637,7 +637,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
part = Scene.GetSceneObjectPart((uint)param1);
if (m_Telehub.DisConnect(part))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
@ -648,7 +648,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
part = Scene.GetSceneObjectPart((uint)param1);
if( m_Telehub.AddSpawnPoint(part.AbsolutePosition))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}
@ -658,7 +658,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
// Remove SpawnPoint from Telehub
if (m_Telehub.RemoveSpawnPoint((int)param1))
{
EstateSettings settings = this.Scene.RegionInfo.EstateSettings;
RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
settings.TelehubRot, settings.SpawnPoints());
}

View File

@ -44,7 +44,6 @@ 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,0.0f);
@ -56,7 +55,6 @@ 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
@ -76,17 +74,17 @@ namespace OpenSim.Region.CoreModules.World.Estate
// Connect the Telehub
public bool Connect(SceneObjectPart part)
{
m_EstateSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_EstateSettings.TelehubObject = part.UUID;
m_EstateSettings.TelehubName = part.Name;
m_EstateSettings.TelehubPos = part.AbsolutePosition;
m_EstateSettings.TelehubRot = part.GetWorldRotation();
m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID;
m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name;
m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition;
m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation();
// Clear this for now
m_EstateSettings.AddSpawnPoint(InitialSpawnPoint);
m_EstateSettings.HasTelehub = true;
m_EstateSettings.Save();
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint);
m_Scene.RegionInfo.RegionSettings.HasTelehub = true;
m_Scene.RegionInfo.RegionSettings.Save();
return true;
}
@ -96,14 +94,14 @@ namespace OpenSim.Region.CoreModules.World.Estate
bool result = false;
try{
m_EstateSettings.TelehubObject = UUID.Zero;
m_EstateSettings.TelehubName = String.Empty;
m_EstateSettings.TelehubPos = Vector3.Zero;
m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty;
m_Scene.RegionInfo.RegionSettings.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();
m_Scene.RegionInfo.RegionSettings.TelehubRot = Quaternion.Identity;
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.HasTelehub = false;
m_Scene.RegionInfo.RegionSettings.Save();
result = true;
}
catch (Exception ex)
@ -122,22 +120,22 @@ namespace OpenSim.Region.CoreModules.World.Estate
public bool AddSpawnPoint(Vector3 point)
{
float dist = (float) Util.GetDistanceTo(m_EstateSettings.TelehubPos, point);
Vector3 nvec = Util.GetNormalizedVector(point - m_EstateSettings.TelehubPos);
float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point);
Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos);
Vector3 spoint = nvec * dist;
m_EstateSettings.AddSpawnPoint(spoint);
m_EstateSettings.Save();
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint);
m_Scene.RegionInfo.RegionSettings.Save();
return true;
}
// Remove a SpawnPoint from the Telehub
public bool RemoveSpawnPoint(int spawnpoint)
{
m_EstateSettings.RemoveSpawnPoint(spawnpoint);
m_EstateSettings.Save();
m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint);
m_Scene.RegionInfo.RegionSettings.Save();
return true;
}
}
}
}