aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-01-24 00:32:10 +0000
committerMelanie2012-01-24 00:32:10 +0000
commit87799c1f3ddfbc4b0994cac4e54498520899e4d4 (patch)
treed57c1643237aa84f0d986afa8a1e2be4514e064b /OpenSim
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-87799c1f3ddfbc4b0994cac4e54498520899e4d4.zip
opensim-SC-87799c1f3ddfbc4b0994cac4e54498520899e4d4.tar.gz
opensim-SC-87799c1f3ddfbc4b0994cac4e54498520899e4d4.tar.bz2
opensim-SC-87799c1f3ddfbc4b0994cac4e54498520899e4d4.tar.xz
Change Telehubs to store only the data that is really needed and not
additional redundant information.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs53
-rw-r--r--OpenSim/Framework/RegionSettings.cs116
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs78
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs70
4 files changed, 123 insertions, 194 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index b94f6ac..ebb41a5 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -997,9 +997,7 @@ namespace OpenSim.Data.MySQL
997 "covenant, Sandbox, sunvectorx, sunvectory, " + 997 "covenant, Sandbox, sunvectorx, sunvectory, " +
998 "sunvectorz, loaded_creation_datetime, " + 998 "sunvectorz, loaded_creation_datetime, " +
999 "loaded_creation_id, map_tile_ID, " + 999 "loaded_creation_id, map_tile_ID, " +
1000 "TelehubEnabled, TelehubObject, TelehubName, " + 1000 "TelehubObject) " +
1001 "TelehubPosX, TelehubPosY, TelehubPosZ, " +
1002 "TelehubRotX, TelehubRotY, TelehubRotZ, TelehubRotW) " +
1003 "values (?RegionUUID, ?BlockTerraform, " + 1001 "values (?RegionUUID, ?BlockTerraform, " +
1004 "?BlockFly, ?AllowDamage, ?RestrictPushing, " + 1002 "?BlockFly, ?AllowDamage, ?RestrictPushing, " +
1005 "?AllowLandResell, ?AllowLandJoinDivide, " + 1003 "?AllowLandResell, ?AllowLandJoinDivide, " +
@@ -1015,10 +1013,7 @@ namespace OpenSim.Data.MySQL
1015 "?SunPosition, ?Covenant, ?Sandbox, " + 1013 "?SunPosition, ?Covenant, ?Sandbox, " +
1016 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + 1014 "?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
1017 "?LoadedCreationDateTime, ?LoadedCreationID, " + 1015 "?LoadedCreationDateTime, ?LoadedCreationID, " +
1018 "?TerrainImageID, " + 1016 "?TerrainImageID) ";
1019 "?TelehubEnabled, ?TelehubObject, ?TelehubName, " +
1020 "?TelehubPosX, ?TelehubPosY, ?TelehubPosZ, " +
1021 "?TelehubRotX, ?TelehubRotY, ?TelehubRotZ, ?TelehubRotW )";
1022 1017
1023 FillRegionSettingsCommand(cmd, rs); 1018 FillRegionSettingsCommand(cmd, rs);
1024 1019
@@ -1306,20 +1301,7 @@ namespace OpenSim.Data.MySQL
1306 newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; 1301 newSettings.LoadedCreationID = (String) row["loaded_creation_id"];
1307 1302
1308 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]); 1303 newSettings.TerrainImageID = DBGuid.FromDB(row["map_tile_ID"]);
1309 newSettings.HasTelehub = Convert.ToBoolean(row["TelehubEnabled"]);
1310 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]); 1304 newSettings.TelehubObject = DBGuid.FromDB(row["TelehubObject"]);
1311 newSettings.TelehubName = (string) row["TelehubName"];
1312 newSettings.TelehubPos = new Vector3 (
1313 Convert.ToSingle(row["TelehubPosX"]),
1314 Convert.ToSingle(row["TelehubPosY"]),
1315 Convert.ToSingle(row["TelehubPosZ"])
1316 );
1317 newSettings.TelehubRot = new Quaternion (
1318 Convert.ToSingle(row["TelehubRotX"]),
1319 Convert.ToSingle(row["TelehubRotY"]),
1320 Convert.ToSingle(row["TelehubRotZ"]),
1321 Convert.ToSingle(row["TelehubRotW"])
1322 );
1323 1305
1324 return newSettings; 1306 return newSettings;
1325 } 1307 }
@@ -1650,16 +1632,7 @@ namespace OpenSim.Data.MySQL
1650 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); 1632 cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
1651 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); 1633 cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
1652 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); 1634 cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
1653 cmd.Parameters.AddWithValue("TelehubEnabled", settings.HasTelehub);
1654 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject); 1635 cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
1655 cmd.Parameters.AddWithValue("TelehubName", settings.TelehubName);
1656 cmd.Parameters.AddWithValue("TelehubPosX", settings.TelehubPos.X);
1657 cmd.Parameters.AddWithValue("TelehubPosY", settings.TelehubPos.Y);
1658 cmd.Parameters.AddWithValue("TelehubPosZ", settings.TelehubPos.Z);
1659 cmd.Parameters.AddWithValue("TelehubRotX", settings.TelehubRot.X);
1660 cmd.Parameters.AddWithValue("TelehubRotY", settings.TelehubRot.Y);
1661 cmd.Parameters.AddWithValue("TelehubRotZ", settings.TelehubRot.Z);
1662 cmd.Parameters.AddWithValue("TelehubRotW", settings.TelehubRot.W);
1663 } 1636 }
1664 1637
1665 /// <summary> 1638 /// <summary>
@@ -1874,20 +1847,20 @@ namespace OpenSim.Data.MySQL
1874 1847
1875 using (MySqlCommand cmd = dbcon.CreateCommand()) 1848 using (MySqlCommand cmd = dbcon.CreateCommand())
1876 { 1849 {
1877 cmd.CommandText = "select PointX, PointY, PointZ from spawn_points where RegionID = ?RegionID"; 1850 cmd.CommandText = "select Yaw, Pitch, Distance from spawn_points where RegionID = ?RegionID";
1878 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); 1851 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
1879 1852
1880 using (IDataReader r = cmd.ExecuteReader()) 1853 using (IDataReader r = cmd.ExecuteReader())
1881 { 1854 {
1882 while (r.Read()) 1855 while (r.Read())
1883 { 1856 {
1884 Vector3 point = new Vector3(); 1857 SpawnPoint sp = new SpawnPoint();
1885 1858
1886 point.X = (float)r["PointX"]; 1859 sp.Yaw = (float)r["Yaw"];
1887 point.Y = (float)r["PointY"]; 1860 sp.Pitch = (float)r["Pitch"];
1888 point.Z = (float)r["PointZ"]; 1861 sp.Distance = (float)r["Distance"];
1889 1862
1890 rs.AddSpawnPoint(point); 1863 rs.AddSpawnPoint(sp);
1891 } 1864 }
1892 } 1865 }
1893 } 1866 }
@@ -1912,14 +1885,14 @@ namespace OpenSim.Data.MySQL
1912 1885
1913 cmd.Parameters.Clear(); 1886 cmd.Parameters.Clear();
1914 1887
1915 cmd.CommandText = "insert into spawn_points (RegionID, PointX, PointY, PointZ) values ( ?RegionID, ?PointX, ?PointY,?PointZ)"; 1888 cmd.CommandText = "insert into spawn_points (RegionID, Yaw, Pitch, Distance) values ( ?RegionID, ?Yaw, ?Pitch, ?Distance)";
1916 1889
1917 foreach (Vector3 p in rs.SpawnPoints()) 1890 foreach (SpawnPoint p in rs.SpawnPoints())
1918 { 1891 {
1919 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString()); 1892 cmd.Parameters.AddWithValue("?RegionID", rs.RegionUUID.ToString());
1920 cmd.Parameters.AddWithValue("?PointX", p.X); 1893 cmd.Parameters.AddWithValue("?Yaw", p.Yaw);
1921 cmd.Parameters.AddWithValue("?PointY", p.Y); 1894 cmd.Parameters.AddWithValue("?Pitch", p.Pitch);
1922 cmd.Parameters.AddWithValue("?PointZ", p.Z); 1895 cmd.Parameters.AddWithValue("?Distance", p.Distance);
1923 1896
1924 cmd.ExecuteNonQuery(); 1897 cmd.ExecuteNonQuery();
1925 cmd.Parameters.Clear(); 1898 cmd.Parameters.Clear();
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs
index 9b5bbf2..0a59f43 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);
@@ -398,28 +439,13 @@ namespace OpenSim.Framework
398 set { m_LoadedCreationID = value; } 439 set { m_LoadedCreationID = value; }
399 } 440 }
400 441
401 // Telehub support
402 private bool m_TelehubEnabled = false;
403 public bool HasTelehub
404 {
405 get { return m_TelehubEnabled; }
406 set { m_TelehubEnabled = value; }
407 }
408
409 // Connected Telehub object 442 // Connected Telehub object
410 private UUID m_TelehubObject; 443 private UUID m_TelehubObject;
411 public UUID TelehubObject 444 public UUID TelehubObject
412 { 445 {
413 get 446 get
414 { 447 {
415 if (HasTelehub) 448 return m_TelehubObject;
416 {
417 return m_TelehubObject;
418 }
419 else
420 {
421 return UUID.Zero;
422 }
423 } 449 }
424 set 450 set
425 { 451 {
@@ -427,66 +453,14 @@ namespace OpenSim.Framework
427 } 453 }
428 } 454 }
429 455
430 // Connected Telehub name
431 private string m_TelehubName;
432 public string TelehubName
433 {
434 get
435 {
436 if (HasTelehub)
437 {
438 return m_TelehubName;
439 }
440 else
441 {
442 return String.Empty;
443 }
444 }
445 set
446 {
447 m_TelehubName = value;
448 }
449 }
450
451 // Connected Telehub position
452 private Vector3 m_TelehubPos;
453 public Vector3 TelehubPos
454 {
455 get
456 {
457 if (HasTelehub)
458 {
459 return m_TelehubPos;
460 }
461 else
462 {
463 return Vector3.Zero;
464 }
465 }
466 set
467 {
468 m_TelehubPos = value;
469 }
470 }
471
472 // Connected Telehub rotation
473 private Quaternion m_TelehubRot;
474 public Quaternion TelehubRot
475 {
476 get
477 { return m_TelehubRot; }
478 set
479 { m_TelehubRot = value; }
480 }
481
482 // Our Connected Telehub's SpawnPoints 456 // Our Connected Telehub's SpawnPoints
483 public List<Vector3> l_SpawnPoints = new List<Vector3>(); 457 public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>();
484 458
485 // Add a SpawnPoint 459 // Add a SpawnPoint
486 // ** These are not region coordinates ** 460 // ** These are not region coordinates **
487 // They are relative to the Telehub coordinates 461 // They are relative to the Telehub coordinates
488 // 462 //
489 public void AddSpawnPoint(Vector3 point) 463 public void AddSpawnPoint(SpawnPoint point)
490 { 464 {
491 l_SpawnPoints.Add(point); 465 l_SpawnPoints.Add(point);
492 } 466 }
@@ -498,7 +472,7 @@ namespace OpenSim.Framework
498 } 472 }
499 473
500 // Return the List of SpawnPoints 474 // Return the List of SpawnPoints
501 public List<Vector3> SpawnPoints() 475 public List<SpawnPoint> SpawnPoints()
502 { 476 {
503 return l_SpawnPoints; 477 return l_SpawnPoints;
504 478
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index cdcea65..2789d5f 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -609,59 +609,37 @@ namespace OpenSim.Region.CoreModules.World.Estate
609 { 609 {
610 case "info ui": 610 case "info ui":
611 // Send info: 611 // Send info:
612 if (Scene.RegionInfo.RegionSettings.HasTelehub) 612 SendTelehubInfo(client);
613 {
614 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
615 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
616 settings.TelehubRot, settings.SpawnPoints());
617 }
618 else
619 {
620 return;
621 }
622 break; 613 break;
623 614
624 case "connect": 615 case "connect":
625 // Add the Telehub 616 // Add the Telehub
626 part = Scene.GetSceneObjectPart((uint)param1); 617 part = Scene.GetSceneObjectPart((uint)param1);
627 if (m_Telehub.Connect(part)) 618 if (part == null)
628 { 619 return;
629 RegionSettings settings = this.Scene.RegionInfo.RegionSettings; 620 SceneObjectGroup grp = part.ParentGroup;
630 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos, 621
631 settings.TelehubRot, settings.SpawnPoints()); 622 if (m_Telehub.Connect(grp))
632 } 623 SendTelehubInfo(client);
633 break; 624 break;
634 625
635 case "delete": 626 case "delete":
636 // Disconnect Telehub 627 // Disconnect Telehub
637 part = Scene.GetSceneObjectPart((uint)param1); 628 if (m_Telehub.Disconnect())
638 if (m_Telehub.DisConnect(part)) 629 SendTelehubInfo(client);
639 {
640 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
641 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
642 settings.TelehubRot, settings.SpawnPoints());
643 }
644 break; 630 break;
645 631
646 case "spawnpoint add": 632 case "spawnpoint add":
647 // Add SpawnPoint to the Telehub 633 // Add SpawnPoint to the Telehub
648 part = Scene.GetSceneObjectPart((uint)param1); 634 part = Scene.GetSceneObjectPart((uint)param1);
649 if( m_Telehub.AddSpawnPoint(part.AbsolutePosition)) 635 if( m_Telehub.AddSpawnPoint(part.AbsolutePosition))
650 { 636 SendTelehubInfo(client);
651 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
652 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
653 settings.TelehubRot, settings.SpawnPoints());
654 }
655 break; 637 break;
656 638
657 case "spawnpoint remove": 639 case "spawnpoint remove":
658 // Remove SpawnPoint from Telehub 640 // Remove SpawnPoint from Telehub
659 if (m_Telehub.RemoveSpawnPoint((int)param1)) 641 if (m_Telehub.RemoveSpawnPoint((int)param1))
660 { 642 SendTelehubInfo(client);
661 RegionSettings settings = this.Scene.RegionInfo.RegionSettings;
662 client.SendTelehubInfo(settings.TelehubObject, settings.TelehubName, settings.TelehubPos,
663 settings.TelehubRot, settings.SpawnPoints());
664 }
665 break; 643 break;
666 644
667 default: 645 default:
@@ -1316,5 +1294,39 @@ namespace OpenSim.Region.CoreModules.World.Estate
1316 if (onmessage != null) 1294 if (onmessage != null)
1317 onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message); 1295 onmessage(Scene.RegionInfo.RegionID, fromID, fromName, message);
1318 } 1296 }
1297
1298
1299 private void SendTelehubInfo(IClientAPI client)
1300 {
1301 RegionSettings settings =
1302 this.Scene.RegionInfo.RegionSettings;
1303
1304 SceneObjectGroup telehub = null;
1305 if (settings.TelehubObject != UUID.Zero &&
1306 (telehub = Scene.GetSceneObjectGroup(settings.TelehubObject)) != null)
1307 {
1308 List<Vector3> spawnPoints = new List<Vector3>();
1309
1310 foreach (SpawnPoint sp in settings.SpawnPoints())
1311 {
1312 spawnPoints.Add(sp.GetLocation(telehub.AbsolutePosition, telehub.GroupRotation));
1313 }
1314
1315 client.SendTelehubInfo(settings.TelehubObject,
1316 telehub.Name,
1317 telehub.AbsolutePosition,
1318 telehub.GroupRotation,
1319 spawnPoints);
1320 }
1321 else
1322 {
1323 client.SendTelehubInfo(UUID.Zero,
1324 String.Empty,
1325 Vector3.Zero,
1326 Quaternion.Identity,
1327 new List<Vector3>());
1328 }
1329 }
1319 } 1330 }
1320} 1331}
1332
diff --git a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs
index 2d7d0ee..3eb7efa 100644
--- a/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs
@@ -43,102 +43,72 @@ namespace OpenSim.Region.CoreModules.World.Estate
43 } 43 }
44 44
45 // Connect the Telehub 45 // Connect the Telehub
46 public bool Connect(SceneObjectPart part) 46 public bool Connect(SceneObjectGroup grp)
47 { 47 {
48 bool result = false;
49
50 if (m_Scene.RegionInfo.RegionSettings.HasTelehub)
51 return result;
52
53 try 48 try
54 { 49 {
55 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); 50 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
56 51
57 m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID; 52 m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID;
58 m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name;
59 m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition;
60 m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation();
61 m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(new Vector3(0.0f,0.0f,0.0f));
62 m_Scene.RegionInfo.RegionSettings.HasTelehub = true;
63 m_Scene.RegionInfo.RegionSettings.Save(); 53 m_Scene.RegionInfo.RegionSettings.Save();
64
65 result = true;
66 } 54 }
67 catch (Exception ex) 55 catch (Exception ex)
68 { 56 {
69 result = false; 57 return false;
70 } 58 }
71 59
72 return result; 60 return true;
73 } 61 }
74 62
75 // Disconnect the Telehub: 63 // Disconnect the Telehub:
76 public bool DisConnect(SceneObjectPart part) 64 public bool Disconnect()
77 { 65 {
78 bool result = false; 66 if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
79 67 return false;
80 if (!m_Scene.RegionInfo.RegionSettings.HasTelehub)
81 return result;
82 68
83 try 69 try
84 { 70 {
85 m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; 71 m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
86 m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty;
87 m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero;
88 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); 72 m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
89 m_Scene.RegionInfo.RegionSettings.HasTelehub = false;
90 m_Scene.RegionInfo.RegionSettings.Save(); 73 m_Scene.RegionInfo.RegionSettings.Save();
91
92 result = true;
93 } 74 }
94 catch (Exception ex) 75 catch (Exception ex)
95 { 76 {
96 result = false; 77 return false;
97 } 78 }
98 79
99 return result; 80 return true;
100 } 81 }
101 82
102 // Add a SpawnPoint to the Telehub 83 // Add a SpawnPoint to the Telehub
103 public bool AddSpawnPoint(Vector3 point) 84 public bool AddSpawnPoint(Vector3 point)
104 { 85 {
105 bool result = false; 86 if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
87 return false;
106 88
107 if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) 89 SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject);
108 return result; 90 if (grp == null)
91 return false;
109 92
110 try 93 try
111 { 94 {
112 // Need to update the position in case the Telehubn has been moved 95 SpawnPoint sp = new SpawnPoint();
113 UUID TelehubID = m_Scene.RegionInfo.RegionSettings.TelehubObject; 96 sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point);
114 SceneObjectPart part = m_Scene.GetSceneObjectPart(TelehubID); 97 m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp);
115
116 Vector3 TelehubPos = part.AbsolutePosition;
117 Quaternion TelehubRot = part.GetWorldRotation();
118
119 m_Scene.RegionInfo.RegionSettings.TelehubPos = TelehubPos;
120 m_Scene.RegionInfo.RegionSettings.TelehubRot = TelehubRot;
121
122 float dist = (float) Util.GetDistanceTo(TelehubPos, point);
123 Vector3 nvec = Util.GetNormalizedVector(point - TelehubPos);
124 Vector3 spoint = nvec * dist;
125
126 m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint);
127 m_Scene.RegionInfo.RegionSettings.Save(); 98 m_Scene.RegionInfo.RegionSettings.Save();
128 result = true;
129 } 99 }
130 catch (Exception ex) 100 catch (Exception ex)
131 { 101 {
132 result = false; 102 return false;
133 } 103 }
134 104
135 return result; 105 return true;
136 } 106 }
137 107
138 // Remove a SpawnPoint from the Telehub 108 // Remove a SpawnPoint from the Telehub
139 public bool RemoveSpawnPoint(int spawnpoint) 109 public bool RemoveSpawnPoint(int spawnpoint)
140 { 110 {
141 if (!m_Scene.RegionInfo.RegionSettings.HasTelehub) 111 if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero)
142 return false; 112 return false;
143 113
144 m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); 114 m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint);