aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs69
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs55
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs186
3 files changed, 153 insertions, 157 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 36e9da6..408d63d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -46,7 +46,7 @@ using Nini.Config;
46 46
47namespace OpenSim.Region.CoreModules.Framework.EntityTransfer 47namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
48{ 48{
49 public class EntityTransferModule : ISharedRegionModule, IEntityTransferModule 49 public class EntityTransferModule : INonSharedRegionModule, IEntityTransferModule
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
@@ -65,9 +65,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
65 public bool EnableWaitForCallbackFromTeleportDest { get; set; } 65 public bool EnableWaitForCallbackFromTeleportDest { get; set; }
66 66
67 protected bool m_Enabled = false; 67 protected bool m_Enabled = false;
68 protected Scene m_aScene; 68
69 protected List<Scene> m_Scenes = new List<Scene>(); 69 protected Scene m_scene;
70
70 protected List<UUID> m_agentsInTransit; 71 protected List<UUID> m_agentsInTransit;
72
71 private ExpiringCache<UUID, ExpiringCache<ulong, DateTime>> m_bannedRegions = 73 private ExpiringCache<UUID, ExpiringCache<ulong, DateTime>> m_bannedRegions =
72 new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>(); 74 new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>();
73 75
@@ -129,10 +131,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
129 if (!m_Enabled) 131 if (!m_Enabled)
130 return; 132 return;
131 133
132 if (m_aScene == null) 134 m_scene = scene;
133 m_aScene = scene;
134 135
135 m_Scenes.Add(scene);
136 scene.RegisterModuleInterface<IEntityTransferModule>(this); 136 scene.RegisterModuleInterface<IEntityTransferModule>(this);
137 scene.EventManager.OnNewClient += OnNewClient; 137 scene.EventManager.OnNewClient += OnNewClient;
138 } 138 }
@@ -143,27 +143,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
143 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 143 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
144 } 144 }
145 145
146 public virtual void Close() 146 public virtual void Close() {}
147 {
148 if (!m_Enabled)
149 return;
150 }
151 147
152 public virtual void RemoveRegion(Scene scene) 148 public virtual void RemoveRegion(Scene scene) {}
153 {
154 if (!m_Enabled)
155 return;
156 if (scene == m_aScene)
157 m_aScene = null;
158 149
159 m_Scenes.Remove(scene); 150 public virtual void RegionLoaded(Scene scene) {}
160 }
161
162 public virtual void RegionLoaded(Scene scene)
163 {
164 if (!m_Enabled)
165 return;
166 }
167 151
168 #endregion 152 #endregion
169 153
@@ -294,7 +278,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
294 { 278 {
295 uint x = 0, y = 0; 279 uint x = 0, y = 0;
296 Utils.LongToUInts(regionHandle, out x, out y); 280 Utils.LongToUInts(regionHandle, out x, out y);
297 GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); 281 GridRegion reg = m_scene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y);
298 282
299 if (reg != null) 283 if (reg != null)
300 { 284 {
@@ -441,7 +425,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
441 425
442 string reason; 426 string reason;
443 string version; 427 string version;
444 if (!m_aScene.SimulationService.QueryAccess( 428 if (!m_scene.SimulationService.QueryAccess(
445 finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason)) 429 finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason))
446 { 430 {
447 sp.ControllingClient.SendTeleportFailed(reason); 431 sp.ControllingClient.SendTeleportFailed(reason);
@@ -660,7 +644,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
660 EnableChildAgents(sp); 644 EnableChildAgents(sp);
661 645
662 // Finally, kill the agent we just created at the destination. 646 // Finally, kill the agent we just created at the destination.
663 m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); 647 m_scene.SimulationService.CloseAgent(finalDestination, sp.UUID);
664 648
665 sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout); 649 sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout);
666 } 650 }
@@ -668,7 +652,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
668 protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout) 652 protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason, out bool logout)
669 { 653 {
670 logout = false; 654 logout = false;
671 bool success = m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); 655 bool success = m_scene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason);
672 656
673 if (success) 657 if (success)
674 sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout); 658 sp.Scene.EventManager.TriggerTeleportStart(sp.ControllingClient, reg, finalDestination, teleportFlags, logout);
@@ -678,7 +662,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
678 662
679 protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) 663 protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent)
680 { 664 {
681 return m_aScene.SimulationService.UpdateAgent(finalDestination, agent); 665 return m_scene.SimulationService.UpdateAgent(finalDestination, agent);
682 } 666 }
683 667
684 protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) 668 protected virtual void SetCallbackURL(AgentData agent, RegionInfo region)
@@ -730,7 +714,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
730 return false; 714 return false;
731 } 715 }
732 716
733
734 #endregion 717 #endregion
735 718
736 #region Landmark Teleport 719 #region Landmark Teleport
@@ -742,7 +725,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
742 /// <param name="position"></param> 725 /// <param name="position"></param>
743 public virtual void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm) 726 public virtual void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm)
744 { 727 {
745 GridRegion info = m_aScene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); 728 GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID);
746 729
747 if (info == null) 730 if (info == null)
748 { 731 {
@@ -763,12 +746,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
763 m_log.DebugFormat( 746 m_log.DebugFormat(
764 "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); 747 "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId);
765 748
766 //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId); 749 //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_scene.PresenceService.GetAgent(client.SessionId);
767 GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString()); 750 GridUserInfo uinfo = m_scene.GridUserService.GetGridUserInfo(client.AgentId.ToString());
768 751
769 if (uinfo != null) 752 if (uinfo != null)
770 { 753 {
771 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); 754 GridRegion regionInfo = m_scene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
772 if (regionInfo == null) 755 if (regionInfo == null)
773 { 756 {
774 // can't find the Home region: Tell viewer and abort 757 // can't find the Home region: Tell viewer and abort
@@ -1625,7 +1608,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1625 #region Agent Arrived 1608 #region Agent Arrived
1626 public void AgentArrivedAtDestination(UUID id) 1609 public void AgentArrivedAtDestination(UUID id)
1627 { 1610 {
1628 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Agent {0} released", id);
1629 ResetFromTransit(id); 1611 ResetFromTransit(id);
1630 } 1612 }
1631 1613
@@ -1896,8 +1878,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1896 //// And the new channel... 1878 //// And the new channel...
1897 //if (m_interregionCommsOut != null) 1879 //if (m_interregionCommsOut != null)
1898 // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); 1880 // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true);
1899 if (m_aScene.SimulationService != null) 1881 if (m_scene.SimulationService != null)
1900 successYN = m_aScene.SimulationService.CreateObject(destination, newPosition, grp, true); 1882 successYN = m_scene.SimulationService.CreateObject(destination, newPosition, grp, true);
1901 1883
1902 if (successYN) 1884 if (successYN)
1903 { 1885 {
@@ -2004,7 +1986,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2004 /// </summary> 1986 /// </summary>
2005 /// <returns>true if the agent is in the process of being teleported, false otherwise.</returns> 1987 /// <returns>true if the agent is in the process of being teleported, false otherwise.</returns>
2006 /// <param name='id'>The agent ID</para></param> 1988 /// <param name='id'>The agent ID</para></param>
2007 protected bool IsInTransit(UUID id) 1989 public bool IsInTransit(UUID id)
2008 { 1990 {
2009 lock (m_agentsInTransit) 1991 lock (m_agentsInTransit)
2010 return m_agentsInTransit.Contains(id); 1992 return m_agentsInTransit.Contains(id);
@@ -2024,10 +2006,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2024 if (m_agentsInTransit.Contains(id)) 2006 if (m_agentsInTransit.Contains(id))
2025 { 2007 {
2026 m_agentsInTransit.Remove(id); 2008 m_agentsInTransit.Remove(id);
2009
2010 m_log.DebugFormat(
2011 "[ENTITY TRANSFER MODULE]: Agent {0} cleared from transit in {1}",
2012 id, m_scene.RegionInfo.RegionName);
2013
2027 return true; 2014 return true;
2028 } 2015 }
2029 } 2016 }
2030 2017
2018 m_log.WarnFormat(
2019 "[ENTITY TRANSFER MODULE]: Agent {0} requested to clear from transit in {1} but was already cleared.",
2020 id, m_scene.RegionInfo.RegionName);
2021
2031 return false; 2022 return false;
2032 } 2023 }
2033 2024
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index b578bcb..4124667 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -45,11 +45,11 @@ using Nini.Config;
45 45
46namespace OpenSim.Region.CoreModules.Framework.EntityTransfer 46namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
47{ 47{
48 public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule 48 public class HGEntityTransferModule
49 : EntityTransferModule, INonSharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule
49 { 50 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 52
52 private bool m_Initialized = false;
53 private int m_levelHGTeleport = 0; 53 private int m_levelHGTeleport = 0;
54 54
55 private GatekeeperServiceConnector m_GatekeeperConnector; 55 private GatekeeperServiceConnector m_GatekeeperConnector;
@@ -64,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
64 public override void Initialise(IConfigSource source) 64 public override void Initialise(IConfigSource source)
65 { 65 {
66 IConfig moduleConfig = source.Configs["Modules"]; 66 IConfig moduleConfig = source.Configs["Modules"];
67
67 if (moduleConfig != null) 68 if (moduleConfig != null)
68 { 69 {
69 string name = moduleConfig.GetString("EntityTransferModule", ""); 70 string name = moduleConfig.GetString("EntityTransferModule", "");
@@ -82,10 +83,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
82 public override void AddRegion(Scene scene) 83 public override void AddRegion(Scene scene)
83 { 84 {
84 base.AddRegion(scene); 85 base.AddRegion(scene);
86
85 if (m_Enabled) 87 if (m_Enabled)
86 {
87 scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); 88 scene.RegisterModuleInterface<IUserAgentVerificationModule>(this);
88 }
89 } 89 }
90 90
91 protected override void OnNewClient(IClientAPI client) 91 protected override void OnNewClient(IClientAPI client)
@@ -98,33 +98,28 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
98 public override void RegionLoaded(Scene scene) 98 public override void RegionLoaded(Scene scene)
99 { 99 {
100 base.RegionLoaded(scene); 100 base.RegionLoaded(scene);
101 if (m_Enabled)
102 if (!m_Initialized)
103 {
104 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
105 m_Initialized = true;
106
107 }
108 101
102 if (m_Enabled)
103 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
109 } 104 }
105
110 public override void RemoveRegion(Scene scene) 106 public override void RemoveRegion(Scene scene)
111 { 107 {
112 base.AddRegion(scene); 108 base.AddRegion(scene);
109
113 if (m_Enabled) 110 if (m_Enabled)
114 {
115 scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this); 111 scene.UnregisterModuleInterface<IUserAgentVerificationModule>(this);
116 }
117 } 112 }
118 113
119
120 #endregion 114 #endregion
121 115
122 #region HG overrides of IEntiryTransferModule 116 #region HG overrides of IEntiryTransferModule
123 117
124 protected override GridRegion GetFinalDestination(GridRegion region) 118 protected override GridRegion GetFinalDestination(GridRegion region)
125 { 119 {
126 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID); 120 int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, region.RegionID);
127 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); 121 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags);
122
128 if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) 123 if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
129 { 124 {
130 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); 125 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID);
@@ -135,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
135 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI); 130 m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: GetHyperlinkRegion to Gatekeeper {0} failed", region.ServerURI);
136 return real_destination; 131 return real_destination;
137 } 132 }
133
138 return region; 134 return region;
139 } 135 }
140 136
@@ -143,7 +139,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
143 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) 139 if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg))
144 return true; 140 return true;
145 141
146 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 142 int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, reg.RegionID);
147 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) 143 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
148 return true; 144 return true;
149 145
@@ -156,7 +152,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
156 if (logout) 152 if (logout)
157 { 153 {
158 // Log them out of this grid 154 // Log them out of this grid
159 m_aScene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); 155 m_scene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
160 } 156 }
161 } 157 }
162 158
@@ -165,7 +161,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
165 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI); 161 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: CreateAgent {0} {1}", reg.ServerURI, finalDestination.ServerURI);
166 reason = string.Empty; 162 reason = string.Empty;
167 logout = false; 163 logout = false;
168 int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); 164 int flags = m_scene.GridService.GetRegionFlags(m_scene.RegionInfo.ScopeID, reg.RegionID);
169 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) 165 if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0)
170 { 166 {
171 // this user is going to another grid 167 // this user is going to another grid
@@ -205,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
205 "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId); 201 "[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.Name, client.AgentId);
206 202
207 // Let's find out if this is a foreign user or a local user 203 // Let's find out if this is a foreign user or a local user
208 IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); 204 IUserManagement uMan = m_scene.RequestModuleInterface<IUserManagement>();
209 if (uMan != null && uMan.IsLocalGridUser(id)) 205 if (uMan != null && uMan.IsLocalGridUser(id))
210 { 206 {
211 // local grid user 207 // local grid user
@@ -262,19 +258,21 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
262 { 258 {
263 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}", 259 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Teleporting agent via landmark to {0} region {1} position {2}",
264 (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position); 260 (lm.Gatekeeper == string.Empty) ? "local" : lm.Gatekeeper, lm.RegionID, lm.Position);
261
265 if (lm.Gatekeeper == string.Empty) 262 if (lm.Gatekeeper == string.Empty)
266 { 263 {
267 base.RequestTeleportLandmark(remoteClient, lm); 264 base.RequestTeleportLandmark(remoteClient, lm);
268 return; 265 return;
269 } 266 }
270 267
271 GridRegion info = m_aScene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID); 268 GridRegion info = m_scene.GridService.GetRegionByUUID(UUID.Zero, lm.RegionID);
272 269
273 // Local region? 270 // Local region?
274 if (info != null) 271 if (info != null)
275 { 272 {
276 ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position, 273 ((Scene)(remoteClient.Scene)).RequestTeleportLocation(remoteClient, info.RegionHandle, lm.Position,
277 Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark)); 274 Vector3.Zero, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaLandmark));
275
278 return; 276 return;
279 } 277 }
280 else 278 else
@@ -285,6 +283,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
285 GridRegion gatekeeper = new GridRegion(); 283 GridRegion gatekeeper = new GridRegion();
286 gatekeeper.ServerURI = lm.Gatekeeper; 284 gatekeeper.ServerURI = lm.Gatekeeper;
287 GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID)); 285 GridRegion finalDestination = gConn.GetHyperlinkRegion(gatekeeper, new UUID(lm.RegionID));
286
288 if (finalDestination != null) 287 if (finalDestination != null)
289 { 288 {
290 ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId); 289 ScenePresence sp = scene.GetScenePresence(remoteClient.AgentId);
@@ -314,8 +313,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
314 IUserAgentService security = new UserAgentServiceConnector(url); 313 IUserAgentService security = new UserAgentServiceConnector(url);
315 return security.VerifyClient(aCircuit.SessionID, token); 314 return security.VerifyClient(aCircuit.SessionID, token);
316 } 315 }
317 else 316 else
318 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!", aCircuit.firstname, aCircuit.lastname); 317 {
318 m_log.DebugFormat(
319 "[HG ENTITY TRANSFER MODULE]: Agent {0} {1} does not have a HomeURI OH NO!",
320 aCircuit.firstname, aCircuit.lastname);
321 }
319 322
320 return false; 323 return false;
321 } 324 }
@@ -332,8 +335,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
332 } 335 }
333 336
334 // Let's find out if this is a foreign user or a local user 337 // Let's find out if this is a foreign user or a local user
335 IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>(); 338 IUserManagement uMan = m_scene.RequestModuleInterface<IUserManagement>();
336 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, obj.AgentId); 339 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, obj.AgentId);
337 if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) 340 if (uMan != null && uMan.IsLocalGridUser(obj.AgentId))
338 { 341 {
339 // local grid user 342 // local grid user
@@ -356,7 +359,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
356 359
357 #endregion 360 #endregion
358 361
359
360 private GridRegion MakeRegion(AgentCircuitData aCircuit) 362 private GridRegion MakeRegion(AgentCircuitData aCircuit)
361 { 363 {
362 GridRegion region = new GridRegion(); 364 GridRegion region = new GridRegion();
@@ -373,6 +375,5 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
373 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); 375 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
374 return region; 376 return region;
375 } 377 }
376
377 } 378 }
378} 379} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 90f27c4..270daad 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Linq;
29using System.Reflection; 30using System.Reflection;
30using log4net; 31using log4net;
31using Nini.Config; 32using Nini.Config;
@@ -41,22 +42,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
41 public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService 42 public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService
42 { 43 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 // Version of this service
45 private const string m_Version = "SIMULATION/0.1";
46 45
47 private List<Scene> m_sceneList = new List<Scene>(); 46 /// <summary>
47 /// Version of this service
48 /// </summary>
49 private const string m_Version = "SIMULATION/0.1";
48 50
49 private IEntityTransferModule m_AgentTransferModule; 51 /// <summary>
50 protected IEntityTransferModule AgentTransferModule 52 /// Map region ID to scene.
51 { 53 /// </summary>
52 get 54 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
53 {
54 if (m_AgentTransferModule == null)
55 m_AgentTransferModule = m_sceneList[0].RequestModuleInterface<IEntityTransferModule>();
56 return m_AgentTransferModule;
57 }
58 }
59 55
56 /// <summary>
57 /// Is this module enabled?
58 /// </summary>
60 private bool m_ModuleEnabled = false; 59 private bool m_ModuleEnabled = false;
61 60
62 #region IRegionModule 61 #region IRegionModule
@@ -129,12 +128,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
129 /// <param name="scene"></param> 128 /// <param name="scene"></param>
130 public void RemoveScene(Scene scene) 129 public void RemoveScene(Scene scene)
131 { 130 {
132 lock (m_sceneList) 131 lock (m_scenes)
133 { 132 {
134 if (m_sceneList.Contains(scene)) 133 if (m_scenes.ContainsKey(scene.RegionInfo.RegionID))
135 { 134 m_scenes.Remove(scene.RegionInfo.RegionID);
136 m_sceneList.Remove(scene); 135 else
137 } 136 m_log.WarnFormat(
137 "[LOCAL SIMULATION CONNECTOR]: Tried to remove region {0} but it was not present",
138 scene.RegionInfo.RegionName);
138 } 139 }
139 } 140 }
140 141
@@ -144,13 +145,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
144 /// <param name="scene"></param> 145 /// <param name="scene"></param>
145 public void Init(Scene scene) 146 public void Init(Scene scene)
146 { 147 {
147 if (!m_sceneList.Contains(scene)) 148 lock (m_scenes)
148 { 149 {
149 lock (m_sceneList) 150 if (!m_scenes.ContainsKey(scene.RegionInfo.RegionID))
150 { 151 m_scenes[scene.RegionInfo.RegionID] = scene;
151 m_sceneList.Add(scene); 152 else
152 } 153 m_log.WarnFormat(
153 154 "[LOCAL SIMULATION CONNECTOR]: Tried to add region {0} but it is already present",
155 scene.RegionInfo.RegionName);
154 } 156 }
155 } 157 }
156 158
@@ -160,13 +162,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
160 162
161 public IScene GetScene(ulong regionhandle) 163 public IScene GetScene(ulong regionhandle)
162 { 164 {
163 foreach (Scene s in m_sceneList) 165 foreach (Scene s in m_scenes.Values)
164 { 166 {
165 if (s.RegionInfo.RegionHandle == regionhandle) 167 if (s.RegionInfo.RegionHandle == regionhandle)
166 return s; 168 return s;
167 } 169 }
170
168 // ? weird. should not happen 171 // ? weird. should not happen
169 return m_sceneList[0]; 172 return m_scenes.Values.ToArray()[0];
170 } 173 }
171 174
172 public ISimulationService GetInnerService() 175 public ISimulationService GetInnerService()
@@ -187,13 +190,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
187 return false; 190 return false;
188 } 191 }
189 192
190 foreach (Scene s in m_sceneList) 193 if (m_scenes.ContainsKey(destination.RegionID))
191 { 194 {
192 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
193 {
194// m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); 195// m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName);
195 return s.NewUserConnection(aCircuit, teleportFlags, out reason); 196 return m_scenes[destination.RegionID].NewUserConnection(aCircuit, teleportFlags, out reason);
196 }
197 } 197 }
198 198
199 reason = "Did not find region " + destination.RegionName; 199 reason = "Did not find region " + destination.RegionName;
@@ -205,17 +205,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
205 if (destination == null) 205 if (destination == null)
206 return false; 206 return false;
207 207
208 foreach (Scene s in m_sceneList) 208 if (m_scenes.ContainsKey(destination.RegionID))
209 { 209 {
210 if (s.RegionInfo.RegionHandle == destination.RegionHandle)
211 {
212// m_log.DebugFormat( 210// m_log.DebugFormat(
213// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 211// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
214// s.RegionInfo.RegionName, destination.RegionHandle); 212// s.RegionInfo.RegionName, destination.RegionHandle);
215 213
216 s.IncomingChildAgentDataUpdate(cAgentData); 214 return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData);
217 return true;
218 }
219 } 215 }
220 216
221// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); 217// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle);
@@ -231,11 +227,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
231 // simulator so when we receive the update we need to hand it to each of the 227 // simulator so when we receive the update we need to hand it to each of the
232 // scenes; scenes each check to see if the is a scene presence for the avatar 228 // scenes; scenes each check to see if the is a scene presence for the avatar
233 // note that we really don't need the GridRegion for this call 229 // note that we really don't need the GridRegion for this call
234 foreach (Scene s in m_sceneList) 230 foreach (Scene s in m_scenes.Values)
235 { 231 {
236 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 232 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
237 s.IncomingChildAgentDataUpdate(cAgentData); 233 s.IncomingChildAgentDataUpdate(cAgentData);
238 } 234 }
235
239 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); 236 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
240 return true; 237 return true;
241 } 238 }
@@ -247,14 +244,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
247 if (destination == null) 244 if (destination == null)
248 return false; 245 return false;
249 246
250 foreach (Scene s in m_sceneList) 247 if (m_scenes.ContainsKey(destination.RegionID))
251 { 248 {
252 if (s.RegionInfo.RegionHandle == destination.RegionHandle) 249// m_log.DebugFormat(
253 { 250// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
254 //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); 251// s.RegionInfo.RegionName, destination.RegionHandle);
255 return s.IncomingRetrieveRootAgent(id, out agent); 252
256 } 253 return m_scenes[destination.RegionID].IncomingRetrieveRootAgent(id, out agent);
257 } 254 }
255
258 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); 256 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
259 return false; 257 return false;
260 } 258 }
@@ -266,27 +264,31 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
266 if (destination == null) 264 if (destination == null)
267 return false; 265 return false;
268 266
269 foreach (Scene s in m_sceneList) 267 if (m_scenes.ContainsKey(destination.RegionID))
270 { 268 {
271 if (s.RegionInfo.RegionID == destination.RegionID) 269// m_log.DebugFormat(
272 return s.QueryAccess(id, position, out reason); 270// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
271// s.RegionInfo.RegionName, destination.RegionHandle);
272
273 return m_scenes[destination.RegionID].QueryAccess(id, position, out reason);
273 } 274 }
275
274 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); 276 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
275 return false; 277 return false;
276 } 278 }
277 279
278 public bool ReleaseAgent(UUID origin, UUID id, string uri) 280 public bool ReleaseAgent(UUID originId, UUID agentId, string uri)
279 { 281 {
280 foreach (Scene s in m_sceneList) 282 if (m_scenes.ContainsKey(originId))
281 { 283 {
282 if (s.RegionInfo.RegionID == origin) 284// m_log.DebugFormat(
283 { 285// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
284// m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); 286// s.RegionInfo.RegionName, destination.RegionHandle);
285 AgentTransferModule.AgentArrivedAtDestination(id); 287
286 return true; 288 m_scenes[originId].EntityTransferModule.AgentArrivedAtDestination(agentId);
287// return s.IncomingReleaseAgent(id); 289 return true;
288 }
289 } 290 }
291
290 //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin); 292 //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin);
291 return false; 293 return false;
292 } 294 }
@@ -296,17 +298,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
296 if (destination == null) 298 if (destination == null)
297 return false; 299 return false;
298 300
299 foreach (Scene s in m_sceneList) 301 if (m_scenes.ContainsKey(destination.RegionID))
300 { 302 {
301 if (s.RegionInfo.RegionID == destination.RegionID) 303// m_log.DebugFormat(
302 { 304// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
303 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); 305// s.RegionInfo.RegionName, destination.RegionHandle);
304 // Let's spawn a threadlet right here, because this may take 306
305 // a while 307 Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id); });
306 Util.FireAndForget(delegate { s.IncomingCloseAgent(id); }); 308 return true;
307 return true;
308 }
309 } 309 }
310
310 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 311 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
311 return false; 312 return false;
312 } 313 }
@@ -320,25 +321,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
320 if (destination == null) 321 if (destination == null)
321 return false; 322 return false;
322 323
323 foreach (Scene s in m_sceneList) 324 if (m_scenes.ContainsKey(destination.RegionID))
324 { 325 {
325 if (s.RegionInfo.RegionHandle == destination.RegionHandle) 326// m_log.DebugFormat(
327// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
328// s.RegionInfo.RegionName, destination.RegionHandle);
329
330 Scene s = m_scenes[destination.RegionID];
331
332 if (isLocalCall)
326 { 333 {
327 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); 334 // We need to make a local copy of the object
328 if (isLocalCall) 335 ISceneObject sogClone = sog.CloneForNewScene();
329 { 336 sogClone.SetState(sog.GetStateSnapshot(), s);
330 // We need to make a local copy of the object 337 return s.IncomingCreateObject(newPosition, sogClone);
331 ISceneObject sogClone = sog.CloneForNewScene(); 338 }
332 sogClone.SetState(sog.GetStateSnapshot(), s); 339 else
333 return s.IncomingCreateObject(newPosition, sogClone); 340 {
334 } 341 // Use the object as it came through the wire
335 else 342 return s.IncomingCreateObject(newPosition, sog);
336 {
337 // Use the object as it came through the wire
338 return s.IncomingCreateObject(newPosition, sog);
339 }
340 } 343 }
341 } 344 }
345
342 return false; 346 return false;
343 } 347 }
344 348
@@ -347,13 +351,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
347 if (destination == null) 351 if (destination == null)
348 return false; 352 return false;
349 353
350 foreach (Scene s in m_sceneList) 354 if (m_scenes.ContainsKey(destination.RegionID))
351 { 355 {
352 if (s.RegionInfo.RegionHandle == destination.RegionHandle) 356// m_log.DebugFormat(
353 { 357// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
354 return s.IncomingCreateObject(userID, itemID); 358// s.RegionInfo.RegionName, destination.RegionHandle);
355 } 359
360 return m_scenes[destination.RegionID].IncomingCreateObject(userID, itemID);
356 } 361 }
362
357 return false; 363 return false;
358 } 364 }
359 365
@@ -364,20 +370,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
364 370
365 public bool IsLocalRegion(ulong regionhandle) 371 public bool IsLocalRegion(ulong regionhandle)
366 { 372 {
367 foreach (Scene s in m_sceneList) 373 foreach (Scene s in m_scenes.Values)
368 if (s.RegionInfo.RegionHandle == regionhandle) 374 if (s.RegionInfo.RegionHandle == regionhandle)
369 return true; 375 return true;
376
370 return false; 377 return false;
371 } 378 }
372 379
373 public bool IsLocalRegion(UUID id) 380 public bool IsLocalRegion(UUID id)
374 { 381 {
375 foreach (Scene s in m_sceneList) 382 return m_scenes.ContainsKey(id);
376 if (s.RegionInfo.RegionID == id)
377 return true;
378 return false;
379 } 383 }
380 384
381 #endregion 385 #endregion
382 } 386 }
383} 387} \ No newline at end of file