From 297cc7ef4f44dc783ebee817f48c205b04aa68f7 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 13 Nov 2007 12:23:05 +0000 Subject: Some work on cleanly removing Regions. --- OpenSim/Framework/IClientAPI.cs | 1 + OpenSim/Region/Application/OpenSimMain.cs | 4 -- OpenSim/Region/ClientStack/ClientView.cs | 10 ++++ OpenSim/Region/Environment/Scenes/Scene.cs | 67 +++++++++++++--------- OpenSim/Region/Environment/Scenes/SceneManager.cs | 29 ++++++++++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 1 + .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 5 ++ 7 files changed, 87 insertions(+), 30 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 5d7bdd4..ed223f4 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -439,6 +439,7 @@ namespace OpenSim.Framework void SetDebug(int newDebug); void InPacket(Packet NewPack); void Close(); + void Stop(); event ViewerEffectEventHandler OnViewerEffect; event Action OnLogout; event Action OnConnectionClosed; diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 7efe408..e041eef 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -435,10 +435,6 @@ namespace OpenSim } } - protected void ConnectToRemoteGridServer() - { - } - #endregion /// diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 4b3a6c1..839556d 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -158,6 +158,16 @@ namespace OpenSim.Region.ClientStack ClientThread.Abort(); } + public void Stop() + { + clientPingTimer.Stop(); + + libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); + OutPacket(disable); + + ClientThread.Abort(); + } + #endregion # region Packet Handling diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b4c8b68..2d58b0e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -47,7 +47,7 @@ using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Types; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Terrain; -using Timer=System.Timers.Timer; +using Timer = System.Timers.Timer; namespace OpenSim.Region.Environment.Scenes { @@ -195,7 +195,7 @@ namespace OpenSim.Region.Environment.Scenes ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim) { updateLock = new Mutex(false); - + m_moduleLoader = moduleLoader; m_authenticateHandler = authen; CommsManager = commsMan; @@ -228,7 +228,7 @@ namespace OpenSim.Region.Environment.Scenes m_sceneObjects = new Dictionary(); MainLog.Instance.Verbose("Creating LandMap"); - Terrain = new TerrainEngine((int) RegionInfo.RegionLocX, (int) RegionInfo.RegionLocY); + Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY); ScenePresence.LoadAnims(); @@ -241,11 +241,26 @@ namespace OpenSim.Region.Environment.Scenes #region Startup / Close Methods public override void Close() { + ForEachScenePresence(delegate(ScenePresence avatar) + { + avatar.ControllingClient.Stop(); + }); + m_heartbeatTimer.Close(); m_innerScene.Close(); m_sceneGridService.Close(); + foreach (IRegionModule module in this.Modules.Values) + { + if (!module.IsSharedModule) + { + module.Close(); + } + } + Modules.Clear(); + base.Close(); + } /// @@ -299,30 +314,30 @@ namespace OpenSim.Region.Environment.Scenes if (m_frame == Int32.MaxValue) m_frame = 0; - if (m_frame%m_update_physics == 0) + if (m_frame % m_update_physics == 0) m_innerScene.UpdatePreparePhysics(); - if (m_frame%m_update_entitymovement == 0) + if (m_frame % m_update_entitymovement == 0) m_innerScene.UpdateEntityMovement(); - if (m_frame%m_update_physics == 0) + if (m_frame % m_update_physics == 0) m_innerScene.UpdatePhysics( Math.Max(SinceLastFrame.TotalSeconds, m_timespan) ); - if (m_frame%m_update_entities == 0) + if (m_frame % m_update_entities == 0) m_innerScene.UpdateEntities(); - if (m_frame%m_update_events == 0) + if (m_frame % m_update_events == 0) UpdateEvents(); - if (m_frame%m_update_backup == 0) + if (m_frame % m_update_backup == 0) UpdateStorageBackup(); - if (m_frame%m_update_terrain == 0) + if (m_frame % m_update_terrain == 0) UpdateTerrain(); - if (m_frame%m_update_land == 0) + if (m_frame % m_update_land == 0) UpdateLand(); // if (m_frame%m_update_avatars == 0) @@ -340,7 +355,7 @@ namespace OpenSim.Region.Environment.Scenes { updateLock.ReleaseMutex(); - m_timedilation = m_timespan/(float) SinceLastFrame.TotalSeconds; + m_timedilation = m_timespan / (float)SinceLastFrame.TotalSeconds; m_lastupdate = DateTime.Now; } } @@ -397,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes { for (int y = 0; y < 16; y++) { - if (Terrain.Tainted(x*16, y*16)) + if (Terrain.Tainted(x * 16, y * 16)) { client.SendLayerData(x, y, terData); } @@ -524,7 +539,7 @@ namespace OpenSim.Region.Environment.Scenes AddEntityFromStorage(prim); SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrimShape( rootPart.Name, rootPart.Shape, @@ -570,11 +585,11 @@ namespace OpenSim.Region.Environment.Scenes // if grass or tree, make phantom if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255)) { - rootPart.ObjectFlags += (uint) LLObject.ObjectFlags.Phantom; + rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; } // if not phantom, add to physics bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) + if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) rootPart.PhysActor = phyScene.AddPrimShape( rootPart.Name, @@ -668,7 +683,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnRegionHandShakeReply += SendLayerData; //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); client.OnModifyTerrain += ModifyTerrain; - // client.OnRequestWearables += InformClientOfNeighbours; + // client.OnRequestWearables += InformClientOfNeighbours; client.OnAddPrim += AddNewPrim; client.OnUpdatePrimGroupPosition += m_innerScene.UpdatePrimPosition; client.OnUpdatePrimSinglePosition += m_innerScene.UpdatePrimSinglePosition; @@ -843,7 +858,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_capsHandlers.ContainsKey(agent.AgentID)) { //MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " + - // agent.AgentID.ToStringHyphenated()); + // agent.AgentID.ToStringHyphenated()); m_capsHandlers[agent.AgentID] = cap; } else @@ -871,7 +886,7 @@ namespace OpenSim.Region.Environment.Scenes if (regionHandle == m_regionHandle) { ScenePresence presence = m_innerScene.GetScenePresence(agentID); - if(presence != null) + if (presence != null) { libsecondlife.Packets.DisableSimulatorPacket disable = new libsecondlife.Packets.DisableSimulatorPacket(); presence.ControllingClient.OutPacket(disable); @@ -879,7 +894,7 @@ namespace OpenSim.Region.Environment.Scenes } } - + /// /// /// @@ -951,17 +966,17 @@ namespace OpenSim.Region.Environment.Scenes public void RegisterModuleInterface(M mod) { - if (!ModuleInterfaces.ContainsKey(typeof (M))) + if (!ModuleInterfaces.ContainsKey(typeof(M))) { - ModuleInterfaces.Add(typeof (M), mod); + ModuleInterfaces.Add(typeof(M), mod); } } public T RequestModuleInterface() { - if (ModuleInterfaces.ContainsKey(typeof (T))) + if (ModuleInterfaces.ContainsKey(typeof(T))) { - return (T) ModuleInterfaces[typeof (T)]; + return (T)ModuleInterfaces[typeof(T)]; } else { @@ -1073,7 +1088,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - ((SceneObjectGroup) ent).ScheduleGroupForFullUpdate(); + ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate(); } } } @@ -1085,7 +1100,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent is SceneObjectGroup) { - SceneObjectPart part = ((SceneObjectGroup) ent).GetChildPart(((SceneObjectGroup) ent).UUID); + SceneObjectPart part = ((SceneObjectGroup)ent).GetChildPart(((SceneObjectGroup)ent).UUID); if (part != null) { if (part.Name == cmmdparams[0]) diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 75e2a41..da553bc 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs @@ -179,6 +179,35 @@ namespace OpenSim.Region.Environment.Scenes } } + public bool TryGetScene(string regionName, out Scene scene) + { + foreach (Scene mscene in m_localScenes) + { + if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) + { + scene = mscene; + return true; + } + } + scene = null; + return false; + } + + public bool TryGetScene(LLUUID regionID, out Scene scene) + { + foreach (Scene mscene in m_localScenes) + { + if (mscene.RegionInfo.RegionID == regionID) + { + scene = mscene; + return true; + } + } + scene = null; + return false; + } + + public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug) { ForEachCurrentScene(delegate(Scene scene) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 48f3ef0..cfa4ffe 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1197,6 +1197,7 @@ namespace OpenSim.Region.Environment.Scenes { m_wearables[wearableId] = wearable; SendOwnWearables(); + } private void SendOwnWearables() diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 474f6fd..0232b2d 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -427,6 +427,11 @@ namespace SimpleApp { } + public void Stop() + { + + } + private uint m_circuitCode; public uint CircuitCode -- cgit v1.1