aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs284
1 files changed, 143 insertions, 141 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index d763fe3..df125aa 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -27,28 +27,28 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Threading; 31using System.Threading;
31using System.Timers; 32using System.Timers;
32using System.IO;
33using System.Xml; 33using System.Xml;
34using Axiom.Math;
34using libsecondlife; 35using libsecondlife;
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Caches;
37using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
38using OpenSim.Framework.Interfaces; 40using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
40using OpenSim.Framework.Types; 42using OpenSim.Framework.Types;
41using OpenSim.Framework.Utilities; 43using OpenSim.Framework.Utilities;
42using OpenSim.Region.Physics.Manager; 44using OpenSim.Region.Capabilities;
43using OpenSim.Framework.Communications.Caches;
44using OpenSim.Region.Environment.LandManagement;
45using OpenSim.Region.Environment;
46using OpenSim.Region.Environment.Interfaces; 45using OpenSim.Region.Environment.Interfaces;
46using OpenSim.Region.Environment.LandManagement;
47using OpenSim.Region.Environment.Scenes.Scripting;
47using OpenSim.Region.Environment.Types; 48using OpenSim.Region.Environment.Types;
49using OpenSim.Region.Physics.Manager;
48using OpenSim.Region.Terrain; 50using OpenSim.Region.Terrain;
49using OpenSim.Framework.Data; 51using Timer=System.Timers.Timer;
50using Caps = OpenSim.Region.Capabilities.Caps;
51using Timer = System.Timers.Timer;
52 52
53namespace OpenSim.Region.Environment.Scenes 53namespace OpenSim.Region.Environment.Scenes
54{ 54{
@@ -61,8 +61,11 @@ namespace OpenSim.Region.Environment.Scenes
61 protected Timer m_heartbeatTimer = new Timer(); 61 protected Timer m_heartbeatTimer = new Timer();
62 protected Dictionary<LLUUID, ScenePresence> Avatars; 62 protected Dictionary<LLUUID, ScenePresence> Avatars;
63 protected Dictionary<LLUUID, SceneObjectGroup> Prims; 63 protected Dictionary<LLUUID, SceneObjectGroup> Prims;
64 public PhysicsScene phyScene; /// publicized so it can be accessed from SceneObjectGroup. 64 public PhysicsScene phyScene;
65
66 /// publicized so it can be accessed from SceneObjectGroup.
65 protected float timeStep = 0.1f; 67 protected float timeStep = 0.1f;
68
66 private Random Rand = new Random(); 69 private Random Rand = new Random();
67 private uint _primCount = 702000; 70 private uint _primCount = 702000;
68 private Mutex _primAllocateMutex = new Mutex(false); 71 private Mutex _primAllocateMutex = new Mutex(false);
@@ -102,8 +105,9 @@ namespace OpenSim.Region.Environment.Scenes
102 105
103 public AgentCircuitManager AuthenticateHandler 106 public AgentCircuitManager AuthenticateHandler
104 { 107 {
105 get { return this.authenticateHandler; } 108 get { return authenticateHandler; }
106 } 109 }
110
107 /// <summary> 111 /// <summary>
108 /// 112 ///
109 /// </summary> 113 /// </summary>
@@ -141,7 +145,7 @@ namespace OpenSim.Region.Environment.Scenes
141 145
142 public int TimePhase 146 public int TimePhase
143 { 147 {
144 get { return this.m_timePhase; } 148 get { return m_timePhase; }
145 } 149 }
146 150
147 #endregion 151 #endregion
@@ -155,7 +159,8 @@ namespace OpenSim.Region.Environment.Scenes
155 /// <param name="regionHandle">Region Handle for this region</param> 159 /// <param name="regionHandle">Region Handle for this region</param>
156 /// <param name="regionName">Region Name for this region</param> 160 /// <param name="regionName">Region Name for this region</param>
157 public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, 161 public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan,
158 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader) 162 AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer,
163 ModuleLoader moduleLoader)
159 { 164 {
160 updateLock = new Mutex(false); 165 updateLock = new Mutex(false);
161 166
@@ -190,22 +195,21 @@ namespace OpenSim.Region.Environment.Scenes
190 Prims = new Dictionary<LLUUID, SceneObjectGroup>(); 195 Prims = new Dictionary<LLUUID, SceneObjectGroup>();
191 196
192 MainLog.Instance.Verbose("Creating LandMap"); 197 MainLog.Instance.Verbose("Creating LandMap");
193 Terrain = new TerrainEngine((int)this.RegionInfo.RegionLocX, (int)this.RegionInfo.RegionLocY); 198 Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY);
194 199
195 ScenePresence.LoadAnims(); 200 ScenePresence.LoadAnims();
196 201
197 httpListener = httpServer; 202 httpListener = httpServer;
198
199 } 203 }
200 204
201 #endregion 205 #endregion
202 206
203 public void SetModuleInterfaces() 207 public void SetModuleInterfaces()
204 { 208 {
205 m_simChatModule = this.RequestModuleInterface<ISimChat>(); 209 m_simChatModule = RequestModuleInterface<ISimChat>();
206 m_httpRequestModule = this.RequestModuleInterface<IHttpRequests>(); 210 m_httpRequestModule = RequestModuleInterface<IHttpRequests>();
207 211
208 XferManager = this.RequestModuleInterface<IXfer>(); 212 XferManager = RequestModuleInterface<IXfer>();
209 } 213 }
210 214
211 #region Script Handling Methods 215 #region Script Handling Methods
@@ -249,7 +253,8 @@ namespace OpenSim.Region.Environment.Scenes
249 { 253 {
250 if (phyScene.IsThreaded) 254 if (phyScene.IsThreaded)
251 { 255 {
252 phyScene.GetResults(); /// no engines implement this, and what does it have to do with threading? possible DEAD CODE 256 phyScene.GetResults();
257 /// no engines implement this, and what does it have to do with threading? possible DEAD CODE
253 } 258 }
254 259
255 List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values); 260 List<EntityBase> moveEntities = new List<EntityBase>(Entities.Values);
@@ -308,9 +313,10 @@ namespace OpenSim.Region.Environment.Scenes
308 { 313 {
309 for (int y = 0; y < 16; y++) 314 for (int y = 0; y < 16; y++)
310 { 315 {
311 if (Terrain.Tainted(x * 16, y * 16)) 316 if (Terrain.Tainted(x*16, y*16))
312 { 317 {
313 SendLayerData(x, y, presence.ControllingClient, terData); 318 SendLayerData(x, y, presence.ControllingClient,
319 terData);
314 } 320 }
315 } 321 }
316 } 322 }
@@ -340,7 +346,7 @@ namespace OpenSim.Region.Environment.Scenes
340 m_timeUpdateCount++; 346 m_timeUpdateCount++;
341 if (m_timeUpdateCount > 600) 347 if (m_timeUpdateCount > 600)
342 { 348 {
343 List<ScenePresence> Avatars = this.RequestAvatarList(); 349 List<ScenePresence> Avatars = RequestAvatarList();
344 foreach (ScenePresence avatar in Avatars) 350 foreach (ScenePresence avatar in Avatars)
345 { 351 {
346 if (!avatar.childAgent) 352 if (!avatar.childAgent)
@@ -398,10 +404,7 @@ namespace OpenSim.Region.Environment.Scenes
398 404
399 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 405 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD());
400 406
401 ForEachScenePresence(delegate(ScenePresence presence) 407 ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); });
402 {
403 SendLayerData(presence.ControllingClient);
404 });
405 408
406 foreach (LLUUID UUID in Entities.Keys) 409 foreach (LLUUID UUID in Entities.Keys)
407 { 410 {
@@ -429,10 +432,7 @@ namespace OpenSim.Region.Environment.Scenes
429 } 432 }
430 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 433 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD());
431 434
432 ForEachScenePresence(delegate(ScenePresence presence) 435 ForEachScenePresence(delegate(ScenePresence presence) { SendLayerData(presence.ControllingClient); });
433 {
434 SendLayerData(presence.ControllingClient);
435 });
436 436
437 foreach (LLUUID UUID in Entities.Keys) 437 foreach (LLUUID UUID in Entities.Keys)
438 { 438 {
@@ -521,23 +521,23 @@ namespace OpenSim.Region.Environment.Scenes
521 public void LoadPrimsFromStorage() 521 public void LoadPrimsFromStorage()
522 { 522 {
523 MainLog.Instance.Verbose("Loading objects from datastore"); 523 MainLog.Instance.Verbose("Loading objects from datastore");
524 List<SceneObjectGroup> PrimsFromDB = storageManager.DataStore.LoadObjects(this.m_regInfo.SimUUID); 524 List<SceneObjectGroup> PrimsFromDB = storageManager.DataStore.LoadObjects(m_regInfo.SimUUID);
525 foreach (SceneObjectGroup prim in PrimsFromDB) 525 foreach (SceneObjectGroup prim in PrimsFromDB)
526 { 526 {
527 AddEntityFromStorage(prim); 527 AddEntityFromStorage(prim);
528 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); 528 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
529 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 529 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
530 rootPart.PhysActor = phyScene.AddPrim( 530 rootPart.PhysActor = phyScene.AddPrim(
531 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), 531 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
532 rootPart.AbsolutePosition.Z),
532 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 533 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
533 new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 534 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
534 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); 535 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
535 } 536 }
536 MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); 537 MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)");
537 } 538 }
538 539
539 540
540
541 /// <summary> 541 /// <summary>
542 /// Returns a new unallocated primitive ID 542 /// Returns a new unallocated primitive ID
543 /// </summary> 543 /// </summary>
@@ -561,20 +561,23 @@ namespace OpenSim.Region.Environment.Scenes
561 /// <param name="ownerID"></param> 561 /// <param name="ownerID"></param>
562 public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) 562 public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape)
563 { 563 {
564 if (this.PermissionsMngr.CanRezObject(ownerID, pos)) 564 if (PermissionsMngr.CanRezObject(ownerID, pos))
565 { 565 {
566 SceneObjectGroup sceneOb = new SceneObjectGroup(this, this.m_regionHandle, ownerID, PrimIDAllocate(), pos, shape); 566 SceneObjectGroup sceneOb =
567 new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, shape);
567 AddEntity(sceneOb); 568 AddEntity(sceneOb);
568 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); 569 SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID);
569 // if grass or tree, make phantom 570 // if grass or tree, make phantom
570 if ((rootPart.Shape.PCode==95) || (rootPart.Shape.PCode==255)) 571 if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255))
571 { 572 {
572 rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; 573 rootPart.ObjectFlags += (uint) LLObject.ObjectFlags.Phantom;
573 } 574 }
574 // if not phantom, add to physics 575 // if not phantom, add to physics
575 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 576 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
576 rootPart.PhysActor = phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z), new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), 577 rootPart.PhysActor =
577 new Axiom.Math.Quaternion()); 578 phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z),
579 new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z),
580 new Quaternion());
578 } 581 }
579 } 582 }
580 583
@@ -584,9 +587,9 @@ namespace OpenSim.Region.Environment.Scenes
584 { 587 {
585 if (obj is SceneObjectGroup) 588 if (obj is SceneObjectGroup)
586 { 589 {
587 if (((SceneObjectGroup)obj).LocalId == localID) 590 if (((SceneObjectGroup) obj).LocalId == localID)
588 { 591 {
589 RemoveEntity((SceneObjectGroup)obj); 592 RemoveEntity((SceneObjectGroup) obj);
590 return; 593 return;
591 } 594 }
592 } 595 }
@@ -595,21 +598,21 @@ namespace OpenSim.Region.Environment.Scenes
595 598
596 public void AddEntityFromStorage(SceneObjectGroup sceneObject) 599 public void AddEntityFromStorage(SceneObjectGroup sceneObject)
597 { 600 {
598 sceneObject.RegionHandle = this.m_regionHandle; 601 sceneObject.RegionHandle = m_regionHandle;
599 sceneObject.SetScene(this); 602 sceneObject.SetScene(this);
600 foreach (SceneObjectPart part in sceneObject.Children.Values) 603 foreach (SceneObjectPart part in sceneObject.Children.Values)
601 { 604 {
602 part.LocalID = this.PrimIDAllocate(); 605 part.LocalID = PrimIDAllocate();
603 } 606 }
604 sceneObject.UpdateParentIDs(); 607 sceneObject.UpdateParentIDs();
605 this.AddEntity(sceneObject); 608 AddEntity(sceneObject);
606 } 609 }
607 610
608 public void AddEntity(SceneObjectGroup sceneObject) 611 public void AddEntity(SceneObjectGroup sceneObject)
609 { 612 {
610 if (!Entities.ContainsKey(sceneObject.UUID)) 613 if (!Entities.ContainsKey(sceneObject.UUID))
611 { 614 {
612 // QuadTree.AddObject(sceneObject); 615 // QuadTree.AddObject(sceneObject);
613 Entities.Add(sceneObject.UUID, sceneObject); 616 Entities.Add(sceneObject.UUID, sceneObject);
614 } 617 }
615 } 618 }
@@ -648,18 +651,19 @@ namespace OpenSim.Region.Environment.Scenes
648 foreach (XmlNode aPrimNode in rootNode.ChildNodes) 651 foreach (XmlNode aPrimNode in rootNode.ChildNodes)
649 { 652 {
650 SceneObjectGroup obj = new SceneObjectGroup(this, 653 SceneObjectGroup obj = new SceneObjectGroup(this,
651 this.m_regionHandle, aPrimNode.OuterXml); 654 m_regionHandle, aPrimNode.OuterXml);
652 //if we want this to be a import method then we need new uuids for the object to avoid any clashes 655 //if we want this to be a import method then we need new uuids for the object to avoid any clashes
653 //obj.RegenerateFullIDs(); 656 //obj.RegenerateFullIDs();
654 AddEntity(obj); 657 AddEntity(obj);
655 658
656 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 659 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
657 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 660 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
658 rootPart.PhysActor = phyScene.AddPrim( 661 rootPart.PhysActor = phyScene.AddPrim(
659 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, rootPart.AbsolutePosition.Z), 662 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
660 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 663 rootPart.AbsolutePosition.Z),
661 new Axiom.Math.Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 664 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
662 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); 665 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
666 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
663 primCount++; 667 primCount++;
664 } 668 }
665 } 669 }
@@ -679,7 +683,7 @@ namespace OpenSim.Region.Environment.Scenes
679 { 683 {
680 if (ent is SceneObjectGroup) 684 if (ent is SceneObjectGroup)
681 { 685 {
682 stream.WriteLine(((SceneObjectGroup)ent).ToXmlString()); 686 stream.WriteLine(((SceneObjectGroup) ent).ToXmlString());
683 primCount++; 687 primCount++;
684 } 688 }
685 } 689 }
@@ -688,7 +692,6 @@ namespace OpenSim.Region.Environment.Scenes
688 file.Close(); 692 file.Close();
689 } 693 }
690 694
691
692 #endregion 695 #endregion
693 696
694 #region Add/Remove Avatar Methods 697 #region Add/Remove Avatar Methods
@@ -703,7 +706,7 @@ namespace OpenSim.Region.Environment.Scenes
703 { 706 {
704 SubscribeToClientEvents(client); 707 SubscribeToClientEvents(client);
705 m_estateManager.sendRegionHandshake(client); 708 m_estateManager.sendRegionHandshake(client);
706 CreateAndAddScenePresence(client, child ); 709 CreateAndAddScenePresence(client, child);
707 m_LandManager.sendParcelOverlay(client); 710 m_LandManager.sendParcelOverlay(client);
708 commsManager.UserProfiles.AddNewUser(client.AgentId); 711 commsManager.UserProfiles.AddNewUser(client.AgentId);
709 commsManager.TransactionsManager.AddUser(client.AgentId); 712 commsManager.TransactionsManager.AddUser(client.AgentId);
@@ -744,9 +747,11 @@ namespace OpenSim.Region.Environment.Scenes
744 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest); 747 client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest);
745 client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest); 748 client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest);
746 client.OnParcelJoinRequest += new ParcelJoinRequest(m_LandManager.handleParcelJoinRequest); 749 client.OnParcelJoinRequest += new ParcelJoinRequest(m_LandManager.handleParcelJoinRequest);
747 client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest); 750 client.OnParcelPropertiesUpdateRequest +=
751 new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest);
748 client.OnParcelSelectObjects += new ParcelSelectObjects(m_LandManager.handleParcelSelectObjectsRequest); 752 client.OnParcelSelectObjects += new ParcelSelectObjects(m_LandManager.handleParcelSelectObjectsRequest);
749 client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest); 753 client.OnParcelObjectOwnerRequest +=
754 new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest);
750 755
751 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage); 756 client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
752 757
@@ -768,7 +773,7 @@ namespace OpenSim.Region.Environment.Scenes
768 EventManager.TriggerOnNewClient(client); 773 EventManager.TriggerOnNewClient(client);
769 } 774 }
770 775
771 protected ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child ) 776 protected ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child)
772 { 777 {
773 ScenePresence newAvatar = null; 778 ScenePresence newAvatar = null;
774 779
@@ -777,16 +782,18 @@ namespace OpenSim.Region.Environment.Scenes
777 782
778 if (child) 783 if (child)
779 { 784 {
780 MainLog.Instance.Verbose(this.RegionInfo.RegionName + ": Creating new child agent."); 785 MainLog.Instance.Verbose(RegionInfo.RegionName + ": Creating new child agent.");
781 } 786 }
782 else 787 else
783 { 788 {
784 newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement; 789 newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement;
785 790
786 MainLog.Instance.Verbose(this.RegionInfo.RegionName + ": Creating new root agent."); 791 MainLog.Instance.Verbose(RegionInfo.RegionName + ": Creating new root agent.");
787 MainLog.Instance.Verbose(this.RegionInfo.RegionName + ": Adding Physical agent."); 792 MainLog.Instance.Verbose(RegionInfo.RegionName + ": Adding Physical agent.");
788 793
789 PhysicsVector pVec = new PhysicsVector(newAvatar.AbsolutePosition.X, newAvatar.AbsolutePosition.Y, newAvatar.AbsolutePosition.Z); 794 PhysicsVector pVec =
795 new PhysicsVector(newAvatar.AbsolutePosition.X, newAvatar.AbsolutePosition.Y,
796 newAvatar.AbsolutePosition.Z);
790 lock (m_syncRoot) 797 lock (m_syncRoot)
791 { 798 {
792 newAvatar.PhysActor = phyScene.AddAvatar(pVec); 799 newAvatar.PhysActor = phyScene.AddAvatar(pVec);
@@ -832,14 +839,14 @@ namespace OpenSim.Region.Environment.Scenes
832 839
833 ForEachScenePresence( 840 ForEachScenePresence(
834 delegate(ScenePresence presence) 841 delegate(ScenePresence presence)
835 {
836 presence.CoarseLocationChange(avatar);
837 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
838 if (presence.PhysActor != null)
839 { 842 {
840 phyScene.RemoveAvatar(presence.PhysActor); 843 presence.CoarseLocationChange(avatar);
841 } 844 presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
842 }); 845 if (presence.PhysActor != null)
846 {
847 phyScene.RemoveAvatar(presence.PhysActor);
848 }
849 });
843 850
844 lock (Avatars) 851 lock (Avatars)
845 { 852 {
@@ -943,7 +950,7 @@ namespace OpenSim.Region.Environment.Scenes
943 if (Entities.ContainsKey(entID)) 950 if (Entities.ContainsKey(entID))
944 { 951 {
945 Entities.Remove(entID); 952 Entities.Remove(entID);
946 storageManager.DataStore.RemoveObject(entID, this.m_regInfo.SimUUID); 953 storageManager.DataStore.RemoveObject(entID, m_regInfo.SimUUID);
947 return true; 954 return true;
948 } 955 }
949 return false; 956 return false;
@@ -951,10 +958,10 @@ namespace OpenSim.Region.Environment.Scenes
951 958
952 public void SendKillObject(uint localID) 959 public void SendKillObject(uint localID)
953 { 960 {
954 List<ScenePresence> avatars = this.RequestAvatarList(); 961 List<ScenePresence> avatars = RequestAvatarList();
955 for (int i = 0; i < avatars.Count; i++) 962 for (int i = 0; i < avatars.Count; i++)
956 { 963 {
957 avatars[i].ControllingClient.SendKillObject(this.m_regionHandle, localID); 964 avatars[i].ControllingClient.SendKillObject(m_regionHandle, localID);
958 } 965 }
959 } 966 }
960 967
@@ -964,8 +971,8 @@ namespace OpenSim.Region.Environment.Scenes
964 { 971 {
965 if (ent is SceneObjectGroup) 972 if (ent is SceneObjectGroup)
966 { 973 {
967 // ((SceneObjectGroup)ent).SendFullUpdateToClient(client); 974 // ((SceneObjectGroup)ent).SendFullUpdateToClient(client);
968 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); 975 ((SceneObjectGroup) ent).ScheduleFullUpdateToAvatar(presence);
969 } 976 }
970 } 977 }
971 } 978 }
@@ -999,15 +1006,19 @@ namespace OpenSim.Region.Environment.Scenes
999 if (agent.CapsPath != "") 1006 if (agent.CapsPath != "")
1000 { 1007 {
1001 //Console.WriteLine("new user, so creating caps handler for it"); 1008 //Console.WriteLine("new user, so creating caps handler for it");
1002 Caps cap = new Caps(commsManager.AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port, agent.CapsPath, agent.AgentID); 1009 Caps cap =
1003 Util.SetCapsURL(agent.AgentID, "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() + "/CAPS/" + agent.CapsPath + "0000/"); 1010 new Caps(commsManager.AssetCache, httpListener, m_regInfo.ExternalHostName, httpListener.Port,
1011 agent.CapsPath, agent.AgentID);
1012 Util.SetCapsURL(agent.AgentID,
1013 "http://" + m_regInfo.ExternalHostName + ":" + httpListener.Port.ToString() +
1014 "/CAPS/" + agent.CapsPath + "0000/");
1004 cap.RegisterHandlers(); 1015 cap.RegisterHandlers();
1005 cap.AddNewInventoryItem = this.AddInventoryItem; 1016 cap.AddNewInventoryItem = AddInventoryItem;
1006 cap.ItemUpdatedCall = this.CapsUpdateInventoryItemAsset; 1017 cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
1007 if (capsHandlers.ContainsKey(agent.AgentID)) 1018 if (capsHandlers.ContainsKey(agent.AgentID))
1008 { 1019 {
1009 MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + 1020 MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " +
1010 agent.AgentID.ToStringHyphenated()); 1021 agent.AgentID.ToStringHyphenated());
1011 capsHandlers[agent.AgentID] = cap; 1022 capsHandlers[agent.AgentID] = cap;
1012 } 1023 }
1013 else 1024 else
@@ -1142,43 +1153,25 @@ namespace OpenSim.Region.Environment.Scenes
1142 1153
1143 public void AddModule(string name, IRegionModule module) 1154 public void AddModule(string name, IRegionModule module)
1144 { 1155 {
1145 if (!this.Modules.ContainsKey(name)) 1156 if (!Modules.ContainsKey(name))
1146 { 1157 {
1147 Modules.Add(name, module); 1158 Modules.Add(name, module);
1148 } 1159 }
1149 } 1160 }
1150 1161
1151 //following delegate methods will be removed, so use the interface methods (below these)
1152 public void RegisterAPIMethod(string name, object method)
1153 {
1154 if (!this.ModuleAPIMethods.ContainsKey(name))
1155 {
1156 this.ModuleAPIMethods.Add(name, method);
1157 }
1158 }
1159
1160 public object RequestAPIMethod(string name)
1161 {
1162 if (this.ModuleAPIMethods.ContainsKey(name))
1163 {
1164 return ModuleAPIMethods[name];
1165 }
1166 return false;
1167 }
1168
1169 public void RegisterModuleInterface<M>(M mod) 1162 public void RegisterModuleInterface<M>(M mod)
1170 { 1163 {
1171 if (!this.ModuleInterfaces.ContainsKey(typeof(M))) 1164 if (!ModuleInterfaces.ContainsKey(typeof (M)))
1172 { 1165 {
1173 ModuleInterfaces.Add(typeof(M), mod); 1166 ModuleInterfaces.Add(typeof (M), mod);
1174 } 1167 }
1175 } 1168 }
1176 1169
1177 public T RequestModuleInterface<T>() 1170 public T RequestModuleInterface<T>()
1178 { 1171 {
1179 if (ModuleInterfaces.ContainsKey(typeof(T))) 1172 if (ModuleInterfaces.ContainsKey(typeof (T)))
1180 { 1173 {
1181 return (T)ModuleInterfaces[typeof(T)]; 1174 return (T) ModuleInterfaces[typeof (T)];
1182 } 1175 }
1183 else 1176 else
1184 { 1177 {
@@ -1191,7 +1184,8 @@ namespace OpenSim.Region.Environment.Scenes
1191 m_timePhase = phase; 1184 m_timePhase = phase;
1192 } 1185 }
1193 1186
1194 public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) 1187 public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned,
1188 string message, string url)
1195 { 1189 {
1196 if (Avatars.ContainsKey(avatarID)) 1190 if (Avatars.ContainsKey(avatarID))
1197 { 1191 {
@@ -1201,7 +1195,7 @@ namespace OpenSim.Region.Environment.Scenes
1201 1195
1202 #region Alert Methods 1196 #region Alert Methods
1203 1197
1204 void SendPermissionAlert(LLUUID user, string reason) 1198 private void SendPermissionAlert(LLUUID user, string reason)
1205 { 1199 {
1206 SendAlertToUser(user, reason, false); 1200 SendAlertToUser(user, reason, false);
1207 } 1201 }
@@ -1209,7 +1203,7 @@ namespace OpenSim.Region.Environment.Scenes
1209 1203
1210 public void SendGeneralAlert(string message) 1204 public void SendGeneralAlert(string message)
1211 { 1205 {
1212 foreach (ScenePresence presence in this.Avatars.Values) 1206 foreach (ScenePresence presence in Avatars.Values)
1213 { 1207 {
1214 presence.ControllingClient.SendAlertMessage(message); 1208 presence.ControllingClient.SendAlertMessage(message);
1215 } 1209 }
@@ -1217,15 +1211,15 @@ namespace OpenSim.Region.Environment.Scenes
1217 1211
1218 public void SendAlertToUser(LLUUID agentID, string message, bool modal) 1212 public void SendAlertToUser(LLUUID agentID, string message, bool modal)
1219 { 1213 {
1220 if (this.Avatars.ContainsKey(agentID)) 1214 if (Avatars.ContainsKey(agentID))
1221 { 1215 {
1222 this.Avatars[agentID].ControllingClient.SendAgentAlertMessage(message, modal); 1216 Avatars[agentID].ControllingClient.SendAgentAlertMessage(message, modal);
1223 } 1217 }
1224 } 1218 }
1225 1219
1226 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 1220 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
1227 { 1221 {
1228 foreach (ScenePresence presence in this.Avatars.Values) 1222 foreach (ScenePresence presence in Avatars.Values)
1229 { 1223 {
1230 if ((presence.Firstname == firstName) && (presence.Lastname == lastName)) 1224 if ((presence.Firstname == firstName) && (presence.Lastname == lastName))
1231 { 1225 {
@@ -1239,13 +1233,13 @@ namespace OpenSim.Region.Environment.Scenes
1239 { 1233 {
1240 if (commandParams[0] == "general") 1234 if (commandParams[0] == "general")
1241 { 1235 {
1242 string message = this.CombineParams(commandParams, 1); 1236 string message = CombineParams(commandParams, 1);
1243 this.SendGeneralAlert(message); 1237 SendGeneralAlert(message);
1244 } 1238 }
1245 else 1239 else
1246 { 1240 {
1247 string message = this.CombineParams(commandParams, 2); 1241 string message = CombineParams(commandParams, 2);
1248 this.SendAlertToUser(commandParams[0], commandParams[1], message, false); 1242 SendAlertToUser(commandParams[0], commandParams[1], message, false);
1249 } 1243 }
1250 } 1244 }
1251 1245
@@ -1258,36 +1252,39 @@ namespace OpenSim.Region.Environment.Scenes
1258 } 1252 }
1259 return result; 1253 return result;
1260 } 1254 }
1255
1261 #endregion 1256 #endregion
1262 1257
1263 public void ForceClientUpdate() 1258 public void ForceClientUpdate()
1264 { 1259 {
1265 foreach (EntityBase ent in this.Entities.Values) 1260 foreach (EntityBase ent in Entities.Values)
1266 { 1261 {
1267 if (ent is SceneObjectGroup) 1262 if (ent is SceneObjectGroup)
1268 { 1263 {
1269 ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); 1264 ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate();
1270 } 1265 }
1271 } 1266 }
1272 } 1267 }
1273 1268
1274 public void HandleEditCommand(string[] cmmdparams) 1269 public void HandleEditCommand(string[] cmmdparams)
1275 { 1270 {
1276 Console.WriteLine("Searching for Primitive: '" + cmmdparams[0] + "'"); 1271 Console.WriteLine("Searching for Primitive: '" + cmmdparams[0] + "'");
1277 foreach (EntityBase ent in this.Entities.Values) 1272 foreach (EntityBase ent in Entities.Values)
1278 { 1273 {
1279 if (ent is SceneObjectGroup) 1274 if (ent is SceneObjectGroup)
1280 { 1275 {
1281 SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); 1276 SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID);
1282 if (part != null) 1277 if (part != null)
1283 { 1278 {
1284 if (part.Name == cmmdparams[0]) 1279 if (part.Name == cmmdparams[0])
1285 { 1280 {
1286 part.Resize( new LLVector3(Convert.ToSingle(cmmdparams[1]), Convert.ToSingle(cmmdparams[2]), Convert.ToSingle(cmmdparams[3]))); 1281 part.Resize(
1287 1282 new LLVector3(Convert.ToSingle(cmmdparams[1]), Convert.ToSingle(cmmdparams[2]),
1288 Console.WriteLine("Edited scale of Primitive: " + part.Name); 1283 Convert.ToSingle(cmmdparams[3])));
1289 } 1284
1290 } 1285 Console.WriteLine("Edited scale of Primitive: " + part.Name);
1286 }
1287 }
1291 } 1288 }
1292 } 1289 }
1293 } 1290 }
@@ -1298,7 +1295,9 @@ namespace OpenSim.Region.Environment.Scenes
1298 { 1295 {
1299 case "users": 1296 case "users":
1300 MainLog.Instance.Error("Current Region: " + RegionInfo.RegionName); 1297 MainLog.Instance.Error("Current Region: " + RegionInfo.RegionName);
1301 MainLog.Instance.Error(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World")); 1298 MainLog.Instance.Error(
1299 String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname",
1300 "Agent ID", "Session ID", "Circuit", "IP", "World"));
1302 1301
1303 foreach (EntityBase entity in Entities.Values) 1302 foreach (EntityBase entity in Entities.Values)
1304 { 1303 {
@@ -1321,8 +1320,8 @@ namespace OpenSim.Region.Environment.Scenes
1321 } 1320 }
1322 break; 1321 break;
1323 case "modules": 1322 case "modules":
1324 MainLog.Instance.Error("The currently loaded modules in " + this.RegionInfo.RegionName + " are:"); 1323 MainLog.Instance.Error("The currently loaded modules in " + RegionInfo.RegionName + " are:");
1325 foreach (OpenSim.Region.Environment.Interfaces.IRegionModule module in this.Modules.Values) 1324 foreach (IRegionModule module in Modules.Values)
1326 { 1325 {
1327 if (!module.IsSharedModule()) 1326 if (!module.IsSharedModule())
1328 { 1327 {
@@ -1337,19 +1336,22 @@ namespace OpenSim.Region.Environment.Scenes
1337 { 1336 {
1338 if (m_httpRequestModule != null) 1337 if (m_httpRequestModule != null)
1339 { 1338 {
1340 return m_httpRequestModule.MakeHttpRequest(url, type, body); 1339 return m_httpRequestModule.MakeHttpRequest(url, type, body);
1341 } 1340 }
1342 return LLUUID.Zero; 1341 return LLUUID.Zero;
1343 } 1342 }
1344 1343
1345 #region Script Engine 1344 #region Script Engine
1346 private List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface> ScriptEngines = new List<OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface>(); 1345
1347 public void AddScriptEngine(OpenSim.Region.Environment.Scenes.Scripting.ScriptEngineInterface ScriptEngine, LogBase m_logger) 1346 private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
1347
1348 public void AddScriptEngine(ScriptEngineInterface ScriptEngine, LogBase m_logger)
1348 { 1349 {
1349 ScriptEngines.Add(ScriptEngine); 1350 ScriptEngines.Add(ScriptEngine);
1350 1351
1351 ScriptEngine.InitializeEngine(this, m_logger); 1352 ScriptEngine.InitializeEngine(this, m_logger);
1352 } 1353 }
1354
1353 #endregion 1355 #endregion
1354 1356
1355 public LLUUID ConvertLocalIDToFullID(uint localID) 1357 public LLUUID ConvertLocalIDToFullID(uint localID)
@@ -1359,10 +1361,10 @@ namespace OpenSim.Region.Environment.Scenes
1359 { 1361 {
1360 if (ent is SceneObjectGroup) 1362 if (ent is SceneObjectGroup)
1361 { 1363 {
1362 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 1364 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
1363 if (hasPrim != false) 1365 if (hasPrim != false)
1364 { 1366 {
1365 return ((SceneObjectGroup)ent).GetPartsFullID(localID); 1367 return ((SceneObjectGroup) ent).GetPartsFullID(localID);
1366 } 1368 }
1367 } 1369 }
1368 } 1370 }
@@ -1376,10 +1378,10 @@ namespace OpenSim.Region.Environment.Scenes
1376 { 1378 {
1377 if (ent is SceneObjectGroup) 1379 if (ent is SceneObjectGroup)
1378 { 1380 {
1379 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 1381 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(localID);
1380 if (hasPrim != false) 1382 if (hasPrim != false)
1381 { 1383 {
1382 return ((SceneObjectGroup)ent).GetChildPart(localID); 1384 return ((SceneObjectGroup) ent).GetChildPart(localID);
1383 } 1385 }
1384 } 1386 }
1385 } 1387 }
@@ -1393,14 +1395,14 @@ namespace OpenSim.Region.Environment.Scenes
1393 { 1395 {
1394 if (ent is SceneObjectGroup) 1396 if (ent is SceneObjectGroup)
1395 { 1397 {
1396 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); 1398 hasPrim = ((SceneObjectGroup) ent).HasChildPrim(fullID);
1397 if (hasPrim != false) 1399 if (hasPrim != false)
1398 { 1400 {
1399 return ((SceneObjectGroup)ent).GetChildPart(fullID); 1401 return ((SceneObjectGroup) ent).GetChildPart(fullID);
1400 } 1402 }
1401 } 1403 }
1402 } 1404 }
1403 return null; 1405 return null;
1404 } 1406 }
1405 } 1407 }
1406} 1408} \ No newline at end of file