diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 129 |
1 files changed, 85 insertions, 44 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 430cc6e..074bfb5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -34,6 +34,7 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Services.Interfaces; | 36 | using OpenSim.Services.Interfaces; |
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | 39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation |
39 | { | 40 | { |
@@ -42,13 +43,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | private List<Scene> m_sceneList = new List<Scene>(); | 44 | private List<Scene> m_sceneList = new List<Scene>(); |
44 | 45 | ||
46 | private bool m_ModuleEnabled = false; | ||
45 | 47 | ||
46 | #region IRegionModule | 48 | #region IRegionModule |
47 | 49 | ||
48 | public void Initialise(IConfigSource config) | 50 | public void Initialise(IConfigSource config) |
49 | { | 51 | { |
50 | // This module is always on | 52 | IConfig moduleConfig = config.Configs["Modules"]; |
51 | m_log.Debug("[LOCAL SIMULATION]: Enabling LocalSimulation module"); | 53 | if (moduleConfig != null) |
54 | { | ||
55 | string name = moduleConfig.GetString("SimulationServices", ""); | ||
56 | if (name == Name) | ||
57 | { | ||
58 | //IConfig userConfig = config.Configs["SimulationService"]; | ||
59 | //if (userConfig == null) | ||
60 | //{ | ||
61 | // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); | ||
62 | // return; | ||
63 | //} | ||
64 | |||
65 | m_ModuleEnabled = true; | ||
66 | |||
67 | m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); | ||
68 | } | ||
69 | } | ||
52 | } | 70 | } |
53 | 71 | ||
54 | public void PostInitialise() | 72 | public void PostInitialise() |
@@ -57,16 +75,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
57 | 75 | ||
58 | public void AddRegion(Scene scene) | 76 | public void AddRegion(Scene scene) |
59 | { | 77 | { |
78 | if (!m_ModuleEnabled) | ||
79 | return; | ||
80 | |||
81 | Init(scene); | ||
82 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
60 | } | 83 | } |
61 | 84 | ||
62 | public void RemoveRegion(Scene scene) | 85 | public void RemoveRegion(Scene scene) |
63 | { | 86 | { |
87 | if (!m_ModuleEnabled) | ||
88 | return; | ||
89 | |||
64 | RemoveScene(scene); | 90 | RemoveScene(scene); |
91 | scene.UnregisterModuleInterface<ISimulationService>(this); | ||
65 | } | 92 | } |
66 | 93 | ||
67 | public void RegionLoaded(Scene scene) | 94 | public void RegionLoaded(Scene scene) |
68 | { | 95 | { |
69 | Init(scene); | ||
70 | } | 96 | } |
71 | 97 | ||
72 | public void Close() | 98 | public void Close() |
@@ -109,7 +135,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
109 | lock (m_sceneList) | 135 | lock (m_sceneList) |
110 | { | 136 | { |
111 | m_sceneList.Add(scene); | 137 | m_sceneList.Add(scene); |
112 | scene.RegisterModuleInterface<ISimulationService>(this); | ||
113 | } | 138 | } |
114 | 139 | ||
115 | } | 140 | } |
@@ -119,16 +144,33 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
119 | 144 | ||
120 | #region ISimulation | 145 | #region ISimulation |
121 | 146 | ||
147 | public IScene GetScene(ulong regionhandle) | ||
148 | { | ||
149 | foreach (Scene s in m_sceneList) | ||
150 | { | ||
151 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
152 | return s; | ||
153 | } | ||
154 | // ? weird. should not happen | ||
155 | return m_sceneList[0]; | ||
156 | } | ||
157 | |||
122 | /** | 158 | /** |
123 | * Agent-related communications | 159 | * Agent-related communications |
124 | */ | 160 | */ |
125 | 161 | ||
126 | public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) | 162 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) |
127 | { | 163 | { |
164 | if (destination == null) | ||
165 | { | ||
166 | reason = "Given destination was null"; | ||
167 | m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); | ||
168 | return false; | ||
169 | } | ||
128 | 170 | ||
129 | foreach (Scene s in m_sceneList) | 171 | foreach (Scene s in m_sceneList) |
130 | { | 172 | { |
131 | if (s.RegionInfo.RegionHandle == regionHandle) | 173 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
132 | { | 174 | { |
133 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); | 175 | // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); |
134 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); | 176 | return s.NewUserConnection(aCircuit, teleportFlags, out reason); |
@@ -136,17 +178,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
136 | } | 178 | } |
137 | 179 | ||
138 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); | 180 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); |
139 | uint x = 0, y = 0; | 181 | reason = "Did not find region " + destination.RegionName; |
140 | Utils.LongToUInts(regionHandle, out x, out y); | ||
141 | reason = "Did not find region " + x + "-" + y; | ||
142 | return false; | 182 | return false; |
143 | } | 183 | } |
144 | 184 | ||
145 | public bool UpdateAgent(ulong regionHandle, AgentData cAgentData) | 185 | public bool UpdateAgent(GridRegion destination, AgentData cAgentData) |
146 | { | 186 | { |
187 | if (destination == null) | ||
188 | return false; | ||
189 | |||
147 | foreach (Scene s in m_sceneList) | 190 | foreach (Scene s in m_sceneList) |
148 | { | 191 | { |
149 | if (s.RegionInfo.RegionHandle == regionHandle) | 192 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
150 | { | 193 | { |
151 | //m_log.DebugFormat( | 194 | //m_log.DebugFormat( |
152 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", | 195 | // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", |
@@ -161,11 +204,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
161 | return false; | 204 | return false; |
162 | } | 205 | } |
163 | 206 | ||
164 | public bool UpdateAgent(ulong regionHandle, AgentPosition cAgentData) | 207 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) |
165 | { | 208 | { |
209 | if (destination == null) | ||
210 | return false; | ||
211 | |||
166 | foreach (Scene s in m_sceneList) | 212 | foreach (Scene s in m_sceneList) |
167 | { | 213 | { |
168 | if (s.RegionInfo.RegionHandle == regionHandle) | 214 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
169 | { | 215 | { |
170 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | 216 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); |
171 | s.IncomingChildAgentDataUpdate(cAgentData); | 217 | s.IncomingChildAgentDataUpdate(cAgentData); |
@@ -176,12 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
176 | return false; | 222 | return false; |
177 | } | 223 | } |
178 | 224 | ||
179 | public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) | 225 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) |
180 | { | 226 | { |
181 | agent = null; | 227 | agent = null; |
228 | |||
229 | if (destination == null) | ||
230 | return false; | ||
231 | |||
182 | foreach (Scene s in m_sceneList) | 232 | foreach (Scene s in m_sceneList) |
183 | { | 233 | { |
184 | if (s.RegionInfo.RegionHandle == regionHandle) | 234 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
185 | { | 235 | { |
186 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | 236 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); |
187 | return s.IncomingRetrieveRootAgent(id, out agent); | 237 | return s.IncomingRetrieveRootAgent(id, out agent); |
@@ -191,16 +241,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
191 | return false; | 241 | return false; |
192 | } | 242 | } |
193 | 243 | ||
194 | public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) | 244 | public bool ReleaseAgent(GridRegion destination, UUID id, string uri) |
195 | { | 245 | { |
196 | //uint x, y; | 246 | if (destination == null) |
197 | //Utils.LongToUInts(regionHandle, out x, out y); | 247 | return false; |
198 | //x = x / Constants.RegionSize; | 248 | |
199 | //y = y / Constants.RegionSize; | ||
200 | //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y); | ||
201 | foreach (Scene s in m_sceneList) | 249 | foreach (Scene s in m_sceneList) |
202 | { | 250 | { |
203 | if (s.RegionInfo.RegionHandle == regionHandle) | 251 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
204 | { | 252 | { |
205 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); | 253 | //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); |
206 | return s.IncomingReleaseAgent(id); | 254 | return s.IncomingReleaseAgent(id); |
@@ -210,16 +258,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
210 | return false; | 258 | return false; |
211 | } | 259 | } |
212 | 260 | ||
213 | public bool CloseAgent(ulong regionHandle, UUID id) | 261 | public bool CloseAgent(GridRegion destination, UUID id) |
214 | { | 262 | { |
215 | //uint x, y; | 263 | if (destination == null) |
216 | //Utils.LongToUInts(regionHandle, out x, out y); | 264 | return false; |
217 | //x = x / Constants.RegionSize; | 265 | |
218 | //y = y / Constants.RegionSize; | ||
219 | //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); | ||
220 | foreach (Scene s in m_sceneList) | 266 | foreach (Scene s in m_sceneList) |
221 | { | 267 | { |
222 | if (s.RegionInfo.RegionHandle == regionHandle) | 268 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
223 | { | 269 | { |
224 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); | 270 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); |
225 | return s.IncomingCloseAgent(id); | 271 | return s.IncomingCloseAgent(id); |
@@ -233,11 +279,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
233 | * Object-related communications | 279 | * Object-related communications |
234 | */ | 280 | */ |
235 | 281 | ||
236 | public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) | 282 | public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) |
237 | { | 283 | { |
284 | if (destination == null) | ||
285 | return false; | ||
286 | |||
238 | foreach (Scene s in m_sceneList) | 287 | foreach (Scene s in m_sceneList) |
239 | { | 288 | { |
240 | if (s.RegionInfo.RegionHandle == regionHandle) | 289 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
241 | { | 290 | { |
242 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); | 291 | //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); |
243 | if (isLocalCall) | 292 | if (isLocalCall) |
@@ -257,11 +306,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
257 | return false; | 306 | return false; |
258 | } | 307 | } |
259 | 308 | ||
260 | public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) | 309 | public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) |
261 | { | 310 | { |
311 | if (destination == null) | ||
312 | return false; | ||
313 | |||
262 | foreach (Scene s in m_sceneList) | 314 | foreach (Scene s in m_sceneList) |
263 | { | 315 | { |
264 | if (s.RegionInfo.RegionHandle == regionHandle) | 316 | if (s.RegionInfo.RegionHandle == destination.RegionHandle) |
265 | { | 317 | { |
266 | return s.IncomingCreateObject(userID, itemID); | 318 | return s.IncomingCreateObject(userID, itemID); |
267 | } | 319 | } |
@@ -274,17 +326,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
274 | 326 | ||
275 | #region Misc | 327 | #region Misc |
276 | 328 | ||
277 | public IScene GetScene(ulong regionhandle) | ||
278 | { | ||
279 | foreach (Scene s in m_sceneList) | ||
280 | { | ||
281 | if (s.RegionInfo.RegionHandle == regionhandle) | ||
282 | return s; | ||
283 | } | ||
284 | // ? weird. should not happen | ||
285 | return m_sceneList[0]; | ||
286 | } | ||
287 | |||
288 | public bool IsLocalRegion(ulong regionhandle) | 329 | public bool IsLocalRegion(ulong regionhandle) |
289 | { | 330 | { |
290 | foreach (Scene s in m_sceneList) | 331 | foreach (Scene s in m_sceneList) |