diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 105 |
1 files changed, 77 insertions, 28 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b3b6cbc..513c0ea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -611,6 +611,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
611 | "delete object name <name>", | 611 | "delete object name <name>", |
612 | "Delete object by name", HandleDeleteObject); | 612 | "Delete object by name", HandleDeleteObject); |
613 | 613 | ||
614 | MainConsole.Instance.Commands.AddCommand("region", false, "delete object outside", | ||
615 | "delete object outside", | ||
616 | "Delete all objects outside boundaries", HandleDeleteObject); | ||
617 | |||
614 | //Bind Storage Manager functions to some land manager functions for this scene | 618 | //Bind Storage Manager functions to some land manager functions for this scene |
615 | EventManager.OnLandObjectAdded += | 619 | EventManager.OnLandObjectAdded += |
616 | new EventManager.LandObjectAdded(simDataService.StoreLandObject); | 620 | new EventManager.LandObjectAdded(simDataService.StoreLandObject); |
@@ -2539,10 +2543,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2539 | #region Add/Remove Avatar Methods | 2543 | #region Add/Remove Avatar Methods |
2540 | 2544 | ||
2541 | /// <summary> | 2545 | /// <summary> |
2542 | /// Adding a New Client and Create a Presence for it. | 2546 | /// Add a new client and create a child agent for it. |
2543 | /// </summary> | 2547 | /// </summary> |
2544 | /// <param name="client"></param> | 2548 | /// <param name="client"></param> |
2545 | public override void AddNewClient(IClientAPI client) | 2549 | /// <param name="type">The type of agent to add.</param> |
2550 | public override void AddNewClient(IClientAPI client, PresenceType type) | ||
2546 | { | 2551 | { |
2547 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | 2552 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); |
2548 | bool vialogin = false; | 2553 | bool vialogin = false; |
@@ -2562,7 +2567,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2562 | m_clientManager.Add(client); | 2567 | m_clientManager.Add(client); |
2563 | SubscribeToClientEvents(client); | 2568 | SubscribeToClientEvents(client); |
2564 | 2569 | ||
2565 | ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance); | 2570 | ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
2566 | m_eventManager.TriggerOnNewPresence(sp); | 2571 | m_eventManager.TriggerOnNewPresence(sp); |
2567 | 2572 | ||
2568 | sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; | 2573 | sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; |
@@ -2577,12 +2582,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2577 | } | 2582 | } |
2578 | } | 2583 | } |
2579 | 2584 | ||
2580 | if (GetScenePresence(client.AgentId) != null) | 2585 | ScenePresence createdSp = GetScenePresence(client.AgentId); |
2586 | if (createdSp != null) | ||
2581 | { | 2587 | { |
2582 | m_LastLogin = Util.EnvironmentTickCount(); | 2588 | m_LastLogin = Util.EnvironmentTickCount(); |
2583 | 2589 | ||
2584 | // Cache the user's name | 2590 | // Cache the user's name |
2585 | CacheUserName(aCircuit); | 2591 | CacheUserName(createdSp, aCircuit); |
2586 | 2592 | ||
2587 | EventManager.TriggerOnNewClient(client); | 2593 | EventManager.TriggerOnNewClient(client); |
2588 | if (vialogin) | 2594 | if (vialogin) |
@@ -2590,28 +2596,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
2590 | } | 2596 | } |
2591 | } | 2597 | } |
2592 | 2598 | ||
2593 | private void CacheUserName(AgentCircuitData aCircuit) | 2599 | /// <summary> |
2600 | /// Cache the user name for later use. | ||
2601 | /// </summary> | ||
2602 | /// <param name="sp"></param> | ||
2603 | /// <param name="aCircuit"></param> | ||
2604 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) | ||
2594 | { | 2605 | { |
2595 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | 2606 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); |
2596 | if (uMan != null) | 2607 | if (uMan != null) |
2597 | { | 2608 | { |
2598 | string homeURL = string.Empty; | ||
2599 | string first = aCircuit.firstname, last = aCircuit.lastname; | 2609 | string first = aCircuit.firstname, last = aCircuit.lastname; |
2600 | 2610 | ||
2601 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | 2611 | if (sp.PresenceType == PresenceType.Npc) |
2602 | homeURL = aCircuit.ServiceURLs["HomeURI"].ToString(); | 2612 | { |
2603 | 2613 | uMan.AddUser(aCircuit.AgentID, first, last); | |
2604 | if (aCircuit.lastname.StartsWith("@")) | 2614 | } |
2615 | else | ||
2605 | { | 2616 | { |
2606 | string[] parts = aCircuit.firstname.Split('.'); | 2617 | string homeURL = string.Empty; |
2607 | if (parts.Length >= 2) | 2618 | |
2619 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | ||
2620 | homeURL = aCircuit.ServiceURLs["HomeURI"].ToString(); | ||
2621 | |||
2622 | if (aCircuit.lastname.StartsWith("@")) | ||
2608 | { | 2623 | { |
2609 | first = parts[0]; | 2624 | string[] parts = aCircuit.firstname.Split('.'); |
2610 | last = parts[1]; | 2625 | if (parts.Length >= 2) |
2626 | { | ||
2627 | first = parts[0]; | ||
2628 | last = parts[1]; | ||
2629 | } | ||
2611 | } | 2630 | } |
2612 | } | ||
2613 | 2631 | ||
2614 | uMan.AddUser(aCircuit.AgentID, first, last, homeURL); | 2632 | uMan.AddUser(aCircuit.AgentID, first, last, homeURL); |
2633 | } | ||
2615 | } | 2634 | } |
2616 | } | 2635 | } |
2617 | 2636 | ||
@@ -3091,11 +3110,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3091 | } | 3110 | } |
3092 | } | 3111 | } |
3093 | 3112 | ||
3094 | /// <summary> | 3113 | public override void RemoveClient(UUID agentID, bool closeChildAgents) |
3095 | /// Remove the given client from the scene. | ||
3096 | /// </summary> | ||
3097 | /// <param name="agentID"></param> | ||
3098 | public override void RemoveClient(UUID agentID) | ||
3099 | { | 3114 | { |
3100 | CheckHeartbeat(); | 3115 | CheckHeartbeat(); |
3101 | bool childagentYN = false; | 3116 | bool childagentYN = false; |
@@ -3116,15 +3131,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3116 | (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); | 3131 | (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); |
3117 | 3132 | ||
3118 | m_sceneGraph.removeUserCount(!childagentYN); | 3133 | m_sceneGraph.removeUserCount(!childagentYN); |
3119 | 3134 | ||
3120 | if (CapsModule != null) | 3135 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3136 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | ||
3137 | if (closeChildAgents && CapsModule != null) | ||
3121 | CapsModule.RemoveCaps(agentID); | 3138 | CapsModule.RemoveCaps(agentID); |
3122 | 3139 | ||
3123 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever | 3140 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3124 | // this method is doing is HORRIBLE!!! | 3141 | // this method is doing is HORRIBLE!!! |
3125 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); | 3142 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); |
3126 | 3143 | ||
3127 | if (!avatar.IsChildAgent) | 3144 | if (closeChildAgents && !avatar.IsChildAgent) |
3128 | { | 3145 | { |
3129 | //List<ulong> childknownRegions = new List<ulong>(); | 3146 | //List<ulong> childknownRegions = new List<ulong>(); |
3130 | //List<ulong> ckn = avatar.KnownChildRegionHandles; | 3147 | //List<ulong> ckn = avatar.KnownChildRegionHandles; |
@@ -3136,6 +3153,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3136 | regions.Remove(RegionInfo.RegionHandle); | 3153 | regions.Remove(RegionInfo.RegionHandle); |
3137 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3154 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3138 | } | 3155 | } |
3156 | |||
3139 | m_eventManager.TriggerClientClosed(agentID, this); | 3157 | m_eventManager.TriggerClientClosed(agentID, this); |
3140 | } | 3158 | } |
3141 | catch (NullReferenceException) | 3159 | catch (NullReferenceException) |
@@ -3146,7 +3164,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3146 | 3164 | ||
3147 | m_eventManager.TriggerOnRemovePresence(agentID); | 3165 | m_eventManager.TriggerOnRemovePresence(agentID); |
3148 | 3166 | ||
3149 | if (avatar != null && (!avatar.IsChildAgent)) | 3167 | if (avatar != null && (!avatar.IsChildAgent) && avatar.PresenceType != PresenceType.Npc) |
3150 | avatar.SaveChangedAttachments(); | 3168 | avatar.SaveChangedAttachments(); |
3151 | 3169 | ||
3152 | ForEachClient( | 3170 | ForEachClient( |
@@ -4942,11 +4960,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
4942 | 4960 | ||
4943 | private void HandleDeleteObject(string module, string[] cmd) | 4961 | private void HandleDeleteObject(string module, string[] cmd) |
4944 | { | 4962 | { |
4945 | if (cmd.Length < 4) | 4963 | if (cmd.Length < 3) |
4946 | return; | 4964 | return; |
4947 | 4965 | ||
4948 | string mode = cmd[2]; | 4966 | string mode = cmd[2]; |
4949 | string o = cmd[3]; | 4967 | string o = ""; |
4968 | |||
4969 | if (mode != "outside") | ||
4970 | { | ||
4971 | if (cmd.Length < 4) | ||
4972 | return; | ||
4973 | |||
4974 | o = cmd[3]; | ||
4975 | } | ||
4950 | 4976 | ||
4951 | List<SceneObjectGroup> deletes = new List<SceneObjectGroup>(); | 4977 | List<SceneObjectGroup> deletes = new List<SceneObjectGroup>(); |
4952 | 4978 | ||
@@ -4988,10 +5014,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
4988 | deletes.Add(g); | 5014 | deletes.Add(g); |
4989 | }); | 5015 | }); |
4990 | break; | 5016 | break; |
5017 | case "outside": | ||
5018 | ForEachSOG(delegate (SceneObjectGroup g) | ||
5019 | { | ||
5020 | SceneObjectPart rootPart = g.RootPart; | ||
5021 | bool delete = false; | ||
5022 | |||
5023 | if (rootPart.GroupPosition.Z < 0.0 || rootPart.GroupPosition.Z > 10000.0) | ||
5024 | { | ||
5025 | delete = true; | ||
5026 | } else { | ||
5027 | ILandObject parcel = LandChannel.GetLandObject(rootPart.GroupPosition.X, rootPart.GroupPosition.Y); | ||
5028 | |||
5029 | if (parcel == null || parcel.LandData.Name == "NO LAND") | ||
5030 | delete = true; | ||
5031 | } | ||
5032 | |||
5033 | if (delete && !rootPart.IsAttachment && !deletes.Contains(g)) | ||
5034 | deletes.Add(g); | ||
5035 | }); | ||
5036 | break; | ||
4991 | } | 5037 | } |
4992 | 5038 | ||
4993 | foreach (SceneObjectGroup g in deletes) | 5039 | foreach (SceneObjectGroup g in deletes) |
5040 | { | ||
5041 | m_log.InfoFormat("[SCENE]: Deleting object {0}", g.UUID); | ||
4994 | DeleteSceneObject(g, false); | 5042 | DeleteSceneObject(g, false); |
5043 | } | ||
4995 | } | 5044 | } |
4996 | 5045 | ||
4997 | private void HandleReloadEstate(string module, string[] cmd) | 5046 | private void HandleReloadEstate(string module, string[] cmd) |