diff options
author | UbitUmarov | 2014-08-17 05:59:14 +0100 |
---|---|---|
committer | UbitUmarov | 2014-08-17 05:59:14 +0100 |
commit | 8d11b96cd989e5e0ddf2a204b1150cca5a5db1a6 (patch) | |
tree | cf637731bf5d9a4525e18bfa64c5f63ac165bc87 /OpenSim | |
parent | bad test (diff) | |
download | opensim-SC-8d11b96cd989e5e0ddf2a204b1150cca5a5db1a6.zip opensim-SC-8d11b96cd989e5e0ddf2a204b1150cca5a5db1a6.tar.gz opensim-SC-8d11b96cd989e5e0ddf2a204b1150cca5a5db1a6.tar.bz2 opensim-SC-8d11b96cd989e5e0ddf2a204b1150cca5a5db1a6.tar.xz |
*DANGER* rearange EnableChildAgents() so that hopefully it does it job
better, like not telling clients to log on regions where they are already
child
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 190 |
1 files changed, 86 insertions, 104 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index fb0da2e..6ea9325 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1841,7 +1841,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1841 | #region Enable Child Agent | 1841 | #region Enable Child Agent |
1842 | 1842 | ||
1843 | /// <summary> | 1843 | /// <summary> |
1844 | /// This informs a single neighbouring region about agent "avatar". | 1844 | /// This informs a single neighbouring region about agent "avatar", and avatar about it |
1845 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | 1845 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. |
1846 | /// </summary> | 1846 | /// </summary> |
1847 | /// <param name="sp"></param> | 1847 | /// <param name="sp"></param> |
@@ -1857,8 +1857,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1857 | agent.startpos = new Vector3(128, 128, 70); | 1857 | agent.startpos = new Vector3(128, 128, 70); |
1858 | agent.child = true; | 1858 | agent.child = true; |
1859 | 1859 | ||
1860 | //agent.Appearance = sp.Appearance; | ||
1861 | //agent.Appearance = new AvatarAppearance(sp.Appearance, true, false); | ||
1862 | agent.Appearance = new AvatarAppearance(); | 1860 | agent.Appearance = new AvatarAppearance(); |
1863 | agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight; | 1861 | agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight; |
1864 | 1862 | ||
@@ -1912,6 +1910,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1912 | 1910 | ||
1913 | /// <summary> | 1911 | /// <summary> |
1914 | /// This informs all neighbouring regions about agent "avatar". | 1912 | /// This informs all neighbouring regions about agent "avatar". |
1913 | /// and as important informs the avatar about then | ||
1915 | /// </summary> | 1914 | /// </summary> |
1916 | /// <param name="sp"></param> | 1915 | /// <param name="sp"></param> |
1917 | public void EnableChildAgents(ScenePresence sp) | 1916 | public void EnableChildAgents(ScenePresence sp) |
@@ -1928,84 +1927,77 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1928 | m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); | 1927 | m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); |
1929 | } | 1928 | } |
1930 | 1929 | ||
1931 | /// We need to find the difference between the new regions where there are no child agents | 1930 | LinkedList<ulong> previousRegionNeighbourHandles; |
1932 | /// and the regions where there are already child agents. We only send notification to the former. | 1931 | |
1933 | List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region | 1932 | Dictionary<ulong, string> seeds; |
1934 | neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too | ||
1935 | List<ulong> previousRegionNeighbourHandles; | ||
1936 | 1933 | ||
1937 | if (sp.Scene.CapsModule != null) | 1934 | if (sp.Scene.CapsModule != null) |
1938 | { | 1935 | { |
1939 | previousRegionNeighbourHandles = | 1936 | seeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); |
1940 | new List<ulong>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys); | 1937 | previousRegionNeighbourHandles = new LinkedList<ulong>(seeds.Keys); |
1941 | } | 1938 | } |
1942 | else | 1939 | else |
1943 | { | 1940 | { |
1944 | previousRegionNeighbourHandles = new List<ulong>(); | ||
1945 | } | ||
1946 | |||
1947 | List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); | ||
1948 | List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); | ||
1949 | |||
1950 | // Dump("Current Neighbors", neighbourHandles); | ||
1951 | // Dump("Previous Neighbours", previousRegionNeighbourHandles); | ||
1952 | // Dump("New Neighbours", newRegions); | ||
1953 | // Dump("Old Neighbours", oldRegions); | ||
1954 | |||
1955 | /// Update the scene presence's known regions here on this region | ||
1956 | sp.DropOldNeighbours(oldRegions); | ||
1957 | |||
1958 | /// Collect as many seeds as possible | ||
1959 | Dictionary<ulong, string> seeds; | ||
1960 | if (sp.Scene.CapsModule != null) | ||
1961 | seeds = new Dictionary<ulong, string>(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); | ||
1962 | else | ||
1963 | seeds = new Dictionary<ulong, string>(); | 1941 | seeds = new Dictionary<ulong, string>(); |
1942 | previousRegionNeighbourHandles = new LinkedList<ulong>(); | ||
1943 | } | ||
1964 | 1944 | ||
1965 | //m_log.Debug(" !!! No. of seeds: " + seeds.Count); | ||
1966 | if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) | 1945 | if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) |
1967 | seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); | 1946 | seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); |
1968 | 1947 | ||
1969 | /// Create the necessary child agents | 1948 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); |
1949 | |||
1950 | List<ulong> newneighbours = new List<ulong>(); | ||
1970 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); | 1951 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); |
1952 | |||
1953 | ulong currentRegionHandler = sp.Scene.RegionInfo.RegionHandle; | ||
1954 | |||
1971 | foreach (GridRegion neighbour in neighbours) | 1955 | foreach (GridRegion neighbour in neighbours) |
1972 | { | 1956 | { |
1973 | if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) | 1957 | ulong handler = neighbour.RegionHandle; |
1974 | { | ||
1975 | AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); | ||
1976 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); | ||
1977 | agent.BaseFolder = UUID.Zero; | ||
1978 | agent.InventoryFolder = UUID.Zero; | ||
1979 | agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour); | ||
1980 | agent.child = true; | ||
1981 | // agent.Appearance = sp.Appearance; | ||
1982 | // agent.Appearance = new AvatarAppearance(sp.Appearance, true, false); | ||
1983 | agent.Appearance = new AvatarAppearance(); | ||
1984 | agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight; | ||
1985 | |||
1986 | if (currentAgentCircuit != null) | ||
1987 | { | ||
1988 | agent.ServiceURLs = currentAgentCircuit.ServiceURLs; | ||
1989 | agent.IPAddress = currentAgentCircuit.IPAddress; | ||
1990 | agent.Viewer = currentAgentCircuit.Viewer; | ||
1991 | agent.Channel = currentAgentCircuit.Channel; | ||
1992 | agent.Mac = currentAgentCircuit.Mac; | ||
1993 | agent.Id0 = currentAgentCircuit.Id0; | ||
1994 | } | ||
1995 | 1958 | ||
1996 | if (newRegions.Contains(neighbour.RegionHandle)) | 1959 | if (handler == currentRegionHandler) |
1997 | { | 1960 | continue; |
1998 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | 1961 | |
1999 | sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath); | 1962 | AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); |
2000 | seeds.Add(neighbour.RegionHandle, agent.CapsPath); | 1963 | agent.BaseFolder = UUID.Zero; |
2001 | } | 1964 | agent.InventoryFolder = UUID.Zero; |
2002 | else | 1965 | agent.startpos = sp.AbsolutePosition + CalculateOffset(sp, neighbour); |
2003 | { | 1966 | agent.child = true; |
2004 | agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); | 1967 | agent.Appearance = new AvatarAppearance(); |
2005 | } | 1968 | agent.Appearance.AvatarHeight = sp.Appearance.AvatarHeight; |
1969 | |||
1970 | if (currentAgentCircuit != null) | ||
1971 | { | ||
1972 | agent.ServiceURLs = currentAgentCircuit.ServiceURLs; | ||
1973 | agent.IPAddress = currentAgentCircuit.IPAddress; | ||
1974 | agent.Viewer = currentAgentCircuit.Viewer; | ||
1975 | agent.Channel = currentAgentCircuit.Channel; | ||
1976 | agent.Mac = currentAgentCircuit.Mac; | ||
1977 | agent.Id0 = currentAgentCircuit.Id0; | ||
1978 | } | ||
2006 | 1979 | ||
2007 | cagents.Add(agent); | 1980 | if (previousRegionNeighbourHandles.Contains(handler)) |
1981 | { | ||
1982 | previousRegionNeighbourHandles.Remove(handler); | ||
1983 | agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, handler); | ||
2008 | } | 1984 | } |
1985 | else | ||
1986 | { | ||
1987 | newneighbours.Add(handler); | ||
1988 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
1989 | sp.AddNeighbourRegion(handler, agent.CapsPath); | ||
1990 | seeds.Add(handler, agent.CapsPath); | ||
1991 | } | ||
1992 | |||
1993 | cagents.Add(agent); | ||
1994 | } | ||
1995 | |||
1996 | //sp.DropOldNeighbours(previousRegionNeighbourHandles); | ||
1997 | foreach (ulong handle in previousRegionNeighbourHandles) | ||
1998 | { | ||
1999 | sp.RemoveNeighbourRegion(handle); | ||
2000 | Scene.CapsModule.DropChildSeed(sp.UUID, handle); | ||
2009 | } | 2001 | } |
2010 | 2002 | ||
2011 | /// Update all child agent with everyone's seeds | 2003 | /// Update all child agent with everyone's seeds |
@@ -2018,59 +2010,49 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2018 | { | 2010 | { |
2019 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); | 2011 | sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); |
2020 | } | 2012 | } |
2013 | |||
2021 | sp.KnownRegions = seeds; | 2014 | sp.KnownRegions = seeds; |
2022 | //avatar.Scene.DumpChildrenSeeds(avatar.UUID); | 2015 | //avatar.Scene.DumpChildrenSeeds(avatar.UUID); |
2023 | //avatar.DumpKnownRegions(); | 2016 | //avatar.DumpKnownRegions(); |
2024 | 2017 | ||
2025 | Util.FireAndForget(delegate | 2018 | Util.FireAndForget(delegate |
2026 | { | 2019 | { |
2027 | /// 5000 is BAD test | 2020 | Thread.Sleep(200); // the original delay that was at InformClientOfNeighbourAsync start |
2028 | Thread.Sleep(5000); // the original delay that was at InformClientOfNeighbourAsync start | ||
2029 | int count = 0; | 2021 | int count = 0; |
2030 | bool newAgent = false; | 2022 | bool newagent; |
2031 | 2023 | ||
2032 | foreach (GridRegion neighbour in neighbours) | 2024 | foreach (GridRegion neighbour in neighbours) |
2033 | { | 2025 | { |
2034 | //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); | 2026 | try |
2035 | // Don't do it if there's already an agent in that region | ||
2036 | if (newRegions.Contains(neighbour.RegionHandle)) | ||
2037 | newAgent = true; | ||
2038 | else | ||
2039 | newAgent = false; | ||
2040 | // continue; | ||
2041 | |||
2042 | if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) | ||
2043 | { | 2027 | { |
2044 | try | 2028 | newagent = newneighbours.Contains(neighbour.RegionHandle); |
2045 | { | 2029 | InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newagent); |
2046 | InformClientOfNeighbourAsync(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent); | 2030 | } |
2047 | } | ||
2048 | 2031 | ||
2049 | catch (ArgumentOutOfRangeException) | 2032 | catch (ArgumentOutOfRangeException) |
2050 | { | 2033 | { |
2051 | m_log.ErrorFormat( | 2034 | m_log.ErrorFormat( |
2052 | "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", | 2035 | "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbour list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", |
2053 | neighbour.ExternalHostName, | 2036 | neighbour.ExternalHostName, |
2054 | neighbour.RegionHandle, | 2037 | neighbour.RegionHandle, |
2038 | neighbour.RegionLocX, | ||
2039 | neighbour.RegionLocY); | ||
2040 | } | ||
2041 | catch (Exception e) | ||
2042 | { | ||
2043 | m_log.ErrorFormat( | ||
2044 | "[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", | ||
2045 | neighbour.ExternalHostName, | ||
2046 | neighbour.RegionHandle, | ||
2055 | neighbour.RegionLocX, | 2047 | neighbour.RegionLocX, |
2056 | neighbour.RegionLocY); | 2048 | neighbour.RegionLocY, |
2057 | } | 2049 | e); |
2058 | catch (Exception e) | 2050 | |
2059 | { | 2051 | // FIXME: Okay, even though we've failed, we're still going to throw the exception on, |
2060 | m_log.ErrorFormat( | 2052 | // since I don't know what will happen if we just let the client continue |
2061 | "[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", | 2053 | |
2062 | neighbour.ExternalHostName, | 2054 | // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. |
2063 | neighbour.RegionHandle, | 2055 | // throw e; |
2064 | neighbour.RegionLocX, | ||
2065 | neighbour.RegionLocY, | ||
2066 | e); | ||
2067 | |||
2068 | // FIXME: Okay, even though we've failed, we're still going to throw the exception on, | ||
2069 | // since I don't know what will happen if we just let the client continue | ||
2070 | |||
2071 | // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. | ||
2072 | // throw e; | ||
2073 | } | ||
2074 | } | 2056 | } |
2075 | count++; | 2057 | count++; |
2076 | } | 2058 | } |