aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneBase.cs
diff options
context:
space:
mode:
authorUbitUmarov2014-08-04 20:32:11 +0100
committerUbitUmarov2014-08-04 20:32:11 +0100
commit3d81f25e34cd7d536ad0e36242703ac1bc56038d (patch)
treeea317cda089e8c7e01e13077fc8038bff8ecd14d /OpenSim/Region/Framework/Scenes/SceneBase.cs
parentstart sending terrain in scenePresence after well defined avatar. Minor (diff)
downloadopensim-SC_OLD-3d81f25e34cd7d536ad0e36242703ac1bc56038d.zip
opensim-SC_OLD-3d81f25e34cd7d536ad0e36242703ac1bc56038d.tar.gz
opensim-SC_OLD-3d81f25e34cd7d536ad0e36242703ac1bc56038d.tar.bz2
opensim-SC_OLD-3d81f25e34cd7d536ad0e36242703ac1bc56038d.tar.xz
Revert "start sending terrain in scenePresence after well defined avatar. Minor"
This reverts commit 05a2feba5d780c57c252891a20071800fd9f2e3e.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneBase.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs1160
1 files changed, 580 insertions, 580 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 6adccca..08e26c5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -1,581 +1,581 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading; 31using System.Threading;
32using OpenMetaverse; 32using OpenMetaverse;
33using log4net; 33using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
41namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
42{ 42{
43 public abstract class SceneBase : IScene 43 public abstract class SceneBase : IScene
44 { 44 {
45 protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 protected static readonly string LogHeader = "[SCENE]"; 46 protected static readonly string LogHeader = "[SCENE]";
47 47
48 #region Events 48 #region Events
49 49
50 public event restart OnRestart; 50 public event restart OnRestart;
51 51
52 #endregion 52 #endregion
53 53
54 #region Fields 54 #region Fields
55 55
56 public string Name { get { return RegionInfo.RegionName; } } 56 public string Name { get { return RegionInfo.RegionName; } }
57 57
58 public IConfigSource Config 58 public IConfigSource Config
59 { 59 {
60 get { return GetConfig(); } 60 get { return GetConfig(); }
61 } 61 }
62 62
63 protected virtual IConfigSource GetConfig() 63 protected virtual IConfigSource GetConfig()
64 { 64 {
65 return null; 65 return null;
66 } 66 }
67 67
68 /// <value> 68 /// <value>
69 /// All the region modules attached to this scene. 69 /// All the region modules attached to this scene.
70 /// </value> 70 /// </value>
71 public Dictionary<string, IRegionModuleBase> RegionModules 71 public Dictionary<string, IRegionModuleBase> RegionModules
72 { 72 {
73 get { return m_regionModules; } 73 get { return m_regionModules; }
74 } 74 }
75 private Dictionary<string, IRegionModuleBase> m_regionModules = new Dictionary<string, IRegionModuleBase>(); 75 private Dictionary<string, IRegionModuleBase> m_regionModules = new Dictionary<string, IRegionModuleBase>();
76 76
77 /// <value> 77 /// <value>
78 /// The module interfaces available from this scene. 78 /// The module interfaces available from this scene.
79 /// </value> 79 /// </value>
80 protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>(); 80 protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>();
81 81
82 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>(); 82 protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
83 83
84 /// <value> 84 /// <value>
85 /// The module commanders available from this scene 85 /// The module commanders available from this scene
86 /// </value> 86 /// </value>
87 protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>(); 87 protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
88 88
89 /// <value> 89 /// <value>
90 /// Registered classes that are capable of creating entities. 90 /// Registered classes that are capable of creating entities.
91 /// </value> 91 /// </value>
92 protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>(); 92 protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>();
93 93
94 /// <summary> 94 /// <summary>
95 /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is 95 /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is
96 /// dispensed. 96 /// dispensed.
97 /// </summary> 97 /// </summary>
98 protected uint m_lastAllocatedLocalId = 720000; 98 protected uint m_lastAllocatedLocalId = 720000;
99 99
100 private readonly Mutex _primAllocateMutex = new Mutex(false); 100 private readonly Mutex _primAllocateMutex = new Mutex(false);
101 101
102 protected readonly ClientManager m_clientManager = new ClientManager(); 102 protected readonly ClientManager m_clientManager = new ClientManager();
103 103
104 public bool LoginsEnabled 104 public bool LoginsEnabled
105 { 105 {
106 get 106 get
107 { 107 {
108 return m_loginsEnabled; 108 return m_loginsEnabled;
109 } 109 }
110 110
111 set 111 set
112 { 112 {
113 if (m_loginsEnabled != value) 113 if (m_loginsEnabled != value)
114 { 114 {
115 m_loginsEnabled = value; 115 m_loginsEnabled = value;
116 EventManager.TriggerRegionLoginsStatusChange(this); 116 EventManager.TriggerRegionLoginsStatusChange(this);
117 } 117 }
118 } 118 }
119 } 119 }
120 private bool m_loginsEnabled; 120 private bool m_loginsEnabled;
121 121
122 public bool Ready 122 public bool Ready
123 { 123 {
124 get 124 get
125 { 125 {
126 return m_ready; 126 return m_ready;
127 } 127 }
128 128
129 set 129 set
130 { 130 {
131 if (m_ready != value) 131 if (m_ready != value)
132 { 132 {
133 m_ready = value; 133 m_ready = value;
134 EventManager.TriggerRegionReadyStatusChange(this); 134 EventManager.TriggerRegionReadyStatusChange(this);
135 } 135 }
136 } 136 }
137 } 137 }
138 private bool m_ready; 138 private bool m_ready;
139 139
140 public float TimeDilation 140 public float TimeDilation
141 { 141 {
142 get { return 1.0f; } 142 get { return 1.0f; }
143 } 143 }
144 144
145 protected ulong m_regionHandle; 145 protected ulong m_regionHandle;
146 protected string m_regionName; 146 protected string m_regionName;
147 147
148 public ITerrainChannel Heightmap; 148 public ITerrainChannel Heightmap;
149 149
150 /// <value> 150 /// <value>
151 /// Allows retrieval of land information for this scene. 151 /// Allows retrieval of land information for this scene.
152 /// </value> 152 /// </value>
153 public ILandChannel LandChannel; 153 public ILandChannel LandChannel;
154 154
155 /// <value> 155 /// <value>
156 /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules 156 /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules
157 /// to subscribe to scene events. 157 /// to subscribe to scene events.
158 /// </value> 158 /// </value>
159 public EventManager EventManager 159 public EventManager EventManager
160 { 160 {
161 get { return m_eventManager; } 161 get { return m_eventManager; }
162 } 162 }
163 protected EventManager m_eventManager; 163 protected EventManager m_eventManager;
164 164
165 protected ScenePermissions m_permissions; 165 protected ScenePermissions m_permissions;
166 public ScenePermissions Permissions 166 public ScenePermissions Permissions
167 { 167 {
168 get { return m_permissions; } 168 get { return m_permissions; }
169 } 169 }
170 170
171 protected string m_datastore; 171 protected string m_datastore;
172 172
173 /* Used by the loadbalancer plugin on GForge */ 173 /* Used by the loadbalancer plugin on GForge */
174 protected RegionStatus m_regStatus; 174 protected RegionStatus m_regStatus;
175 public RegionStatus RegionStatus 175 public RegionStatus RegionStatus
176 { 176 {
177 get { return m_regStatus; } 177 get { return m_regStatus; }
178 set { m_regStatus = value; } 178 set { m_regStatus = value; }
179 } 179 }
180 180
181 #endregion 181 #endregion
182 182
183 public SceneBase(RegionInfo regInfo) 183 public SceneBase(RegionInfo regInfo)
184 { 184 {
185 RegionInfo = regInfo; 185 RegionInfo = regInfo;
186 } 186 }
187 187
188 #region Update Methods 188 #region Update Methods
189 189
190 /// <summary> 190 /// <summary>
191 /// Called to update the scene loop by a number of frames and until shutdown. 191 /// Called to update the scene loop by a number of frames and until shutdown.
192 /// </summary> 192 /// </summary>
193 /// <param name="frames"> 193 /// <param name="frames">
194 /// Number of frames to update. Exits on shutdown even if there are frames remaining. 194 /// Number of frames to update. Exits on shutdown even if there are frames remaining.
195 /// If -1 then updates until shutdown. 195 /// If -1 then updates until shutdown.
196 /// </param> 196 /// </param>
197 public abstract void Update(int frames); 197 public abstract void Update(int frames);
198 198
199 #endregion 199 #endregion
200 200
201 #region Terrain Methods 201 #region Terrain Methods
202 202
203 /// <summary> 203 /// <summary>
204 /// Loads the World heightmap 204 /// Loads the World heightmap
205 /// </summary> 205 /// </summary>
206 public abstract void LoadWorldMap(); 206 public abstract void LoadWorldMap();
207 207
208 /// <summary> 208 /// <summary>
209 /// Send the region heightmap to the client 209 /// Send the region heightmap to the client
210 /// </summary> 210 /// </summary>
211 /// <param name="RemoteClient">Client to send to</param> 211 /// <param name="RemoteClient">Client to send to</param>
212 public virtual void SendLayerData(IClientAPI RemoteClient) 212 public virtual void SendLayerData(IClientAPI RemoteClient)
213 { 213 {
214 RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); 214 RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised());
215 } 215 }
216 216
217 #endregion 217 #endregion
218 218
219 #region Add/Remove Agent/Avatar 219 #region Add/Remove Agent/Avatar
220 220
221 public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); 221 public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type);
222 222
223 public abstract bool CloseAgent(UUID agentID, bool force); 223 public abstract bool CloseAgent(UUID agentID, bool force);
224 224
225 public bool TryGetScenePresence(UUID agentID, out object scenePresence) 225 public bool TryGetScenePresence(UUID agentID, out object scenePresence)
226 { 226 {
227 scenePresence = null; 227 scenePresence = null;
228 ScenePresence sp = null; 228 ScenePresence sp = null;
229 if (TryGetScenePresence(agentID, out sp)) 229 if (TryGetScenePresence(agentID, out sp))
230 { 230 {
231 scenePresence = sp; 231 scenePresence = sp;
232 return true; 232 return true;
233 } 233 }
234 234
235 return false; 235 return false;
236 } 236 }
237 237
238 /// <summary> 238 /// <summary>
239 /// Try to get a scene presence from the scene 239 /// Try to get a scene presence from the scene
240 /// </summary> 240 /// </summary>
241 /// <param name="agentID"></param> 241 /// <param name="agentID"></param>
242 /// <param name="scenePresence">null if there is no scene presence with the given agent id</param> 242 /// <param name="scenePresence">null if there is no scene presence with the given agent id</param>
243 /// <returns>true if there was a scene presence with the given id, false otherwise.</returns> 243 /// <returns>true if there was a scene presence with the given id, false otherwise.</returns>
244 public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); 244 public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence);
245 245
246 #endregion 246 #endregion
247 247
248 /// <summary> 248 /// <summary>
249 /// 249 ///
250 /// </summary> 250 /// </summary>
251 /// <returns></returns> 251 /// <returns></returns>
252 public virtual RegionInfo RegionInfo { get; private set; } 252 public virtual RegionInfo RegionInfo { get; private set; }
253 253
254 #region admin stuff 254 #region admin stuff
255 255
256 public abstract void OtherRegionUp(GridRegion otherRegion); 256 public abstract void OtherRegionUp(GridRegion otherRegion);
257 257
258 public virtual string GetSimulatorVersion() 258 public virtual string GetSimulatorVersion()
259 { 259 {
260 return "OpenSimulator Server"; 260 return "OpenSimulator Server";
261 } 261 }
262 262
263 #endregion 263 #endregion
264 264
265 #region Shutdown 265 #region Shutdown
266 266
267 /// <summary> 267 /// <summary>
268 /// Tidy before shutdown 268 /// Tidy before shutdown
269 /// </summary> 269 /// </summary>
270 public virtual void Close() 270 public virtual void Close()
271 { 271 {
272 try 272 try
273 { 273 {
274 EventManager.TriggerShutdown(); 274 EventManager.TriggerShutdown();
275 } 275 }
276 catch (Exception e) 276 catch (Exception e)
277 { 277 {
278 m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); 278 m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e));
279 } 279 }
280 } 280 }
281 281
282 #endregion 282 #endregion
283 283
284 /// <summary> 284 /// <summary>
285 /// Returns a new unallocated local ID 285 /// Returns a new unallocated local ID
286 /// </summary> 286 /// </summary>
287 /// <returns>A brand new local ID</returns> 287 /// <returns>A brand new local ID</returns>
288 public uint AllocateLocalId() 288 public uint AllocateLocalId()
289 { 289 {
290 uint myID; 290 uint myID;
291 291
292 _primAllocateMutex.WaitOne(); 292 _primAllocateMutex.WaitOne();
293 myID = ++m_lastAllocatedLocalId; 293 myID = ++m_lastAllocatedLocalId;
294 _primAllocateMutex.ReleaseMutex(); 294 _primAllocateMutex.ReleaseMutex();
295 295
296 return myID; 296 return myID;
297 } 297 }
298 298
299 #region Module Methods 299 #region Module Methods
300 300
301 /// <summary> 301 /// <summary>
302 /// Add a region-module to this scene. TODO: This will replace AddModule in the future. 302 /// Add a region-module to this scene. TODO: This will replace AddModule in the future.
303 /// </summary> 303 /// </summary>
304 /// <param name="name"></param> 304 /// <param name="name"></param>
305 /// <param name="module"></param> 305 /// <param name="module"></param>
306 public void AddRegionModule(string name, IRegionModuleBase module) 306 public void AddRegionModule(string name, IRegionModuleBase module)
307 { 307 {
308 if (!RegionModules.ContainsKey(name)) 308 if (!RegionModules.ContainsKey(name))
309 { 309 {
310 RegionModules.Add(name, module); 310 RegionModules.Add(name, module);
311 } 311 }
312 } 312 }
313 313
314 public void RemoveRegionModule(string name) 314 public void RemoveRegionModule(string name)
315 { 315 {
316 RegionModules.Remove(name); 316 RegionModules.Remove(name);
317 } 317 }
318 318
319 /// <summary> 319 /// <summary>
320 /// Register a module commander. 320 /// Register a module commander.
321 /// </summary> 321 /// </summary>
322 /// <param name="commander"></param> 322 /// <param name="commander"></param>
323 public void RegisterModuleCommander(ICommander commander) 323 public void RegisterModuleCommander(ICommander commander)
324 { 324 {
325 lock (m_moduleCommanders) 325 lock (m_moduleCommanders)
326 { 326 {
327 m_moduleCommanders.Add(commander.Name, commander); 327 m_moduleCommanders.Add(commander.Name, commander);
328 } 328 }
329 } 329 }
330 330
331 /// <summary> 331 /// <summary>
332 /// Unregister a module commander and all its commands 332 /// Unregister a module commander and all its commands
333 /// </summary> 333 /// </summary>
334 /// <param name="name"></param> 334 /// <param name="name"></param>
335 public void UnregisterModuleCommander(string name) 335 public void UnregisterModuleCommander(string name)
336 { 336 {
337 lock (m_moduleCommanders) 337 lock (m_moduleCommanders)
338 { 338 {
339 ICommander commander; 339 ICommander commander;
340 if (m_moduleCommanders.TryGetValue(name, out commander)) 340 if (m_moduleCommanders.TryGetValue(name, out commander))
341 m_moduleCommanders.Remove(name); 341 m_moduleCommanders.Remove(name);
342 } 342 }
343 } 343 }
344 344
345 /// <summary> 345 /// <summary>
346 /// Get a module commander 346 /// Get a module commander
347 /// </summary> 347 /// </summary>
348 /// <param name="name"></param> 348 /// <param name="name"></param>
349 /// <returns>The module commander, null if no module commander with that name was found</returns> 349 /// <returns>The module commander, null if no module commander with that name was found</returns>
350 public ICommander GetCommander(string name) 350 public ICommander GetCommander(string name)
351 { 351 {
352 lock (m_moduleCommanders) 352 lock (m_moduleCommanders)
353 { 353 {
354 if (m_moduleCommanders.ContainsKey(name)) 354 if (m_moduleCommanders.ContainsKey(name))
355 return m_moduleCommanders[name]; 355 return m_moduleCommanders[name];
356 } 356 }
357 357
358 return null; 358 return null;
359 } 359 }
360 360
361 public Dictionary<string, ICommander> GetCommanders() 361 public Dictionary<string, ICommander> GetCommanders()
362 { 362 {
363 return m_moduleCommanders; 363 return m_moduleCommanders;
364 } 364 }
365 365
366 /// <summary> 366 /// <summary>
367 /// Register an interface to a region module. This allows module methods to be called directly as 367 /// Register an interface to a region module. This allows module methods to be called directly as
368 /// well as via events. If there is already a module registered for this interface, it is not replaced 368 /// well as via events. If there is already a module registered for this interface, it is not replaced
369 /// (is this the best behaviour?) 369 /// (is this the best behaviour?)
370 /// </summary> 370 /// </summary>
371 /// <param name="mod"></param> 371 /// <param name="mod"></param>
372 public void RegisterModuleInterface<M>(M mod) 372 public void RegisterModuleInterface<M>(M mod)
373 { 373 {
374// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); 374// m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M));
375 375
376 List<Object> l = null; 376 List<Object> l = null;
377 if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) 377 if (!ModuleInterfaces.TryGetValue(typeof(M), out l))
378 { 378 {
379 l = new List<Object>(); 379 l = new List<Object>();
380 ModuleInterfaces.Add(typeof(M), l); 380 ModuleInterfaces.Add(typeof(M), l);
381 } 381 }
382 382
383 if (l.Count > 0) 383 if (l.Count > 0)
384 return; 384 return;
385 385
386 l.Add(mod); 386 l.Add(mod);
387 387
388 if (mod is IEntityCreator) 388 if (mod is IEntityCreator)
389 { 389 {
390 IEntityCreator entityCreator = (IEntityCreator)mod; 390 IEntityCreator entityCreator = (IEntityCreator)mod;
391 foreach (PCode pcode in entityCreator.CreationCapabilities) 391 foreach (PCode pcode in entityCreator.CreationCapabilities)
392 { 392 {
393 m_entityCreators[pcode] = entityCreator; 393 m_entityCreators[pcode] = entityCreator;
394 } 394 }
395 } 395 }
396 } 396 }
397 397
398 public void UnregisterModuleInterface<M>(M mod) 398 public void UnregisterModuleInterface<M>(M mod)
399 { 399 {
400 List<Object> l; 400 List<Object> l;
401 if (ModuleInterfaces.TryGetValue(typeof(M), out l)) 401 if (ModuleInterfaces.TryGetValue(typeof(M), out l))
402 { 402 {
403 if (l.Remove(mod)) 403 if (l.Remove(mod))
404 { 404 {
405 if (mod is IEntityCreator) 405 if (mod is IEntityCreator)
406 { 406 {
407 IEntityCreator entityCreator = (IEntityCreator)mod; 407 IEntityCreator entityCreator = (IEntityCreator)mod;
408 foreach (PCode pcode in entityCreator.CreationCapabilities) 408 foreach (PCode pcode in entityCreator.CreationCapabilities)
409 { 409 {
410 m_entityCreators[pcode] = null; 410 m_entityCreators[pcode] = null;
411 } 411 }
412 } 412 }
413 } 413 }
414 } 414 }
415 } 415 }
416 416
417 public void StackModuleInterface<M>(M mod) 417 public void StackModuleInterface<M>(M mod)
418 { 418 {
419 List<Object> l; 419 List<Object> l;
420 if (ModuleInterfaces.ContainsKey(typeof(M))) 420 if (ModuleInterfaces.ContainsKey(typeof(M)))
421 l = ModuleInterfaces[typeof(M)]; 421 l = ModuleInterfaces[typeof(M)];
422 else 422 else
423 l = new List<Object>(); 423 l = new List<Object>();
424 424
425 if (l.Contains(mod)) 425 if (l.Contains(mod))
426 return; 426 return;
427 427
428 l.Add(mod); 428 l.Add(mod);
429 429
430 if (mod is IEntityCreator) 430 if (mod is IEntityCreator)
431 { 431 {
432 IEntityCreator entityCreator = (IEntityCreator)mod; 432 IEntityCreator entityCreator = (IEntityCreator)mod;
433 foreach (PCode pcode in entityCreator.CreationCapabilities) 433 foreach (PCode pcode in entityCreator.CreationCapabilities)
434 { 434 {
435 m_entityCreators[pcode] = entityCreator; 435 m_entityCreators[pcode] = entityCreator;
436 } 436 }
437 } 437 }
438 438
439 ModuleInterfaces[typeof(M)] = l; 439 ModuleInterfaces[typeof(M)] = l;
440 } 440 }
441 441
442 /// <summary> 442 /// <summary>
443 /// For the given interface, retrieve the region module which implements it. 443 /// For the given interface, retrieve the region module which implements it.
444 /// </summary> 444 /// </summary>
445 /// <returns>null if there is no registered module implementing that interface</returns> 445 /// <returns>null if there is no registered module implementing that interface</returns>
446 public T RequestModuleInterface<T>() 446 public T RequestModuleInterface<T>()
447 { 447 {
448 if (ModuleInterfaces.ContainsKey(typeof(T)) && 448 if (ModuleInterfaces.ContainsKey(typeof(T)) &&
449 (ModuleInterfaces[typeof(T)].Count > 0)) 449 (ModuleInterfaces[typeof(T)].Count > 0))
450 return (T)ModuleInterfaces[typeof(T)][0]; 450 return (T)ModuleInterfaces[typeof(T)][0];
451 else 451 else
452 return default(T); 452 return default(T);
453 } 453 }
454 454
455 /// <summary> 455 /// <summary>
456 /// For the given interface, retrieve an array of region modules that implement it. 456 /// For the given interface, retrieve an array of region modules that implement it.
457 /// </summary> 457 /// </summary>
458 /// <returns>an empty array if there are no registered modules implementing that interface</returns> 458 /// <returns>an empty array if there are no registered modules implementing that interface</returns>
459 public T[] RequestModuleInterfaces<T>() 459 public T[] RequestModuleInterfaces<T>()
460 { 460 {
461 if (ModuleInterfaces.ContainsKey(typeof(T))) 461 if (ModuleInterfaces.ContainsKey(typeof(T)))
462 { 462 {
463 List<T> ret = new List<T>(); 463 List<T> ret = new List<T>();
464 464
465 foreach (Object o in ModuleInterfaces[typeof(T)]) 465 foreach (Object o in ModuleInterfaces[typeof(T)])
466 ret.Add((T)o); 466 ret.Add((T)o);
467 return ret.ToArray(); 467 return ret.ToArray();
468 } 468 }
469 else 469 else
470 { 470 {
471 return new T[] {}; 471 return new T[] {};
472 } 472 }
473 } 473 }
474 474
475 #endregion 475 #endregion
476 476
477 /// <summary> 477 /// <summary>
478 /// Call this from a region module to add a command to the OpenSim console. 478 /// Call this from a region module to add a command to the OpenSim console.
479 /// </summary> 479 /// </summary>
480 /// <param name="mod"></param> 480 /// <param name="mod"></param>
481 /// <param name="command"></param> 481 /// <param name="command"></param>
482 /// <param name="shorthelp"></param> 482 /// <param name="shorthelp"></param>
483 /// <param name="longhelp"></param> 483 /// <param name="longhelp"></param>
484 /// <param name="callback"></param> 484 /// <param name="callback"></param>
485 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) 485 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback)
486 { 486 {
487 AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); 487 AddCommand(module, command, shorthelp, longhelp, string.Empty, callback);
488 } 488 }
489 489
490 /// <summary> 490 /// <summary>
491 /// Call this from a region module to add a command to the OpenSim console. 491 /// Call this from a region module to add a command to the OpenSim console.
492 /// </summary> 492 /// </summary>
493 /// <param name="mod"> 493 /// <param name="mod">
494 /// The use of IRegionModuleBase is a cheap trick to get a different method signature, 494 /// The use of IRegionModuleBase is a cheap trick to get a different method signature,
495 /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. 495 /// though all new modules should be using interfaces descended from IRegionModuleBase anyway.
496 /// </param> 496 /// </param>
497 /// <param name="category"> 497 /// <param name="category">
498 /// Category of the command. This is the section under which it will appear when the user asks for help 498 /// Category of the command. This is the section under which it will appear when the user asks for help
499 /// </param> 499 /// </param>
500 /// <param name="command"></param> 500 /// <param name="command"></param>
501 /// <param name="shorthelp"></param> 501 /// <param name="shorthelp"></param>
502 /// <param name="longhelp"></param> 502 /// <param name="longhelp"></param>
503 /// <param name="callback"></param> 503 /// <param name="callback"></param>
504 public void AddCommand( 504 public void AddCommand(
505 string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) 505 string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback)
506 { 506 {
507 AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); 507 AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback);
508 } 508 }
509 509
510 /// <summary> 510 /// <summary>
511 /// Call this from a region module to add a command to the OpenSim console. 511 /// Call this from a region module to add a command to the OpenSim console.
512 /// </summary> 512 /// </summary>
513 /// <param name="mod"></param> 513 /// <param name="mod"></param>
514 /// <param name="command"></param> 514 /// <param name="command"></param>
515 /// <param name="shorthelp"></param> 515 /// <param name="shorthelp"></param>
516 /// <param name="longhelp"></param> 516 /// <param name="longhelp"></param>
517 /// <param name="descriptivehelp"></param> 517 /// <param name="descriptivehelp"></param>
518 /// <param name="callback"></param> 518 /// <param name="callback"></param>
519 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) 519 public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback)
520 { 520 {
521 string moduleName = ""; 521 string moduleName = "";
522 522
523 if (module != null) 523 if (module != null)
524 moduleName = module.Name; 524 moduleName = module.Name;
525 525
526 AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); 526 AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback);
527 } 527 }
528 528
529 /// <summary> 529 /// <summary>
530 /// Call this from a region module to add a command to the OpenSim console. 530 /// Call this from a region module to add a command to the OpenSim console.
531 /// </summary> 531 /// </summary>
532 /// <param name="category"> 532 /// <param name="category">
533 /// Category of the command. This is the section under which it will appear when the user asks for help 533 /// Category of the command. This is the section under which it will appear when the user asks for help
534 /// </param> 534 /// </param>
535 /// <param name="mod"></param> 535 /// <param name="mod"></param>
536 /// <param name="command"></param> 536 /// <param name="command"></param>
537 /// <param name="shorthelp"></param> 537 /// <param name="shorthelp"></param>
538 /// <param name="longhelp"></param> 538 /// <param name="longhelp"></param>
539 /// <param name="descriptivehelp"></param> 539 /// <param name="descriptivehelp"></param>
540 /// <param name="callback"></param> 540 /// <param name="callback"></param>
541 public void AddCommand( 541 public void AddCommand(
542 string category, IRegionModuleBase module, string command, 542 string category, IRegionModuleBase module, string command,
543 string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) 543 string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback)
544 { 544 {
545 if (MainConsole.Instance == null) 545 if (MainConsole.Instance == null)
546 return; 546 return;
547 547
548 bool shared = false; 548 bool shared = false;
549 549
550 if (module != null) 550 if (module != null)
551 shared = module is ISharedRegionModule; 551 shared = module is ISharedRegionModule;
552 552
553 MainConsole.Instance.Commands.AddCommand( 553 MainConsole.Instance.Commands.AddCommand(
554 category, shared, command, shorthelp, longhelp, descriptivehelp, callback); 554 category, shared, command, shorthelp, longhelp, descriptivehelp, callback);
555 } 555 }
556 556
557 public virtual ISceneObject DeserializeObject(string representation) 557 public virtual ISceneObject DeserializeObject(string representation)
558 { 558 {
559 return null; 559 return null;
560 } 560 }
561 561
562 public virtual bool AllowScriptCrossings 562 public virtual bool AllowScriptCrossings
563 { 563 {
564 get { return false; } 564 get { return false; }
565 } 565 }
566 566
567 public virtual void Start() 567 public virtual void Start()
568 { 568 {
569 } 569 }
570 570
571 public void Restart() 571 public void Restart()
572 { 572 {
573 // This has to be here to fire the event 573 // This has to be here to fire the event
574 restart handlerPhysicsCrash = OnRestart; 574 restart handlerPhysicsCrash = OnRestart;
575 if (handlerPhysicsCrash != null) 575 if (handlerPhysicsCrash != null)
576 handlerPhysicsCrash(RegionInfo); 576 handlerPhysicsCrash(RegionInfo);
577 } 577 }
578 578
579 public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); 579 public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep);
580 } 580 }
581} 581}