diff options
author | Melanie | 2012-01-24 00:32:10 +0000 |
---|---|---|
committer | Melanie | 2012-01-24 00:32:10 +0000 |
commit | 87799c1f3ddfbc4b0994cac4e54498520899e4d4 (patch) | |
tree | d57c1643237aa84f0d986afa8a1e2be4514e064b /OpenSim/Region/CoreModules/World | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-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/Region/CoreModules/World')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 78 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/TelehubManager.cs | 70 |
2 files changed, 65 insertions, 83 deletions
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); |