aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.cs
diff options
context:
space:
mode:
authorlbsa712007-07-17 17:47:23 +0000
committerlbsa712007-07-17 17:47:23 +0000
commitd95918f2288967de3937ec7aa648a5303eba4027 (patch)
tree7eeb692e0939d566da2e246a7077b8fcc68ec1b3 /OpenSim/Region/Environment/Scenes/Scene.cs
parent* Added "backup" console command for sdague (diff)
downloadopensim-SC_OLD-d95918f2288967de3937ec7aa648a5303eba4027.zip
opensim-SC_OLD-d95918f2288967de3937ec7aa648a5303eba4027.tar.gz
opensim-SC_OLD-d95918f2288967de3937ec7aa648a5303eba4027.tar.bz2
opensim-SC_OLD-d95918f2288967de3937ec7aa648a5303eba4027.tar.xz
* Changed SimpleApp to use EventManager and Scene timer
* Refactored a lot of m_* and public -> wrappers
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs326
1 files changed, 162 insertions, 164 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 5bba87a..b6a2a34 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -30,7 +30,6 @@ using System.Collections.Generic;
30using System.Threading; 30using System.Threading;
31using System.Timers; 31using System.Timers;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
@@ -39,17 +38,16 @@ using OpenSim.Framework.Servers;
39using OpenSim.Framework.Types; 38using OpenSim.Framework.Types;
40using OpenSim.Physics.Manager; 39using OpenSim.Physics.Manager;
41using OpenSim.Region.Caches; 40using OpenSim.Region.Caches;
42using OpenSim.Region.Interfaces; 41using OpenSim.Region.Environment.LandManagement;
43using OpenSim.Region.Scripting; 42using OpenSim.Region.Scripting;
44using OpenSim.Region.Terrain; 43using OpenSim.Region.Terrain;
45using Caps = OpenSim.Region.Capabilities.Caps; 44using Caps=OpenSim.Region.Capabilities.Caps;
46using Timer = System.Timers.Timer; 45using Timer=System.Timers.Timer;
47
48using OpenSim.Region.Environment.LandManagement;
49 46
50namespace OpenSim.Region.Environment.Scenes 47namespace OpenSim.Region.Environment.Scenes
51{ 48{
52 public delegate bool FilterAvatarList(ScenePresence avatar); 49 public delegate bool FilterAvatarList(ScenePresence avatar);
50
53 public delegate void ForEachScenePresenceDelegate(ScenePresence presence); 51 public delegate void ForEachScenePresenceDelegate(ScenePresence presence);
54 52
55 public partial class Scene : SceneBase, ILocalStorageReceiver 53 public partial class Scene : SceneBase, ILocalStorageReceiver
@@ -61,7 +59,7 @@ namespace OpenSim.Region.Environment.Scenes
61 protected float timeStep = 0.1f; 59 protected float timeStep = 0.1f;
62 private Random Rand = new Random(); 60 private Random Rand = new Random();
63 private uint _primCount = 702000; 61 private uint _primCount = 702000;
64 private System.Threading.Mutex _primAllocateMutex = new Mutex(false); 62 private Mutex _primAllocateMutex = new Mutex(false);
65 private int storageCount; 63 private int storageCount;
66 private int landPrimCheckCount; 64 private int landPrimCheckCount;
67 private Mutex updateLock; 65 private Mutex updateLock;
@@ -75,40 +73,39 @@ namespace OpenSim.Region.Environment.Scenes
75 protected BaseHttpServer httpListener; 73 protected BaseHttpServer httpListener;
76 74
77 #region Properties 75 #region Properties
76
78 /// <summary> 77 /// <summary>
79 /// 78 ///
80 /// </summary> 79 /// </summary>
81 public PhysicsScene PhysScene 80 public PhysicsScene PhysScene
82 { 81 {
83 set 82 set { phyScene = value; }
84 { 83 get { return (phyScene); }
85 this.phyScene = value;
86 }
87 get
88 {
89 return (this.phyScene);
90 }
91 } 84 }
92 85
93 private LandManager m_LandManager; 86 private LandManager m_LandManager;
87
94 public LandManager LandManager 88 public LandManager LandManager
95 { 89 {
96 get { return m_LandManager; } 90 get { return m_LandManager; }
97 } 91 }
98 92
99 private EstateManager m_estateManager; 93 private EstateManager m_estateManager;
94
100 public EstateManager EstateManager 95 public EstateManager EstateManager
101 { 96 {
102 get { return m_estateManager; } 97 get { return m_estateManager; }
103 } 98 }
104 99
105 private EventManager m_eventManager; 100 private EventManager m_eventManager;
101
106 public EventManager EventManager 102 public EventManager EventManager
107 { 103 {
108 get { return m_eventManager; } 104 get { return m_eventManager; }
109 } 105 }
110 106
111 private ScriptManager m_scriptManager; 107 private ScriptManager m_scriptManager;
108
112 public ScriptManager ScriptManager 109 public ScriptManager ScriptManager
113 { 110 {
114 get { return m_scriptManager; } 111 get { return m_scriptManager; }
@@ -122,31 +119,34 @@ namespace OpenSim.Region.Environment.Scenes
122 #endregion 119 #endregion
123 120
124 #region Constructors 121 #region Constructors
122
125 /// <summary> 123 /// <summary>
126 /// Creates a new World class, and a region to go with it. 124 /// Creates a new World class, and a region to go with it.
127 /// </summary> 125 /// </summary>
128 /// <param name="clientThreads">Dictionary to contain client threads</param> 126 /// <param name="clientThreads">Dictionary to contain client threads</param>
129 /// <param name="regionHandle">Region Handle for this region</param> 127 /// <param name="regionHandle">Region Handle for this region</param>
130 /// <param name="regionName">Region Name for this region</param> 128 /// <param name="regionName">Region Name for this region</param>
131 public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) 129 public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan,
130 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer)
132 { 131 {
133 updateLock = new Mutex(false); 132 updateLock = new Mutex(false);
134 this.authenticateHandler = authen; 133 authenticateHandler = authen;
135 this.commsManager = commsMan; 134 commsManager = commsMan;
136 this.storageManager = storeManager; 135 storageManager = storeManager;
137 this.assetCache = assetCach; 136 assetCache = assetCach;
138 m_regInfo = regInfo; 137 m_regInfo = regInfo;
139 m_regionHandle = m_regInfo.RegionHandle; 138 m_regionHandle = m_regInfo.RegionHandle;
140 m_regionName = m_regInfo.RegionName; 139 m_regionName = m_regInfo.RegionName;
141 this.m_datastore = m_regInfo.DataStore; 140 m_datastore = m_regInfo.DataStore;
142 this.RegisterRegionWithComms(); 141 RegisterRegionWithComms();
143 142
144 m_LandManager = new LandManager(this, this.m_regInfo); 143 m_LandManager = new LandManager(this, m_regInfo);
145 m_estateManager = new EstateManager(this, this.m_regInfo); 144 m_estateManager = new EstateManager(this, m_regInfo);
146 m_scriptManager = new ScriptManager(this); 145 m_scriptManager = new ScriptManager(this);
147 m_eventManager = new EventManager(); 146 m_eventManager = new EventManager();
148 147
149 m_eventManager.OnParcelPrimCountAdd += new EventManager.OnParcelPrimCountAddDelegate(m_LandManager.addPrimToLandPrimCounts); 148 m_eventManager.OnParcelPrimCountAdd +=
149 new EventManager.OnParcelPrimCountAddDelegate(m_LandManager.addPrimToLandPrimCounts);
150 150
151 MainLog.Instance.Verbose("World.cs - creating new entitities instance"); 151 MainLog.Instance.Verbose("World.cs - creating new entitities instance");
152 Entities = new Dictionary<LLUUID, EntityBase>(); 152 Entities = new Dictionary<LLUUID, EntityBase>();
@@ -167,8 +167,9 @@ namespace OpenSim.Region.Environment.Scenes
167 167
168 ScenePresence.LoadAnims(); 168 ScenePresence.LoadAnims();
169 169
170 this.httpListener = httpServer; 170 httpListener = httpServer;
171 } 171 }
172
172 #endregion 173 #endregion
173 174
174 #region Script Handling Methods 175 #region Script Handling Methods
@@ -187,21 +188,19 @@ namespace OpenSim.Region.Environment.Scenes
187 { 188 {
188 m_heartbeatTimer.Enabled = true; 189 m_heartbeatTimer.Enabled = true;
189 m_heartbeatTimer.Interval = 100; 190 m_heartbeatTimer.Interval = 100;
190 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat); 191 m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
191 } 192 }
192 193
193
194 #region Update Methods 194 #region Update Methods
195 195
196
197 /// <summary> 196 /// <summary>
198 /// Performs per-frame updates regularly 197 /// Performs per-frame updates regularly
199 /// </summary> 198 /// </summary>
200 /// <param name="sender"></param> 199 /// <param name="sender"></param>
201 /// <param name="e"></param> 200 /// <param name="e"></param>
202 void Heartbeat(object sender, EventArgs e) 201 private void Heartbeat(object sender, EventArgs e)
203 { 202 {
204 this.Update(); 203 Update();
205 } 204 }
206 205
207 /// <summary> 206 /// <summary>
@@ -212,10 +211,9 @@ namespace OpenSim.Region.Environment.Scenes
212 updateLock.WaitOne(); 211 updateLock.WaitOne();
213 try 212 try
214 { 213 {
215 if (this.phyScene.IsThreaded) 214 if (phyScene.IsThreaded)
216 { 215 {
217 this.phyScene.GetResults(); 216 phyScene.GetResults();
218
219 } 217 }
220 218
221 foreach (LLUUID UUID in Entities.Keys) 219 foreach (LLUUID UUID in Entities.Keys)
@@ -223,45 +221,43 @@ namespace OpenSim.Region.Environment.Scenes
223 Entities[UUID].updateMovement(); 221 Entities[UUID].updateMovement();
224 } 222 }
225 223
226 lock (this.m_syncRoot) 224 lock (m_syncRoot)
227 { 225 {
228 this.phyScene.Simulate(timeStep); 226 phyScene.Simulate(timeStep);
229 } 227 }
230 228
231 foreach (LLUUID UUID in Entities.Keys) 229 foreach (LLUUID UUID in Entities.Keys)
232 { 230 {
233 Entities[UUID].update(); 231 Entities[UUID].Update();
234 } 232 }
235 233
236 // General purpose event manager 234 // General purpose event manager
237 m_eventManager.TriggerOnFrame(); 235 m_eventManager.TriggerOnFrame();
238 236
239 //backup world data 237 //backup world data
240 this.storageCount++; 238 storageCount++;
241 if (storageCount > 1200) //set to how often you want to backup 239 if (storageCount > 1200) //set to how often you want to backup
242 { 240 {
243 this.Backup(); 241 Backup();
244 storageCount = 0; 242 storageCount = 0;
245 } 243 }
246 244
247 this.landPrimCheckCount++; 245 landPrimCheckCount++;
248 if (this.landPrimCheckCount > 50) //check every 5 seconds for tainted prims 246 if (landPrimCheckCount > 50) //check every 5 seconds for tainted prims
249 { 247 {
250 if (m_LandManager.landPrimCountTainted) 248 if (m_LandManager.landPrimCountTainted)
251 { 249 {
252 //Perform land update of prim count 250 //Perform land update of prim count
253 performParcelPrimCountUpdate(); 251 performParcelPrimCountUpdate();
254 this.landPrimCheckCount = 0; 252 landPrimCheckCount = 0;
255 } 253 }
256 } 254 }
257
258 } 255 }
259 catch (Exception e) 256 catch (Exception e)
260 { 257 {
261 MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString()); 258 MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString());
262 } 259 }
263 updateLock.ReleaseMutex(); 260 updateLock.ReleaseMutex();
264
265 } 261 }
266 262
267 /// <summary> 263 /// <summary>
@@ -270,9 +266,10 @@ namespace OpenSim.Region.Environment.Scenes
270 /// <returns></returns> 266 /// <returns></returns>
271 public bool Backup() 267 public bool Backup()
272 { 268 {
273 EventManager.TriggerOnBackup(this.storageManager.DataStore); 269 EventManager.TriggerOnBackup(storageManager.DataStore);
274 return true; 270 return true;
275 } 271 }
272
276 #endregion 273 #endregion
277 274
278 #region Regenerate Terrain 275 #region Regenerate Terrain
@@ -286,17 +283,17 @@ namespace OpenSim.Region.Environment.Scenes
286 { 283 {
287 Terrain.hills(); 284 Terrain.hills();
288 285
289 lock (this.m_syncRoot) 286 lock (m_syncRoot)
290 { 287 {
291 this.phyScene.SetTerrain(Terrain.getHeights1D()); 288 phyScene.SetTerrain(Terrain.getHeights1D());
292 } 289 }
293 290
294 this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); 291 storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
295 292
296 this.ForEachScenePresence(delegate(ScenePresence presence) 293 ForEachScenePresence(delegate(ScenePresence presence)
297 { 294 {
298 this.SendLayerData(presence.ControllingClient); 295 SendLayerData(presence.ControllingClient);
299 }); 296 });
300 297
301 foreach (LLUUID UUID in Entities.Keys) 298 foreach (LLUUID UUID in Entities.Keys)
302 { 299 {
@@ -317,17 +314,17 @@ namespace OpenSim.Region.Environment.Scenes
317 { 314 {
318 try 315 try
319 { 316 {
320 this.Terrain.setHeights2D(newMap); 317 Terrain.setHeights2D(newMap);
321 lock (this.m_syncRoot) 318 lock (m_syncRoot)
322 { 319 {
323 this.phyScene.SetTerrain(this.Terrain.getHeights1D()); 320 phyScene.SetTerrain(Terrain.getHeights1D());
324 } 321 }
325 this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); 322 storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
326 323
327 this.ForEachScenePresence(delegate(ScenePresence presence) 324 ForEachScenePresence(delegate(ScenePresence presence)
328 { 325 {
329 this.SendLayerData(presence.ControllingClient); 326 SendLayerData(presence.ControllingClient);
330 }); 327 });
331 328
332 foreach (LLUUID UUID in Entities.Keys) 329 foreach (LLUUID UUID in Entities.Keys)
333 { 330 {
@@ -354,10 +351,10 @@ namespace OpenSim.Region.Environment.Scenes
354 { 351 {
355 /* Dont save here, rely on tainting system instead */ 352 /* Dont save here, rely on tainting system instead */
356 353
357 this.ForEachScenePresence(delegate(ScenePresence presence) 354 ForEachScenePresence(delegate(ScenePresence presence)
358 { 355 {
359 this.SendLayerData(pointx, pointy, presence.ControllingClient); 356 SendLayerData(pointx, pointy, presence.ControllingClient);
360 }); 357 });
361 } 358 }
362 } 359 }
363 catch (Exception e) 360 catch (Exception e)
@@ -369,6 +366,7 @@ namespace OpenSim.Region.Environment.Scenes
369 #endregion 366 #endregion
370 367
371 #region Load Terrain 368 #region Load Terrain
369
372 /// <summary> 370 /// <summary>
373 /// Loads the World heightmap 371 /// Loads the World heightmap
374 /// </summary> 372 /// </summary>
@@ -377,38 +375,37 @@ namespace OpenSim.Region.Environment.Scenes
377 { 375 {
378 try 376 try
379 { 377 {
380 double[,] map = this.storageManager.DataStore.LoadTerrain(); 378 double[,] map = storageManager.DataStore.LoadTerrain();
381 if (map == null) 379 if (map == null)
382 { 380 {
383 if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile)) 381 if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile))
384 { 382 {
385 Console.WriteLine("No default terrain, procedurally generating..."); 383 Console.WriteLine("No default terrain, procedurally generating...");
386 this.Terrain.hills(); 384 Terrain.hills();
387 385
388 this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); 386 storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
389 } 387 }
390 else 388 else
391 { 389 {
392 try 390 try
393 { 391 {
394 this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile); 392 Terrain.loadFromFileF32(m_regInfo.estateSettings.terrainFile);
395 this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier; 393 Terrain *= m_regInfo.estateSettings.terrainMultiplier;
396 } 394 }
397 catch 395 catch
398 { 396 {
399 Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); 397 Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
400 Terrain.hills(); 398 Terrain.hills();
401 } 399 }
402 this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD()); 400 storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
403 } 401 }
404 } 402 }
405 else 403 else
406 { 404 {
407 this.Terrain.setHeights2D(map); 405 Terrain.setHeights2D(map);
408 } 406 }
409 407
410 CreateTerrainTexture(); 408 CreateTerrainTexture();
411
412 } 409 }
413 catch (Exception e) 410 catch (Exception e)
414 { 411 {
@@ -422,27 +419,27 @@ namespace OpenSim.Region.Environment.Scenes
422 public void CreateTerrainTexture() 419 public void CreateTerrainTexture()
423 { 420 {
424 //create a texture asset of the terrain 421 //create a texture asset of the terrain
425 byte[] data = this.Terrain.exportJpegImage("defaultstripe.png"); 422 byte[] data = Terrain.exportJpegImage("defaultstripe.png");
426 this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random(); 423 m_regInfo.estateSettings.terrainImageID = LLUUID.Random();
427 AssetBase asset = new AssetBase(); 424 AssetBase asset = new AssetBase();
428 asset.FullID = this.m_regInfo.estateSettings.terrainImageID; 425 asset.FullID = m_regInfo.estateSettings.terrainImageID;
429 asset.Data = data; 426 asset.Data = data;
430 asset.Name = "terrainImage"; 427 asset.Name = "terrainImage";
431 asset.Type = 0; 428 asset.Type = 0;
432 this.assetCache.AddAsset(asset); 429 assetCache.AddAsset(asset);
433 } 430 }
431
434 #endregion 432 #endregion
435 433
436 #region Primitives Methods 434 #region Primitives Methods
437 435
438
439 /// <summary> 436 /// <summary>
440 /// Loads the World's objects 437 /// Loads the World's objects
441 /// </summary> 438 /// </summary>
442 public void LoadPrimsFromStorage() 439 public void LoadPrimsFromStorage()
443 { 440 {
444 MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); 441 MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
445 this.localStorage.LoadPrimitives(this); 442 localStorage.LoadPrimitives(this);
446 } 443 }
447 444
448 /// <summary> 445 /// <summary>
@@ -476,8 +473,7 @@ namespace OpenSim.Region.Environment.Scenes
476 /// <param name="ownerID"></param> 473 /// <param name="ownerID"></param>
477 public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) 474 public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape)
478 { 475 {
479 476 SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, PrimIDAllocate(), pos, shape);
480 SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape);
481 AddEntity(sceneOb); 477 AddEntity(sceneOb);
482 } 478 }
483 479
@@ -487,27 +483,26 @@ namespace OpenSim.Region.Environment.Scenes
487 { 483 {
488 if (obj is SceneObject) 484 if (obj is SceneObject)
489 { 485 {
490 if (((SceneObject)obj).LocalId == localID) 486 if (((SceneObject) obj).LocalId == localID)
491 { 487 {
492 RemoveEntity((SceneObject)obj); 488 RemoveEntity((SceneObject) obj);
493 return; 489 return;
494 } 490 }
495 } 491 }
496 } 492 }
497
498 } 493 }
499 494
500 public void AddEntity(SceneObject sceneObject) 495 public void AddEntity(SceneObject sceneObject)
501 { 496 {
502 this.Entities.Add(sceneObject.rootUUID, sceneObject); 497 Entities.Add(sceneObject.rootUUID, sceneObject);
503 } 498 }
504 499
505 public void RemoveEntity(SceneObject sceneObject) 500 public void RemoveEntity(SceneObject sceneObject)
506 { 501 {
507 if (this.Entities.ContainsKey(sceneObject.rootUUID)) 502 if (Entities.ContainsKey(sceneObject.rootUUID))
508 { 503 {
509 m_LandManager.removePrimFromLandPrimCounts(sceneObject); 504 m_LandManager.removePrimFromLandPrimCounts(sceneObject);
510 this.Entities.Remove(sceneObject.rootUUID); 505 Entities.Remove(sceneObject.rootUUID);
511 m_LandManager.setPrimsTainted(); 506 m_LandManager.setPrimsTainted();
512 } 507 }
513 } 508 }
@@ -520,6 +515,7 @@ namespace OpenSim.Region.Environment.Scenes
520 { 515 {
521 prim.OnPrimCountTainted += m_LandManager.setPrimsTainted; 516 prim.OnPrimCountTainted += m_LandManager.setPrimsTainted;
522 } 517 }
518
523 #endregion 519 #endregion
524 520
525 #region Add/Remove Avatar Methods 521 #region Add/Remove Avatar Methods
@@ -533,48 +529,48 @@ namespace OpenSim.Region.Environment.Scenes
533 public override void AddNewClient(IClientAPI client, bool child) 529 public override void AddNewClient(IClientAPI client, bool child)
534 { 530 {
535 SubscribeToClientEvents(client); 531 SubscribeToClientEvents(client);
536 this.m_estateManager.sendRegionHandshake(client); 532 m_estateManager.sendRegionHandshake(client);
537 CreateAndAddScenePresence(client); 533 CreateAndAddScenePresence(client);
538 this.m_LandManager.sendParcelOverlay(client); 534 m_LandManager.sendParcelOverlay(client);
539
540 } 535 }
541 536
542 protected virtual void SubscribeToClientEvents(IClientAPI client) 537 protected virtual void SubscribeToClientEvents(IClientAPI client)
543 { 538 {
544 client.OnRegionHandShakeReply += this.SendLayerData; 539 client.OnRegionHandShakeReply += SendLayerData;
545 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); 540 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
546 client.OnChatFromViewer += this.SimChat; 541 client.OnChatFromViewer += SimChat;
547 client.OnInstantMessage += this.InstantMessage; 542 client.OnInstantMessage += InstantMessage;
548 client.OnRequestWearables += this.InformClientOfNeighbours; 543 client.OnRequestWearables += InformClientOfNeighbours;
549 client.OnAddPrim += this.AddNewPrim; 544 client.OnAddPrim += AddNewPrim;
550 client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition; 545 client.OnUpdatePrimGroupPosition += UpdatePrimPosition;
551 client.OnUpdatePrimSinglePosition += this.UpdatePrimSinglePosition; 546 client.OnUpdatePrimSinglePosition += UpdatePrimSinglePosition;
552 client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation; 547 client.OnUpdatePrimGroupRotation += UpdatePrimRotation;
553 client.OnUpdatePrimGroupMouseRotation += this.UpdatePrimRotation; 548 client.OnUpdatePrimGroupMouseRotation += UpdatePrimRotation;
554 client.OnUpdatePrimSingleRotation += this.UpdatePrimSingleRotation; 549 client.OnUpdatePrimSingleRotation += UpdatePrimSingleRotation;
555 client.OnUpdatePrimScale += this.UpdatePrimScale; 550 client.OnUpdatePrimScale += UpdatePrimScale;
556 client.OnUpdatePrimShape += this.UpdatePrimShape; 551 client.OnUpdatePrimShape += UpdatePrimShape;
557 client.OnRequestMapBlocks += this.RequestMapBlocks; 552 client.OnRequestMapBlocks += RequestMapBlocks;
558 client.OnUpdatePrimTexture += this.UpdatePrimTexture; 553 client.OnUpdatePrimTexture += UpdatePrimTexture;
559 client.OnTeleportLocationRequest += this.RequestTeleportLocation; 554 client.OnTeleportLocationRequest += RequestTeleportLocation;
560 client.OnObjectSelect += this.SelectPrim; 555 client.OnObjectSelect += SelectPrim;
561 client.OnObjectDeselect += this.DeselectPrim; 556 client.OnObjectDeselect += DeselectPrim;
562 client.OnGrapUpdate += this.MoveObject; 557 client.OnGrapUpdate += MoveObject;
563 client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; 558 client.OnNameFromUUIDRequest += commsManager.HandleUUIDNameRequest;
564 client.OnObjectDescription += this.PrimDescription; 559 client.OnObjectDescription += PrimDescription;
565 client.OnObjectName += this.PrimName; 560 client.OnObjectName += PrimName;
566 client.OnLinkObjects += this.LinkObjects; 561 client.OnLinkObjects += LinkObjects;
567 client.OnObjectDuplicate += this.DuplicateObject; 562 client.OnObjectDuplicate += DuplicateObject;
568 563
569 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest); 564 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest);
570 client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest); 565 client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest);
571 client.OnParcelJoinRequest += new ParcelJoinRequest(m_LandManager.handleParcelJoinRequest); 566 client.OnParcelJoinRequest += new ParcelJoinRequest(m_LandManager.handleParcelJoinRequest);
572 client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest); 567 client.OnParcelPropertiesUpdateRequest +=
568 new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest);
573 client.OnParcelSelectObjects += new ParcelSelectObjects(m_LandManager.handleParcelSelectObjectsRequest); 569 client.OnParcelSelectObjects += new ParcelSelectObjects(m_LandManager.handleParcelSelectObjectsRequest);
574 client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); 570 client.OnParcelObjectOwnerRequest +=
571 new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest);
575 572
576 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 573 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
577
578 } 574 }
579 575
580 protected ScenePresence CreateAndAddScenePresence(IClientAPI client) 576 protected ScenePresence CreateAndAddScenePresence(IClientAPI client)
@@ -582,21 +578,21 @@ namespace OpenSim.Region.Environment.Scenes
582 ScenePresence newAvatar = null; 578 ScenePresence newAvatar = null;
583 579
584 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); 580 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
585 newAvatar = new ScenePresence(client, this, this.m_regInfo); 581 newAvatar = new ScenePresence(client, this, m_regInfo);
586 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world"); 582 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world");
587 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake "); 583 MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake ");
588 584
589 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); 585 PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
590 lock (this.m_syncRoot) 586 lock (m_syncRoot)
591 { 587 {
592 newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); 588 newAvatar.PhysActor = phyScene.AddAvatar(pVec);
593 } 589 }
594 590
595 lock (Entities) 591 lock (Entities)
596 { 592 {
597 if (!Entities.ContainsKey(client.AgentId)) 593 if (!Entities.ContainsKey(client.AgentId))
598 { 594 {
599 this.Entities.Add(client.AgentId, newAvatar); 595 Entities.Add(client.AgentId, newAvatar);
600 } 596 }
601 else 597 else
602 { 598 {
@@ -611,7 +607,7 @@ namespace OpenSim.Region.Environment.Scenes
611 } 607 }
612 else 608 else
613 { 609 {
614 this.Avatars.Add(client.AgentId, newAvatar); 610 Avatars.Add(client.AgentId, newAvatar);
615 } 611 }
616 } 612 }
617 newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement; 613 newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement;
@@ -627,13 +623,13 @@ namespace OpenSim.Region.Environment.Scenes
627 { 623 {
628 m_eventManager.TriggerOnRemovePresence(agentID); 624 m_eventManager.TriggerOnRemovePresence(agentID);
629 625
630 ScenePresence avatar = this.RequestAvatar(agentID); 626 ScenePresence avatar = RequestAvatar(agentID);
631 627
632 this.ForEachScenePresence( 628 ForEachScenePresence(
633 delegate(ScenePresence presence) 629 delegate(ScenePresence presence)
634 { 630 {
635 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId); 631 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
636 }); 632 });
637 633
638 lock (Avatars) 634 lock (Avatars)
639 { 635 {
@@ -652,12 +648,13 @@ namespace OpenSim.Region.Environment.Scenes
652 // TODO: Add the removal from physics ? 648 // TODO: Add the removal from physics ?
653 649
654 650
655
656 return; 651 return;
657 } 652 }
653
658 #endregion 654 #endregion
659 655
660 #region Request Avatars List Methods 656 #region Request Avatars List Methods
657
661 //The idea is to have a group of method that return a list of avatars meeting some requirement 658 //The idea is to have a group of method that return a list of avatars meeting some requirement
662 // ie it could be all Avatars within a certain range of the calling prim/avatar. 659 // ie it could be all Avatars within a certain range of the calling prim/avatar.
663 660
@@ -703,7 +700,7 @@ namespace OpenSim.Region.Environment.Scenes
703 /// <returns></returns> 700 /// <returns></returns>
704 public ScenePresence RequestAvatar(LLUUID avatarID) 701 public ScenePresence RequestAvatar(LLUUID avatarID)
705 { 702 {
706 if (this.Avatars.ContainsKey(avatarID)) 703 if (Avatars.ContainsKey(avatarID))
707 { 704 {
708 return Avatars[avatarID]; 705 return Avatars[avatarID];
709 } 706 }
@@ -712,13 +709,13 @@ namespace OpenSim.Region.Environment.Scenes
712 709
713 public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo) 710 public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo)
714 { 711 {
715 foreach (ScenePresence presence in this.Avatars.Values) 712 foreach (ScenePresence presence in Avatars.Values)
716 { 713 {
717 whatToDo(presence); 714 whatToDo(presence);
718 } 715 }
719 } 716 }
720 #endregion
721 717
718 #endregion
722 719
723 /// <summary> 720 /// <summary>
724 /// 721 ///
@@ -727,9 +724,9 @@ namespace OpenSim.Region.Environment.Scenes
727 /// <returns></returns> 724 /// <returns></returns>
728 public bool DeleteEntity(LLUUID entID) 725 public bool DeleteEntity(LLUUID entID)
729 { 726 {
730 if (this.Entities.ContainsKey(entID)) 727 if (Entities.ContainsKey(entID))
731 { 728 {
732 this.Entities.Remove(entID); 729 Entities.Remove(entID);
733 return true; 730 return true;
734 } 731 }
735 return false; 732 return false;
@@ -741,7 +738,7 @@ namespace OpenSim.Region.Environment.Scenes
741 { 738 {
742 if (ent is SceneObject) 739 if (ent is SceneObject)
743 { 740 {
744 ((SceneObject)ent).SendAllChildPrimsToClient(client); 741 ((SceneObject) ent).SendAllChildPrimsToClient(client);
745 } 742 }
746 } 743 }
747 } 744 }
@@ -753,12 +750,11 @@ namespace OpenSim.Region.Environment.Scenes
753 /// </summary> 750 /// </summary>
754 public void RegisterRegionWithComms() 751 public void RegisterRegionWithComms()
755 { 752 {
756 753 regionCommsHost = commsManager.GridServer.RegisterRegion(m_regInfo);
757 this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo); 754 if (regionCommsHost != null)
758 if (this.regionCommsHost != null)
759 { 755 {
760 this.regionCommsHost.OnExpectUser += this.NewUserConnection; 756 regionCommsHost.OnExpectUser += NewUserConnection;
761 this.regionCommsHost.OnAvatarCrossingIntoRegion += this.AgentCrossing; 757 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
762 } 758 }
763 } 759 }
764 760
@@ -771,35 +767,37 @@ namespace OpenSim.Region.Environment.Scenes
771 { 767 {
772 // Console.WriteLine("World.cs - add new user connection"); 768 // Console.WriteLine("World.cs - add new user connection");
773 //should just check that its meant for this region 769 //should just check that its meant for this region
774 if (regionHandle == this.m_regInfo.RegionHandle) 770 if (regionHandle == m_regInfo.RegionHandle)
775 { 771 {
776 if (agent.CapsPath != "") 772 if (agent.CapsPath != "")
777 { 773 {
778 //Console.WriteLine("new user, so creating caps handler for it"); 774 //Console.WriteLine("new user, so creating caps handler for it");
779 Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID); 775 Caps cap =
776 new Caps(assetCache, httpListener, m_regInfo.ExternalHostName, m_regInfo.ExternalEndPoint.Port,
777 agent.CapsPath, agent.AgentID);
780 cap.RegisterHandlers(); 778 cap.RegisterHandlers();
781 if (capsHandlers.ContainsKey(agent.AgentID)) 779 if (capsHandlers.ContainsKey(agent.AgentID))
782 { 780 {
783 OpenSim.Framework.Console.MainLog.Instance.Warn("Adding duplicate CAPS entry for user " + agent.AgentID.ToStringHyphenated()); 781 MainLog.Instance.Warn("Adding duplicate CAPS entry for user " +
784 this.capsHandlers[agent.AgentID] = cap; 782 agent.AgentID.ToStringHyphenated());
783 capsHandlers[agent.AgentID] = cap;
785 } 784 }
786 else 785 else
787 { 786 {
788 this.capsHandlers.Add(agent.AgentID, cap); 787 capsHandlers.Add(agent.AgentID, cap);
789 } 788 }
790
791 } 789 }
792 this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 790 authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
793 } 791 }
794 } 792 }
795 793
796 public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) 794 public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
797 { 795 {
798 if (regionHandle == this.m_regInfo.RegionHandle) 796 if (regionHandle == m_regInfo.RegionHandle)
799 { 797 {
800 if (this.Avatars.ContainsKey(agentID)) 798 if (Avatars.ContainsKey(agentID))
801 { 799 {
802 this.Avatars[agentID].MakeAvatar(position); 800 Avatars[agentID].MakeAvatar(position);
803 } 801 }
804 } 802 }
805 } 803 }
@@ -809,7 +807,7 @@ namespace OpenSim.Region.Environment.Scenes
809 /// </summary> 807 /// </summary>
810 public void InformClientOfNeighbours(IClientAPI remoteClient) 808 public void InformClientOfNeighbours(IClientAPI remoteClient)
811 { 809 {
812 List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo); 810 List<RegionInfo> neighbours = commsManager.GridServer.RequestNeighbours(m_regInfo);
813 811
814 if (neighbours != null) 812 if (neighbours != null)
815 { 813 {
@@ -820,7 +818,7 @@ namespace OpenSim.Region.Environment.Scenes
820 agent.InventoryFolder = LLUUID.Zero; 818 agent.InventoryFolder = LLUUID.Zero;
821 agent.startpos = new LLVector3(128, 128, 70); 819 agent.startpos = new LLVector3(128, 128, 70);
822 agent.child = true; 820 agent.child = true;
823 this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent); 821 commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent);
824 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint); 822 remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint);
825 //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort); 823 //this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort);
826 } 824 }
@@ -834,7 +832,7 @@ namespace OpenSim.Region.Environment.Scenes
834 /// <returns></returns> 832 /// <returns></returns>
835 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) 833 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
836 { 834 {
837 return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle); 835 return commsManager.GridServer.RequestNeighbourInfo(regionHandle);
838 } 836 }
839 837
840 /// <summary> 838 /// <summary>
@@ -847,7 +845,7 @@ namespace OpenSim.Region.Environment.Scenes
847 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) 845 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
848 { 846 {
849 List<MapBlockData> mapBlocks; 847 List<MapBlockData> mapBlocks;
850 mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 848 mapBlocks = commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
851 remoteClient.SendMapBlock(mapBlocks); 849 remoteClient.SendMapBlock(mapBlocks);
852 } 850 }
853 851
@@ -859,20 +857,21 @@ namespace OpenSim.Region.Environment.Scenes
859 /// <param name="position"></param> 857 /// <param name="position"></param>
860 /// <param name="lookAt"></param> 858 /// <param name="lookAt"></param>
861 /// <param name="flags"></param> 859 /// <param name="flags"></param>
862 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) 860 public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position,
861 LLVector3 lookAt, uint flags)
863 { 862 {
864 if (regionHandle == this.m_regionHandle) 863 if (regionHandle == m_regionHandle)
865 { 864 {
866 if (this.Avatars.ContainsKey(remoteClient.AgentId)) 865 if (Avatars.ContainsKey(remoteClient.AgentId))
867 { 866 {
868 remoteClient.SendTeleportLocationStart(); 867 remoteClient.SendTeleportLocationStart();
869 remoteClient.SendLocalTeleport(position, lookAt, flags); 868 remoteClient.SendLocalTeleport(position, lookAt, flags);
870 this.Avatars[remoteClient.AgentId].Teleport(position); 869 Avatars[remoteClient.AgentId].Teleport(position);
871 } 870 }
872 } 871 }
873 else 872 else
874 { 873 {
875 RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle); 874 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
876 if (reg != null) 875 if (reg != null)
877 { 876 {
878 remoteClient.SendTeleportLocationStart(); 877 remoteClient.SendTeleportLocationStart();
@@ -881,11 +880,10 @@ namespace OpenSim.Region.Environment.Scenes
881 agent.InventoryFolder = LLUUID.Zero; 880 agent.InventoryFolder = LLUUID.Zero;
882 agent.startpos = new LLVector3(128, 128, 70); 881 agent.startpos = new LLVector3(128, 128, 70);
883 agent.child = true; 882 agent.child = true;
884 this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); 883 commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
885 this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); 884 commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
886 885
887 remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4)); 886 remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4));
888
889 } 887 }
890 } 888 }
891 } 889 }
@@ -898,7 +896,7 @@ namespace OpenSim.Region.Environment.Scenes
898 /// <param name="position"></param> 896 /// <param name="position"></param>
899 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) 897 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position)
900 { 898 {
901 return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); 899 return commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
902 } 900 }
903 901
904 public void performParcelPrimCountUpdate() 902 public void performParcelPrimCountUpdate()
@@ -908,7 +906,7 @@ namespace OpenSim.Region.Environment.Scenes
908 m_LandManager.finalizeLandPrimCountUpdate(); 906 m_LandManager.finalizeLandPrimCountUpdate();
909 m_LandManager.landPrimCountTainted = false; 907 m_LandManager.landPrimCountTainted = false;
910 } 908 }
911 #endregion
912 909
910 #endregion
913 } 911 }
914} 912} \ No newline at end of file