aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2012-01-24 00:36:42 +0000
committerMelanie2012-01-24 00:36:42 +0000
commit07ad821157a5e86d706114645eee1339a6ba51ae (patch)
treec2cf6cdd466fc6e492e95a852b94cbbc7604ee83
parentMerge branch 'master' of ssh://3dhosting.de/var/git/careminster (diff)
parentChange Telehubs to store only the data that is really needed and not (diff)
downloadopensim-SC_OLD-07ad821157a5e86d706114645eee1339a6ba51ae.zip
opensim-SC_OLD-07ad821157a5e86d706114645eee1339a6ba51ae.tar.gz
opensim-SC_OLD-07ad821157a5e86d706114645eee1339a6ba51ae.tar.bz2
opensim-SC_OLD-07ad821157a5e86d706114645eee1339a6ba51ae.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Data/MySQL/MySQLSimulationData.cs OpenSim/Framework/RegionSettings.cs
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs52
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations15
-rw-r--r--OpenSim/Framework/RegionSettings.cs108
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs78
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs101
5 files changed, 146 insertions, 208 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index bddb971..a346548 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -1012,9 +1012,7 @@ namespace OpenSim.Data.MySQL
1012 "covenant, Sandbox, sunvectorx, sunvectory, " + 1012 "covenant, Sandbox, sunvectorx, sunvectory, " +
1013 "sunvectorz, loaded_creation_datetime, " + 1013 "sunvectorz, loaded_creation_datetime, " +
1014 "loaded_creation_id, map_tile_ID, block_search, casino, " + 1014 "loaded_creation_id, map_tile_ID, block_search, casino, " +
1015 "TelehubEnabled, TelehubObject, TelehubName, " + 1015 "TelehubObject) " +
1016 "TelehubPosX, TelehubPosY, TelehubPosZ, " +
1017 "TelehubRotX, TelehubRotY, TelehubRotZ, TelehubRotW) " +
1018 "values (?RegionUUID, ?BlockTerraform, " + 1016 "values (?RegionUUID, ?BlockTerraform, " +
1019 "?BlockFly, ?AllowDamage, ?RestrictPushing, " + 1017 "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
1020 "?AllowLandResell, ?AllowLandJoinDivide, " + 1018 "?AllowLandResell, ?AllowLandJoinDivide, " +
@@ -1031,9 +1029,7 @@ namespace OpenSim.Data.MySQL
1031 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + 1029 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
1032 "?LoadedCreationDateTime, ?LoadedCreationID, " + 1030 "?LoadedCreationDateTime, ?LoadedCreationID, " +
1033 "?TerrainImageID, ?block_search, ?casino, " + 1031 "?TerrainImageID, ?block_search, ?casino, " +
1034 "?TelehubEnabled, ?TelehubObject, ?TelehubName, " + 1032 "?TelehubObject, " +
1035 "?TelehubPosX, ?TelehubPosY, ?TelehubPosZ, " +
1036 "?TelehubRotX, ?TelehubRotY, ?TelehubRotZ, ?TelehubRotW )";
1037 1033
1038 FillRegionSettingsCommand(cmd, rs); 1034 FillRegionSettingsCommand(cmd, rs);
1039 1035
@@ -1321,20 +1317,7 @@ namespace OpenSim.Data.MySQL
1321 newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; 1317 newSettings.LoadedCreationID = (String) row["loaded_creation_id"];
1322 1318
1323 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); 1319 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
1324 newSettings.HasTelehub = Convert.ToBoolean(row["TelehubEnabled"]);
1325 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); 1320 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]);
1326 newSettings.TelehubName = (string) row["TelehubName"];
1327 newSettings.TelehubPos = new Vector3 (
1328 Convert.ToSingle(row["TelehubPosX"]),
1329 Convert.ToSingle(row["TelehubPosY"]),
1330 Convert.ToSingle(row["TelehubPosZ"])
1331 );
1332 newSettings.TelehubRot = new Quaternion (
1333 Convert.ToSingle(row["TelehubRotX"]),
1334 Convert.ToSingle(row["TelehubRotY"]),
1335 Convert.ToSingle(row["TelehubRotZ"]),
1336 Convert.ToSingle(row["TelehubRotW"])
1337 );
1338 1321
1339 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]); 1322 newSettings.GodBlockSearch = Convert.ToBoolean(row["block_search"]);
1340 newSettings.Casino = Convert.ToBoolean(row["casino"]); 1323 newSettings.Casino = Convert.ToBoolean(row["casino"]);
@@ -1675,16 +1658,7 @@ namespace OpenSim.Data.MySQL
1675 cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch); 1658 cmd.Parameters.AddWithValue("block_search", settings.GodBlockSearch);
1676 cmd.Parameters.AddWithValue("casino", settings.Casino); 1659 cmd.Parameters.AddWithValue("casino", settings.Casino);
1677 1660
1678 cmd.Parameters.AddWithValue("TelehubEnabled", settings.HasTelehub);
1679 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); 1661 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
1680 cmd.Parameters.AddWithValue("TelehubName", settings.TelehubName);
1681 cmd.Parameters.AddWithValue("TelehubPosX", settings.TelehubPos.X);
1682 cmd.Parameters.AddWithValue("TelehubPosY", settings.TelehubPos.Y);
1683 cmd.Parameters.AddWithValue("TelehubPosZ", settings.TelehubPos.Z);
1684 cmd.Parameters.AddWithValue("TelehubRotX", settings.TelehubRot.X);
1685 cmd.Parameters.AddWithValue("TelehubRotY", settings.TelehubRot.Y);
1686 cmd.Parameters.AddWithValue("TelehubRotZ", settings.TelehubRot.Z);
1687 cmd.Parameters.AddWithValue("TelehubRotW", settings.TelehubRot.W);
1688 } 1662 }
1689 1663
1690 /// <summary> 1664 /// <summary>
@@ -1899,20 +1873,20 @@ namespace OpenSim.Data.MySQL
1899 1873
1900 using (MySqlCommand cmd = dbcon.CreateCommand()) 1874 using (MySqlCommand cmd = dbcon.CreateCommand())
1901 { 1875 {
1902 cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; 1876 cmd.CommandText = "select Yaw, Pitch, Distance from spawn_points where RegionID = ?RegionID";
1903 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); 1877 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
1904 1878
1905 using (IDataReader r = cmd.ExecuteReader()) 1879 using (IDataReader r = cmd.ExecuteReader())
1906 { 1880 {
1907 while (r.Read()) 1881 while (r.Read())
1908 { 1882 {
1909 Vector3 point = new Vector3(); 1883 SpawnPoint sp = new SpawnPoint();
1910 1884
1911 point.X = (float)r["PointX"]; 1885 sp.Yaw = (float)r["Yaw"];
1912 point.Y = (float)r["PointY"]; 1886 sp.Pitch = (float)r["Pitch"];
1913 point.Z = (float)r["PointZ"]; 1887 sp.Distance = (float)r["Distance"];
1914 1888
1915 rs.AddSpawnPoint(point); 1889 rs.AddSpawnPoint(sp);
1916 } 1890 }
1917 } 1891 }
1918 } 1892 }
@@ -1937,14 +1911,14 @@ namespace OpenSim.Data.MySQL
1937 1911
1938 cmd.Parameters.Clear(); 1912 cmd.Parameters.Clear();
1939 1913
1940 cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?RegionID, ?PointX, ?PointY,?PointZ)"; 1914 cmd.CommandText = "insert into spawn_points (RegionID, Yaw, Pitch, Distance) values ( ?RegionID, ?Yaw, ?Pitch, ?Distance)";
1941 1915
1942 foreach (Vector3 p in rs.SpawnPoints()) 1916 foreach (SpawnPoint p in rs.SpawnPoints())
1943 { 1917 {
1944 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); 1918 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
1945 cmd.Parameters.AddWithValue("?PointX", p.X); 1919 cmd.Parameters.AddWithValue("?Yaw", p.Yaw);
1946 cmd.Parameters.AddWithValue("?PointY", p.Y); 1920 cmd.Parameters.AddWithValue("?Pitch", p.Pitch);
1947 cmd.Parameters.AddWithValue("?PointZ", p.Z); 1921 cmd.Parameters.AddWithValue("?Distance", p.Distance);
1948 1922
1949 cmd.ExecuteNonQuery(); 1923 cmd.ExecuteNonQuery();
1950 cmd.Parameters.Clear(); 1924 cmd.Parameters.Clear();
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index 3872a75..219de62 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -848,21 +848,12 @@ COMMIT;
848BEGIN; 848BEGIN;
849CREATE TABLE IF NOT EXISTS `spawn_points` ( 849CREATE TABLE IF NOT EXISTS `spawn_points` (
850 `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL, 850 `RegionID` varchar(36) COLLATE utf8_unicode_ci NOT NULL,
851 `PointX` float NOT NULL, 851 `Yaw` float NOT NULL,
852 `PointY` float NOT NULL, 852 `Pitch` float NOT NULL,
853 `PointZ` float NOT NULL, 853 `Distance` float NOT NULL,
854 KEY `RegionID` (`RegionID`) 854 KEY `RegionID` (`RegionID`)
855) ENGINE=Innodb; 855) ENGINE=Innodb;
856 856
857ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL; 857ALTER TABLE `regionsettings` ADD COLUMN `TelehubObject` varchar(36) NOT NULL;
858ALTER TABLE `regionsettings` ADD COLUMN `TelehubName` varchar(255) NOT NULL;
859ALTER TABLE `regionsettings` ADD COLUMN `TelehubEnabled` tinyint(4) NOT NULL;
860ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosX` float NOT NULL;
861ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosY` float NOT NULL;
862ALTER TABLE `regionsettings` ADD COLUMN `TelehubPosZ` float NOT NULL;
863ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotX` float NOT NULL;
864ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotY` float NOT NULL;
865ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotZ` float NOT NULL;
866ALTER TABLE `regionsettings` ADD COLUMN `TelehubRotW` float NOT NULL;
867COMMIT; 858COMMIT;
868 859
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs
index 01406ce..7cdfc1c 100644
--- a/OpenSim/Framework/RegionSettings.cs
+++ b/OpenSim/Framework/RegionSettings.cs
@@ -32,6 +32,47 @@ using OpenMetaverse;
32 32
33namespace OpenSim.Framework 33namespace OpenSim.Framework
34{ 34{
35 public struct SpawnPoint
36 {
37 public float Yaw;
38 public float Pitch;
39 public float Distance;
40
41 public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point)
42 {
43 // The point is an absolute position, so we need the relative
44 // location to the spawn point
45 Vector3 offset = pos - point;
46 Distance = Vector3.Mag(offset);
47
48 // Next we need to rotate this vector into the spawn point's
49 // coordinate system
50 offset = offset * rot;
51
52 Vector3 dir = Vector3.Normalize(offset);
53
54 // Get the bearing (yaw)
55 Yaw = (float)Math.Atan2(dir.Y, dir.X);
56
57 // Get the elevation (pitch)
58 Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y));
59 }
60
61 public Vector3 GetLocation(Vector3 pos, Quaternion rot)
62 {
63 Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
64 Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
65
66 Vector3 dir = new Vector3(1, 0, 0) * p * y;
67 Vector3 offset = dir * (float)Distance;
68
69 rot.W = -rot.W;
70 offset *= rot;
71
72 return pos + offset;
73 }
74 }
75
35 public class RegionSettings 76 public class RegionSettings
36 { 77 {
37 public delegate void SaveDelegate(RegionSettings rs); 78 public delegate void SaveDelegate(RegionSettings rs);
@@ -426,14 +467,7 @@ namespace OpenSim.Framework
426 { 467 {
427 get 468 get
428 { 469 {
429 if (HasTelehub) 470 return m_TelehubObject;
430 {
431 return m_TelehubObject;
432 }
433 else
434 {
435 return UUID.Zero;
436 }
437 } 471 }
438 set 472 set
439 { 473 {
@@ -441,66 +475,14 @@ namespace OpenSim.Framework
441 } 475 }
442 } 476 }
443 477
444 // Connected Telehub name
445 private string m_TelehubName;
446 public string TelehubName
447 {
448 get
449 {
450 if (HasTelehub)
451 {
452 return m_TelehubName;
453 }
454 else
455 {
456 return String.Empty;
457 }
458 }
459 set
460 {
461 m_TelehubName = value;
462 }
463 }
464
465 // Connected Telehub position
466 private Vector3 m_TelehubPos;
467 public Vector3 TelehubPos
468 {
469 get
470 {
471 if (HasTelehub)
472 {
473 return m_TelehubPos;
474 }
475 else
476 {
477 return Vector3.Zero;
478 }
479 }
480 set
481 {
482 m_TelehubPos = value;
483 }
484 }
485
486 // Connected Telehub rotation
487 private Quaternion m_TelehubRot;
488 public Quaternion TelehubRot
489 {
490 get
491 { return m_TelehubRot; }
492 set
493 { m_TelehubRot = value; }
494 }
495
496 // Our Connected Telehub's SpawnPoints 478 // Our Connected Telehub's SpawnPoints
497 public List<Vector3> l_SpawnPoints = new List<Vector3>(); 479 public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>();
498 480
499 // Add a SpawnPoint 481 // Add a SpawnPoint
500 // ** These are not region coordinates ** 482 // ** These are not region coordinates **
501 // They are relative to the Telehub coordinates 483 // They are relative to the Telehub coordinates
502 // 484 //
503 public void AddSpawnPoint(Vector3 point) 485 public void AddSpawnPoint(SpawnPoint point)
504 { 486 {
505 l_SpawnPoints.Add(point); 487 l_SpawnPoints.Add(point);
506 } 488 }
@@ -512,7 +494,7 @@ namespace OpenSim.Framework
512 } 494 }
513 495
514 // Return the List of SpawnPoints 496 // Return the List of SpawnPoints
515 public List<Vector3> SpawnPoints() 497 public List<SpawnPoint> SpawnPoints()
516 { 498 {
517 return l_SpawnPoints; 499 return l_SpawnPoints;
518 500
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 4f3b271..ea8d396 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -624,59 +624,37 @@ namespace OpenSim.Region.CoreModules.World.Estate
624 { 624 {
625 case "info ui": 625 case "info ui":
626 // Send info: 626 // Send info:
627 if (Scene.RegionInfo.RegionSettings.HasTelehub) 627 SendTelehubInfo(client);
628 {
629 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
630 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
631 settings.TelehubRot, settings.SpawnPoints());
632 }
633 else
634 {
635 return;
636 }
637 break; 628 break;
638 629
639 case "connect": 630 case "connect":
640 // Add the Telehub 631 // Add the Telehub
641 part = Scene.GetSceneObjectPart((uint)param1); 632 part = Scene.GetSceneObjectPart((uint)param1);
642 if (m_Telehub.Connect(part)) 633 if (part == null)
643 { 634 return;
644 RegionSettings settings = this.Scene.RegionInfo.RegionSettings; 635 SceneObjectGroup grp = part.ParentGroup;
645 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, 636
646 settings.TelehubRot, settings.SpawnPoints()); 637 if (m_Telehub.Connect(grp))
647 } 638 SendTelehubInfo(client);
648 break; 639 break;
649 640
650 case "delete": 641 case "delete":
651 // Disconnect Telehub 642 // Disconnect Telehub
652 part = Scene.GetSceneObjectPart((uint)param1); 643 if (m_Telehub.Disconnect())
653 if (m_Telehub.DisConnect(part)) 644 SendTelehubInfo(client);
654 {
655 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
656 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
657 settings.TelehubRot, settings.SpawnPoints());
658 }
659 break; 645 break;
660 646
661 case "spawnpoint add": 647 case "spawnpoint add":
662 // Add SpawnPoint to the Telehub 648 // Add SpawnPoint to the Telehub
663 part = Scene.GetSceneObjectPart((uint)param1); 649 part = Scene.GetSceneObjectPart((uint)param1);
664 if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) 650 if( m_Telehub.AddSpawnPoint(part.AbsolutePosition))
665 { 651 SendTelehubInfo(client);
666 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
667 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
668 settings.TelehubRot, settings.SpawnPoints());
669 }
670 break; 652 break;
671 653
672 case "spawnpoint remove": 654 case "spawnpoint remove":
673 // Remove SpawnPoint from Telehub 655 // Remove SpawnPoint from Telehub
674 if (m_Telehub.RemoveSpawnPoint((int)param1)) 656 if (m_Telehub.RemoveSpawnPoint((int)param1))
675 { 657 SendTelehubInfo(client);
676 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
677 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
678 settings.TelehubRot, settings.SpawnPoints());
679 }
680 break; 658 break;
681 659
682 default: 660 default:
@@ -1365,5 +1343,39 @@ namespace OpenSim.Region.CoreModules.World.Estate
1365 if (onmessage != null) 1343 if (onmessage != null)
1366 onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message); 1344 onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
1367 } 1345 }
1346
1347
1348 private void SendTelehubInfo(IClientAPI client)
1349 {
1350 RegionSettings settings =
1351 this.Scene.RegionInfo.RegionSettings;
1352
1353 SceneObjectGroup telehub = null;
1354 if (settings.TelehubObject != UUID.Zero &&
1355 (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
1356 {
1357 List<Vector3> spawnPoints = new List<Vector3>();
1358
1359 foreach (SpawnPoint sp in settings.SpawnPoints())
1360 {
1361 spawnPoints.Add(sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation));
1362 }
1363
1364 client.SendTelehubInfo(settings.TelehubObject,
1365 telehub.Name,
1366 telehub.AbsolutePosition,
1367 telehub.GroupRotation,
1368 spawnPoints);
1369 }
1370 else
1371 {
1372 client.SendTelehubInfo(UUID.Zero,
1373 String.Empty,
1374 Vector3.Zero,
1375 Quaternion.Identity,
1376 new List<Vector3>());
1377 }
1378 }
1368 } 1379 }
1369} 1380}
1381
diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs
index ee77ae1..3eb7efa 100644
--- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs
@@ -35,103 +35,82 @@ namespace OpenSim.Region.CoreModules.World.Estate
35{ 35{
36 public class TelehubManager 36 public class TelehubManager
37 { 37 {
38
39 private UUID ObjectID;
40 private string ObjectName;
41 private Vector3 ObjectPosition;
42 Quaternion ObjectRotation;
43 List<Vector3> SpawnPoint = new List<Vector3>();
44 UUID EstateID;
45 bool m_HasTelehub = false;
46 Scene m_Scene; 38 Scene m_Scene;
47 // This will get an option...
48 Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f);
49
50 public bool HasTelehub
51 {
52 get { return m_HasTelehub; }
53 }
54 39
55 public TelehubManager(Scene scene) 40 public TelehubManager(Scene scene)
56 { 41 {
57 m_Scene = scene; 42 m_Scene = scene;
58 } 43 }
59 44
60 // Fill our Telehub struct with values
61// public Telehub TelehubVals()
62// {
63// // Telehub telehub = new Telehub();
64// EstateSettings telehub = m_EstateSettings;
65//
66// telehub.TelehubObject = ObjectID;
67// telehub.TelehubName = ObjectName;
68// telehub.TelehubPos = ObjectPosition;
69// telehub.TelehubRot = ObjectRotation;
70// telehub. = SpawnPoint;
71// return telehub;
72// }
73
74 // Connect the Telehub 45 // Connect the Telehub
75 public bool Connect(SceneObjectPart part) 46 public bool Connect(SceneObjectGroup grp)
76 { 47 {
77 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); 48 try
78 49 {
79 m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID; 50 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
80 m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name; 51
81 m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition; 52 m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID;
82 m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation(); 53 m_Scene.RegionInfo.RegionSettings.Save();
54 }
55 catch (Exception ex)
56 {
57 return false;
58 }
83 59
84 // Clear this for now
85 m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint);
86 m_Scene.RegionInfo.RegionSettings.HasTelehub = true;
87 m_Scene.RegionInfo.RegionSettings.Save();
88 return true; 60 return true;
89 } 61 }
90 62
91 // Disconnect the Telehub: Clear it out for now, look at just disableing 63 // Disconnect the Telehub:
92 public bool DisConnect(SceneObjectPart part) 64 public bool Disconnect()
93 { 65 {
94 bool result = false; 66 if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
67 return false;
95 68
96 try{ 69 try
70 {
97 m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; 71 m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
98 m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty;
99 m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero;
100 // This is probably wrong! But, HasTelehub will block access
101 m_Scene.RegionInfo.RegionSettings.TelehubRot = Quaternion.Identity;
102 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); 72 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
103 m_Scene.RegionInfo.RegionSettings.HasTelehub = false;
104 m_Scene.RegionInfo.RegionSettings.Save(); 73 m_Scene.RegionInfo.RegionSettings.Save();
105 result = true;
106 } 74 }
107 catch (Exception ex) 75 catch (Exception ex)
108 { 76 {
109 result = false; 77 return false;
110 }
111 finally
112 {
113
114 } 78 }
115 79
116 return result; 80 return true;
117 } 81 }
118 82
119 // Add a SpawnPoint to the Telehub 83 // Add a SpawnPoint to the Telehub
120 public bool AddSpawnPoint(Vector3 point) 84 public bool AddSpawnPoint(Vector3 point)
121 { 85 {
86 if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
87 return false;
122 88
123 float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); 89 SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject);
124 Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); 90 if (grp == null)
125 Vector3 spoint = nvec * dist; 91 return false;
92
93 try
94 {
95 SpawnPoint sp = new SpawnPoint();
96 sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point);
97 m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp);
98 m_Scene.RegionInfo.RegionSettings.Save();
99 }
100 catch (Exception ex)
101 {
102 return false;
103 }
126 104
127 m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint);
128 m_Scene.RegionInfo.RegionSettings.Save();
129 return true; 105 return true;
130 } 106 }
131 107
132 // Remove a SpawnPoint from the Telehub 108 // Remove a SpawnPoint from the Telehub
133 public bool RemoveSpawnPoint(int spawnpoint) 109 public bool RemoveSpawnPoint(int spawnpoint)
134 { 110 {
111 if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
112 return false;
113
135 m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); 114 m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint);
136 m_Scene.RegionInfo.RegionSettings.Save(); 115 m_Scene.RegionInfo.RegionSettings.Save();
137 116